-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmatrix_access.ts
46 lines (39 loc) · 962 Bytes
/
matrix_access.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import {
bridgeProviderConfig,
} from "./src/config";
import {
MatrixAuth,
} from "matrix-bot-sdk";
import inquirer from "inquirer";
const {
matrix: matrixConfig,
} = bridgeProviderConfig();
const {
homeserverUrl,
} = matrixConfig;
const auth = new MatrixAuth(homeserverUrl);
const questions = [{
type: "input",
name: "username",
message: "Username: ",
}, {
type: "password",
name: "password",
message: "Password: ",
}];
console.info(
"Get the AccessToken from Matrix",
`(homeserver: ${homeserverUrl || "undefined"})`,
"\n",
);
inquirer.prompt(questions).then(({username, password}) => {
console.info();
auth.passwordLogin(username, password).then((client) => {
console.info("AccessToken:", client.accessToken);
return client.getUserId();
}).then((userId) => {
console.info("User ID:", userId);
}).catch(() => {
console.error("Unauthorized");
});
});