separate login script
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 37s Details

This commit is contained in:
Ladd Hoffman 2024-04-24 14:04:29 -05:00
parent d3bc08dd24
commit 5d0266a390
4 changed files with 23 additions and 7 deletions

View File

@ -7,6 +7,7 @@ INFURA_API_KEY=
MATRIX_HOMESERVER_URL="https://matrix.dgov.io"
MATRIX_USER="forum-api"
MATRIX_PASSWORD=
MATRIX_ACCESS_TOKEN=
BOT_STORAGE_PATH="./data/bot-storage.json"
BOT_CRYPTO_STORAGE_PATH="./data/bot-crypto"
BOT_INSTANCE_ID=

View File

@ -4,7 +4,8 @@
"description": "",
"main": "src/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"login": "node scripts/matrix-login"
},
"author": "",
"license": "ISC",

View File

@ -0,0 +1,18 @@
const {
MatrixAuth,
} = require('matrix-bot-sdk');
const {
MATRIX_HOMESERVER_URL,
MATRIX_USER,
MATRIX_PASSWORD,
} = process.env;
const login = async () => {
console.log(`MATRIX_HOMESERVER_URL="${MATRIX_HOMESERVER_URL}"`);
const auth = new MatrixAuth(MATRIX_HOMESERVER_URL);
const client = await auth.passwordLogin(MATRIX_USER, MATRIX_PASSWORD);
console.log(`MATRIX_ACCESS_TOKEN="${client.accessToken}"`);
};
login();

View File

@ -1,6 +1,5 @@
const {
AutojoinRoomsMixin,
MatrixAuth,
MatrixClient,
RustSdkCryptoStorageProvider,
SimpleFsStorageProvider,
@ -11,8 +10,7 @@ const { appState, proposalEventIds } = require('./db');
const {
MATRIX_HOMESERVER_URL,
MATRIX_USER,
MATRIX_PASSWORD,
MATRIX_ACCESS_TOKEN,
BOT_STORAGE_PATH,
BOT_CRYPTO_STORAGE_PATH,
BOT_INSTANCE_ID,
@ -50,11 +48,9 @@ outboundQueue.pause();
const start = async () => {
console.log('MATRIX_HOMESERVER_URL:', MATRIX_HOMESERVER_URL);
const auth = new MatrixAuth(MATRIX_HOMESERVER_URL);
const authClient = await auth.passwordLogin(MATRIX_USER, MATRIX_PASSWORD);
client = new MatrixClient(
MATRIX_HOMESERVER_URL,
authClient.accessToken,
MATRIX_ACCESS_TOKEN,
storageProvider,
cryptoProvider,
);