import { MatrixAuth } from "matrix-bot-sdk"; import configMain from "./config.json" assert {type: "json"}; import config from "./logAuthToken.json" assert {type: "json"}; const homeserverUrl = configMain.homeserver; const username = config.username; const password = config.password; function configNotFound(name) { throw new Error(`ERROR: Config option "${name}" not found`); } if (!homeserverUrl) configNotFound("config.json => homeserver"); if (!username) configNotFound("logAuthToken.json => username"); if (!password) configNotFound("logAuthToken.json => password"); console.log("Access token: " + (await new MatrixAuth(homeserverUrl).passwordLogin(username, password)).accessToken);