Inspired by examples/browser
yarn build)
matrix.js, olm.js and olm.wasm
in directory lib/
python3 -m http.server) and go to it through your browser
aliceMatrixClient = await newMatrixClient("alice-"+randomHex());
await aliceMatrixClient.exportDevice();
await aliceMatrixClient.getAccessToken();
exportDevice and getAccessToken somewhere
(not in a JS variable as it will be destroyed when you refresh the page)
ALICE_ID
with the user ID of Alice (you can find it in the exported data)
bobMatrixClient = await newMatrixClient("bob-"+randomHex());
roomId = await bobMatrixClient.createEncryptedRoom([ALICE_ID]);
await bobMatrixClient.sendTextMessage('Hi Alice!', roomId);
aliceMatrixClient = await importMatrixClient(EXPORTED_DATA, ACCESS_TOKEN);