Created
October 20, 2021 02:20
-
-
Save ara4n/7edefcdb9dfaba627c9c4654dfd920ec to your computer and use it in GitHub Desktop.
megolm test jig
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import olm from "olm"; | |
import sdk from "matrix-js-sdk"; | |
import { MatrixEvent } from "matrix-js-sdk"; | |
import { LocalStorage } from "node-localstorage"; | |
global.Olm = olm; | |
const myUserId = "@matthewtest94:matrix.org"; | |
const myAccessToken = "secret"; | |
const matrixClient = sdk.createClient({ | |
baseUrl: "http://matrix.org", | |
accessToken: myAccessToken, | |
userId: myUserId, | |
deviceId: "JKGRJUVTBL", | |
sessionStore: new sdk.WebStorageSessionStore(new LocalStorage("./scratch")), | |
cryptoStore: new sdk.MemoryCryptoStore(), | |
}); | |
await matrixClient.initCrypto(); | |
await matrixClient.startClient(); | |
matrixClient.crypto.setGlobalErrorOnUnknownDevices(false); | |
matrixClient.once('sync', async function(state, prevState, res) { | |
if(state === 'PREPARED') { | |
console.log("prepared"); | |
const ct1 = await matrixClient.sendEvent( | |
"!BBYSlfSuRqYdhBZxjF:matrix.org", | |
"m.room.message", | |
{ | |
"body": "hello world", | |
} | |
); | |
} else { | |
console.log(state); | |
process.exit(1); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment