Doorbell works, added user friendliness for setup

This commit is contained in:
2024-08-16 00:31:24 +02:00
parent 0cef4671c5
commit a25190d742
6 changed files with 75 additions and 10 deletions

18
logAuthToken.mjs Normal file
View File

@@ -0,0 +1,18 @@
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);