diff --git a/.env b/.env index 3bf12f9..6ba43f6 100644 --- a/.env +++ b/.env @@ -1,3 +1,9 @@ +# Matrix Ancestor Quote Bot Configuration + +# IMPORTANT: Replace these values with your own! MATRIX_HOME_SERVER=https://matrix.org -MATRIX_ACCESS_TOKEN=YOUR_ACCESS_TOKEN_HERE +MATRIX_ACCESS_TOKEN=your_real_access_token_here BOT_COMMAND=!quote +DEBUG=false + +# If you want debug logging, set DEBUG=true diff --git a/.env.example b/.env.example index 4ae0de7..8992157 100644 --- a/.env.example +++ b/.env.example @@ -1,9 +1,9 @@ # Matrix Ancestor Quote Bot Configuration -# Replace these values with your own: +# IMPORTANT: Replace these values with your own! MATRIX_HOME_SERVER=https://matrix.org -MATRIX_ACCESS_TOKEN=your_access_token_here +MATRIX_ACCESS_TOKEN=your_real_access_token_here BOT_COMMAND=!quote -# Optional: Enable debug logging (set to false in production) +# If you want debug logging, set DEBUG=true DEBUG=false diff --git a/Dockerfile b/Dockerfile index d5d6b7b..d9523f8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,10 @@ -FROM node:18-alpine +FROM node:20-alpine WORKDIR /app -# Copy package files first for better layer caching COPY package*.json ./ - -# Install dependencies (including dotenv) RUN npm install -# Copy application source code COPY . . -# Expose port if needed (optional, Matrix uses websocket) -# EXPOSE 3000 - -# Run the bot (dotenv will auto-load from /app/.env or environment variables) CMD ["node", "index.js"] diff --git a/README.md b/README.md index d9ec583..30527ee 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Ancestor Quote Bot 🎃 +# 🎃 Ancestor Quote Bot A Matrix chatbot that responds to `!quote` commands with random quotes from Darkest Dungeons. @@ -7,7 +7,7 @@ A Matrix chatbot that responds to `!quote` commands with random quotes from Dark ```bash # 1. Update .env file (create from template) cp .env.example .env -# Edit .env with your MATRIX_ACCESS_TOKEN and MATRIX_HOME_SERVER +nano .env # Edit MATRIX_ACCESS_TOKEN and MATRIX_HOME_SERVER # 2. Build Docker image docker build -t ancestor-quote-bot . @@ -15,13 +15,13 @@ docker build -t ancestor-quote-bot . # 3. Run the bot docker run --rm \ -e MATRIX_HOME_SERVER=https://matrix.org \ - -e MATRIX_ACCESS_TOKEN=your_token_here \ + -e MATRIX_ACCESS_TOKEN=your_access_token_here \ ancestor-quote-bot ``` ## Deployment Options -### Option 1: Pass env vars via `docker run` (Recommended for Docker) +### Option A: Pass env vars via `docker run` (Recommended) ```bash docker run --rm \ -e MATRIX_HOME_SERVER=https://matrix.org \ @@ -30,22 +30,13 @@ docker run --rm \ ancestor-quote-bot ``` -### Option 2: Mount .env file directly +### Option B: Mount .env file directly ```bash docker run --rm \ -v $(pwd)/.env:/app/.env \ ancestor-quote-bot ``` -### Option 3: Use docker-compose.yml (Production) -```bash -docker compose up -d -# Or with custom env: -docker compose up -d \ - -e MATRIX_HOME_SERVER=https://matrix.org \ - -e MATRIX_ACCESS_TOKEN=your_access_token_here -``` - ## Configuration | Variable | Description | Default | @@ -54,15 +45,30 @@ docker compose up -d \ | `MATRIX_ACCESS_TOKEN` | Bot access token for authentication | REQUIRED | | `BOT_COMMAND` | Command trigger to request a quote | !quote | +## Getting an Access Token + +1. Go to [Matrix Registration API](https://matrix.org/docs/projects/registration/matrix-registration-api) +2. Or use your Matrix admin panel to create a bot account +3. Get the access token from your Matrix settings + ## How It Works 1. The bot connects to your Matrix homeserver using the provided access token 2. Once joined to a room, it listens for messages containing the trigger command 3. When triggered, it selects a random quote from `quotes.json` and replies instantly -## Getting an Access Token +## Usage -Use [this](https://matrix.org/docs/projects/registration/matrix-registration-api) or your Matrix admin panel to register a bot account. +```bash +# Invite the bot to a room: +# @ancestor-quote-bot:matrix.org (or your custom username) + +# In any Matrix room, type: +!quote + +# Bot responds with: +"Dispatch this thug in brutal fashion, that all may hear of your arrival!" +``` ## License diff --git a/index.js b/index.js index 115f638..1af2587 100644 --- a/index.js +++ b/index.js @@ -4,75 +4,79 @@ import fs from 'fs'; dotenv.config(); +console.log('🚀 Starting Ancestor Quote Bot...\n'); + const client = new MatrixClient({ accessToken: process.env.MATRIX_ACCESS_TOKEN, - matrix_homeserver: { - baseUrl: process.env.MATRIX_HOME_SERVER, - }, + baseUrl: process.env.MATRIX_HOME_SERVER, }); function loadQuotes() { - return new Promise((resolve) => { - setTimeout(() => { - const quotesFile = './quotes.json'; - if (fs.existsSync(quotesFile)) { - try { - resolve(JSON.parse(fs.readFileSync(quotesFile, 'utf8'))); - } catch (err) { - resolve([]); - } - } else { - resolve([]); - } - }, 0); - }); + try { + const quotesFile = './quotes.json'; + if (fs.existsSync(quotesFile)) { + return JSON.parse(fs.readFileSync(quotesFile, 'utf8')); + } + } catch (err) { + console.error('Error loading quotes:', err.message); + } + return []; } -loadQuotes().then((quotes) => { +(async () => { + const quotes = loadQuotes(); + if (quotes.length === 0) { - console.error('No quotes found! Please ensure quotes.json is present.'); + console.error('❌ No quotes found! Please ensure quotes.json is present.'); process.exit(1); } - console.log('Bot initialized successfully'); + console.log(`✅ Loaded ${quotes.length} Ancestor quotes`); - let joinedRooms = new Set(); + try { + await client.startClient(); + console.log('✅ Client initialized\n'); + + let joinedRooms = new Set(); + let lastSentMessage = null; - client.on('RoomMember#joined', (member) => { - const room = member.room; - if (!joinedRooms.has(room.roomId)) { - joinedRooms.add(room.roomId); - console.log(`Joined room: ${room.roomId}`); - - room.on('EventMessage', async (event) => { - const messageContent = event.getContent(); + client.on('RoomMember#joined', (member) => { + const room = member.room; + if (!joinedRooms.has(room.roomId)) { + joinedRooms.add(room.roomId); + console.log(`✅ Joined: ${room.roomId}`); - if (!messageContent || !messageContent.body) return; - - const body = messageContent.body.toLowerCase(); - const botCommand = (process.env.BOT_COMMAND || '!quote').toLowerCase(); - - if (body.includes(botCommand)) { - const randomQuote = quotes[Math.floor(Math.random() * quotes.length)]; - try { - await room.sendMessage(randomQuote); - console.log(`Sent quote to ${room.roomId}`); - } catch (err) { - console.error('Failed to send message:', err.message); + room.on('EventMessage', async (event) => { + const content = event.getContent(); + if (!content || !content.body) return; + + const body = content.body.toLowerCase(); + const cmd = (process.env.BOT_COMMAND || '!quote').toLowerCase(); + + if (body.includes(cmd)) { + if (!lastSentMessage || Date.now() - lastSentMessage > 300) { + const quote = quotes[Math.floor(Math.random() * quotes.length)]; + await room.sendMessage(quote); + console.log(`🎃 Quote: ${quote}`); + lastSentMessage = Date.now(); + } } - } - }); - - room.on('RoomMember#left', () => { - joinedRooms.delete(room.roomId); - console.log(`Left room: ${room.roomId}`); - }); - } - }); + }); - // Keep process alive with periodic heartbeat - setInterval(() => {}, 1000 * 60); // Heartbeat every minute - console.log('Bot is running. Press Ctrl+C to exit.'); -}).catch(err => { - console.error('Failed to load quotes:', err.message); -}); + room.on('RoomMember#left', () => { + joinedRooms.delete(room.roomId); + console.log(`ℹ️ Left: ${room.roomId}`); + }); + } + }); + + console.log('🤖 Bot is running!'); + console.log(' Invite to a Matrix room and type !quote to get an Ancestor quote.\n'); + + } catch (err) { + console.error('Fatal error:', err.message); + process.exit(1); + } + + setInterval(() => {}, 60000); +})(); diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index 6952f46..991e772 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -1,22 +1,25 @@ { - "name": "ancestor-bot", + "name": "ancestor-quote-bot", "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "node_modules/@babel/runtime": { - "version": "8.0.5", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-8.0.5.tgz", - "integrity": "sha512-7NK+Lz3spQ52XsUGTxIEVU4jYN2/dIaX8sTxRFAUtYmttYZnVh3aehiihv+/Gb7+duMNHl2OrFcBQRyOHScxpg==", - "license": "MIT" + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.7.tgz", + "integrity": "sha512-Nq8OhGWiZIZGV6hLHoyAKLLcJihP/xFeBMGJoUrxTX2psI8dCifzLhZISFb+VWS3wFMRDmCGw5R+dOySCqPLhw==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } }, "node_modules/@matrix-org/matrix-sdk-crypto-wasm": { - "version": "18.8.0", - "resolved": "https://registry.npmjs.org/@matrix-org/matrix-sdk-crypto-wasm/-/matrix-sdk-crypto-wasm-18.8.0.tgz", - "integrity": "sha512-J+bYzUqtkYSrIUbDT8Razf9F1gzlpC94qeC5LQlr9QmjrzyaErwlV9v7S+gtSOeDvJCdfP8ebEDaANHiVLCYQg==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@matrix-org/matrix-sdk-crypto-wasm/-/matrix-sdk-crypto-wasm-1.3.0.tgz", + "integrity": "sha512-vQ5PVppKu1PY7xy7QDw+RJLYLGFKhJyxLqjXHr0uEUJwfvz2IH2njTLXzrz77dOo9qacxJ9/YNOTe0Hl+98N0A==", "license": "Apache-2.0", "engines": { - "node": ">= 18" + "node": ">= 10" } }, "node_modules/@types/events": { @@ -25,6 +28,12 @@ "integrity": "sha512-trOc4AAUThEz9hapPtSd7wf5tiQKvTtu5b371UxXdTuqzIh0ArcRspRP0i0Viu+LXstIQ1z96t1nsPxT9ol01g==", "license": "MIT" }, + "node_modules/@types/retry": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.0.tgz", + "integrity": "sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==", + "license": "MIT" + }, "node_modules/another-json": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/another-json/-/another-json-0.2.0.tgz", @@ -32,33 +41,36 @@ "license": "Apache-2.0" }, "node_modules/base-x": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/base-x/-/base-x-5.0.1.tgz", - "integrity": "sha512-M7uio8Zt++eg3jPj+rHMfCC+IuygQHHCOU+IYsVtik6FWjuYpVt/+MRKcgsAMHh8mMFAwnB+Bs+mTrFiXjMzKg==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/base-x/-/base-x-4.0.1.tgz", + "integrity": "sha512-uAZ8x6r6S3aUM9rbHGVOIsR15U/ZSc82b3ymnCPsT45Gk1DDvhDPdIgB5MrhirZWt+5K0EEPQH985kNqZgNPFw==", "license": "MIT" }, "node_modules/bs58": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/bs58/-/bs58-6.0.0.tgz", - "integrity": "sha512-PD0wEnEYg6ijszw/u8s+iI3H17cTymlrwkKhDhPZq+Sokl3AU4htyBFTjAeNAlCCmg0f53g6ih3jATyCKftTfw==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/bs58/-/bs58-5.0.0.tgz", + "integrity": "sha512-r+ihvQJvahgYT50JD05dyJNKlmmSlMoOGwn1lCcEzanPglg7TxYjioQUYehQ9mAR/+hOSd2jRc/Z2y5UxBymvQ==", "license": "MIT", "dependencies": { - "base-x": "^5.0.0" + "base-x": "^4.0.0" } }, "node_modules/content-type": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz", - "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", "license": "MIT", "engines": { - "node": ">=18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" + "node": ">= 0.6" } }, + "node_modules/crypto-js": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz", + "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==", + "deprecated": "Active development of CryptoJS has been discontinued. This library is no longer maintained.", + "license": "MIT" + }, "node_modules/dotenv": { "version": "17.4.2", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.4.2.tgz", @@ -80,17 +92,11 @@ "node": ">=0.8.x" } }, - "node_modules/is-network-error": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/is-network-error/-/is-network-error-1.3.2.tgz", - "integrity": "sha512-PhBY86zaxNZUuWP6h13Vu5oFe0XY6/UlKzQnYFELzGVHygP3MxmvTfYSG7GN3aIab/iWudSMgjSnG9Dq+nHrgA==", - "license": "MIT", - "engines": { - "node": ">=16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } + "node_modules/jwt-decode": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-3.1.2.tgz", + "integrity": "sha512-UfpWE/VZn0iP50d8cz9NrZLM9lSWhcJ+0Gt/nm4by88UL+J1SiKN8/5dkjMmbEzwL2CAe+67GsegCbIKtbp75A==", + "license": "MIT" }, "node_modules/loglevel": { "version": "1.9.2", @@ -112,25 +118,28 @@ "license": "Apache-2.0" }, "node_modules/matrix-js-sdk": { - "version": "42.3.0", - "resolved": "https://registry.npmjs.org/matrix-js-sdk/-/matrix-js-sdk-42.3.0.tgz", - "integrity": "sha512-jXXFLlaA25zQ2oxXCgbAEubGC8KpF8OabSf387W0RXfkwqhNXEbU+veeUaZMT+bCbyE5nDxkN3iBy038VbntQg==", + "version": "27.1.0", + "resolved": "https://registry.npmjs.org/matrix-js-sdk/-/matrix-js-sdk-27.1.0.tgz", + "integrity": "sha512-ge1P1iNit0demKA11YzXt4QdsBHObrPdIVdecutFX7OwOBat6BC1F6AxsvPZQPDqnT5oelJt55ym4U7i8G9IRg==", "license": "Apache-2.0", "dependencies": { - "@babel/runtime": "^8.0.0", - "@matrix-org/matrix-sdk-crypto-wasm": "^18.4.0", + "@babel/runtime": "^7.12.5", + "@matrix-org/matrix-sdk-crypto-wasm": "^1.1.0", "another-json": "^0.2.0", - "bs58": "^6.0.0", - "content-type": "^2.0.0", - "loglevel": "^1.9.2", + "bs58": "^5.0.0", + "content-type": "^1.0.4", + "jwt-decode": "^3.1.2", + "loglevel": "^1.7.1", "matrix-events-sdk": "0.0.1", - "matrix-widget-api": "^1.18.0", - "p-retry": "8", - "sdp-transform": "^3.0.0", - "unhomoglyph": "^1.0.6" + "matrix-widget-api": "^1.3.1", + "oidc-client-ts": "^2.2.4", + "p-retry": "4", + "sdp-transform": "^2.14.1", + "unhomoglyph": "^1.0.6", + "uuid": "9" }, "engines": { - "node": ">=22.0.0" + "node": ">=18.0.0" } }, "node_modules/matrix-widget-api": { @@ -143,25 +152,45 @@ "events": "^3.2.0" } }, - "node_modules/p-retry": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/p-retry/-/p-retry-8.0.1.tgz", - "integrity": "sha512-NAigyu8hfvJe7MsS18mnc4is0MZtau3QMdBklaJKK23oBQb6occO3UPM3vHmTckW8KhfyjMZaUOqdTFEYliHgg==", - "license": "MIT", + "node_modules/oidc-client-ts": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/oidc-client-ts/-/oidc-client-ts-2.5.0.tgz", + "integrity": "sha512-JZ/Sp+AoML4sBWCn8ShAjnIMKx3GXwU/8sQY2btRPOUS8kBZltC2dFqOdN5Mimc4g7oVGSTC/bVDBviYcuud9g==", + "license": "Apache-2.0", "dependencies": { - "is-network-error": "^1.3.0" + "crypto-js": "^4.2.0", + "jwt-decode": "^3.1.2" }, "engines": { - "node": ">=22" + "node": ">=12.13.0" + } + }, + "node_modules/p-retry": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/p-retry/-/p-retry-4.6.2.tgz", + "integrity": "sha512-312Id396EbJdvRONlngUx0NydfrIQ5lsYu0znKVUzVvArzEIt08V1qhtyESbGVd1FGX7UKtiFp5uwKZdM8wIuQ==", + "license": "MIT", + "dependencies": { + "@types/retry": "0.12.0", + "retry": "^0.13.1" }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "engines": { + "node": ">=8" + } + }, + "node_modules/retry": { + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/retry/-/retry-0.13.1.tgz", + "integrity": "sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg==", + "license": "MIT", + "engines": { + "node": ">= 4" } }, "node_modules/sdp-transform": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/sdp-transform/-/sdp-transform-3.0.0.tgz", - "integrity": "sha512-gfYVRGxjHkGF2NPeUWHw5u6T/KGFtS5/drPms73gaSuMaVHKCY3lpLnGDfswVQO0kddeePoti09AwhYP4zA8dQ==", + "version": "2.15.0", + "resolved": "https://registry.npmjs.org/sdp-transform/-/sdp-transform-2.15.0.tgz", + "integrity": "sha512-KrOH82c/W+GYQ0LHqtr3caRpM3ITglq3ljGUIb8LTki7ByacJZ9z+piSGiwZDsRyhQbYBOBJgr2k6X4BZXi3Kw==", "license": "MIT", "bin": { "sdp-verify": "checker.js" @@ -172,6 +201,20 @@ "resolved": "https://registry.npmjs.org/unhomoglyph/-/unhomoglyph-1.0.6.tgz", "integrity": "sha512-7uvcWI3hWshSADBu4JpnyYbTVc7YlhF5GDW/oPD5AxIxl34k4wXR3WDkPnzLxkN32LiTCTKMQLtKVZiwki3zGg==", "license": "MIT" + }, + "node_modules/uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "deprecated": "uuid@10 and below is no longer supported. For ESM codebases, update to uuid@latest. For CommonJS codebases, use uuid@11 (but be aware this version will likely be deprecated in 2028).", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" + } } } } diff --git a/node_modules/@babel/runtime/package.json b/node_modules/@babel/runtime/package.json index 150389b..0f7db7f 100644 --- a/node_modules/@babel/runtime/package.json +++ b/node_modules/@babel/runtime/package.json @@ -1,6 +1,6 @@ { "name": "@babel/runtime", - "version": "8.0.5", + "version": "7.29.7", "description": "babel's modular runtime helpers", "license": "MIT", "publishConfig": { @@ -13,474 +13,1095 @@ }, "homepage": "https://babel.dev/docs/en/next/babel-runtime", "author": "The Babel Team (https://babel.dev/team)", - "sideEffects": false, "exports": { - "./helpers/OverloadYield": { - "node": "./helpers/OverloadYield.js", - "import": "./helpers/esm/OverloadYield.js", - "default": "./helpers/OverloadYield.js" - }, - "./helpers/applyDecoratedDescriptor": { - "node": "./helpers/applyDecoratedDescriptor.js", - "import": "./helpers/esm/applyDecoratedDescriptor.js", - "default": "./helpers/applyDecoratedDescriptor.js" - }, - "./helpers/applyDecs2311": { - "node": "./helpers/applyDecs2311.js", - "import": "./helpers/esm/applyDecs2311.js", - "default": "./helpers/applyDecs2311.js" - }, - "./helpers/arrayLikeToArray": { - "node": "./helpers/arrayLikeToArray.js", - "import": "./helpers/esm/arrayLikeToArray.js", - "default": "./helpers/arrayLikeToArray.js" - }, - "./helpers/arrayWithHoles": { - "node": "./helpers/arrayWithHoles.js", - "import": "./helpers/esm/arrayWithHoles.js", - "default": "./helpers/arrayWithHoles.js" - }, - "./helpers/arrayWithoutHoles": { - "node": "./helpers/arrayWithoutHoles.js", - "import": "./helpers/esm/arrayWithoutHoles.js", - "default": "./helpers/arrayWithoutHoles.js" - }, - "./helpers/assertClassBrand": { - "node": "./helpers/assertClassBrand.js", - "import": "./helpers/esm/assertClassBrand.js", - "default": "./helpers/assertClassBrand.js" - }, - "./helpers/assertThisInitialized": { - "node": "./helpers/assertThisInitialized.js", - "import": "./helpers/esm/assertThisInitialized.js", - "default": "./helpers/assertThisInitialized.js" - }, - "./helpers/asyncGeneratorDelegate": { - "node": "./helpers/asyncGeneratorDelegate.js", - "import": "./helpers/esm/asyncGeneratorDelegate.js", - "default": "./helpers/asyncGeneratorDelegate.js" - }, - "./helpers/asyncIterator": { - "node": "./helpers/asyncIterator.js", - "import": "./helpers/esm/asyncIterator.js", - "default": "./helpers/asyncIterator.js" - }, - "./helpers/asyncToGenerator": { - "node": "./helpers/asyncToGenerator.js", - "import": "./helpers/esm/asyncToGenerator.js", - "default": "./helpers/asyncToGenerator.js" - }, - "./helpers/awaitAsyncGenerator": { - "node": "./helpers/awaitAsyncGenerator.js", - "import": "./helpers/esm/awaitAsyncGenerator.js", - "default": "./helpers/awaitAsyncGenerator.js" - }, - "./helpers/callSuper": { - "node": "./helpers/callSuper.js", - "import": "./helpers/esm/callSuper.js", - "default": "./helpers/callSuper.js" - }, - "./helpers/checkInRHS": { - "node": "./helpers/checkInRHS.js", - "import": "./helpers/esm/checkInRHS.js", - "default": "./helpers/checkInRHS.js" - }, - "./helpers/checkPrivateRedeclaration": { - "node": "./helpers/checkPrivateRedeclaration.js", - "import": "./helpers/esm/checkPrivateRedeclaration.js", - "default": "./helpers/checkPrivateRedeclaration.js" - }, - "./helpers/classCallCheck": { - "node": "./helpers/classCallCheck.js", - "import": "./helpers/esm/classCallCheck.js", - "default": "./helpers/classCallCheck.js" - }, - "./helpers/classNameTDZError": { - "node": "./helpers/classNameTDZError.js", - "import": "./helpers/esm/classNameTDZError.js", - "default": "./helpers/classNameTDZError.js" - }, - "./helpers/classPrivateFieldGet2": { - "node": "./helpers/classPrivateFieldGet2.js", - "import": "./helpers/esm/classPrivateFieldGet2.js", - "default": "./helpers/classPrivateFieldGet2.js" - }, - "./helpers/classPrivateFieldInitSpec": { - "node": "./helpers/classPrivateFieldInitSpec.js", - "import": "./helpers/esm/classPrivateFieldInitSpec.js", - "default": "./helpers/classPrivateFieldInitSpec.js" - }, - "./helpers/classPrivateFieldLooseBase": { - "node": "./helpers/classPrivateFieldLooseBase.js", - "import": "./helpers/esm/classPrivateFieldLooseBase.js", - "default": "./helpers/classPrivateFieldLooseBase.js" - }, - "./helpers/classPrivateFieldLooseKey": { - "node": "./helpers/classPrivateFieldLooseKey.js", - "import": "./helpers/esm/classPrivateFieldLooseKey.js", - "default": "./helpers/classPrivateFieldLooseKey.js" - }, - "./helpers/classPrivateFieldSet2": { - "node": "./helpers/classPrivateFieldSet2.js", - "import": "./helpers/esm/classPrivateFieldSet2.js", - "default": "./helpers/classPrivateFieldSet2.js" - }, - "./helpers/classPrivateGetter": { - "node": "./helpers/classPrivateGetter.js", - "import": "./helpers/esm/classPrivateGetter.js", - "default": "./helpers/classPrivateGetter.js" - }, - "./helpers/classPrivateMethodInitSpec": { - "node": "./helpers/classPrivateMethodInitSpec.js", - "import": "./helpers/esm/classPrivateMethodInitSpec.js", - "default": "./helpers/classPrivateMethodInitSpec.js" - }, - "./helpers/classPrivateSetter": { - "node": "./helpers/classPrivateSetter.js", - "import": "./helpers/esm/classPrivateSetter.js", - "default": "./helpers/classPrivateSetter.js" - }, - "./helpers/classStaticPrivateMethodGet": { - "node": "./helpers/classStaticPrivateMethodGet.js", - "import": "./helpers/esm/classStaticPrivateMethodGet.js", - "default": "./helpers/classStaticPrivateMethodGet.js" - }, - "./helpers/construct": { - "node": "./helpers/construct.js", - "import": "./helpers/esm/construct.js", - "default": "./helpers/construct.js" - }, - "./helpers/createClass": { - "node": "./helpers/createClass.js", - "import": "./helpers/esm/createClass.js", - "default": "./helpers/createClass.js" - }, - "./helpers/createForOfIteratorHelper": { - "node": "./helpers/createForOfIteratorHelper.js", - "import": "./helpers/esm/createForOfIteratorHelper.js", - "default": "./helpers/createForOfIteratorHelper.js" - }, - "./helpers/createForOfIteratorHelperLoose": { - "node": "./helpers/createForOfIteratorHelperLoose.js", - "import": "./helpers/esm/createForOfIteratorHelperLoose.js", - "default": "./helpers/createForOfIteratorHelperLoose.js" - }, - "./helpers/createSuper": { - "node": "./helpers/createSuper.js", - "import": "./helpers/esm/createSuper.js", - "default": "./helpers/createSuper.js" - }, - "./helpers/defaults": { - "node": "./helpers/defaults.js", - "import": "./helpers/esm/defaults.js", - "default": "./helpers/defaults.js" - }, - "./helpers/defineAccessor": { - "node": "./helpers/defineAccessor.js", - "import": "./helpers/esm/defineAccessor.js", - "default": "./helpers/defineAccessor.js" - }, - "./helpers/defineProperty": { - "node": "./helpers/defineProperty.js", - "import": "./helpers/esm/defineProperty.js", - "default": "./helpers/defineProperty.js" - }, - "./helpers/extends": { - "node": "./helpers/extends.js", - "import": "./helpers/esm/extends.js", - "default": "./helpers/extends.js" - }, - "./helpers/get": { - "node": "./helpers/get.js", - "import": "./helpers/esm/get.js", - "default": "./helpers/get.js" - }, - "./helpers/getPrototypeOf": { - "node": "./helpers/getPrototypeOf.js", - "import": "./helpers/esm/getPrototypeOf.js", - "default": "./helpers/getPrototypeOf.js" - }, - "./helpers/identity": { - "node": "./helpers/identity.js", - "import": "./helpers/esm/identity.js", - "default": "./helpers/identity.js" - }, - "./helpers/importDeferProxy": { - "node": "./helpers/importDeferProxy.js", - "import": "./helpers/esm/importDeferProxy.js", - "default": "./helpers/importDeferProxy.js" - }, - "./helpers/inherits": { - "node": "./helpers/inherits.js", - "import": "./helpers/esm/inherits.js", - "default": "./helpers/inherits.js" - }, - "./helpers/inheritsLoose": { - "node": "./helpers/inheritsLoose.js", - "import": "./helpers/esm/inheritsLoose.js", - "default": "./helpers/inheritsLoose.js" - }, - "./helpers/initializerDefineProperty": { - "node": "./helpers/initializerDefineProperty.js", - "import": "./helpers/esm/initializerDefineProperty.js", - "default": "./helpers/initializerDefineProperty.js" - }, - "./helpers/initializerWarningHelper": { - "node": "./helpers/initializerWarningHelper.js", - "import": "./helpers/esm/initializerWarningHelper.js", - "default": "./helpers/initializerWarningHelper.js" - }, - "./helpers/instanceof": { - "node": "./helpers/instanceof.js", - "import": "./helpers/esm/instanceof.js", - "default": "./helpers/instanceof.js" - }, - "./helpers/interopRequireDefault": { - "node": "./helpers/interopRequireDefault.js", - "import": "./helpers/esm/interopRequireDefault.js", - "default": "./helpers/interopRequireDefault.js" - }, - "./helpers/interopRequireWildcard": { - "node": "./helpers/interopRequireWildcard.js", - "import": "./helpers/esm/interopRequireWildcard.js", - "default": "./helpers/interopRequireWildcard.js" - }, - "./helpers/isNativeFunction": { - "node": "./helpers/isNativeFunction.js", - "import": "./helpers/esm/isNativeFunction.js", - "default": "./helpers/isNativeFunction.js" - }, - "./helpers/isNativeReflectConstruct": { - "node": "./helpers/isNativeReflectConstruct.js", - "import": "./helpers/esm/isNativeReflectConstruct.js", - "default": "./helpers/isNativeReflectConstruct.js" - }, - "./helpers/iterableToArray": { - "node": "./helpers/iterableToArray.js", - "import": "./helpers/esm/iterableToArray.js", - "default": "./helpers/iterableToArray.js" - }, - "./helpers/iterableToArrayLimit": { - "node": "./helpers/iterableToArrayLimit.js", - "import": "./helpers/esm/iterableToArrayLimit.js", - "default": "./helpers/iterableToArrayLimit.js" - }, - "./helpers/jsx": { - "node": "./helpers/jsx.js", - "import": "./helpers/esm/jsx.js", - "default": "./helpers/jsx.js" - }, - "./helpers/maybeArrayLike": { - "node": "./helpers/maybeArrayLike.js", - "import": "./helpers/esm/maybeArrayLike.js", - "default": "./helpers/maybeArrayLike.js" - }, - "./helpers/newArrowCheck": { - "node": "./helpers/newArrowCheck.js", - "import": "./helpers/esm/newArrowCheck.js", - "default": "./helpers/newArrowCheck.js" - }, - "./helpers/nonIterableRest": { - "node": "./helpers/nonIterableRest.js", - "import": "./helpers/esm/nonIterableRest.js", - "default": "./helpers/nonIterableRest.js" - }, - "./helpers/nonIterableSpread": { - "node": "./helpers/nonIterableSpread.js", - "import": "./helpers/esm/nonIterableSpread.js", - "default": "./helpers/nonIterableSpread.js" - }, - "./helpers/nullishReceiverError": { - "node": "./helpers/nullishReceiverError.js", - "import": "./helpers/esm/nullishReceiverError.js", - "default": "./helpers/nullishReceiverError.js" - }, - "./helpers/objectDestructuringEmpty": { - "node": "./helpers/objectDestructuringEmpty.js", - "import": "./helpers/esm/objectDestructuringEmpty.js", - "default": "./helpers/objectDestructuringEmpty.js" - }, - "./helpers/objectSpread2": { - "node": "./helpers/objectSpread2.js", - "import": "./helpers/esm/objectSpread2.js", - "default": "./helpers/objectSpread2.js" - }, - "./helpers/objectWithoutProperties": { - "node": "./helpers/objectWithoutProperties.js", - "import": "./helpers/esm/objectWithoutProperties.js", - "default": "./helpers/objectWithoutProperties.js" - }, - "./helpers/objectWithoutPropertiesLoose": { - "node": "./helpers/objectWithoutPropertiesLoose.js", - "import": "./helpers/esm/objectWithoutPropertiesLoose.js", - "default": "./helpers/objectWithoutPropertiesLoose.js" - }, - "./helpers/possibleConstructorReturn": { - "node": "./helpers/possibleConstructorReturn.js", - "import": "./helpers/esm/possibleConstructorReturn.js", - "default": "./helpers/possibleConstructorReturn.js" - }, - "./helpers/readOnlyError": { - "node": "./helpers/readOnlyError.js", - "import": "./helpers/esm/readOnlyError.js", - "default": "./helpers/readOnlyError.js" - }, - "./helpers/regenerator": { - "node": "./helpers/regenerator.js", - "import": "./helpers/esm/regenerator.js", - "default": "./helpers/regenerator.js" - }, - "./helpers/regeneratorAsync": { - "node": "./helpers/regeneratorAsync.js", - "import": "./helpers/esm/regeneratorAsync.js", - "default": "./helpers/regeneratorAsync.js" - }, - "./helpers/regeneratorAsyncGen": { - "node": "./helpers/regeneratorAsyncGen.js", - "import": "./helpers/esm/regeneratorAsyncGen.js", - "default": "./helpers/regeneratorAsyncGen.js" - }, - "./helpers/regeneratorKeys": { - "node": "./helpers/regeneratorKeys.js", - "import": "./helpers/esm/regeneratorKeys.js", - "default": "./helpers/regeneratorKeys.js" - }, - "./helpers/regeneratorValues": { - "node": "./helpers/regeneratorValues.js", - "import": "./helpers/esm/regeneratorValues.js", - "default": "./helpers/regeneratorValues.js" - }, - "./helpers/set": { - "node": "./helpers/set.js", - "import": "./helpers/esm/set.js", - "default": "./helpers/set.js" - }, - "./helpers/setFunctionName": { - "node": "./helpers/setFunctionName.js", - "import": "./helpers/esm/setFunctionName.js", - "default": "./helpers/setFunctionName.js" - }, - "./helpers/setPrototypeOf": { - "node": "./helpers/setPrototypeOf.js", - "import": "./helpers/esm/setPrototypeOf.js", - "default": "./helpers/setPrototypeOf.js" - }, - "./helpers/skipFirstGeneratorNext": { - "node": "./helpers/skipFirstGeneratorNext.js", - "import": "./helpers/esm/skipFirstGeneratorNext.js", - "default": "./helpers/skipFirstGeneratorNext.js" - }, - "./helpers/slicedToArray": { - "node": "./helpers/slicedToArray.js", - "import": "./helpers/esm/slicedToArray.js", - "default": "./helpers/slicedToArray.js" - }, - "./helpers/superPropBase": { - "node": "./helpers/superPropBase.js", - "import": "./helpers/esm/superPropBase.js", - "default": "./helpers/superPropBase.js" - }, - "./helpers/superPropGet": { - "node": "./helpers/superPropGet.js", - "import": "./helpers/esm/superPropGet.js", - "default": "./helpers/superPropGet.js" - }, - "./helpers/superPropSet": { - "node": "./helpers/superPropSet.js", - "import": "./helpers/esm/superPropSet.js", - "default": "./helpers/superPropSet.js" - }, - "./helpers/taggedTemplateLiteral": { - "node": "./helpers/taggedTemplateLiteral.js", - "import": "./helpers/esm/taggedTemplateLiteral.js", - "default": "./helpers/taggedTemplateLiteral.js" - }, - "./helpers/taggedTemplateLiteralLoose": { - "node": "./helpers/taggedTemplateLiteralLoose.js", - "import": "./helpers/esm/taggedTemplateLiteralLoose.js", - "default": "./helpers/taggedTemplateLiteralLoose.js" - }, - "./helpers/tdz": { - "node": "./helpers/tdz.js", - "import": "./helpers/esm/tdz.js", - "default": "./helpers/tdz.js" - }, - "./helpers/temporalRef": { - "node": "./helpers/temporalRef.js", - "import": "./helpers/esm/temporalRef.js", - "default": "./helpers/temporalRef.js" - }, - "./helpers/temporalUndefined": { - "node": "./helpers/temporalUndefined.js", - "import": "./helpers/esm/temporalUndefined.js", - "default": "./helpers/temporalUndefined.js" - }, - "./helpers/toArray": { - "node": "./helpers/toArray.js", - "import": "./helpers/esm/toArray.js", - "default": "./helpers/toArray.js" - }, - "./helpers/toConsumableArray": { - "node": "./helpers/toConsumableArray.js", - "import": "./helpers/esm/toConsumableArray.js", - "default": "./helpers/toConsumableArray.js" - }, - "./helpers/toPrimitive": { - "node": "./helpers/toPrimitive.js", - "import": "./helpers/esm/toPrimitive.js", - "default": "./helpers/toPrimitive.js" - }, - "./helpers/toPropertyKey": { - "node": "./helpers/toPropertyKey.js", - "import": "./helpers/esm/toPropertyKey.js", - "default": "./helpers/toPropertyKey.js" - }, - "./helpers/toSetter": { - "node": "./helpers/toSetter.js", - "import": "./helpers/esm/toSetter.js", - "default": "./helpers/toSetter.js" - }, - "./helpers/tsRewriteRelativeImportExtensions": { - "node": "./helpers/tsRewriteRelativeImportExtensions.js", - "import": "./helpers/esm/tsRewriteRelativeImportExtensions.js", - "default": "./helpers/tsRewriteRelativeImportExtensions.js" - }, - "./helpers/typeof": { - "node": "./helpers/typeof.js", - "import": "./helpers/esm/typeof.js", - "default": "./helpers/typeof.js" - }, - "./helpers/unsupportedIterableToArray": { - "node": "./helpers/unsupportedIterableToArray.js", - "import": "./helpers/esm/unsupportedIterableToArray.js", - "default": "./helpers/unsupportedIterableToArray.js" - }, - "./helpers/usingCtx": { - "node": "./helpers/usingCtx.js", - "import": "./helpers/esm/usingCtx.js", - "default": "./helpers/usingCtx.js" - }, - "./helpers/wrapAsyncGenerator": { - "node": "./helpers/wrapAsyncGenerator.js", - "import": "./helpers/esm/wrapAsyncGenerator.js", - "default": "./helpers/wrapAsyncGenerator.js" - }, - "./helpers/wrapNativeSuper": { - "node": "./helpers/wrapNativeSuper.js", - "import": "./helpers/esm/wrapNativeSuper.js", - "default": "./helpers/wrapNativeSuper.js" - }, - "./helpers/wrapRegExp": { - "node": "./helpers/wrapRegExp.js", - "import": "./helpers/esm/wrapRegExp.js", - "default": "./helpers/wrapRegExp.js" - }, - "./helpers/writeOnlyError": { - "node": "./helpers/writeOnlyError.js", - "import": "./helpers/esm/writeOnlyError.js", - "default": "./helpers/writeOnlyError.js" - }, - "./package.json": "./package.json" + "./helpers/OverloadYield": [ + { + "node": "./helpers/OverloadYield.js", + "import": "./helpers/esm/OverloadYield.js", + "default": "./helpers/OverloadYield.js" + }, + "./helpers/OverloadYield.js" + ], + "./helpers/esm/OverloadYield": "./helpers/esm/OverloadYield.js", + "./helpers/applyDecoratedDescriptor": [ + { + "node": "./helpers/applyDecoratedDescriptor.js", + "import": "./helpers/esm/applyDecoratedDescriptor.js", + "default": "./helpers/applyDecoratedDescriptor.js" + }, + "./helpers/applyDecoratedDescriptor.js" + ], + "./helpers/esm/applyDecoratedDescriptor": "./helpers/esm/applyDecoratedDescriptor.js", + "./helpers/applyDecs2311": [ + { + "node": "./helpers/applyDecs2311.js", + "import": "./helpers/esm/applyDecs2311.js", + "default": "./helpers/applyDecs2311.js" + }, + "./helpers/applyDecs2311.js" + ], + "./helpers/esm/applyDecs2311": "./helpers/esm/applyDecs2311.js", + "./helpers/arrayLikeToArray": [ + { + "node": "./helpers/arrayLikeToArray.js", + "import": "./helpers/esm/arrayLikeToArray.js", + "default": "./helpers/arrayLikeToArray.js" + }, + "./helpers/arrayLikeToArray.js" + ], + "./helpers/esm/arrayLikeToArray": "./helpers/esm/arrayLikeToArray.js", + "./helpers/arrayWithHoles": [ + { + "node": "./helpers/arrayWithHoles.js", + "import": "./helpers/esm/arrayWithHoles.js", + "default": "./helpers/arrayWithHoles.js" + }, + "./helpers/arrayWithHoles.js" + ], + "./helpers/esm/arrayWithHoles": "./helpers/esm/arrayWithHoles.js", + "./helpers/arrayWithoutHoles": [ + { + "node": "./helpers/arrayWithoutHoles.js", + "import": "./helpers/esm/arrayWithoutHoles.js", + "default": "./helpers/arrayWithoutHoles.js" + }, + "./helpers/arrayWithoutHoles.js" + ], + "./helpers/esm/arrayWithoutHoles": "./helpers/esm/arrayWithoutHoles.js", + "./helpers/assertClassBrand": [ + { + "node": "./helpers/assertClassBrand.js", + "import": "./helpers/esm/assertClassBrand.js", + "default": "./helpers/assertClassBrand.js" + }, + "./helpers/assertClassBrand.js" + ], + "./helpers/esm/assertClassBrand": "./helpers/esm/assertClassBrand.js", + "./helpers/assertThisInitialized": [ + { + "node": "./helpers/assertThisInitialized.js", + "import": "./helpers/esm/assertThisInitialized.js", + "default": "./helpers/assertThisInitialized.js" + }, + "./helpers/assertThisInitialized.js" + ], + "./helpers/esm/assertThisInitialized": "./helpers/esm/assertThisInitialized.js", + "./helpers/asyncGeneratorDelegate": [ + { + "node": "./helpers/asyncGeneratorDelegate.js", + "import": "./helpers/esm/asyncGeneratorDelegate.js", + "default": "./helpers/asyncGeneratorDelegate.js" + }, + "./helpers/asyncGeneratorDelegate.js" + ], + "./helpers/esm/asyncGeneratorDelegate": "./helpers/esm/asyncGeneratorDelegate.js", + "./helpers/asyncIterator": [ + { + "node": "./helpers/asyncIterator.js", + "import": "./helpers/esm/asyncIterator.js", + "default": "./helpers/asyncIterator.js" + }, + "./helpers/asyncIterator.js" + ], + "./helpers/esm/asyncIterator": "./helpers/esm/asyncIterator.js", + "./helpers/asyncToGenerator": [ + { + "node": "./helpers/asyncToGenerator.js", + "import": "./helpers/esm/asyncToGenerator.js", + "default": "./helpers/asyncToGenerator.js" + }, + "./helpers/asyncToGenerator.js" + ], + "./helpers/esm/asyncToGenerator": "./helpers/esm/asyncToGenerator.js", + "./helpers/awaitAsyncGenerator": [ + { + "node": "./helpers/awaitAsyncGenerator.js", + "import": "./helpers/esm/awaitAsyncGenerator.js", + "default": "./helpers/awaitAsyncGenerator.js" + }, + "./helpers/awaitAsyncGenerator.js" + ], + "./helpers/esm/awaitAsyncGenerator": "./helpers/esm/awaitAsyncGenerator.js", + "./helpers/callSuper": [ + { + "node": "./helpers/callSuper.js", + "import": "./helpers/esm/callSuper.js", + "default": "./helpers/callSuper.js" + }, + "./helpers/callSuper.js" + ], + "./helpers/esm/callSuper": "./helpers/esm/callSuper.js", + "./helpers/checkInRHS": [ + { + "node": "./helpers/checkInRHS.js", + "import": "./helpers/esm/checkInRHS.js", + "default": "./helpers/checkInRHS.js" + }, + "./helpers/checkInRHS.js" + ], + "./helpers/esm/checkInRHS": "./helpers/esm/checkInRHS.js", + "./helpers/checkPrivateRedeclaration": [ + { + "node": "./helpers/checkPrivateRedeclaration.js", + "import": "./helpers/esm/checkPrivateRedeclaration.js", + "default": "./helpers/checkPrivateRedeclaration.js" + }, + "./helpers/checkPrivateRedeclaration.js" + ], + "./helpers/esm/checkPrivateRedeclaration": "./helpers/esm/checkPrivateRedeclaration.js", + "./helpers/classCallCheck": [ + { + "node": "./helpers/classCallCheck.js", + "import": "./helpers/esm/classCallCheck.js", + "default": "./helpers/classCallCheck.js" + }, + "./helpers/classCallCheck.js" + ], + "./helpers/esm/classCallCheck": "./helpers/esm/classCallCheck.js", + "./helpers/classNameTDZError": [ + { + "node": "./helpers/classNameTDZError.js", + "import": "./helpers/esm/classNameTDZError.js", + "default": "./helpers/classNameTDZError.js" + }, + "./helpers/classNameTDZError.js" + ], + "./helpers/esm/classNameTDZError": "./helpers/esm/classNameTDZError.js", + "./helpers/classPrivateFieldGet2": [ + { + "node": "./helpers/classPrivateFieldGet2.js", + "import": "./helpers/esm/classPrivateFieldGet2.js", + "default": "./helpers/classPrivateFieldGet2.js" + }, + "./helpers/classPrivateFieldGet2.js" + ], + "./helpers/esm/classPrivateFieldGet2": "./helpers/esm/classPrivateFieldGet2.js", + "./helpers/classPrivateFieldInitSpec": [ + { + "node": "./helpers/classPrivateFieldInitSpec.js", + "import": "./helpers/esm/classPrivateFieldInitSpec.js", + "default": "./helpers/classPrivateFieldInitSpec.js" + }, + "./helpers/classPrivateFieldInitSpec.js" + ], + "./helpers/esm/classPrivateFieldInitSpec": "./helpers/esm/classPrivateFieldInitSpec.js", + "./helpers/classPrivateFieldLooseBase": [ + { + "node": "./helpers/classPrivateFieldLooseBase.js", + "import": "./helpers/esm/classPrivateFieldLooseBase.js", + "default": "./helpers/classPrivateFieldLooseBase.js" + }, + "./helpers/classPrivateFieldLooseBase.js" + ], + "./helpers/esm/classPrivateFieldLooseBase": "./helpers/esm/classPrivateFieldLooseBase.js", + "./helpers/classPrivateFieldLooseKey": [ + { + "node": "./helpers/classPrivateFieldLooseKey.js", + "import": "./helpers/esm/classPrivateFieldLooseKey.js", + "default": "./helpers/classPrivateFieldLooseKey.js" + }, + "./helpers/classPrivateFieldLooseKey.js" + ], + "./helpers/esm/classPrivateFieldLooseKey": "./helpers/esm/classPrivateFieldLooseKey.js", + "./helpers/classPrivateFieldSet2": [ + { + "node": "./helpers/classPrivateFieldSet2.js", + "import": "./helpers/esm/classPrivateFieldSet2.js", + "default": "./helpers/classPrivateFieldSet2.js" + }, + "./helpers/classPrivateFieldSet2.js" + ], + "./helpers/esm/classPrivateFieldSet2": "./helpers/esm/classPrivateFieldSet2.js", + "./helpers/classPrivateGetter": [ + { + "node": "./helpers/classPrivateGetter.js", + "import": "./helpers/esm/classPrivateGetter.js", + "default": "./helpers/classPrivateGetter.js" + }, + "./helpers/classPrivateGetter.js" + ], + "./helpers/esm/classPrivateGetter": "./helpers/esm/classPrivateGetter.js", + "./helpers/classPrivateMethodInitSpec": [ + { + "node": "./helpers/classPrivateMethodInitSpec.js", + "import": "./helpers/esm/classPrivateMethodInitSpec.js", + "default": "./helpers/classPrivateMethodInitSpec.js" + }, + "./helpers/classPrivateMethodInitSpec.js" + ], + "./helpers/esm/classPrivateMethodInitSpec": "./helpers/esm/classPrivateMethodInitSpec.js", + "./helpers/classPrivateSetter": [ + { + "node": "./helpers/classPrivateSetter.js", + "import": "./helpers/esm/classPrivateSetter.js", + "default": "./helpers/classPrivateSetter.js" + }, + "./helpers/classPrivateSetter.js" + ], + "./helpers/esm/classPrivateSetter": "./helpers/esm/classPrivateSetter.js", + "./helpers/classStaticPrivateMethodGet": [ + { + "node": "./helpers/classStaticPrivateMethodGet.js", + "import": "./helpers/esm/classStaticPrivateMethodGet.js", + "default": "./helpers/classStaticPrivateMethodGet.js" + }, + "./helpers/classStaticPrivateMethodGet.js" + ], + "./helpers/esm/classStaticPrivateMethodGet": "./helpers/esm/classStaticPrivateMethodGet.js", + "./helpers/construct": [ + { + "node": "./helpers/construct.js", + "import": "./helpers/esm/construct.js", + "default": "./helpers/construct.js" + }, + "./helpers/construct.js" + ], + "./helpers/esm/construct": "./helpers/esm/construct.js", + "./helpers/createClass": [ + { + "node": "./helpers/createClass.js", + "import": "./helpers/esm/createClass.js", + "default": "./helpers/createClass.js" + }, + "./helpers/createClass.js" + ], + "./helpers/esm/createClass": "./helpers/esm/createClass.js", + "./helpers/createForOfIteratorHelper": [ + { + "node": "./helpers/createForOfIteratorHelper.js", + "import": "./helpers/esm/createForOfIteratorHelper.js", + "default": "./helpers/createForOfIteratorHelper.js" + }, + "./helpers/createForOfIteratorHelper.js" + ], + "./helpers/esm/createForOfIteratorHelper": "./helpers/esm/createForOfIteratorHelper.js", + "./helpers/createForOfIteratorHelperLoose": [ + { + "node": "./helpers/createForOfIteratorHelperLoose.js", + "import": "./helpers/esm/createForOfIteratorHelperLoose.js", + "default": "./helpers/createForOfIteratorHelperLoose.js" + }, + "./helpers/createForOfIteratorHelperLoose.js" + ], + "./helpers/esm/createForOfIteratorHelperLoose": "./helpers/esm/createForOfIteratorHelperLoose.js", + "./helpers/createSuper": [ + { + "node": "./helpers/createSuper.js", + "import": "./helpers/esm/createSuper.js", + "default": "./helpers/createSuper.js" + }, + "./helpers/createSuper.js" + ], + "./helpers/esm/createSuper": "./helpers/esm/createSuper.js", + "./helpers/decorate": [ + { + "node": "./helpers/decorate.js", + "import": "./helpers/esm/decorate.js", + "default": "./helpers/decorate.js" + }, + "./helpers/decorate.js" + ], + "./helpers/esm/decorate": "./helpers/esm/decorate.js", + "./helpers/defaults": [ + { + "node": "./helpers/defaults.js", + "import": "./helpers/esm/defaults.js", + "default": "./helpers/defaults.js" + }, + "./helpers/defaults.js" + ], + "./helpers/esm/defaults": "./helpers/esm/defaults.js", + "./helpers/defineAccessor": [ + { + "node": "./helpers/defineAccessor.js", + "import": "./helpers/esm/defineAccessor.js", + "default": "./helpers/defineAccessor.js" + }, + "./helpers/defineAccessor.js" + ], + "./helpers/esm/defineAccessor": "./helpers/esm/defineAccessor.js", + "./helpers/defineProperty": [ + { + "node": "./helpers/defineProperty.js", + "import": "./helpers/esm/defineProperty.js", + "default": "./helpers/defineProperty.js" + }, + "./helpers/defineProperty.js" + ], + "./helpers/esm/defineProperty": "./helpers/esm/defineProperty.js", + "./helpers/extends": [ + { + "node": "./helpers/extends.js", + "import": "./helpers/esm/extends.js", + "default": "./helpers/extends.js" + }, + "./helpers/extends.js" + ], + "./helpers/esm/extends": "./helpers/esm/extends.js", + "./helpers/get": [ + { + "node": "./helpers/get.js", + "import": "./helpers/esm/get.js", + "default": "./helpers/get.js" + }, + "./helpers/get.js" + ], + "./helpers/esm/get": "./helpers/esm/get.js", + "./helpers/getPrototypeOf": [ + { + "node": "./helpers/getPrototypeOf.js", + "import": "./helpers/esm/getPrototypeOf.js", + "default": "./helpers/getPrototypeOf.js" + }, + "./helpers/getPrototypeOf.js" + ], + "./helpers/esm/getPrototypeOf": "./helpers/esm/getPrototypeOf.js", + "./helpers/identity": [ + { + "node": "./helpers/identity.js", + "import": "./helpers/esm/identity.js", + "default": "./helpers/identity.js" + }, + "./helpers/identity.js" + ], + "./helpers/esm/identity": "./helpers/esm/identity.js", + "./helpers/importDeferProxy": [ + { + "node": "./helpers/importDeferProxy.js", + "import": "./helpers/esm/importDeferProxy.js", + "default": "./helpers/importDeferProxy.js" + }, + "./helpers/importDeferProxy.js" + ], + "./helpers/esm/importDeferProxy": "./helpers/esm/importDeferProxy.js", + "./helpers/inherits": [ + { + "node": "./helpers/inherits.js", + "import": "./helpers/esm/inherits.js", + "default": "./helpers/inherits.js" + }, + "./helpers/inherits.js" + ], + "./helpers/esm/inherits": "./helpers/esm/inherits.js", + "./helpers/inheritsLoose": [ + { + "node": "./helpers/inheritsLoose.js", + "import": "./helpers/esm/inheritsLoose.js", + "default": "./helpers/inheritsLoose.js" + }, + "./helpers/inheritsLoose.js" + ], + "./helpers/esm/inheritsLoose": "./helpers/esm/inheritsLoose.js", + "./helpers/initializerDefineProperty": [ + { + "node": "./helpers/initializerDefineProperty.js", + "import": "./helpers/esm/initializerDefineProperty.js", + "default": "./helpers/initializerDefineProperty.js" + }, + "./helpers/initializerDefineProperty.js" + ], + "./helpers/esm/initializerDefineProperty": "./helpers/esm/initializerDefineProperty.js", + "./helpers/initializerWarningHelper": [ + { + "node": "./helpers/initializerWarningHelper.js", + "import": "./helpers/esm/initializerWarningHelper.js", + "default": "./helpers/initializerWarningHelper.js" + }, + "./helpers/initializerWarningHelper.js" + ], + "./helpers/esm/initializerWarningHelper": "./helpers/esm/initializerWarningHelper.js", + "./helpers/instanceof": [ + { + "node": "./helpers/instanceof.js", + "import": "./helpers/esm/instanceof.js", + "default": "./helpers/instanceof.js" + }, + "./helpers/instanceof.js" + ], + "./helpers/esm/instanceof": "./helpers/esm/instanceof.js", + "./helpers/interopRequireDefault": [ + { + "node": "./helpers/interopRequireDefault.js", + "import": "./helpers/esm/interopRequireDefault.js", + "default": "./helpers/interopRequireDefault.js" + }, + "./helpers/interopRequireDefault.js" + ], + "./helpers/esm/interopRequireDefault": "./helpers/esm/interopRequireDefault.js", + "./helpers/interopRequireWildcard": [ + { + "node": "./helpers/interopRequireWildcard.js", + "import": "./helpers/esm/interopRequireWildcard.js", + "default": "./helpers/interopRequireWildcard.js" + }, + "./helpers/interopRequireWildcard.js" + ], + "./helpers/esm/interopRequireWildcard": "./helpers/esm/interopRequireWildcard.js", + "./helpers/isNativeFunction": [ + { + "node": "./helpers/isNativeFunction.js", + "import": "./helpers/esm/isNativeFunction.js", + "default": "./helpers/isNativeFunction.js" + }, + "./helpers/isNativeFunction.js" + ], + "./helpers/esm/isNativeFunction": "./helpers/esm/isNativeFunction.js", + "./helpers/isNativeReflectConstruct": [ + { + "node": "./helpers/isNativeReflectConstruct.js", + "import": "./helpers/esm/isNativeReflectConstruct.js", + "default": "./helpers/isNativeReflectConstruct.js" + }, + "./helpers/isNativeReflectConstruct.js" + ], + "./helpers/esm/isNativeReflectConstruct": "./helpers/esm/isNativeReflectConstruct.js", + "./helpers/iterableToArray": [ + { + "node": "./helpers/iterableToArray.js", + "import": "./helpers/esm/iterableToArray.js", + "default": "./helpers/iterableToArray.js" + }, + "./helpers/iterableToArray.js" + ], + "./helpers/esm/iterableToArray": "./helpers/esm/iterableToArray.js", + "./helpers/iterableToArrayLimit": [ + { + "node": "./helpers/iterableToArrayLimit.js", + "import": "./helpers/esm/iterableToArrayLimit.js", + "default": "./helpers/iterableToArrayLimit.js" + }, + "./helpers/iterableToArrayLimit.js" + ], + "./helpers/esm/iterableToArrayLimit": "./helpers/esm/iterableToArrayLimit.js", + "./helpers/jsx": [ + { + "node": "./helpers/jsx.js", + "import": "./helpers/esm/jsx.js", + "default": "./helpers/jsx.js" + }, + "./helpers/jsx.js" + ], + "./helpers/esm/jsx": "./helpers/esm/jsx.js", + "./helpers/maybeArrayLike": [ + { + "node": "./helpers/maybeArrayLike.js", + "import": "./helpers/esm/maybeArrayLike.js", + "default": "./helpers/maybeArrayLike.js" + }, + "./helpers/maybeArrayLike.js" + ], + "./helpers/esm/maybeArrayLike": "./helpers/esm/maybeArrayLike.js", + "./helpers/newArrowCheck": [ + { + "node": "./helpers/newArrowCheck.js", + "import": "./helpers/esm/newArrowCheck.js", + "default": "./helpers/newArrowCheck.js" + }, + "./helpers/newArrowCheck.js" + ], + "./helpers/esm/newArrowCheck": "./helpers/esm/newArrowCheck.js", + "./helpers/nonIterableRest": [ + { + "node": "./helpers/nonIterableRest.js", + "import": "./helpers/esm/nonIterableRest.js", + "default": "./helpers/nonIterableRest.js" + }, + "./helpers/nonIterableRest.js" + ], + "./helpers/esm/nonIterableRest": "./helpers/esm/nonIterableRest.js", + "./helpers/nonIterableSpread": [ + { + "node": "./helpers/nonIterableSpread.js", + "import": "./helpers/esm/nonIterableSpread.js", + "default": "./helpers/nonIterableSpread.js" + }, + "./helpers/nonIterableSpread.js" + ], + "./helpers/esm/nonIterableSpread": "./helpers/esm/nonIterableSpread.js", + "./helpers/nullishReceiverError": [ + { + "node": "./helpers/nullishReceiverError.js", + "import": "./helpers/esm/nullishReceiverError.js", + "default": "./helpers/nullishReceiverError.js" + }, + "./helpers/nullishReceiverError.js" + ], + "./helpers/esm/nullishReceiverError": "./helpers/esm/nullishReceiverError.js", + "./helpers/objectDestructuringEmpty": [ + { + "node": "./helpers/objectDestructuringEmpty.js", + "import": "./helpers/esm/objectDestructuringEmpty.js", + "default": "./helpers/objectDestructuringEmpty.js" + }, + "./helpers/objectDestructuringEmpty.js" + ], + "./helpers/esm/objectDestructuringEmpty": "./helpers/esm/objectDestructuringEmpty.js", + "./helpers/objectSpread2": [ + { + "node": "./helpers/objectSpread2.js", + "import": "./helpers/esm/objectSpread2.js", + "default": "./helpers/objectSpread2.js" + }, + "./helpers/objectSpread2.js" + ], + "./helpers/esm/objectSpread2": "./helpers/esm/objectSpread2.js", + "./helpers/objectWithoutProperties": [ + { + "node": "./helpers/objectWithoutProperties.js", + "import": "./helpers/esm/objectWithoutProperties.js", + "default": "./helpers/objectWithoutProperties.js" + }, + "./helpers/objectWithoutProperties.js" + ], + "./helpers/esm/objectWithoutProperties": "./helpers/esm/objectWithoutProperties.js", + "./helpers/objectWithoutPropertiesLoose": [ + { + "node": "./helpers/objectWithoutPropertiesLoose.js", + "import": "./helpers/esm/objectWithoutPropertiesLoose.js", + "default": "./helpers/objectWithoutPropertiesLoose.js" + }, + "./helpers/objectWithoutPropertiesLoose.js" + ], + "./helpers/esm/objectWithoutPropertiesLoose": "./helpers/esm/objectWithoutPropertiesLoose.js", + "./helpers/possibleConstructorReturn": [ + { + "node": "./helpers/possibleConstructorReturn.js", + "import": "./helpers/esm/possibleConstructorReturn.js", + "default": "./helpers/possibleConstructorReturn.js" + }, + "./helpers/possibleConstructorReturn.js" + ], + "./helpers/esm/possibleConstructorReturn": "./helpers/esm/possibleConstructorReturn.js", + "./helpers/readOnlyError": [ + { + "node": "./helpers/readOnlyError.js", + "import": "./helpers/esm/readOnlyError.js", + "default": "./helpers/readOnlyError.js" + }, + "./helpers/readOnlyError.js" + ], + "./helpers/esm/readOnlyError": "./helpers/esm/readOnlyError.js", + "./helpers/regenerator": [ + { + "node": "./helpers/regenerator.js", + "import": "./helpers/esm/regenerator.js", + "default": "./helpers/regenerator.js" + }, + "./helpers/regenerator.js" + ], + "./helpers/esm/regenerator": "./helpers/esm/regenerator.js", + "./helpers/regeneratorAsync": [ + { + "node": "./helpers/regeneratorAsync.js", + "import": "./helpers/esm/regeneratorAsync.js", + "default": "./helpers/regeneratorAsync.js" + }, + "./helpers/regeneratorAsync.js" + ], + "./helpers/esm/regeneratorAsync": "./helpers/esm/regeneratorAsync.js", + "./helpers/regeneratorAsyncGen": [ + { + "node": "./helpers/regeneratorAsyncGen.js", + "import": "./helpers/esm/regeneratorAsyncGen.js", + "default": "./helpers/regeneratorAsyncGen.js" + }, + "./helpers/regeneratorAsyncGen.js" + ], + "./helpers/esm/regeneratorAsyncGen": "./helpers/esm/regeneratorAsyncGen.js", + "./helpers/regeneratorKeys": [ + { + "node": "./helpers/regeneratorKeys.js", + "import": "./helpers/esm/regeneratorKeys.js", + "default": "./helpers/regeneratorKeys.js" + }, + "./helpers/regeneratorKeys.js" + ], + "./helpers/esm/regeneratorKeys": "./helpers/esm/regeneratorKeys.js", + "./helpers/regeneratorValues": [ + { + "node": "./helpers/regeneratorValues.js", + "import": "./helpers/esm/regeneratorValues.js", + "default": "./helpers/regeneratorValues.js" + }, + "./helpers/regeneratorValues.js" + ], + "./helpers/esm/regeneratorValues": "./helpers/esm/regeneratorValues.js", + "./helpers/set": [ + { + "node": "./helpers/set.js", + "import": "./helpers/esm/set.js", + "default": "./helpers/set.js" + }, + "./helpers/set.js" + ], + "./helpers/esm/set": "./helpers/esm/set.js", + "./helpers/setFunctionName": [ + { + "node": "./helpers/setFunctionName.js", + "import": "./helpers/esm/setFunctionName.js", + "default": "./helpers/setFunctionName.js" + }, + "./helpers/setFunctionName.js" + ], + "./helpers/esm/setFunctionName": "./helpers/esm/setFunctionName.js", + "./helpers/setPrototypeOf": [ + { + "node": "./helpers/setPrototypeOf.js", + "import": "./helpers/esm/setPrototypeOf.js", + "default": "./helpers/setPrototypeOf.js" + }, + "./helpers/setPrototypeOf.js" + ], + "./helpers/esm/setPrototypeOf": "./helpers/esm/setPrototypeOf.js", + "./helpers/skipFirstGeneratorNext": [ + { + "node": "./helpers/skipFirstGeneratorNext.js", + "import": "./helpers/esm/skipFirstGeneratorNext.js", + "default": "./helpers/skipFirstGeneratorNext.js" + }, + "./helpers/skipFirstGeneratorNext.js" + ], + "./helpers/esm/skipFirstGeneratorNext": "./helpers/esm/skipFirstGeneratorNext.js", + "./helpers/slicedToArray": [ + { + "node": "./helpers/slicedToArray.js", + "import": "./helpers/esm/slicedToArray.js", + "default": "./helpers/slicedToArray.js" + }, + "./helpers/slicedToArray.js" + ], + "./helpers/esm/slicedToArray": "./helpers/esm/slicedToArray.js", + "./helpers/superPropBase": [ + { + "node": "./helpers/superPropBase.js", + "import": "./helpers/esm/superPropBase.js", + "default": "./helpers/superPropBase.js" + }, + "./helpers/superPropBase.js" + ], + "./helpers/esm/superPropBase": "./helpers/esm/superPropBase.js", + "./helpers/superPropGet": [ + { + "node": "./helpers/superPropGet.js", + "import": "./helpers/esm/superPropGet.js", + "default": "./helpers/superPropGet.js" + }, + "./helpers/superPropGet.js" + ], + "./helpers/esm/superPropGet": "./helpers/esm/superPropGet.js", + "./helpers/superPropSet": [ + { + "node": "./helpers/superPropSet.js", + "import": "./helpers/esm/superPropSet.js", + "default": "./helpers/superPropSet.js" + }, + "./helpers/superPropSet.js" + ], + "./helpers/esm/superPropSet": "./helpers/esm/superPropSet.js", + "./helpers/taggedTemplateLiteral": [ + { + "node": "./helpers/taggedTemplateLiteral.js", + "import": "./helpers/esm/taggedTemplateLiteral.js", + "default": "./helpers/taggedTemplateLiteral.js" + }, + "./helpers/taggedTemplateLiteral.js" + ], + "./helpers/esm/taggedTemplateLiteral": "./helpers/esm/taggedTemplateLiteral.js", + "./helpers/taggedTemplateLiteralLoose": [ + { + "node": "./helpers/taggedTemplateLiteralLoose.js", + "import": "./helpers/esm/taggedTemplateLiteralLoose.js", + "default": "./helpers/taggedTemplateLiteralLoose.js" + }, + "./helpers/taggedTemplateLiteralLoose.js" + ], + "./helpers/esm/taggedTemplateLiteralLoose": "./helpers/esm/taggedTemplateLiteralLoose.js", + "./helpers/tdz": [ + { + "node": "./helpers/tdz.js", + "import": "./helpers/esm/tdz.js", + "default": "./helpers/tdz.js" + }, + "./helpers/tdz.js" + ], + "./helpers/esm/tdz": "./helpers/esm/tdz.js", + "./helpers/temporalRef": [ + { + "node": "./helpers/temporalRef.js", + "import": "./helpers/esm/temporalRef.js", + "default": "./helpers/temporalRef.js" + }, + "./helpers/temporalRef.js" + ], + "./helpers/esm/temporalRef": "./helpers/esm/temporalRef.js", + "./helpers/temporalUndefined": [ + { + "node": "./helpers/temporalUndefined.js", + "import": "./helpers/esm/temporalUndefined.js", + "default": "./helpers/temporalUndefined.js" + }, + "./helpers/temporalUndefined.js" + ], + "./helpers/esm/temporalUndefined": "./helpers/esm/temporalUndefined.js", + "./helpers/toArray": [ + { + "node": "./helpers/toArray.js", + "import": "./helpers/esm/toArray.js", + "default": "./helpers/toArray.js" + }, + "./helpers/toArray.js" + ], + "./helpers/esm/toArray": "./helpers/esm/toArray.js", + "./helpers/toConsumableArray": [ + { + "node": "./helpers/toConsumableArray.js", + "import": "./helpers/esm/toConsumableArray.js", + "default": "./helpers/toConsumableArray.js" + }, + "./helpers/toConsumableArray.js" + ], + "./helpers/esm/toConsumableArray": "./helpers/esm/toConsumableArray.js", + "./helpers/toPrimitive": [ + { + "node": "./helpers/toPrimitive.js", + "import": "./helpers/esm/toPrimitive.js", + "default": "./helpers/toPrimitive.js" + }, + "./helpers/toPrimitive.js" + ], + "./helpers/esm/toPrimitive": "./helpers/esm/toPrimitive.js", + "./helpers/toPropertyKey": [ + { + "node": "./helpers/toPropertyKey.js", + "import": "./helpers/esm/toPropertyKey.js", + "default": "./helpers/toPropertyKey.js" + }, + "./helpers/toPropertyKey.js" + ], + "./helpers/esm/toPropertyKey": "./helpers/esm/toPropertyKey.js", + "./helpers/toSetter": [ + { + "node": "./helpers/toSetter.js", + "import": "./helpers/esm/toSetter.js", + "default": "./helpers/toSetter.js" + }, + "./helpers/toSetter.js" + ], + "./helpers/esm/toSetter": "./helpers/esm/toSetter.js", + "./helpers/tsRewriteRelativeImportExtensions": [ + { + "node": "./helpers/tsRewriteRelativeImportExtensions.js", + "import": "./helpers/esm/tsRewriteRelativeImportExtensions.js", + "default": "./helpers/tsRewriteRelativeImportExtensions.js" + }, + "./helpers/tsRewriteRelativeImportExtensions.js" + ], + "./helpers/esm/tsRewriteRelativeImportExtensions": "./helpers/esm/tsRewriteRelativeImportExtensions.js", + "./helpers/typeof": [ + { + "node": "./helpers/typeof.js", + "import": "./helpers/esm/typeof.js", + "default": "./helpers/typeof.js" + }, + "./helpers/typeof.js" + ], + "./helpers/esm/typeof": "./helpers/esm/typeof.js", + "./helpers/unsupportedIterableToArray": [ + { + "node": "./helpers/unsupportedIterableToArray.js", + "import": "./helpers/esm/unsupportedIterableToArray.js", + "default": "./helpers/unsupportedIterableToArray.js" + }, + "./helpers/unsupportedIterableToArray.js" + ], + "./helpers/esm/unsupportedIterableToArray": "./helpers/esm/unsupportedIterableToArray.js", + "./helpers/usingCtx": [ + { + "node": "./helpers/usingCtx.js", + "import": "./helpers/esm/usingCtx.js", + "default": "./helpers/usingCtx.js" + }, + "./helpers/usingCtx.js" + ], + "./helpers/esm/usingCtx": "./helpers/esm/usingCtx.js", + "./helpers/wrapAsyncGenerator": [ + { + "node": "./helpers/wrapAsyncGenerator.js", + "import": "./helpers/esm/wrapAsyncGenerator.js", + "default": "./helpers/wrapAsyncGenerator.js" + }, + "./helpers/wrapAsyncGenerator.js" + ], + "./helpers/esm/wrapAsyncGenerator": "./helpers/esm/wrapAsyncGenerator.js", + "./helpers/wrapNativeSuper": [ + { + "node": "./helpers/wrapNativeSuper.js", + "import": "./helpers/esm/wrapNativeSuper.js", + "default": "./helpers/wrapNativeSuper.js" + }, + "./helpers/wrapNativeSuper.js" + ], + "./helpers/esm/wrapNativeSuper": "./helpers/esm/wrapNativeSuper.js", + "./helpers/wrapRegExp": [ + { + "node": "./helpers/wrapRegExp.js", + "import": "./helpers/esm/wrapRegExp.js", + "default": "./helpers/wrapRegExp.js" + }, + "./helpers/wrapRegExp.js" + ], + "./helpers/esm/wrapRegExp": "./helpers/esm/wrapRegExp.js", + "./helpers/writeOnlyError": [ + { + "node": "./helpers/writeOnlyError.js", + "import": "./helpers/esm/writeOnlyError.js", + "default": "./helpers/writeOnlyError.js" + }, + "./helpers/writeOnlyError.js" + ], + "./helpers/esm/writeOnlyError": "./helpers/esm/writeOnlyError.js", + "./helpers/AwaitValue": [ + { + "node": "./helpers/AwaitValue.js", + "import": "./helpers/esm/AwaitValue.js", + "default": "./helpers/AwaitValue.js" + }, + "./helpers/AwaitValue.js" + ], + "./helpers/esm/AwaitValue": "./helpers/esm/AwaitValue.js", + "./helpers/applyDecs": [ + { + "node": "./helpers/applyDecs.js", + "import": "./helpers/esm/applyDecs.js", + "default": "./helpers/applyDecs.js" + }, + "./helpers/applyDecs.js" + ], + "./helpers/esm/applyDecs": "./helpers/esm/applyDecs.js", + "./helpers/applyDecs2203": [ + { + "node": "./helpers/applyDecs2203.js", + "import": "./helpers/esm/applyDecs2203.js", + "default": "./helpers/applyDecs2203.js" + }, + "./helpers/applyDecs2203.js" + ], + "./helpers/esm/applyDecs2203": "./helpers/esm/applyDecs2203.js", + "./helpers/applyDecs2203R": [ + { + "node": "./helpers/applyDecs2203R.js", + "import": "./helpers/esm/applyDecs2203R.js", + "default": "./helpers/applyDecs2203R.js" + }, + "./helpers/applyDecs2203R.js" + ], + "./helpers/esm/applyDecs2203R": "./helpers/esm/applyDecs2203R.js", + "./helpers/applyDecs2301": [ + { + "node": "./helpers/applyDecs2301.js", + "import": "./helpers/esm/applyDecs2301.js", + "default": "./helpers/applyDecs2301.js" + }, + "./helpers/applyDecs2301.js" + ], + "./helpers/esm/applyDecs2301": "./helpers/esm/applyDecs2301.js", + "./helpers/applyDecs2305": [ + { + "node": "./helpers/applyDecs2305.js", + "import": "./helpers/esm/applyDecs2305.js", + "default": "./helpers/applyDecs2305.js" + }, + "./helpers/applyDecs2305.js" + ], + "./helpers/esm/applyDecs2305": "./helpers/esm/applyDecs2305.js", + "./helpers/classApplyDescriptorDestructureSet": [ + { + "node": "./helpers/classApplyDescriptorDestructureSet.js", + "import": "./helpers/esm/classApplyDescriptorDestructureSet.js", + "default": "./helpers/classApplyDescriptorDestructureSet.js" + }, + "./helpers/classApplyDescriptorDestructureSet.js" + ], + "./helpers/esm/classApplyDescriptorDestructureSet": "./helpers/esm/classApplyDescriptorDestructureSet.js", + "./helpers/classApplyDescriptorGet": [ + { + "node": "./helpers/classApplyDescriptorGet.js", + "import": "./helpers/esm/classApplyDescriptorGet.js", + "default": "./helpers/classApplyDescriptorGet.js" + }, + "./helpers/classApplyDescriptorGet.js" + ], + "./helpers/esm/classApplyDescriptorGet": "./helpers/esm/classApplyDescriptorGet.js", + "./helpers/classApplyDescriptorSet": [ + { + "node": "./helpers/classApplyDescriptorSet.js", + "import": "./helpers/esm/classApplyDescriptorSet.js", + "default": "./helpers/classApplyDescriptorSet.js" + }, + "./helpers/classApplyDescriptorSet.js" + ], + "./helpers/esm/classApplyDescriptorSet": "./helpers/esm/classApplyDescriptorSet.js", + "./helpers/classCheckPrivateStaticAccess": [ + { + "node": "./helpers/classCheckPrivateStaticAccess.js", + "import": "./helpers/esm/classCheckPrivateStaticAccess.js", + "default": "./helpers/classCheckPrivateStaticAccess.js" + }, + "./helpers/classCheckPrivateStaticAccess.js" + ], + "./helpers/esm/classCheckPrivateStaticAccess": "./helpers/esm/classCheckPrivateStaticAccess.js", + "./helpers/classCheckPrivateStaticFieldDescriptor": [ + { + "node": "./helpers/classCheckPrivateStaticFieldDescriptor.js", + "import": "./helpers/esm/classCheckPrivateStaticFieldDescriptor.js", + "default": "./helpers/classCheckPrivateStaticFieldDescriptor.js" + }, + "./helpers/classCheckPrivateStaticFieldDescriptor.js" + ], + "./helpers/esm/classCheckPrivateStaticFieldDescriptor": "./helpers/esm/classCheckPrivateStaticFieldDescriptor.js", + "./helpers/classExtractFieldDescriptor": [ + { + "node": "./helpers/classExtractFieldDescriptor.js", + "import": "./helpers/esm/classExtractFieldDescriptor.js", + "default": "./helpers/classExtractFieldDescriptor.js" + }, + "./helpers/classExtractFieldDescriptor.js" + ], + "./helpers/esm/classExtractFieldDescriptor": "./helpers/esm/classExtractFieldDescriptor.js", + "./helpers/classPrivateFieldDestructureSet": [ + { + "node": "./helpers/classPrivateFieldDestructureSet.js", + "import": "./helpers/esm/classPrivateFieldDestructureSet.js", + "default": "./helpers/classPrivateFieldDestructureSet.js" + }, + "./helpers/classPrivateFieldDestructureSet.js" + ], + "./helpers/esm/classPrivateFieldDestructureSet": "./helpers/esm/classPrivateFieldDestructureSet.js", + "./helpers/classPrivateFieldGet": [ + { + "node": "./helpers/classPrivateFieldGet.js", + "import": "./helpers/esm/classPrivateFieldGet.js", + "default": "./helpers/classPrivateFieldGet.js" + }, + "./helpers/classPrivateFieldGet.js" + ], + "./helpers/esm/classPrivateFieldGet": "./helpers/esm/classPrivateFieldGet.js", + "./helpers/classPrivateFieldSet": [ + { + "node": "./helpers/classPrivateFieldSet.js", + "import": "./helpers/esm/classPrivateFieldSet.js", + "default": "./helpers/classPrivateFieldSet.js" + }, + "./helpers/classPrivateFieldSet.js" + ], + "./helpers/esm/classPrivateFieldSet": "./helpers/esm/classPrivateFieldSet.js", + "./helpers/classPrivateMethodGet": [ + { + "node": "./helpers/classPrivateMethodGet.js", + "import": "./helpers/esm/classPrivateMethodGet.js", + "default": "./helpers/classPrivateMethodGet.js" + }, + "./helpers/classPrivateMethodGet.js" + ], + "./helpers/esm/classPrivateMethodGet": "./helpers/esm/classPrivateMethodGet.js", + "./helpers/classPrivateMethodSet": [ + { + "node": "./helpers/classPrivateMethodSet.js", + "import": "./helpers/esm/classPrivateMethodSet.js", + "default": "./helpers/classPrivateMethodSet.js" + }, + "./helpers/classPrivateMethodSet.js" + ], + "./helpers/esm/classPrivateMethodSet": "./helpers/esm/classPrivateMethodSet.js", + "./helpers/classStaticPrivateFieldDestructureSet": [ + { + "node": "./helpers/classStaticPrivateFieldDestructureSet.js", + "import": "./helpers/esm/classStaticPrivateFieldDestructureSet.js", + "default": "./helpers/classStaticPrivateFieldDestructureSet.js" + }, + "./helpers/classStaticPrivateFieldDestructureSet.js" + ], + "./helpers/esm/classStaticPrivateFieldDestructureSet": "./helpers/esm/classStaticPrivateFieldDestructureSet.js", + "./helpers/classStaticPrivateFieldSpecGet": [ + { + "node": "./helpers/classStaticPrivateFieldSpecGet.js", + "import": "./helpers/esm/classStaticPrivateFieldSpecGet.js", + "default": "./helpers/classStaticPrivateFieldSpecGet.js" + }, + "./helpers/classStaticPrivateFieldSpecGet.js" + ], + "./helpers/esm/classStaticPrivateFieldSpecGet": "./helpers/esm/classStaticPrivateFieldSpecGet.js", + "./helpers/classStaticPrivateFieldSpecSet": [ + { + "node": "./helpers/classStaticPrivateFieldSpecSet.js", + "import": "./helpers/esm/classStaticPrivateFieldSpecSet.js", + "default": "./helpers/classStaticPrivateFieldSpecSet.js" + }, + "./helpers/classStaticPrivateFieldSpecSet.js" + ], + "./helpers/esm/classStaticPrivateFieldSpecSet": "./helpers/esm/classStaticPrivateFieldSpecSet.js", + "./helpers/classStaticPrivateMethodSet": [ + { + "node": "./helpers/classStaticPrivateMethodSet.js", + "import": "./helpers/esm/classStaticPrivateMethodSet.js", + "default": "./helpers/classStaticPrivateMethodSet.js" + }, + "./helpers/classStaticPrivateMethodSet.js" + ], + "./helpers/esm/classStaticPrivateMethodSet": "./helpers/esm/classStaticPrivateMethodSet.js", + "./helpers/defineEnumerableProperties": [ + { + "node": "./helpers/defineEnumerableProperties.js", + "import": "./helpers/esm/defineEnumerableProperties.js", + "default": "./helpers/defineEnumerableProperties.js" + }, + "./helpers/defineEnumerableProperties.js" + ], + "./helpers/esm/defineEnumerableProperties": "./helpers/esm/defineEnumerableProperties.js", + "./helpers/dispose": [ + { + "node": "./helpers/dispose.js", + "import": "./helpers/esm/dispose.js", + "default": "./helpers/dispose.js" + }, + "./helpers/dispose.js" + ], + "./helpers/esm/dispose": "./helpers/esm/dispose.js", + "./helpers/objectSpread": [ + { + "node": "./helpers/objectSpread.js", + "import": "./helpers/esm/objectSpread.js", + "default": "./helpers/objectSpread.js" + }, + "./helpers/objectSpread.js" + ], + "./helpers/esm/objectSpread": "./helpers/esm/objectSpread.js", + "./helpers/regeneratorRuntime": [ + { + "node": "./helpers/regeneratorRuntime.js", + "import": "./helpers/esm/regeneratorRuntime.js", + "default": "./helpers/regeneratorRuntime.js" + }, + "./helpers/regeneratorRuntime.js" + ], + "./helpers/esm/regeneratorRuntime": "./helpers/esm/regeneratorRuntime.js", + "./helpers/using": [ + { + "node": "./helpers/using.js", + "import": "./helpers/esm/using.js", + "default": "./helpers/using.js" + }, + "./helpers/using.js" + ], + "./helpers/esm/using": "./helpers/esm/using.js", + "./package": "./package.json", + "./package.json": "./package.json", + "./regenerator": "./regenerator/index.js", + "./regenerator/*.js": "./regenerator/*.js", + "./regenerator/": "./regenerator/" + }, + "engines": { + "node": ">=6.9.0" }, "type": "commonjs" } \ No newline at end of file diff --git a/node_modules/@matrix-org/matrix-sdk-crypto-wasm/README.md b/node_modules/@matrix-org/matrix-sdk-crypto-wasm/README.md index 70e4488..540910c 100644 --- a/node_modules/@matrix-org/matrix-sdk-crypto-wasm/README.md +++ b/node_modules/@matrix-org/matrix-sdk-crypto-wasm/README.md @@ -22,102 +22,66 @@ Encryption](https://en.wikipedia.org/wiki/End-to-end_encryption)) for or: ``` - pnpm add @matrix-org/matrix-sdk-crypto-wasm + yarn add @matrix-org/matrix-sdk-crypto-wasm ``` 2. Import the library into your project and initialise it. - On Web platforms, the library must be initialised by calling `initAsync` - before it can be used, else it will throw an error. This is also recommended - on other platforms, as it allows the WebAssembly module to be loaded - asynchronously. + It is recommended that you use a dynamic import, particularly in a Web + environment, because the WASM artifiact is large: ```javascript - import { initAsync, Tracing, LoggerLevel, OlmMachine, UserId, DeviceId } from "@matrix-org/matrix-sdk-crypto-wasm"; - async function loadCrypto(userId, deviceId) { - // Do this before any other calls to the library - await initAsync(); + const matrixSdkCrypto = await import("@matrix-org/matrix-sdk-crypto-wasm"); + await matrixSdkCrypto.initAsync(); // Optional: enable tracing in the rust-sdk - new Tracing(LoggerLevel.Trace).turnOn(); + new matrixSdkCrypto.Tracing(matrixSdkCrypto.LoggerLevel.Trace).turnOn(); // Create a new OlmMachine // // The following will use an in-memory store. It is recommended to use // indexedDB where that is available. - // See https://matrix-org.github.io/matrix-sdk-crypto-wasm/classes/OlmMachine.html#initialize - const olmMachine = await OlmMachine.initialize(new UserId(userId), new DeviceId(deviceId)); + // See https://matrix-org.github.io/matrix-rust-sdk-crypto-wasm/classes/OlmMachine.html#initialize + const olmMachine = await matrixSdkCrypto.OlmMachine.initialize( + new RustSdkCryptoJs.UserId(userId), + new RustSdkCryptoJs.DeviceId(deviceId), + ); return olmMachine; } ``` - See the [API documentation](https://matrix-org.github.io/matrix-sdk-crypto-wasm/) for more information. - -3. Build your project. - - The packaging of this library aims to "just work" the same as any plain-javascript project would: it includes - separate entry points for Node.js-like environments (which read the WASM file via - [`fs.readFile()`](https://nodejs.org/api/fs.html#fsreadfilepath-options-callback)) and web-like environments (which - download the WASM file with [`fetch()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/fetch)). There are - both CommonJS and ES Module entry points for each environment; an appropriate entrypoint should be selected - automatically. - - If your environment supports the experimental [ES Module Integration Proposal for WebAssembly](https://github.com/WebAssembly/esm-integration), - you can instead use that, by setting the `matrix-org:wasm-esm` custom [export condition](https://nodejs.org/api/packages.html#conditional-exports). - This is only supported when the library is imported as an ES Module. For example: - - - In Webpack, set [`experiments.asyncWebAssembly`](https://webpack.js.org/configuration/experiments/#experiments) - to `true` and [`resolve.conditionNames`](https://webpack.js.org/configuration/resolve/#resolveconditionnames) - to `["matrix-org:wasm-esm", "..."]` (the `"..."` preserves default condition names). - - In Node.js, invoke with commandline arguments [`--experimental-wasm-modules`](https://nodejs.org/api/esm.html#wasm-modules) - [`--conditions=wasm-esm`](https://nodejs.org/api/cli.html#-c-condition---conditionscondition). - -## Building matrix-sdk-crypto-wasm +## Building These WebAssembly bindings are written in [Rust]. To build them, you need to install the Rust compiler, see [the Install Rust Page](https://www.rust-lang.org/tools/install). Then, the workflow is -pretty classical by using [pnpm](https://pnpm.io), see [the Downloading and installing +pretty classical by using [yarn](https://yarnpkg.com/), see [the Downloading and installing Node.js and npm -Page](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) and [installing pnpm](https://pnpm.io/installation). +Page](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) and [installing yarn](https://classic.yarnpkg.com/lang/en/docs/install). -Once the Rust compiler, Node.js and pnpm are installed, you can run the +Once the Rust compiler, Node.js and yarn are installed, you can run the following commands: ```sh -$ pnpm install -$ pnpm build # or 'pnpm build:dev' to make an unoptimised build -$ pnpm test +$ yarn install +$ yarn build # or 'yarn build:dev' to make an unoptimised build +$ yarn test ``` The compiled output should be generated in the `pkg/` directory. -## Local development with matrix-rust-sdk - -To build based on a local `matrix-rust-sdk`, add something like this to your -`.cargo/config` file: - -``` -[patch.'https://github.com/matrix-org/matrix-rust-sdk'] -matrix-sdk-base = { path = "../matrix-rust-sdk/crates/matrix-sdk-base" } -matrix-sdk-common = { path = "../matrix-rust-sdk/crates/matrix-sdk-common" } -matrix-sdk-crypto = { path = "../matrix-rust-sdk/crates/matrix-sdk-crypto" } -matrix-sdk-indexeddb = { path = "../matrix-rust-sdk/crates/matrix-sdk-indexeddb" } -matrix-sdk-qrcode = { path = "../matrix-rust-sdk/crates/matrix-sdk-qrcode" } -``` - ## Documentation [The documentation can be found -online](https://matrix-org.github.io/matrix-sdk-crypto-wasm/). +online](https://matrix-org.github.io/matrix-rust-sdk-crypto-wasm/). To generate the documentation locally, please run the following command: ```sh -$ pnpm doc +$ yarn doc ``` The documentation is generated in the `./docs` directory. @@ -128,7 +92,3 @@ The documentation is generated in the `./docs` directory. [Matrix]: https://matrix.org/ [Rust]: https://www.rust-lang.org/ [npm]: https://www.npmjs.com/ - -## Contributing - -Thank you! See the [contributing](CONTRIBUTING.md) doc for more info. diff --git a/node_modules/@matrix-org/matrix-sdk-crypto-wasm/index-wasm-esm.mjs b/node_modules/@matrix-org/matrix-sdk-crypto-wasm/index-wasm-esm.mjs deleted file mode 100644 index 89db517..0000000 --- a/node_modules/@matrix-org/matrix-sdk-crypto-wasm/index-wasm-esm.mjs +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2024 The Matrix.org Foundation C.I.C. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// @ts-check - -/** - * This is the entry point for ESM environments which support the ES Module Integration Proposal for WebAssembly [1]. - * - * [1]: https://github.com/webassembly/esm-integration - */ - -import * as bindings from "./pkg/matrix_sdk_crypto_wasm_bg.js"; - -// Although we could simply instantiate the WASM at import time with a top-level `await`, -// we avoid that, to make it easier for callers to delay loading the WASM (and instead -// wait until `initAsync` is called). (Also, Safari 14 doesn't support top-level `await`.) -// -// However, having done so, there is no way to synchronously load the WASM if the user ends -// up using the bindings before calling `initAsync` (unlike under Node.js), so we just throw -// an error. -bindings.__wbg_set_wasm( - new Proxy( - {}, - { - get() { - throw new Error( - "@matrix-org/matrix-sdk-crypto-wasm was used before it was initialized. Call `initAsync` first.", - ); - }, - }, - ), -); - -/** - * Stores a promise of the `loadModuleAsync` call - * @type {Promise | null} - */ -let modPromise = null; - -/** - * Loads and instantiates the WASM module asynchronously - * - * @returns {Promise} - */ -async function loadModuleAsync() { - /** @type {typeof import("./pkg/matrix_sdk_crypto_wasm_bg.wasm.d.ts")} */ - // @ts-expect-error TSC can't find the definitions file, for some reason. - const wasm = await import("./pkg/matrix_sdk_crypto_wasm_bg.wasm"); - bindings.__wbg_set_wasm(wasm); - wasm.__wbindgen_start(); -} - -/** - * Load the WebAssembly module in the background, if it has not already been loaded. - * - * Returns a promise which will resolve once the other methods are ready. - * - * @returns {Promise} - */ -export async function initAsync() { - if (!modPromise) modPromise = loadModuleAsync(); - await modPromise; -} - -// Re-export everything from the generated javascript wrappers -export * from "./pkg/matrix_sdk_crypto_wasm_bg.js"; diff --git a/node_modules/@matrix-org/matrix-sdk-crypto-wasm/index.cjs b/node_modules/@matrix-org/matrix-sdk-crypto-wasm/index.cjs deleted file mode 100644 index 4a6cc27..0000000 --- a/node_modules/@matrix-org/matrix-sdk-crypto-wasm/index.cjs +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2024 The Matrix.org Foundation C.I.C. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// @ts-check - -/** - * This is the entrypoint on non-node CommonJS environments. - * `asyncLoad` will load the WASM module using a `fetch` call. - */ - -const bindings = require("./pkg/matrix_sdk_crypto_wasm_bg.cjs"); - -const defaultURL = require.resolve("./pkg/matrix_sdk_crypto_wasm_bg.wasm"); - -// We want to throw an error if the user tries to use the bindings before -// calling `initAsync`. -bindings.__wbg_set_wasm( - new Proxy( - {}, - { - get() { - throw new Error( - "@matrix-org/matrix-sdk-crypto-wasm was used before it was initialized. Call `initAsync` first.", - ); - }, - }, - ), -); - -/** - * Stores a promise of the `loadModule` call - * @type {Promise | null} - */ -let modPromise = null; - -/** - * Loads and instantiates the WASM module asynchronously - * - * @param {URL | string} url - The URL to fetch the WebAssembly module from - * @returns {Promise} - */ -async function loadModuleAsync(url) { - const { instance } = await WebAssembly.instantiateStreaming(fetch(url), { - // @ts-expect-error: The bindings don't exactly match the 'ExportValue' type - "./matrix_sdk_crypto_wasm_bg.js": bindings, - }); - - bindings.__wbg_set_wasm(instance.exports); - // @ts-expect-error: Typescript doesn't know what the module exports are - instance.exports.__wbindgen_start(); -} - -/** - * Load the WebAssembly module in the background, if it has not already been loaded. - * - * Returns a promise which will resolve once the other methods are ready. - * - * @param {URL | string} [url] - The URL to fetch the WebAssembly module from. If not provided, a default URL will be used. - * @returns {Promise} - */ -async function initAsync(url = defaultURL) { - if (!modPromise) modPromise = loadModuleAsync(url); - await modPromise; -} - -module.exports = { - // Re-export everything from the generated javascript wrappers - ...bindings, - initAsync, -}; diff --git a/node_modules/@matrix-org/matrix-sdk-crypto-wasm/index.d.ts b/node_modules/@matrix-org/matrix-sdk-crypto-wasm/index.d.ts deleted file mode 100644 index 6a968e7..0000000 --- a/node_modules/@matrix-org/matrix-sdk-crypto-wasm/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2024 The Matrix.org Foundation C.I.C. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/* - * Re-export all the type definitions that wasm-bindgen generated for us. - * - * We do this by referring to a non-existent "matrix_sdk_crypto_wasm.js" file. This works because TSC will automatically - * transform this into the correct name "matrix_sdk_crypto_wasm.d.ts" [1]. - * - * Other alternatives don't work: - * - * - `export * from "./pkg/matrix_sdk_crypto_wasm.d.ts"`: You're not allowed to `import from ".d.ts"` - * without `import type`, because normally, that would mean you don't get the runtime definitions that are in - * ".js". This lint rule even applies to ".d.ts" files, which is arguably overzealous, but there you have it. - * - * - `export type * from "./pkg/matrix_sdk_crypto_wasm.d.ts"`: Doing this means you can't call the constructors on any - * of the exported types: `new RoomId(...)` gives a build error. - * - * - `export * from "./pkg/matrix_sdk_crypto_wasm"`: This works in *some* environments, but in others, typescript - * complains [2]. We could maybe get around this by mandating a `moduleResolution` setting of `bundler` or so, but - * that is restrictive on our downstreams. - * - * A final alternative would be just to cat `matrix_sdk_crypto_wasm.d.ts` in here as part of the build script, but - * for now at least we're trying to avoid too much file manipulation. - * - * [1]: https://www.typescriptlang.org/docs/handbook/modules/reference.html#file-extension-substitution - * [2]: https://www.typescriptlang.org/docs/handbook/modules/reference.html#extensionless-relative-paths - */ -export * from "./pkg/matrix_sdk_crypto_wasm.js"; - -/** - * Load the WebAssembly module in the background, if it has not already been loaded. - * - * Returns a promise which will resolve once the other methods are ready. - * @param {URL | string} [url] - The URL to fetch the WebAssembly module from. If not provided, a default URL will be used. - * @returns {Promise} - */ -export declare function initAsync(url?: URL | string): Promise; diff --git a/node_modules/@matrix-org/matrix-sdk-crypto-wasm/index.mjs b/node_modules/@matrix-org/matrix-sdk-crypto-wasm/index.mjs deleted file mode 100644 index cf58971..0000000 --- a/node_modules/@matrix-org/matrix-sdk-crypto-wasm/index.mjs +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2024 The Matrix.org Foundation C.I.C. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// @ts-check - -/** - * This is the entrypoint on non-node ESM environments. - * `asyncLoad` will load the WASM module using a `fetch` call. - */ - -import * as bindings from "./pkg/matrix_sdk_crypto_wasm_bg.js"; - -const defaultURL = new URL("./pkg/matrix_sdk_crypto_wasm_bg.wasm", import.meta.url); - -// Although we could simply instantiate the WASM at import time with a top-level `await`, -// we avoid that, to make it easier for callers to delay loading the WASM (and instead -// wait until `initAsync` is called). (Also, Safari 14 doesn't support top-level `await`.) -// -// However, having done so, there is no way to synchronously load the WASM if the user ends -// up using the bindings before calling `initAsync` (unlike under Node.js), so we just throw -// an error. -bindings.__wbg_set_wasm( - new Proxy( - {}, - { - get() { - throw new Error( - "@matrix-org/matrix-sdk-crypto-wasm was used before it was initialized. Call `initAsync` first.", - ); - }, - }, - ), -); - -/** - * Stores a promise of the `loadModuleAsync` call - * @type {Promise | null} - */ -let modPromise = null; - -/** - * Loads and instantiates the WASM module asynchronously - * - * @param {URL | string} url - The URL to fetch the WebAssembly module from - * @returns {Promise} - */ -async function loadModuleAsync(url) { - const { instance } = await WebAssembly.instantiateStreaming(fetch(url), { - // @ts-expect-error: The bindings don't exactly match the 'ExportValue' type - "./matrix_sdk_crypto_wasm_bg.js": bindings, - }); - - bindings.__wbg_set_wasm(instance.exports); - // @ts-expect-error: Typescript doesn't know what the module exports are - instance.exports.__wbindgen_start(); -} - -/** - * Load the WebAssembly module in the background, if it has not already been loaded. - * - * Returns a promise which will resolve once the other methods are ready. - * - * @param {URL | string} [url] - The URL to fetch the WebAssembly module from. If not provided, a default URL will be used. - * @returns {Promise} - */ -export async function initAsync(url = defaultURL) { - if (!modPromise) modPromise = loadModuleAsync(url); - await modPromise; -} - -// Re-export everything from the generated javascript wrappers -export * from "./pkg/matrix_sdk_crypto_wasm_bg.js"; diff --git a/node_modules/@matrix-org/matrix-sdk-crypto-wasm/node.cjs b/node_modules/@matrix-org/matrix-sdk-crypto-wasm/node.cjs deleted file mode 100644 index 2e67fb3..0000000 --- a/node_modules/@matrix-org/matrix-sdk-crypto-wasm/node.cjs +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright 2024 The Matrix.org Foundation C.I.C. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// @ts-check - -/** - * This is the entrypoint on node-compatible CommonJS environments. - * `asyncLoad` will use `fs.readFile` to load the WASM module. - */ - -const { readFileSync } = require("node:fs"); -const { readFile } = require("node:fs/promises"); -const path = require("node:path"); -const bindings = require("./pkg/matrix_sdk_crypto_wasm_bg.cjs"); - -const filename = path.join(__dirname, "pkg/matrix_sdk_crypto_wasm_bg.wasm"); - -// In node environments, we want to automatically load the WASM module -// synchronously if the consumer did not call `initAsync`. To do so, we install -// a `Proxy` that will intercept calls to the WASM module. -bindings.__wbg_set_wasm( - new Proxy( - {}, - { - get(_target, prop) { - const instance = loadModuleSync(); - // @ts-expect-error: This results in an `any` type, which is fine - return instance[prop]; - }, - }, - ), -); - -/** - * Stores a promise which resolves to the WebAssembly module - * @type {Promise | null} - */ -let modPromise = null; - -/** - * Tracks whether the module has been instantiated or not - * @type {boolean} - */ -let initialised = false; - -/** - * Loads and instantiates the WASM module synchronously - * - * It will throw if there is an attempt to load the module asynchronously running - * - * @returns {typeof import("./pkg/matrix_sdk_crypto_wasm_bg.wasm.d", { with: { "resolution-mode": "require" } })} - */ -function loadModuleSync() { - if (modPromise) throw new Error("The WASM module is being loaded asynchronously but hasn't finished"); - const bytes = readFileSync(filename); - const mod = new WebAssembly.Module(bytes); - - const instance = new WebAssembly.Instance(mod, { - // @ts-expect-error: The bindings don't exactly match the 'ExportValue' type - "./matrix_sdk_crypto_wasm_bg.js": bindings, - }); - - initInstance(instance); - - // @ts-expect-error: Typescript doesn't know what the instance exports exactly - return instance.exports; -} - -/** - * Loads and instantiates the WASM module asynchronously - * - * @returns {Promise} - */ -async function loadModuleAsync() { - const bytes = await readFile(filename); - const { instance } = await WebAssembly.instantiate(bytes, { - // @ts-expect-error: The bindings don't exactly match the 'ExportValue' type - "./matrix_sdk_crypto_wasm_bg.js": bindings, - }); - - initInstance(instance); - - // @ts-expect-error: Typescript doesn't know what the instance exports exactly - return instance.exports; -} - -/** - * Initializes the WASM module and returns the exports from the WASM module. - * - * @param {WebAssembly.Instance} instance - */ -function initInstance(instance) { - if (initialised) throw new Error("initInstance called twice"); - bindings.__wbg_set_wasm(instance.exports); - // @ts-expect-error: Typescript doesn't know what the instance exports exactly - instance.exports.__wbindgen_start(); - initialised = true; -} - -/** - * Load the WebAssembly module in the background, if it has not already been loaded. - * - * Returns a promise which will resolve once the other methods are ready. - * - * @returns {Promise} - */ -async function initAsync() { - if (initialised) return; - if (!modPromise) modPromise = loadModuleAsync(); - await modPromise; -} - -module.exports = { - // Re-export everything from the generated javascript wrappers - ...bindings, - initAsync, -}; diff --git a/node_modules/@matrix-org/matrix-sdk-crypto-wasm/node.mjs b/node_modules/@matrix-org/matrix-sdk-crypto-wasm/node.mjs deleted file mode 100644 index 65c9cca..0000000 --- a/node_modules/@matrix-org/matrix-sdk-crypto-wasm/node.mjs +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright 2024 The Matrix.org Foundation C.I.C. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// @ts-check - -/** - * This is the entrypoint on node-compatible ESM environments. - * `asyncLoad` will use `fs.readFile` to load the WASM module. - */ - -import { fileURLToPath } from "node:url"; -import { readFileSync } from "node:fs"; -import { readFile } from "node:fs/promises"; -import * as bindings from "./pkg/matrix_sdk_crypto_wasm_bg.js"; - -const filename = fileURLToPath(new URL("./pkg/matrix_sdk_crypto_wasm_bg.wasm", import.meta.url)); - -// In node environments, we want to automatically load the WASM module -// synchronously if the consumer did not call `initAsync`. To do so, we install -// a `Proxy` that will intercept calls to the WASM module. -bindings.__wbg_set_wasm( - new Proxy( - {}, - { - get(_target, prop) { - const instance = loadModuleSync(); - // @ts-expect-error: This results in an `any` type, which is fine - return instance[prop]; - }, - }, - ), -); - -/** - * Stores a promise which resolves to the WebAssembly module - * @type {Promise | null} - */ -let modPromise = null; - -/** - * Tracks whether the module has been instantiated or not - * @type {boolean} - */ -let initialised = false; - -/** - * Loads and instantiates the WASM module synchronously - * - * It will throw if there is an attempt to load the module asynchronously running - * - * @returns {typeof import("./pkg/matrix_sdk_crypto_wasm_bg.wasm.d.ts")} - */ -function loadModuleSync() { - if (modPromise) throw new Error("The WASM module is being loaded asynchronously but hasn't finished"); - const bytes = readFileSync(filename); - const mod = new WebAssembly.Module(bytes); - - const instance = new WebAssembly.Instance(mod, { - // @ts-expect-error: The bindings don't exactly match the 'ExportValue' type - "./matrix_sdk_crypto_wasm_bg.js": bindings, - }); - - initInstance(instance); - - // @ts-expect-error: Typescript doesn't know what the module exports are - return instance.exports; -} - -/** - * Loads and instantiates the WASM module asynchronously - * - * @returns {Promise} - */ -async function loadModuleAsync() { - const bytes = await readFile(filename); - const { instance } = await WebAssembly.instantiate(bytes, { - // @ts-expect-error: The bindings don't exactly match the 'ExportValue' type - "./matrix_sdk_crypto_wasm_bg.js": bindings, - }); - - initInstance(instance); - - // @ts-expect-error: Typescript doesn't know what the module exports are - return instance.exports; -} - -/** - * Initializes the WASM module and returns the exports from the WASM module. - * - * @param {WebAssembly.Instance} instance - */ -function initInstance(instance) { - if (initialised) throw new Error("initInstance called twice"); - bindings.__wbg_set_wasm(instance.exports); - // @ts-expect-error: Typescript doesn't know what the module exports are - instance.exports.__wbindgen_start(); - initialised = true; -} - -/** - * Load the WebAssembly module in the background, if it has not already been loaded. - * - * Returns a promise which will resolve once the other methods are ready. - * - * @returns {Promise} - */ -export async function initAsync() { - if (initialised) return; - if (!modPromise) modPromise = loadModuleAsync(); - await modPromise; -} - -// Re-export everything from the generated javascript wrappers -export * from "./pkg/matrix_sdk_crypto_wasm_bg.js"; diff --git a/node_modules/@matrix-org/matrix-sdk-crypto-wasm/package.json b/node_modules/@matrix-org/matrix-sdk-crypto-wasm/package.json index 5d2a4a5..59c6c4b 100644 --- a/node_modules/@matrix-org/matrix-sdk-crypto-wasm/package.json +++ b/node_modules/@matrix-org/matrix-sdk-crypto-wasm/package.json @@ -1,7 +1,7 @@ { "name": "@matrix-org/matrix-sdk-crypto-wasm", - "version": "18.8.0", - "homepage": "https://github.com/matrix-org/matrix-sdk-crypto-wasm", + "version": "1.3.0", + "homepage": "https://github.com/matrix-org/matrix-rust-sdk-wasm", "description": "WebAssembly bindings of the matrix-sdk-crypto encryption library", "license": "Apache-2.0", "collaborators": [ @@ -9,7 +9,7 @@ ], "repository": { "type": "git", - "url": "https://github.com/matrix-org/matrix-sdk-crypto-wasm" + "url": "https://github.com/matrix-org/matrix-rust-sdk-wasm" }, "keywords": [ "matrix", @@ -18,71 +18,33 @@ "ruma", "nio" ], - "type": "module", - "exports": { - ".": { - "matrix-org:wasm-esm": { - "types": "./index.d.ts", - "default": "./index-wasm-esm.mjs" - }, - "require": { - "types": "./index.d.ts", - "node": "./node.cjs", - "default": "./index.cjs" - }, - "import": { - "types": "./index.d.ts", - "node": "./node.mjs", - "default": "./index.mjs" - } - } - }, + "main": "pkg/matrix_sdk_crypto_wasm.js", + "types": "pkg/matrix_sdk_crypto_wasm.d.ts", "files": [ - "index.mjs", - "index.cjs", - "index-wasm-esm.mjs", - "index.d.ts", - "node.mjs", - "node.cjs", - "pkg/matrix_sdk_crypto_wasm.d.ts", - "pkg/matrix_sdk_crypto_wasm_bg.js", - "pkg/matrix_sdk_crypto_wasm_bg.cjs", + "pkg/matrix_sdk_crypto_wasm_bg.wasm.js", "pkg/matrix_sdk_crypto_wasm_bg.wasm.d.ts", - "pkg/matrix_sdk_crypto_wasm_bg.wasm" + "pkg/matrix_sdk_crypto_wasm.js", + "pkg/matrix_sdk_crypto_wasm.d.ts" ], "devDependencies": { - "@babel/cli": "^7.28.6", - "@babel/core": "^7.29.0", - "@babel/plugin-transform-modules-commonjs": "^7.28.6", - "@babel/preset-env": "^7.29.0", - "@babel/preset-typescript": "^7.28.5", - "@tsconfig/node18": "^18.2.6", - "@types/jest": "^29.5.14", - "@types/node": "^18.19.130", - "babel-jest": "^29.7.0", "cross-env": "^7.0.3", - "eslint": "^8.57.1", - "fake-indexeddb": "^4.0.2", - "jest": "^28.1.3", - "prettier": "^2.8.8", - "typedoc": "^0.27.9", - "typescript": "5.7.2", - "wasm-pack": "~0.13.1", + "fake-indexeddb": "^4.0", + "jest": "^28.1.0", + "prettier": "^2.8.3", + "typedoc": "^0.22.17", + "typescript": "4.7", + "wasm-pack": "^0.10.2", "yargs-parser": "~21.0.1" }, "engines": { - "node": ">= 18" + "node": ">= 10" }, - "packageManager": "pnpm@10.30.3+sha512.c961d1e0a2d8e354ecaa5166b822516668b7f44cb5bd95122d590dd81922f606f5473b6d23ec4a5be05e7fcd18e8488d47d978bbe981872f1145d06e9a740017", "scripts": { - "lint": "pnpm lint:eslint && pnpm lint:prettier && pnpm lint:types", - "lint:eslint": "eslint --max-warnings 0 tests", - "lint:prettier": "prettier --check .", - "lint:types": "tsc --noEmit", + "lint": "prettier --check .", "build": "WASM_PACK_ARGS=--release ./scripts/build.sh", "build:dev": "WASM_PACK_ARGS=--dev ./scripts/build.sh", - "test": "jest --verbose && pnpm wasm-pack test --node", - "doc": "typedoc --treatWarningsAsErrors --tsconfig .", - "prepack": "pnpm build && pnpm run test" + "test": "jest --verbose", + "doc": "typedoc --tsconfig .", + "prepack": "npm run build && npm run test" } } diff --git a/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm.d.ts b/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm.d.ts index 77466fe..a489f85 100644 --- a/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm.d.ts +++ b/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm.d.ts @@ -1,5161 +1,3046 @@ /* tslint:disable */ /* eslint-disable */ - -/** The types returned by {@link OlmMachine.outgoingRequests}. */ -type OutgoingRequest = -| KeysUploadRequest -| KeysQueryRequest -| KeysClaimRequest -| ToDeviceRequest -| SignatureUploadRequest -| RoomMessageRequest -| KeysBackupRequest; - - - -/** The types returned by {@link OlmMachine.receiveSyncChanges}. */ -type ProcessedToDeviceEvent = -| DecryptedToDeviceEvent -| PlainTextToDeviceEvent -| InvalidToDeviceEvent -| UTDToDeviceEvent; - - - -interface JsLogger { - debug(data: any): void; - info(data: any): void; - warn(data: any): void; - error(data: any): void; -} - - -type OutgoingVerificationRequest = -| ToDeviceRequest -| RoomMessageRequest; - - - /** - * A type to encrypt and to decrypt anything that can fit in an - * `Uint8Array`, usually big buffer. - */ -export class Attachment { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Decrypt an `EncryptedAttachment`. - * - * The encrypted attachment can be created manually, or from the - * `encrypt` method. - * - * **Warning**: The encrypted attachment can be used only - * **once**! The encrypted data will still be present, but the - * media encryption info (which contain secrets) will be - * destroyed. It is still possible to get a JSON-encoded backup - * by calling `EncryptedAttachment.mediaEncryptionInfo`. - */ - static decrypt(attachment: EncryptedAttachment): Uint8Array; - /** - * Encrypt the content of the `Uint8Array`. - * - * It produces an `EncryptedAttachment`, which can be used to - * retrieve the media encryption information, or the encrypted - * data. - */ - static encrypt(array: Uint8Array): EncryptedAttachment; -} - -/** - * The private part of the backup key, the one used for recovery. - */ -export class BackupDecryptionKey { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Create a new random [`BackupDecryptionKey`]. - */ - static createRandomKey(): BackupDecryptionKey; - /** - * Try to decrypt a message that was encrypted using the public part of the - * backup key. - */ - decryptV1(ephemeral_key: string, mac: string, ciphertext: string): string; - /** - * Try to create a [`BackupDecryptionKey`] from a base 64 encoded string. - */ - static fromBase64(key: string): BackupDecryptionKey; - /** - * Convert the backup decryption key to a base 64 encoded string. - */ - toBase64(): string; - /** - * Get the public part of the backup key. - */ - readonly megolmV1PublicKey: MegolmV1BackupKey; -} - -/** - * Stored versions of the backup keys. - */ -export class BackupKeys { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * The key used to decrypt backed up room keys, encoded as base64 - * - * @deprecated Use `BackupKeys.decryptionKey.toBase64()` - */ - readonly decryptionKeyBase64: string | undefined; - /** - * The version that we are using for backups. - */ - get backupVersion(): string | undefined; - /** - * The version that we are using for backups. - */ - set backupVersion(value: string | null | undefined); - /** - * The key used to decrypt backed up room keys - */ - get decryptionKey(): BackupDecryptionKey | undefined; - /** - * The key used to decrypt backed up room keys - */ - set decryptionKey(value: BackupDecryptionKey | null | undefined); -} - -/** - * The backup-specific parts of a secrets bundle. - */ -export class BackupSecretsBundle { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * The backup version which this backup decryption key is used with. - */ - backup_version: string; - /** - * The backup decryption key, encoded as unpadded base64. - */ - key: string; -} - -/** - * The base64-encoded variant of a {@link PkMessage}. - * - * This can be useful if the encrypted message should be put into JSON. - */ -export class Base64EncodedPkMessage { - free(): void; - [Symbol.dispose](): void; - /** - * Creates a new base64-encoded encrypted message from its parts. - */ - constructor(ciphertext: string, mac: string, ephemeral_key: string); - /** - * The base64-encoded ciphertext. - */ - ciphertext: string; - /** - * The base64-encoded ephemeral public key. - */ - ephemeralKey: string; - /** - * The base64-encoded message authentication code (MAC). - */ - mac: string; -} - -/** - * The base dataset that is important to migrate to the Rust SDK. - * - * Can be imported into the rust store with {@link Migration::migrateBaseData}. - */ -export class BaseMigrationData { - free(): void; - [Symbol.dispose](): void; - /** - * Create a new `BaseMigrationData` with default values. - */ - constructor(); - /** - * The backup recovery key, as a base64-encoded string. - */ - get backupRecoveryKey(): string | undefined; - /** - * The backup recovery key, as a base64-encoded string. - */ - set backupRecoveryKey(value: string | null | undefined); - /** - * The backup version that is currently active. - */ - get backupVersion(): string | undefined; - /** - * The backup version that is currently active. - */ - set backupVersion(value: string | null | undefined); - /** - * The device ID of the account owner. - */ - get deviceId(): DeviceId | undefined; - /** - * The device ID of the account owner. - */ - set deviceId(value: DeviceId | null | undefined); - /** - * The pickle string holding the Olm Account, as returned by - * `olm_pickle_account` in libolm. - */ - pickledAccount: string; - /** - * The private, base64-encoded, master cross-signing key. - */ - get privateCrossSigningMasterKey(): string | undefined; - /** - * The private, base64-encoded, master cross-signing key. - */ - set privateCrossSigningMasterKey(value: string | null | undefined); - /** - * The private, base64-encoded, self-signing key. - */ - get privateCrossSigningSelfSigningKey(): string | undefined; - /** - * The private, base64-encoded, self-signing key. - */ - set privateCrossSigningSelfSigningKey(value: string | null | undefined); - /** - * The private, base64-encoded, user-signing key. - */ - get privateCrossSigningUserSigningKey(): string | undefined; - /** - * The private, base64-encoded, user-signing key. - */ - set privateCrossSigningUserSigningKey(value: string | null | undefined); - /** - * The user id of the account owner. - */ - get userId(): UserId | undefined; - /** - * The user id of the account owner. - */ - set userId(value: UserId | null | undefined); -} - -/** - * Information about the cancellation of a verification request or - * verification flow. - */ -export class CancelInfo { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Get the `code` (e.g. `m.user`) that was used to cancel the - * verification. - */ - cancelCode(): string; - /** - * Was the verification cancelled by us? - */ - cancelledbyUs(): boolean; - /** - * Get the human readable reason of the cancellation. - */ - reason(): string; -} - -/** - * A check code that can be used to confirm that two {@link EstablishedEcies} - * objects share the same secret. This is supposed to be shared out-of-band to - * protect against active Man-in-the-middle (MITM) attacks. - * - * Since the initiator device can always tell whether a MITM attack is in - * progress after channel establishment, this code technically carries only a - * single bit of information, representing whether the initiator has determined - * that the channel is "secure" or "not secure". - * - * However, given this will need to be interactively confirmed by the user, - * there is risk that the user would confirm the dialogue without paying - * attention to its content. By expanding this single bit into a deterministic - * two-digit check code, the user is forced to pay more attention by having to - * enter it instead of just clicking through a dialogue. - */ -export class CheckCode { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Convert the check code to an array of two bytes. - * - * The bytes can be converted to a more user-friendly representation. - * {@link to_digit} and {@link toDigitNoLeadingZero} convert the bytes to a - * two-digit number. - */ - as_bytes(): Uint8Array; - /** - * Convert the check code to two base-10 numbers, with no leading zero. - * - * This corresponds to the way the digits are defined in - * {@link https://github.com/matrix-org/matrix-spec-proposals/pull/4388 MSC4388}. - */ - toDigitNoLeadingZero(): number; - /** - * Convert the check code to two base-10 numbers, allowing a leading zero. - * - * This corresponds to the way the digits were used in the initial version - * of {@link https://github.com/matrix-org/matrix-spec-proposals/pull/4108 MSC4108}. - * See {@link toDigitNoLeadingZero} for a more recent implementation. - * - * The number should be displayed with a leading 0 in case the first digit - * is a 0. - */ - to_digit(): number; -} - -/** - * Strategy to collect the devices that should receive room keys for the - * current discussion. - */ -export class CollectStrategy { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Share with all (unblacklisted) devices. - */ - static allDevices(): CollectStrategy; - /** - * Device based sharing strategy. - * - * @deprecated: use one of {@link allDevices}, {@link - * errorOnUnverifiedUserProblem} or {@link onlyTrustedDevices}. - */ - static deviceBasedStrategy(only_allow_trusted_devices: boolean, error_on_verified_user_problem: boolean): CollectStrategy; - /** - * Tests for equality between two [`CollectStrategy`]s. - */ - eq(other: CollectStrategy): boolean; - /** - * Share with all devices, except that errors for *verified* users cause - * sharing to fail with an error. - * - * In this strategy, if a verified user has an unsigned device, or - * a verified user has replaced their identity, key - * sharing will fail with an error. - * - * Otherwise, keys are shared with unsigned devices as normal. - * - * Once the problematic devices are blacklisted or whitelisted the - * caller can try sharing a second time. - */ - static errorOnUnverifiedUserProblem(): CollectStrategy; - /** - * Share based on identity. Only distribute to devices signed by their - * owner. If a user has no published identity he will not receive - * any room keys. - */ - static identityBasedStrategy(): CollectStrategy; - /** - * Only share keys with devices that we "trust". A device is trusted if any - * of the following is true: - * - It was manually marked as trusted. - * - It was marked as verified via interactive verification. - * - It is signed by its owner identity, and this identity has been - * trusted via interactive verification. - * - It is the current own device of the user. - */ - static onlyTrustedDevices(): CollectStrategy; -} - -/** - * A set of requests to be executed when bootstrapping cross-signing using - * {@link OlmMachine.bootstrapCrossSigning}. - */ -export class CrossSigningBootstrapRequests { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * An optional request to upload a device key. - * - * This will either be `undefined`, or an "outgoing request" as returned by - * {@link OlmMachine.outgoingRequests}. - * - * If it is defined, the request should be sent first, and the result sent - * back with {@link OlmMachine.markRequestAsSent}. - */ - readonly uploadKeysRequest: any; - /** - * Request to upload key signatures, including those for the cross-signing - * keys, and maybe some for the optional uploaded key too. - * - * Should be sent last. - */ - readonly uploadSignaturesRequest: SignatureUploadRequest; - /** - * Request to upload the cross-signing keys. - * - * Should be sent second. - */ - readonly uploadSigningKeysRequest: UploadSigningKeysRequest; -} - -/** - * A struct containing private cross signing keys that can be backed - * up or uploaded to the secret store. - */ -export class CrossSigningKeyExport { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * The seed of the master key encoded as unpadded base64. - */ - readonly masterKey: string | undefined; - /** - * The seed of the self signing key encoded as unpadded base64. - */ - readonly self_signing_key: string | undefined; - /** - * The seed of the user signing key encoded as unpadded base64. - */ - readonly userSigningKey: string | undefined; -} - -/** - * Struct representing the state of our private cross signing keys, - * it shows which private cross signing keys we have locally stored. - */ -export class CrossSigningStatus { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Do we have the master key? - */ - readonly hasMaster: boolean; - /** - * Do we have the self signing key? This one is necessary to sign - * our own devices. - */ - readonly hasSelfSigning: boolean; - /** - * Do we have the user signing key? This one is necessary to sign - * other users. - */ - readonly hasUserSigning: boolean; -} - -/** - * A Curve25519 public key. - */ -export class Curve25519PublicKey { - free(): void; - [Symbol.dispose](): void; - /** - * Create a new [`Curve25519PublicKey`] from a base64 encoded string. - */ - constructor(key: string); - /** - * Serialize an Curve25519 public key to an unpadded base64 - * representation. - */ - toBase64(): string; - /** - * The number of bytes a Curve25519 public key has. - */ - readonly length: number; -} - -/** - * A Curve25519 secret key. - */ -export class Curve25519SecretKey { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Creates a `Curve25519SecretKey` from a base64-encoded representation of - * the key. - */ - static fromBase64(string: string): Curve25519SecretKey; - /** - * Creates a `Curve25519SecretKey` from a raw byte slice. - */ - static fromUint8Array(slice: Uint8Array): Curve25519SecretKey; - /** - * Generates a new random Curve25519 secret key. - */ - static new(): Curve25519SecretKey; - /** - * Encodes the secret key into a base64 string. - */ - toBase64(): string; - /** - * Converts the secret key into a raw byte vector. - */ - toUint8Array(): Uint8Array; -} - -/** - * A decrypted room event. - */ -export class DecryptedRoomEvent { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * The verification state of the device that sent us the event. - * Note this is the state of the device at the time of - * decryption. It may change in the future if a device gets - * verified or deleted. - */ - shieldState(strict: boolean): ShieldState; - /** - * If the keys for this message were shared-on-invite as part of an - * [MSC4268] key bundle, the ID of the user who sent us the bundle. - * - * [MSC4268]: https://github.com/matrix-org/matrix-spec-proposals/pull/4268 - */ - readonly forwarder: UserId | undefined; - /** - * If the keys for this message were shared-on-invite as part of an - * [MSC4268] key bundle, the ID of the device from which this bundle - * was sent. - * - * [MSC4268]: https://github.com/matrix-org/matrix-spec-proposals/pull/4268 - */ - readonly forwarderDevice: DeviceId | undefined; - /** - * Returns an empty array - * - * Previously, this returned the chain of Curve25519 keys through which - * this session was forwarded, via `m.forwarded_room_key` events. - * However, that is not cryptographically reliable, and clients should not - * be using it. - * - * @see https://github.com/matrix-org/matrix-spec/issues/1089 - */ - readonly forwardingCurve25519KeyChain: string[]; - /** - * The user ID of the event sender, note this is untrusted data - * unless the `verification_state` is as well trusted. - */ - readonly sender: UserId; - /** - * The signing Ed25519 key that have created the megolm key that - * was used to decrypt this session. - */ - readonly senderClaimedEd25519Key: string | undefined; - /** - * The Curve25519 key of the device that created the megolm - * decryption key originally. - */ - readonly senderCurve25519Key: string; - /** - * The device ID of the device that sent us the event, note this - * is untrusted data unless `verification_state` is as well - * trusted. - */ - readonly senderDevice: DeviceId | undefined; - /** - * The JSON-encoded decrypted event. - */ - readonly event: string; -} - -/** - * Represents an encrypted to-device event, after it has been decrypted. - */ -export class DecryptedToDeviceEvent { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * The type of processed to-device event. Always {@link - * ProcessedToDeviceEventType.Decrypted} for this type. - */ - readonly type: ProcessedToDeviceEventType; - /** - * The encryption information for the event. - */ - readonly encryptionInfo: ToDeviceEncryptionInfo; - /** - * The decrypted event, as if it had been sent in the clear, encoded as - * JSON. - * - * Typically contains properties `type`, `sender` and `content`. - * - * (For room keys or secrets, some part of the content might have been - * zeroized). - */ - readonly rawEvent: string; -} - -/** - * Decryption error codes - */ -export enum DecryptionErrorCode { - /** - * The room key is not known - */ - MissingRoomKey = 0, - /** - * The room key is known but ratcheted - */ - UnknownMessageIndex = 1, - /** - * Decryption failed because of a mismatch between the identity keys of the - * device we received the room key from and the identity keys recorded in - * the plaintext of the room key to-device message. - */ - MismatchedIdentityKeys = 2, - /** - * We weren't able to link the message back to any known device. - */ - UnknownSenderDevice = 3, - /** - * The sender device is not cross-signed. - */ - UnsignedSenderDevice = 4, - /** - * The sender's identity is unverified, but was previously verified. - */ - SenderIdentityVerificationViolation = 5, - /** - * Other failure. - */ - UnableToDecrypt = 6, - /** - * The `sender` field on the event does not match the owner of the device - * that established the Megolm session. - */ - MismatchedSender = 7, -} - -/** - * Settings for decrypting messages - */ -export class DecryptionSettings { - free(): void; - [Symbol.dispose](): void; - /** - * Create a new `DecryptionSettings` with the given trust requirement. - */ - constructor(sender_device_trust_requirement: TrustRequirement); - /** - * The trust level required to decrypt the event - */ - sender_device_trust_requirement: TrustRequirement; -} - -/** - * A dehydrated device that can be uploaded to the server - */ -export class DehydratedDevice { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Create the request to upload the dehydrated device - */ - keysForUpload(initial_device_display_name: string, dehydrated_device_key: DehydratedDeviceKey): Promise; -} - -/** - * Dehydrated device key - */ -export class DehydratedDeviceKey { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Generates a dehydrated device key from a given array. - */ - static createKeyFromArray(array: Uint8Array): DehydratedDeviceKey; - /** - * Generates a new random dehydrated device key. - */ - static createRandomKey(): DehydratedDeviceKey; - /** - * Convert the dehydrated device key to a base64-encoded string. - */ - toBase64(): string; -} - -/** - * Struct collecting methods to create and rehydrate dehydrated devices. - */ -export class DehydratedDevices { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Create a new {@link DehydratedDevice} which can be uploaded to the - * server. - */ - create(): Promise; - /** - * Clear the dehydrated device key saved in the crypto store. - */ - deleteDehydratedDeviceKey(): Promise; - /** - * Get the cached dehydrated device key if any. - * - * `None` if the key was not previously cached (via - * {@link DehydratedDevices.saveDehydratedDeviceKey}). - */ - getDehydratedDeviceKey(): Promise; - /** - * Rehydrate a dehydrated device. - */ - rehydrate(dehydrated_device_key: DehydratedDeviceKey, device_id: DeviceId, device_data: string): Promise; - /** - * Store the dehydrated device key in the crypto store. - */ - saveDehydratedDeviceKey(dehydrated_device_key: DehydratedDeviceKey): Promise; -} - -/** - * A device represents a E2EE capable client of an user. - */ -export class Device { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Encrypt a to-device message to be sent to this device, using Olm - * encryption. - * - * Prior to calling this method you must ensure that an Olm session is - * available for the target device. This can be done by calling - * {@link OlmMachine.getMissingSessions}. - * - * The caller is responsible for sending the encrypted - * event to the target device. If multiple messages are - * encrypted for the same device using this method they should be sent in - * the same order as they are encrypted. - * - * # Returns - * - * Returns a promise for a JSON string containing the `content` of an - * encrypted event, which be used to create the payload for a - * `/sendToDevice` API. - */ - encryptToDeviceEvent(event_type: string, content: any, share_strategy?: CollectStrategy | null): Promise; - /** - * Timestamp representing the first time this device has been seen (in - * milliseconds). - */ - firstTimeSeen(): bigint; - /** - * Get the key of the given key algorithm belonging to this device. - */ - getKey(algorithm: DeviceKeyAlgorithmName): DeviceKey | undefined; - /** - * Is the device locally marked as blacklisted? - * - * Blacklisted devices won’t receive any group sessions. - */ - isBlacklisted(): boolean; - /** - * Is this device cross-signed by its owner? - */ - isCrossSignedByOwner(): boolean; - /** - * Is this device considered to be verified using cross signing. - */ - isCrossSigningTrusted(): boolean; - /** - * Is the device deleted? - */ - isDeleted(): boolean; - /** - * Is the device locally marked as trusted? - */ - isLocallyTrusted(): boolean; - /** - * Is this device considered to be verified. - * - * This method returns true if either the `is_locally_trusted` - * method returns `true` or if the `is_cross_signing_trusted` - * method returns `true`. - */ - isVerified(): boolean; - /** - * Request an interactive verification with this device. - * - * Returns a 2-element array `[VerificationRequest, ToDeviceRequest]`. - */ - requestVerification(methods?: VerificationMethod[]): [VerificationRequest, ToDeviceRequest]; - /** - * Set the local trust state of the device to the given state. - * - * This won’t affect any cross signing trust state, this only - * sets a flag marking to have the given trust state. - * - * `trust_state` represents the new trust state that should be - * set for the device. - */ - setLocalTrust(local_state: LocalTrust): Promise; - /** - * Mark this device as verified. - * Works only if the device is owned by the current user. - * - * Returns a signature upload request that needs to be sent out. - */ - verify(): Promise; - /** - * Get the list of algorithms this device supports. - * - * Returns `Array`. - */ - readonly algorithms: EncryptionAlgorithm[]; - /** - * Get the Curve25519 key of the given device. - */ - readonly curve25519Key: Curve25519PublicKey | undefined; - /** - * The unique ID of the device. - */ - readonly deviceId: DeviceId; - /** - * Get the human readable name of the device. - */ - readonly displayName: string | undefined; - /** - * Get the Ed25519 key of the given device. - */ - readonly ed25519Key: Ed25519PublicKey | undefined; - /** - * Whether or not the device is a dehydrated device. - */ - readonly isDehydrated: boolean; - /** - * Get a map containing all the device keys. - */ - readonly keys: Map; - /** - * Get the trust state of the device. - */ - readonly localTrustState: LocalTrust; - /** - * Get a map containing all the device signatures. - */ - readonly signatures: Signatures; - /** - * The user ID of the device owner. - */ - readonly userId: UserId; -} - -/** - * A Matrix key ID. - * - * Device identifiers in Matrix are completely opaque character - * sequences. This type is provided simply for its semantic value. - */ -export class DeviceId { - free(): void; - [Symbol.dispose](): void; - /** - * Create a new `DeviceId`. - */ - constructor(id: string); - /** - * Return the device ID as a string. - */ - toString(): string; -} - -/** - * An enum over the different key types a device can have. - * - * Currently devices have a curve25519 and ed25519 keypair. The keys - * transport format is a base64 encoded string, any unknown key type - * will be left as such a string. - */ -export class DeviceKey { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Convert the `DeviceKey` into a base64 encoded string. - */ - toBase64(): string; - /** - * Get the value associated to the `Curve25519` device key name. - */ - readonly curve25519: Curve25519PublicKey | undefined; - /** - * Get the value associated to the `Ed25519` device key name. - */ - readonly ed25519: Ed25519PublicKey | undefined; - /** - * Get the name of the device key. - */ - readonly name: DeviceKeyName; - /** - * Get the value associated to the `Unknown` device key name. - */ - readonly unknown: string | undefined; -} - -/** - * The basic key algorithms in the specification. - */ -export class DeviceKeyAlgorithm { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Return the device key algorithm as a string. - */ - toString(): string; - /** - * Read the device key algorithm's name. If the name is - * `Unknown`, one may be interested by the `to_string` method to - * read the original name. - */ - readonly name: DeviceKeyAlgorithmName; -} - -/** - * The basic key algorithm names in the specification. - */ -export enum DeviceKeyAlgorithmName { - /** - * The Ed25519 signature algorithm. - */ - Ed25519 = 0, - /** - * The Curve25519 ECDH algorithm. - */ - Curve25519 = 1, - /** - * An unknown device key algorithm. - */ - Unknown = 3, -} - -/** - * A Matrix device key ID. - * - * A key algorithm and a device ID, combined with a ‘:’. - */ -export class DeviceKeyId { - free(): void; - [Symbol.dispose](): void; - /** - * Parse/validate and create a new `DeviceKeyId`. - */ - constructor(id: string); - /** - * Return the device key ID as a string. - */ - toString(): string; - /** - * Returns key algorithm of the device key ID. - */ - readonly algorithm: DeviceKeyAlgorithm; - /** - * Returns device ID of the device key ID. - */ - readonly deviceId: DeviceId; -} - -/** - * An enum over the different key types a device can have. - * - * Currently devices have a curve25519 and ed25519 keypair. The keys - * transport format is a base64 encoded string, any unknown key type - * will be left as such a string. - */ -export enum DeviceKeyName { - /** - * The curve25519 device key. - */ - Curve25519 = 0, - /** - * The ed25519 device key. - */ - Ed25519 = 1, - /** - * An unknown device key. - */ - Unknown = 2, -} - -/** - * Information on E2E device updates. - */ -export class DeviceLists { - free(): void; - [Symbol.dispose](): void; - /** - * Returns true if there are no device list updates. - */ - isEmpty(): boolean; - /** - * Create an empty `DeviceLists`. - * - * `changed` and `left` must be an array of `UserId`. - * - * Items inside `changed` and `left` will be invalidated by this method. Be - * careful not to use the `UserId`s after this method has been called. - */ - constructor(changed?: UserId[] | null, left?: UserId[] | null); - /** - * List of users who have updated their device identity keys or - * who now share an encrypted room with the client since the - * previous sync - */ - readonly changed: UserId[]; - /** - * List of users who no longer share encrypted rooms since the - * previous sync response. - */ - readonly left: UserId[]; -} - -/** - * An unestablished ECIES session. - */ -export class Ecies { - free(): void; - [Symbol.dispose](): void; - /** - * Create a [`EstablishedEcies`] from an initial message encrypted by the - * other side. - */ - establish_inbound_channel(initial_message: string): InboundCreationResult; - /** - * Create an [`EstablishedEcies`] session using the other side's Curve25519 - * public key and an initial plaintext. - * - * After the channel has been established, we can encrypt messages to send - * to the other side. The other side uses the initial message to - * establishes the same channel on its side. - */ - establish_outbound_channel(public_key: Curve25519PublicKey, initial_message: string): OutboundCreationResult; - /** - * Create a new, random, unestablished ECIES session. - * - * This method will use the - * [`MATRIX_QR_CODE_LOGIN`](https://github.com/matrix-org/matrix-spec-proposals/pull/4108) - * info for domain separation when creating the session. - */ - constructor(); - /** - * Get our [`Curve25519PublicKey`]. - * - * This public key needs to be sent to the other side to be able to - * establish an ECIES channel. - */ - public_key(): Curve25519PublicKey; -} - -/** - * An Ed25519 public key, used to verify digital signatures. - */ -export class Ed25519PublicKey { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Serialize an Ed25519 public key to an unpadded base64 - * representation. - */ - toBase64(): string; - /** - * The number of bytes an Ed25519 public key has. - */ - readonly length: number; -} - -/** - * An Ed25519 digital signature, can be used to verify the - * authenticity of a message. - */ -export class Ed25519Signature { - free(): void; - [Symbol.dispose](): void; - /** - * Try to create an Ed25519 signature from an unpadded base64 - * representation. - */ - constructor(signature: string); - /** - * Serialize a Ed25519 signature to an unpadded base64 - * representation. - */ - toBase64(): string; -} - -/** - * An emoji that is used for interactive verification using a short - * auth string. - * - * This will contain a single emoji and description from the list of - * emojis from [the specification]. - * - * [the specification]: https://spec.matrix.org/unstable/client-server-api/#sas-method-emoji - */ -export class Emoji { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * The description of the emoji, for example ‘Dog’. - */ - readonly description: string; - /** - * The emoji symbol that represents a part of the short auth - * string, for example: 🐶 - */ - readonly symbol: string; -} - -/** - * An encrypted attachment, usually created from `Attachment.encrypt`. - */ -export class EncryptedAttachment { - free(): void; - [Symbol.dispose](): void; - /** - * Create a new encrypted attachment manually. - * - * It needs encrypted data, stored in an `Uint8Array`, and a - * [media encryption - * information](https://docs.rs/matrix-sdk-crypto/latest/matrix_sdk_crypto/struct.MediaEncryptionInfo.html), - * as a JSON-encoded object. - * - * The media encryption information aren't stored as a string: - * they are parsed, validated and fully deserialized. - * - * See [the specification to learn - * more](https://spec.matrix.org/unstable/client-server-api/#extensions-to-mroommessage-msgtypes). - */ - constructor(encrypted_data: Uint8Array, media_encryption_info: string); - /** - * The actual encrypted data. - * - * **Warning**: It returns a **copy** of the entire encrypted - * data; be nice with your memory. - */ - readonly encryptedData: Uint8Array; - /** - * Check whether the media encryption info has been consumed by - * `Attachment.decrypt` already. - */ - readonly hasMediaEncryptionInfoBeenConsumed: boolean; - /** - * Return the media encryption info as a JSON-encoded object. The - * structure is fully valid. - * - * If the media encryption info have been consumed already, it - * will return `null`. - */ - readonly mediaEncryptionInfo: string | undefined; -} - -/** - * An encryption algorithm to be used to encrypt messages sent to a - * room. - */ -export enum EncryptionAlgorithm { - /** - * Olm version 1 using Curve25519, AES-256, and SHA-256. - */ - OlmV1Curve25519AesSha2 = 0, - /** - * Megolm version 1 using AES-256 and SHA-256. - */ - MegolmV1AesSha2 = 1, - /** - * Unsupported algorithm. - * - * Applications should ignore this value if it is received, and should - * never set it. - */ - Unknown = 2, -} - -/** - * Struct containing information on how a room event was decrypted. - */ -export class EncryptionInfo { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * The verification state of the device that sent us the event. - * Note this is the state of the device at the time of - * decryption. It may change in the future if a device gets - * verified or deleted. - * - * # Arguments - * - * * `strict` - whether to enable "strict mode" verification. In non-strict - * mode, unverified users are given no shield, and keys that have been - * forwarded or restored from an insecure backup are given a grey shield - * (both get a red shield in strict mode). - */ - shieldState(strict: boolean): ShieldState; - /** - * The device ID of the user who sent us the keys with which we decrypted - * this event as part of an MSC4268 key bundle, if present. Only applicable - * for room events. - */ - get forwarderDevice(): DeviceId | undefined; - /** - * The device ID of the user who sent us the keys with which we decrypted - * this event as part of an MSC4268 key bundle, if present. Only applicable - * for room events. - */ - set forwarderDevice(value: DeviceId | null | undefined); - /** - * The ID of the user who sent us the keys with which we decrypted this - * event as part of an MSC4268 key bundle, if present. Only applicable for - * room events. - */ - get forwarder(): UserId | undefined; - /** - * The ID of the user who sent us the keys with which we decrypted this - * event as part of an MSC4268 key bundle, if present. Only applicable for - * room events. - */ - set forwarder(value: UserId | null | undefined); - /** - * The signing Ed25519 key that created the megolm key that - * was used to decrypt this session. - */ - get senderClaimedEd25519Key(): string | undefined; - /** - * The signing Ed25519 key that created the megolm key that - * was used to decrypt this session. - */ - set senderClaimedEd25519Key(value: string | null | undefined); - /** - * The base64-encoded public Curve25519 key of the device that created the - * megolm decryption key originally. - */ - senderCurve25519Key: string; - /** - * The device ID of the device that sent us the event. - * - * Note this is untrusted data unless {@link shieldState} shows that the - * sender is verified. - */ - get senderDevice(): DeviceId | undefined; - /** - * The device ID of the device that sent us the event. - * - * Note this is untrusted data unless {@link shieldState} shows that the - * sender is verified. - */ - set senderDevice(value: DeviceId | null | undefined); - /** - * The user ID of the sender of the event. - * - * Note this is untrusted data unless {@link shieldState} shows that the - * sender is verified. - */ - sender: UserId; -} - -/** - * Settings for an encrypted room. - * - * This determines the algorithm and rotation periods of a group - * session. - */ -export class EncryptionSettings { - free(): void; - [Symbol.dispose](): void; - /** - * Create a new `EncryptionSettings` with default values. - */ - constructor(); - /** - * The encryption algorithm that should be used in the room. - */ - algorithm: EncryptionAlgorithm; - /** - * Whether state event encryption is enabled. - */ - encryptStateEvents: boolean; - /** - * The history visibility of the room when the session was - * created. - */ - historyVisibility: HistoryVisibility; - /** - * How many messages should be sent before changing the session. - */ - rotationPeriodMessages: bigint; - /** - * How long the session should be used before changing it, - * expressed in microseconds. - */ - rotationPeriod: bigint; - /** - * Should untrusted devices receive the room key, or should they be - * excluded from the conversation. - */ - sharingStrategy: CollectStrategy; -} - -/** - * An established ECIES session. - * - * This session can be used to encrypt and decrypt messages between the two - * sides of the channel. - */ -export class EstablishedEcies { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Get the [`CheckCode`] which uniquely identifies this - * [`EstablishedEcies`] session. - * - * This check code can be used to verify and confirm that both sides of the - * session are indeed using the same shared secret. - */ - check_code(): CheckCode; - /** - * Decrypt the given message using this [`EstablishedEcies`] session. - */ - decrypt(message: string): string; - /** - * Encrypt the given plaintext using this [`EstablishedEcies`] session. - */ - encrypt(message: string): string; - /** - * Get our [`Curve25519PublicKey`]. - * - * This public key needs to be sent to the other side so that it can - * complete the ECIES channel establishment. - */ - public_key(): Curve25519PublicKey; -} - -/** - * A Matrix [event ID]. - * - * An `EventId` is generated randomly or converted from a string - * slice, and can be converted back into a string as needed. - * - * [event ID]: https://spec.matrix.org/v1.2/appendices/#room-ids-and-event-ids - */ -export class EventId { - free(): void; - [Symbol.dispose](): void; - /** - * Parse/validate and create a new `EventId`. - */ - constructor(id: string); - /** - * Return the event ID as a string. - */ - toString(): string; - /** - * Returns the event's localpart. - */ - readonly localpart: string; - /** - * Returns the server name of the event ID. - */ - readonly serverName: ServerName | undefined; -} - -/** - * Who can see a room's history. - */ -export enum HistoryVisibility { - /** - * Previous events are accessible to newly joined members from - * the point they were invited onwards. - * - * Events stop being accessible when the member's state changes - * to something other than *invite* or *join*. - */ - Invited = 0, - /** - * Previous events are accessible to newly joined members from - * the point they joined the room onwards. - * - * Events stop being accessible when the member's state changes - * to something other than *join*. - */ - Joined = 1, - /** - * Previous events are always accessible to newly joined members. - * - * All events in the room are accessible, even those sent when - * the member was not a part of the room. - */ - Shared = 2, - /** - * All events while this is the `HistoryVisibility` value may be - * shared by any participating homeserver with anyone, regardless - * of whether they have ever joined the room. - */ - WorldReadable = 3, -} - -/** - * Struct holding the two public identity keys of an account. - */ -export class IdentityKeys { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * The Curve25519 public key, used for establish shared secrets. - */ - curve25519: Curve25519PublicKey; - /** - * The Ed25519 public key, used for signing. - */ - ed25519: Ed25519PublicKey; -} - -/** - * The result of an inbound ECIES channel establishment. - */ -export class InboundCreationResult { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * The established ECIES channel. - */ - channel: EstablishedEcies; - /** - * The plaintext of the initial message. - */ - message: string; -} - -/** - * Inbound group session. - * - * Inbound group sessions are used to exchange room messages between a group of - * participants. Inbound group sessions are used to decrypt the room messages. - */ -export class InboundGroupSession { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Has the session been imported from a file or server-side backup? As - * opposed to being directly received as an `m.room_key` event. - */ - hasBeenImported(): boolean; - /** - * The room where this session is used in. - */ - readonly roomId: RoomId; - /** - * The Curve25519 key of the sender of this session, as a - * [Curve25519PublicKey]. - */ - readonly senderKey: Curve25519PublicKey; - /** - * Returns the unique identifier for this session. - */ - readonly sessionId: string; -} - -/** - * Represents an invalid to-device event that was ignored (because it is - * missing some mandatory fields, for example). - */ -export class InvalidToDeviceEvent { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * The original message as received from sync, encoded as JSON. - */ - readonly rawEvent: string; - /** - * The type of processed to-device event. Always {@link - * ProcessedToDeviceEventType.Invalid} for this type. - */ - readonly type: ProcessedToDeviceEventType; -} - -/** - * A request that will back up a batch of room keys to the server - * ([specification]). - * - * [specification]: https://spec.matrix.org/unstable/client-server-api/#put_matrixclientv3room_keyskeys - */ -export class KeysBackupRequest { - free(): void; - [Symbol.dispose](): void; - /** - * Create a new `KeysBackupRequest`. - */ - constructor(id: string, body: string, version: string); - /** - * A JSON-encoded object containing the rest of the payload: `rooms`. - * - * It represents the body of the HTTP request. - */ - readonly body: string; - /** - * The request ID. - */ - readonly id: string; - /** - * The backup version that these room keys should be part of. - */ - readonly version: string; - /** - * Get its request type. - */ - readonly type: RequestType; -} - -/** - * Data for a request to the `/keys/claim` API endpoint - * ([specification]). - * - * Claims one-time keys that can be used to establish 1-to-1 E2EE - * sessions. - * - * [specification]: https://spec.matrix.org/unstable/client-server-api/#post_matrixclientv3keysclaim - */ -export class KeysClaimRequest { - free(): void; - [Symbol.dispose](): void; - /** - * Create a new `KeysClaimRequest`. - */ - constructor(id: string, body: string); - /** - * A JSON-encoded object containing the rest of the payload: `timeout`, - * `one_time_keys`. - * - * It represents the body of the HTTP request. - */ - readonly body: string; - /** - * The request ID. - */ - readonly id: string; - /** - * Get its request type. - */ - readonly type: RequestType; -} - -/** - * Data for a request to the `/keys/query` API endpoint - * ([specification]). - * - * Returns the current devices and identity keys for the given users. - * - * [specification]: https://spec.matrix.org/unstable/client-server-api/#post_matrixclientv3keysquery - */ -export class KeysQueryRequest { - free(): void; - [Symbol.dispose](): void; - /** - * Create a new `KeysQueryRequest`. - */ - constructor(id: string, body: string); - /** - * A JSON-encoded object containing the rest of the payload: `timeout`, - * `device_keys`, `token`. - * - * It represents the body of the HTTP request. - */ - readonly body: string; - /** - * The request ID. - */ - readonly id: string; - /** - * Get its request type. - */ - readonly type: RequestType; -} - -/** - * Data for a request to the `/keys/upload` API endpoint - * ([specification]). - * - * Publishes end-to-end encryption keys for the device. - * - * [specification]: https://spec.matrix.org/unstable/client-server-api/#post_matrixclientv3keysupload - */ -export class KeysUploadRequest { - free(): void; - [Symbol.dispose](): void; - /** - * Create a new `KeysUploadRequest`. - */ - constructor(id: string, body: string); - /** - * A JSON-encoded object containing the rest of the payload: `device_keys`, - * `one_time_keys`, `fallback_keys`. - * - * It represents the body of the HTTP request. - */ - readonly body: string; - /** - * The request ID. - */ - readonly id: string; - /** - * Get its request type. - */ - readonly type: RequestType; -} - -/** - * The local trust state of a device. - */ -export enum LocalTrust { - /** - * The device has been verified and is trusted. - */ - Verified = 0, - /** - * The device been blacklisted from communicating. - */ - BlackListed = 1, - /** - * The trust state of the device is being ignored. - */ - Ignored = 2, - /** - * The trust state is unset. - */ - Unset = 3, -} - -/** - * Logger level. - */ -export enum LoggerLevel { - /** - * `TRACE` level. - * - * Designate very low priority, often extremely verbose, - * information. - */ - Trace = 0, - /** - * `DEBUG` level. - * - * Designate lower priority information. - */ - Debug = 1, - /** - * `INFO` level. - * - * Designate useful information. - */ - Info = 2, - /** - * `WARN` level. - * - * Designate hazardous situations. - */ - Warn = 3, - /** - * `ERROR` level. - * - * Designate very serious errors. - */ - Error = 4, -} - -/** - * Represents a signature that is either valid _or_ that could not be - * decoded. - */ -export class MaybeSignature { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Check whether the signature could not be successfully decoded. - */ - isInvalid(): boolean; - /** - * Check whether the signature has been successfully decoded. - */ - isValid(): boolean; - /** - * The base64 encoded string that is claimed to contain a - * signature but could not be decoded, if any. - */ - readonly invalidSignatureSource: string | undefined; - /** - * The signature, if successfully decoded. - */ - readonly signature: Signature | undefined; -} - -/** - * Js Decryption error with code. - */ -export class MegolmDecryptionError { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Creates generic error with description - */ - static unable_to_decrypt(desc: string): MegolmDecryptionError; - /** - * Description code for the error. See `DecryptionErrorCode` - */ - readonly code: DecryptionErrorCode; - /** - * detailed description - */ - readonly description: string; - /** - * Textual description of the withheld code, if any. - * - * Example: "The sender has disabled encrypting to unverified devices." - * - * `undefined` if we have not received a withheld code for the megolm - * session. - */ - readonly maybe_withheld: string | undefined; - /** - * The withheld code, if any. - * - * Example: "m.unverified" - * - * `undefined` if we have not received a withheld code for the megolm - * session. - */ - readonly withheldCode: string | undefined; -} - -/** - * The public part of the backup key. - */ -export class MegolmV1BackupKey { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Get the full name of the backup algorithm this backup key supports. - */ - readonly algorithm: string; - /** - * The actual base64 encoded public key. - */ - readonly publicKeyBase64: string; -} - -/** - * Migration routines - * - * The public methods are exposed as static methods on this class, for - * namespacing and to enable easier mocking in unit tests. - */ -export class Migration { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Import the base dataset from a libolm-based setup to a vodozemac-based - * setup stored in IndexedDB. - * - * Populates the user credentials, Olm account, backup data, etc. This is - * the first step in the migration process. Once this base data is - * imported, further data can be imported with {@link - * migrateOlmSessions}, {@link migrateMegolmSessions}, and TODO room - * settings. - * - * # Arguments - * - * * `data` - The data to be migrated - * * `pickle_key` - The libolm pickle key that was used to pickle the olm - * account objects. - * * `store_handle` - A connection to the CryptoStore which will be used to - * store the vodozemac data. - * * `logger` - An optional logger instance to use for writing log messages - * during the migration operation. An instance of `JsLogger`. - */ - static migrateBaseData(data: BaseMigrationData, pickle_key: Uint8Array, store_handle: StoreHandle, logger?: JsLogger): Promise; - /** - * Migrate Megolm sessions of a libolm-based setup to a vodozemac-based - * setup stored in an indexedDB crypto store. - * - * Before this method can be used, {@link migrateBaseData} must be used to - * import the base data into the crypto store. - * - * This method should be called a number of times, with separate batches of - * `sessions`. If a progress display is given, it can be updated after - * each batch is successfully imported. - * - * # Arguments - * - * * `sessions` - An `Array` of {@link PickledInboundGroupSession}s to - * import. Items inside `sessions` will be invalidated by this method. - * * `pickle_key` - The libolm pickle key that was used to pickle the - * megolm session objects. - * * `store_handle` - A connection to the CryptoStore which will be used to - * store the vodozemac data. - * * `logger` - An optional logger instance to use for writing log messages - * during the migration operation. An instance of `JsLogger`. - */ - static migrateMegolmSessions(sessions: PickledInboundGroupSession[], pickle_key: Uint8Array, store_handle: StoreHandle, logger?: JsLogger): Promise; - /** - * Migrate Olm sessions of a libolm-based setup to a vodozemac-based setup - * stored in an indexedDB crypto store. - * - * Before this method can be used, {@link migrateBaseData} must be used to - * import the base data into the crypto store. - * - * This method should be called a number of times, with separate batches of - * `sessions`. If a progress display is given, it can be updated after - * each batch is successfully imported. - * - * # Arguments - * - * * `sessions` - An `Array` of {@link PickledSession}s to import. Items - * inside `sessions` will be invalidated by this method. - * * `pickle_key` - The libolm pickle key that was used to pickle the olm - * session objects. - * * `store_handle` - A connection to the CryptoStore which will be used to - * store the vodozemac data. - * * `logger` - An optional logger instance to use for writing log messages - * during the migration operation. An instance of `JsLogger`. - */ - static migrateOlmSessions(sessions: PickledSession[], pickle_key: Uint8Array, store_handle: StoreHandle, logger?: JsLogger): Promise; -} - -/** - * Intent-specific data in the case the QR code adheres to - * {@link https://github.com/matrix-org/matrix-spec-proposals/pull/4108 MSC4108} of the QR code - * data format. - */ -export class Msc4108IntentData { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Get the URL of the rendezvous server which will be used to exchange - * messages between the two devices. - */ - rendezvousUrl: string; - /** - * Get the server name of the homeserver which the new device will be - * logged in to. - * - * This will be only available if the existing device has generated the QR - * code and the new device is the one scanning the QR code. - */ - get serverName(): string | undefined; - /** - * Get the server name of the homeserver which the new device will be - * logged in to. - * - * This will be only available if the existing device has generated the QR - * code and the new device is the one scanning the QR code. - */ - set serverName(value: string | null | undefined); -} - -/** - * Intent-specific data in the case the QR code adheres to - * {@link https://github.com/matrix-org/matrix-spec-proposals/pull/4388 MSC4388} of the QR code - * data format. - */ -export class Msc4388IntentData { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * The base URL of the homeserver that the device generating the QR is - * using. - */ - baseUrl: string; - /** - * The ID of the rendezvous session, can be used to exchange messages with - * the other device. - */ - rendezvousId: string; -} - -/** - * State machine implementation of the Olm/Megolm encryption protocol - * used for Matrix end to end encryption. - */ -export class OlmMachine { - free(): void; - [Symbol.dispose](): void; - /** - * Encrypt a batch of room keys and return a request that needs to be sent - * out to backup the room keys. - * - * Returns an optional {@link KeysBackupRequest}. - */ - backupRoomKeys(): Promise; - /** - * Create a new cross signing identity and get the upload request - * to push the new public keys to the server. - * - * Warning: This will delete any existing cross signing keys that - * might exist on the server and thus will reset the trust - * between all the devices. - * - * Uploading these keys will require user interactive auth. - * - * # Arguments - * - * * `reset`, whether the method should create a new identity or use the - * existing one during the request. If set to true, the request will - * attempt to upload a new identity. If set to false, the request will - * attempt to upload the existing identity. Since the uploading process - * requires user interactive authentication, which involves sending out - * the same request multiple times, setting this argument to false - * enables you to reuse the same request. - * - * Returns a {@link CrossSigningBootstrapRequests}. - */ - bootstrapCrossSigning(reset: boolean): Promise; - /** - * Assemble, and encrypt, a room key bundle for sharing encrypted history, - * as per {@link https://github.com/matrix-org/matrix-spec-proposals/pull/4268|MSC4268}. - * - * Returns `undefined` if there are no keys to share in the given room, - * otherwise an {@link EncryptedAttachment}. - * - * The data should be uploaded to the media server, and the details then - * passed to {@link shareRoomKeyBundleData}. - * - * @experimental - */ - buildRoomKeyBundle(room_id: RoomId): Promise; - /** - * Store the fact that we are no longer waiting for a key bundle in the - * given room. - * - * The counterpart to {@link storeRoomPendingKeyBundle}. Should be called - * when, for example, we leave a room, or have successfully imported a - * bundle. - * - * @experimental - */ - clearRoomPendingKeyBundle(room_id: RoomId): Promise; - /** - * Shut down the `OlmMachine`. - * - * The `OlmMachine` cannot be used after this method has been called. - * - * All associated resources will be closed too, like IndexedDB - * connections. - */ - close(): void; - /** - * Get the status of the private cross signing keys. - * - * This can be used to check which private cross signing keys we - * have stored locally. - */ - crossSigningStatus(): Promise; - /** - * Try to decrypt a reader into a list of exported room keys. - * - * `encrypted_exported_room_keys` is the result from - * `encrypt_exported_room_keys`. `passphrase` is the passphrase that was - * used when calling `encrypt_exported_room_keys`. - */ - static decryptExportedRoomKeys(encrypted_exported_room_keys: string, passphrase: string): string; - /** - * Decrypt an event from a room timeline. - * - * # Arguments - * - * * `event`, the event that should be decrypted. - * * `room_id`, the ID of the room where the event was sent to. - * - * # Returns - * - * A `Promise` which resolves to a {@link DecryptedRoomEvent} instance, or - * rejects with a {@link MegolmDecryptionError} instance. - */ - decryptRoomEvent(event: string, room_id: RoomId, decryption_settings: DecryptionSettings): Promise; - /** - * Manage dehydrated devices - */ - dehydratedDevices(): DehydratedDevices; - /** - * Delete all secrets with the given secret name from the inbox. - * - * Should be called after handling the secrets with - * `get_secrets_from_inbox`. - * - * # Arguments - * - * * `secret_name` - The name of the secret to delete. - */ - deleteSecretsFromInbox(secret_name: string): Promise; - /** - * Disable and reset our backup state. - * - * This will remove any pending backup request, remove the backup key and - * reset the backup state of each room key we have. - * - * Returns `Promise`. - */ - disableBackup(): Promise; - /** - * Activate the given backup key to be used with the given backup version. - * - * **Warning**: The caller needs to make sure that the given `BackupKey` is - * trusted, otherwise we might be encrypting room keys that a malicious - * party could decrypt. - * - * The {@link verifyBackup} method can be used to do so. - * - * Returns `Promise`. - */ - enableBackupV1(public_key_base_64: string, version: string): Promise; - /** - * Encrypt the list of exported room keys using the given passphrase. - * - * `exported_room_keys` is a list of sessions that should be encrypted - * (it's generally returned by `export_room_keys`). `passphrase` is the - * passphrase that will be used to encrypt the exported room keys. And - * `rounds` is the number of rounds that should be used for the key - * derivation when the passphrase gets turned into an AES key. More rounds - * are increasingly computationnally intensive and as such help against - * brute-force attacks. Should be at least `10_000`, while values in the - * `100_000` ranges should be preferred. - */ - static encryptExportedRoomKeys(exported_room_keys: string, passphrase: string, rounds: number): string; - /** - * Encrypt a room message for the given room. - * - * **Note**: A room key needs to be shared with the group of users that are - * members in the given room. If this is not done this method will panic. - * - * The usual flow to encrypt an event using this state machine is as - * follows: - * - * 1. Get the one-time key claim request to establish 1:1 Olm sessions for - * the room members of the room we wish to participate in. This is done - * using the [`get_missing_sessions()`](Self::get_missing_sessions) - * method. This method call should be locked per call. - * - * 2. Share a room key with all the room members using the - * [`share_room_key()`](Self::share_room_key). This method call should - * be locked per room. - * - * 3. Encrypt the event using this method. - * - * 4. Send the encrypted event to the server. - * - * After the room key is shared steps 1 and 2 will become noops, unless - * there's some changes in the room membership or in the list of devices a - * member has. - * - * - * `room_id` is the ID of the room for which the message should - * be encrypted. `event_type` is the type of the event. `content` - * is the plaintext content of the message that should be - * encrypted. - * - * # Panics - * - * Panics if a group session for the given room wasn't shared - * beforehand. - */ - encryptRoomEvent(room_id: RoomId, event_type: string, content: string): Promise; - /** - * Encrypt a state event for the given room. - * - * This method encrypts a state event for the specified room, using the - * current group session. The event will be encrypted so that only - * authorized room members can decrypt it. - * - * **Note**: A room key must have been shared with the group of users in - * the room before calling this method. If not, this method will panic. - * - * The usual flow to encrypt a state event using this machine is identical - * to that outlined for [`OlmMachine::encrypt_room_event`]. - * - * # Arguments - * - * * `room_id` - The ID of the room for which the state event should be - * encrypted. - * * `event_type` - The type of the state event. - * * `state_key` - The state key for the event. - * * `content` - The plaintext JSON content of the event to encrypt. - * - * # Returns - * - * A `Promise` resolving to a JSON string containing the encrypted event. - * - * # Panics - * - * Panics if a group session for the given room was not previously shared. - */ - encryptStateEvent(room_id: RoomId, event_type: string, state_key: string, content: string): Promise; - /** - * Export all the private cross signing keys we have. - * - * The export will contain the seeds for the ed25519 keys as - * unpadded base64 encoded strings. - * - * Returns `undefined` if we don’t have any private cross signing keys; - * otherwise returns a `CrossSigningKeyExport`. - */ - exportCrossSigningKeys(): Promise; - /** - * Export the keys that match the given predicate. - * - * `predicate` is a closure that will be called for every known - * `InboundGroupSession`, which represents a room key. If the closure - * returns `true`, the `InboundGroupSession` will be included in the - * export; otherwise it won't. - * - * Returns a Promise containing a Result containing a String which is a - * JSON-encoded array of ExportedRoomKey objects. - */ - exportRoomKeys(predicate: (session: InboundGroupSession) => boolean): Promise; - /** - * Export all the secrets we have in the store into a {@link - * SecretsBundle}. - * - * This method will export all the private cross-signing keys and, if - * available, the private part of a backup key and its accompanying - * version. - * - * The method will fail if we don't have all three private cross-signing - * keys available. - * - * **Warning**: Only export this and share it with a trusted recipient, - * i.e. if an existing device is sharing this with a new device. - */ - exportSecretsBundle(): Promise>; - /** - * Get a list of all rooms where we are waiting for a key bundle. - * - * @see getPendingKeyBundleDetailsForRoom - * - * @experimental - */ - getAllRoomsPendingKeyBundles(): Promise>; - /** - * Get the backup keys we have saved in our store. - * Returns a `Promise` for {@link BackupKeys}. - */ - getBackupKeys(): Promise; - /** - * Get a specific device of a user. - * - * ### Parameters - * - * * `user_id` - The unique ID of the user that the device belongs to. - * - * * `device_id` - The unique ID of the device. - * - * * `timeout_secs` - The amount of time we should wait for a `/keys/query` - * response before returning if the user's device list has been marked as - * stale. **Note**, this assumes that the requests from {@link - * OlmMachine.outgoingRequests} are being processed and sent out. - * - * If unset, we will return immediately even if the device list is stale. - * - * ### Returns - * - * If the device is known, a {@link Device}. Otherwise, `undefined`. - */ - getDevice(user_id: UserId, device_id: DeviceId, timeout_secs?: number | null): Promise; - /** - * Get the cross signing user identity of a user. - * - * Returns a promise for an {@link OwnUserIdentity}, a - * {@link OtherUserIdentity}, or `undefined`. - */ - getIdentity(user_id: UserId): Promise; - /** - * Get the a key claiming request for the user/device pairs that - * we are missing Olm sessions for. - * - * Returns `null` if no key claiming request needs to be sent - * out, otherwise it returns a `KeysClaimRequest` object. - * - * Sessions need to be established between devices so group - * sessions for a room can be shared with them. - * - * This should be called every time a group session needs to be - * shared as well as between sync calls. After a sync some - * devices may request room keys without us having a valid Olm - * session with them, making it impossible to server the room key - * request, thus it’s necessary to check for missing sessions - * between sync as well. - * - * Note: Care should be taken that only one such request at a - * time is in flight, e.g. using a lock. - * - * The response of a successful key claiming requests needs to be - * passed to the `OlmMachine` with the `mark_request_as_sent`. - * - * `users` represents the list of users that we should check if - * we lack a session with one of their devices. This can be an - * empty iterator when calling this method between sync requests. - * - * Items inside `users` will be invalidated by this method. Be careful not - * to use the `UserId`s after this method has been called. - */ - getMissingSessions(users: UserId[]): Promise; - /** - * See if we have recently accepted an invitation to the given room. - * - * If we have accepted an invite to a room without finding an - * {@link https://github.com/matrix-org/matrix-spec-proposals/pull/4268|MSC4268} - * key bundle, we should accept a key bundle once one arrives. - * - * The data returned here is populated by the application, via {@link - * storeRoomPendingKeyBundle}. - * - * @experimental - */ - getPendingKeyBundleDetailsForRoom(room_id: RoomId): Promise; - /** - * See if we have received an {@link https://github.com/matrix-org/matrix-spec-proposals/pull/4268|MSC4268} - * room key bundle for the given room from the given user. - * - * Before calling this, the application must make sure that we have an - * up-to-date copy of the inviter's cross-signing keys, so that we can - * verify the device that sent us the key bundle data message. (For - * now, the easiest way to do that is by calling {@link queryKeysForUsers} - * for the inviter, and making the resultant request.) - * - * Returns either `undefined` if no suitable bundle has been received, - * or an {@link StoredRoomKeyBundleData}, in which case, the bundle - * should be downloaded, and then passed to {@link - * receiveRoomKeyBundle}. - * - * @experimental - */ - getReceivedRoomKeyBundleData(room_id: RoomId, inviter: UserId): Promise; - /** - * Get encryption info for a decrypted timeline event. - * - * This recalculates the `EncryptionInfo` data that is returned by - * `decryptRoomEvent`, based on the current - * verification status of the sender, etc. - * - * Returns an error for an unencrypted event. - * - * # Arguments - * - * * `event` - The event to get information for. - * * `room_id` - The ID of the room where the event was sent to. - * - * # Returns - * - * {@link EncryptionInfo} - */ - getRoomEventEncryptionInfo(event: string, room_id: RoomId): Promise; - /** - * Get the stored room settings, such as the encryption algorithm or - * whether to encrypt only for trusted devices. - * - * These settings can be modified via {@link setRoomSettings}. - * - * # Returns - * - * `Promise` - */ - getRoomSettings(room_id: RoomId): Promise>; - /** - * Get all the secrets with the given secret_name we have currently - * stored. - * The only secret this will currently return is the - * `m.megolm_backup.v1` secret. - * - * Usually you would just register a callback with - * [`register_receive_secret_callback`], but if the client is shut down - * before handling them, this method can be used to retrieve them. - * This method should therefore be called at client startup to retrieve any - * secrets received during the previous session. - * - * The secrets are guaranteed to have been received over a 1-to-1 encrypted - * to_device message from one of the user's own verified devices. - * - * Returns a `Promise` for a `Set` of `String` corresponding to the secret - * values. - * - * If the secret is valid and handled, the secret inbox should be cleared - * by calling `delete_secrets_from_inbox`. - */ - getSecretsFromInbox(secret_name: string): Promise>; - /** - * Get a map holding all the devices of a user. - * - * ### Parameters - * - * * `user_id` - The unique ID of the user that the device belongs to. - * - * * `timeout_secs` - The amount of time we should wait for a `/keys/query` - * response before returning if the user's device list has been marked as - * stale. **Note**, this assumes that the requests from {@link - * OlmMachine.outgoingRequests} are being processed and sent out. - * - * If unset, we will return immediately even if the device list is stale. - * - * ### Returns - * - * A {@link UserDevices} object. - */ - getUserDevices(user_id: UserId, timeout_secs?: number | null): Promise; - /** - * Get a verification object for the given user ID with the given - * flow ID (a to-device request ID if the verification has been - * requested by a to-device request, or a room event ID if the - * verification has been requested by a room event). - * - * It returns a “`Verification` object”, which is either a `Sas` - * or `Qr` object. - */ - getVerification(user_id: UserId, flow_id: string): Sas | Qr | undefined; - /** - * Get a verification request object with the given flow ID. - */ - getVerificationRequest(user_id: UserId, flow_id: string): VerificationRequest | undefined; - /** - * Get all the verification requests of a given user. - */ - getVerificationRequests(user_id: UserId): VerificationRequest[]; - /** - * Get whether we have previously downloaded all message keys for a - * particular room from the key backup. Typically called in advance of - * building a room key bundle. - */ - hasDownloadedAllRoomKeys(room_id: RoomId): Promise; - /** - * Import the given room keys into our store. - * - * # Arguments - * - * * `backed_up_room_keys`: keys that were retrieved from backup and that - * should be added to our store (provided they are better than our - * current versions of those keys). Specifically, it should be a Map from - * {@link RoomId}, to a Map from session ID to a (decrypted) session data - * structure. - * - * * `progress_listener`: an optional callback that takes 3 arguments: - * `progress` (the number of keys that have successfully been imported), - * `total` (the total number of keys), and `failures` (the number of keys - * that failed to import), and returns nothing. - * - * # Returns - * - * A {@link RoomKeyImportResult}. - */ - importBackedUpRoomKeys(backed_up_room_keys: Map>, progress_listener: (progress: bigint, total: bigint, failures: bigint) => void | undefined, backup_version: string): Promise; - /** - * Import our private cross signing keys. - * - * The keys should be provided as unpadded-base64-encoded strings. - * - * Returns a `CrossSigningStatus`. - */ - importCrossSigningKeys(master_key?: string | null, self_signing_key?: string | null, user_signing_key?: string | null): Promise; - /** - * Import the given room keys into our store. - * - * `exported_keys` is a JSON-encoded list of previously exported keys that - * should be imported into our store. If we already have a better - * version of a key, the key will _not_ be imported. - * - * `progress_listener` is a closure that takes 2 `BigInt` arguments: - * `progress` and `total`, and returns nothing. - * - * Returns a {@link RoomKeyImportResult}. - */ - importExportedRoomKeys(exported_room_keys: string, progress_listener: (progress: bigint, total: bigint) => void): Promise; - /** - * Import the given room keys into our store. - * - * Mostly, a deprecated alias for `importExportedRoomKeys`, though the - * return type is different. - * - * Returns a String containing a JSON-encoded object, holding three - * properties: - * * `total_count` (the total number of keys found in the export data). - * * `imported_count` (the number of keys that were imported). - * * `keys` (the keys that were imported; a map from room id to a map of - * the sender key to a list of session ids). - * - * @deprecated Use `importExportedRoomKeys` or `importBackedUpRoomKeys`. - */ - importRoomKeys(exported_room_keys: string, progress_listener: (imported: bigint, total: bigint) => void): Promise; - /** - * Import and persists secrets from a {@link SecretsBundle}. - * - * This method will import all the private cross-signing keys and, if - * available, the private part of a backup key and its accompanying - * version into the store. - * - * **Warning**: Only import this from a trusted source, i.e. if an existing - * device is sharing this with a new device. The imported cross-signing - * keys will create a {@link OwnUserIdentity} and mark it as verified. - * - * The backup key will be persisted in the store and can be enabled using - * the BackupMachine. - * - * The provided `SecretsBundle` is freed by this method; be careful not to - * use it once this method has been called. - */ - importSecretsBundle(bundle: SecretsBundle): Promise; - /** - * Create a new `OlmMachine` backed by an existing store. - * - * # Arguments - * - * * `user_id` - represents the unique ID of the user that owns this - * machine. - * - * * `device_id` - represents the unique ID of the device - * that owns this machine. - * - * * `store_handle` - the connection to the crypto store to be used for - * this machine. - * - * * `logger` - Optional logger to use for all operations on this machine. - * An instance of `JsLogger`. - * - * * `ca_certs_pem` - Optional PEM-formatted string that provides CA - * certificates. These will be used to check X.509 signatures on user - * identities. Any user identity that has a valid signature according to - * the supplied CAs will be considered verified, without any manual - * - * * `raw_x509_signer` - Optional async function for signing some data with - * an X.509 certificate. Used to sign the user's identity so compatible - * clients will recognise this user as verified without manual - * verification taking place. If you supply this you must also supply - * raw_x509_validity. - * - * * `raw_x509_validity` - Optional function returning the validity period - * of the X.509 certificate used for signing, as the number of - * milliseconds since the Unix epoch. If you supply this you must also - * supply raw_x509_signer. - */ - static initFromStore(user_id: UserId, device_id: DeviceId, store_handle: StoreHandle, logger?: JsLogger, ca_certs_pem?: String, raw_x509_signer?: (item: Uint8Array) => Promise<{ signature_bytes: Uint8Array, certificate_chain: string }>, raw_x509_validity?: () => number): Promise; - /** - * Create a new `OlmMachine`. - * - * The created machine will keep the encryption keys either in a IndexedDB - * based store, or in a memory store and once the objects is dropped, - * the keys will be lost. - * - * # Arguments - * - * * `user_id` - represents the unique ID of the user that owns this - * machine. - * - * * `device_id` - represents the unique ID of the device - * that owns this machine. - * - * * `store_name` - The name that should be used to open the IndexedDB - * based database. If this isn't provided, a memory-only store will be - * used. *Note* the memory-only store will lose your E2EE keys when the - * `OlmMachine` gets dropped. - * - * * `store_passphrase` - The passphrase that should be used to encrypt the - * IndexedDB-based store. - * - * * `logger` - Optional logger to use for all operations on this machine. - * An instance of `JsLogger`. - * - * * `ca_certs_pem` - Optional PEM-formatted string that provides CA - * certificates. These will be used to check X.509 signatures on user - * identities. Any user identity that has a valid signature according to - * the supplied CAs will be considered verified, without any manual - * verification taking place. A PEM-formatted string. - * - * * `raw_x509_signer` - Optional async function for signing some data with - * an X.509 certificate. Used to sign the user's identity so compatible - * clients will recognise this user as verified without manual - * verification taking place. If you supply this you must also supply - * raw_x509_validity. - * - * * `raw_x509_validity` - Optional function returning the validity period - * of the X.509 certificate used for signing, as the number of - * milliseconds since the Unix epoch. If you supply this you must also - * supply raw_x509_signer. - */ - static initialize(user_id: UserId, device_id: DeviceId, store_name?: string, store_passphrase?: string, logger?: JsLogger, ca_certs_pem?: String, raw_x509_signer?: (item: Uint8Array) => Promise<{ signature_bytes: Uint8Array, certificate_chain: string }>, raw_x509_validity?: () => number): Promise; - /** - * Invalidate the currently active outbound group session for the - * given room. - * - * Returns true if a session was invalidated, false if there was - * no session to invalidate. - */ - invalidateGroupSession(room_id: RoomId): Promise; - /** - * Are we able to encrypt room keys. - * - * This returns true if we have an active `BackupKey` and backup version - * registered with the state machine. - * - * Returns `Promise`. - */ - isBackupEnabled(): Promise; - /** - * Mark all tracked users as dirty. - * - * All users *whose device lists we are tracking* are flagged as needing a - * key query. Users whose devices we are not tracking are ignored. - */ - markAllTrackedUsersAsDirty(): Promise; - /** - * Mark the request with the given request ID as sent (see - * `outgoing_requests`). - * - * Arguments are: - * - * * `request_id` represents the unique ID of the request that was sent - * out. This is needed to couple the response with the now sent out - * request. - * * `response_type` represents the type of the request that was sent out. - * * `response` represents the response that was received from the server - * after the outgoing request was sent out. - */ - markRequestAsSent(request_id: string, request_type: RequestType, response: string): Promise; - /** - * Constructor will always fail. To create a new `OlmMachine`, please use - * the `initialize` method. - * - * Why this pattern? `initialize` returns a `Promise`. Returning a - * `Promise` from a constructor is not idiomatic in JavaScript. - */ - constructor(); - /** - * Get the outgoing requests that need to be sent out. - * - * This returns a list of values, each of which can be any of: - * * {@link KeysUploadRequest}, - * * {@link KeysQueryRequest}, - * * {@link KeysClaimRequest}, - * * {@link ToDeviceRequest}, - * * {@link SignatureUploadRequest}, - * * {@link RoomMessageRequest}, or - * * {@link KeysBackupRequest}. - * - * Those requests need to be sent out to the server and the - * responses need to be passed back to the state machine - * using {@link OlmMachine.markRequestAsSent}. - */ - outgoingRequests(): Promise; - /** - * Push a secret to all of our other verified devices - * - * This function assumes that we already have Olm sessions with the other - * devices. This can be done by calling {@link - * OlmMachine.getMissingSessions}. - * - * # Arguments - * - * * `secret_name` - The name of the secret to push. - */ - pushSecretToVerifiedDevices(name: string): Promise; - /** - * Generate an "out-of-band" key query request for the given set of users. - * - * This can be useful if we need the results from `getIdentity` or - * `getUserDevices` to be as up-to-date as possible. - * - * Returns a `KeysQueryRequest` object. The response of the request should - * be passed to the `OlmMachine` with the `mark_request_as_sent`. - * - * Items inside `users` will be invalidated by this method. Be careful not - * to use the `UserId`s after this method has been called. - */ - queryKeysForUsers(users: UserId[]): KeysQueryRequest; - /** - * Import the message keys from a downloaded room key bundle. - * - * After {@link getReceivedRoomKeyBundleData} returns a truthy result, the - * media file should be downloaded and then passed into this method to - * actually do the import. - * - * @experimental - */ - receiveRoomKeyBundle(bundle_data: StoredRoomKeyBundleData, encrypted_bundle: Uint8Array): Promise; - /** - * Handle to-device events and one-time key counts from a sync - * response. - * - * This will decrypt and handle to-device events returning the - * decrypted versions of them. - * - * To decrypt an event from the room timeline call - * `decrypt_room_event`. - * - * # Arguments - * - * * `to_device_events`: the JSON-encoded to-device evens from the `/sync` - * response - * * `changed_devices`: the mapping of changed and left devices, from the - * `/sync` response - * * `one_time_keys_counts`: The number of one-time keys on the server, - * from the `/sync` response. A `Map` from string (encryption algorithm) - * to number (number of keys). Following the sync v2 semantics, a missing - * entry for an algorithm means that there are *zero* keys of that type - * on the server. If the caller has no information about the key counts - * (for example, because it is processing only part of a sync response), - * it should use {@link receiveSyncChangesMsc4186} instead. - * * `unused_fallback_keys`: Optionally, a `Set` of unused fallback keys on - * the server, from the `/sync` response. If this is set, it is used to - * determine if new fallback keys should be uploaded. - * * `decryption_settings`: Optionally, the settings to use when decrypting - * to-device events. If not set, to-device events will be decrypted with - * a {@link TrustRequirement} of `Untrusted`. - * - * # Returns - * - * A list of values, each of which can be any of: - * * {@link DecryptedToDeviceEvent} - * * {@link PlainTextToDeviceEvent} - * * {@link UTDToDeviceEvent} - * * {@link InvalidToDeviceEvent} - */ - receiveSyncChanges(to_device_events: string, changed_devices: DeviceLists, one_time_keys_counts: Map, unused_fallback_keys?: Set, decryption_settings?: DecryptionSettings): Promise; - /** - * Handle the changes to the end-to-end encryption state we received from - * a [MSC4186](https://github.com/matrix-org/matrix-spec-proposals/pull/4186) - * (simplified sliding sync) response. - * - * This behaves exactly like {@link receiveSyncChanges}, except for the - * handling of `one_time_keys_counts`: under MSC4186 semantics, a missing - * entry for an algorithm means that the number of keys on the server is - * *unchanged*, rather than zero. - * - * This is therefore also the method to use when the caller has no - * information about the one-time key counts, for example because it is - * processing only the to-device events or the device list changes from a - * sync response. - * - * # Arguments - * - * * `to_device_events`: the JSON-encoded to-device events from the sync - * response - * * `changed_devices`: the mapping of changed and left devices, from the - * sync response - * * `one_time_keys_counts`: The number of one-time keys on the server, - * from the sync response. A `Map` from string (encryption algorithm) to - * number (number of keys). A missing entry means "unchanged". - * * `unused_fallback_keys`: Optionally, a `Set` of unused fallback keys on - * the server, from the sync response. If this is set, it is used to - * determine if new fallback keys should be uploaded. - * * `decryption_settings`: Optionally, the settings to use when decrypting - * to-device events. If not set, to-device events will be decrypted with - * a {@link TrustRequirement} of `Untrusted`. - * - * # Returns - * - * A list of values, each of which can be any of: - * * {@link DecryptedToDeviceEvent} - * * {@link PlainTextToDeviceEvent} - * * {@link UTDToDeviceEvent} - * * {@link InvalidToDeviceEvent} - */ - receiveSyncChangesMsc4186(to_device_events: string, changed_devices: DeviceLists, one_time_keys_counts: Map, unused_fallback_keys?: Set, decryption_settings?: DecryptionSettings): Promise; - /** - * Receive a verification event. - * - * This method can be used to pass verification events that are happening - * in rooms to the `OlmMachine`. The event should be in the decrypted form. - */ - receiveVerificationEvent(event: string, room_id: RoomId): Promise; - /** - * Register a callback which will be called whenever there is an update to - * a device. - * - * `callback` should be a function that takes a single argument (an array - * of user IDs as strings) and returns a Promise. - */ - registerDevicesUpdatedCallback(callback: (userIds: string[]) => Promise): void; - /** - * Register a callback which will be called whenever a secret - * (`m.secret.send`) is received. - * - * The only secret this will currently broadcast is the - * `m.megolm_backup.v1` (the cross signing secrets are handled internally). - * - * To request a secret from other devices, a client sends an - * `m.secret.request` device event with `action` set to `request` and - * `name` set to the identifier of the secret. A device that wishes to - * share the secret will reply with an `m.secret.send` event, encrypted - * using olm. - * - * The secrets are guaranteed to have been received over a 1-to-1 encrypted - * to_device message from a one of the user's own verified devices. - * - * See https://matrix-org.github.io/matrix-rust-sdk/matrix_sdk_crypto/store/struct.Store.html#method.secrets_stream for more information. - * - * `callback` should be a function that takes 2 arguments: the secret name - * (string) and value (string). - * - * **Note**: if the secret is valid and handled on the javascript side, the - * secret inbox should be cleared by calling - * `delete_secrets_from_inbox`. - */ - registerReceiveSecretCallback(callback: (name: string, value: string) => Promise): void; - /** - * Register a callback which will be called whenever there is an update to - * a room key. - * - * `callback` should be a function that takes a single argument (an array - * of {@link RoomKeyInfo}) and returns a Promise. - */ - registerRoomKeyUpdatedCallback(callback: (info: RoomKeyInfo[]) => Promise): void; - /** - * Register a callback which will be called whenever we receive a - * notification that some room keys have been withheld. - * - * `callback` should be a function that takes a single argument (an array - * of {@link RoomKeyWithheldInfo}) and returns a Promise. - */ - registerRoomKeysWithheldCallback(callback: (info: RoomKeyWithheldInfo[]) => Promise): void; - /** - * Register a callback which will be called whenever there is an update to - * a user identity. - * - * `callback` should be a function that takes a single argument (a {@link - * UserId}) and returns a Promise. - */ - registerUserIdentityUpdatedCallback(callback: (id: UserId) => Promise): void; - /** - * Request missing local secrets from our other trusted devices. - * - * "Local secrets" refers to secrets which can be shared between trusted - * devices, such as private cross-signing keys, and the megolm backup - * decryption key. - * - * This method will cause the sdk to generated outgoing secret requests - * (`m.secret.request`) to get the missing secrets. These requests will - * then be returned by a future call to {@link - * OlmMachine#outgoingRequests}. - * - * # Returns - * - * A `Promise` for a `bool` result, which will be true if secrets were - * missing, and a request was generated. - */ - requestMissingSecretsIfNeeded(): Promise; - /** - * Get the number of backed up room keys and the total number of room keys. - * Returns a {@link RoomKeyCounts}. - */ - roomKeyCounts(): Promise; - /** - * Store the backup decryption key in the crypto store. - * - * This is useful if the client wants to support gossiping of the backup - * key. - * - * Returns `Promise`. - */ - saveBackupDecryptionKey(decryption_key: BackupDecryptionKey, version: string): Promise; - /** - * Record that we have downloaded all message keys for the given room. - */ - setHasDownloadedAllRoomKeys(room_id: RoomId): Promise; - /** - * Store encryption settings for the given room. - * - * This method checks if the new settings are "safe" -- ie, that they do - * not represent a downgrade in encryption security from any previous - * settings. Attempts to downgrade security will result in an error. - * - * If the settings are valid, they will be persisted to the crypto store. - * These settings are not used directly by this library, but the saved - * settings can be retrieved via {@link getRoomSettings}. - */ - setRoomSettings(room_id: RoomId, room_settings: RoomSettings): Promise; - /** - * Get to-device requests to share a room key with users in a room. - * - * `room_id` is the room ID. `users` is an array of `UserId` - * objects. `encryption_settings` are an `EncryptionSettings` - * object. - * - * Note: Care should be taken that only one such request at a - * time is in flight for the same room, e.g. using a lock. - * - * Returns an array of `ToDeviceRequest`s. - * - * Items inside `users` will be invalidated by this method. Be careful not - * to use the `UserId`s after this method has been called. - */ - shareRoomKey(room_id: RoomId, users: UserId[], encryption_settings: EncryptionSettings): Promise; - /** - * Collect the devices belonging to the given user, and send the details - * of a room key bundle to those devices. - * - * Returns a list of to-device requests which must be sent. - * - * @experimental - */ - shareRoomKeyBundleData(user: UserId, room: RoomId, url: string, media_encryption_info: string | null | undefined, sharing_strategy: CollectStrategy): Promise; - /** - * Sign the given message using our device key and if available - * cross-signing master key. - */ - sign(message: string): Promise; - /** - * Store the fact that we have accepted an invitation to the given room, so - * should accept a key bundle if one arrives soon. - * - * This should be called whenever we join a room following an invite, but - * it has no effect other than that the room will be returned by a future - * call to {@link getPendingKeyBundleDetailsForRoom}. - * - * @experimental - */ - storeRoomPendingKeyBundle(room_id: RoomId, inviter: UserId): Promise; - /** - * Get the list of users whose devices we are currently tracking. - * - * A user can be marked for tracking using the - * [`update_tracked_users`](#method.update_tracked_users) method. - * - * Returns a `Set`. - */ - trackedUsers(): Promise>; - /** - * Update the list of tracked users. - * - * The OlmMachine maintains a list of users whose devices we are keeping - * track of: these are known as "tracked users". These must be users - * that we share a room with, so that the server sends us updates for - * their device lists. - * - * # Arguments - * - * * `users` - An array of user ids that should be added to the list of - * tracked users - * - * Any users that hadn't been seen before will be flagged for a key query - * immediately, and whenever `receive_sync_changes` receives a - * "changed" notification for that user in the future. - * - * Users that were already in the list are unaffected. - * - * Items inside `users` will be invalidated by this method. Be careful not - * to use the `UserId`s after this method has been called. - */ - updateTrackedUsers(users: UserId[]): Promise; - /** - * Check if the given backup has been verified by us or by another of our - * devices that we trust. - * - * The `backup_info` should be a Javascript object with the following - * format: - * - * ```json - * { - * "algorithm": "m.megolm_backup.v1.curve25519-aes-sha2", - * "auth_data": { - * "public_key":"XjhWTCjW7l59pbfx9tlCBQolfnIQWARoKOzjTOPSlWM", - * "signatures": {} - * } - * } - * ``` - * - * Returns a {@link SignatureVerification} object. - */ - verifyBackup(backup_info: any): Promise; - /** - * The time, in milliseconds since the unix epoch, at which the `Account` - * backing this `OlmMachine` was created. - * - * An `Account` is created when an `OlmMachine` is first instantiated - * against a given `Store`, at which point it creates identity keys etc. - * This method returns the timestamp, according to the local clock, at - * which that happened. - */ - readonly deviceCreationTimeMs: number; - /** - * The unique device ID that identifies this `OlmMachine`. - */ - readonly deviceId: DeviceId; - /** - * Get the display name of our own device. - */ - readonly displayName: Promise; - /** - * Get the public parts of our Olm identity keys. - */ - readonly identityKeys: IdentityKeys; - /** - * Whether room key forwarding is enabled. - * - * If room key forwarding is enabled, we will automatically reply to - * incoming `m.room_key_request` messages from verified devices by - * forwarding the requested key (if we have it). - */ - roomKeyForwardingEnabled: boolean; - /** - * Whether automatic transmission of room key requests is enabled. - * - * Room key requests allow the device to request room keys that it might - * have missed in the original share using `m.room_key_request` - * events. - */ - roomKeyRequestsEnabled: boolean; - /** - * The unique user ID that owns this `OlmMachine` instance. - */ - readonly userId: UserId; -} - -/** - * Struct representing a cross signing identity of a user. - * - * This is the user identity of a user that isn't our own. Other users will - * only contain a master key and a self signing key, meaning that only device - * signatures can be checked with this identity. - * - * This struct wraps a read-only version of the struct and allows verifications - * to be requested to verify our own device with the user identity. - */ -export class OtherUserIdentity { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Was this identity verified since initial observation and is not anymore? - * - * Such a violation should be reported to the local user by the - * application, and resolved by - * - * - Verifying the new identity with {@link requestVerification}, or: - * - Withdrawing the verification requirement with {@link - * withdrawVerification}. - */ - hasVerificationViolation(): boolean; - /** - * Has the identity changed in a way that requires approval from the user? - * - * A user identity needs approval if it changed after the crypto machine - * has already observed ("pinned") a different identity for that user, - * unless it is an explicitly verified identity (using for example - * interactive verification). - * - * This situation can be resolved by: - * - * - Verifying the new identity with {@link requestVerification}, or: - * - Updating the pin to the new identity with {@link pinCurrentMasterKey}. - */ - identityNeedsUserApproval(): boolean; - /** - * Is this user identity verified? - */ - isVerified(): boolean; - /** - * Pin the current identity (public part of the master signing key). - */ - pinCurrentMasterKey(): Promise; - /** - * Create a `VerificationRequest` object after the verification - * request content has been sent out. - */ - requestVerification(room_id: RoomId, request_event_id: EventId, methods?: VerificationMethod[]): VerificationRequest; - /** - * Send a verification request to the given user. - * - * The returned content needs to be sent out into a DM room with the given - * user. - * - * After the content has been sent out a VerificationRequest can be started - * with the `request_verification` method. - */ - verificationRequestContent(methods?: VerificationMethod[]): string; - /** - * Manually verify this user. - * - * This method will attempt to sign the user identity using our private - * cross signing key. - * - * This method fails if we don't have the private part of our user-signing - * key. - * - * Returns a request that needs to be sent out for the user to be marked as - * verified. - */ - verify(): Promise; - /** - * True if we verified this identity (with any own identity, at any - * point). - * - * To set this latch back to false, call {@link withdrawVerification}. - */ - wasPreviouslyVerified(): boolean; - /** - * Remove the requirement for this identity to be verified. - * - * If an identity was previously verified and is not anymore it will be - * reported to the user. In order to remove this notice users have to - * verify again or to withdraw the verification requirement. - */ - withdrawVerification(): Promise; - /** - * Get the master key of the identity. - */ - readonly masterKey: string; - /** - * Get the self-signing key of the identity. - */ - readonly selfSigningKey: string; -} - -/** - * The result of an outbound ECIES channel establishment. - */ -export class OutboundCreationResult { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * The established ECIES channel. - */ - channel: EstablishedEcies; - /** - * The initial encrypted message. - */ - initial_message: string; -} - -/** - * Struct representing a cross signing identity of a user. - * - * This is the user identity of a user that is our own. - */ -export class OwnUserIdentity { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Was this identity verified since initial observation and is not anymore? - * - * Such a violation should be reported to the local user by the - * application, and resolved by - * - * - Verifying the new identity with {@link requestVerification}, or: - * - Withdrawing the verification requirement with {@link - * withdrawVerification}. - */ - hasVerificationViolation(): boolean; - /** - * Is this user identity verified? - */ - isVerified(): boolean; - /** - * Send a verification request to our other devices. - */ - requestVerification(methods?: VerificationMethod[]): Promise<[VerificationRequest, OutgoingVerificationRequest]>; - /** - * Does our user identity trust our own device, i.e. have we signed our own - * device keys with our self-signing key? - */ - trustsOurOwnDevice(): Promise; - /** - * Mark our user identity as verified. - * - * This will mark the identity locally as verified and sign it with our own - * device. - * - * Returns a signature upload request that needs to be sent out. - */ - verify(): Promise; - /** - * True if we verified our own identity at some point in the past. - * - * To reset this latch back to `false`, call {@link withdrawVerification}. - */ - wasPreviouslyVerified(): boolean; - /** - * Remove the requirement for this identity to be verified. - * - * If an identity was previously verified and is not any longer, it will be - * reported to the user. In order to remove this notice users have to - * verify again or to withdraw the verification requirement. - */ - withdrawVerification(): Promise; - /** - * Get the master key of the identity. - */ - readonly masterKey: string; - /** - * Get the self-signing key of the identity. - */ - readonly selfSigningKey: string; - /** - * Get the user-signing key of the identity. This is only present for our - * own user identity. - */ - readonly userSigningKey: string; -} - -/** - * A pickled version of an `InboundGroupSession`. - * - * Holds all the information that needs to be stored in a database to restore - * an InboundGroupSession. - */ -export class PickledInboundGroupSession { - free(): void; - [Symbol.dispose](): void; - /** - * Construct a new `PickledInboundGroupSession`, with default values. - */ - constructor(); - /** - * Flag remembering if the session has been backed up. - */ - backedUp: boolean; - /** - * Flag remembering if the session was directly sent to us by the sender - * or if it was imported. - */ - imported: boolean; - /** - * The pickle string holding the Megolm Session, as returned by - * `olm_pickle_inbound_group_session` in libolm. - */ - pickle: string; - /** - * The id of the room that the session is used in. - * - * Nullable so that a `PickledInboundGroupSession` can be constructed - * incrementally. Must be populated! - */ - get roomId(): RoomId | undefined; - /** - * The id of the room that the session is used in. - * - * Nullable so that a `PickledInboundGroupSession` can be constructed - * incrementally. Must be populated! - */ - set roomId(value: RoomId | null | undefined); - /** - * The public curve25519 key of the account that sent us the session. - */ - senderKey: string; - /** - * The public ed25519 key of the account that is believed to have initiated - * the session, if known. - * - * If the session was received directly from the creator via an - * Olm-encrypted `m.room_key` event, this value is taken from the `keys` - * property of the plaintext payload of that event (see - * [`m.olm.v1.curve25519-aes-sha2`]). - * - * If the session was forwarded to us using an [`m.forwarded_room_key`], - * this value is a copy of the `sender_claimed_ed25519_key` from the - * content of the event. - * - * [`m.olm.v1.curve25519-aes-sha2`]: https://spec.matrix.org/v1.9/client-server-api/#molmv1curve25519-aes-sha2 - * [`m.forwarded_room_key`]: https://spec.matrix.org/v1.9/client-server-api/#mforwarded_room_key - */ - get senderSigningKey(): string | undefined; - /** - * The public ed25519 key of the account that is believed to have initiated - * the session, if known. - * - * If the session was received directly from the creator via an - * Olm-encrypted `m.room_key` event, this value is taken from the `keys` - * property of the plaintext payload of that event (see - * [`m.olm.v1.curve25519-aes-sha2`]). - * - * If the session was forwarded to us using an [`m.forwarded_room_key`], - * this value is a copy of the `sender_claimed_ed25519_key` from the - * content of the event. - * - * [`m.olm.v1.curve25519-aes-sha2`]: https://spec.matrix.org/v1.9/client-server-api/#molmv1curve25519-aes-sha2 - * [`m.forwarded_room_key`]: https://spec.matrix.org/v1.9/client-server-api/#mforwarded_room_key - */ - set senderSigningKey(value: string | null | undefined); -} - -/** - * A pickled version of a `Session`. - * - * Holds all the information that needs to be stored in a database to restore - * an Olm Session. Can be imported into the rust store with {@link - * Migration::migrateOlmSessions}. - */ -export class PickledSession { - free(): void; - [Symbol.dispose](): void; - /** - * Construct a new `PickledSession`, with default values. - */ - constructor(); - /** - * Was the session created using a fallback key? - */ - createdUsingFallbackKey: boolean; - /** - * When the session was created. - */ - creationTime: Date; - /** - * When the session was last used. - */ - lastUseTime: Date; - /** - * The pickle string holding the Olm Session, as returned by - * `olm_pickle_session` in libolm. - */ - pickle: string; - /** - * The base64-encoded public curve25519 key of the other user that we share - * this session with. - */ - senderKey: string; -} - -/** - * A class representing a public-key decryption instance. - * - * This implements the decryption part of the - * `m.megolm_backup.v1.curve25519-aes-sha2` algorithm described in the Matrix - * {@link https://spec.matrix.org/v1.11/client-server-api/#backup-algorithm-mmegolm_backupv1curve25519-aes-sha2 | spec}. - * - * @see {@link PkEncryption} - * - * More details can be found in the official {@link https://docs.rs/vodozemac/latest/vodozemac/pk_encryption/ | vodozemac documentation}. - */ -export class PkDecryption { - free(): void; - [Symbol.dispose](): void; - /** - * Decrypts an encrypted message and returns the raw `Uint8Array`. - */ - decrypt(message: PkMessage): Uint8Array; - /** - * Decrypts an encrypted message and returns the plaintext as a UTF-8 - * string. - */ - decryptString(message: PkMessage): string; - /** - * Creates a `PkDecryption` instance from a secret key. - */ - static fromKey(key: Curve25519SecretKey): PkDecryption; - /** - * Creates a new `PkDecryption` instance with a newly generated key pair. - */ - constructor(); - /** - * Returns the public key associated with this decryption instance. - * - * This can be used to construct a {@link PkEncryption} object to encrypt a - * message for this `PkDecryption` object. - */ - publicKey(): Curve25519PublicKey; - /** - * Returns the secret key associated with this `PkDecryption` instance. - */ - secretKey(): Curve25519SecretKey; -} - -/** - * A class representing a public-key encryption instance. - * - * This implements the encryption part of the - * `m.megolm_backup.v1.curve25519-aes-sha2` algorithm described in the Matrix - * {@link https://spec.matrix.org/v1.11/client-server-api/#backup-algorithm-mmegolm_backupv1curve25519-aes-sha2 | spec}. - * - * @see {@link PkDecryption} - * - * More details can be found in the official {@link https://docs.rs/vodozemac/latest/vodozemac/pk_encryption/ | vodozemac documentation}. - */ -export class PkEncryption { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Encrypts a byte message and returns an encrypted {@link PkMessage}. - */ - encrypt(message: Uint8Array): PkMessage; - /** - * Encrypts a string message and returns an encrypted {@link PkMessage}. - */ - encryptString(message: string): PkMessage; - /** - * Creates a new `PkEncryption` instance from a public key. - */ - static fromKey(public_key: Curve25519PublicKey): PkEncryption; -} - -/** - * A class representing an encrypted message using {@link PkEncryption}. - */ -export class PkMessage { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Returns the raw ciphertext as a `Uint8Array`. - */ - ciphertext(): Uint8Array; - /** - * Returns the ephemeral public key used during encryption. - */ - ephemeralKey(): Curve25519PublicKey; - /** - * Constructs a `PkMessage` from a base64-encoded representation. - */ - static fromBase64(message: Base64EncodedPkMessage): PkMessage; - /** - * Constructs a `PkMessage` from its parts: ciphertext, MAC, and ephemeral - * key. - */ - static fromParts(ciphertext: Uint8Array, mac: Uint8Array, ephemeral_key: Curve25519PublicKey): PkMessage; - /** - * Returns the raw message authentication code (MAC) as a `Uint8Array`. - */ - mac(): Uint8Array; - /** - * Converts the `PkMessage` into a base64-encoded representation. - */ - toBase64(): Base64EncodedPkMessage; -} - -/** - * Represents a to-device event sent in the clear. - */ -export class PlainTextToDeviceEvent { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * The to-device message, containing `type`, `sender` and `content` fields, - * encoded as JSON. - */ - readonly rawEvent: string; - /** - * The type of processed to-device event. Always {@link - * ProcessedToDeviceEventType.PlainText} for this type. - */ - readonly type: ProcessedToDeviceEventType; -} - -/** - * The type of a {@link ProcessedToDeviceEvent}. - */ -export enum ProcessedToDeviceEventType { - /** - * A successfully-decrypted encrypted to-device message. - */ - Decrypted = 0, - /** - * An encrypted to-device message which could not be decrypted. - */ - UnableToDecrypt = 1, - /** - * An unencrypted to-device message (sent in clear). - */ - PlainText = 2, - /** - * An invalid to-device message that was ignored because it is missing some - * required information to be processed (like no event `type` for - * example) - */ - Invalid = 3, -} - -/** - * A request that will upload a dehydrated device to the server. - */ -export class PutDehydratedDeviceRequest { - free(): void; - [Symbol.dispose](): void; - /** - * Create a new `PutDehydratedDeviceRequest` - */ - constructor(body: string); - /** - * A JSON-encoded object containing the rest of the payload: `rooms`. - * - * It represents the body of the HTTP request. - */ - readonly body: string; -} - -/** - * QR code based verification. - */ -export class Qr { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Cancel the verification flow. - * - * Returns either an `OutgoingVerificationRequest` which should be sent - * out, or `undefined` if the verification is already cancelled. - */ - cancel(): OutgoingVerificationRequest | undefined; - /** - * Get info about the cancellation if the verification flow has - * been cancelled. - */ - cancelInfo(): CancelInfo | undefined; - /** - * Cancel the verification. - * - * This cancels the verification with given code (e.g. `m.user`). - * - * Returns either an `OutgoingVerificationRequest` which should be sent - * out, or `undefined` if the verification is already cancelled. - */ - cancelWithCode(code: string): OutgoingVerificationRequest | undefined; - /** - * Confirm that the other side has scanned our QR code. - * - * Returns either an `OutgoingVerificationRequest` which should be sent - * out, or `undefined` if the verification is already confirmed. - */ - confirmScanning(): OutgoingVerificationRequest | undefined; - /** - * Has the scanning of the QR code been confirmed by us? - */ - hasBeenConfirmed(): boolean; - /** - * Has the QR verification been scanned by the other side. - * - * When the verification object is in this state it’s required - * that the user confirms that the other side has scanned the QR - * code. - */ - hasBeenScanned(): boolean; - /** - * Has the verification flow been cancelled? - */ - isCancelled(): boolean; - /** - * Has the verification flow completed? - */ - isDone(): boolean; - /** - * Is this a verification that is verifying one of our own devices? - */ - isSelfVerification(): boolean; - /** - * Notify the other side that we have successfully scanned the QR - * code and that the QR verification flow can start. - * - * This will return some OutgoingContent if the object is in the - * correct state to start the verification flow, otherwise None. - */ - reciprocate(): OutgoingVerificationRequest | undefined; - /** - * Have we successfully scanned the QR code and are able to send - * a reciprocation event? - */ - reciprocated(): boolean; - /** - * Register a callback which will be called whenever there is an update to - * the request - * - * The `callback` is called with no parameters. - */ - registerChangesCallback(callback: () => Promise): void; - /** - * Get the current state of this request. - * - * Returns a `QrState`. - */ - state(): QrState; - /** - * Generate a the raw bytes that should be encoded as a QR code - * is representing this verification flow. - * - * The `to_qr_code` method can be used to instead output a QrCode - * object that can be rendered. - */ - toBytes(): Uint8ClampedArray; - /** - * Generate a QR code object that is representing this - * verification flow. - * - * The QrCode can then be rendered as an image or as an unicode - * string. - * - * The `to_bytes` method can be used to instead output the raw - * bytes that should be encoded as a QR code. - * - * Returns a `QrCode`. - */ - toQrCode(): QrCode; - /** - * Did we initiate the verification request? - */ - weStarted(): boolean; - /** - * Get the unique ID that identifies this QR verification flow, - * be either a to-device request ID or a room event ID. - */ - readonly flowId: string; - /** - * Get the device ID of the other side. - */ - readonly otherDeviceId: DeviceId; - /** - * Get the user id of the other user that is participating in - * this verification flow. - */ - readonly otherUserId: UserId; - /** - * Get the room id if the verification is happening inside a - * room. - */ - readonly roomId: RoomId | undefined; - /** - * Get our own user ID. - */ - readonly userId: UserId; -} - -/** - * A QR code. - */ -export class QrCode { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Render the QR code into a `Uint8ClampedArray` where 1 represents a - * dark pixel and 0 a white pixel. - */ - renderIntoBuffer(): Uint8ClampedArray; -} - -/** - * Data for the QR code login mechanism. - * - * The {@link QrCodeData} can be serialized and encoded as a QR code or it can - * be decoded from a QR code. - * - * This type supports both the format originally speicied in - * {link https://github.com/matrix-org/matrix-spec-proposals/pull/4108 MSC4108} as well as the - * updated format found in - * {link https://github.com/matrix-org/matrix-spec-proposals/pull/4388 MSC4388}. - */ -export class QrCodeData { - free(): void; - [Symbol.dispose](): void; - /** - * Attempt to decode a base64 encoded string into a {@link QrCodeData} - * object. - */ - static fromBase64(data: string): QrCodeData; - /** - * Attempt to decode a slice of bytes into a {@link QrCodeData} object. - * - * The slice of bytes would generally be returned by a QR code decoder. - */ - static fromBytes(bytes: Uint8Array): QrCodeData; - /** - * Create new {@link QrCodeData} from a given public key, a rendezvous URL - * and, optionally, a server name for the homeserver. - * - * If a server name is given, then the {@link QrCodeData} mode will be - * {@link QrCodeIntent.Reciprocate}, i.e. the QR code will contain data for - * the existing device to display the QR code. - * - * If no server name is given, the {@link QrCodeData} mode will be - * {@link QrCodeIntent.Login}, i.e. the QR code will contain data for the - * new device to display the QR code. - */ - constructor(public_key: Curve25519PublicKey, rendezvous_url: string, server_name?: string | null); - /** - * Create new {@link QrCodeData} from a given public key, a rendezvous ID - * and, a base homeserver URL. - * - * This creates a QR code which conforms to - * {@link https://github.com/matrix-org/matrix-spec-proposals/pull/4388 MSC4388} of the data - * format for QR login. - */ - static newMsc4388(public_key: Curve25519PublicKey, rendezvous_id: string, base_url: string, intent: QrCodeIntent): QrCodeData; - /** - * Encode the {@link QrCodeData} into a string using base64. - * - * This format can be used for debugging purposes and the - * [`QrcodeData::from_base64()`] method can be used to parse the string - * again. - */ - toBase64(): string; - /** - * Encode the {@link QrCodeData} into a list of bytes. - * - * The list of bytes can be used by a QR code generator to create an image - * containing a QR code. - */ - toBytes(): Uint8Array; - /** - * Get the intent-specific data embedded in the {@link QrCodeData}. - */ - readonly intentData: QrCodeIntentData; - /** - * Get the mode of this {@link QrCodeData} instance. - */ - readonly mode: QrCodeIntent; - /** - * Get the Curve25519 public key embedded in the {@link QrCodeData}. - * - * This Curve25519 public key should be used to establish an - * [HPKE](https://www.rfc-editor.org/rfc/rfc9180.html) - * (Hybrid Public Key Encryption) channel with the other device. - */ - readonly publicKey: Curve25519PublicKey; - /** - * Get the URL of the rendezvous server which will be used to exchange - * messages between the two devices. - */ - readonly rendezvousUrl: string | undefined; - /** - * Get the server name of the homeserver which the new device will be - * logged in to. - * - * This will be only available if the existing device has generated the QR - * code and the new device is the one scanning the QR code. - */ - readonly serverName: string | undefined; -} - -/** - * The mode of the QR code login. - * - * The QR code login mechanism supports both, the new device, as well as the - * existing device to display the QR code. - * - * The different modes have an explicit one-byte identifier which gets added to - * the QR code data. - */ -export enum QrCodeIntent { - /** - * The new device is displaying the QR code. - */ - Login = 0, - /** - * The existing device is displaying the QR code. - */ - Reciprocate = 1, -} - -/** - * Intent and MSC-specific data class for the QR code login support. - */ -export class QrCodeIntentData { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * The MSC4108-specific intent data. - * - * This will not be `null` only if the {@link QrCodeData} contains data as - * specified in the QR code format of MSC4108. Otherwise it will contain - * MSC4388-specific intent data. - */ - get msc4108(): Msc4108IntentData | undefined; - /** - * The MSC4108-specific intent data. - * - * This will not be `null` only if the {@link QrCodeData} contains data as - * specified in the QR code format of MSC4108. Otherwise it will contain - * MSC4388-specific intent data. - */ - set msc4108(value: Msc4108IntentData | null | undefined); - /** - * The MSC4833-specific intent data. - * - * This will not be `null` only if the {@link QrCodeData} contains data as - * specified in the QR code format of MSC4388. Otherwise it will contain - * MSC4108-specific intent data. - */ - get msc4388(): Msc4388IntentData | undefined; - /** - * The MSC4833-specific intent data. - * - * This will not be `null` only if the {@link QrCodeData} contains data as - * specified in the QR code format of MSC4388. Otherwise it will contain - * MSC4108-specific intent data. - */ - set msc4388(value: Msc4388IntentData | null | undefined); -} - -/** - * A scanned QR code. - */ -export class QrCodeScan { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Parse the decoded payload of a QR code in byte slice form. - * - * This method is useful if you would like to do your own custom QR code - * decoding. - */ - static fromBytes(buffer: Uint8ClampedArray): QrCodeScan; -} - -/** - * List of `Qr` states - */ -export enum QrState { - /** - * We have received the other device's details (from the - * `m.key.verification.request` or `m.key.verification.ready`) and - * established the shared secret, so can - * display the QR code. - */ - Created = 0, - /** - * The other side has scanned our QR code and sent an - * `m.key.verification.start` message with `method: m.reciprocate.v1` with - * matching shared secret. - */ - Scanned = 1, - /** - * Our user has confirmed that the other device scanned successfully. We - * have sent an `m.key.verification.done`. - */ - Confirmed = 2, - /** - * We have scanned the other side's QR code and are able to send a - * `m.key.verification.start` message with `method: m.reciprocate.v1`. - * - * Call `Qr::reciprocate` to build the start message. - * - * Note that, despite the name of this state, we have not necessarily - * yet sent the `m.reciprocate.v1` message. - */ - Reciprocated = 3, - /** - * Verification complete: we have received an `m.key.verification.done` - * from the other side. - */ - Done = 4, - /** - * Verification cancelled or failed. - */ - Cancelled = 5, -} - -/** - * A rehydrated device - * - * This device can receive to-device events to get room keys that were send to - * it. - */ -export class RehydratedDevice { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Receive the to-device events that sent to the dehydrated device - * - * The rehydrated device will decrypt the events and pass the room keys - * into the `OlmMachine`. - * - * # Arguments - * - * * `to_device_events` is a JSON-encoded result of the `events` array from - * `/dehydrated_device/{device_id}/events`. - * * `decryption_settings`: Optionally, the settings to use when decrypting - * to-device events. If not set, to-device events will be decrypted with - * a {@link TrustRequirement} of `Untrusted`. - * - * Returns an array of `RoomKeyInfo`, indicating the room keys that were - * received. - */ - receiveEvents(to_device_events: string, decryption_settings?: DecryptionSettings | null): Promise>; -} - -/** - * Represent the type of a request. - */ -export enum RequestType { - /** - * Represents a `KeysUploadRequest`. - */ - KeysUpload = 0, - /** - * Represents a `KeysQueryRequest`. - */ - KeysQuery = 1, - /** - * Represents a `KeysClaimRequest`. - */ - KeysClaim = 2, - /** - * Represents a `ToDeviceRequest`. - */ - ToDevice = 3, - /** - * Represents a `SignatureUploadRequest`. - */ - SignatureUpload = 4, - /** - * Represents a `RoomMessageRequest`. - */ - RoomMessage = 5, - /** - * Represents a `KeysBackupRequest`. - */ - KeysBackup = 6, -} - -/** - * A Matrix [room ID]. - * - * [room ID]: https://spec.matrix.org/v1.2/appendices/#room-ids-and-event-ids - */ -export class RoomId { - free(): void; - [Symbol.dispose](): void; - /** - * Parse/validate and create a new `RoomId`. - */ - constructor(id: string); - /** - * Return the room ID as a string. - */ - toString(): string; -} - -/** - * Struct holding the number of room keys we have. - */ -export class RoomKeyCounts { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * The number of backed up room keys. - */ - backedUp: number; - /** - * The total number of room keys. - */ - total: number; -} - -/** - * The result of a call to {@link OlmMachine.importExportedRoomKeys} or - * {@link OlmMachine.importBackedUpRoomKeys}. - */ -export class RoomKeyImportResult { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * The keys that were imported. - * - * A Map from room id to a Map of the sender key to a Set of session ids. - * - * Typescript type: `Map>`. - */ - keys(): Map>>; - /** - * The number of room keys that were imported. - */ - readonly importedCount: number; - /** - * The total number of room keys that were found in the export. - */ - readonly totalCount: number; -} - -/** - * Information on a room key that has been received or imported. - */ -export class RoomKeyInfo { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * The {@link EncryptionAlgorithm} that this key is used for. Will be one - * of the `m.megolm.*` algorithms. - */ - readonly algorithm: EncryptionAlgorithm; - /** - * The room where the key is used. - */ - readonly roomId: RoomId; - /** - * The Curve25519 key of the device which initiated the session originally. - */ - readonly senderKey: Curve25519PublicKey; - /** - * The ID of the session that the key is for. - */ - readonly sessionId: string; -} - -/** - * Information on a received `m.room_key.withheld` event. - */ -export class RoomKeyWithheldInfo { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * The encryption algorithm of the session that is being withheld. - * - * This may be from an `m.room_key.withheld` event, or from a shared room - * key bundle under MSC4268. - */ - readonly algorithm: EncryptionAlgorithm; - /** - * The room ID of the session that is being withheld. - */ - readonly roomId: RoomId; - /** - * The User ID of the sender of the withheld information. - * - * This may be the sender of an `m.room_key.withheld` event, or the sender - * of a shared room key bundle under MSC4268. - */ - readonly sender: UserId; - /** - * The session ID of the session that is being withheld. - */ - readonly sessionId: string; - /** - * The `code` indicating why the key was withheld, such as `m.unverified`. - * - * This may be from an `m.room_key.withheld` event (such as - * `m.unverified`), or from a shared room key bundle under MSC4268. - */ - readonly withheldCode: string; -} - -/** - * A customized owned request type for sending out room messages - * ([specification]). - * - * [specification]: https://spec.matrix.org/unstable/client-server-api/#put_matrixclientv3roomsroomidsendeventtypetxnid - */ -export class RoomMessageRequest { - free(): void; - [Symbol.dispose](): void; - /** - * Create a new `RoomMessageRequest`. - */ - constructor(id: string, room_id: string, txn_id: string, event_type: string, content: string); - /** - * A JSON-encoded object containing the message's content. - */ - readonly body: string; - /** - * A string representing the type of event to be sent. - */ - readonly event_type: string; - /** - * The request ID. - */ - readonly id: string; - /** - * A string representing the room to send the event to. - */ - readonly room_id: string; - /** - * A string representing the transaction ID for this event. - * - * Clients should generate an ID unique across requests with the same - * access token; it will be used by the server to ensure idempotency of - * requests. - */ - readonly txn_id: string; - /** - * Get its request type. - */ - readonly type: RequestType; -} - -/** - * Information on a room which is waiting for a key bundle to arrive. - */ -export class RoomPendingKeyBundleDetails { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * The time that the invite was accepted. - */ - readonly inviteAcceptedAtMillis: number; - /** - * The ID of the user that invited us - */ - readonly inviterId: UserId; - /** - * The room that is waiting for a key bundle. - */ - readonly roomId: RoomId; -} - -/** - * Room encryption settings which are modified by state events or user options - */ -export class RoomSettings { - free(): void; - [Symbol.dispose](): void; - /** - * Create a new `RoomSettings` with default values. - */ - constructor(); - /** - * The encryption algorithm that should be used in the room. - * - * Should be one of the members of {@link EncryptionAlgorithm}. - */ - algorithm: EncryptionAlgorithm; - /** - * Whether state event encryption is enabled. - */ - encryptStateEvents: boolean; - /** - * Whether untrusted devices should receive room keys. If this is `false`, - * they will be excluded from the conversation. - */ - onlyAllowTrustedDevices: boolean; - /** - * The maximum number of messages an encryption session should be used for, - * before it is rotated. - */ - get sessionRotationPeriodMessages(): number | undefined; - /** - * The maximum number of messages an encryption session should be used for, - * before it is rotated. - */ - set sessionRotationPeriodMessages(value: number | null | undefined); - /** - * The maximum time, in milliseconds, that an encryption session should be - * used for, before it is rotated. - */ - get sessionRotationPeriodMs(): number | undefined; - /** - * The maximum time, in milliseconds, that an encryption session should be - * used for, before it is rotated. - */ - set sessionRotationPeriodMs(value: number | null | undefined); -} - -/** - * Short Authentication String (SAS) verification. - */ -export class Sas { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Accept the SAS verification. - * - * This does nothing (and returns `undefined`) if the verification was - * already accepted, otherwise it returns an `OutgoingVerificationRequest` - * that needs to be sent out. - */ - accept(): OutgoingVerificationRequest | undefined; - /** - * Are we in a state where we can show the short auth string? - */ - canBePresented(): boolean; - /** - * Cancel the verification. - * - * Returns either an `OutgoingVerificationRequest` which should be sent - * out, or `undefined` if the verification is already cancelled. - */ - cancel(): OutgoingVerificationRequest | undefined; - /** - * Get info about the cancellation if the verification flow has - * been cancelled. - */ - cancelInfo(): CancelInfo | undefined; - /** - * Cancel the verification. - * - * This cancels the verification with given code (e.g. `m.user`). - * - * Returns either an `OutgoingVerificationRequest` which should be sent - * out, or `undefined` if the verification is already cancelled. - */ - cancelWithCode(code: string): OutgoingVerificationRequest | undefined; - /** - * Confirm the SAS verification. - * - * This confirms that the short auth strings match on both sides. - * - * Does nothing if we’re not in a state where we can confirm the - * short auth string. - * - * Returns a `Promise` for an array of `OutgoingVerificationRequest`s. - */ - confirm(): Promise; - /** - * Get the decimal version of the short auth string. - * - * Returns None if we can’t yet present the short auth string, - * otherwise a tuple containing three 4-digit integers that - * represent the short auth string. - */ - decimals(): Uint16Array | undefined; - /** - * Get the emoji version of the short auth string. - * - * Returns `undefined` if we can't yet present the short auth string, - * otherwise an array of seven `Emoji` objects. - */ - emoji(): Emoji[] | undefined; - /** - * Get the index of the emoji representing the short auth string - * - * Returns `undefined` if we can’t yet present the short auth - * string, otherwise seven `u8` numbers in the range from 0 to 63 - * inclusive which can be converted to an emoji using [the - * relevant specification - * entry](https://spec.matrix.org/unstable/client-server-api/#sas-method-emoji). - */ - emojiIndex(): Uint8Array | undefined; - /** - * Has the verification been accepted by both parties? - */ - hasBeenAccepted(): boolean; - /** - * Have we confirmed that the short auth string matches? - */ - haveWeConfirmed(): boolean; - /** - * Is the SAS flow cancelled? - */ - isCancelled(): boolean; - /** - * Is the SAS flow done? - */ - isDone(): boolean; - /** - * Is this a verification that is verifying one of our own - * devices? - */ - isSelfVerification(): boolean; - /** - * Register a callback which will be called whenever there is an update to - * the request. - * - * The `callback` is called with no parameters. - */ - registerChangesCallback(callback: () => Promise): void; - /** - * Did this verification flow start from a verification request? - */ - startedFromRequest(): boolean; - /** - * Does this verification flow support displaying emoji for the - * short authentication string? - */ - supportsEmoji(): boolean; - /** - * Has the SAS verification flow timed out? - */ - timedOut(): boolean; - /** - * True if we initiated the verification flow (ie, we sent the - * `m.key.verification.request`). - */ - weStarted(): boolean; - /** - * Get our own device ID. - */ - readonly deviceId: DeviceId; - /** - * Get the unique ID that identifies this SAS verification flow, - * be either a to-device request ID or a room event ID. - */ - readonly flowId: string; - /** - * Get the device ID of the other side. - */ - readonly otherDeviceId: DeviceId; - /** - * Get the user id of the other side. - */ - readonly otherUserId: UserId; - /** - * Get the room ID if the verification is happening inside a - * room. - */ - readonly roomId: RoomId | undefined; - /** - * Get our own user ID. - */ - readonly userId: UserId; -} - -/** - * Struct containing the bundle of secrets to fully activate a new device for - * end-to-end encryption. - */ -export class SecretsBundle { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Deserialize the [`SecretsBundle`] from a JSON object. - */ - static from_json(json: unknown): SecretsBundle; - /** - * Serialize the [`SecretsBundle`] to a JSON object. - */ - to_json(): unknown; - /** - * The bundle of the backup decryption key and backup version if any. - */ - readonly backupBundle: BackupSecretsBundle | undefined; - /** - * The seed of the master key encoded as unpadded base64. - */ - readonly masterKey: string; - /** - * The seed of the self signing key encoded as unpadded base64. - */ - readonly selfSigningKey: string; - /** - * The seed of the user signing key encoded as unpadded base64. - */ - readonly userSigningKey: string; -} - -/** - * A Matrix-spec compliant [server name]. - * - * It consists of a host and an optional port (separated by a colon if - * present). - * - * [server name]: https://spec.matrix.org/v1.2/appendices/#server-name - */ -export class ServerName { - free(): void; - [Symbol.dispose](): void; - /** - * Returns true if and only if the server name is an IPv4 or IPv6 - * address. - */ - isIpLiteral(): boolean; - /** - * Parse/validate and create a new `ServerName`. - */ - constructor(name: string); - /** - * Returns the host of the server name. - * - * That is: Return the part of the server before `:` or the - * full server name if there is no port. - */ - readonly host: string; - /** - * Returns the port of the server name if any. - */ - readonly port: number | undefined; -} - -/** - * Take a look at [`matrix_sdk_common::deserialized_responses::ShieldState`] - * for more info. - */ -export enum ShieldColor { - /** - * Important warning - */ - Red = 0, - /** - * Low warning - */ - Grey = 1, - /** - * No warning - */ - None = 2, -} - -/** - * Take a look at [`matrix_sdk_common::deserialized_responses::ShieldState`] - * for more info. - */ -export class ShieldState { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * A machine-readable representation of the authenticity for a - * `ShieldState`. - */ - get code(): ShieldStateCode | undefined; - /** - * A machine-readable representation of the authenticity for a - * `ShieldState`. - */ - set code(value: ShieldStateCode | null | undefined); - /** - * The shield color - */ - color: ShieldColor; - /** - * Error message that can be displayed as a tooltip - */ - readonly message: string | undefined; -} - -/** - * A machine-readable representation of the authenticity for a `ShieldState`. - */ -export enum ShieldStateCode { - /** - * Not enough information available to check the authenticity. - */ - AuthenticityNotGuaranteed = 0, - /** - * The sending device isn't yet known by the Client. - */ - UnknownDevice = 1, - /** - * The sending device hasn't been verified by the sender. - */ - UnsignedDevice = 2, - /** - * The sender hasn't been verified by the Client's user. - */ - UnverifiedIdentity = 3, - /** - * The sender was previously verified but changed their identity. - */ - VerificationViolation = 4, - /** - * The `sender` field on the event does not match the owner of the device - * that established the Megolm session. - */ - MismatchedSender = 5, -} - -/** - * Represents a potentially decoded signature (but not a validated - * one). - */ -export class Signature { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Convert the signature to a base64 encoded string. - */ - toBase64(): string; - /** - * Get the Ed25519 signature, if this is one. - */ - readonly ed25519: Ed25519Signature | undefined; -} - -/** - * The result of a signature check. - */ -export enum SignatureState { - /** - * The signature is missing. - */ - Missing = 0, - /** - * The signature is invalid. - */ - Invalid = 1, - /** - * The signature is valid but the device or user identity that created the - * signature is not trusted. - */ - ValidButNotTrusted = 2, - /** - * The signature is valid and the device or user identity that created the - * signature is trusted. - */ - ValidAndTrusted = 3, -} - -/** - * Data for a request to the `/keys/signatures/upload` API endpoint - * ([specification]). - * - * Publishes cross-signing signatures for the user. - * - * [specification]: https://spec.matrix.org/unstable/client-server-api/#post_matrixclientv3keyssignaturesupload - */ -export class SignatureUploadRequest { - free(): void; - [Symbol.dispose](): void; - /** - * Create a new `SignatureUploadRequest`. - */ - constructor(id: string, signed_keys: string); - /** - * A JSON-encoded object containing the payload of the request - * - * It represents the body of the HTTP request. - */ - readonly body: string; - /** - * The request ID. - * Some signature upload will have to an `id` field, some won't. - * They have one when they are created automatically during an interactive - * verification, otherwise they don't. - */ - readonly id: string | undefined; - /** - * Get its request type. - */ - readonly type: RequestType; -} - -/** - * The result of a signature verification of a signed JSON object. - */ -export class SignatureVerification { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Is the result considered to be trusted? - * - * This tells us if the result has a valid signature from any of the - * following: - * - * * Our own device - * * Our own user identity, provided the identity is trusted as well - * * Any of our own devices, provided the device is trusted as well - */ - trusted(): boolean; - /** - * Give the backup signature state from the current device. - * See SignatureState for values - */ - readonly deviceState: SignatureState; - /** - * Give the backup signature state from the current user identity. - * See SignatureState for values - */ - readonly userState: SignatureState; -} - -/** - * A collection of `Signature`. - */ -export class Signatures { - free(): void; - [Symbol.dispose](): void; - /** - * Add the given signature from the given signer and the given key ID to - * the collection. - */ - addSignature(signer: UserId, key_id: DeviceKeyId, signature: Ed25519Signature): MaybeSignature | undefined; - /** - * Get the json with all signatures - */ - asJSON(): string; - /** - * Remove all the signatures we currently hold. - */ - clear(): void; - /** - * Get the map of signatures that belong to the given user. - */ - get(signer: UserId): Map | undefined; - /** - * Try to find an Ed25519 signature from the given signer with - * the given key ID. - */ - getSignature(signer: UserId, key_id: DeviceKeyId): Ed25519Signature | undefined; - /** - * Do we hold any signatures or is our collection completely - * empty. - */ - isEmpty(): boolean; - /** - * Creates a new, empty, signatures collection. - */ - constructor(); - /** - * How many signatures do we currently hold. - */ - readonly count: number; -} - -/** - * A struct containing an open connection to a CryptoStore. - * - * Opening the CryptoStore can take some time, due to the PBKDF calculation - * involved, so if multiple operations are being done on the same store, it is - * more efficient to open it once. - */ -export class StoreHandle { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Open a crypto store. - * - * The created store will be based on IndexedDB if a `store_name` is - * provided; otherwise it will be based on a memory store and once the - * objects is dropped, the keys will be lost. - * - * # Arguments - * - * * `store_name` - The name that should be used to open the IndexedDB - * based database. If this isn't provided, a memory-only store will be - * used. *Note* the memory-only store will lose your E2EE keys when the - * `StoreHandle` gets dropped. - * - * * `store_passphrase` - The passphrase that should be used to encrypt the - * store, for IndexedDB-based stores - * - * * `logger` - An optional logger instance to use for writing log messages - * during the open operation. An instance of `JsLogger`. - */ - static open(store_name: string | null | undefined, store_passphrase: string | null | undefined, logger?: JsLogger): Promise; - /** - * Open a crypto store based on IndexedDB, using the given key for - * encryption. - * - * # Arguments - * - * * `store_name` - The name that should be used to open the IndexedDB - * based database. - * - * * `store_key` - The key that should be used to encrypt the store, for - * IndexedDB-based stores. Must be a 32-byte array. - * - * * `logger` - An optional logger instance to use for writing log messages - * during the open operation. An instance of `JsLogger`. - */ - static openWithKey(store_name: string, store_key: Uint8Array, logger?: JsLogger): Promise; -} - -/** - * Information on a stored room key bundle data event. - */ -export class StoredRoomKeyBundleData { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * The JSON-encoded encryption info for the key bundle. - * - * @deprecated Should not be used within applications. - */ - readonly encryptionInfo: string; - /** - * The room that these keys are for. - */ - readonly roomId: RoomId; - /** - * The user that sent us this data. - */ - readonly senderUser: UserId; - /** - * The location of the bundle. - */ - readonly url: string; -} - -/** - * Struct containing information on how a to-device message was decrypted. - */ -export class ToDeviceEncryptionInfo { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Returns whether the sender device is in a verified state. - * This reflects the state at the time of decryption. - */ - isSenderVerified(): boolean; - /** - * The base64-encoded public Curve25519 key of the device that encrypted - * the message. - */ - senderCurve25519Key: string; - /** - * The device ID of the device that sent us the to-device message. - * - * Could be `undefined` in the case where the to-device message sender - * checks are delayed. There is no delay for to-device messages other - * than `m.room_key`, so this will always be truthy for other - * message types (the decryption would fail if the sender device keys - * cannot be found). - * - * Note this is untrusted data unless {@link isSenderVerified} is true. - */ - get senderDevice(): DeviceId | undefined; - /** - * The device ID of the device that sent us the to-device message. - * - * Could be `undefined` in the case where the to-device message sender - * checks are delayed. There is no delay for to-device messages other - * than `m.room_key`, so this will always be truthy for other - * message types (the decryption would fail if the sender device keys - * cannot be found). - * - * Note this is untrusted data unless {@link isSenderVerified} is true. - */ - set senderDevice(value: DeviceId | null | undefined); - /** - * The user ID of the sender of the event. - * - * Note this is untrusted data unless {@link isSenderVerified} is true. - */ - sender: UserId; -} - -/** - * Data for a request to the `/sendToDevice` API endpoint - * ([specification]). - * - * Send an event to a single device or to a group of devices. - * - * [specification]: https://spec.matrix.org/unstable/client-server-api/#put_matrixclientv3sendtodeviceeventtypetxnid - */ -export class ToDeviceRequest { - free(): void; - [Symbol.dispose](): void; - /** - * Create a new `ToDeviceRequest`. - */ - constructor(id: string, event_type: string, txn_id: string, body: string); - /** - * A JSON-encoded object containing the rest of the payload: `messages`. - * - * It represents the body of the HTTP request. - */ - readonly body: string; - /** - * A string representing the type of event being sent to each devices. - */ - readonly event_type: string; - /** - * The request ID. - * For to-device request this would be the same value as `txn_id`. It is - * exposed also as `id` so that the js bindings are consistent with the - * other request types by using this field to mark as sent. - */ - readonly id: string; - /** - * A string representing a request identifier unique to the access token - * used to send the request. - */ - readonly txn_id: string; - /** - * Get its request type. - */ - readonly type: RequestType; -} - -/** - * Metadata about a to-device event that could not be decrypted. - */ -export class ToDeviceUnableToDecryptInfo { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Reason code for the decryption failure - */ - reason: ToDeviceUnableToDecryptReason; -} - -/** - * Reason code for a to-device decryption failure - */ -export enum ToDeviceUnableToDecryptReason { - /** - * An error occurred while encrypting the event. This covers all - * `OlmError` types. - */ - DecryptionFailure = 0, - /** - * We refused to decrypt the message because the sender's device is not - * verified, or more generally, the sender's identity did not match the - * trust requirement we were asked to provide. - */ - UnverifiedSenderDevice = 1, - /** - * We have no `OlmMachine`. This should not happen unless we forget to set - * things up by calling `OlmMachine::activate()`. - */ - NoOlmMachine = 2, - /** - * The Matrix SDK was compiled without encryption support. - */ - EncryptionIsDisabled = 3, -} - -/** - * Type to install and to manipulate the tracing layer. - */ -export class Tracing { - free(): void; - [Symbol.dispose](): void; - /** - * Check whether the `tracing` feature has been enabled. - * - * @deprecated: `tracing` is now always enabled. - */ - static isAvailable(): boolean; - /** - * Install the tracing layer. - */ - constructor(min_level: LoggerLevel); - /** - * Turn the logger off, i.e. it no longer emits logs. - */ - turnOff(): void; - /** - * Turn the logger on, i.e. it emits logs again if it was turned - * off. - */ - turnOn(): void; - /** - * Re-define the minimum logger level. - */ - set minLevel(value: LoggerLevel); -} - -/** - * The trust level required to decrypt an event - */ -export enum TrustRequirement { - /** - * Decrypt events from everyone regardless of trust - */ - Untrusted = 0, - /** - * Only decrypt events from cross-signed or legacy devices - */ - CrossSignedOrLegacy = 1, - /** - * Only decrypt events from cross-signed devices - */ - CrossSigned = 2, -} - -/** - * Represents an encrypted to-device event that could not be decrypted. - */ -export class UTDToDeviceEvent { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * The original message (of type `m.room.encrypted`) that failed to be - * decrypted, encoded as JSON. - */ - readonly rawEvent: string; - /** - * Information on the reason we failed to decrypt - */ - readonly utdInfo: ToDeviceUnableToDecryptInfo; - /** - * The type of processed to-device event. Always {@link - * ProcessedToDeviceEventType.UnableToDecrypt} for this type. - */ - readonly type: ProcessedToDeviceEventType; -} - -/** - * Other Requests * - * Request that will publish a cross signing identity. - * - * This uploads the public cross signing key triplet. - */ -export class UploadSigningKeysRequest { - free(): void; - [Symbol.dispose](): void; - /** - * Create a new `UploadSigningKeysRequest`. - */ - constructor(body: string); - /** - * A JSON-encoded object containing the rest of the payload: `master_key`, - * `self_signing_key`, `user_signing_key`. - * - * It represents the body of the HTTP request. - */ - readonly body: string; -} - -/** - * A read only view over all devices belonging to a user. - */ -export class UserDevices { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Iterator over all the devices of the user devices. - */ - devices(): Device[]; - /** - * Get the specific device with the given device ID. - */ - get(device_id: DeviceId): Device | undefined; - /** - * Returns true if there is at least one devices of this user - * that is considered to be verified, false otherwise. - * - * This won't consider your own device as verified, as your own - * device is always implicitly verified. - */ - isAnyVerified(): boolean; - /** - * Array over all the device IDs of the user devices. - */ - keys(): DeviceId[]; -} - -/** - * A Matrix [user ID]. - * - * [user ID]: https://spec.matrix.org/v1.2/appendices/#user-identifiers - */ -export class UserId { - free(): void; - [Symbol.dispose](): void; - /** - * Create a clone of this `UserId`. - * - * This can be useful when passing a `UserId` instance to methods such as - * {@link OlmMachine.updateTrackedUsers} which destroy the instance. - */ - clone(): UserId; - /** - * Whether this user ID is a historical one. - * - * A historical user ID is one that doesn't conform to the latest - * specification of the user ID grammar but is still accepted - * because it was previously allowed. - */ - isHistorical(): boolean; - /** - * Parse/validate and create a new `UserId`. - */ - constructor(id: string); - /** - * Return the user ID as a string. - */ - toString(): string; - /** - * Returns the user's localpart. - */ - readonly localpart: string; - /** - * Returns the server name of the user ID. - */ - readonly serverName: ServerName; -} - -/** - * List of available verification methods. - */ -export enum VerificationMethod { - /** - * The `m.sas.v1` verification method. - * - * SAS means Short Authentication String. - */ - SasV1 = 0, - /** - * The `m.qr_code.scan.v1` verification method. - */ - QrCodeScanV1 = 1, - /** - * The `m.qr_code.show.v1` verification method. - */ - QrCodeShowV1 = 2, - /** - * The `m.reciprocate.v1` verification method. - */ - ReciprocateV1 = 3, -} - -/** - * An object controlling key verification requests. - * - * Interactive verification flows usually start with a verification - * request, this object lets you send and reply to such a - * verification request. - * - * After the initial handshake the verification flow transitions into - * one of the verification methods. - */ -export class VerificationRequest { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * Accept the verification request. - * - * This method will accept the request and signal that it - * supports the `m.sas.v1`, the `m.qr_code.show.v1`, and - * `m.reciprocate.v1` method. - * - * `m.qr_code.show.v1` will only be signaled if the `qrcode` - * feature is enabled. This feature is disabled by default. If - * it's enabled and QR code scanning should be supported or QR - * code showing shouldn't be supported the `accept_with_methods` - * method should be used instead. - * - * It returns either a `ToDeviceRequest`, a `RoomMessageRequest` - * or `undefined`. - */ - accept(): OutgoingVerificationRequest | undefined; - /** - * Accept the verification request signaling that our client - * supports the given verification methods. - * - * `methods` represents the methods that we should advertise as - * supported by us. - * - * It returns either a `ToDeviceRequest`, a `RoomMessageRequest` - * or `undefined`. - */ - acceptWithMethods(methods: VerificationMethod[]): OutgoingVerificationRequest | undefined; - /** - * Cancel the verification request. - * - * It returns either a `ToDeviceRequest`, a `RoomMessageRequest` - * or `undefined`. - */ - cancel(): OutgoingVerificationRequest | undefined; - /** - * Generate a QR code that can be used by another client to start - * a QR code based verification. - * - * Returns a `Qr` or `undefined`. - */ - generateQrCode(): Promise; - /** - * If this request has transitioned into a concrete verification - * flow (and not yet been completed or cancelled), returns a `Verification` - * object. - * - * Returns: a `Sas`, a `Qr`, or `undefined`. - */ - getVerification(): Sas | Qr | undefined; - /** - * Has the verification flow that was started with this request - * been cancelled? - */ - isCancelled(): boolean; - /** - * Has the verification flow that was started with this request - * finished? - */ - isDone(): boolean; - /** - * Has the verification request been answered by another device? - */ - isPassive(): boolean; - /** - * Is the verification request ready to start a verification flow? - */ - isReady(): boolean; - /** - * Is this a verification that is verifying one of our own - * devices? - */ - isSelfVerification(): boolean; - /** - * Get the current phase of this request. - * - * Returns a `VerificationRequestPhase`. - */ - phase(): VerificationRequestPhase; - /** - * Register a callback which will be called whenever there is an update to - * the request. - * - * The `callback` is called with no parameters. - */ - registerChangesCallback(callback: () => Promise): void; - /** - * Create an event content that can be sent as a room event to - * request verification from the other side. This should be used - * only for verifications of other users and it should be sent to - * a room we consider to be a DM with the other user. - */ - static request(own_user_id: UserId, own_device_id: DeviceId, other_user_id: UserId, methods?: VerificationMethod[]): string; - /** - * Start a QR code verification by providing a scanned QR code - * for this verification flow. - */ - scanQrCode(data: QrCodeScan): Promise; - /** - * Transition from this verification request into a SAS verification flow. - * - * Returns `Promise<[Sas, OutgoingVerificationRequest] | undefined>` - */ - startSas(): Promise<[Sas, OutgoingVerificationRequest] | undefined>; - /** - * The number of milliseconds remaining before this verification flow times - * out. - * - * Returns zero if the time has already passed. - */ - timeRemainingMillis(): number; - /** - * Has the verification flow timed out? - */ - timedOut(): boolean; - /** - * Did we initiate the verification request? - */ - weStarted(): boolean; - /** - * Get info about the cancellation if the verification request - * has been cancelled. - */ - readonly cancelInfo: CancelInfo | undefined; - /** - * Get the unique ID of this verification request. - */ - readonly flowId: string; - /** - * The ID of the other device that is participating in this - * verification. - */ - readonly otherDeviceId: DeviceId | undefined; - /** - * The ID of the other user that is participating in this - * verification request. - */ - readonly otherUserId: UserId; - /** - * Get our own supported verification methods that we advertised. - * - * Will be present only we requested the verification or if we’re - * in the ready state. - */ - readonly ourSupportedMethods: VerificationMethod[] | undefined; - /** - * Our own user id. - */ - readonly ownUserId: UserId; - /** - * Get the room ID if the verification is happening inside a - * room. - */ - readonly roomId: RoomId | undefined; - /** - * Get the supported verification methods of the other side. - * - * Will be present only if the other side requested the - * verification or if we’re in the ready state. - * - * # Returns - * - * `undefined` if we do not yet know the supported methods; otherwise, an - * array of `VerificationMethod`s. - */ - readonly theirSupportedMethods: VerificationMethod[] | undefined; -} - -/** - * List of VerificationRequestState phases - */ -export enum VerificationRequestPhase { - /** - * The verification request has been newly created by us. - */ - Created = 0, - /** - * The verification request was received from the other party. - */ - Requested = 1, - /** - * The verification request is ready to start a verification flow. - */ - Ready = 2, - /** - * The verification request has transitioned into a concrete verification - * flow. For example it transitioned into the emoji based SAS - * verification. - */ - Transitioned = 3, - /** - * The verification flow that was started with this request has finished. - */ - Done = 4, - /** - * The verification process has been cancelled. - */ - Cancelled = 5, -} - -/** - * Object containing the versions of the Rust libraries we are using. - */ -export class Versions { - private constructor(); - free(): void; - [Symbol.dispose](): void; - /** - * The build-time output of the `git describe` command of the source tree - * of crate. - */ - readonly git_description: string; - /** - * The Git commit hash of the crate's source tree at build time. - */ - readonly git_sha: string; - /** - * The version of the matrix-sdk-crypto crate. - */ - readonly matrix_sdk_crypto: string; - /** - * The version of the vodozemac crate. - */ - readonly vodozemac: string; -} - -/** - * Get the versions of the Rust libraries we are using. - */ +* Get the versions of the Rust libraries we are using. +* @returns {Versions} +*/ export function getVersions(): Versions; - /** - * Run some stuff when the Wasm module is instantiated. - * - * Right now, it does the following: - * - * * Redirect Rust panics to JavaScript console. - */ +* Run some stuff when the Wasm module is instantiated. +* +* Right now, it does the following: +* +* * Redirect Rust panics to JavaScript console. +*/ export function start(): void; +/** +* The basic key algorithm names in the specification. +*/ +export enum DeviceKeyAlgorithmName { +/** +* The Ed25519 signature algorithm. +*/ + Ed25519 = 0, +/** +* The Curve25519 ECDH algorithm. +*/ + Curve25519 = 1, +/** +* The Curve25519 ECDH algorithm, but the key also contains +* signatures. +*/ + SignedCurve25519 = 2, +/** +* An unknown device key algorithm. +*/ + Unknown = 3, +} +/** +* The result of a signature check. +*/ +export enum SignatureState { +/** +* The signature is missing. +*/ + Missing = 0, +/** +* The signature is invalid. +*/ + Invalid = 1, +/** +* The signature is valid but the device or user identity that created the +* signature is not trusted. +*/ + ValidButNotTrusted = 2, +/** +* The signature is valid and the device or user identity that created the +* signature is trusted. +*/ + ValidAndTrusted = 3, +} +/** +* List of available verification methods. +*/ +export enum VerificationMethod { +/** +* The `m.sas.v1` verification method. +* +* SAS means Short Authentication String. +*/ + SasV1 = 0, +/** +* The `m.qr_code.scan.v1` verification method. +*/ + QrCodeScanV1 = 1, +/** +* The `m.qr_code.show.v1` verification method. +*/ + QrCodeShowV1 = 2, +/** +* The `m.reciprocate.v1` verification method. +*/ + ReciprocateV1 = 3, +} +/** +* An error code for why the process/request was cancelled by the +* user. +*/ +export enum CancelCode { +/** +* Unknown cancel code. +*/ + Other = 0, +/** +* The user cancelled the verification. +*/ + User = 1, +/** +* The verification process timed out. +* +* Verification processes can define their own timeout +* parameters. +*/ + Timeout = 2, +/** +* The device does not know about the given transaction ID. +*/ + UnknownTransaction = 3, +/** +* The device does not know how to handle the requested method. +* +* Should be sent for `m.key.verification.start` messages and +* messages defined by individual verification processes. +*/ + UnknownMethod = 4, +/** +* The device received an unexpected message. +* +* Typically raised when one of the parties is handling the +* verification out of order. +*/ + UnexpectedMessage = 5, +/** +* The key was not verified. +*/ + KeyMismatch = 6, +/** +* The expected user did not match the user verified. +*/ + UserMismatch = 7, +/** +* The message received was invalid. +*/ + InvalidMessage = 8, +/** +* An `m.key.verification.request` was accepted by a different +* device. +* +* The device receiving this error can ignore the verification +* request. +*/ + Accepted = 9, +/** +* The device receiving this error can ignore the verification +* request. +*/ + MismatchedCommitment = 10, +/** +* The SAS did not match. +*/ + MismatchedSas = 11, +} +/** +* List of `Qr` states +*/ +export enum QrState { +/** +* We have received the other device's details (from the +* `m.key.verification.request` or `m.key.verification.ready`) and +* established the shared secret, so can +* display the QR code. +*/ + Created = 0, +/** +* The other side has scanned our QR code and sent an +* `m.key.verification.start` message with `method: m.reciprocate.v1` with +* matching shared secret. +*/ + Scanned = 1, +/** +* Our user has confirmed that the other device scanned successfully. We +* have sent an `m.key.verification.done`. +*/ + Confirmed = 2, +/** +* We have scanned the other side's QR code and are able to send a +* `m.key.verification.start` message with `method: m.reciprocate.v1`. +* +* Call `Qr::reciprocate` to build the start message. +* +* Note that, despite the name of this state, we have not necessarily +* yet sent the `m.reciprocate.v1` message. +*/ + Reciprocated = 3, +/** +* Verification complete: we have received an `m.key.verification.done` +* from the other side. +*/ + Done = 4, +/** +* Verification cancelled or failed. +*/ + Cancelled = 5, +} +/** +* List of VerificationRequestState phases +*/ +export enum VerificationRequestPhase { +/** +* The verification request has been newly created by us. +*/ + Created = 0, +/** +* The verification request was received from the other party. +*/ + Requested = 1, +/** +* The verification request is ready to start a verification flow. +*/ + Ready = 2, +/** +* The verification request has transitioned into a concrete verification +* flow. For example it transitioned into the emoji based SAS +* verification. +*/ + Transitioned = 3, +/** +* The verification flow that was started with this request has finished. +*/ + Done = 4, +/** +* The verification process has been cancelled. +*/ + Cancelled = 5, +} +/** +* Logger level. +*/ +export enum LoggerLevel { +/** +* `TRACE` level. +* +* Designate very low priority, often extremely verbose, +* information. +*/ + Trace = 0, +/** +* `DEBUG` level. +* +* Designate lower priority information. +*/ + Debug = 1, +/** +* `INFO` level. +* +* Designate useful information. +*/ + Info = 2, +/** +* `WARN` level. +* +* Designate hazardous situations. +*/ + Warn = 3, +/** +* `ERROR` level. +* +* Designate very serious errors. +*/ + Error = 4, +} +/** +* Decryption error codes +*/ +export enum DecryptionErrorCode { +/** +* The room key is not known +*/ + MissingRoomKey = 0, +/** +* The room key is known but ratcheted +*/ + UnknownMessageIndex = 1, +/** +* Decryption failed because of a mismatch between the identity keys of the +* device we received the room key from and the identity keys recorded in +* the plaintext of the room key to-device message. +*/ + MismatchedIdentityKeys = 2, +/** +* Other failuer +*/ + UnableToDecrypt = 3, +} +/** +* An enum over the different key types a device can have. +* +* Currently devices have a curve25519 and ed25519 keypair. The keys +* transport format is a base64 encoded string, any unknown key type +* will be left as such a string. +*/ +export enum DeviceKeyName { +/** +* The curve25519 device key. +*/ + Curve25519 = 0, +/** +* The ed25519 device key. +*/ + Ed25519 = 1, +/** +* An unknown device key. +*/ + Unknown = 2, +} +/** +* The local trust state of a device. +*/ +export enum LocalTrust { +/** +* The device has been verified and is trusted. +*/ + Verified = 0, +/** +* The device been blacklisted from communicating. +*/ + BlackListed = 1, +/** +* The trust state of the device is being ignored. +*/ + Ignored = 2, +/** +* The trust state is unset. +*/ + Unset = 3, +} +/** +* Who can see a room's history. +*/ +export enum HistoryVisibility { +/** +* Previous events are accessible to newly joined members from +* the point they were invited onwards. +* +* Events stop being accessible when the member's state changes +* to something other than *invite* or *join*. +*/ + Invited = 0, +/** +* Previous events are accessible to newly joined members from +* the point they joined the room onwards. +* +* Events stop being accessible when the member's state changes +* to something other than *join*. +*/ + Joined = 1, +/** +* Previous events are always accessible to newly joined members. +* +* All events in the room are accessible, even those sent when +* the member was not a part of the room. +*/ + Shared = 2, +/** +* All events while this is the `HistoryVisibility` value may be +* shared by any participating homeserver with anyone, regardless +* of whether they have ever joined the room. +*/ + WorldReadable = 3, +} +/** +* Represent the type of a request. +*/ +export enum RequestType { +/** +* Represents a `KeysUploadRequest`. +*/ + KeysUpload = 0, +/** +* Represents a `KeysQueryRequest`. +*/ + KeysQuery = 1, +/** +* Represents a `KeysClaimRequest`. +*/ + KeysClaim = 2, +/** +* Represents a `ToDeviceRequest`. +*/ + ToDevice = 3, +/** +* Represents a `SignatureUploadRequest`. +*/ + SignatureUpload = 4, +/** +* Represents a `RoomMessageRequest`. +*/ + RoomMessage = 5, +/** +* Represents a `KeysBackupRequest`. +*/ + KeysBackup = 6, +/** +* Represents a `SigningKeysUploadRequest` +*/ + SigningKeysUpload = 7, +} +/** +* An encryption algorithm to be used to encrypt messages sent to a +* room. +*/ +export enum EncryptionAlgorithm { +/** +* Olm version 1 using Curve25519, AES-256, and SHA-256. +*/ + OlmV1Curve25519AesSha2 = 0, +/** +* Megolm version 1 using AES-256 and SHA-256. +*/ + MegolmV1AesSha2 = 1, +} +/** +* Take a look at [`matrix_sdk_common::deserialized_responses::ShieldState`] +* for more info. +*/ +export enum ShieldColor { +/** +* Important warning +*/ + Red = 0, +/** +* Low warning +*/ + Grey = 1, +/** +* No warning +*/ + None = 2, +} +/** +* A type to encrypt and to decrypt anything that can fit in an +* `Uint8Array`, usually big buffer. +*/ +export class Attachment { + free(): void; +/** +* Encrypt the content of the `Uint8Array`. +* +* It produces an `EncryptedAttachment`, which can be used to +* retrieve the media encryption information, or the encrypted +* data. +* @param {Uint8Array} array +* @returns {EncryptedAttachment} +*/ + static encrypt(array: Uint8Array): EncryptedAttachment; +/** +* Decrypt an `EncryptedAttachment`. +* +* The encrypted attachment can be created manually, or from the +* `encrypt` method. +* +* **Warning**: The encrypted attachment can be used only +* **once**! The encrypted data will still be present, but the +* media encryption info (which contain secrets) will be +* destroyed. It is still possible to get a JSON-encoded backup +* by calling `EncryptedAttachment.mediaEncryptionInfo`. +* @param {EncryptedAttachment} attachment +* @returns {Uint8Array} +*/ + static decrypt(attachment: EncryptedAttachment): Uint8Array; +} +/** +* The private part of the backup key, the one used for recovery. +*/ +export class BackupDecryptionKey { + free(): void; +/** +* Create a new random [`BackupDecryptionKey`]. +* @returns {BackupDecryptionKey} +*/ + static createRandomKey(): BackupDecryptionKey; +/** +* Try to create a [`BackupDecryptionKey`] from a base 64 encoded string. +* @param {string} key +* @returns {BackupDecryptionKey} +*/ + static fromBase64(key: string): BackupDecryptionKey; +/** +* Convert the backup decryption key to a base 64 encoded string. +* @returns {string} +*/ + toBase64(): string; +/** +* Try to decrypt a message that was encrypted using the public part of the +* backup key. +* @param {string} ephemeral_key +* @param {string} mac +* @param {string} ciphertext +* @returns {string} +*/ + decryptV1(ephemeral_key: string, mac: string, ciphertext: string): string; +/** +* Get the public part of the backup key. +*/ + readonly megolmV1PublicKey: MegolmV1BackupKey; +} +/** +* Stored versions of the backup keys. +*/ +export class BackupKeys { + free(): void; +/** +* The version that we are using for backups. +*/ + backupVersion?: string; +/** +* The key used to decrypt backed up room keys +*/ + decryptionKey?: BackupDecryptionKey; +/** +* The key used to decrypt backed up room keys, encoded as base64 +* +* @deprecated Use `BackupKeys.decryptionKey.toBase64()` +*/ + readonly decryptionKeyBase64: string | undefined; +} +/** +* Information about the cancellation of a verification request or +* verification flow. +*/ +export class CancelInfo { + free(): void; +/** +* Get the human readable reason of the cancellation. +* @returns {string} +*/ + reason(): string; +/** +* Get the `CancelCode` that cancelled this verification. +* @returns {number} +*/ + cancelCode(): number; +/** +* Was the verification cancelled by us? +* @returns {boolean} +*/ + cancelledbyUs(): boolean; +} +/** +* A struct containing private cross signing keys that can be backed +* up or uploaded to the secret store. +*/ +export class CrossSigningKeyExport { + free(): void; +/** +* The seed of the master key encoded as unpadded base64. +*/ + readonly masterKey: string | undefined; +/** +* The seed of the self signing key encoded as unpadded base64. +*/ + readonly self_signing_key: string | undefined; +/** +* The seed of the user signing key encoded as unpadded base64. +*/ + readonly userSigningKey: string | undefined; +} +/** +* Struct representing the state of our private cross signing keys, +* it shows which private cross signing keys we have locally stored. +*/ +export class CrossSigningStatus { + free(): void; +/** +* Do we have the master key? +*/ + readonly hasMaster: boolean; +/** +* Do we have the self signing key? This one is necessary to sign +* our own devices. +*/ + readonly hasSelfSigning: boolean; +/** +* Do we have the user signing key? This one is necessary to sign +* other users. +*/ + readonly hasUserSigning: boolean; +} +/** +* A Curve25519 public key. +*/ +export class Curve25519PublicKey { + free(): void; +/** +* Serialize an Curve25519 public key to an unpadded base64 +* representation. +* @returns {string} +*/ + toBase64(): string; +/** +* The number of bytes a Curve25519 public key has. +*/ + readonly length: number; +} +/** +* A decrypted room event. +*/ +export class DecryptedRoomEvent { + free(): void; +/** +* The verification state of the device that sent us the event. +* Note this is the state of the device at the time of +* decryption. It may change in the future if a device gets +* verified or deleted. +* @param {boolean} strict +* @returns {ShieldState | undefined} +*/ + shieldState(strict: boolean): ShieldState | undefined; +/** +* The JSON-encoded decrypted event. +*/ + readonly event: string; +/** +* Returns an empty array +* +* Previously, this returned the chain of Curve25519 keys through which +* this session was forwarded, via `m.forwarded_room_key` events. +* However, that is not cryptographically reliable, and clients should not +* be using it. +* +* @see https://github.com/matrix-org/matrix-spec/issues/1089 +*/ + readonly forwardingCurve25519KeyChain: Array; +/** +* The user ID of the event sender, note this is untrusted data +* unless the `verification_state` is as well trusted. +*/ + readonly sender: UserId | undefined; +/** +* The signing Ed25519 key that have created the megolm key that +* was used to decrypt this session. +*/ + readonly senderClaimedEd25519Key: string | undefined; +/** +* The Curve25519 key of the device that created the megolm +* decryption key originally. +*/ + readonly senderCurve25519Key: string | undefined; +/** +* The device ID of the device that sent us the event, note this +* is untrusted data unless `verification_state` is as well +* trusted. +*/ + readonly senderDevice: DeviceId | undefined; +} +/** +* A device represents a E2EE capable client of an user. +*/ +export class Device { + free(): void; +/** +* Request an interactive verification with this device. +* +* Returns a Promise for a 2-element array `[VerificationRequest, +* ToDeviceRequest]`. +* @param {Array | undefined} methods +* @returns {Promise} +*/ + requestVerification(methods?: Array): Promise; +/** +* Is this device considered to be verified. +* +* This method returns true if either the `is_locally_trusted` +* method returns `true` or if the `is_cross_signing_trusted` +* method returns `true`. +* @returns {boolean} +*/ + isVerified(): boolean; +/** +* Is this device considered to be verified using cross signing. +* @returns {boolean} +*/ + isCrossSigningTrusted(): boolean; +/** +* Is this device cross-signed by its owner? +* @returns {boolean} +*/ + isCrossSignedByOwner(): boolean; +/** +* Set the local trust state of the device to the given state. +* +* This won’t affect any cross signing trust state, this only +* sets a flag marking to have the given trust state. +* +* `trust_state` represents the new trust state that should be +* set for the device. +* @param {number} local_state +* @returns {Promise} +*/ + setLocalTrust(local_state: number): Promise; +/** +* Get the key of the given key algorithm belonging to this device. +* @param {number} algorithm +* @returns {DeviceKey | undefined} +*/ + getKey(algorithm: number): DeviceKey | undefined; +/** +* Is the device locally marked as trusted? +* @returns {boolean} +*/ + isLocallyTrusted(): boolean; +/** +* Is the device locally marked as blacklisted? +* +* Blacklisted devices won’t receive any group sessions. +* @returns {boolean} +*/ + isBlacklisted(): boolean; +/** +* Is the device deleted? +* @returns {boolean} +*/ + isDeleted(): boolean; +/** +* Timestamp representing the first time this device has been seen (in +* milliseconds). +* @returns {bigint} +*/ + firstTimeSeen(): bigint; +/** +* Mark this device as verified. +* Works only if the device is owned by the current user. +* +* Returns a signature upload request that needs to be sent out. +* @returns {Promise} +*/ + verify(): Promise; +/** +* Get the list of algorithms this device supports. +* +* Returns `Array`. +*/ + readonly algorithms: Array; +/** +* Get the Curve25519 key of the given device. +*/ + readonly curve25519Key: Curve25519PublicKey | undefined; +/** +* The unique ID of the device. +*/ + readonly deviceId: DeviceId; +/** +* Get the human readable name of the device. +*/ + readonly displayName: string | undefined; +/** +* Get the Ed25519 key of the given device. +*/ + readonly ed25519Key: Ed25519PublicKey | undefined; +/** +* Get a map containing all the device keys. +*/ + readonly keys: Map; +/** +* Get the trust state of the device. +*/ + readonly localTrustState: number; +/** +* Get a map containing all the device signatures. +*/ + readonly signatures: Signatures; +/** +* The user ID of the device owner. +*/ + readonly userId: UserId; +} +/** +* A Matrix key ID. +* +* Device identifiers in Matrix are completely opaque character +* sequences. This type is provided simply for its semantic value. +*/ +export class DeviceId { + free(): void; +/** +* Create a new `DeviceId`. +* @param {string} id +*/ + constructor(id: string); +/** +* Return the device ID as a string. +* @returns {string} +*/ + toString(): string; +} +/** +* An enum over the different key types a device can have. +* +* Currently devices have a curve25519 and ed25519 keypair. The keys +* transport format is a base64 encoded string, any unknown key type +* will be left as such a string. +*/ +export class DeviceKey { + free(): void; +/** +* Convert the `DeviceKey` into a base64 encoded string. +* @returns {string} +*/ + toBase64(): string; +/** +* Get the value associated to the `Curve25519` device key name. +*/ + readonly curve25519: Curve25519PublicKey | undefined; +/** +* Get the value associated to the `Ed25519` device key name. +*/ + readonly ed25519: Ed25519PublicKey | undefined; +/** +* Get the name of the device key. +*/ + readonly name: number; +/** +* Get the value associated to the `Unknown` device key name. +*/ + readonly unknown: string | undefined; +} +/** +* The basic key algorithms in the specification. +*/ +export class DeviceKeyAlgorithm { + free(): void; +/** +* Return the device key algorithm as a string. +* @returns {string} +*/ + toString(): string; +/** +* Read the device key algorithm's name. If the name is +* `Unknown`, one may be interested by the `to_string` method to +* read the original name. +*/ + readonly name: number; +} +/** +* A Matrix device key ID. +* +* A key algorithm and a device ID, combined with a ‘:’. +*/ +export class DeviceKeyId { + free(): void; +/** +* Parse/validate and create a new `DeviceKeyId`. +* @param {string} id +*/ + constructor(id: string); +/** +* Return the device key ID as a string. +* @returns {string} +*/ + toString(): string; +/** +* Returns key algorithm of the device key ID. +*/ + readonly algorithm: DeviceKeyAlgorithm; +/** +* Returns device ID of the device key ID. +*/ + readonly deviceId: DeviceId; +} +/** +* Information on E2E device updates. +*/ +export class DeviceLists { + free(): void; +/** +* Create an empty `DeviceLists`. +* +* `changed` and `left` must be an array of `UserId`. +* @param {Array | undefined} changed +* @param {Array | undefined} left +*/ + constructor(changed?: Array, left?: Array); +/** +* Returns true if there are no device list updates. +* @returns {boolean} +*/ + isEmpty(): boolean; +/** +* List of users who have updated their device identity keys or +* who now share an encrypted room with the client since the +* previous sync +*/ + readonly changed: Array; +/** +* List of users who no longer share encrypted rooms since the +* previous sync response. +*/ + readonly left: Array; +} +/** +* An Ed25519 public key, used to verify digital signatures. +*/ +export class Ed25519PublicKey { + free(): void; +/** +* Serialize an Ed25519 public key to an unpadded base64 +* representation. +* @returns {string} +*/ + toBase64(): string; +/** +* The number of bytes an Ed25519 public key has. +*/ + readonly length: number; +} +/** +* An Ed25519 digital signature, can be used to verify the +* authenticity of a message. +*/ +export class Ed25519Signature { + free(): void; +/** +* Try to create an Ed25519 signature from an unpadded base64 +* representation. +* @param {string} signature +*/ + constructor(signature: string); +/** +* Serialize a Ed25519 signature to an unpadded base64 +* representation. +* @returns {string} +*/ + toBase64(): string; +} +/** +* An emoji that is used for interactive verification using a short +* auth string. +* +* This will contain a single emoji and description from the list of +* emojis from [the specification]. +* +* [the specification]: https://spec.matrix.org/unstable/client-server-api/#sas-method-emoji +*/ +export class Emoji { + free(): void; +/** +* The description of the emoji, for example ‘Dog’. +*/ + readonly description: string; +/** +* The emoji symbol that represents a part of the short auth +* string, for example: 🐶 +*/ + readonly symbol: string; +} +/** +* An encrypted attachment, usually created from `Attachment.encrypt`. +*/ +export class EncryptedAttachment { + free(): void; +/** +* Create a new encrypted attachment manually. +* +* It needs encrypted data, stored in an `Uint8Array`, and a +* [media encryption +* information](https://docs.rs/matrix-sdk-crypto/latest/matrix_sdk_crypto/struct.MediaEncryptionInfo.html), +* as a JSON-encoded string. +* +* The media encryption information aren't stored as a string: +* they are parsed, validated and fully deserialized. +* +* See [the specification to learn +* more](https://spec.matrix.org/unstable/client-server-api/#extensions-to-mroommessage-msgtypes). +* @param {Uint8Array} encrypted_data +* @param {string} media_encryption_info +*/ + constructor(encrypted_data: Uint8Array, media_encryption_info: string); +/** +* The actual encrypted data. +* +* **Warning**: It returns a **copy** of the entire encrypted +* data; be nice with your memory. +*/ + readonly encryptedData: Uint8Array; +/** +* Check whether the media encryption info has been consumed by +* `Attachment.decrypt` already. +*/ + readonly hasMediaEncryptionInfoBeenConsumed: boolean; +/** +* Return the media encryption info as a JSON-encoded string. The +* structure is fully valid. +* +* If the media encryption info have been consumed already, it +* will return `null`. +*/ + readonly mediaEncryptionInfo: string | undefined; +} +/** +* Struct containing information on how an event was decrypted. +*/ +export class EncryptionInfo { + free(): void; +/** +* The verification state of the device that sent us the event. +* Note this is the state of the device at the time of +* decryption. It may change in the future if a device gets +* verified or deleted. +* +* # Arguments +* +* * `strict` - whether to enable "strict mode" verification. In non-strict +* mode, unverified users are given no shield, and keys that have been +* forwarded or restored from an insecure backup are given a grey shield +* (both get a red shield in strict mode). +* @param {boolean} strict +* @returns {ShieldState} +*/ + shieldState(strict: boolean): ShieldState; +/** +* The user ID of the event sender. Note this is untrusted data +* unless `verification_state` is also trusted. +*/ + readonly sender: UserId; +/** +* The signing Ed25519 key that created the megolm key that +* was used to decrypt this session. +*/ + readonly senderClaimedEd25519Key: string | undefined; +/** +* The Curve25519 key of the device that created the megolm +* decryption key originally. +*/ + readonly senderCurve25519Key: string | undefined; +/** +* The device ID of the device that sent us the event. Note this +* is untrusted data unless `verification_state` is also +* trusted. +*/ + readonly senderDevice: DeviceId | undefined; +} +/** +* Settings for an encrypted room. +* +* This determines the algorithm and rotation periods of a group +* session. +*/ +export class EncryptionSettings { + free(): void; +/** +* Create a new `EncryptionSettings` with default values. +*/ + constructor(); +/** +* The encryption algorithm that should be used in the room. +*/ + algorithm: number; +/** +* The history visibility of the room when the session was +* created. +*/ + historyVisibility: number; +/** +* Should untrusted devices receive the room key, or should they be +* excluded from the conversation. +*/ + onlyAllowTrustedDevices: boolean; +/** +* How long the session should be used before changing it, +* expressed in microseconds. +*/ + rotationPeriod: bigint; +/** +* How many messages should be sent before changing the session. +*/ + rotationPeriodMessages: bigint; +} +/** +* A Matrix [event ID]. +* +* An `EventId` is generated randomly or converted from a string +* slice, and can be converted back into a string as needed. +* +* [event ID]: https://spec.matrix.org/v1.2/appendices/#room-ids-and-event-ids +*/ +export class EventId { + free(): void; +/** +* Parse/validate and create a new `EventId`. +* @param {string} id +*/ + constructor(id: string); +/** +* Return the event ID as a string. +* @returns {string} +*/ + toString(): string; +/** +* Returns the event's localpart. +*/ + readonly localpart: string; +/** +* Returns the server name of the event ID. +*/ + readonly serverName: ServerName | undefined; +} +/** +* Struct holding the two public identity keys of an account. +*/ +export class IdentityKeys { + free(): void; +/** +* The Curve25519 public key, used for establish shared secrets. +*/ + curve25519: Curve25519PublicKey; +/** +* The Ed25519 public key, used for signing. +*/ + ed25519: Ed25519PublicKey; +} +/** +* Inbound group session. +* +* Inbound group sessions are used to exchange room messages between a group of +* participants. Inbound group sessions are used to decrypt the room messages. +*/ +export class InboundGroupSession { + free(): void; +/** +* Has the session been imported from a file or server-side backup? As +* opposed to being directly received as an `m.room_key` event. +* @returns {boolean} +*/ + hasBeenImported(): boolean; +/** +* The room where this session is used in. +*/ + readonly roomId: RoomId; +/** +* The Curve25519 key of the sender of this session, as a +* [Curve25519PublicKey]. +*/ + readonly senderKey: Curve25519PublicKey; +/** +* Returns the unique identifier for this session. +*/ + readonly sessionId: string; +} +/** +* A request that will back up a batch of room keys to the server +* ([specification]). +* +* [specification]: https://spec.matrix.org/unstable/client-server-api/#put_matrixclientv3room_keyskeys +*/ +export class KeysBackupRequest { + free(): void; +/** +* Create a new `KeysBackupRequest`. +* @param {string} id +* @param {string} body +* @param {string} version +*/ + constructor(id: string, body: string, version: string); +/** +* A JSON-encoded string containing the rest of the payload: `rooms`. +* +* It represents the body of the HTTP request. +*/ + readonly body: string; +/** +* The request ID. +*/ + readonly id: string | undefined; +/** +* Get its request type. +*/ + readonly type: number; +/** +* The backup version that these room keys should be part of. +*/ + readonly version: string; +} +/** +* Data for a request to the `/keys/claim` API endpoint +* ([specification]). +* +* Claims one-time keys that can be used to establish 1-to-1 E2EE +* sessions. +* +* [specification]: https://spec.matrix.org/unstable/client-server-api/#post_matrixclientv3keysclaim +*/ +export class KeysClaimRequest { + free(): void; +/** +* Create a new `KeysClaimRequest`. +* @param {string} id +* @param {string} body +*/ + constructor(id: string, body: string); +/** +* A JSON-encoded string containing the rest of the payload: `timeout`, +* `one_time_keys`. +* +* It represents the body of the HTTP request. +*/ + readonly body: string; +/** +* The request ID. +*/ + readonly id: string | undefined; +/** +* Get its request type. +*/ + readonly type: number; +} +/** +* Data for a request to the `/keys/query` API endpoint +* ([specification]). +* +* Returns the current devices and identity keys for the given users. +* +* [specification]: https://spec.matrix.org/unstable/client-server-api/#post_matrixclientv3keysquery +*/ +export class KeysQueryRequest { + free(): void; +/** +* Create a new `KeysQueryRequest`. +* @param {string} id +* @param {string} body +*/ + constructor(id: string, body: string); +/** +* A JSON-encoded string containing the rest of the payload: `timeout`, +* `device_keys`, `token`. +* +* It represents the body of the HTTP request. +*/ + readonly body: string; +/** +* The request ID. +*/ + readonly id: string | undefined; +/** +* Get its request type. +*/ + readonly type: number; +} +/** +* Outgoing Requests * +* Data for a request to the `/keys/upload` API endpoint +* ([specification]). +* +* Publishes end-to-end encryption keys for the device. +* +* [specification]: https://spec.matrix.org/unstable/client-server-api/#post_matrixclientv3keysupload +*/ +export class KeysUploadRequest { + free(): void; +/** +* Create a new `KeysUploadRequest`. +* @param {string} id +* @param {string} body +*/ + constructor(id: string, body: string); +/** +* A JSON-encoded string containing the rest of the payload: `device_keys`, +* `one_time_keys`, `fallback_keys`. +* +* It represents the body of the HTTP request. +*/ + readonly body: string; +/** +* The request ID. +*/ + readonly id: string | undefined; +/** +* Get its request type. +*/ + readonly type: number; +} +/** +* Represents a signature that is either valid _or_ that could not be +* decoded. +*/ +export class MaybeSignature { + free(): void; +/** +* Check whether the signature has been successfully decoded. +* @returns {boolean} +*/ + isValid(): boolean; +/** +* Check whether the signature could not be successfully decoded. +* @returns {boolean} +*/ + isInvalid(): boolean; +/** +* The base64 encoded string that is claimed to contain a +* signature but could not be decoded, if any. +*/ + readonly invalidSignatureSource: string | undefined; +/** +* The signature, if successfully decoded. +*/ + readonly signature: Signature | undefined; +} +/** +* Js Decryption error with code. +*/ +export class MegolmDecryptionError { + free(): void; +/** +* Description code for the error. See `DecryptionErrorCode` +*/ + readonly code: number; +/** +* detailed description +*/ + readonly description: string; +/** +* Witheld code if any. Only for `UnknownMessageIndex` error code +*/ + readonly maybe_withheld: string | undefined; +} +/** +* The public part of the backup key. +*/ +export class MegolmV1BackupKey { + free(): void; +/** +* Get the full name of the backup algorithm this backup key supports. +*/ + readonly algorithm: string; +/** +* The actual base64 encoded public key. +*/ + readonly publicKeyBase64: string; +} +/** +* State machine implementation of the Olm/Megolm encryption protocol +* used for Matrix end to end encryption. +*/ +export class OlmMachine { + free(): void; +/** +* Constructor will always fail. To create a new `OlmMachine`, please use +* the `initialize` method. +* +* Why this pattern? `initialize` returns a `Promise`. Returning a +*/ + constructor(); +/** +* Create a new `OlmMachine`. +* +* The created machine will keep the encryption keys either in a IndexedDB +* based store, or in a memory store and once the objects is dropped, +* the keys will be lost. +* +* # Arguments +* +* * `user_id` - represents the unique ID of the user that owns this +* machine. +* +* * `device_id` - represents the unique ID of the device +* that owns this machine. +* +* * `store_name` - The name that should be used to open the IndexedDB +* based database. If this isn't provided, a memory-only store will be +* used. *Note* the memory-only store will lose your E2EE keys when the +* `OlmMachine` gets dropped. +* +* * `store_passphrase` - The passphrase that should be used to encrypt the +* IndexedDB based +* @param {UserId} user_id +* @param {DeviceId} device_id +* @param {string | undefined} store_name +* @param {string | undefined} store_passphrase +* @returns {Promise} +*/ + static initialize(user_id: UserId, device_id: DeviceId, store_name?: string, store_passphrase?: string): Promise; +/** +* Get the list of users whose devices we are currently tracking. +* +* A user can be marked for tracking using the +* [`update_tracked_users`](#method.update_tracked_users) method. +* +* Returns a `Set`. +* @returns {Promise} +*/ + trackedUsers(): Promise; +/** +* Update the list of tracked users. +* +* The OlmMachine maintains a list of users whose devices we are keeping +* track of: these are known as "tracked users". These must be users +* that we share a room with, so that the server sends us updates for +* their device lists. +* +* # Arguments +* +* * `users` - An array of user ids that should be added to the list of +* tracked users +* +* Any users that hadn't been seen before will be flagged for a key query +* immediately, and whenever `receive_sync_changes` receives a +* "changed" notification for that user in the future. +* +* Users that were already in the list are unaffected. +* @param {Array} users +* @returns {Promise} +*/ + updateTrackedUsers(users: Array): Promise; +/** +* Handle to-device events and one-time key counts from a sync +* response. +* +* This will decrypt and handle to-device events returning the +* decrypted versions of them. +* +* To decrypt an event from the room timeline call +* `decrypt_room_event`. +* +* # Arguments +* +* * `to_device_events`: the JSON-encoded to-device evens from the `/sync` +* response +* * `changed_devices`: the mapping of changed and left devices, from the +* `/sync` response +* * `one_time_keys_counts`: The number of one-time keys on the server, +* from the `/sync` response. A `Map` from string (encryption algorithm) +* to number (number of keys). +* * `unused_fallback_keys`: Optionally, a `Set` of unused fallback keys on +* the server, from the `/sync` response. If this is set, it is used to +* determine if new fallback keys should be uploaded. +* +* # Returns +* +* A list of JSON strings, containing the decrypted to-device events. +* @param {string} to_device_events +* @param {DeviceLists} changed_devices +* @param {Map} one_time_keys_counts +* @param {Set | undefined} unused_fallback_keys +* @returns {Promise} +*/ + receiveSyncChanges(to_device_events: string, changed_devices: DeviceLists, one_time_keys_counts: Map, unused_fallback_keys?: Set): Promise; +/** +* Get the outgoing requests that need to be sent out. +* +* This returns a list of `JsValue` to represent either: +* * `KeysUploadRequest`, +* * `KeysQueryRequest`, +* * `KeysClaimRequest`, +* * `ToDeviceRequest`, +* * `SignatureUploadRequest`, +* * `RoomMessageRequest` or +* * `KeysBackupRequest`. +* +* Those requests need to be sent out to the server and the +* responses need to be passed back to the state machine using +* `mark_request_as_sent`. +* @returns {Promise} +*/ + outgoingRequests(): Promise; +/** +* Mark the request with the given request ID as sent (see +* `outgoing_requests`). +* +* Arguments are: +* +* * `request_id` represents the unique ID of the request that was sent +* out. This is needed to couple the response with the now sent out +* request. +* * `response_type` represents the type of the request that was sent out. +* * `response` represents the response that was received from the server +* after the outgoing request was sent out. +* @param {string} request_id +* @param {number} request_type +* @param {string} response +* @returns {Promise} +*/ + markRequestAsSent(request_id: string, request_type: number, response: string): Promise; +/** +* Encrypt a room message for the given room. +* +* Beware that a room key needs to be shared before this +* method can be called using the `share_room_key` method. +* +* `room_id` is the ID of the room for which the message should +* be encrypted. `event_type` is the type of the event. `content` +* is the plaintext content of the message that should be +* encrypted. +* +* # Panics +* +* Panics if a group session for the given room wasn't shared +* beforehand. +* @param {RoomId} room_id +* @param {string} event_type +* @param {string} content +* @returns {Promise} +*/ + encryptRoomEvent(room_id: RoomId, event_type: string, content: string): Promise; +/** +* Decrypt an event from a room timeline. +* +* # Arguments +* +* * `event`, the event that should be decrypted. +* * `room_id`, the ID of the room where the event was sent to. +* +* # Returns +* +* A `Promise` which resolves to a {@link DecryptedRoomEvent} instance, or +* rejects with a {@link MegolmDecryptionError} instance. +* @param {string} event +* @param {RoomId} room_id +* @returns {Promise} +*/ + decryptRoomEvent(event: string, room_id: RoomId): Promise; +/** +* Get encryption info for a decrypted timeline event. +* +* This recalculates the `EncryptionInfo` data that is returned by +* `decryptRoomEvent`, based on the current +* verification status of the sender, etc. +* +* Returns an error for an unencrypted event. +* +* # Arguments +* +* * `event` - The event to get information for. +* * `room_id` - The ID of the room where the event was sent to. +* +* # Returns +* +* {@link EncryptionInfo} +* @param {string} event +* @param {RoomId} room_id +* @returns {Promise} +*/ + getRoomEventEncryptionInfo(event: string, room_id: RoomId): Promise; +/** +* Get the status of the private cross signing keys. +* +* This can be used to check which private cross signing keys we +* have stored locally. +* @returns {Promise} +*/ + crossSigningStatus(): Promise; +/** +* Export all the private cross signing keys we have. +* +* The export will contain the seeds for the ed25519 keys as +* unpadded base64 encoded strings. +* +* Returns `null` if we don’t have any private cross signing keys; +* otherwise returns a `CrossSigningKeyExport`. +* @returns {Promise} +*/ + exportCrossSigningKeys(): Promise; +/** +* Import our private cross signing keys. +* +* The keys should be provided as unpadded-base64-encoded strings. +* +* Returns a `CrossSigningStatus`. +* @param {string | undefined} master_key +* @param {string | undefined} self_signing_key +* @param {string | undefined} user_signing_key +* @returns {Promise} +*/ + importCrossSigningKeys(master_key?: string, self_signing_key?: string, user_signing_key?: string): Promise; +/** +* Create a new cross signing identity and get the upload request +* to push the new public keys to the server. +* +* Warning: This will delete any existing cross signing keys that +* might exist on the server and thus will reset the trust +* between all the devices. +* +* Uploading these keys will require user interactive auth. +* +* # Arguments +* +* * `reset`, whether the method should create a new identity or use the +* existing one during the request. If set to true, the request will +* attempt to upload a new identity. If set to false, the request will +* attempt to upload the existing identity. Since the uploading process +* requires user interactive authentication, which involves sending out +* the same request multiple times, setting this argument to false +* enables you to reuse the same request. +* +* Returns an `Array` of `OutgoingRequest`s +* @param {boolean} reset +* @returns {Promise} +*/ + bootstrapCrossSigning(reset: boolean): Promise; +/** +* Get the cross signing user identity of a user. +* +* Returns a promise for an `OwnUserIdentity`, a `UserIdentity`, or +* `undefined`. +* @param {UserId} user_id +* @returns {Promise} +*/ + getIdentity(user_id: UserId): Promise; +/** +* Sign the given message using our device key and if available +* cross-signing master key. +* @param {string} message +* @returns {Promise} +*/ + sign(message: string): Promise; +/** +* Invalidate the currently active outbound group session for the +* given room. +* +* Returns true if a session was invalidated, false if there was +* no session to invalidate. +* @param {RoomId} room_id +* @returns {Promise} +*/ + invalidateGroupSession(room_id: RoomId): Promise; +/** +* Get to-device requests to share a room key with users in a room. +* +* `room_id` is the room ID. `users` is an array of `UserId` +* objects. `encryption_settings` are an `EncryptionSettings` +* object. +* +* Returns an array of `ToDeviceRequest`s. +* @param {RoomId} room_id +* @param {Array} users +* @param {EncryptionSettings} encryption_settings +* @returns {Promise} +*/ + shareRoomKey(room_id: RoomId, users: Array, encryption_settings: EncryptionSettings): Promise; +/** +* Generate an "out-of-band" key query request for the given set of users. +* +* This can be useful if we need the results from `getIdentity` or +* `getUserDevices` to be as up-to-date as possible. +* +* Returns a `KeysQueryRequest` object. The response of the request should +* be passed to the `OlmMachine` with the `mark_request_as_sent`. +* @param {Array} users +* @returns {KeysQueryRequest} +*/ + queryKeysForUsers(users: Array): KeysQueryRequest; +/** +* Get the a key claiming request for the user/device pairs that +* we are missing Olm sessions for. +* +* Returns `null` if no key claiming request needs to be sent +* out, otherwise it returns a `KeysClaimRequest` object. +* +* Sessions need to be established between devices so group +* sessions for a room can be shared with them. +* +* This should be called every time a group session needs to be +* shared as well as between sync calls. After a sync some +* devices may request room keys without us having a valid Olm +* session with them, making it impossible to server the room key +* request, thus it’s necessary to check for missing sessions +* between sync as well. +* +* Note: Care should be taken that only one such request at a +* time is in flight, e.g. using a lock. +* +* The response of a successful key claiming requests needs to be +* passed to the `OlmMachine` with the `mark_request_as_sent`. +* +* `users` represents the list of users that we should check if +* we lack a session with one of their devices. This can be an +* empty iterator when calling this method between sync requests. +* @param {Array} users +* @returns {Promise} +*/ + getMissingSessions(users: Array): Promise; +/** +* Get a map holding all the devices of a user. +* +* `user_id` represents the unique ID of the user that the +* devices belong to. +* @param {UserId} user_id +* @returns {Promise} +*/ + getUserDevices(user_id: UserId): Promise; +/** +* Get a specific device of a user if one is found and the crypto store +* didn't throw an error. +* +* `user_id` represents the unique ID of the user that the +* identity belongs to. `device_id` represents the unique ID of +* the device. +* @param {UserId} user_id +* @param {DeviceId} device_id +* @returns {Promise} +*/ + getDevice(user_id: UserId, device_id: DeviceId): Promise; +/** +* Get a verification object for the given user ID with the given +* flow ID (a to-device request ID if the verification has been +* requested by a to-device request, or a room event ID if the +* verification has been requested by a room event). +* +* It returns a “`Verification` object”, which is either a `Sas` +* or `Qr` object. +* @param {UserId} user_id +* @param {string} flow_id +* @returns {any} +*/ + getVerification(user_id: UserId, flow_id: string): any; +/** +* Get a verification request object with the given flow ID. +* @param {UserId} user_id +* @param {string} flow_id +* @returns {VerificationRequest | undefined} +*/ + getVerificationRequest(user_id: UserId, flow_id: string): VerificationRequest | undefined; +/** +* Get all the verification requests of a given user. +* @param {UserId} user_id +* @returns {Array} +*/ + getVerificationRequests(user_id: UserId): Array; +/** +* Receive a verification event. +* +* This method can be used to pass verification events that are happening +* in rooms to the `OlmMachine`. The event should be in the decrypted form. +* @param {string} event +* @param {RoomId} room_id +* @returns {Promise} +*/ + receiveVerificationEvent(event: string, room_id: RoomId): Promise; +/** +* Export the keys that match the given predicate. +* +* `predicate` is a closure that will be called for every known +* `InboundGroupSession`, which represents a room key. If the closure +* returns `true`, the `InboundGroupSession` will be included in the +* export, otherwise it won't. +* @param {Function} predicate +* @returns {Promise} +*/ + exportRoomKeys(predicate: Function): Promise; +/** +* Import the given room keys into our store. +* +* `exported_keys` is a list of previously exported keys that should be +* imported into our store. If we already have a better version of a key, +* the key will _not_ be imported. +* +* `progress_listener` is a closure that takes 2 arguments: `progress` and +* `total`, and returns nothing. +* @param {string} exported_room_keys +* @param {Function} progress_listener +* @returns {Promise} +*/ + importRoomKeys(exported_room_keys: string, progress_listener: Function): Promise; +/** +* Store the backup decryption key in the crypto store. +* +* This is useful if the client wants to support gossiping of the backup +* key. +* +* Returns `Promise`. +* @param {BackupDecryptionKey} decryption_key +* @param {string} version +* @returns {Promise} +*/ + saveBackupDecryptionKey(decryption_key: BackupDecryptionKey, version: string): Promise; +/** +* Get the backup keys we have saved in our store. +* Returns a `Promise` for {@link BackupKeys}. +* @returns {Promise} +*/ + getBackupKeys(): Promise; +/** +* Check if the given backup has been verified by us or by another of our +* devices that we trust. +* +* The `backup_info` should be a Javascript object with the following +* format: +* +* ```json +* { +* "algorithm": "m.megolm_backup.v1.curve25519-aes-sha2", +* "auth_data": { +* "public_key":"XjhWTCjW7l59pbfx9tlCBQolfnIQWARoKOzjTOPSlWM", +* "signatures": {} +* } +* } +* ``` +* +* Returns a {@link SignatureVerification} object. +* @param {any} backup_info +* @returns {Promise} +*/ + verifyBackup(backup_info: any): Promise; +/** +* Activate the given backup key to be used with the given backup version. +* +* **Warning**: The caller needs to make sure that the given `BackupKey` is +* trusted, otherwise we might be encrypting room keys that a malicious +* party could decrypt. +* +* The {@link #verifyBackup} method can be used to do so. +* +* Returns `Promise`. +* @param {string} public_key_base_64 +* @param {string} version +* @returns {Promise} +*/ + enableBackupV1(public_key_base_64: string, version: string): Promise; +/** +* Are we able to encrypt room keys. +* +* This returns true if we have an active `BackupKey` and backup version +* registered with the state machine. +* +* Returns `Promise`. +* @returns {Promise} +*/ + isBackupEnabled(): Promise; +/** +* Disable and reset our backup state. +* +* This will remove any pending backup request, remove the backup key and +* reset the backup state of each room key we have. +* +* Returns `Promise`. +* @returns {Promise} +*/ + disableBackup(): Promise; +/** +* Encrypt a batch of room keys and return a request that needs to be sent +* out to backup the room keys. +* +* Returns an optional {@link KeysBackupRequest}. +* @returns {Promise} +*/ + backupRoomKeys(): Promise; +/** +* Get the number of backed up room keys and the total number of room keys. +* Returns a {@link RoomKeyCounts}. +* @returns {Promise} +*/ + roomKeyCounts(): Promise; +/** +* Encrypt the list of exported room keys using the given passphrase. +* +* `exported_room_keys` is a list of sessions that should be encrypted +* (it's generally returned by `export_room_keys`). `passphrase` is the +* passphrase that will be used to encrypt the exported room keys. And +* `rounds` is the number of rounds that should be used for the key +* derivation when the passphrase gets turned into an AES key. More rounds +* are increasingly computationnally intensive and as such help against +* brute-force attacks. Should be at least `10_000`, while values in the +* `100_000` ranges should be preferred. +* @param {string} exported_room_keys +* @param {string} passphrase +* @param {number} rounds +* @returns {string} +*/ + static encryptExportedRoomKeys(exported_room_keys: string, passphrase: string, rounds: number): string; +/** +* Try to decrypt a reader into a list of exported room keys. +* +* `encrypted_exported_room_keys` is the result from +* `encrypt_exported_room_keys`. `passphrase` is the passphrase that was +* used when calling `encrypt_exported_room_keys`. +* @param {string} encrypted_exported_room_keys +* @param {string} passphrase +* @returns {string} +*/ + static decryptExportedRoomKeys(encrypted_exported_room_keys: string, passphrase: string): string; +/** +* Register a callback which will be called whenever there is an update to +* a room key. +* +* `callback` should be a function that takes a single argument (an array +* of {@link RoomKeyInfo}) and returns a Promise. +* @param {Function} callback +* @returns {Promise} +*/ + registerRoomKeyUpdatedCallback(callback: Function): Promise; +/** +* Register a callback which will be called whenever there is an update to +* a user identity. +* +* `callback` should be a function that takes a single argument (a {@link +* UserId}) and returns a Promise. +* @param {Function} callback +* @returns {Promise} +*/ + registerUserIdentityUpdatedCallback(callback: Function): Promise; +/** +* Shut down the `OlmMachine`. +* +* The `OlmMachine` cannot be used after this method has been called. +* +* All associated resources will be closed too, like IndexedDB +* connections. +*/ + close(): void; +/** +* The unique device ID that identifies this `OlmMachine`. +*/ + readonly deviceId: DeviceId; +/** +* Get the display name of our own device. +*/ + readonly displayName: Promise; +/** +* Get the public parts of our Olm identity keys. +*/ + readonly identityKeys: IdentityKeys; +/** +* The unique user ID that owns this `OlmMachine` instance. +*/ + readonly userId: UserId; +} +/** +* Struct representing a cross signing identity of a user. +* +* This is the user identity of a user that is our own. +*/ +export class OwnUserIdentity { + free(): void; +/** +* Is this user identity verified? +* @returns {boolean} +*/ + isVerified(): boolean; +/** +* Mark our user identity as verified. +* +* This will mark the identity locally as verified and sign it with our own +* device. +* +* Returns a signature upload request that needs to be sent out. +* @returns {Promise} +*/ + verify(): Promise; +/** +* Send a verification request to our other devices. +* @param {Array | undefined} methods +* @returns {Promise} +*/ + requestVerification(methods?: Array): Promise; +/** +* Does our user identity trust our own device, i.e. have we signed our own +* device keys with our self-signing key? +* @returns {Promise} +*/ + trustsOurOwnDevice(): Promise; +/** +* Get the master key of the identity. +*/ + readonly masterKey: string; +/** +* Get the self-signing key of the identity. +*/ + readonly selfSigningKey: string; +/** +* Get the user-signing key of the identity, this is only present for our +* own user identity.. +*/ + readonly userSigningKey: string; +} +/** +* QR code based verification. +*/ +export class Qr { + free(): void; +/** +* Get the current state of this request. +* +* Returns a `QrState`. +* @returns {number} +*/ + state(): number; +/** +* Has the QR verification been scanned by the other side. +* +* When the verification object is in this state it’s required +* that the user confirms that the other side has scanned the QR +* code. +* @returns {boolean} +*/ + hasBeenScanned(): boolean; +/** +* Has the scanning of the QR code been confirmed by us? +* @returns {boolean} +*/ + hasBeenConfirmed(): boolean; +/** +* Did we initiate the verification request? +* @returns {boolean} +*/ + weStarted(): boolean; +/** +* Get info about the cancellation if the verification flow has +* been cancelled. +* @returns {CancelInfo | undefined} +*/ + cancelInfo(): CancelInfo | undefined; +/** +* Has the verification flow completed? +* @returns {boolean} +*/ + isDone(): boolean; +/** +* Has the verification flow been cancelled? +* @returns {boolean} +*/ + isCancelled(): boolean; +/** +* Is this a verification that is verifying one of our own devices? +* @returns {boolean} +*/ + isSelfVerification(): boolean; +/** +* Have we successfully scanned the QR code and are able to send +* a reciprocation event? +* @returns {boolean} +*/ + reciprocated(): boolean; +/** +* Generate a QR code object that is representing this +* verification flow. +* +* The QrCode can then be rendered as an image or as an unicode +* string. +* +* The `to_bytes` method can be used to instead output the raw +* bytes that should be encoded as a QR code. +* +* Returns a `QrCode`. +* @returns {QrCode} +*/ + toQrCode(): QrCode; +/** +* Generate a the raw bytes that should be encoded as a QR code +* is representing this verification flow. +* +* The `to_qr_code` method can be used to instead output a QrCode +* object that can be rendered. +* @returns {Uint8ClampedArray} +*/ + toBytes(): Uint8ClampedArray; +/** +* Notify the other side that we have successfully scanned the QR +* code and that the QR verification flow can start. +* +* This will return some OutgoingContent if the object is in the +* correct state to start the verification flow, otherwise None. +* @returns {any} +*/ + reciprocate(): any; +/** +* Confirm that the other side has scanned our QR code. +* +* Returns either an `OutgoingRequest` which should be sent out, or +* `undefined` if the verification is already confirmed. +* @returns {any} +*/ + confirmScanning(): any; +/** +* Cancel the verification flow. +* +* Returns either an `OutgoingRequest` which should be sent out, or +* `undefined` if the verification is already cancelled. +* @returns {any} +*/ + cancel(): any; +/** +* Cancel the verification. +* +* This cancels the verification with given code. +* +* Returns either an `OutgoingRequest` which should be sent out, or +* `undefined` if the verification is already cancelled. +* @param {number} code +* @returns {any} +*/ + cancelWithCode(code: number): any; +/** +* Register a callback which will be called whenever there is an update to +* the request +* +* The `callback` is called with no parameters. +* @param {Function} callback +*/ + registerChangesCallback(callback: Function): void; +/** +* Get the unique ID that identifies this QR verification flow, +* be either a to-device request ID or a room event ID. +*/ + readonly flowId: string; +/** +* Get the device ID of the other side. +*/ + readonly otherDeviceId: DeviceId; +/** +* Get the user id of the other user that is participating in +* this verification flow. +*/ + readonly otherUserId: UserId; +/** +* Get the room id if the verification is happening inside a +* room. +*/ + readonly roomId: RoomId | undefined; +/** +* Get our own user ID. +*/ + readonly userId: UserId; +} +/** +* A QR code. +*/ +export class QrCode { + free(): void; +/** +* Render the QR code into a `Uint8ClampedArray` where 1 represents a +* dark pixel and 0 a white pixel. +* @returns {Uint8ClampedArray} +*/ + renderIntoBuffer(): Uint8ClampedArray; +} +/** +* A scanned QR code. +*/ +export class QrCodeScan { + free(): void; +/** +* Parse the decoded payload of a QR code in byte slice form. +* +* This method is useful if you would like to do your own custom QR code +* decoding. +* @param {Uint8ClampedArray} buffer +* @returns {QrCodeScan} +*/ + static fromBytes(buffer: Uint8ClampedArray): QrCodeScan; +} +/** +* A Matrix [room ID]. +* +* [room ID]: https://spec.matrix.org/v1.2/appendices/#room-ids-and-event-ids +*/ +export class RoomId { + free(): void; +/** +* Parse/validate and create a new `RoomId`. +* @param {string} id +*/ + constructor(id: string); +/** +* Return the room ID as a string. +* @returns {string} +*/ + toString(): string; +/** +* Returns the user's localpart. +*/ + readonly localpart: string; +/** +* Returns the server name of the room ID. +*/ + readonly serverName: ServerName; +} +/** +* Struct holding the number of room keys we have. +*/ +export class RoomKeyCounts { + free(): void; +/** +* The number of backed up room keys. +*/ + backedUp: number; +/** +* The total number of room keys. +*/ + total: number; +} +/** +* Information on a room key that has been received or imported. +*/ +export class RoomKeyInfo { + free(): void; +/** +* The {@link EncryptionAlgorithm} that this key is used for. Will be one +* of the `m.megolm.*` algorithms. +*/ + readonly algorithm: number; +/** +* The room where the key is used. +*/ + readonly roomId: RoomId; +/** +* The Curve25519 key of the device which initiated the session originally. +*/ + readonly senderKey: Curve25519PublicKey; +/** +* The ID of the session that the key is for. +*/ + readonly sessionId: string; +} +/** +* A customized owned request type for sending out room messages +* ([specification]). +* +* [specification]: https://spec.matrix.org/unstable/client-server-api/#put_matrixclientv3roomsroomidsendeventtypetxnid +*/ +export class RoomMessageRequest { + free(): void; +/** +* Create a new `RoomMessageRequest`. +* @param {string} id +* @param {string} room_id +* @param {string} txn_id +* @param {string} event_type +* @param {string} content +*/ + constructor(id: string, room_id: string, txn_id: string, event_type: string, content: string); +/** +* A JSON-encoded string containing the message's content. +*/ + readonly body: string; +/** +* A string representing the type of event to be sent. +*/ + readonly event_type: string; +/** +* The request ID. +*/ + readonly id: string | undefined; +/** +* A string representing the room to send the event to. +*/ + readonly room_id: string; +/** +* A string representing the transaction ID for this event. +* +* Clients should generate an ID unique across requests with the same +* access token; it will be used by the server to ensure idempotency of +* requests. +*/ + readonly txn_id: string; +/** +* Get its request type. +*/ + readonly type: number; +} +/** +* Short Authentication String (SAS) verification. +*/ +export class Sas { + free(): void; +/** +* Does this verification flow support displaying emoji for the +* short authentication string? +* @returns {boolean} +*/ + supportsEmoji(): boolean; +/** +* Did this verification flow start from a verification request? +* @returns {boolean} +*/ + startedFromRequest(): boolean; +/** +* Is this a verification that is verifying one of our own +* devices? +* @returns {boolean} +*/ + isSelfVerification(): boolean; +/** +* Have we confirmed that the short auth string matches? +* @returns {boolean} +*/ + haveWeConfirmed(): boolean; +/** +* Has the verification been accepted by both parties? +* @returns {boolean} +*/ + hasBeenAccepted(): boolean; +/** +* Get info about the cancellation if the verification flow has +* been cancelled. +* @returns {CancelInfo | undefined} +*/ + cancelInfo(): CancelInfo | undefined; +/** +* True if we initiated the verification flow (ie, we sent the +* `m.key.verification.request`). +* @returns {boolean} +*/ + weStarted(): boolean; +/** +* Accept the SAS verification. +* +* This does nothing (and returns `undefined`) if the verification was +* already accepted, otherwise it returns an `OutgoingRequest` +* that needs to be sent out. +* @returns {any} +*/ + accept(): any; +/** +* Confirm the SAS verification. +* +* This confirms that the short auth strings match on both sides. +* +* Does nothing if we’re not in a state where we can confirm the +* short auth string. +* +* Returns a `Promise` for an array of `OutgoingRequest`s. +* @returns {Promise} +*/ + confirm(): Promise; +/** +* Cancel the verification. +* +* Returns either an `OutgoingRequest` which should be sent out, or +* `undefined` if the verification is already cancelled. +* @returns {any} +*/ + cancel(): any; +/** +* Cancel the verification. +* +* This cancels the verification with given code. +* +* Returns either an `OutgoingRequest` which should be sent out, or +* `undefined` if the verification is already cancelled. +* @param {number} code +* @returns {any} +*/ + cancelWithCode(code: number): any; +/** +* Has the SAS verification flow timed out? +* @returns {boolean} +*/ + timedOut(): boolean; +/** +* Are we in a state where we can show the short auth string? +* @returns {boolean} +*/ + canBePresented(): boolean; +/** +* Is the SAS flow done? +* @returns {boolean} +*/ + isDone(): boolean; +/** +* Is the SAS flow cancelled? +* @returns {boolean} +*/ + isCancelled(): boolean; +/** +* Get the emoji version of the short auth string. +* +* Returns `undefined` if we can't yet present the short auth string, +* otherwise an array of seven `Emoji` objects. +* @returns {Array | undefined} +*/ + emoji(): Array | undefined; +/** +* Get the index of the emoji representing the short auth string +* +* Returns `undefined` if we can’t yet present the short auth +* string, otherwise seven `u8` numbers in the range from 0 to 63 +* inclusive which can be converted to an emoji using [the +* relevant specification +* entry](https://spec.matrix.org/unstable/client-server-api/#sas-method-emoji). +* @returns {Array | undefined} +*/ + emojiIndex(): Array | undefined; +/** +* Get the decimal version of the short auth string. +* +* Returns None if we can’t yet present the short auth string, +* otherwise a tuple containing three 4-digit integers that +* represent the short auth string. +* @returns {Array | undefined} +*/ + decimals(): Array | undefined; +/** +* Register a callback which will be called whenever there is an update to +* the request. +* +* The `callback` is called with no parameters. +* @param {Function} callback +*/ + registerChangesCallback(callback: Function): void; +/** +* Get our own device ID. +*/ + readonly deviceId: DeviceId; +/** +* Get the unique ID that identifies this SAS verification flow, +* be either a to-device request ID or a room event ID. +*/ + readonly flowId: string; +/** +* Get the device ID of the other side. +*/ + readonly otherDeviceId: DeviceId; +/** +* Get the user id of the other side. +*/ + readonly otherUserId: UserId; +/** +* Get the room ID if the verification is happening inside a +* room. +*/ + readonly roomId: RoomId | undefined; +/** +* Get our own user ID. +*/ + readonly userId: UserId; +} +/** +* A Matrix-spec compliant [server name]. +* +* It consists of a host and an optional port (separated by a colon if +* present). +* +* [server name]: https://spec.matrix.org/v1.2/appendices/#server-name +*/ +export class ServerName { + free(): void; +/** +* Parse/validate and create a new `ServerName`. +* @param {string} name +*/ + constructor(name: string); +/** +* Returns true if and only if the server name is an IPv4 or IPv6 +* address. +* @returns {boolean} +*/ + isIpLiteral(): boolean; +/** +* Returns the host of the server name. +* +* That is: Return the part of the server before `:` or the +* full server name if there is no port. +*/ + readonly host: string; +/** +* Returns the port of the server name if any. +*/ + readonly port: number | undefined; +} +/** +* Take a look at [`matrix_sdk_common::deserialized_responses::ShieldState`] +* for more info. +*/ +export class ShieldState { + free(): void; +/** +* The shield color +*/ + color: number; +/** +* Error message that can be displayed as a tooltip +*/ + readonly message: string | undefined; +} +/** +* Represents a potentially decoded signature (but not a validated +* one). +*/ +export class Signature { + free(): void; +/** +* Convert the signature to a base64 encoded string. +* @returns {string} +*/ + toBase64(): string; +/** +* Get the Ed25519 signature, if this is one. +*/ + readonly ed25519: Ed25519Signature | undefined; +} +/** +* Data for a request to the `/keys/signatures/upload` API endpoint +* ([specification]). +* +* Publishes cross-signing signatures for the user. +* +* [specification]: https://spec.matrix.org/unstable/client-server-api/#post_matrixclientv3keyssignaturesupload +*/ +export class SignatureUploadRequest { + free(): void; +/** +* Create a new `SignatureUploadRequest`. +* @param {string} id +* @param {string} signed_keys +*/ + constructor(id: string, signed_keys: string); +/** +* A JSON-encoded string containing the payload of the request +* +* It represents the body of the HTTP request. +*/ + readonly body: string; +/** +* The request ID. +*/ + readonly id: string | undefined; +/** +* Get its request type. +*/ + readonly type: number; +} +/** +* The result of a signature verification of a signed JSON object. +*/ +export class SignatureVerification { + free(): void; +/** +* Is the result considered to be trusted? +* +* This tells us if the result has a valid signature from any of the +* following: +* +* * Our own device +* * Our own user identity, provided the identity is trusted as well +* * Any of our own devices, provided the device is trusted as well +* @returns {boolean} +*/ + trusted(): boolean; +/** +* Give the backup signature state from the current device. +* See SignatureState for values +*/ + readonly deviceState: number; +/** +* Give the backup signature state from the current user identity. +* See SignatureState for values +*/ + readonly userState: number; +} +/** +* A collection of `Signature`. +*/ +export class Signatures { + free(): void; +/** +* Creates a new, empty, signatures collection. +*/ + constructor(); +/** +* Add the given signature from the given signer and the given key ID to +* the collection. +* @param {UserId} signer +* @param {DeviceKeyId} key_id +* @param {Ed25519Signature} signature +* @returns {MaybeSignature | undefined} +*/ + addSignature(signer: UserId, key_id: DeviceKeyId, signature: Ed25519Signature): MaybeSignature | undefined; +/** +* Try to find an Ed25519 signature from the given signer with +* the given key ID. +* @param {UserId} signer +* @param {DeviceKeyId} key_id +* @returns {Ed25519Signature | undefined} +*/ + getSignature(signer: UserId, key_id: DeviceKeyId): Ed25519Signature | undefined; +/** +* Get the map of signatures that belong to the given user. +* @param {UserId} signer +* @returns {Map | undefined} +*/ + get(signer: UserId): Map | undefined; +/** +* Remove all the signatures we currently hold. +*/ + clear(): void; +/** +* Do we hold any signatures or is our collection completely +* empty. +* @returns {boolean} +*/ + isEmpty(): boolean; +/** +* Get the json with all signatures +* @returns {string} +*/ + asJSON(): string; +/** +* How many signatures do we currently hold. +*/ + readonly count: number; +} +/** +* Other Requests * +* Request that will publish a cross signing identity. +* +* This uploads the public cross signing key triplet. +*/ +export class SigningKeysUploadRequest { + free(): void; +/** +* Create a new `SigningKeysUploadRequest`. +* @param {string} id +* @param {string} body +*/ + constructor(id: string, body: string); +/** +* A JSON-encoded string containing the rest of the payload: `master_key`, +* `self_signing_key`, `user_signing_key`. +* +* It represents the body of the HTTP request. +*/ + readonly body: string; +/** +* The request ID. +*/ + readonly id: string | undefined; +/** +* Get its request type. +*/ + readonly type: number; +} +/** +* Data for a request to the `/sendToDevice` API endpoint +* ([specification]). +* +* Send an event to a single device or to a group of devices. +* +* [specification]: https://spec.matrix.org/unstable/client-server-api/#put_matrixclientv3sendtodeviceeventtypetxnid +*/ +export class ToDeviceRequest { + free(): void; +/** +* Create a new `ToDeviceRequest`. +* @param {string} id +* @param {string} event_type +* @param {string} txn_id +* @param {string} body +*/ + constructor(id: string, event_type: string, txn_id: string, body: string); +/** +* A JSON-encoded string containing the rest of the payload: `messages`. +* +* It represents the body of the HTTP request. +*/ + readonly body: string; +/** +* A string representing the type of event being sent to each devices. +*/ + readonly event_type: string; +/** +* The request ID. +*/ + readonly id: string | undefined; +/** +* A string representing a request identifier unique to the access token +* used to send the request. +*/ + readonly txn_id: string; +/** +* Get its request type. +*/ + readonly type: number; +} +/** +* Type to install and to manipulate the tracing layer. +*/ +export class Tracing { + free(): void; +/** +* Check whether the `tracing` feature has been enabled. +* @returns {boolean} +*/ + static isAvailable(): boolean; +/** +* Install the tracing layer. +* +* `Tracing` is a singleton. Once it is installed, +* consecutive calls to the constructor will construct a new +* `Tracing` object but with the exact same inner +* state. Calling the constructor with a new `min_level` will +* just update the `min_level` parameter; in that regard, it +* is similar to calling the `min_level` method on an +* existing `Tracing` object. +* @param {number} min_level +*/ + constructor(min_level: number); +/** +* Turn the logger on, i.e. it emits logs again if it was turned +* off. +*/ + turnOn(): void; +/** +* Turn the logger off, i.e. it no long emits logs. +*/ + turnOff(): void; +/** +* Re-define the minimum logger level. +*/ + minLevel: number; +} +/** +* A read only view over all devices belonging to a user. +*/ +export class UserDevices { + free(): void; +/** +* Get the specific device with the given device ID. +* @param {DeviceId} device_id +* @returns {Device | undefined} +*/ + get(device_id: DeviceId): Device | undefined; +/** +* Returns true if there is at least one devices of this user +* that is considered to be verified, false otherwise. +* +* This won't consider your own device as verified, as your own +* device is always implicitly verified. +* @returns {boolean} +*/ + isAnyVerified(): boolean; +/** +* Array over all the device IDs of the user devices. +* @returns {Array} +*/ + keys(): Array; +/** +* Iterator over all the devices of the user devices. +* @returns {Array} +*/ + devices(): Array; +} +/** +* A Matrix [user ID]. +* +* [user ID]: https://spec.matrix.org/v1.2/appendices/#user-identifiers +*/ +export class UserId { + free(): void; +/** +* Parse/validate and create a new `UserId`. +* @param {string} id +*/ + constructor(id: string); +/** +* Whether this user ID is a historical one. +* +* A historical user ID is one that doesn't conform to the latest +* specification of the user ID grammar but is still accepted +* because it was previously allowed. +* @returns {boolean} +*/ + isHistorical(): boolean; +/** +* Return the user ID as a string. +* @returns {string} +*/ + toString(): string; +/** +* Returns the user's localpart. +*/ + readonly localpart: string; +/** +* Returns the server name of the user ID. +*/ + readonly serverName: ServerName; +} +/** +* Struct representing a cross signing identity of a user. +* +* This is the user identity of a user that isn't our own. Other users will +* only contain a master key and a self signing key, meaning that only device +* signatures can be checked with this identity. +* +* This struct wraps a read-only version of the struct and allows verifications +* to be requested to verify our own device with the user identity. +*/ +export class UserIdentity { + free(): void; +/** +* Is this user identity verified? +* @returns {boolean} +*/ + isVerified(): boolean; +/** +* Manually verify this user. +* +* This method will attempt to sign the user identity using our private +* cross signing key. +* +* This method fails if we don't have the private part of our user-signing +* key. +* +* Returns a request that needs to be sent out for the user to be marked as +* verified. +* @returns {Promise} +*/ + verify(): Promise; +/** +* Create a `VerificationRequest` object after the verification +* request content has been sent out. +* @param {RoomId} room_id +* @param {EventId} request_event_id +* @param {Array | undefined} methods +* @returns {Promise} +*/ + requestVerification(room_id: RoomId, request_event_id: EventId, methods?: Array): Promise; +/** +* Send a verification request to the given user. +* +* The returned content needs to be sent out into a DM room with the given +* user. +* +* After the content has been sent out a VerificationRequest can be started +* with the `request_verification` method. +* @param {Array | undefined} methods +* @returns {Promise} +*/ + verificationRequestContent(methods?: Array): Promise; +/** +* Get the master key of the identity. +*/ + readonly masterKey: string; +/** +* Get the self-signing key of the identity. +*/ + readonly selfSigningKey: string; +} +/** +* An object controlling key verification requests. +* +* Interactive verification flows usually start with a verification +* request, this object lets you send and reply to such a +* verification request. +* +* After the initial handshake the verification flow transitions into +* one of the verification methods. +*/ +export class VerificationRequest { + free(): void; +/** +* Create an event content that can be sent as a room event to +* request verification from the other side. This should be used +* only for verifications of other users and it should be sent to +* a room we consider to be a DM with the other user. +* @param {UserId} own_user_id +* @param {DeviceId} own_device_id +* @param {UserId} other_user_id +* @param {Array | undefined} methods +* @returns {string} +*/ + static request(own_user_id: UserId, own_device_id: DeviceId, other_user_id: UserId, methods?: Array): string; +/** +* Has the verification request been answered by another device? +* @returns {boolean} +*/ + isPassive(): boolean; +/** +* Is the verification request ready to start a verification flow? +* @returns {boolean} +*/ + isReady(): boolean; +/** +* Has the verification flow timed out? +* @returns {boolean} +*/ + timedOut(): boolean; +/** +* The number of milliseconds remaining before this verification flow times +* out. +* +* Returns zero if the time has already passed. +* @returns {number} +*/ + timeRemainingMillis(): number; +/** +* Is this a verification that is verifying one of our own +* devices? +* @returns {boolean} +*/ + isSelfVerification(): boolean; +/** +* Did we initiate the verification request? +* @returns {boolean} +*/ + weStarted(): boolean; +/** +* Has the verification flow that was started with this request +* finished? +* @returns {boolean} +*/ + isDone(): boolean; +/** +* Get the current phase of this request. +* +* Returns a `VerificationRequestPhase`. +* @returns {number} +*/ + phase(): number; +/** +* If this request has transitioned into a concrete verification +* flow (and not yet been completed or cancelled), returns a `Verification` +* object. +* +* Returns: a `Sas`, a `Qr`, or `undefined`. +* @returns {any} +*/ + getVerification(): any; +/** +* Register a callback which will be called whenever there is an update to +* the request. +* +* The `callback` is called with no parameters. +* @param {Function} callback +*/ + registerChangesCallback(callback: Function): void; +/** +* Has the verification flow that was started with this request +* been cancelled? +* @returns {boolean} +*/ + isCancelled(): boolean; +/** +* Accept the verification request signaling that our client +* supports the given verification methods. +* +* `methods` represents the methods that we should advertise as +* supported by us. +* +* It returns either a `ToDeviceRequest`, a `RoomMessageRequest` +* or `undefined`. +* @param {Array} methods +* @returns {any} +*/ + acceptWithMethods(methods: Array): any; +/** +* Accept the verification request. +* +* This method will accept the request and signal that it +* supports the `m.sas.v1`, the `m.qr_code.show.v1`, and +* `m.reciprocate.v1` method. +* +* `m.qr_code.show.v1` will only be signaled if the `qrcode` +* feature is enabled. This feature is disabled by default. If +* it's enabled and QR code scanning should be supported or QR +* code showing shouldn't be supported the `accept_with_methods` +* method should be used instead. +* +* It returns either a `ToDeviceRequest`, a `RoomMessageRequest` +* or `undefined`. +* @returns {any} +*/ + accept(): any; +/** +* Cancel the verification request. +* +* It returns either a `ToDeviceRequest`, a `RoomMessageRequest` +* or `undefined`. +* @returns {any} +*/ + cancel(): any; +/** +* Transition from this verification request into a SAS verification flow. +* +* Returns `Promise<[Sas, RoomMessageRequest|ToDeviceRequest] | undefined>` +* @returns {Promise} +*/ + startSas(): Promise; +/** +* Generate a QR code that can be used by another client to start +* a QR code based verification. +* +* Returns a `Qr`. +* @returns {Promise} +*/ + generateQrCode(): Promise; +/** +* Start a QR code verification by providing a scanned QR code +* for this verification flow. +* @param {QrCodeScan} data +* @returns {Promise} +*/ + scanQrCode(data: QrCodeScan): Promise; +/** +* Get info about the cancellation if the verification request +* has been cancelled. +*/ + readonly cancelInfo: CancelInfo | undefined; +/** +* Get the unique ID of this verification request. +*/ + readonly flowId: string; +/** +* The ID of the other device that is participating in this +* verification. +*/ + readonly otherDeviceId: DeviceId | undefined; +/** +* The ID of the other user that is participating in this +* verification request. +*/ + readonly otherUserId: UserId; +/** +* Get our own supported verification methods that we advertised. +* +* Will be present only we requested the verification or if we’re +* in the ready state. +*/ + readonly ourSupportedMethods: Array | undefined; +/** +* Our own user id. +*/ + readonly ownUserId: UserId; +/** +* Get the room ID if the verification is happening inside a +* room. +*/ + readonly roomId: RoomId | undefined; +/** +* Get the supported verification methods of the other side. +* +* Will be present only if the other side requested the +* verification or if we’re in the ready state. +* +* It return a `Option>`. +*/ + readonly theirSupportedMethods: Array | undefined; +} +/** +* Object containing the versions of the Rust libraries we are using. +*/ +export class Versions { + free(): void; +/** +* The version of the matrix-sdk-crypto crate. +*/ + readonly matrix_sdk_crypto: string; +/** +* The version of the vodozemac crate. +*/ + readonly vodozemac: string; +} +/** + * Load the WebAssembly module in the background, if it has not already been loaded. + * + * Returns a promise which will resolve once the other methods are ready. + * + * @returns {Promise} + */ +export function initAsync(): Promise; diff --git a/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.cjs b/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.cjs deleted file mode 100644 index 3610ce5..0000000 --- a/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.cjs +++ /dev/null @@ -1,12809 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.ToDeviceRequest = exports.ToDeviceEncryptionInfo = exports.StoredRoomKeyBundleData = exports.StoreHandle = exports.Signatures = exports.SignatureVerification = exports.SignatureUploadRequest = exports.SignatureState = exports.Signature = exports.ShieldStateCode = exports.ShieldState = exports.ShieldColor = exports.ServerName = exports.SecretsBundle = exports.Sas = exports.RoomSettings = exports.RoomPendingKeyBundleDetails = exports.RoomMessageRequest = exports.RoomKeyWithheldInfo = exports.RoomKeyInfo = exports.RoomKeyImportResult = exports.RoomKeyCounts = exports.RoomId = exports.RequestType = exports.RehydratedDevice = exports.QrState = exports.QrCodeScan = exports.QrCodeIntentData = exports.QrCodeIntent = exports.QrCodeData = exports.QrCode = exports.Qr = exports.PutDehydratedDeviceRequest = exports.ProcessedToDeviceEventType = exports.PlainTextToDeviceEvent = exports.PkMessage = exports.PkEncryption = exports.PkDecryption = exports.PickledSession = exports.PickledInboundGroupSession = exports.OwnUserIdentity = exports.OutboundCreationResult = exports.OtherUserIdentity = exports.OlmMachine = exports.Msc4388IntentData = exports.Msc4108IntentData = exports.Migration = exports.MegolmV1BackupKey = exports.MegolmDecryptionError = exports.MaybeSignature = exports.LoggerLevel = exports.LocalTrust = exports.KeysUploadRequest = exports.KeysQueryRequest = exports.KeysClaimRequest = exports.KeysBackupRequest = exports.InvalidToDeviceEvent = exports.InboundGroupSession = exports.InboundCreationResult = exports.IdentityKeys = exports.HistoryVisibility = exports.EventId = exports.EstablishedEcies = exports.EncryptionSettings = exports.EncryptionInfo = exports.EncryptionAlgorithm = exports.EncryptedAttachment = exports.Emoji = exports.Ed25519Signature = exports.Ed25519PublicKey = exports.Ecies = exports.DeviceLists = exports.DeviceKeyName = exports.DeviceKeyId = exports.DeviceKeyAlgorithmName = exports.DeviceKeyAlgorithm = exports.DeviceKey = exports.DeviceId = exports.Device = exports.DehydratedDevices = exports.DehydratedDeviceKey = exports.DehydratedDevice = exports.DecryptionSettings = exports.DecryptionErrorCode = exports.DecryptedToDeviceEvent = exports.DecryptedRoomEvent = exports.Curve25519SecretKey = exports.Curve25519PublicKey = exports.CrossSigningStatus = exports.CrossSigningKeyExport = exports.CrossSigningBootstrapRequests = exports.CollectStrategy = exports.CheckCode = exports.CancelInfo = exports.BaseMigrationData = exports.Base64EncodedPkMessage = exports.BackupSecretsBundle = exports.BackupKeys = exports.BackupDecryptionKey = exports.Attachment = void 0; -exports.Versions = exports.VerificationRequestPhase = exports.VerificationRequest = exports.VerificationMethod = exports.UserId = exports.UserDevices = exports.UploadSigningKeysRequest = exports.UTDToDeviceEvent = exports.TrustRequirement = exports.Tracing = exports.ToDeviceUnableToDecryptReason = exports.ToDeviceUnableToDecryptInfo = void 0; -exports.__wbg_Error_408e67f47ca7b58b = __wbg_Error_408e67f47ca7b58b; -exports.__wbg_Number_3890faa6d3ff057d = __wbg_Number_3890faa6d3ff057d; -exports.__wbg_String_8564e559799eccda = __wbg_String_8564e559799eccda; -exports.__wbg_Window_241244be8c9776c1 = __wbg_Window_241244be8c9776c1; -exports.__wbg_WorkerGlobalScope_8623a7c9030fbce2 = __wbg_WorkerGlobalScope_8623a7c9030fbce2; -exports.__wbg___wbindgen_bigint_get_as_i64_c4ecf48528083721 = __wbg___wbindgen_bigint_get_as_i64_c4ecf48528083721; -exports.__wbg___wbindgen_boolean_get_c9c83ebd41b34df3 = __wbg___wbindgen_boolean_get_c9c83ebd41b34df3; -exports.__wbg___wbindgen_debug_string_a57024b9c6e4a48b = __wbg___wbindgen_debug_string_a57024b9c6e4a48b; -exports.__wbg___wbindgen_in_ac983077f137f2e6 = __wbg___wbindgen_in_ac983077f137f2e6; -exports.__wbg___wbindgen_is_bigint_8ffbbef442139384 = __wbg___wbindgen_is_bigint_8ffbbef442139384; -exports.__wbg___wbindgen_is_function_5e4570eb24ffa122 = __wbg___wbindgen_is_function_5e4570eb24ffa122; -exports.__wbg___wbindgen_is_null_7d13f41e1a2d5140 = __wbg___wbindgen_is_null_7d13f41e1a2d5140; -exports.__wbg___wbindgen_is_object_a2790eb24c211ea0 = __wbg___wbindgen_is_object_a2790eb24c211ea0; -exports.__wbg___wbindgen_is_string_e6f02f0ea5f20a32 = __wbg___wbindgen_is_string_e6f02f0ea5f20a32; -exports.__wbg___wbindgen_is_undefined_6cff064c44e0d823 = __wbg___wbindgen_is_undefined_6cff064c44e0d823; -exports.__wbg___wbindgen_jsval_eq_0a18949a61670320 = __wbg___wbindgen_jsval_eq_0a18949a61670320; -exports.__wbg___wbindgen_jsval_loose_eq_acf2776254a8d832 = __wbg___wbindgen_jsval_loose_eq_acf2776254a8d832; -exports.__wbg___wbindgen_number_get_136b9679cab35cfb = __wbg___wbindgen_number_get_136b9679cab35cfb; -exports.__wbg___wbindgen_string_get_d154f1e671052120 = __wbg___wbindgen_string_get_d154f1e671052120; -exports.__wbg___wbindgen_throw_bb96b2010945f0bc = __wbg___wbindgen_throw_bb96b2010945f0bc; -exports.__wbg__wbg_cb_unref_be22cc64ae6946a0 = __wbg__wbg_cb_unref_be22cc64ae6946a0; -exports.__wbg_abort_32b500c4f9eab55d = __wbg_abort_32b500c4f9eab55d; -exports.__wbg_add_18ccb6b4b9da9cd9 = __wbg_add_18ccb6b4b9da9cd9; -exports.__wbg_add_2b945856b580d5ab = __wbg_add_2b945856b580d5ab; -exports.__wbg_at_facbe5ae998bba3a = __wbg_at_facbe5ae998bba3a; -exports.__wbg_backupkeys_new = __wbg_backupkeys_new; -exports.__wbg_bound_e48dc2f851c77207 = __wbg_bound_e48dc2f851c77207; -exports.__wbg_call_0f2a9af232c18fd2 = __wbg_call_0f2a9af232c18fd2; -exports.__wbg_call_1c5886ab9c57d1c7 = __wbg_call_1c5886ab9c57d1c7; -exports.__wbg_call_35dba3c747ad7521 = __wbg_call_35dba3c747ad7521; -exports.__wbg_call_39f824e18d9d2414 = __wbg_call_39f824e18d9d2414; -exports.__wbg_clearTimeout_3629d6209dfcc46e = __wbg_clearTimeout_3629d6209dfcc46e; -exports.__wbg_clear_07a20ccd42c66921 = __wbg_clear_07a20ccd42c66921; -exports.__wbg_close_0c1f30aeb9a080a7 = __wbg_close_0c1f30aeb9a080a7; -exports.__wbg_code_5c2c992d8a3afb58 = __wbg_code_5c2c992d8a3afb58; -exports.__wbg_commit_ebd6d9676954e0d2 = __wbg_commit_ebd6d9676954e0d2; -exports.__wbg_continue_cbf53c725c127fe3 = __wbg_continue_cbf53c725c127fe3; -exports.__wbg_count_be9295f0aceb7d6a = __wbg_count_be9295f0aceb7d6a; -exports.__wbg_count_c48ec9dcdccef1d5 = __wbg_count_c48ec9dcdccef1d5; -exports.__wbg_createIndex_9e2beb35a103225a = __wbg_createIndex_9e2beb35a103225a; -exports.__wbg_createIndex_f8a090296c419c6c = __wbg_createIndex_f8a090296c419c6c; -exports.__wbg_createObjectStore_d3884936b845900f = __wbg_createObjectStore_d3884936b845900f; -exports.__wbg_crosssigningbootstraprequests_new = __wbg_crosssigningbootstraprequests_new; -exports.__wbg_crosssigningkeyexport_new = __wbg_crosssigningkeyexport_new; -exports.__wbg_crosssigningstatus_new = __wbg_crosssigningstatus_new; -exports.__wbg_crypto_38df2bab126b63dc = __wbg_crypto_38df2bab126b63dc; -exports.__wbg_debug_1ac2ea5532f70f4c = __wbg_debug_1ac2ea5532f70f4c; -exports.__wbg_debug_3853dbaf0bca30f9 = __wbg_debug_3853dbaf0bca30f9; -exports.__wbg_decryptedroomevent_new = __wbg_decryptedroomevent_new; -exports.__wbg_decryptedtodeviceevent_new = __wbg_decryptedtodeviceevent_new; -exports.__wbg_dehydrateddevice_new = __wbg_dehydrateddevice_new; -exports.__wbg_dehydrateddevicekey_new = __wbg_dehydrateddevicekey_new; -exports.__wbg_deleteObjectStore_ed0e7d0b256bead4 = __wbg_deleteObjectStore_ed0e7d0b256bead4; -exports.__wbg_delete_03ff02bcb1b57138 = __wbg_delete_03ff02bcb1b57138; -exports.__wbg_delete_27b012593b3f623b = __wbg_delete_27b012593b3f623b; -exports.__wbg_device_new = __wbg_device_new; -exports.__wbg_deviceid_new = __wbg_deviceid_new; -exports.__wbg_devicekey_new = __wbg_devicekey_new; -exports.__wbg_devicekeyid_new = __wbg_devicekeyid_new; -exports.__wbg_done_669171204c3dcae2 = __wbg_done_669171204c3dcae2; -exports.__wbg_emoji_new = __wbg_emoji_new; -exports.__wbg_encryptedattachment_new = __wbg_encryptedattachment_new; -exports.__wbg_encryptioninfo_new = __wbg_encryptioninfo_new; -exports.__wbg_entries_71601bcb707d5078 = __wbg_entries_71601bcb707d5078; -exports.__wbg_entries_7774d489e1da5f4f = __wbg_entries_7774d489e1da5f4f; -exports.__wbg_error_24e6ac605d438e54 = __wbg_error_24e6ac605d438e54; -exports.__wbg_error_757e9472f8410341 = __wbg_error_757e9472f8410341; -exports.__wbg_error_dbd3752906405f8d = __wbg_error_dbd3752906405f8d; -exports.__wbg_error_dd408a7b3cb542dd = __wbg_error_dd408a7b3cb542dd; -exports.__wbg_from_74f3d90e0ff11240 = __wbg_from_74f3d90e0ff11240; -exports.__wbg_getAllKeys_1de66542d233a4a5 = __wbg_getAllKeys_1de66542d233a4a5; -exports.__wbg_getAllKeys_65d7deed4f9b2d48 = __wbg_getAllKeys_65d7deed4f9b2d48; -exports.__wbg_getAll_358f5970d9bee84b = __wbg_getAll_358f5970d9bee84b; -exports.__wbg_getAll_6b556cfcbf040afc = __wbg_getAll_6b556cfcbf040afc; -exports.__wbg_getAll_86c18743042fe4ca = __wbg_getAll_86c18743042fe4ca; -exports.__wbg_getAll_edf30bc7f595e7ae = __wbg_getAll_edf30bc7f595e7ae; -exports.__wbg_getRandomValues_26c0cdf963e46393 = __wbg_getRandomValues_26c0cdf963e46393; -exports.__wbg_getRandomValues_436a51d0629d84e1 = __wbg_getRandomValues_436a51d0629d84e1; -exports.__wbg_getRandomValues_c44a50d8cfdaebeb = __wbg_getRandomValues_c44a50d8cfdaebeb; -exports.__wbg_getTime_63fb0332e6c4ec17 = __wbg_getTime_63fb0332e6c4ec17; -exports.__wbg_get_4babbbf9303c1945 = __wbg_get_4babbbf9303c1945; -exports.__wbg_get_94b5ec70e1f04bdd = __wbg_get_94b5ec70e1f04bdd; -exports.__wbg_get_971a0c45d172643f = __wbg_get_971a0c45d172643f; -exports.__wbg_get_c0c8f8d7da0c03dd = __wbg_get_c0c8f8d7da0c03dd; -exports.__wbg_get_d173c0308df22d37 = __wbg_get_d173c0308df22d37; -exports.__wbg_get_unchecked_e20b893aeafc3fca = __wbg_get_unchecked_e20b893aeafc3fca; -exports.__wbg_get_with_ref_key_6412cf3094599694 = __wbg_get_with_ref_key_6412cf3094599694; -exports.__wbg_global_94a489d2e6a0c5fd = __wbg_global_94a489d2e6a0c5fd; -exports.__wbg_inboundgroupsession_new = __wbg_inboundgroupsession_new; -exports.__wbg_index_bed5a9f21dfebeea = __wbg_index_bed5a9f21dfebeea; -exports.__wbg_indexedDB_47c354eb27472a00 = __wbg_indexedDB_47c354eb27472a00; -exports.__wbg_indexedDB_9e20c97c033151f3 = __wbg_indexedDB_9e20c97c033151f3; -exports.__wbg_indexedDB_ced363f3de8fb099 = __wbg_indexedDB_ced363f3de8fb099; -exports.__wbg_info_726982aff9befe16 = __wbg_info_726982aff9befe16; -exports.__wbg_info_929f1b00bd4820a9 = __wbg_info_929f1b00bd4820a9; -exports.__wbg_instanceof_ArrayBuffer_993d02d2d254cad1 = __wbg_instanceof_ArrayBuffer_993d02d2d254cad1; -exports.__wbg_instanceof_CursorSys_383984afc1fa1bbc = __wbg_instanceof_CursorSys_383984afc1fa1bbc; -exports.__wbg_instanceof_DomException_55a5af63fefe4042 = __wbg_instanceof_DomException_55a5af63fefe4042; -exports.__wbg_instanceof_Error_61d8a02a0f3383a1 = __wbg_instanceof_Error_61d8a02a0f3383a1; -exports.__wbg_instanceof_IdbCursor_9bd028886fa2ccf0 = __wbg_instanceof_IdbCursor_9bd028886fa2ccf0; -exports.__wbg_instanceof_IdbDatabase_e9dd9f20c51d8d42 = __wbg_instanceof_IdbDatabase_e9dd9f20c51d8d42; -exports.__wbg_instanceof_IdbOpenDbRequest_b913751ffb9239bb = __wbg_instanceof_IdbOpenDbRequest_b913751ffb9239bb; -exports.__wbg_instanceof_IdbRequest_471b050024626dac = __wbg_instanceof_IdbRequest_471b050024626dac; -exports.__wbg_instanceof_Map_9a4d6ead180ae3a9 = __wbg_instanceof_Map_9a4d6ead180ae3a9; -exports.__wbg_instanceof_Promise_e6e764b945c3128a = __wbg_instanceof_Promise_e6e764b945c3128a; -exports.__wbg_instanceof_Uint8Array_f935dbb0aa7cdeed = __wbg_instanceof_Uint8Array_f935dbb0aa7cdeed; -exports.__wbg_invalidtodeviceevent_new = __wbg_invalidtodeviceevent_new; -exports.__wbg_isArray_291e8fbbc73f8b2e = __wbg_isArray_291e8fbbc73f8b2e; -exports.__wbg_isArray_6339f732981044bf = __wbg_isArray_6339f732981044bf; -exports.__wbg_isSafeInteger_f3d6cd19ccfe4512 = __wbg_isSafeInteger_f3d6cd19ccfe4512; -exports.__wbg_item_754b49ed01198c29 = __wbg_item_754b49ed01198c29; -exports.__wbg_iterator_5cebbb86e33c6dd6 = __wbg_iterator_5cebbb86e33c6dd6; -exports.__wbg_key_18fe06a6310bf3fb = __wbg_key_18fe06a6310bf3fb; -exports.__wbg_keysbackuprequest_new = __wbg_keysbackuprequest_new; -exports.__wbg_keysclaimrequest_new = __wbg_keysclaimrequest_new; -exports.__wbg_keysqueryrequest_new = __wbg_keysqueryrequest_new; -exports.__wbg_keysuploadrequest_new = __wbg_keysuploadrequest_new; -exports.__wbg_length_13032799523c5735 = __wbg_length_13032799523c5735; -exports.__wbg_length_36bd29c6848c2144 = __wbg_length_36bd29c6848c2144; -exports.__wbg_length_ecfa2c63d3d0d82c = __wbg_length_ecfa2c63d3d0d82c; -exports.__wbg_lowerBound_66a1695f45ef6c88 = __wbg_lowerBound_66a1695f45ef6c88; -exports.__wbg_maybesignature_new = __wbg_maybesignature_new; -exports.__wbg_megolmdecryptionerror_new = __wbg_megolmdecryptionerror_new; -exports.__wbg_message_88eda073e68b1d26 = __wbg_message_88eda073e68b1d26; -exports.__wbg_message_c141d5e68716b595 = __wbg_message_c141d5e68716b595; -exports.__wbg_msCrypto_bd5a034af96bcba6 = __wbg_msCrypto_bd5a034af96bcba6; -exports.__wbg_name_facbed56940f0fec = __wbg_name_facbed56940f0fec; -exports.__wbg_new_116be93542d39019 = __wbg_new_116be93542d39019; -exports.__wbg_new_227d7c05414eb861 = __wbg_new_227d7c05414eb861; -exports.__wbg_new_358857d90afd5a2d = __wbg_new_358857d90afd5a2d; -exports.__wbg_new_418fb92a013d5930 = __wbg_new_418fb92a013d5930; -exports.__wbg_new_77cc4f4f472aeb81 = __wbg_new_77cc4f4f472aeb81; -exports.__wbg_new_cdf041679ded4c5f = __wbg_new_cdf041679ded4c5f; -exports.__wbg_new_d29ccbc1854174b3 = __wbg_new_d29ccbc1854174b3; -exports.__wbg_new_ebe3e0f6837f0879 = __wbg_new_ebe3e0f6837f0879; -exports.__wbg_new_f9d6489212f3b2b3 = __wbg_new_f9d6489212f3b2b3; -exports.__wbg_new_from_slice_3eea173078478cfe = __wbg_new_from_slice_3eea173078478cfe; -exports.__wbg_new_typed_cceaf62d8d95e9f2 = __wbg_new_typed_cceaf62d8d95e9f2; -exports.__wbg_new_with_length_3ffc1c56427c525c = __wbg_new_with_length_3ffc1c56427c525c; -exports.__wbg_new_with_length_5d351ffdb6e3397d = __wbg_new_with_length_5d351ffdb6e3397d; -exports.__wbg_next_42cf16ee0dafc9e2 = __wbg_next_42cf16ee0dafc9e2; -exports.__wbg_next_8f26b64fa5e9f64b = __wbg_next_8f26b64fa5e9f64b; -exports.__wbg_node_84ea875411254db1 = __wbg_node_84ea875411254db1; -exports.__wbg_now_8b265300afd5f2b9 = __wbg_now_8b265300afd5f2b9; -exports.__wbg_now_e7c6795a7f81e10f = __wbg_now_e7c6795a7f81e10f; -exports.__wbg_objectStoreNames_94ee5410bc505cae = __wbg_objectStoreNames_94ee5410bc505cae; -exports.__wbg_objectStore_222b7add2b5c2770 = __wbg_objectStore_222b7add2b5c2770; -exports.__wbg_oldVersion_92fccbad82f5635a = __wbg_oldVersion_92fccbad82f5635a; -exports.__wbg_olmmachine_new = __wbg_olmmachine_new; -exports.__wbg_openCursor_1015e5f363cc8494 = __wbg_openCursor_1015e5f363cc8494; -exports.__wbg_openCursor_6dd512fe9cbf9f67 = __wbg_openCursor_6dd512fe9cbf9f67; -exports.__wbg_openCursor_f34b182699875701 = __wbg_openCursor_f34b182699875701; -exports.__wbg_open_66c8b00ee562451f = __wbg_open_66c8b00ee562451f; -exports.__wbg_open_c5ecda93515ce190 = __wbg_open_c5ecda93515ce190; -exports.__wbg_otheruseridentity_new = __wbg_otheruseridentity_new; -exports.__wbg_ownuseridentity_new = __wbg_ownuseridentity_new; -exports.__wbg_parse_1cc93481b0865939 = __wbg_parse_1cc93481b0865939; -exports.__wbg_performance_3fcf6e32a7e1ed0a = __wbg_performance_3fcf6e32a7e1ed0a; -exports.__wbg_pickledinboundgroupsession_unwrap = __wbg_pickledinboundgroupsession_unwrap; -exports.__wbg_pickledsession_unwrap = __wbg_pickledsession_unwrap; -exports.__wbg_plaintexttodeviceevent_new = __wbg_plaintexttodeviceevent_new; -exports.__wbg_process_44c7a14e11e9f69e = __wbg_process_44c7a14e11e9f69e; -exports.__wbg_prototypesetcall_8798824fd302dd72 = __wbg_prototypesetcall_8798824fd302dd72; -exports.__wbg_prototypesetcall_de8e0d9553586985 = __wbg_prototypesetcall_de8e0d9553586985; -exports.__wbg_push_adb0107829f02d75 = __wbg_push_adb0107829f02d75; -exports.__wbg_put_5e0ae8c80bb952a7 = __wbg_put_5e0ae8c80bb952a7; -exports.__wbg_putdehydrateddevicerequest_new = __wbg_putdehydrateddevicerequest_new; -exports.__wbg_qr_new = __wbg_qr_new; -exports.__wbg_queueMicrotask_ac694eae12e92dfb = __wbg_queueMicrotask_ac694eae12e92dfb; -exports.__wbg_queueMicrotask_be5fe34a8f4cad4d = __wbg_queueMicrotask_be5fe34a8f4cad4d; -exports.__wbg_randomFillSync_6c25eac9869eb53c = __wbg_randomFillSync_6c25eac9869eb53c; -exports.__wbg_readyState_599831d0754935af = __wbg_readyState_599831d0754935af; -exports.__wbg_rehydrateddevice_new = __wbg_rehydrateddevice_new; -exports.__wbg_request_64abeba15a72c084 = __wbg_request_64abeba15a72c084; -exports.__wbg_request_72a78988f2edecad = __wbg_request_72a78988f2edecad; -exports.__wbg_require_b4edbdcf3e2a1ef0 = __wbg_require_b4edbdcf3e2a1ef0; -exports.__wbg_resolve_020f95d838c6ef25 = __wbg_resolve_020f95d838c6ef25; -exports.__wbg_result_0501bea148306f01 = __wbg_result_0501bea148306f01; -exports.__wbg_roomid_unwrap = __wbg_roomid_unwrap; -exports.__wbg_roomkeycounts_new = __wbg_roomkeycounts_new; -exports.__wbg_roomkeyimportresult_new = __wbg_roomkeyimportresult_new; -exports.__wbg_roomkeyinfo_new = __wbg_roomkeyinfo_new; -exports.__wbg_roomkeywithheldinfo_new = __wbg_roomkeywithheldinfo_new; -exports.__wbg_roommessagerequest_new = __wbg_roommessagerequest_new; -exports.__wbg_roompendingkeybundledetails_new = __wbg_roompendingkeybundledetails_new; -exports.__wbg_roomsettings_new = __wbg_roomsettings_new; -exports.__wbg_sas_new = __wbg_sas_new; -exports.__wbg_secretsbundle_new = __wbg_secretsbundle_new; -exports.__wbg_setTimeout_56bcdccbad22fd44 = __wbg_setTimeout_56bcdccbad22fd44; -exports.__wbg_set_014226dfeca53178 = __wbg_set_014226dfeca53178; -exports.__wbg_set_5c15d3c5973de97a = __wbg_set_5c15d3c5973de97a; -exports.__wbg_set_6be42768c690e380 = __wbg_set_6be42768c690e380; -exports.__wbg_set_a80955eb93b145c6 = __wbg_set_a80955eb93b145c6; -exports.__wbg_set_onabort_fda794cb1089d6b5 = __wbg_set_onabort_fda794cb1089d6b5; -exports.__wbg_set_oncomplete_ff31bdacaa1b3558 = __wbg_set_oncomplete_ff31bdacaa1b3558; -exports.__wbg_set_onerror_3dff0f2abceea5e9 = __wbg_set_onerror_3dff0f2abceea5e9; -exports.__wbg_set_onerror_41278ace6abe3973 = __wbg_set_onerror_41278ace6abe3973; -exports.__wbg_set_onsuccess_86d76d6974cd57e4 = __wbg_set_onsuccess_86d76d6974cd57e4; -exports.__wbg_set_onupgradeneeded_79b60102909f4a5e = __wbg_set_onupgradeneeded_79b60102909f4a5e; -exports.__wbg_set_unique_c03185d3bf563306 = __wbg_set_unique_c03185d3bf563306; -exports.__wbg_set_wasm = __wbg_set_wasm; -exports.__wbg_signatures_new = __wbg_signatures_new; -exports.__wbg_signatureuploadrequest_new = __wbg_signatureuploadrequest_new; -exports.__wbg_signatureverification_new = __wbg_signatureverification_new; -exports.__wbg_stack_3b0d974bbf31e44f = __wbg_stack_3b0d974bbf31e44f; -exports.__wbg_static_accessor_GLOBAL_THIS_466428f93b4eaa76 = __wbg_static_accessor_GLOBAL_THIS_466428f93b4eaa76; -exports.__wbg_static_accessor_GLOBAL_c7aea38d4de089bc = __wbg_static_accessor_GLOBAL_c7aea38d4de089bc; -exports.__wbg_static_accessor_SELF_42d4fae05e59267a = __wbg_static_accessor_SELF_42d4fae05e59267a; -exports.__wbg_static_accessor_WINDOW_e0db14a0eba6a812 = __wbg_static_accessor_WINDOW_e0db14a0eba6a812; -exports.__wbg_storedroomkeybundledata_new = __wbg_storedroomkeybundledata_new; -exports.__wbg_storehandle_new = __wbg_storehandle_new; -exports.__wbg_stringify_f93a4ebae9231922 = __wbg_stringify_f93a4ebae9231922; -exports.__wbg_subarray_a4cc58201c7359fd = __wbg_subarray_a4cc58201c7359fd; -exports.__wbg_target_13424fe1cdc436ac = __wbg_target_13424fe1cdc436ac; -exports.__wbg_then_7026b513a94278a8 = __wbg_then_7026b513a94278a8; -exports.__wbg_then_72819b8d4e081fb5 = __wbg_then_72819b8d4e081fb5; -exports.__wbg_toString_2f0b0aec069cb718 = __wbg_toString_2f0b0aec069cb718; -exports.__wbg_todevicerequest_new = __wbg_todevicerequest_new; -exports.__wbg_transaction_0458565e8cdfb620 = __wbg_transaction_0458565e8cdfb620; -exports.__wbg_transaction_4c999693e6e601bf = __wbg_transaction_4c999693e6e601bf; -exports.__wbg_transaction_728366e915610cb0 = __wbg_transaction_728366e915610cb0; -exports.__wbg_transaction_77d93778cbec28c3 = __wbg_transaction_77d93778cbec28c3; -exports.__wbg_update_df04b6b83954c5a0 = __wbg_update_df04b6b83954c5a0; -exports.__wbg_upperBound_916ed065b0d6fe6c = __wbg_upperBound_916ed065b0d6fe6c; -exports.__wbg_userdevices_new = __wbg_userdevices_new; -exports.__wbg_userid_new = __wbg_userid_new; -exports.__wbg_userid_unwrap = __wbg_userid_unwrap; -exports.__wbg_utdtodeviceevent_new = __wbg_utdtodeviceevent_new; -exports.__wbg_value_1e2369fab29b420e = __wbg_value_1e2369fab29b420e; -exports.__wbg_value_496e02446340ae74 = __wbg_value_496e02446340ae74; -exports.__wbg_values_d512097b1a1a9459 = __wbg_values_d512097b1a1a9459; -exports.__wbg_verificationrequest_new = __wbg_verificationrequest_new; -exports.__wbg_version_26237923fff15d6e = __wbg_version_26237923fff15d6e; -exports.__wbg_versions_276b2795b1c6a219 = __wbg_versions_276b2795b1c6a219; -exports.__wbg_warn_917d7f727ab78481 = __wbg_warn_917d7f727ab78481; -exports.__wbg_warn_b62de6508e8608cc = __wbg_warn_b62de6508e8608cc; -exports.__wbindgen_cast_0000000000000001 = __wbindgen_cast_0000000000000001; -exports.__wbindgen_cast_0000000000000002 = __wbindgen_cast_0000000000000002; -exports.__wbindgen_cast_0000000000000003 = __wbindgen_cast_0000000000000003; -exports.__wbindgen_cast_0000000000000004 = __wbindgen_cast_0000000000000004; -exports.__wbindgen_cast_0000000000000005 = __wbindgen_cast_0000000000000005; -exports.__wbindgen_cast_0000000000000006 = __wbindgen_cast_0000000000000006; -exports.__wbindgen_cast_0000000000000007 = __wbindgen_cast_0000000000000007; -exports.__wbindgen_cast_0000000000000008 = __wbindgen_cast_0000000000000008; -exports.__wbindgen_cast_0000000000000009 = __wbindgen_cast_0000000000000009; -exports.__wbindgen_cast_000000000000000a = __wbindgen_cast_000000000000000a; -exports.__wbindgen_init_externref_table = __wbindgen_init_externref_table; -exports.getVersions = getVersions; -exports.start = start; -/** - * A type to encrypt and to decrypt anything that can fit in an - * `Uint8Array`, usually big buffer. - */ -class Attachment { - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - AttachmentFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_attachment_free(ptr, 0); - } - /** - * Decrypt an `EncryptedAttachment`. - * - * The encrypted attachment can be created manually, or from the - * `encrypt` method. - * - * **Warning**: The encrypted attachment can be used only - * **once**! The encrypted data will still be present, but the - * media encryption info (which contain secrets) will be - * destroyed. It is still possible to get a JSON-encoded backup - * by calling `EncryptedAttachment.mediaEncryptionInfo`. - * @param {EncryptedAttachment} attachment - * @returns {Uint8Array} - */ - static decrypt(attachment) { - _assertClass(attachment, EncryptedAttachment); - const ret = wasm.attachment_decrypt(attachment.__wbg_ptr); - if (ret[3]) { - throw takeFromExternrefTable0(ret[2]); - } - var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - return v1; - } - /** - * Encrypt the content of the `Uint8Array`. - * - * It produces an `EncryptedAttachment`, which can be used to - * retrieve the media encryption information, or the encrypted - * data. - * @param {Uint8Array} array - * @returns {EncryptedAttachment} - */ - static encrypt(array) { - const ptr0 = passArray8ToWasm0(array, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.attachment_encrypt(ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return EncryptedAttachment.__wrap(ret[0]); - } -} -exports.Attachment = Attachment; -if (Symbol.dispose) Attachment.prototype[Symbol.dispose] = Attachment.prototype.free; - -/** - * The private part of the backup key, the one used for recovery. - */ -class BackupDecryptionKey { - static __wrap(ptr) { - const obj = Object.create(BackupDecryptionKey.prototype); - obj.__wbg_ptr = ptr; - BackupDecryptionKeyFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - BackupDecryptionKeyFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_backupdecryptionkey_free(ptr, 0); - } - /** - * Create a new random [`BackupDecryptionKey`]. - * @returns {BackupDecryptionKey} - */ - static createRandomKey() { - const ret = wasm.backupdecryptionkey_createRandomKey(); - return BackupDecryptionKey.__wrap(ret); - } - /** - * Try to decrypt a message that was encrypted using the public part of the - * backup key. - * @param {string} ephemeral_key - * @param {string} mac - * @param {string} ciphertext - * @returns {string} - */ - decryptV1(ephemeral_key, mac, ciphertext) { - let deferred5_0; - let deferred5_1; - try { - const ptr0 = passStringToWasm0(ephemeral_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(mac, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(ciphertext, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ret = wasm.backupdecryptionkey_decryptV1(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2); - var ptr4 = ret[0]; - var len4 = ret[1]; - if (ret[3]) { - ptr4 = 0; - len4 = 0; - throw takeFromExternrefTable0(ret[2]); - } - deferred5_0 = ptr4; - deferred5_1 = len4; - return getStringFromWasm0(ptr4, len4); - } finally { - wasm.__wbindgen_free(deferred5_0, deferred5_1, 1); - } - } - /** - * Try to create a [`BackupDecryptionKey`] from a base 64 encoded string. - * @param {string} key - * @returns {BackupDecryptionKey} - */ - static fromBase64(key) { - const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.backupdecryptionkey_fromBase64(ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return BackupDecryptionKey.__wrap(ret[0]); - } - /** - * Get the public part of the backup key. - * @returns {MegolmV1BackupKey} - */ - get megolmV1PublicKey() { - const ret = wasm.backupdecryptionkey_megolmV1PublicKey(this.__wbg_ptr); - return MegolmV1BackupKey.__wrap(ret); - } - /** - * Convert the backup decryption key to a base 64 encoded string. - * @returns {string} - */ - toBase64() { - const ret = wasm.backupdecryptionkey_toBase64(this.__wbg_ptr); - return ret; - } -} -exports.BackupDecryptionKey = BackupDecryptionKey; -if (Symbol.dispose) BackupDecryptionKey.prototype[Symbol.dispose] = BackupDecryptionKey.prototype.free; - -/** - * Stored versions of the backup keys. - */ -class BackupKeys { - static __wrap(ptr) { - const obj = Object.create(BackupKeys.prototype); - obj.__wbg_ptr = ptr; - BackupKeysFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - BackupKeysFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_backupkeys_free(ptr, 0); - } - /** - * The key used to decrypt backed up room keys, encoded as base64 - * - * @deprecated Use `BackupKeys.decryptionKey.toBase64()` - * @returns {string | undefined} - */ - get decryptionKeyBase64() { - const ret = wasm.backupkeys_decryptionKeyBase64(this.__wbg_ptr); - return ret; - } - /** - * The version that we are using for backups. - * @returns {string | undefined} - */ - get backupVersion() { - const ret = wasm.__wbg_get_backupkeys_backupVersion(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * The key used to decrypt backed up room keys - * @returns {BackupDecryptionKey | undefined} - */ - get decryptionKey() { - const ret = wasm.__wbg_get_backupkeys_decryptionKey(this.__wbg_ptr); - return ret === 0 ? undefined : BackupDecryptionKey.__wrap(ret); - } - /** - * The version that we are using for backups. - * @param {string | null} [arg0] - */ - set backupVersion(arg0) { - var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_backupkeys_backupVersion(this.__wbg_ptr, ptr0, len0); - } - /** - * The key used to decrypt backed up room keys - * @param {BackupDecryptionKey | null} [arg0] - */ - set decryptionKey(arg0) { - let ptr0 = 0; - if (!isLikeNone(arg0)) { - _assertClass(arg0, BackupDecryptionKey); - ptr0 = arg0.__destroy_into_raw(); - } - wasm.__wbg_set_backupkeys_decryptionKey(this.__wbg_ptr, ptr0); - } -} -exports.BackupKeys = BackupKeys; -if (Symbol.dispose) BackupKeys.prototype[Symbol.dispose] = BackupKeys.prototype.free; - -/** - * The backup-specific parts of a secrets bundle. - */ -class BackupSecretsBundle { - static __wrap(ptr) { - const obj = Object.create(BackupSecretsBundle.prototype); - obj.__wbg_ptr = ptr; - BackupSecretsBundleFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - BackupSecretsBundleFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_backupsecretsbundle_free(ptr, 0); - } - /** - * The backup version which this backup decryption key is used with. - * @returns {string} - */ - get backup_version() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_backupsecretsbundle_backup_version(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The backup decryption key, encoded as unpadded base64. - * @returns {string} - */ - get key() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_backupsecretsbundle_key(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The backup version which this backup decryption key is used with. - * @param {string} arg0 - */ - set backup_version(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_backupsecretsbundle_backup_version(this.__wbg_ptr, ptr0, len0); - } - /** - * The backup decryption key, encoded as unpadded base64. - * @param {string} arg0 - */ - set key(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_backupsecretsbundle_key(this.__wbg_ptr, ptr0, len0); - } -} -exports.BackupSecretsBundle = BackupSecretsBundle; -if (Symbol.dispose) BackupSecretsBundle.prototype[Symbol.dispose] = BackupSecretsBundle.prototype.free; - -/** - * The base64-encoded variant of a {@link PkMessage}. - * - * This can be useful if the encrypted message should be put into JSON. - */ -class Base64EncodedPkMessage { - static __wrap(ptr) { - const obj = Object.create(Base64EncodedPkMessage.prototype); - obj.__wbg_ptr = ptr; - Base64EncodedPkMessageFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - Base64EncodedPkMessageFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_base64encodedpkmessage_free(ptr, 0); - } - /** - * Creates a new base64-encoded encrypted message from its parts. - * @param {string} ciphertext - * @param {string} mac - * @param {string} ephemeral_key - */ - constructor(ciphertext, mac, ephemeral_key) { - const ptr0 = passStringToWasm0(ciphertext, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(mac, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(ephemeral_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ret = wasm.base64encodedpkmessage_new(ptr0, len0, ptr1, len1, ptr2, len2); - this.__wbg_ptr = ret; - Base64EncodedPkMessageFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * The base64-encoded ciphertext. - * @returns {string} - */ - get ciphertext() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_base64encodedpkmessage_ciphertext(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The base64-encoded ephemeral public key. - * @returns {string} - */ - get ephemeralKey() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_base64encodedpkmessage_ephemeralKey(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The base64-encoded message authentication code (MAC). - * @returns {string} - */ - get mac() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_base64encodedpkmessage_mac(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The base64-encoded ciphertext. - * @param {string} arg0 - */ - set ciphertext(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_base64encodedpkmessage_ciphertext(this.__wbg_ptr, ptr0, len0); - } - /** - * The base64-encoded ephemeral public key. - * @param {string} arg0 - */ - set ephemeralKey(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_base64encodedpkmessage_ephemeralKey(this.__wbg_ptr, ptr0, len0); - } - /** - * The base64-encoded message authentication code (MAC). - * @param {string} arg0 - */ - set mac(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_base64encodedpkmessage_mac(this.__wbg_ptr, ptr0, len0); - } -} -exports.Base64EncodedPkMessage = Base64EncodedPkMessage; -if (Symbol.dispose) Base64EncodedPkMessage.prototype[Symbol.dispose] = Base64EncodedPkMessage.prototype.free; - -/** - * The base dataset that is important to migrate to the Rust SDK. - * - * Can be imported into the rust store with {@link Migration::migrateBaseData}. - */ -class BaseMigrationData { - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - BaseMigrationDataFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_basemigrationdata_free(ptr, 0); - } - /** - * Create a new `BaseMigrationData` with default values. - */ - constructor() { - const ret = wasm.basemigrationdata_new(); - this.__wbg_ptr = ret; - BaseMigrationDataFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * The backup recovery key, as a base64-encoded string. - * @returns {string | undefined} - */ - get backupRecoveryKey() { - const ret = wasm.__wbg_get_basemigrationdata_backupRecoveryKey(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * The backup version that is currently active. - * @returns {string | undefined} - */ - get backupVersion() { - const ret = wasm.__wbg_get_basemigrationdata_backupVersion(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * The device ID of the account owner. - * @returns {DeviceId | undefined} - */ - get deviceId() { - const ret = wasm.__wbg_get_basemigrationdata_deviceId(this.__wbg_ptr); - return ret === 0 ? undefined : DeviceId.__wrap(ret); - } - /** - * The pickle string holding the Olm Account, as returned by - * `olm_pickle_account` in libolm. - * @returns {string} - */ - get pickledAccount() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_basemigrationdata_pickledAccount(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The private, base64-encoded, master cross-signing key. - * @returns {string | undefined} - */ - get privateCrossSigningMasterKey() { - const ret = wasm.__wbg_get_basemigrationdata_privateCrossSigningMasterKey(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * The private, base64-encoded, self-signing key. - * @returns {string | undefined} - */ - get privateCrossSigningSelfSigningKey() { - const ret = wasm.__wbg_get_basemigrationdata_privateCrossSigningSelfSigningKey(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * The private, base64-encoded, user-signing key. - * @returns {string | undefined} - */ - get privateCrossSigningUserSigningKey() { - const ret = wasm.__wbg_get_basemigrationdata_privateCrossSigningUserSigningKey(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * The user id of the account owner. - * @returns {UserId | undefined} - */ - get userId() { - const ret = wasm.__wbg_get_basemigrationdata_userId(this.__wbg_ptr); - return ret === 0 ? undefined : UserId.__wrap(ret); - } - /** - * The backup recovery key, as a base64-encoded string. - * @param {string | null} [arg0] - */ - set backupRecoveryKey(arg0) { - var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_basemigrationdata_backupRecoveryKey(this.__wbg_ptr, ptr0, len0); - } - /** - * The backup version that is currently active. - * @param {string | null} [arg0] - */ - set backupVersion(arg0) { - var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_basemigrationdata_backupVersion(this.__wbg_ptr, ptr0, len0); - } - /** - * The device ID of the account owner. - * @param {DeviceId | null} [arg0] - */ - set deviceId(arg0) { - let ptr0 = 0; - if (!isLikeNone(arg0)) { - _assertClass(arg0, DeviceId); - ptr0 = arg0.__destroy_into_raw(); - } - wasm.__wbg_set_basemigrationdata_deviceId(this.__wbg_ptr, ptr0); - } - /** - * The pickle string holding the Olm Account, as returned by - * `olm_pickle_account` in libolm. - * @param {string} arg0 - */ - set pickledAccount(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_basemigrationdata_pickledAccount(this.__wbg_ptr, ptr0, len0); - } - /** - * The private, base64-encoded, master cross-signing key. - * @param {string | null} [arg0] - */ - set privateCrossSigningMasterKey(arg0) { - var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_basemigrationdata_privateCrossSigningMasterKey(this.__wbg_ptr, ptr0, len0); - } - /** - * The private, base64-encoded, self-signing key. - * @param {string | null} [arg0] - */ - set privateCrossSigningSelfSigningKey(arg0) { - var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_basemigrationdata_privateCrossSigningSelfSigningKey(this.__wbg_ptr, ptr0, len0); - } - /** - * The private, base64-encoded, user-signing key. - * @param {string | null} [arg0] - */ - set privateCrossSigningUserSigningKey(arg0) { - var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_basemigrationdata_privateCrossSigningUserSigningKey(this.__wbg_ptr, ptr0, len0); - } - /** - * The user id of the account owner. - * @param {UserId | null} [arg0] - */ - set userId(arg0) { - let ptr0 = 0; - if (!isLikeNone(arg0)) { - _assertClass(arg0, UserId); - ptr0 = arg0.__destroy_into_raw(); - } - wasm.__wbg_set_basemigrationdata_userId(this.__wbg_ptr, ptr0); - } -} -exports.BaseMigrationData = BaseMigrationData; -if (Symbol.dispose) BaseMigrationData.prototype[Symbol.dispose] = BaseMigrationData.prototype.free; - -/** - * Information about the cancellation of a verification request or - * verification flow. - */ -class CancelInfo { - static __wrap(ptr) { - const obj = Object.create(CancelInfo.prototype); - obj.__wbg_ptr = ptr; - CancelInfoFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - CancelInfoFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_cancelinfo_free(ptr, 0); - } - /** - * Get the `code` (e.g. `m.user`) that was used to cancel the - * verification. - * @returns {string} - */ - cancelCode() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.cancelinfo_cancelCode(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Was the verification cancelled by us? - * @returns {boolean} - */ - cancelledbyUs() { - const ret = wasm.cancelinfo_cancelledbyUs(this.__wbg_ptr); - return ret !== 0; - } - /** - * Get the human readable reason of the cancellation. - * @returns {string} - */ - reason() { - const ret = wasm.cancelinfo_reason(this.__wbg_ptr); - return ret; - } -} -exports.CancelInfo = CancelInfo; -if (Symbol.dispose) CancelInfo.prototype[Symbol.dispose] = CancelInfo.prototype.free; - -/** - * A check code that can be used to confirm that two {@link EstablishedEcies} - * objects share the same secret. This is supposed to be shared out-of-band to - * protect against active Man-in-the-middle (MITM) attacks. - * - * Since the initiator device can always tell whether a MITM attack is in - * progress after channel establishment, this code technically carries only a - * single bit of information, representing whether the initiator has determined - * that the channel is "secure" or "not secure". - * - * However, given this will need to be interactively confirmed by the user, - * there is risk that the user would confirm the dialogue without paying - * attention to its content. By expanding this single bit into a deterministic - * two-digit check code, the user is forced to pay more attention by having to - * enter it instead of just clicking through a dialogue. - */ -class CheckCode { - static __wrap(ptr) { - const obj = Object.create(CheckCode.prototype); - obj.__wbg_ptr = ptr; - CheckCodeFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - CheckCodeFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_checkcode_free(ptr, 0); - } - /** - * Convert the check code to an array of two bytes. - * - * The bytes can be converted to a more user-friendly representation. - * {@link to_digit} and {@link toDigitNoLeadingZero} convert the bytes to a - * two-digit number. - * @returns {Uint8Array} - */ - as_bytes() { - const ret = wasm.checkcode_as_bytes(this.__wbg_ptr); - var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - return v1; - } - /** - * Convert the check code to two base-10 numbers, with no leading zero. - * - * This corresponds to the way the digits are defined in - * {@link https://github.com/matrix-org/matrix-spec-proposals/pull/4388 MSC4388}. - * @returns {number} - */ - toDigitNoLeadingZero() { - const ret = wasm.checkcode_toDigitNoLeadingZero(this.__wbg_ptr); - return ret; - } - /** - * Convert the check code to two base-10 numbers, allowing a leading zero. - * - * This corresponds to the way the digits were used in the initial version - * of {@link https://github.com/matrix-org/matrix-spec-proposals/pull/4108 MSC4108}. - * See {@link toDigitNoLeadingZero} for a more recent implementation. - * - * The number should be displayed with a leading 0 in case the first digit - * is a 0. - * @returns {number} - */ - to_digit() { - const ret = wasm.checkcode_to_digit(this.__wbg_ptr); - return ret; - } -} -exports.CheckCode = CheckCode; -if (Symbol.dispose) CheckCode.prototype[Symbol.dispose] = CheckCode.prototype.free; - -/** - * Strategy to collect the devices that should receive room keys for the - * current discussion. - */ -class CollectStrategy { - static __wrap(ptr) { - const obj = Object.create(CollectStrategy.prototype); - obj.__wbg_ptr = ptr; - CollectStrategyFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - CollectStrategyFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_collectstrategy_free(ptr, 0); - } - /** - * Share with all (unblacklisted) devices. - * @returns {CollectStrategy} - */ - static allDevices() { - const ret = wasm.collectstrategy_allDevices(); - return CollectStrategy.__wrap(ret); - } - /** - * Device based sharing strategy. - * - * @deprecated: use one of {@link allDevices}, {@link - * errorOnUnverifiedUserProblem} or {@link onlyTrustedDevices}. - * @param {boolean} only_allow_trusted_devices - * @param {boolean} error_on_verified_user_problem - * @returns {CollectStrategy} - */ - static deviceBasedStrategy(only_allow_trusted_devices, error_on_verified_user_problem) { - const ret = wasm.collectstrategy_deviceBasedStrategy(only_allow_trusted_devices, error_on_verified_user_problem); - return CollectStrategy.__wrap(ret); - } - /** - * Tests for equality between two [`CollectStrategy`]s. - * @param {CollectStrategy} other - * @returns {boolean} - */ - eq(other) { - _assertClass(other, CollectStrategy); - const ret = wasm.collectstrategy_eq(this.__wbg_ptr, other.__wbg_ptr); - return ret !== 0; - } - /** - * Share with all devices, except that errors for *verified* users cause - * sharing to fail with an error. - * - * In this strategy, if a verified user has an unsigned device, or - * a verified user has replaced their identity, key - * sharing will fail with an error. - * - * Otherwise, keys are shared with unsigned devices as normal. - * - * Once the problematic devices are blacklisted or whitelisted the - * caller can try sharing a second time. - * @returns {CollectStrategy} - */ - static errorOnUnverifiedUserProblem() { - const ret = wasm.collectstrategy_errorOnUnverifiedUserProblem(); - return CollectStrategy.__wrap(ret); - } - /** - * Share based on identity. Only distribute to devices signed by their - * owner. If a user has no published identity he will not receive - * any room keys. - * @returns {CollectStrategy} - */ - static identityBasedStrategy() { - const ret = wasm.collectstrategy_identityBasedStrategy(); - return CollectStrategy.__wrap(ret); - } - /** - * Only share keys with devices that we "trust". A device is trusted if any - * of the following is true: - * - It was manually marked as trusted. - * - It was marked as verified via interactive verification. - * - It is signed by its owner identity, and this identity has been - * trusted via interactive verification. - * - It is the current own device of the user. - * @returns {CollectStrategy} - */ - static onlyTrustedDevices() { - const ret = wasm.collectstrategy_onlyTrustedDevices(); - return CollectStrategy.__wrap(ret); - } -} -exports.CollectStrategy = CollectStrategy; -if (Symbol.dispose) CollectStrategy.prototype[Symbol.dispose] = CollectStrategy.prototype.free; - -/** - * A set of requests to be executed when bootstrapping cross-signing using - * {@link OlmMachine.bootstrapCrossSigning}. - */ -class CrossSigningBootstrapRequests { - static __wrap(ptr) { - const obj = Object.create(CrossSigningBootstrapRequests.prototype); - obj.__wbg_ptr = ptr; - CrossSigningBootstrapRequestsFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - CrossSigningBootstrapRequestsFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_crosssigningbootstraprequests_free(ptr, 0); - } - /** - * An optional request to upload a device key. - * - * This will either be `undefined`, or an "outgoing request" as returned by - * {@link OlmMachine.outgoingRequests}. - * - * If it is defined, the request should be sent first, and the result sent - * back with {@link OlmMachine.markRequestAsSent}. - * @returns {any} - */ - get uploadKeysRequest() { - const ret = wasm.__wbg_get_crosssigningbootstraprequests_uploadKeysRequest(this.__wbg_ptr); - return ret; - } - /** - * Request to upload key signatures, including those for the cross-signing - * keys, and maybe some for the optional uploaded key too. - * - * Should be sent last. - * @returns {SignatureUploadRequest} - */ - get uploadSignaturesRequest() { - const ret = wasm.__wbg_get_crosssigningbootstraprequests_uploadSignaturesRequest(this.__wbg_ptr); - return SignatureUploadRequest.__wrap(ret); - } - /** - * Request to upload the cross-signing keys. - * - * Should be sent second. - * @returns {UploadSigningKeysRequest} - */ - get uploadSigningKeysRequest() { - const ret = wasm.__wbg_get_crosssigningbootstraprequests_uploadSigningKeysRequest(this.__wbg_ptr); - return UploadSigningKeysRequest.__wrap(ret); - } -} -exports.CrossSigningBootstrapRequests = CrossSigningBootstrapRequests; -if (Symbol.dispose) CrossSigningBootstrapRequests.prototype[Symbol.dispose] = CrossSigningBootstrapRequests.prototype.free; - -/** - * A struct containing private cross signing keys that can be backed - * up or uploaded to the secret store. - */ -class CrossSigningKeyExport { - static __wrap(ptr) { - const obj = Object.create(CrossSigningKeyExport.prototype); - obj.__wbg_ptr = ptr; - CrossSigningKeyExportFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - CrossSigningKeyExportFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_crosssigningkeyexport_free(ptr, 0); - } - /** - * The seed of the master key encoded as unpadded base64. - * @returns {string | undefined} - */ - get masterKey() { - const ret = wasm.crosssigningkeyexport_masterKey(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * The seed of the self signing key encoded as unpadded base64. - * @returns {string | undefined} - */ - get self_signing_key() { - const ret = wasm.crosssigningkeyexport_self_signing_key(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * The seed of the user signing key encoded as unpadded base64. - * @returns {string | undefined} - */ - get userSigningKey() { - const ret = wasm.crosssigningkeyexport_userSigningKey(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } -} -exports.CrossSigningKeyExport = CrossSigningKeyExport; -if (Symbol.dispose) CrossSigningKeyExport.prototype[Symbol.dispose] = CrossSigningKeyExport.prototype.free; - -/** - * Struct representing the state of our private cross signing keys, - * it shows which private cross signing keys we have locally stored. - */ -class CrossSigningStatus { - static __wrap(ptr) { - const obj = Object.create(CrossSigningStatus.prototype); - obj.__wbg_ptr = ptr; - CrossSigningStatusFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - CrossSigningStatusFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_crosssigningstatus_free(ptr, 0); - } - /** - * Do we have the master key? - * @returns {boolean} - */ - get hasMaster() { - const ret = wasm.crosssigningstatus_hasMaster(this.__wbg_ptr); - return ret !== 0; - } - /** - * Do we have the self signing key? This one is necessary to sign - * our own devices. - * @returns {boolean} - */ - get hasSelfSigning() { - const ret = wasm.crosssigningstatus_hasSelfSigning(this.__wbg_ptr); - return ret !== 0; - } - /** - * Do we have the user signing key? This one is necessary to sign - * other users. - * @returns {boolean} - */ - get hasUserSigning() { - const ret = wasm.crosssigningstatus_hasUserSigning(this.__wbg_ptr); - return ret !== 0; - } -} -exports.CrossSigningStatus = CrossSigningStatus; -if (Symbol.dispose) CrossSigningStatus.prototype[Symbol.dispose] = CrossSigningStatus.prototype.free; - -/** - * A Curve25519 public key. - */ -class Curve25519PublicKey { - static __wrap(ptr) { - const obj = Object.create(Curve25519PublicKey.prototype); - obj.__wbg_ptr = ptr; - Curve25519PublicKeyFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - Curve25519PublicKeyFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_curve25519publickey_free(ptr, 0); - } - /** - * The number of bytes a Curve25519 public key has. - * @returns {number} - */ - get length() { - const ret = wasm.curve25519publickey_length(this.__wbg_ptr); - return ret >>> 0; - } - /** - * Create a new [`Curve25519PublicKey`] from a base64 encoded string. - * @param {string} key - */ - constructor(key) { - const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.curve25519publickey_new(ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - this.__wbg_ptr = ret[0]; - Curve25519PublicKeyFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Serialize an Curve25519 public key to an unpadded base64 - * representation. - * @returns {string} - */ - toBase64() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.curve25519publickey_toBase64(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } -} -exports.Curve25519PublicKey = Curve25519PublicKey; -if (Symbol.dispose) Curve25519PublicKey.prototype[Symbol.dispose] = Curve25519PublicKey.prototype.free; - -/** - * A Curve25519 secret key. - */ -class Curve25519SecretKey { - static __wrap(ptr) { - const obj = Object.create(Curve25519SecretKey.prototype); - obj.__wbg_ptr = ptr; - Curve25519SecretKeyFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - Curve25519SecretKeyFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_curve25519secretkey_free(ptr, 0); - } - /** - * Creates a `Curve25519SecretKey` from a base64-encoded representation of - * the key. - * @param {string} string - * @returns {Curve25519SecretKey} - */ - static fromBase64(string) { - const ptr0 = passStringToWasm0(string, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.curve25519secretkey_fromBase64(ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return Curve25519SecretKey.__wrap(ret[0]); - } - /** - * Creates a `Curve25519SecretKey` from a raw byte slice. - * @param {Uint8Array} slice - * @returns {Curve25519SecretKey} - */ - static fromUint8Array(slice) { - const ptr0 = passArray8ToWasm0(slice, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.curve25519secretkey_fromUint8Array(ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return Curve25519SecretKey.__wrap(ret[0]); - } - /** - * Generates a new random Curve25519 secret key. - * @returns {Curve25519SecretKey} - */ - static new() { - const ret = wasm.curve25519secretkey_new(); - return Curve25519SecretKey.__wrap(ret); - } - /** - * Encodes the secret key into a base64 string. - * @returns {string} - */ - toBase64() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.curve25519secretkey_toBase64(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Converts the secret key into a raw byte vector. - * @returns {Uint8Array} - */ - toUint8Array() { - const ret = wasm.curve25519secretkey_toUint8Array(this.__wbg_ptr); - var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - return v1; - } -} -exports.Curve25519SecretKey = Curve25519SecretKey; -if (Symbol.dispose) Curve25519SecretKey.prototype[Symbol.dispose] = Curve25519SecretKey.prototype.free; - -/** - * A decrypted room event. - */ -class DecryptedRoomEvent { - static __wrap(ptr) { - const obj = Object.create(DecryptedRoomEvent.prototype); - obj.__wbg_ptr = ptr; - DecryptedRoomEventFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - DecryptedRoomEventFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_decryptedroomevent_free(ptr, 0); - } - /** - * If the keys for this message were shared-on-invite as part of an - * [MSC4268] key bundle, the ID of the user who sent us the bundle. - * - * [MSC4268]: https://github.com/matrix-org/matrix-spec-proposals/pull/4268 - * @returns {UserId | undefined} - */ - get forwarder() { - const ret = wasm.decryptedroomevent_forwarder(this.__wbg_ptr); - return ret === 0 ? undefined : UserId.__wrap(ret); - } - /** - * If the keys for this message were shared-on-invite as part of an - * [MSC4268] key bundle, the ID of the device from which this bundle - * was sent. - * - * [MSC4268]: https://github.com/matrix-org/matrix-spec-proposals/pull/4268 - * @returns {DeviceId | undefined} - */ - get forwarderDevice() { - const ret = wasm.decryptedroomevent_forwarderDevice(this.__wbg_ptr); - return ret === 0 ? undefined : DeviceId.__wrap(ret); - } - /** - * Returns an empty array - * - * Previously, this returned the chain of Curve25519 keys through which - * this session was forwarded, via `m.forwarded_room_key` events. - * However, that is not cryptographically reliable, and clients should not - * be using it. - * - * @see https://github.com/matrix-org/matrix-spec/issues/1089 - * @returns {string[]} - */ - get forwardingCurve25519KeyChain() { - const ret = wasm.decryptedroomevent_forwardingCurve25519KeyChain(this.__wbg_ptr); - return ret; - } - /** - * The user ID of the event sender, note this is untrusted data - * unless the `verification_state` is as well trusted. - * @returns {UserId} - */ - get sender() { - const ret = wasm.decryptedroomevent_sender(this.__wbg_ptr); - return UserId.__wrap(ret); - } - /** - * The signing Ed25519 key that have created the megolm key that - * was used to decrypt this session. - * @returns {string | undefined} - */ - get senderClaimedEd25519Key() { - const ret = wasm.decryptedroomevent_senderClaimedEd25519Key(this.__wbg_ptr); - return ret; - } - /** - * The Curve25519 key of the device that created the megolm - * decryption key originally. - * @returns {string} - */ - get senderCurve25519Key() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.decryptedroomevent_senderCurve25519Key(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The device ID of the device that sent us the event, note this - * is untrusted data unless `verification_state` is as well - * trusted. - * @returns {DeviceId | undefined} - */ - get senderDevice() { - const ret = wasm.decryptedroomevent_senderDevice(this.__wbg_ptr); - return ret === 0 ? undefined : DeviceId.__wrap(ret); - } - /** - * The verification state of the device that sent us the event. - * Note this is the state of the device at the time of - * decryption. It may change in the future if a device gets - * verified or deleted. - * @param {boolean} strict - * @returns {ShieldState} - */ - shieldState(strict) { - const ret = wasm.decryptedroomevent_shieldState(this.__wbg_ptr, strict); - return ShieldState.__wrap(ret); - } - /** - * The JSON-encoded decrypted event. - * @returns {string} - */ - get event() { - const ret = wasm.__wbg_get_decryptedroomevent_event(this.__wbg_ptr); - return ret; - } -} -exports.DecryptedRoomEvent = DecryptedRoomEvent; -if (Symbol.dispose) DecryptedRoomEvent.prototype[Symbol.dispose] = DecryptedRoomEvent.prototype.free; - -/** - * Represents an encrypted to-device event, after it has been decrypted. - */ -class DecryptedToDeviceEvent { - static __wrap(ptr) { - const obj = Object.create(DecryptedToDeviceEvent.prototype); - obj.__wbg_ptr = ptr; - DecryptedToDeviceEventFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - DecryptedToDeviceEventFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_decryptedtodeviceevent_free(ptr, 0); - } - /** - * The type of processed to-device event. Always {@link - * ProcessedToDeviceEventType.Decrypted} for this type. - * @returns {ProcessedToDeviceEventType} - */ - get type() { - const ret = wasm.decryptedtodeviceevent_type(this.__wbg_ptr); - return ret; - } - /** - * The encryption information for the event. - * @returns {ToDeviceEncryptionInfo} - */ - get encryptionInfo() { - const ret = wasm.__wbg_get_decryptedtodeviceevent_encryptionInfo(this.__wbg_ptr); - return ToDeviceEncryptionInfo.__wrap(ret); - } - /** - * The decrypted event, as if it had been sent in the clear, encoded as - * JSON. - * - * Typically contains properties `type`, `sender` and `content`. - * - * (For room keys or secrets, some part of the content might have been - * zeroized). - * @returns {string} - */ - get rawEvent() { - const ret = wasm.__wbg_get_decryptedtodeviceevent_rawEvent(this.__wbg_ptr); - return ret; - } -} -exports.DecryptedToDeviceEvent = DecryptedToDeviceEvent; -if (Symbol.dispose) DecryptedToDeviceEvent.prototype[Symbol.dispose] = DecryptedToDeviceEvent.prototype.free; - -/** - * Decryption error codes - * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7} - */ -const DecryptionErrorCode = exports.DecryptionErrorCode = Object.freeze({ - /** - * The room key is not known - */ - MissingRoomKey: 0, - "0": "MissingRoomKey", - /** - * The room key is known but ratcheted - */ - UnknownMessageIndex: 1, - "1": "UnknownMessageIndex", - /** - * Decryption failed because of a mismatch between the identity keys of the - * device we received the room key from and the identity keys recorded in - * the plaintext of the room key to-device message. - */ - MismatchedIdentityKeys: 2, - "2": "MismatchedIdentityKeys", - /** - * We weren't able to link the message back to any known device. - */ - UnknownSenderDevice: 3, - "3": "UnknownSenderDevice", - /** - * The sender device is not cross-signed. - */ - UnsignedSenderDevice: 4, - "4": "UnsignedSenderDevice", - /** - * The sender's identity is unverified, but was previously verified. - */ - SenderIdentityVerificationViolation: 5, - "5": "SenderIdentityVerificationViolation", - /** - * Other failure. - */ - UnableToDecrypt: 6, - "6": "UnableToDecrypt", - /** - * The `sender` field on the event does not match the owner of the device - * that established the Megolm session. - */ - MismatchedSender: 7, - "7": "MismatchedSender" -}); - -/** - * Settings for decrypting messages - */ -class DecryptionSettings { - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - DecryptionSettingsFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_decryptionsettings_free(ptr, 0); - } - /** - * Create a new `DecryptionSettings` with the given trust requirement. - * @param {TrustRequirement} sender_device_trust_requirement - */ - constructor(sender_device_trust_requirement) { - const ret = wasm.decryptionsettings_new(sender_device_trust_requirement); - this.__wbg_ptr = ret; - DecryptionSettingsFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * The trust level required to decrypt the event - * @returns {TrustRequirement} - */ - get sender_device_trust_requirement() { - const ret = wasm.__wbg_get_decryptionsettings_sender_device_trust_requirement(this.__wbg_ptr); - return ret; - } - /** - * The trust level required to decrypt the event - * @param {TrustRequirement} arg0 - */ - set sender_device_trust_requirement(arg0) { - wasm.__wbg_set_decryptionsettings_sender_device_trust_requirement(this.__wbg_ptr, arg0); - } -} -exports.DecryptionSettings = DecryptionSettings; -if (Symbol.dispose) DecryptionSettings.prototype[Symbol.dispose] = DecryptionSettings.prototype.free; - -/** - * A dehydrated device that can be uploaded to the server - */ -class DehydratedDevice { - static __wrap(ptr) { - const obj = Object.create(DehydratedDevice.prototype); - obj.__wbg_ptr = ptr; - DehydratedDeviceFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - DehydratedDeviceFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_dehydrateddevice_free(ptr, 0); - } - /** - * Create the request to upload the dehydrated device - * @param {string} initial_device_display_name - * @param {DehydratedDeviceKey} dehydrated_device_key - * @returns {Promise} - */ - keysForUpload(initial_device_display_name, dehydrated_device_key) { - _assertClass(dehydrated_device_key, DehydratedDeviceKey); - const ret = wasm.dehydrateddevice_keysForUpload(this.__wbg_ptr, initial_device_display_name, dehydrated_device_key.__wbg_ptr); - return ret; - } -} -exports.DehydratedDevice = DehydratedDevice; -if (Symbol.dispose) DehydratedDevice.prototype[Symbol.dispose] = DehydratedDevice.prototype.free; - -/** - * Dehydrated device key - */ -class DehydratedDeviceKey { - static __wrap(ptr) { - const obj = Object.create(DehydratedDeviceKey.prototype); - obj.__wbg_ptr = ptr; - DehydratedDeviceKeyFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - DehydratedDeviceKeyFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_dehydrateddevicekey_free(ptr, 0); - } - /** - * Generates a dehydrated device key from a given array. - * @param {Uint8Array} array - * @returns {DehydratedDeviceKey} - */ - static createKeyFromArray(array) { - const ret = wasm.dehydrateddevicekey_createKeyFromArray(array); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return DehydratedDeviceKey.__wrap(ret[0]); - } - /** - * Generates a new random dehydrated device key. - * @returns {DehydratedDeviceKey} - */ - static createRandomKey() { - const ret = wasm.dehydrateddevicekey_createRandomKey(); - return DehydratedDeviceKey.__wrap(ret); - } - /** - * Convert the dehydrated device key to a base64-encoded string. - * @returns {string} - */ - toBase64() { - const ret = wasm.dehydrateddevicekey_toBase64(this.__wbg_ptr); - return ret; - } -} -exports.DehydratedDeviceKey = DehydratedDeviceKey; -if (Symbol.dispose) DehydratedDeviceKey.prototype[Symbol.dispose] = DehydratedDeviceKey.prototype.free; - -/** - * Struct collecting methods to create and rehydrate dehydrated devices. - */ -class DehydratedDevices { - static __wrap(ptr) { - const obj = Object.create(DehydratedDevices.prototype); - obj.__wbg_ptr = ptr; - DehydratedDevicesFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - DehydratedDevicesFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_dehydrateddevices_free(ptr, 0); - } - /** - * Create a new {@link DehydratedDevice} which can be uploaded to the - * server. - * @returns {Promise} - */ - create() { - const ret = wasm.dehydrateddevices_create(this.__wbg_ptr); - return ret; - } - /** - * Clear the dehydrated device key saved in the crypto store. - * @returns {Promise} - */ - deleteDehydratedDeviceKey() { - const ret = wasm.dehydrateddevices_deleteDehydratedDeviceKey(this.__wbg_ptr); - return ret; - } - /** - * Get the cached dehydrated device key if any. - * - * `None` if the key was not previously cached (via - * {@link DehydratedDevices.saveDehydratedDeviceKey}). - * @returns {Promise} - */ - getDehydratedDeviceKey() { - const ret = wasm.dehydrateddevices_getDehydratedDeviceKey(this.__wbg_ptr); - return ret; - } - /** - * Rehydrate a dehydrated device. - * @param {DehydratedDeviceKey} dehydrated_device_key - * @param {DeviceId} device_id - * @param {string} device_data - * @returns {Promise} - */ - rehydrate(dehydrated_device_key, device_id, device_data) { - _assertClass(dehydrated_device_key, DehydratedDeviceKey); - _assertClass(device_id, DeviceId); - const ptr0 = passStringToWasm0(device_data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.dehydrateddevices_rehydrate(this.__wbg_ptr, dehydrated_device_key.__wbg_ptr, device_id.__wbg_ptr, ptr0, len0); - return ret; - } - /** - * Store the dehydrated device key in the crypto store. - * @param {DehydratedDeviceKey} dehydrated_device_key - * @returns {Promise} - */ - saveDehydratedDeviceKey(dehydrated_device_key) { - _assertClass(dehydrated_device_key, DehydratedDeviceKey); - const ret = wasm.dehydrateddevices_saveDehydratedDeviceKey(this.__wbg_ptr, dehydrated_device_key.__wbg_ptr); - return ret; - } -} -exports.DehydratedDevices = DehydratedDevices; -if (Symbol.dispose) DehydratedDevices.prototype[Symbol.dispose] = DehydratedDevices.prototype.free; - -/** - * A device represents a E2EE capable client of an user. - */ -class Device { - static __wrap(ptr) { - const obj = Object.create(Device.prototype); - obj.__wbg_ptr = ptr; - DeviceFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - DeviceFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_device_free(ptr, 0); - } - /** - * Get the list of algorithms this device supports. - * - * Returns `Array`. - * @returns {EncryptionAlgorithm[]} - */ - get algorithms() { - const ret = wasm.device_algorithms(this.__wbg_ptr); - return ret; - } - /** - * Get the Curve25519 key of the given device. - * @returns {Curve25519PublicKey | undefined} - */ - get curve25519Key() { - const ret = wasm.device_curve25519Key(this.__wbg_ptr); - return ret === 0 ? undefined : Curve25519PublicKey.__wrap(ret); - } - /** - * The unique ID of the device. - * @returns {DeviceId} - */ - get deviceId() { - const ret = wasm.device_deviceId(this.__wbg_ptr); - return DeviceId.__wrap(ret); - } - /** - * Get the human readable name of the device. - * @returns {string | undefined} - */ - get displayName() { - const ret = wasm.device_displayName(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * Get the Ed25519 key of the given device. - * @returns {Ed25519PublicKey | undefined} - */ - get ed25519Key() { - const ret = wasm.device_ed25519Key(this.__wbg_ptr); - return ret === 0 ? undefined : Ed25519PublicKey.__wrap(ret); - } - /** - * Encrypt a to-device message to be sent to this device, using Olm - * encryption. - * - * Prior to calling this method you must ensure that an Olm session is - * available for the target device. This can be done by calling - * {@link OlmMachine.getMissingSessions}. - * - * The caller is responsible for sending the encrypted - * event to the target device. If multiple messages are - * encrypted for the same device using this method they should be sent in - * the same order as they are encrypted. - * - * # Returns - * - * Returns a promise for a JSON string containing the `content` of an - * encrypted event, which be used to create the payload for a - * `/sendToDevice` API. - * @param {string} event_type - * @param {any} content - * @param {CollectStrategy | null} [share_strategy] - * @returns {Promise} - */ - encryptToDeviceEvent(event_type, content, share_strategy) { - const ptr0 = passStringToWasm0(event_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - let ptr1 = 0; - if (!isLikeNone(share_strategy)) { - _assertClass(share_strategy, CollectStrategy); - ptr1 = share_strategy.__destroy_into_raw(); - } - const ret = wasm.device_encryptToDeviceEvent(this.__wbg_ptr, ptr0, len0, content, ptr1); - return ret; - } - /** - * Timestamp representing the first time this device has been seen (in - * milliseconds). - * @returns {bigint} - */ - firstTimeSeen() { - const ret = wasm.device_firstTimeSeen(this.__wbg_ptr); - return BigInt.asUintN(64, ret); - } - /** - * Get the key of the given key algorithm belonging to this device. - * @param {DeviceKeyAlgorithmName} algorithm - * @returns {DeviceKey | undefined} - */ - getKey(algorithm) { - const ret = wasm.device_getKey(this.__wbg_ptr, algorithm); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return ret[0] === 0 ? undefined : DeviceKey.__wrap(ret[0]); - } - /** - * Is the device locally marked as blacklisted? - * - * Blacklisted devices won’t receive any group sessions. - * @returns {boolean} - */ - isBlacklisted() { - const ret = wasm.device_isBlacklisted(this.__wbg_ptr); - return ret !== 0; - } - /** - * Is this device cross-signed by its owner? - * @returns {boolean} - */ - isCrossSignedByOwner() { - const ret = wasm.device_isCrossSignedByOwner(this.__wbg_ptr); - return ret !== 0; - } - /** - * Is this device considered to be verified using cross signing. - * @returns {boolean} - */ - isCrossSigningTrusted() { - const ret = wasm.device_isCrossSigningTrusted(this.__wbg_ptr); - return ret !== 0; - } - /** - * Whether or not the device is a dehydrated device. - * @returns {boolean} - */ - get isDehydrated() { - const ret = wasm.device_isDehydrated(this.__wbg_ptr); - return ret !== 0; - } - /** - * Is the device deleted? - * @returns {boolean} - */ - isDeleted() { - const ret = wasm.device_isDeleted(this.__wbg_ptr); - return ret !== 0; - } - /** - * Is the device locally marked as trusted? - * @returns {boolean} - */ - isLocallyTrusted() { - const ret = wasm.device_isLocallyTrusted(this.__wbg_ptr); - return ret !== 0; - } - /** - * Is this device considered to be verified. - * - * This method returns true if either the `is_locally_trusted` - * method returns `true` or if the `is_cross_signing_trusted` - * method returns `true`. - * @returns {boolean} - */ - isVerified() { - const ret = wasm.device_isVerified(this.__wbg_ptr); - return ret !== 0; - } - /** - * Get a map containing all the device keys. - * @returns {Map} - */ - get keys() { - const ret = wasm.device_keys(this.__wbg_ptr); - return ret; - } - /** - * Get the trust state of the device. - * @returns {LocalTrust} - */ - get localTrustState() { - const ret = wasm.device_localTrustState(this.__wbg_ptr); - return ret; - } - /** - * Request an interactive verification with this device. - * - * Returns a 2-element array `[VerificationRequest, ToDeviceRequest]`. - * @param {VerificationMethod[]} [methods] - * @returns {[VerificationRequest, ToDeviceRequest]} - */ - requestVerification(methods) { - var ptr0 = isLikeNone(methods) ? 0 : passArrayJsValueToWasm0(methods, wasm.__wbindgen_malloc); - var len0 = WASM_VECTOR_LEN; - const ret = wasm.device_requestVerification(this.__wbg_ptr, ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Set the local trust state of the device to the given state. - * - * This won’t affect any cross signing trust state, this only - * sets a flag marking to have the given trust state. - * - * `trust_state` represents the new trust state that should be - * set for the device. - * @param {LocalTrust} local_state - * @returns {Promise} - */ - setLocalTrust(local_state) { - const ret = wasm.device_setLocalTrust(this.__wbg_ptr, local_state); - return ret; - } - /** - * Get a map containing all the device signatures. - * @returns {Signatures} - */ - get signatures() { - const ret = wasm.device_signatures(this.__wbg_ptr); - return Signatures.__wrap(ret); - } - /** - * The user ID of the device owner. - * @returns {UserId} - */ - get userId() { - const ret = wasm.device_userId(this.__wbg_ptr); - return UserId.__wrap(ret); - } - /** - * Mark this device as verified. - * Works only if the device is owned by the current user. - * - * Returns a signature upload request that needs to be sent out. - * @returns {Promise} - */ - verify() { - const ret = wasm.device_verify(this.__wbg_ptr); - return ret; - } -} -exports.Device = Device; -if (Symbol.dispose) Device.prototype[Symbol.dispose] = Device.prototype.free; - -/** - * A Matrix key ID. - * - * Device identifiers in Matrix are completely opaque character - * sequences. This type is provided simply for its semantic value. - */ -class DeviceId { - static __wrap(ptr) { - const obj = Object.create(DeviceId.prototype); - obj.__wbg_ptr = ptr; - DeviceIdFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - DeviceIdFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_deviceid_free(ptr, 0); - } - /** - * Create a new `DeviceId`. - * @param {string} id - */ - constructor(id) { - const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.deviceid_new(ptr0, len0); - this.__wbg_ptr = ret; - DeviceIdFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Return the device ID as a string. - * @returns {string} - */ - toString() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.deviceid_toString(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } -} -exports.DeviceId = DeviceId; -if (Symbol.dispose) DeviceId.prototype[Symbol.dispose] = DeviceId.prototype.free; - -/** - * An enum over the different key types a device can have. - * - * Currently devices have a curve25519 and ed25519 keypair. The keys - * transport format is a base64 encoded string, any unknown key type - * will be left as such a string. - */ -class DeviceKey { - static __wrap(ptr) { - const obj = Object.create(DeviceKey.prototype); - obj.__wbg_ptr = ptr; - DeviceKeyFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - DeviceKeyFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_devicekey_free(ptr, 0); - } - /** - * Get the value associated to the `Curve25519` device key name. - * @returns {Curve25519PublicKey | undefined} - */ - get curve25519() { - const ret = wasm.devicekey_curve25519(this.__wbg_ptr); - return ret === 0 ? undefined : Curve25519PublicKey.__wrap(ret); - } - /** - * Get the value associated to the `Ed25519` device key name. - * @returns {Ed25519PublicKey | undefined} - */ - get ed25519() { - const ret = wasm.devicekey_ed25519(this.__wbg_ptr); - return ret === 0 ? undefined : Ed25519PublicKey.__wrap(ret); - } - /** - * Get the name of the device key. - * @returns {DeviceKeyName} - */ - get name() { - const ret = wasm.devicekey_name(this.__wbg_ptr); - return ret; - } - /** - * Convert the `DeviceKey` into a base64 encoded string. - * @returns {string} - */ - toBase64() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.devicekey_toBase64(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Get the value associated to the `Unknown` device key name. - * @returns {string | undefined} - */ - get unknown() { - const ret = wasm.devicekey_unknown(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } -} -exports.DeviceKey = DeviceKey; -if (Symbol.dispose) DeviceKey.prototype[Symbol.dispose] = DeviceKey.prototype.free; - -/** - * The basic key algorithms in the specification. - */ -class DeviceKeyAlgorithm { - static __wrap(ptr) { - const obj = Object.create(DeviceKeyAlgorithm.prototype); - obj.__wbg_ptr = ptr; - DeviceKeyAlgorithmFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - DeviceKeyAlgorithmFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_devicekeyalgorithm_free(ptr, 0); - } - /** - * Read the device key algorithm's name. If the name is - * `Unknown`, one may be interested by the `to_string` method to - * read the original name. - * @returns {DeviceKeyAlgorithmName} - */ - get name() { - const ret = wasm.devicekeyalgorithm_name(this.__wbg_ptr); - return ret; - } - /** - * Return the device key algorithm as a string. - * @returns {string} - */ - toString() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.devicekeyalgorithm_toString(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } -} -exports.DeviceKeyAlgorithm = DeviceKeyAlgorithm; -if (Symbol.dispose) DeviceKeyAlgorithm.prototype[Symbol.dispose] = DeviceKeyAlgorithm.prototype.free; - -/** - * The basic key algorithm names in the specification. - * @enum {0 | 1 | 3} - */ -const DeviceKeyAlgorithmName = exports.DeviceKeyAlgorithmName = Object.freeze({ - /** - * The Ed25519 signature algorithm. - */ - Ed25519: 0, - "0": "Ed25519", - /** - * The Curve25519 ECDH algorithm. - */ - Curve25519: 1, - "1": "Curve25519", - /** - * An unknown device key algorithm. - */ - Unknown: 3, - "3": "Unknown" -}); - -/** - * A Matrix device key ID. - * - * A key algorithm and a device ID, combined with a ‘:’. - */ -class DeviceKeyId { - static __wrap(ptr) { - const obj = Object.create(DeviceKeyId.prototype); - obj.__wbg_ptr = ptr; - DeviceKeyIdFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - DeviceKeyIdFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_devicekeyid_free(ptr, 0); - } - /** - * Returns key algorithm of the device key ID. - * @returns {DeviceKeyAlgorithm} - */ - get algorithm() { - const ret = wasm.devicekeyid_algorithm(this.__wbg_ptr); - return DeviceKeyAlgorithm.__wrap(ret); - } - /** - * Returns device ID of the device key ID. - * @returns {DeviceId} - */ - get deviceId() { - const ret = wasm.devicekeyid_deviceId(this.__wbg_ptr); - return DeviceId.__wrap(ret); - } - /** - * Parse/validate and create a new `DeviceKeyId`. - * @param {string} id - */ - constructor(id) { - const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.devicekeyid_new(ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - this.__wbg_ptr = ret[0]; - DeviceKeyIdFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Return the device key ID as a string. - * @returns {string} - */ - toString() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.devicekeyid_toString(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } -} -exports.DeviceKeyId = DeviceKeyId; -if (Symbol.dispose) DeviceKeyId.prototype[Symbol.dispose] = DeviceKeyId.prototype.free; - -/** - * An enum over the different key types a device can have. - * - * Currently devices have a curve25519 and ed25519 keypair. The keys - * transport format is a base64 encoded string, any unknown key type - * will be left as such a string. - * @enum {0 | 1 | 2} - */ -const DeviceKeyName = exports.DeviceKeyName = Object.freeze({ - /** - * The curve25519 device key. - */ - Curve25519: 0, - "0": "Curve25519", - /** - * The ed25519 device key. - */ - Ed25519: 1, - "1": "Ed25519", - /** - * An unknown device key. - */ - Unknown: 2, - "2": "Unknown" -}); - -/** - * Information on E2E device updates. - */ -class DeviceLists { - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - DeviceListsFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_devicelists_free(ptr, 0); - } - /** - * List of users who have updated their device identity keys or - * who now share an encrypted room with the client since the - * previous sync - * @returns {UserId[]} - */ - get changed() { - const ret = wasm.devicelists_changed(this.__wbg_ptr); - var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 4, 4); - return v1; - } - /** - * Returns true if there are no device list updates. - * @returns {boolean} - */ - isEmpty() { - const ret = wasm.devicelists_isEmpty(this.__wbg_ptr); - return ret !== 0; - } - /** - * List of users who no longer share encrypted rooms since the - * previous sync response. - * @returns {UserId[]} - */ - get left() { - const ret = wasm.devicelists_left(this.__wbg_ptr); - var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 4, 4); - return v1; - } - /** - * Create an empty `DeviceLists`. - * - * `changed` and `left` must be an array of `UserId`. - * - * Items inside `changed` and `left` will be invalidated by this method. Be - * careful not to use the `UserId`s after this method has been called. - * @param {UserId[] | null} [changed] - * @param {UserId[] | null} [left] - */ - constructor(changed, left) { - var ptr0 = isLikeNone(changed) ? 0 : passArrayJsValueToWasm0(changed, wasm.__wbindgen_malloc); - var len0 = WASM_VECTOR_LEN; - var ptr1 = isLikeNone(left) ? 0 : passArrayJsValueToWasm0(left, wasm.__wbindgen_malloc); - var len1 = WASM_VECTOR_LEN; - const ret = wasm.devicelists_new(ptr0, len0, ptr1, len1); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - this.__wbg_ptr = ret[0]; - DeviceListsFinalization.register(this, this.__wbg_ptr, this); - return this; - } -} -exports.DeviceLists = DeviceLists; -if (Symbol.dispose) DeviceLists.prototype[Symbol.dispose] = DeviceLists.prototype.free; - -/** - * An unestablished ECIES session. - */ -class Ecies { - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - EciesFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_ecies_free(ptr, 0); - } - /** - * Create a [`EstablishedEcies`] from an initial message encrypted by the - * other side. - * @param {string} initial_message - * @returns {InboundCreationResult} - */ - establish_inbound_channel(initial_message) { - const ptr0 = passStringToWasm0(initial_message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.ecies_establish_inbound_channel(this.__wbg_ptr, ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return InboundCreationResult.__wrap(ret[0]); - } - /** - * Create an [`EstablishedEcies`] session using the other side's Curve25519 - * public key and an initial plaintext. - * - * After the channel has been established, we can encrypt messages to send - * to the other side. The other side uses the initial message to - * establishes the same channel on its side. - * @param {Curve25519PublicKey} public_key - * @param {string} initial_message - * @returns {OutboundCreationResult} - */ - establish_outbound_channel(public_key, initial_message) { - _assertClass(public_key, Curve25519PublicKey); - const ptr0 = passStringToWasm0(initial_message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.ecies_establish_outbound_channel(this.__wbg_ptr, public_key.__wbg_ptr, ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return OutboundCreationResult.__wrap(ret[0]); - } - /** - * Create a new, random, unestablished ECIES session. - * - * This method will use the - * [`MATRIX_QR_CODE_LOGIN`](https://github.com/matrix-org/matrix-spec-proposals/pull/4108) - * info for domain separation when creating the session. - */ - constructor() { - const ret = wasm.ecies_new(); - this.__wbg_ptr = ret; - EciesFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Get our [`Curve25519PublicKey`]. - * - * This public key needs to be sent to the other side to be able to - * establish an ECIES channel. - * @returns {Curve25519PublicKey} - */ - public_key() { - const ret = wasm.ecies_public_key(this.__wbg_ptr); - return Curve25519PublicKey.__wrap(ret); - } -} -exports.Ecies = Ecies; -if (Symbol.dispose) Ecies.prototype[Symbol.dispose] = Ecies.prototype.free; - -/** - * An Ed25519 public key, used to verify digital signatures. - */ -class Ed25519PublicKey { - static __wrap(ptr) { - const obj = Object.create(Ed25519PublicKey.prototype); - obj.__wbg_ptr = ptr; - Ed25519PublicKeyFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - Ed25519PublicKeyFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_ed25519publickey_free(ptr, 0); - } - /** - * The number of bytes an Ed25519 public key has. - * @returns {number} - */ - get length() { - const ret = wasm.ed25519publickey_length(this.__wbg_ptr); - return ret >>> 0; - } - /** - * Serialize an Ed25519 public key to an unpadded base64 - * representation. - * @returns {string} - */ - toBase64() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.ed25519publickey_toBase64(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } -} -exports.Ed25519PublicKey = Ed25519PublicKey; -if (Symbol.dispose) Ed25519PublicKey.prototype[Symbol.dispose] = Ed25519PublicKey.prototype.free; - -/** - * An Ed25519 digital signature, can be used to verify the - * authenticity of a message. - */ -class Ed25519Signature { - static __wrap(ptr) { - const obj = Object.create(Ed25519Signature.prototype); - obj.__wbg_ptr = ptr; - Ed25519SignatureFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - Ed25519SignatureFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_ed25519signature_free(ptr, 0); - } - /** - * Try to create an Ed25519 signature from an unpadded base64 - * representation. - * @param {string} signature - */ - constructor(signature) { - const ptr0 = passStringToWasm0(signature, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.ed25519signature_new(ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - this.__wbg_ptr = ret[0]; - Ed25519SignatureFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Serialize a Ed25519 signature to an unpadded base64 - * representation. - * @returns {string} - */ - toBase64() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.ed25519signature_toBase64(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } -} -exports.Ed25519Signature = Ed25519Signature; -if (Symbol.dispose) Ed25519Signature.prototype[Symbol.dispose] = Ed25519Signature.prototype.free; - -/** - * An emoji that is used for interactive verification using a short - * auth string. - * - * This will contain a single emoji and description from the list of - * emojis from [the specification]. - * - * [the specification]: https://spec.matrix.org/unstable/client-server-api/#sas-method-emoji - */ -class Emoji { - static __wrap(ptr) { - const obj = Object.create(Emoji.prototype); - obj.__wbg_ptr = ptr; - EmojiFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - EmojiFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_emoji_free(ptr, 0); - } - /** - * The description of the emoji, for example ‘Dog’. - * @returns {string} - */ - get description() { - const ret = wasm.emoji_description(this.__wbg_ptr); - return ret; - } - /** - * The emoji symbol that represents a part of the short auth - * string, for example: 🐶 - * @returns {string} - */ - get symbol() { - const ret = wasm.emoji_symbol(this.__wbg_ptr); - return ret; - } -} -exports.Emoji = Emoji; -if (Symbol.dispose) Emoji.prototype[Symbol.dispose] = Emoji.prototype.free; - -/** - * An encrypted attachment, usually created from `Attachment.encrypt`. - */ -class EncryptedAttachment { - static __wrap(ptr) { - const obj = Object.create(EncryptedAttachment.prototype); - obj.__wbg_ptr = ptr; - EncryptedAttachmentFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - EncryptedAttachmentFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_encryptedattachment_free(ptr, 0); - } - /** - * The actual encrypted data. - * - * **Warning**: It returns a **copy** of the entire encrypted - * data; be nice with your memory. - * @returns {Uint8Array} - */ - get encryptedData() { - const ret = wasm.encryptedattachment_encryptedData(this.__wbg_ptr); - var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - return v1; - } - /** - * Check whether the media encryption info has been consumed by - * `Attachment.decrypt` already. - * @returns {boolean} - */ - get hasMediaEncryptionInfoBeenConsumed() { - const ret = wasm.encryptedattachment_hasMediaEncryptionInfoBeenConsumed(this.__wbg_ptr); - return ret !== 0; - } - /** - * Return the media encryption info as a JSON-encoded object. The - * structure is fully valid. - * - * If the media encryption info have been consumed already, it - * will return `null`. - * @returns {string | undefined} - */ - get mediaEncryptionInfo() { - const ret = wasm.encryptedattachment_mediaEncryptionInfo(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * Create a new encrypted attachment manually. - * - * It needs encrypted data, stored in an `Uint8Array`, and a - * [media encryption - * information](https://docs.rs/matrix-sdk-crypto/latest/matrix_sdk_crypto/struct.MediaEncryptionInfo.html), - * as a JSON-encoded object. - * - * The media encryption information aren't stored as a string: - * they are parsed, validated and fully deserialized. - * - * See [the specification to learn - * more](https://spec.matrix.org/unstable/client-server-api/#extensions-to-mroommessage-msgtypes). - * @param {Uint8Array} encrypted_data - * @param {string} media_encryption_info - */ - constructor(encrypted_data, media_encryption_info) { - const ptr0 = passArray8ToWasm0(encrypted_data, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(media_encryption_info, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ret = wasm.encryptedattachment_new(ptr0, len0, ptr1, len1); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - this.__wbg_ptr = ret[0]; - EncryptedAttachmentFinalization.register(this, this.__wbg_ptr, this); - return this; - } -} -exports.EncryptedAttachment = EncryptedAttachment; -if (Symbol.dispose) EncryptedAttachment.prototype[Symbol.dispose] = EncryptedAttachment.prototype.free; - -/** - * An encryption algorithm to be used to encrypt messages sent to a - * room. - * @enum {0 | 1 | 2} - */ -const EncryptionAlgorithm = exports.EncryptionAlgorithm = Object.freeze({ - /** - * Olm version 1 using Curve25519, AES-256, and SHA-256. - */ - OlmV1Curve25519AesSha2: 0, - "0": "OlmV1Curve25519AesSha2", - /** - * Megolm version 1 using AES-256 and SHA-256. - */ - MegolmV1AesSha2: 1, - "1": "MegolmV1AesSha2", - /** - * Unsupported algorithm. - * - * Applications should ignore this value if it is received, and should - * never set it. - */ - Unknown: 2, - "2": "Unknown" -}); - -/** - * Struct containing information on how a room event was decrypted. - */ -class EncryptionInfo { - static __wrap(ptr) { - const obj = Object.create(EncryptionInfo.prototype); - obj.__wbg_ptr = ptr; - EncryptionInfoFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - EncryptionInfoFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_encryptioninfo_free(ptr, 0); - } - /** - * The verification state of the device that sent us the event. - * Note this is the state of the device at the time of - * decryption. It may change in the future if a device gets - * verified or deleted. - * - * # Arguments - * - * * `strict` - whether to enable "strict mode" verification. In non-strict - * mode, unverified users are given no shield, and keys that have been - * forwarded or restored from an insecure backup are given a grey shield - * (both get a red shield in strict mode). - * @param {boolean} strict - * @returns {ShieldState} - */ - shieldState(strict) { - const ret = wasm.encryptioninfo_shieldState(this.__wbg_ptr, strict); - return ShieldState.__wrap(ret); - } - /** - * The device ID of the user who sent us the keys with which we decrypted - * this event as part of an MSC4268 key bundle, if present. Only applicable - * for room events. - * @returns {DeviceId | undefined} - */ - get forwarderDevice() { - const ret = wasm.__wbg_get_encryptioninfo_forwarderDevice(this.__wbg_ptr); - return ret === 0 ? undefined : DeviceId.__wrap(ret); - } - /** - * The ID of the user who sent us the keys with which we decrypted this - * event as part of an MSC4268 key bundle, if present. Only applicable for - * room events. - * @returns {UserId | undefined} - */ - get forwarder() { - const ret = wasm.__wbg_get_encryptioninfo_forwarder(this.__wbg_ptr); - return ret === 0 ? undefined : UserId.__wrap(ret); - } - /** - * The signing Ed25519 key that created the megolm key that - * was used to decrypt this session. - * @returns {string | undefined} - */ - get senderClaimedEd25519Key() { - const ret = wasm.__wbg_get_encryptioninfo_senderClaimedEd25519Key(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * The base64-encoded public Curve25519 key of the device that created the - * megolm decryption key originally. - * @returns {string} - */ - get senderCurve25519Key() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_encryptioninfo_senderCurve25519Key(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The device ID of the device that sent us the event. - * - * Note this is untrusted data unless {@link shieldState} shows that the - * sender is verified. - * @returns {DeviceId | undefined} - */ - get senderDevice() { - const ret = wasm.__wbg_get_encryptioninfo_senderDevice(this.__wbg_ptr); - return ret === 0 ? undefined : DeviceId.__wrap(ret); - } - /** - * The user ID of the sender of the event. - * - * Note this is untrusted data unless {@link shieldState} shows that the - * sender is verified. - * @returns {UserId} - */ - get sender() { - const ret = wasm.__wbg_get_encryptioninfo_sender(this.__wbg_ptr); - return UserId.__wrap(ret); - } - /** - * The device ID of the user who sent us the keys with which we decrypted - * this event as part of an MSC4268 key bundle, if present. Only applicable - * for room events. - * @param {DeviceId | null} [arg0] - */ - set forwarderDevice(arg0) { - let ptr0 = 0; - if (!isLikeNone(arg0)) { - _assertClass(arg0, DeviceId); - ptr0 = arg0.__destroy_into_raw(); - } - wasm.__wbg_set_encryptioninfo_forwarderDevice(this.__wbg_ptr, ptr0); - } - /** - * The ID of the user who sent us the keys with which we decrypted this - * event as part of an MSC4268 key bundle, if present. Only applicable for - * room events. - * @param {UserId | null} [arg0] - */ - set forwarder(arg0) { - let ptr0 = 0; - if (!isLikeNone(arg0)) { - _assertClass(arg0, UserId); - ptr0 = arg0.__destroy_into_raw(); - } - wasm.__wbg_set_encryptioninfo_forwarder(this.__wbg_ptr, ptr0); - } - /** - * The signing Ed25519 key that created the megolm key that - * was used to decrypt this session. - * @param {string | null} [arg0] - */ - set senderClaimedEd25519Key(arg0) { - var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_encryptioninfo_senderClaimedEd25519Key(this.__wbg_ptr, ptr0, len0); - } - /** - * The base64-encoded public Curve25519 key of the device that created the - * megolm decryption key originally. - * @param {string} arg0 - */ - set senderCurve25519Key(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_encryptioninfo_senderCurve25519Key(this.__wbg_ptr, ptr0, len0); - } - /** - * The device ID of the device that sent us the event. - * - * Note this is untrusted data unless {@link shieldState} shows that the - * sender is verified. - * @param {DeviceId | null} [arg0] - */ - set senderDevice(arg0) { - let ptr0 = 0; - if (!isLikeNone(arg0)) { - _assertClass(arg0, DeviceId); - ptr0 = arg0.__destroy_into_raw(); - } - wasm.__wbg_set_encryptioninfo_senderDevice(this.__wbg_ptr, ptr0); - } - /** - * The user ID of the sender of the event. - * - * Note this is untrusted data unless {@link shieldState} shows that the - * sender is verified. - * @param {UserId} arg0 - */ - set sender(arg0) { - _assertClass(arg0, UserId); - var ptr0 = arg0.__destroy_into_raw(); - wasm.__wbg_set_encryptioninfo_sender(this.__wbg_ptr, ptr0); - } -} -exports.EncryptionInfo = EncryptionInfo; -if (Symbol.dispose) EncryptionInfo.prototype[Symbol.dispose] = EncryptionInfo.prototype.free; - -/** - * Settings for an encrypted room. - * - * This determines the algorithm and rotation periods of a group - * session. - */ -class EncryptionSettings { - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - EncryptionSettingsFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_encryptionsettings_free(ptr, 0); - } - /** - * Create a new `EncryptionSettings` with default values. - */ - constructor() { - const ret = wasm.encryptionsettings_new(); - this.__wbg_ptr = ret; - EncryptionSettingsFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * The encryption algorithm that should be used in the room. - * @returns {EncryptionAlgorithm} - */ - get algorithm() { - const ret = wasm.__wbg_get_encryptionsettings_algorithm(this.__wbg_ptr); - return ret; - } - /** - * Whether state event encryption is enabled. - * @returns {boolean} - */ - get encryptStateEvents() { - const ret = wasm.__wbg_get_encryptionsettings_encryptStateEvents(this.__wbg_ptr); - return ret !== 0; - } - /** - * The history visibility of the room when the session was - * created. - * @returns {HistoryVisibility} - */ - get historyVisibility() { - const ret = wasm.__wbg_get_encryptionsettings_historyVisibility(this.__wbg_ptr); - return ret; - } - /** - * How many messages should be sent before changing the session. - * @returns {bigint} - */ - get rotationPeriodMessages() { - const ret = wasm.__wbg_get_encryptionsettings_rotationPeriodMessages(this.__wbg_ptr); - return BigInt.asUintN(64, ret); - } - /** - * How long the session should be used before changing it, - * expressed in microseconds. - * @returns {bigint} - */ - get rotationPeriod() { - const ret = wasm.__wbg_get_encryptionsettings_rotationPeriod(this.__wbg_ptr); - return BigInt.asUintN(64, ret); - } - /** - * Should untrusted devices receive the room key, or should they be - * excluded from the conversation. - * @returns {CollectStrategy} - */ - get sharingStrategy() { - const ret = wasm.__wbg_get_encryptionsettings_sharingStrategy(this.__wbg_ptr); - return CollectStrategy.__wrap(ret); - } - /** - * The encryption algorithm that should be used in the room. - * @param {EncryptionAlgorithm} arg0 - */ - set algorithm(arg0) { - wasm.__wbg_set_encryptionsettings_algorithm(this.__wbg_ptr, arg0); - } - /** - * Whether state event encryption is enabled. - * @param {boolean} arg0 - */ - set encryptStateEvents(arg0) { - wasm.__wbg_set_encryptionsettings_encryptStateEvents(this.__wbg_ptr, arg0); - } - /** - * The history visibility of the room when the session was - * created. - * @param {HistoryVisibility} arg0 - */ - set historyVisibility(arg0) { - wasm.__wbg_set_encryptionsettings_historyVisibility(this.__wbg_ptr, arg0); - } - /** - * How many messages should be sent before changing the session. - * @param {bigint} arg0 - */ - set rotationPeriodMessages(arg0) { - wasm.__wbg_set_encryptionsettings_rotationPeriodMessages(this.__wbg_ptr, arg0); - } - /** - * How long the session should be used before changing it, - * expressed in microseconds. - * @param {bigint} arg0 - */ - set rotationPeriod(arg0) { - wasm.__wbg_set_encryptionsettings_rotationPeriod(this.__wbg_ptr, arg0); - } - /** - * Should untrusted devices receive the room key, or should they be - * excluded from the conversation. - * @param {CollectStrategy} arg0 - */ - set sharingStrategy(arg0) { - _assertClass(arg0, CollectStrategy); - var ptr0 = arg0.__destroy_into_raw(); - wasm.__wbg_set_encryptionsettings_sharingStrategy(this.__wbg_ptr, ptr0); - } -} -exports.EncryptionSettings = EncryptionSettings; -if (Symbol.dispose) EncryptionSettings.prototype[Symbol.dispose] = EncryptionSettings.prototype.free; - -/** - * An established ECIES session. - * - * This session can be used to encrypt and decrypt messages between the two - * sides of the channel. - */ -class EstablishedEcies { - static __wrap(ptr) { - const obj = Object.create(EstablishedEcies.prototype); - obj.__wbg_ptr = ptr; - EstablishedEciesFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - EstablishedEciesFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_establishedecies_free(ptr, 0); - } - /** - * Get the [`CheckCode`] which uniquely identifies this - * [`EstablishedEcies`] session. - * - * This check code can be used to verify and confirm that both sides of the - * session are indeed using the same shared secret. - * @returns {CheckCode} - */ - check_code() { - const ret = wasm.establishedecies_check_code(this.__wbg_ptr); - return CheckCode.__wrap(ret); - } - /** - * Decrypt the given message using this [`EstablishedEcies`] session. - * @param {string} message - * @returns {string} - */ - decrypt(message) { - let deferred3_0; - let deferred3_1; - try { - const ptr0 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.establishedecies_decrypt(this.__wbg_ptr, ptr0, len0); - var ptr2 = ret[0]; - var len2 = ret[1]; - if (ret[3]) { - ptr2 = 0; - len2 = 0; - throw takeFromExternrefTable0(ret[2]); - } - deferred3_0 = ptr2; - deferred3_1 = len2; - return getStringFromWasm0(ptr2, len2); - } finally { - wasm.__wbindgen_free(deferred3_0, deferred3_1, 1); - } - } - /** - * Encrypt the given plaintext using this [`EstablishedEcies`] session. - * @param {string} message - * @returns {string} - */ - encrypt(message) { - let deferred2_0; - let deferred2_1; - try { - const ptr0 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.establishedecies_encrypt(this.__wbg_ptr, ptr0, len0); - deferred2_0 = ret[0]; - deferred2_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); - } - } - /** - * Get our [`Curve25519PublicKey`]. - * - * This public key needs to be sent to the other side so that it can - * complete the ECIES channel establishment. - * @returns {Curve25519PublicKey} - */ - public_key() { - const ret = wasm.establishedecies_public_key(this.__wbg_ptr); - return Curve25519PublicKey.__wrap(ret); - } -} -exports.EstablishedEcies = EstablishedEcies; -if (Symbol.dispose) EstablishedEcies.prototype[Symbol.dispose] = EstablishedEcies.prototype.free; - -/** - * A Matrix [event ID]. - * - * An `EventId` is generated randomly or converted from a string - * slice, and can be converted back into a string as needed. - * - * [event ID]: https://spec.matrix.org/v1.2/appendices/#room-ids-and-event-ids - */ -class EventId { - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - EventIdFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_eventid_free(ptr, 0); - } - /** - * Returns the event's localpart. - * @returns {string} - */ - get localpart() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.eventid_localpart(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Parse/validate and create a new `EventId`. - * @param {string} id - */ - constructor(id) { - const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.eventid_new(ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - this.__wbg_ptr = ret[0]; - EventIdFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Returns the server name of the event ID. - * @returns {ServerName | undefined} - */ - get serverName() { - const ret = wasm.eventid_serverName(this.__wbg_ptr); - return ret === 0 ? undefined : ServerName.__wrap(ret); - } - /** - * Return the event ID as a string. - * @returns {string} - */ - toString() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.eventid_toString(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } -} -exports.EventId = EventId; -if (Symbol.dispose) EventId.prototype[Symbol.dispose] = EventId.prototype.free; - -/** - * Who can see a room's history. - * @enum {0 | 1 | 2 | 3} - */ -const HistoryVisibility = exports.HistoryVisibility = Object.freeze({ - /** - * Previous events are accessible to newly joined members from - * the point they were invited onwards. - * - * Events stop being accessible when the member's state changes - * to something other than *invite* or *join*. - */ - Invited: 0, - "0": "Invited", - /** - * Previous events are accessible to newly joined members from - * the point they joined the room onwards. - * - * Events stop being accessible when the member's state changes - * to something other than *join*. - */ - Joined: 1, - "1": "Joined", - /** - * Previous events are always accessible to newly joined members. - * - * All events in the room are accessible, even those sent when - * the member was not a part of the room. - */ - Shared: 2, - "2": "Shared", - /** - * All events while this is the `HistoryVisibility` value may be - * shared by any participating homeserver with anyone, regardless - * of whether they have ever joined the room. - */ - WorldReadable: 3, - "3": "WorldReadable" -}); - -/** - * Struct holding the two public identity keys of an account. - */ -class IdentityKeys { - static __wrap(ptr) { - const obj = Object.create(IdentityKeys.prototype); - obj.__wbg_ptr = ptr; - IdentityKeysFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - IdentityKeysFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_identitykeys_free(ptr, 0); - } - /** - * The Curve25519 public key, used for establish shared secrets. - * @returns {Curve25519PublicKey} - */ - get curve25519() { - const ret = wasm.__wbg_get_identitykeys_curve25519(this.__wbg_ptr); - return Curve25519PublicKey.__wrap(ret); - } - /** - * The Ed25519 public key, used for signing. - * @returns {Ed25519PublicKey} - */ - get ed25519() { - const ret = wasm.__wbg_get_identitykeys_ed25519(this.__wbg_ptr); - return Ed25519PublicKey.__wrap(ret); - } - /** - * The Curve25519 public key, used for establish shared secrets. - * @param {Curve25519PublicKey} arg0 - */ - set curve25519(arg0) { - _assertClass(arg0, Curve25519PublicKey); - var ptr0 = arg0.__destroy_into_raw(); - wasm.__wbg_set_identitykeys_curve25519(this.__wbg_ptr, ptr0); - } - /** - * The Ed25519 public key, used for signing. - * @param {Ed25519PublicKey} arg0 - */ - set ed25519(arg0) { - _assertClass(arg0, Ed25519PublicKey); - var ptr0 = arg0.__destroy_into_raw(); - wasm.__wbg_set_identitykeys_ed25519(this.__wbg_ptr, ptr0); - } -} -exports.IdentityKeys = IdentityKeys; -if (Symbol.dispose) IdentityKeys.prototype[Symbol.dispose] = IdentityKeys.prototype.free; - -/** - * The result of an inbound ECIES channel establishment. - */ -class InboundCreationResult { - static __wrap(ptr) { - const obj = Object.create(InboundCreationResult.prototype); - obj.__wbg_ptr = ptr; - InboundCreationResultFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - InboundCreationResultFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_inboundcreationresult_free(ptr, 0); - } - /** - * The established ECIES channel. - * @returns {EstablishedEcies} - */ - get channel() { - const ret = wasm.__wbg_get_inboundcreationresult_channel(this.__wbg_ptr); - return EstablishedEcies.__wrap(ret); - } - /** - * The plaintext of the initial message. - * @returns {string} - */ - get message() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_inboundcreationresult_message(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The established ECIES channel. - * @param {EstablishedEcies} arg0 - */ - set channel(arg0) { - _assertClass(arg0, EstablishedEcies); - var ptr0 = arg0.__destroy_into_raw(); - wasm.__wbg_set_inboundcreationresult_channel(this.__wbg_ptr, ptr0); - } - /** - * The plaintext of the initial message. - * @param {string} arg0 - */ - set message(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_inboundcreationresult_message(this.__wbg_ptr, ptr0, len0); - } -} -exports.InboundCreationResult = InboundCreationResult; -if (Symbol.dispose) InboundCreationResult.prototype[Symbol.dispose] = InboundCreationResult.prototype.free; - -/** - * Inbound group session. - * - * Inbound group sessions are used to exchange room messages between a group of - * participants. Inbound group sessions are used to decrypt the room messages. - */ -class InboundGroupSession { - static __wrap(ptr) { - const obj = Object.create(InboundGroupSession.prototype); - obj.__wbg_ptr = ptr; - InboundGroupSessionFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - InboundGroupSessionFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_inboundgroupsession_free(ptr, 0); - } - /** - * Has the session been imported from a file or server-side backup? As - * opposed to being directly received as an `m.room_key` event. - * @returns {boolean} - */ - hasBeenImported() { - const ret = wasm.inboundgroupsession_hasBeenImported(this.__wbg_ptr); - return ret !== 0; - } - /** - * The room where this session is used in. - * @returns {RoomId} - */ - get roomId() { - const ret = wasm.inboundgroupsession_roomId(this.__wbg_ptr); - return RoomId.__wrap(ret); - } - /** - * The Curve25519 key of the sender of this session, as a - * [Curve25519PublicKey]. - * @returns {Curve25519PublicKey} - */ - get senderKey() { - const ret = wasm.inboundgroupsession_senderKey(this.__wbg_ptr); - return Curve25519PublicKey.__wrap(ret); - } - /** - * Returns the unique identifier for this session. - * @returns {string} - */ - get sessionId() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.inboundgroupsession_sessionId(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } -} -exports.InboundGroupSession = InboundGroupSession; -if (Symbol.dispose) InboundGroupSession.prototype[Symbol.dispose] = InboundGroupSession.prototype.free; - -/** - * Represents an invalid to-device event that was ignored (because it is - * missing some mandatory fields, for example). - */ -class InvalidToDeviceEvent { - static __wrap(ptr) { - const obj = Object.create(InvalidToDeviceEvent.prototype); - obj.__wbg_ptr = ptr; - InvalidToDeviceEventFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - InvalidToDeviceEventFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_invalidtodeviceevent_free(ptr, 0); - } - /** - * The original message as received from sync, encoded as JSON. - * @returns {string} - */ - get rawEvent() { - const ret = wasm.__wbg_get_invalidtodeviceevent_rawEvent(this.__wbg_ptr); - return ret; - } - /** - * The type of processed to-device event. Always {@link - * ProcessedToDeviceEventType.Invalid} for this type. - * @returns {ProcessedToDeviceEventType} - */ - get type() { - const ret = wasm.invalidtodeviceevent_type(this.__wbg_ptr); - return ret; - } -} -exports.InvalidToDeviceEvent = InvalidToDeviceEvent; -if (Symbol.dispose) InvalidToDeviceEvent.prototype[Symbol.dispose] = InvalidToDeviceEvent.prototype.free; - -/** - * A request that will back up a batch of room keys to the server - * ([specification]). - * - * [specification]: https://spec.matrix.org/unstable/client-server-api/#put_matrixclientv3room_keyskeys - */ -class KeysBackupRequest { - static __wrap(ptr) { - const obj = Object.create(KeysBackupRequest.prototype); - obj.__wbg_ptr = ptr; - KeysBackupRequestFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - KeysBackupRequestFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_keysbackuprequest_free(ptr, 0); - } - /** - * A JSON-encoded object containing the rest of the payload: `rooms`. - * - * It represents the body of the HTTP request. - * @returns {string} - */ - get body() { - const ret = wasm.__wbg_get_keysbackuprequest_body(this.__wbg_ptr); - return ret; - } - /** - * The request ID. - * @returns {string} - */ - get id() { - const ret = wasm.__wbg_get_keysbackuprequest_id(this.__wbg_ptr); - return ret; - } - /** - * The backup version that these room keys should be part of. - * @returns {string} - */ - get version() { - const ret = wasm.__wbg_get_keysbackuprequest_version(this.__wbg_ptr); - return ret; - } - /** - * Create a new `KeysBackupRequest`. - * @param {string} id - * @param {string} body - * @param {string} version - */ - constructor(id, body, version) { - const ret = wasm.keysbackuprequest_new(id, body, version); - this.__wbg_ptr = ret; - KeysBackupRequestFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Get its request type. - * @returns {RequestType} - */ - get type() { - const ret = wasm.keysbackuprequest_type(this.__wbg_ptr); - return ret; - } -} -exports.KeysBackupRequest = KeysBackupRequest; -if (Symbol.dispose) KeysBackupRequest.prototype[Symbol.dispose] = KeysBackupRequest.prototype.free; - -/** - * Data for a request to the `/keys/claim` API endpoint - * ([specification]). - * - * Claims one-time keys that can be used to establish 1-to-1 E2EE - * sessions. - * - * [specification]: https://spec.matrix.org/unstable/client-server-api/#post_matrixclientv3keysclaim - */ -class KeysClaimRequest { - static __wrap(ptr) { - const obj = Object.create(KeysClaimRequest.prototype); - obj.__wbg_ptr = ptr; - KeysClaimRequestFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - KeysClaimRequestFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_keysclaimrequest_free(ptr, 0); - } - /** - * A JSON-encoded object containing the rest of the payload: `timeout`, - * `one_time_keys`. - * - * It represents the body of the HTTP request. - * @returns {string} - */ - get body() { - const ret = wasm.__wbg_get_keysclaimrequest_body(this.__wbg_ptr); - return ret; - } - /** - * The request ID. - * @returns {string} - */ - get id() { - const ret = wasm.__wbg_get_keysclaimrequest_id(this.__wbg_ptr); - return ret; - } - /** - * Create a new `KeysClaimRequest`. - * @param {string} id - * @param {string} body - */ - constructor(id, body) { - const ret = wasm.keysclaimrequest_new(id, body); - this.__wbg_ptr = ret; - KeysClaimRequestFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Get its request type. - * @returns {RequestType} - */ - get type() { - const ret = wasm.keysclaimrequest_type(this.__wbg_ptr); - return ret; - } -} -exports.KeysClaimRequest = KeysClaimRequest; -if (Symbol.dispose) KeysClaimRequest.prototype[Symbol.dispose] = KeysClaimRequest.prototype.free; - -/** - * Data for a request to the `/keys/query` API endpoint - * ([specification]). - * - * Returns the current devices and identity keys for the given users. - * - * [specification]: https://spec.matrix.org/unstable/client-server-api/#post_matrixclientv3keysquery - */ -class KeysQueryRequest { - static __wrap(ptr) { - const obj = Object.create(KeysQueryRequest.prototype); - obj.__wbg_ptr = ptr; - KeysQueryRequestFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - KeysQueryRequestFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_keysqueryrequest_free(ptr, 0); - } - /** - * A JSON-encoded object containing the rest of the payload: `timeout`, - * `device_keys`, `token`. - * - * It represents the body of the HTTP request. - * @returns {string} - */ - get body() { - const ret = wasm.__wbg_get_keysqueryrequest_body(this.__wbg_ptr); - return ret; - } - /** - * The request ID. - * @returns {string} - */ - get id() { - const ret = wasm.__wbg_get_keysqueryrequest_id(this.__wbg_ptr); - return ret; - } - /** - * Create a new `KeysQueryRequest`. - * @param {string} id - * @param {string} body - */ - constructor(id, body) { - const ret = wasm.keysqueryrequest_new(id, body); - this.__wbg_ptr = ret; - KeysQueryRequestFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Get its request type. - * @returns {RequestType} - */ - get type() { - const ret = wasm.keysqueryrequest_type(this.__wbg_ptr); - return ret; - } -} -exports.KeysQueryRequest = KeysQueryRequest; -if (Symbol.dispose) KeysQueryRequest.prototype[Symbol.dispose] = KeysQueryRequest.prototype.free; - -/** - * Data for a request to the `/keys/upload` API endpoint - * ([specification]). - * - * Publishes end-to-end encryption keys for the device. - * - * [specification]: https://spec.matrix.org/unstable/client-server-api/#post_matrixclientv3keysupload - */ -class KeysUploadRequest { - static __wrap(ptr) { - const obj = Object.create(KeysUploadRequest.prototype); - obj.__wbg_ptr = ptr; - KeysUploadRequestFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - KeysUploadRequestFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_keysuploadrequest_free(ptr, 0); - } - /** - * A JSON-encoded object containing the rest of the payload: `device_keys`, - * `one_time_keys`, `fallback_keys`. - * - * It represents the body of the HTTP request. - * @returns {string} - */ - get body() { - const ret = wasm.__wbg_get_keysuploadrequest_body(this.__wbg_ptr); - return ret; - } - /** - * The request ID. - * @returns {string} - */ - get id() { - const ret = wasm.__wbg_get_keysuploadrequest_id(this.__wbg_ptr); - return ret; - } - /** - * Create a new `KeysUploadRequest`. - * @param {string} id - * @param {string} body - */ - constructor(id, body) { - const ret = wasm.keysuploadrequest_new(id, body); - this.__wbg_ptr = ret; - KeysUploadRequestFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Get its request type. - * @returns {RequestType} - */ - get type() { - const ret = wasm.keysuploadrequest_type(this.__wbg_ptr); - return ret; - } -} -exports.KeysUploadRequest = KeysUploadRequest; -if (Symbol.dispose) KeysUploadRequest.prototype[Symbol.dispose] = KeysUploadRequest.prototype.free; - -/** - * The local trust state of a device. - * @enum {0 | 1 | 2 | 3} - */ -const LocalTrust = exports.LocalTrust = Object.freeze({ - /** - * The device has been verified and is trusted. - */ - Verified: 0, - "0": "Verified", - /** - * The device been blacklisted from communicating. - */ - BlackListed: 1, - "1": "BlackListed", - /** - * The trust state of the device is being ignored. - */ - Ignored: 2, - "2": "Ignored", - /** - * The trust state is unset. - */ - Unset: 3, - "3": "Unset" -}); - -/** - * Logger level. - * @enum {0 | 1 | 2 | 3 | 4} - */ -const LoggerLevel = exports.LoggerLevel = Object.freeze({ - /** - * `TRACE` level. - * - * Designate very low priority, often extremely verbose, - * information. - */ - Trace: 0, - "0": "Trace", - /** - * `DEBUG` level. - * - * Designate lower priority information. - */ - Debug: 1, - "1": "Debug", - /** - * `INFO` level. - * - * Designate useful information. - */ - Info: 2, - "2": "Info", - /** - * `WARN` level. - * - * Designate hazardous situations. - */ - Warn: 3, - "3": "Warn", - /** - * `ERROR` level. - * - * Designate very serious errors. - */ - Error: 4, - "4": "Error" -}); - -/** - * Represents a signature that is either valid _or_ that could not be - * decoded. - */ -class MaybeSignature { - static __wrap(ptr) { - const obj = Object.create(MaybeSignature.prototype); - obj.__wbg_ptr = ptr; - MaybeSignatureFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - MaybeSignatureFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_maybesignature_free(ptr, 0); - } - /** - * The base64 encoded string that is claimed to contain a - * signature but could not be decoded, if any. - * @returns {string | undefined} - */ - get invalidSignatureSource() { - const ret = wasm.maybesignature_invalidSignatureSource(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * Check whether the signature could not be successfully decoded. - * @returns {boolean} - */ - isInvalid() { - const ret = wasm.maybesignature_isInvalid(this.__wbg_ptr); - return ret !== 0; - } - /** - * Check whether the signature has been successfully decoded. - * @returns {boolean} - */ - isValid() { - const ret = wasm.maybesignature_isValid(this.__wbg_ptr); - return ret !== 0; - } - /** - * The signature, if successfully decoded. - * @returns {Signature | undefined} - */ - get signature() { - const ret = wasm.maybesignature_signature(this.__wbg_ptr); - return ret === 0 ? undefined : Signature.__wrap(ret); - } -} -exports.MaybeSignature = MaybeSignature; -if (Symbol.dispose) MaybeSignature.prototype[Symbol.dispose] = MaybeSignature.prototype.free; - -/** - * Js Decryption error with code. - */ -class MegolmDecryptionError { - static __wrap(ptr) { - const obj = Object.create(MegolmDecryptionError.prototype); - obj.__wbg_ptr = ptr; - MegolmDecryptionErrorFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - MegolmDecryptionErrorFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_megolmdecryptionerror_free(ptr, 0); - } - /** - * Description code for the error. See `DecryptionErrorCode` - * @returns {DecryptionErrorCode} - */ - get code() { - const ret = wasm.__wbg_get_megolmdecryptionerror_code(this.__wbg_ptr); - return ret; - } - /** - * detailed description - * @returns {string} - */ - get description() { - const ret = wasm.__wbg_get_megolmdecryptionerror_description(this.__wbg_ptr); - return ret; - } - /** - * Textual description of the withheld code, if any. - * - * Example: "The sender has disabled encrypting to unverified devices." - * - * `undefined` if we have not received a withheld code for the megolm - * session. - * @returns {string | undefined} - */ - get maybe_withheld() { - const ret = wasm.megolmdecryptionerror_maybe_withheld(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * Creates generic error with description - * @param {string} desc - * @returns {MegolmDecryptionError} - */ - static unable_to_decrypt(desc) { - const ptr0 = passStringToWasm0(desc, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.megolmdecryptionerror_unable_to_decrypt(ptr0, len0); - return MegolmDecryptionError.__wrap(ret); - } - /** - * The withheld code, if any. - * - * Example: "m.unverified" - * - * `undefined` if we have not received a withheld code for the megolm - * session. - * @returns {string | undefined} - */ - get withheldCode() { - const ret = wasm.megolmdecryptionerror_withheldCode(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } -} -exports.MegolmDecryptionError = MegolmDecryptionError; -if (Symbol.dispose) MegolmDecryptionError.prototype[Symbol.dispose] = MegolmDecryptionError.prototype.free; - -/** - * The public part of the backup key. - */ -class MegolmV1BackupKey { - static __wrap(ptr) { - const obj = Object.create(MegolmV1BackupKey.prototype); - obj.__wbg_ptr = ptr; - MegolmV1BackupKeyFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - MegolmV1BackupKeyFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_megolmv1backupkey_free(ptr, 0); - } - /** - * Get the full name of the backup algorithm this backup key supports. - * @returns {string} - */ - get algorithm() { - const ret = wasm.megolmv1backupkey_algorithm(this.__wbg_ptr); - return ret; - } - /** - * The actual base64 encoded public key. - * @returns {string} - */ - get publicKeyBase64() { - const ret = wasm.megolmv1backupkey_publicKeyBase64(this.__wbg_ptr); - return ret; - } -} -exports.MegolmV1BackupKey = MegolmV1BackupKey; -if (Symbol.dispose) MegolmV1BackupKey.prototype[Symbol.dispose] = MegolmV1BackupKey.prototype.free; - -/** - * Migration routines - * - * The public methods are exposed as static methods on this class, for - * namespacing and to enable easier mocking in unit tests. - */ -class Migration { - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - MigrationFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_migration_free(ptr, 0); - } - /** - * Import the base dataset from a libolm-based setup to a vodozemac-based - * setup stored in IndexedDB. - * - * Populates the user credentials, Olm account, backup data, etc. This is - * the first step in the migration process. Once this base data is - * imported, further data can be imported with {@link - * migrateOlmSessions}, {@link migrateMegolmSessions}, and TODO room - * settings. - * - * # Arguments - * - * * `data` - The data to be migrated - * * `pickle_key` - The libolm pickle key that was used to pickle the olm - * account objects. - * * `store_handle` - A connection to the CryptoStore which will be used to - * store the vodozemac data. - * * `logger` - An optional logger instance to use for writing log messages - * during the migration operation. An instance of `JsLogger`. - * @param {BaseMigrationData} data - * @param {Uint8Array} pickle_key - * @param {StoreHandle} store_handle - * @param {JsLogger} [logger] - * @returns {Promise} - */ - static migrateBaseData(data, pickle_key, store_handle, logger) { - _assertClass(data, BaseMigrationData); - _assertClass(store_handle, StoreHandle); - const ret = wasm.migration_migrateBaseData(data.__wbg_ptr, pickle_key, store_handle.__wbg_ptr, isLikeNone(logger) ? 0 : addToExternrefTable0(logger)); - return ret; - } - /** - * Migrate Megolm sessions of a libolm-based setup to a vodozemac-based - * setup stored in an indexedDB crypto store. - * - * Before this method can be used, {@link migrateBaseData} must be used to - * import the base data into the crypto store. - * - * This method should be called a number of times, with separate batches of - * `sessions`. If a progress display is given, it can be updated after - * each batch is successfully imported. - * - * # Arguments - * - * * `sessions` - An `Array` of {@link PickledInboundGroupSession}s to - * import. Items inside `sessions` will be invalidated by this method. - * * `pickle_key` - The libolm pickle key that was used to pickle the - * megolm session objects. - * * `store_handle` - A connection to the CryptoStore which will be used to - * store the vodozemac data. - * * `logger` - An optional logger instance to use for writing log messages - * during the migration operation. An instance of `JsLogger`. - * @param {PickledInboundGroupSession[]} sessions - * @param {Uint8Array} pickle_key - * @param {StoreHandle} store_handle - * @param {JsLogger} [logger] - * @returns {Promise} - */ - static migrateMegolmSessions(sessions, pickle_key, store_handle, logger) { - const ptr0 = passArrayJsValueToWasm0(sessions, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(store_handle, StoreHandle); - const ret = wasm.migration_migrateMegolmSessions(ptr0, len0, pickle_key, store_handle.__wbg_ptr, isLikeNone(logger) ? 0 : addToExternrefTable0(logger)); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Migrate Olm sessions of a libolm-based setup to a vodozemac-based setup - * stored in an indexedDB crypto store. - * - * Before this method can be used, {@link migrateBaseData} must be used to - * import the base data into the crypto store. - * - * This method should be called a number of times, with separate batches of - * `sessions`. If a progress display is given, it can be updated after - * each batch is successfully imported. - * - * # Arguments - * - * * `sessions` - An `Array` of {@link PickledSession}s to import. Items - * inside `sessions` will be invalidated by this method. - * * `pickle_key` - The libolm pickle key that was used to pickle the olm - * session objects. - * * `store_handle` - A connection to the CryptoStore which will be used to - * store the vodozemac data. - * * `logger` - An optional logger instance to use for writing log messages - * during the migration operation. An instance of `JsLogger`. - * @param {PickledSession[]} sessions - * @param {Uint8Array} pickle_key - * @param {StoreHandle} store_handle - * @param {JsLogger} [logger] - * @returns {Promise} - */ - static migrateOlmSessions(sessions, pickle_key, store_handle, logger) { - const ptr0 = passArrayJsValueToWasm0(sessions, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(store_handle, StoreHandle); - const ret = wasm.migration_migrateOlmSessions(ptr0, len0, pickle_key, store_handle.__wbg_ptr, isLikeNone(logger) ? 0 : addToExternrefTable0(logger)); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } -} -exports.Migration = Migration; -if (Symbol.dispose) Migration.prototype[Symbol.dispose] = Migration.prototype.free; - -/** - * Intent-specific data in the case the QR code adheres to - * {@link https://github.com/matrix-org/matrix-spec-proposals/pull/4108 MSC4108} of the QR code - * data format. - */ -class Msc4108IntentData { - static __wrap(ptr) { - const obj = Object.create(Msc4108IntentData.prototype); - obj.__wbg_ptr = ptr; - Msc4108IntentDataFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - Msc4108IntentDataFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_msc4108intentdata_free(ptr, 0); - } - /** - * Get the URL of the rendezvous server which will be used to exchange - * messages between the two devices. - * @returns {string} - */ - get rendezvousUrl() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_msc4108intentdata_rendezvousUrl(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Get the server name of the homeserver which the new device will be - * logged in to. - * - * This will be only available if the existing device has generated the QR - * code and the new device is the one scanning the QR code. - * @returns {string | undefined} - */ - get serverName() { - const ret = wasm.__wbg_get_msc4108intentdata_serverName(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * Get the URL of the rendezvous server which will be used to exchange - * messages between the two devices. - * @param {string} arg0 - */ - set rendezvousUrl(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_msc4108intentdata_rendezvousUrl(this.__wbg_ptr, ptr0, len0); - } - /** - * Get the server name of the homeserver which the new device will be - * logged in to. - * - * This will be only available if the existing device has generated the QR - * code and the new device is the one scanning the QR code. - * @param {string | null} [arg0] - */ - set serverName(arg0) { - var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_msc4108intentdata_serverName(this.__wbg_ptr, ptr0, len0); - } -} -exports.Msc4108IntentData = Msc4108IntentData; -if (Symbol.dispose) Msc4108IntentData.prototype[Symbol.dispose] = Msc4108IntentData.prototype.free; - -/** - * Intent-specific data in the case the QR code adheres to - * {@link https://github.com/matrix-org/matrix-spec-proposals/pull/4388 MSC4388} of the QR code - * data format. - */ -class Msc4388IntentData { - static __wrap(ptr) { - const obj = Object.create(Msc4388IntentData.prototype); - obj.__wbg_ptr = ptr; - Msc4388IntentDataFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - Msc4388IntentDataFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_msc4388intentdata_free(ptr, 0); - } - /** - * The base URL of the homeserver that the device generating the QR is - * using. - * @returns {string} - */ - get baseUrl() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_msc4388intentdata_baseUrl(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The ID of the rendezvous session, can be used to exchange messages with - * the other device. - * @returns {string} - */ - get rendezvousId() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_msc4388intentdata_rendezvousId(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The base URL of the homeserver that the device generating the QR is - * using. - * @param {string} arg0 - */ - set baseUrl(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_msc4388intentdata_baseUrl(this.__wbg_ptr, ptr0, len0); - } - /** - * The ID of the rendezvous session, can be used to exchange messages with - * the other device. - * @param {string} arg0 - */ - set rendezvousId(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_msc4388intentdata_rendezvousId(this.__wbg_ptr, ptr0, len0); - } -} -exports.Msc4388IntentData = Msc4388IntentData; -if (Symbol.dispose) Msc4388IntentData.prototype[Symbol.dispose] = Msc4388IntentData.prototype.free; - -/** - * State machine implementation of the Olm/Megolm encryption protocol - * used for Matrix end to end encryption. - */ -class OlmMachine { - static __wrap(ptr) { - const obj = Object.create(OlmMachine.prototype); - obj.__wbg_ptr = ptr; - OlmMachineFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - OlmMachineFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_olmmachine_free(ptr, 0); - } - /** - * Encrypt a batch of room keys and return a request that needs to be sent - * out to backup the room keys. - * - * Returns an optional {@link KeysBackupRequest}. - * @returns {Promise} - */ - backupRoomKeys() { - const ret = wasm.olmmachine_backupRoomKeys(this.__wbg_ptr); - return ret; - } - /** - * Create a new cross signing identity and get the upload request - * to push the new public keys to the server. - * - * Warning: This will delete any existing cross signing keys that - * might exist on the server and thus will reset the trust - * between all the devices. - * - * Uploading these keys will require user interactive auth. - * - * # Arguments - * - * * `reset`, whether the method should create a new identity or use the - * existing one during the request. If set to true, the request will - * attempt to upload a new identity. If set to false, the request will - * attempt to upload the existing identity. Since the uploading process - * requires user interactive authentication, which involves sending out - * the same request multiple times, setting this argument to false - * enables you to reuse the same request. - * - * Returns a {@link CrossSigningBootstrapRequests}. - * @param {boolean} reset - * @returns {Promise} - */ - bootstrapCrossSigning(reset) { - const ret = wasm.olmmachine_bootstrapCrossSigning(this.__wbg_ptr, reset); - return ret; - } - /** - * Assemble, and encrypt, a room key bundle for sharing encrypted history, - * as per {@link https://github.com/matrix-org/matrix-spec-proposals/pull/4268|MSC4268}. - * - * Returns `undefined` if there are no keys to share in the given room, - * otherwise an {@link EncryptedAttachment}. - * - * The data should be uploaded to the media server, and the details then - * passed to {@link shareRoomKeyBundleData}. - * - * @experimental - * @param {RoomId} room_id - * @returns {Promise} - */ - buildRoomKeyBundle(room_id) { - _assertClass(room_id, RoomId); - const ret = wasm.olmmachine_buildRoomKeyBundle(this.__wbg_ptr, room_id.__wbg_ptr); - return ret; - } - /** - * Store the fact that we are no longer waiting for a key bundle in the - * given room. - * - * The counterpart to {@link storeRoomPendingKeyBundle}. Should be called - * when, for example, we leave a room, or have successfully imported a - * bundle. - * - * @experimental - * @param {RoomId} room_id - * @returns {Promise} - */ - clearRoomPendingKeyBundle(room_id) { - _assertClass(room_id, RoomId); - const ret = wasm.olmmachine_clearRoomPendingKeyBundle(this.__wbg_ptr, room_id.__wbg_ptr); - return ret; - } - /** - * Shut down the `OlmMachine`. - * - * The `OlmMachine` cannot be used after this method has been called. - * - * All associated resources will be closed too, like IndexedDB - * connections. - */ - close() { - const ptr = this.__destroy_into_raw(); - wasm.olmmachine_close(ptr); - } - /** - * Get the status of the private cross signing keys. - * - * This can be used to check which private cross signing keys we - * have stored locally. - * @returns {Promise} - */ - crossSigningStatus() { - const ret = wasm.olmmachine_crossSigningStatus(this.__wbg_ptr); - return ret; - } - /** - * Try to decrypt a reader into a list of exported room keys. - * - * `encrypted_exported_room_keys` is the result from - * `encrypt_exported_room_keys`. `passphrase` is the passphrase that was - * used when calling `encrypt_exported_room_keys`. - * @param {string} encrypted_exported_room_keys - * @param {string} passphrase - * @returns {string} - */ - static decryptExportedRoomKeys(encrypted_exported_room_keys, passphrase) { - let deferred4_0; - let deferred4_1; - try { - const ptr0 = passStringToWasm0(encrypted_exported_room_keys, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(passphrase, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_decryptExportedRoomKeys(ptr0, len0, ptr1, len1); - var ptr3 = ret[0]; - var len3 = ret[1]; - if (ret[3]) { - ptr3 = 0; - len3 = 0; - throw takeFromExternrefTable0(ret[2]); - } - deferred4_0 = ptr3; - deferred4_1 = len3; - return getStringFromWasm0(ptr3, len3); - } finally { - wasm.__wbindgen_free(deferred4_0, deferred4_1, 1); - } - } - /** - * Decrypt an event from a room timeline. - * - * # Arguments - * - * * `event`, the event that should be decrypted. - * * `room_id`, the ID of the room where the event was sent to. - * - * # Returns - * - * A `Promise` which resolves to a {@link DecryptedRoomEvent} instance, or - * rejects with a {@link MegolmDecryptionError} instance. - * @param {string} event - * @param {RoomId} room_id - * @param {DecryptionSettings} decryption_settings - * @returns {Promise} - */ - decryptRoomEvent(event, room_id, decryption_settings) { - const ptr0 = passStringToWasm0(event, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(room_id, RoomId); - _assertClass(decryption_settings, DecryptionSettings); - const ret = wasm.olmmachine_decryptRoomEvent(this.__wbg_ptr, ptr0, len0, room_id.__wbg_ptr, decryption_settings.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Manage dehydrated devices - * @returns {DehydratedDevices} - */ - dehydratedDevices() { - const ret = wasm.olmmachine_dehydratedDevices(this.__wbg_ptr); - return DehydratedDevices.__wrap(ret); - } - /** - * Delete all secrets with the given secret name from the inbox. - * - * Should be called after handling the secrets with - * `get_secrets_from_inbox`. - * - * # Arguments - * - * * `secret_name` - The name of the secret to delete. - * @param {string} secret_name - * @returns {Promise} - */ - deleteSecretsFromInbox(secret_name) { - const ptr0 = passStringToWasm0(secret_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_deleteSecretsFromInbox(this.__wbg_ptr, ptr0, len0); - return ret; - } - /** - * The time, in milliseconds since the unix epoch, at which the `Account` - * backing this `OlmMachine` was created. - * - * An `Account` is created when an `OlmMachine` is first instantiated - * against a given `Store`, at which point it creates identity keys etc. - * This method returns the timestamp, according to the local clock, at - * which that happened. - * @returns {number} - */ - get deviceCreationTimeMs() { - const ret = wasm.olmmachine_deviceCreationTimeMs(this.__wbg_ptr); - return ret; - } - /** - * The unique device ID that identifies this `OlmMachine`. - * @returns {DeviceId} - */ - get deviceId() { - const ret = wasm.olmmachine_deviceId(this.__wbg_ptr); - return DeviceId.__wrap(ret); - } - /** - * Disable and reset our backup state. - * - * This will remove any pending backup request, remove the backup key and - * reset the backup state of each room key we have. - * - * Returns `Promise`. - * @returns {Promise} - */ - disableBackup() { - const ret = wasm.olmmachine_disableBackup(this.__wbg_ptr); - return ret; - } - /** - * Get the display name of our own device. - * @returns {Promise} - */ - get displayName() { - const ret = wasm.olmmachine_displayName(this.__wbg_ptr); - return ret; - } - /** - * Activate the given backup key to be used with the given backup version. - * - * **Warning**: The caller needs to make sure that the given `BackupKey` is - * trusted, otherwise we might be encrypting room keys that a malicious - * party could decrypt. - * - * The {@link verifyBackup} method can be used to do so. - * - * Returns `Promise`. - * @param {string} public_key_base_64 - * @param {string} version - * @returns {Promise} - */ - enableBackupV1(public_key_base_64, version) { - const ptr0 = passStringToWasm0(public_key_base_64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(version, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_enableBackupV1(this.__wbg_ptr, ptr0, len0, ptr1, len1); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Encrypt the list of exported room keys using the given passphrase. - * - * `exported_room_keys` is a list of sessions that should be encrypted - * (it's generally returned by `export_room_keys`). `passphrase` is the - * passphrase that will be used to encrypt the exported room keys. And - * `rounds` is the number of rounds that should be used for the key - * derivation when the passphrase gets turned into an AES key. More rounds - * are increasingly computationnally intensive and as such help against - * brute-force attacks. Should be at least `10_000`, while values in the - * `100_000` ranges should be preferred. - * @param {string} exported_room_keys - * @param {string} passphrase - * @param {number} rounds - * @returns {string} - */ - static encryptExportedRoomKeys(exported_room_keys, passphrase, rounds) { - let deferred4_0; - let deferred4_1; - try { - const ptr0 = passStringToWasm0(exported_room_keys, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(passphrase, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_encryptExportedRoomKeys(ptr0, len0, ptr1, len1, rounds); - var ptr3 = ret[0]; - var len3 = ret[1]; - if (ret[3]) { - ptr3 = 0; - len3 = 0; - throw takeFromExternrefTable0(ret[2]); - } - deferred4_0 = ptr3; - deferred4_1 = len3; - return getStringFromWasm0(ptr3, len3); - } finally { - wasm.__wbindgen_free(deferred4_0, deferred4_1, 1); - } - } - /** - * Encrypt a room message for the given room. - * - * **Note**: A room key needs to be shared with the group of users that are - * members in the given room. If this is not done this method will panic. - * - * The usual flow to encrypt an event using this state machine is as - * follows: - * - * 1. Get the one-time key claim request to establish 1:1 Olm sessions for - * the room members of the room we wish to participate in. This is done - * using the [`get_missing_sessions()`](Self::get_missing_sessions) - * method. This method call should be locked per call. - * - * 2. Share a room key with all the room members using the - * [`share_room_key()`](Self::share_room_key). This method call should - * be locked per room. - * - * 3. Encrypt the event using this method. - * - * 4. Send the encrypted event to the server. - * - * After the room key is shared steps 1 and 2 will become noops, unless - * there's some changes in the room membership or in the list of devices a - * member has. - * - * - * `room_id` is the ID of the room for which the message should - * be encrypted. `event_type` is the type of the event. `content` - * is the plaintext content of the message that should be - * encrypted. - * - * # Panics - * - * Panics if a group session for the given room wasn't shared - * beforehand. - * @param {RoomId} room_id - * @param {string} event_type - * @param {string} content - * @returns {Promise} - */ - encryptRoomEvent(room_id, event_type, content) { - _assertClass(room_id, RoomId); - const ptr0 = passStringToWasm0(event_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_encryptRoomEvent(this.__wbg_ptr, room_id.__wbg_ptr, ptr0, len0, ptr1, len1); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Encrypt a state event for the given room. - * - * This method encrypts a state event for the specified room, using the - * current group session. The event will be encrypted so that only - * authorized room members can decrypt it. - * - * **Note**: A room key must have been shared with the group of users in - * the room before calling this method. If not, this method will panic. - * - * The usual flow to encrypt a state event using this machine is identical - * to that outlined for [`OlmMachine::encrypt_room_event`]. - * - * # Arguments - * - * * `room_id` - The ID of the room for which the state event should be - * encrypted. - * * `event_type` - The type of the state event. - * * `state_key` - The state key for the event. - * * `content` - The plaintext JSON content of the event to encrypt. - * - * # Returns - * - * A `Promise` resolving to a JSON string containing the encrypted event. - * - * # Panics - * - * Panics if a group session for the given room was not previously shared. - * @param {RoomId} room_id - * @param {string} event_type - * @param {string} state_key - * @param {string} content - * @returns {Promise} - */ - encryptStateEvent(room_id, event_type, state_key, content) { - _assertClass(room_id, RoomId); - const ptr0 = passStringToWasm0(event_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(state_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_encryptStateEvent(this.__wbg_ptr, room_id.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Export all the private cross signing keys we have. - * - * The export will contain the seeds for the ed25519 keys as - * unpadded base64 encoded strings. - * - * Returns `undefined` if we don’t have any private cross signing keys; - * otherwise returns a `CrossSigningKeyExport`. - * @returns {Promise} - */ - exportCrossSigningKeys() { - const ret = wasm.olmmachine_exportCrossSigningKeys(this.__wbg_ptr); - return ret; - } - /** - * Export the keys that match the given predicate. - * - * `predicate` is a closure that will be called for every known - * `InboundGroupSession`, which represents a room key. If the closure - * returns `true`, the `InboundGroupSession` will be included in the - * export; otherwise it won't. - * - * Returns a Promise containing a Result containing a String which is a - * JSON-encoded array of ExportedRoomKey objects. - * @param {(session: InboundGroupSession) => boolean} predicate - * @returns {Promise} - */ - exportRoomKeys(predicate) { - const ret = wasm.olmmachine_exportRoomKeys(this.__wbg_ptr, predicate); - return ret; - } - /** - * Export all the secrets we have in the store into a {@link - * SecretsBundle}. - * - * This method will export all the private cross-signing keys and, if - * available, the private part of a backup key and its accompanying - * version. - * - * The method will fail if we don't have all three private cross-signing - * keys available. - * - * **Warning**: Only export this and share it with a trusted recipient, - * i.e. if an existing device is sharing this with a new device. - * @returns {Promise} - */ - exportSecretsBundle() { - const ret = wasm.olmmachine_exportSecretsBundle(this.__wbg_ptr); - return ret; - } - /** - * Get a list of all rooms where we are waiting for a key bundle. - * - * @see getPendingKeyBundleDetailsForRoom - * - * @experimental - * @returns {Promise>} - */ - getAllRoomsPendingKeyBundles() { - const ret = wasm.olmmachine_getAllRoomsPendingKeyBundles(this.__wbg_ptr); - return ret; - } - /** - * Get the backup keys we have saved in our store. - * Returns a `Promise` for {@link BackupKeys}. - * @returns {Promise} - */ - getBackupKeys() { - const ret = wasm.olmmachine_getBackupKeys(this.__wbg_ptr); - return ret; - } - /** - * Get a specific device of a user. - * - * ### Parameters - * - * * `user_id` - The unique ID of the user that the device belongs to. - * - * * `device_id` - The unique ID of the device. - * - * * `timeout_secs` - The amount of time we should wait for a `/keys/query` - * response before returning if the user's device list has been marked as - * stale. **Note**, this assumes that the requests from {@link - * OlmMachine.outgoingRequests} are being processed and sent out. - * - * If unset, we will return immediately even if the device list is stale. - * - * ### Returns - * - * If the device is known, a {@link Device}. Otherwise, `undefined`. - * @param {UserId} user_id - * @param {DeviceId} device_id - * @param {number | null} [timeout_secs] - * @returns {Promise} - */ - getDevice(user_id, device_id, timeout_secs) { - _assertClass(user_id, UserId); - _assertClass(device_id, DeviceId); - const ret = wasm.olmmachine_getDevice(this.__wbg_ptr, user_id.__wbg_ptr, device_id.__wbg_ptr, !isLikeNone(timeout_secs), isLikeNone(timeout_secs) ? 0 : timeout_secs); - return ret; - } - /** - * Get the cross signing user identity of a user. - * - * Returns a promise for an {@link OwnUserIdentity}, a - * {@link OtherUserIdentity}, or `undefined`. - * @param {UserId} user_id - * @returns {Promise} - */ - getIdentity(user_id) { - _assertClass(user_id, UserId); - const ret = wasm.olmmachine_getIdentity(this.__wbg_ptr, user_id.__wbg_ptr); - return ret; - } - /** - * Get the a key claiming request for the user/device pairs that - * we are missing Olm sessions for. - * - * Returns `null` if no key claiming request needs to be sent - * out, otherwise it returns a `KeysClaimRequest` object. - * - * Sessions need to be established between devices so group - * sessions for a room can be shared with them. - * - * This should be called every time a group session needs to be - * shared as well as between sync calls. After a sync some - * devices may request room keys without us having a valid Olm - * session with them, making it impossible to server the room key - * request, thus it’s necessary to check for missing sessions - * between sync as well. - * - * Note: Care should be taken that only one such request at a - * time is in flight, e.g. using a lock. - * - * The response of a successful key claiming requests needs to be - * passed to the `OlmMachine` with the `mark_request_as_sent`. - * - * `users` represents the list of users that we should check if - * we lack a session with one of their devices. This can be an - * empty iterator when calling this method between sync requests. - * - * Items inside `users` will be invalidated by this method. Be careful not - * to use the `UserId`s after this method has been called. - * @param {UserId[]} users - * @returns {Promise} - */ - getMissingSessions(users) { - const ptr0 = passArrayJsValueToWasm0(users, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_getMissingSessions(this.__wbg_ptr, ptr0, len0); - return ret; - } - /** - * See if we have recently accepted an invitation to the given room. - * - * If we have accepted an invite to a room without finding an - * {@link https://github.com/matrix-org/matrix-spec-proposals/pull/4268|MSC4268} - * key bundle, we should accept a key bundle once one arrives. - * - * The data returned here is populated by the application, via {@link - * storeRoomPendingKeyBundle}. - * - * @experimental - * @param {RoomId} room_id - * @returns {Promise} - */ - getPendingKeyBundleDetailsForRoom(room_id) { - _assertClass(room_id, RoomId); - const ret = wasm.olmmachine_getPendingKeyBundleDetailsForRoom(this.__wbg_ptr, room_id.__wbg_ptr); - return ret; - } - /** - * See if we have received an {@link https://github.com/matrix-org/matrix-spec-proposals/pull/4268|MSC4268} - * room key bundle for the given room from the given user. - * - * Before calling this, the application must make sure that we have an - * up-to-date copy of the inviter's cross-signing keys, so that we can - * verify the device that sent us the key bundle data message. (For - * now, the easiest way to do that is by calling {@link queryKeysForUsers} - * for the inviter, and making the resultant request.) - * - * Returns either `undefined` if no suitable bundle has been received, - * or an {@link StoredRoomKeyBundleData}, in which case, the bundle - * should be downloaded, and then passed to {@link - * receiveRoomKeyBundle}. - * - * @experimental - * @param {RoomId} room_id - * @param {UserId} inviter - * @returns {Promise} - */ - getReceivedRoomKeyBundleData(room_id, inviter) { - _assertClass(room_id, RoomId); - _assertClass(inviter, UserId); - const ret = wasm.olmmachine_getReceivedRoomKeyBundleData(this.__wbg_ptr, room_id.__wbg_ptr, inviter.__wbg_ptr); - return ret; - } - /** - * Get encryption info for a decrypted timeline event. - * - * This recalculates the `EncryptionInfo` data that is returned by - * `decryptRoomEvent`, based on the current - * verification status of the sender, etc. - * - * Returns an error for an unencrypted event. - * - * # Arguments - * - * * `event` - The event to get information for. - * * `room_id` - The ID of the room where the event was sent to. - * - * # Returns - * - * {@link EncryptionInfo} - * @param {string} event - * @param {RoomId} room_id - * @returns {Promise} - */ - getRoomEventEncryptionInfo(event, room_id) { - const ptr0 = passStringToWasm0(event, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(room_id, RoomId); - const ret = wasm.olmmachine_getRoomEventEncryptionInfo(this.__wbg_ptr, ptr0, len0, room_id.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Get the stored room settings, such as the encryption algorithm or - * whether to encrypt only for trusted devices. - * - * These settings can be modified via {@link setRoomSettings}. - * - * # Returns - * - * `Promise` - * @param {RoomId} room_id - * @returns {Promise} - */ - getRoomSettings(room_id) { - _assertClass(room_id, RoomId); - const ret = wasm.olmmachine_getRoomSettings(this.__wbg_ptr, room_id.__wbg_ptr); - return ret; - } - /** - * Get all the secrets with the given secret_name we have currently - * stored. - * The only secret this will currently return is the - * `m.megolm_backup.v1` secret. - * - * Usually you would just register a callback with - * [`register_receive_secret_callback`], but if the client is shut down - * before handling them, this method can be used to retrieve them. - * This method should therefore be called at client startup to retrieve any - * secrets received during the previous session. - * - * The secrets are guaranteed to have been received over a 1-to-1 encrypted - * to_device message from one of the user's own verified devices. - * - * Returns a `Promise` for a `Set` of `String` corresponding to the secret - * values. - * - * If the secret is valid and handled, the secret inbox should be cleared - * by calling `delete_secrets_from_inbox`. - * @param {string} secret_name - * @returns {Promise>} - */ - getSecretsFromInbox(secret_name) { - const ptr0 = passStringToWasm0(secret_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_getSecretsFromInbox(this.__wbg_ptr, ptr0, len0); - return ret; - } - /** - * Get a map holding all the devices of a user. - * - * ### Parameters - * - * * `user_id` - The unique ID of the user that the device belongs to. - * - * * `timeout_secs` - The amount of time we should wait for a `/keys/query` - * response before returning if the user's device list has been marked as - * stale. **Note**, this assumes that the requests from {@link - * OlmMachine.outgoingRequests} are being processed and sent out. - * - * If unset, we will return immediately even if the device list is stale. - * - * ### Returns - * - * A {@link UserDevices} object. - * @param {UserId} user_id - * @param {number | null} [timeout_secs] - * @returns {Promise} - */ - getUserDevices(user_id, timeout_secs) { - _assertClass(user_id, UserId); - const ret = wasm.olmmachine_getUserDevices(this.__wbg_ptr, user_id.__wbg_ptr, !isLikeNone(timeout_secs), isLikeNone(timeout_secs) ? 0 : timeout_secs); - return ret; - } - /** - * Get a verification object for the given user ID with the given - * flow ID (a to-device request ID if the verification has been - * requested by a to-device request, or a room event ID if the - * verification has been requested by a room event). - * - * It returns a “`Verification` object”, which is either a `Sas` - * or `Qr` object. - * @param {UserId} user_id - * @param {string} flow_id - * @returns {Sas | Qr | undefined} - */ - getVerification(user_id, flow_id) { - _assertClass(user_id, UserId); - const ptr0 = passStringToWasm0(flow_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_getVerification(this.__wbg_ptr, user_id.__wbg_ptr, ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Get a verification request object with the given flow ID. - * @param {UserId} user_id - * @param {string} flow_id - * @returns {VerificationRequest | undefined} - */ - getVerificationRequest(user_id, flow_id) { - _assertClass(user_id, UserId); - const ptr0 = passStringToWasm0(flow_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_getVerificationRequest(this.__wbg_ptr, user_id.__wbg_ptr, ptr0, len0); - return ret === 0 ? undefined : VerificationRequest.__wrap(ret); - } - /** - * Get all the verification requests of a given user. - * @param {UserId} user_id - * @returns {VerificationRequest[]} - */ - getVerificationRequests(user_id) { - _assertClass(user_id, UserId); - const ret = wasm.olmmachine_getVerificationRequests(this.__wbg_ptr, user_id.__wbg_ptr); - return ret; - } - /** - * Get whether we have previously downloaded all message keys for a - * particular room from the key backup. Typically called in advance of - * building a room key bundle. - * @param {RoomId} room_id - * @returns {Promise} - */ - hasDownloadedAllRoomKeys(room_id) { - _assertClass(room_id, RoomId); - const ret = wasm.olmmachine_hasDownloadedAllRoomKeys(this.__wbg_ptr, room_id.__wbg_ptr); - return ret; - } - /** - * Get the public parts of our Olm identity keys. - * @returns {IdentityKeys} - */ - get identityKeys() { - const ret = wasm.olmmachine_identityKeys(this.__wbg_ptr); - return IdentityKeys.__wrap(ret); - } - /** - * Import the given room keys into our store. - * - * # Arguments - * - * * `backed_up_room_keys`: keys that were retrieved from backup and that - * should be added to our store (provided they are better than our - * current versions of those keys). Specifically, it should be a Map from - * {@link RoomId}, to a Map from session ID to a (decrypted) session data - * structure. - * - * * `progress_listener`: an optional callback that takes 3 arguments: - * `progress` (the number of keys that have successfully been imported), - * `total` (the total number of keys), and `failures` (the number of keys - * that failed to import), and returns nothing. - * - * # Returns - * - * A {@link RoomKeyImportResult}. - * @param {Map>} backed_up_room_keys - * @param {(progress: bigint, total: bigint, failures: bigint) => void | undefined} progress_listener - * @param {string} backup_version - * @returns {Promise} - */ - importBackedUpRoomKeys(backed_up_room_keys, progress_listener, backup_version) { - const ptr0 = passStringToWasm0(backup_version, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_importBackedUpRoomKeys(this.__wbg_ptr, backed_up_room_keys, isLikeNone(progress_listener) ? 0 : addToExternrefTable0(progress_listener), ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Import our private cross signing keys. - * - * The keys should be provided as unpadded-base64-encoded strings. - * - * Returns a `CrossSigningStatus`. - * @param {string | null} [master_key] - * @param {string | null} [self_signing_key] - * @param {string | null} [user_signing_key] - * @returns {Promise} - */ - importCrossSigningKeys(master_key, self_signing_key, user_signing_key) { - var ptr0 = isLikeNone(master_key) ? 0 : passStringToWasm0(master_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - var ptr1 = isLikeNone(self_signing_key) ? 0 : passStringToWasm0(self_signing_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len1 = WASM_VECTOR_LEN; - var ptr2 = isLikeNone(user_signing_key) ? 0 : passStringToWasm0(user_signing_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len2 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_importCrossSigningKeys(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2); - return ret; - } - /** - * Import the given room keys into our store. - * - * `exported_keys` is a JSON-encoded list of previously exported keys that - * should be imported into our store. If we already have a better - * version of a key, the key will _not_ be imported. - * - * `progress_listener` is a closure that takes 2 `BigInt` arguments: - * `progress` and `total`, and returns nothing. - * - * Returns a {@link RoomKeyImportResult}. - * @param {string} exported_room_keys - * @param {(progress: bigint, total: bigint) => void} progress_listener - * @returns {Promise} - */ - importExportedRoomKeys(exported_room_keys, progress_listener) { - const ptr0 = passStringToWasm0(exported_room_keys, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_importExportedRoomKeys(this.__wbg_ptr, ptr0, len0, progress_listener); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Import the given room keys into our store. - * - * Mostly, a deprecated alias for `importExportedRoomKeys`, though the - * return type is different. - * - * Returns a String containing a JSON-encoded object, holding three - * properties: - * * `total_count` (the total number of keys found in the export data). - * * `imported_count` (the number of keys that were imported). - * * `keys` (the keys that were imported; a map from room id to a map of - * the sender key to a list of session ids). - * - * @deprecated Use `importExportedRoomKeys` or `importBackedUpRoomKeys`. - * @param {string} exported_room_keys - * @param {(imported: bigint, total: bigint) => void} progress_listener - * @returns {Promise} - */ - importRoomKeys(exported_room_keys, progress_listener) { - const ptr0 = passStringToWasm0(exported_room_keys, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_importRoomKeys(this.__wbg_ptr, ptr0, len0, progress_listener); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Import and persists secrets from a {@link SecretsBundle}. - * - * This method will import all the private cross-signing keys and, if - * available, the private part of a backup key and its accompanying - * version into the store. - * - * **Warning**: Only import this from a trusted source, i.e. if an existing - * device is sharing this with a new device. The imported cross-signing - * keys will create a {@link OwnUserIdentity} and mark it as verified. - * - * The backup key will be persisted in the store and can be enabled using - * the BackupMachine. - * - * The provided `SecretsBundle` is freed by this method; be careful not to - * use it once this method has been called. - * @param {SecretsBundle} bundle - * @returns {Promise} - */ - importSecretsBundle(bundle) { - _assertClass(bundle, SecretsBundle); - var ptr0 = bundle.__destroy_into_raw(); - const ret = wasm.olmmachine_importSecretsBundle(this.__wbg_ptr, ptr0); - return ret; - } - /** - * Create a new `OlmMachine` backed by an existing store. - * - * # Arguments - * - * * `user_id` - represents the unique ID of the user that owns this - * machine. - * - * * `device_id` - represents the unique ID of the device - * that owns this machine. - * - * * `store_handle` - the connection to the crypto store to be used for - * this machine. - * - * * `logger` - Optional logger to use for all operations on this machine. - * An instance of `JsLogger`. - * - * * `ca_certs_pem` - Optional PEM-formatted string that provides CA - * certificates. These will be used to check X.509 signatures on user - * identities. Any user identity that has a valid signature according to - * the supplied CAs will be considered verified, without any manual - * - * * `raw_x509_signer` - Optional async function for signing some data with - * an X.509 certificate. Used to sign the user's identity so compatible - * clients will recognise this user as verified without manual - * verification taking place. If you supply this you must also supply - * raw_x509_validity. - * - * * `raw_x509_validity` - Optional function returning the validity period - * of the X.509 certificate used for signing, as the number of - * milliseconds since the Unix epoch. If you supply this you must also - * supply raw_x509_signer. - * @param {UserId} user_id - * @param {DeviceId} device_id - * @param {StoreHandle} store_handle - * @param {JsLogger} [logger] - * @param {String} [ca_certs_pem] - * @param {(item: Uint8Array) => Promise<{ signature_bytes: Uint8Array, certificate_chain: string }>} [raw_x509_signer] - * @param {() => number} [raw_x509_validity] - * @returns {Promise} - */ - static initFromStore(user_id, device_id, store_handle, logger, ca_certs_pem, raw_x509_signer, raw_x509_validity) { - _assertClass(user_id, UserId); - _assertClass(device_id, DeviceId); - _assertClass(store_handle, StoreHandle); - var ptr0 = isLikeNone(ca_certs_pem) ? 0 : passStringToWasm0(ca_certs_pem, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_initFromStore(user_id.__wbg_ptr, device_id.__wbg_ptr, store_handle.__wbg_ptr, isLikeNone(logger) ? 0 : addToExternrefTable0(logger), ptr0, len0, isLikeNone(raw_x509_signer) ? 0 : addToExternrefTable0(raw_x509_signer), isLikeNone(raw_x509_validity) ? 0 : addToExternrefTable0(raw_x509_validity)); - return ret; - } - /** - * Create a new `OlmMachine`. - * - * The created machine will keep the encryption keys either in a IndexedDB - * based store, or in a memory store and once the objects is dropped, - * the keys will be lost. - * - * # Arguments - * - * * `user_id` - represents the unique ID of the user that owns this - * machine. - * - * * `device_id` - represents the unique ID of the device - * that owns this machine. - * - * * `store_name` - The name that should be used to open the IndexedDB - * based database. If this isn't provided, a memory-only store will be - * used. *Note* the memory-only store will lose your E2EE keys when the - * `OlmMachine` gets dropped. - * - * * `store_passphrase` - The passphrase that should be used to encrypt the - * IndexedDB-based store. - * - * * `logger` - Optional logger to use for all operations on this machine. - * An instance of `JsLogger`. - * - * * `ca_certs_pem` - Optional PEM-formatted string that provides CA - * certificates. These will be used to check X.509 signatures on user - * identities. Any user identity that has a valid signature according to - * the supplied CAs will be considered verified, without any manual - * verification taking place. A PEM-formatted string. - * - * * `raw_x509_signer` - Optional async function for signing some data with - * an X.509 certificate. Used to sign the user's identity so compatible - * clients will recognise this user as verified without manual - * verification taking place. If you supply this you must also supply - * raw_x509_validity. - * - * * `raw_x509_validity` - Optional function returning the validity period - * of the X.509 certificate used for signing, as the number of - * milliseconds since the Unix epoch. If you supply this you must also - * supply raw_x509_signer. - * @param {UserId} user_id - * @param {DeviceId} device_id - * @param {string} [store_name] - * @param {string} [store_passphrase] - * @param {JsLogger} [logger] - * @param {String} [ca_certs_pem] - * @param {(item: Uint8Array) => Promise<{ signature_bytes: Uint8Array, certificate_chain: string }>} [raw_x509_signer] - * @param {() => number} [raw_x509_validity] - * @returns {Promise} - */ - static initialize(user_id, device_id, store_name, store_passphrase, logger, ca_certs_pem, raw_x509_signer, raw_x509_validity) { - _assertClass(user_id, UserId); - _assertClass(device_id, DeviceId); - var ptr0 = isLikeNone(store_name) ? 0 : passStringToWasm0(store_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - var ptr1 = isLikeNone(store_passphrase) ? 0 : passStringToWasm0(store_passphrase, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len1 = WASM_VECTOR_LEN; - var ptr2 = isLikeNone(ca_certs_pem) ? 0 : passStringToWasm0(ca_certs_pem, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len2 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_initialize(user_id.__wbg_ptr, device_id.__wbg_ptr, ptr0, len0, ptr1, len1, isLikeNone(logger) ? 0 : addToExternrefTable0(logger), ptr2, len2, isLikeNone(raw_x509_signer) ? 0 : addToExternrefTable0(raw_x509_signer), isLikeNone(raw_x509_validity) ? 0 : addToExternrefTable0(raw_x509_validity)); - return ret; - } - /** - * Invalidate the currently active outbound group session for the - * given room. - * - * Returns true if a session was invalidated, false if there was - * no session to invalidate. - * @param {RoomId} room_id - * @returns {Promise} - */ - invalidateGroupSession(room_id) { - _assertClass(room_id, RoomId); - const ret = wasm.olmmachine_invalidateGroupSession(this.__wbg_ptr, room_id.__wbg_ptr); - return ret; - } - /** - * Are we able to encrypt room keys. - * - * This returns true if we have an active `BackupKey` and backup version - * registered with the state machine. - * - * Returns `Promise`. - * @returns {Promise} - */ - isBackupEnabled() { - const ret = wasm.olmmachine_isBackupEnabled(this.__wbg_ptr); - return ret; - } - /** - * Mark all tracked users as dirty. - * - * All users *whose device lists we are tracking* are flagged as needing a - * key query. Users whose devices we are not tracking are ignored. - * @returns {Promise} - */ - markAllTrackedUsersAsDirty() { - const ret = wasm.olmmachine_markAllTrackedUsersAsDirty(this.__wbg_ptr); - return ret; - } - /** - * Mark the request with the given request ID as sent (see - * `outgoing_requests`). - * - * Arguments are: - * - * * `request_id` represents the unique ID of the request that was sent - * out. This is needed to couple the response with the now sent out - * request. - * * `response_type` represents the type of the request that was sent out. - * * `response` represents the response that was received from the server - * after the outgoing request was sent out. - * @param {string} request_id - * @param {RequestType} request_type - * @param {string} response - * @returns {Promise} - */ - markRequestAsSent(request_id, request_type, response) { - const ptr0 = passStringToWasm0(request_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(response, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_markRequestAsSent(this.__wbg_ptr, ptr0, len0, request_type, ptr1, len1); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Constructor will always fail. To create a new `OlmMachine`, please use - * the `initialize` method. - * - * Why this pattern? `initialize` returns a `Promise`. Returning a - * `Promise` from a constructor is not idiomatic in JavaScript. - */ - constructor() { - const ret = wasm.olmmachine_new(); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - this.__wbg_ptr = ret[0]; - OlmMachineFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Get the outgoing requests that need to be sent out. - * - * This returns a list of values, each of which can be any of: - * * {@link KeysUploadRequest}, - * * {@link KeysQueryRequest}, - * * {@link KeysClaimRequest}, - * * {@link ToDeviceRequest}, - * * {@link SignatureUploadRequest}, - * * {@link RoomMessageRequest}, or - * * {@link KeysBackupRequest}. - * - * Those requests need to be sent out to the server and the - * responses need to be passed back to the state machine - * using {@link OlmMachine.markRequestAsSent}. - * @returns {Promise} - */ - outgoingRequests() { - const ret = wasm.olmmachine_outgoingRequests(this.__wbg_ptr); - return ret; - } - /** - * Push a secret to all of our other verified devices - * - * This function assumes that we already have Olm sessions with the other - * devices. This can be done by calling {@link - * OlmMachine.getMissingSessions}. - * - * # Arguments - * - * * `secret_name` - The name of the secret to push. - * @param {string} name - * @returns {Promise} - */ - pushSecretToVerifiedDevices(name) { - const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_pushSecretToVerifiedDevices(this.__wbg_ptr, ptr0, len0); - return ret; - } - /** - * Generate an "out-of-band" key query request for the given set of users. - * - * This can be useful if we need the results from `getIdentity` or - * `getUserDevices` to be as up-to-date as possible. - * - * Returns a `KeysQueryRequest` object. The response of the request should - * be passed to the `OlmMachine` with the `mark_request_as_sent`. - * - * Items inside `users` will be invalidated by this method. Be careful not - * to use the `UserId`s after this method has been called. - * @param {UserId[]} users - * @returns {KeysQueryRequest} - */ - queryKeysForUsers(users) { - const ptr0 = passArrayJsValueToWasm0(users, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_queryKeysForUsers(this.__wbg_ptr, ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return KeysQueryRequest.__wrap(ret[0]); - } - /** - * Import the message keys from a downloaded room key bundle. - * - * After {@link getReceivedRoomKeyBundleData} returns a truthy result, the - * media file should be downloaded and then passed into this method to - * actually do the import. - * - * @experimental - * @param {StoredRoomKeyBundleData} bundle_data - * @param {Uint8Array} encrypted_bundle - * @returns {Promise} - */ - receiveRoomKeyBundle(bundle_data, encrypted_bundle) { - _assertClass(bundle_data, StoredRoomKeyBundleData); - var ptr0 = bundle_data.__destroy_into_raw(); - const ptr1 = passArray8ToWasm0(encrypted_bundle, wasm.__wbindgen_malloc); - const len1 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_receiveRoomKeyBundle(this.__wbg_ptr, ptr0, ptr1, len1); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Handle to-device events and one-time key counts from a sync - * response. - * - * This will decrypt and handle to-device events returning the - * decrypted versions of them. - * - * To decrypt an event from the room timeline call - * `decrypt_room_event`. - * - * # Arguments - * - * * `to_device_events`: the JSON-encoded to-device evens from the `/sync` - * response - * * `changed_devices`: the mapping of changed and left devices, from the - * `/sync` response - * * `one_time_keys_counts`: The number of one-time keys on the server, - * from the `/sync` response. A `Map` from string (encryption algorithm) - * to number (number of keys). Following the sync v2 semantics, a missing - * entry for an algorithm means that there are *zero* keys of that type - * on the server. If the caller has no information about the key counts - * (for example, because it is processing only part of a sync response), - * it should use {@link receiveSyncChangesMsc4186} instead. - * * `unused_fallback_keys`: Optionally, a `Set` of unused fallback keys on - * the server, from the `/sync` response. If this is set, it is used to - * determine if new fallback keys should be uploaded. - * * `decryption_settings`: Optionally, the settings to use when decrypting - * to-device events. If not set, to-device events will be decrypted with - * a {@link TrustRequirement} of `Untrusted`. - * - * # Returns - * - * A list of values, each of which can be any of: - * * {@link DecryptedToDeviceEvent} - * * {@link PlainTextToDeviceEvent} - * * {@link UTDToDeviceEvent} - * * {@link InvalidToDeviceEvent} - * @param {string} to_device_events - * @param {DeviceLists} changed_devices - * @param {Map} one_time_keys_counts - * @param {Set} [unused_fallback_keys] - * @param {DecryptionSettings} [decryption_settings] - * @returns {Promise} - */ - receiveSyncChanges(to_device_events, changed_devices, one_time_keys_counts, unused_fallback_keys, decryption_settings) { - const ptr0 = passStringToWasm0(to_device_events, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(changed_devices, DeviceLists); - let ptr1 = 0; - if (!isLikeNone(decryption_settings)) { - _assertClass(decryption_settings, DecryptionSettings); - ptr1 = decryption_settings.__destroy_into_raw(); - } - const ret = wasm.olmmachine_receiveSyncChanges(this.__wbg_ptr, ptr0, len0, changed_devices.__wbg_ptr, one_time_keys_counts, isLikeNone(unused_fallback_keys) ? 0 : addToExternrefTable0(unused_fallback_keys), ptr1); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Handle the changes to the end-to-end encryption state we received from - * a [MSC4186](https://github.com/matrix-org/matrix-spec-proposals/pull/4186) - * (simplified sliding sync) response. - * - * This behaves exactly like {@link receiveSyncChanges}, except for the - * handling of `one_time_keys_counts`: under MSC4186 semantics, a missing - * entry for an algorithm means that the number of keys on the server is - * *unchanged*, rather than zero. - * - * This is therefore also the method to use when the caller has no - * information about the one-time key counts, for example because it is - * processing only the to-device events or the device list changes from a - * sync response. - * - * # Arguments - * - * * `to_device_events`: the JSON-encoded to-device events from the sync - * response - * * `changed_devices`: the mapping of changed and left devices, from the - * sync response - * * `one_time_keys_counts`: The number of one-time keys on the server, - * from the sync response. A `Map` from string (encryption algorithm) to - * number (number of keys). A missing entry means "unchanged". - * * `unused_fallback_keys`: Optionally, a `Set` of unused fallback keys on - * the server, from the sync response. If this is set, it is used to - * determine if new fallback keys should be uploaded. - * * `decryption_settings`: Optionally, the settings to use when decrypting - * to-device events. If not set, to-device events will be decrypted with - * a {@link TrustRequirement} of `Untrusted`. - * - * # Returns - * - * A list of values, each of which can be any of: - * * {@link DecryptedToDeviceEvent} - * * {@link PlainTextToDeviceEvent} - * * {@link UTDToDeviceEvent} - * * {@link InvalidToDeviceEvent} - * @param {string} to_device_events - * @param {DeviceLists} changed_devices - * @param {Map} one_time_keys_counts - * @param {Set} [unused_fallback_keys] - * @param {DecryptionSettings} [decryption_settings] - * @returns {Promise} - */ - receiveSyncChangesMsc4186(to_device_events, changed_devices, one_time_keys_counts, unused_fallback_keys, decryption_settings) { - const ptr0 = passStringToWasm0(to_device_events, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(changed_devices, DeviceLists); - let ptr1 = 0; - if (!isLikeNone(decryption_settings)) { - _assertClass(decryption_settings, DecryptionSettings); - ptr1 = decryption_settings.__destroy_into_raw(); - } - const ret = wasm.olmmachine_receiveSyncChangesMsc4186(this.__wbg_ptr, ptr0, len0, changed_devices.__wbg_ptr, one_time_keys_counts, isLikeNone(unused_fallback_keys) ? 0 : addToExternrefTable0(unused_fallback_keys), ptr1); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Receive a verification event. - * - * This method can be used to pass verification events that are happening - * in rooms to the `OlmMachine`. The event should be in the decrypted form. - * @param {string} event - * @param {RoomId} room_id - * @returns {Promise} - */ - receiveVerificationEvent(event, room_id) { - const ptr0 = passStringToWasm0(event, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(room_id, RoomId); - const ret = wasm.olmmachine_receiveVerificationEvent(this.__wbg_ptr, ptr0, len0, room_id.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Register a callback which will be called whenever there is an update to - * a device. - * - * `callback` should be a function that takes a single argument (an array - * of user IDs as strings) and returns a Promise. - * @param {(userIds: string[]) => Promise} callback - */ - registerDevicesUpdatedCallback(callback) { - wasm.olmmachine_registerDevicesUpdatedCallback(this.__wbg_ptr, callback); - } - /** - * Register a callback which will be called whenever a secret - * (`m.secret.send`) is received. - * - * The only secret this will currently broadcast is the - * `m.megolm_backup.v1` (the cross signing secrets are handled internally). - * - * To request a secret from other devices, a client sends an - * `m.secret.request` device event with `action` set to `request` and - * `name` set to the identifier of the secret. A device that wishes to - * share the secret will reply with an `m.secret.send` event, encrypted - * using olm. - * - * The secrets are guaranteed to have been received over a 1-to-1 encrypted - * to_device message from a one of the user's own verified devices. - * - * See https://matrix-org.github.io/matrix-rust-sdk/matrix_sdk_crypto/store/struct.Store.html#method.secrets_stream for more information. - * - * `callback` should be a function that takes 2 arguments: the secret name - * (string) and value (string). - * - * **Note**: if the secret is valid and handled on the javascript side, the - * secret inbox should be cleared by calling - * `delete_secrets_from_inbox`. - * @param {(name: string, value: string) => Promise} callback - */ - registerReceiveSecretCallback(callback) { - wasm.olmmachine_registerReceiveSecretCallback(this.__wbg_ptr, callback); - } - /** - * Register a callback which will be called whenever there is an update to - * a room key. - * - * `callback` should be a function that takes a single argument (an array - * of {@link RoomKeyInfo}) and returns a Promise. - * @param {(info: RoomKeyInfo[]) => Promise} callback - */ - registerRoomKeyUpdatedCallback(callback) { - wasm.olmmachine_registerRoomKeyUpdatedCallback(this.__wbg_ptr, callback); - } - /** - * Register a callback which will be called whenever we receive a - * notification that some room keys have been withheld. - * - * `callback` should be a function that takes a single argument (an array - * of {@link RoomKeyWithheldInfo}) and returns a Promise. - * @param {(info: RoomKeyWithheldInfo[]) => Promise} callback - */ - registerRoomKeysWithheldCallback(callback) { - wasm.olmmachine_registerRoomKeysWithheldCallback(this.__wbg_ptr, callback); - } - /** - * Register a callback which will be called whenever there is an update to - * a user identity. - * - * `callback` should be a function that takes a single argument (a {@link - * UserId}) and returns a Promise. - * @param {(id: UserId) => Promise} callback - */ - registerUserIdentityUpdatedCallback(callback) { - wasm.olmmachine_registerUserIdentityUpdatedCallback(this.__wbg_ptr, callback); - } - /** - * Request missing local secrets from our other trusted devices. - * - * "Local secrets" refers to secrets which can be shared between trusted - * devices, such as private cross-signing keys, and the megolm backup - * decryption key. - * - * This method will cause the sdk to generated outgoing secret requests - * (`m.secret.request`) to get the missing secrets. These requests will - * then be returned by a future call to {@link - * OlmMachine#outgoingRequests}. - * - * # Returns - * - * A `Promise` for a `bool` result, which will be true if secrets were - * missing, and a request was generated. - * @returns {Promise} - */ - requestMissingSecretsIfNeeded() { - const ret = wasm.olmmachine_requestMissingSecretsIfNeeded(this.__wbg_ptr); - return ret; - } - /** - * Get the number of backed up room keys and the total number of room keys. - * Returns a {@link RoomKeyCounts}. - * @returns {Promise} - */ - roomKeyCounts() { - const ret = wasm.olmmachine_roomKeyCounts(this.__wbg_ptr); - return ret; - } - /** - * Whether room key forwarding is enabled. - * - * If room key forwarding is enabled, we will automatically reply to - * incoming `m.room_key_request` messages from verified devices by - * forwarding the requested key (if we have it). - * @returns {boolean} - */ - get roomKeyForwardingEnabled() { - const ret = wasm.olmmachine_roomKeyForwardingEnabled(this.__wbg_ptr); - return ret !== 0; - } - /** - * Whether automatic transmission of room key requests is enabled. - * - * Room key requests allow the device to request room keys that it might - * have missed in the original share using `m.room_key_request` - * events. - * @returns {boolean} - */ - get roomKeyRequestsEnabled() { - const ret = wasm.olmmachine_roomKeyRequestsEnabled(this.__wbg_ptr); - return ret !== 0; - } - /** - * Store the backup decryption key in the crypto store. - * - * This is useful if the client wants to support gossiping of the backup - * key. - * - * Returns `Promise`. - * @param {BackupDecryptionKey} decryption_key - * @param {string} version - * @returns {Promise} - */ - saveBackupDecryptionKey(decryption_key, version) { - _assertClass(decryption_key, BackupDecryptionKey); - const ptr0 = passStringToWasm0(version, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_saveBackupDecryptionKey(this.__wbg_ptr, decryption_key.__wbg_ptr, ptr0, len0); - return ret; - } - /** - * Record that we have downloaded all message keys for the given room. - * @param {RoomId} room_id - * @returns {Promise} - */ - setHasDownloadedAllRoomKeys(room_id) { - _assertClass(room_id, RoomId); - const ret = wasm.olmmachine_setHasDownloadedAllRoomKeys(this.__wbg_ptr, room_id.__wbg_ptr); - return ret; - } - /** - * Store encryption settings for the given room. - * - * This method checks if the new settings are "safe" -- ie, that they do - * not represent a downgrade in encryption security from any previous - * settings. Attempts to downgrade security will result in an error. - * - * If the settings are valid, they will be persisted to the crypto store. - * These settings are not used directly by this library, but the saved - * settings can be retrieved via {@link getRoomSettings}. - * @param {RoomId} room_id - * @param {RoomSettings} room_settings - * @returns {Promise} - */ - setRoomSettings(room_id, room_settings) { - _assertClass(room_id, RoomId); - _assertClass(room_settings, RoomSettings); - const ret = wasm.olmmachine_setRoomSettings(this.__wbg_ptr, room_id.__wbg_ptr, room_settings.__wbg_ptr); - return ret; - } - /** - * Enable or disable room key forwarding. - * @param {boolean} enabled - */ - set roomKeyForwardingEnabled(enabled) { - wasm.olmmachine_set_roomKeyForwardingEnabled(this.__wbg_ptr, enabled); - } - /** - * Enable or disable automatic transmission of room key requests. - * @param {boolean} enabled - */ - set roomKeyRequestsEnabled(enabled) { - wasm.olmmachine_set_roomKeyRequestsEnabled(this.__wbg_ptr, enabled); - } - /** - * Get to-device requests to share a room key with users in a room. - * - * `room_id` is the room ID. `users` is an array of `UserId` - * objects. `encryption_settings` are an `EncryptionSettings` - * object. - * - * Note: Care should be taken that only one such request at a - * time is in flight for the same room, e.g. using a lock. - * - * Returns an array of `ToDeviceRequest`s. - * - * Items inside `users` will be invalidated by this method. Be careful not - * to use the `UserId`s after this method has been called. - * @param {RoomId} room_id - * @param {UserId[]} users - * @param {EncryptionSettings} encryption_settings - * @returns {Promise} - */ - shareRoomKey(room_id, users, encryption_settings) { - _assertClass(room_id, RoomId); - const ptr0 = passArrayJsValueToWasm0(users, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(encryption_settings, EncryptionSettings); - const ret = wasm.olmmachine_shareRoomKey(this.__wbg_ptr, room_id.__wbg_ptr, ptr0, len0, encryption_settings.__wbg_ptr); - return ret; - } - /** - * Collect the devices belonging to the given user, and send the details - * of a room key bundle to those devices. - * - * Returns a list of to-device requests which must be sent. - * - * @experimental - * @param {UserId} user - * @param {RoomId} room - * @param {string} url - * @param {string | null | undefined} media_encryption_info - * @param {CollectStrategy} sharing_strategy - * @returns {Promise} - */ - shareRoomKeyBundleData(user, room, url, media_encryption_info, sharing_strategy) { - _assertClass(user, UserId); - _assertClass(room, RoomId); - const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - var ptr1 = isLikeNone(media_encryption_info) ? 0 : passStringToWasm0(media_encryption_info, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len1 = WASM_VECTOR_LEN; - _assertClass(sharing_strategy, CollectStrategy); - var ptr2 = sharing_strategy.__destroy_into_raw(); - const ret = wasm.olmmachine_shareRoomKeyBundleData(this.__wbg_ptr, user.__wbg_ptr, room.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Sign the given message using our device key and if available - * cross-signing master key. - * @param {string} message - * @returns {Promise} - */ - sign(message) { - const ptr0 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_sign(this.__wbg_ptr, ptr0, len0); - return ret; - } - /** - * Store the fact that we have accepted an invitation to the given room, so - * should accept a key bundle if one arrives soon. - * - * This should be called whenever we join a room following an invite, but - * it has no effect other than that the room will be returned by a future - * call to {@link getPendingKeyBundleDetailsForRoom}. - * - * @experimental - * @param {RoomId} room_id - * @param {UserId} inviter - * @returns {Promise} - */ - storeRoomPendingKeyBundle(room_id, inviter) { - _assertClass(room_id, RoomId); - _assertClass(inviter, UserId); - const ret = wasm.olmmachine_storeRoomPendingKeyBundle(this.__wbg_ptr, room_id.__wbg_ptr, inviter.__wbg_ptr); - return ret; - } - /** - * Get the list of users whose devices we are currently tracking. - * - * A user can be marked for tracking using the - * [`update_tracked_users`](#method.update_tracked_users) method. - * - * Returns a `Set`. - * @returns {Promise>} - */ - trackedUsers() { - const ret = wasm.olmmachine_trackedUsers(this.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Update the list of tracked users. - * - * The OlmMachine maintains a list of users whose devices we are keeping - * track of: these are known as "tracked users". These must be users - * that we share a room with, so that the server sends us updates for - * their device lists. - * - * # Arguments - * - * * `users` - An array of user ids that should be added to the list of - * tracked users - * - * Any users that hadn't been seen before will be flagged for a key query - * immediately, and whenever `receive_sync_changes` receives a - * "changed" notification for that user in the future. - * - * Users that were already in the list are unaffected. - * - * Items inside `users` will be invalidated by this method. Be careful not - * to use the `UserId`s after this method has been called. - * @param {UserId[]} users - * @returns {Promise} - */ - updateTrackedUsers(users) { - const ptr0 = passArrayJsValueToWasm0(users, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_updateTrackedUsers(this.__wbg_ptr, ptr0, len0); - return ret; - } - /** - * The unique user ID that owns this `OlmMachine` instance. - * @returns {UserId} - */ - get userId() { - const ret = wasm.olmmachine_userId(this.__wbg_ptr); - return UserId.__wrap(ret); - } - /** - * Check if the given backup has been verified by us or by another of our - * devices that we trust. - * - * The `backup_info` should be a Javascript object with the following - * format: - * - * ```json - * { - * "algorithm": "m.megolm_backup.v1.curve25519-aes-sha2", - * "auth_data": { - * "public_key":"XjhWTCjW7l59pbfx9tlCBQolfnIQWARoKOzjTOPSlWM", - * "signatures": {} - * } - * } - * ``` - * - * Returns a {@link SignatureVerification} object. - * @param {any} backup_info - * @returns {Promise} - */ - verifyBackup(backup_info) { - const ret = wasm.olmmachine_verifyBackup(this.__wbg_ptr, backup_info); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } -} -exports.OlmMachine = OlmMachine; -if (Symbol.dispose) OlmMachine.prototype[Symbol.dispose] = OlmMachine.prototype.free; - -/** - * Struct representing a cross signing identity of a user. - * - * This is the user identity of a user that isn't our own. Other users will - * only contain a master key and a self signing key, meaning that only device - * signatures can be checked with this identity. - * - * This struct wraps a read-only version of the struct and allows verifications - * to be requested to verify our own device with the user identity. - */ -class OtherUserIdentity { - static __wrap(ptr) { - const obj = Object.create(OtherUserIdentity.prototype); - obj.__wbg_ptr = ptr; - OtherUserIdentityFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - OtherUserIdentityFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_otheruseridentity_free(ptr, 0); - } - /** - * Was this identity verified since initial observation and is not anymore? - * - * Such a violation should be reported to the local user by the - * application, and resolved by - * - * - Verifying the new identity with {@link requestVerification}, or: - * - Withdrawing the verification requirement with {@link - * withdrawVerification}. - * @returns {boolean} - */ - hasVerificationViolation() { - const ret = wasm.otheruseridentity_hasVerificationViolation(this.__wbg_ptr); - return ret !== 0; - } - /** - * Has the identity changed in a way that requires approval from the user? - * - * A user identity needs approval if it changed after the crypto machine - * has already observed ("pinned") a different identity for that user, - * unless it is an explicitly verified identity (using for example - * interactive verification). - * - * This situation can be resolved by: - * - * - Verifying the new identity with {@link requestVerification}, or: - * - Updating the pin to the new identity with {@link pinCurrentMasterKey}. - * @returns {boolean} - */ - identityNeedsUserApproval() { - const ret = wasm.otheruseridentity_identityNeedsUserApproval(this.__wbg_ptr); - return ret !== 0; - } - /** - * Is this user identity verified? - * @returns {boolean} - */ - isVerified() { - const ret = wasm.otheruseridentity_isVerified(this.__wbg_ptr); - return ret !== 0; - } - /** - * Get the master key of the identity. - * @returns {string} - */ - get masterKey() { - let deferred2_0; - let deferred2_1; - try { - const ret = wasm.otheruseridentity_masterKey(this.__wbg_ptr); - var ptr1 = ret[0]; - var len1 = ret[1]; - if (ret[3]) { - ptr1 = 0; - len1 = 0; - throw takeFromExternrefTable0(ret[2]); - } - deferred2_0 = ptr1; - deferred2_1 = len1; - return getStringFromWasm0(ptr1, len1); - } finally { - wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); - } - } - /** - * Pin the current identity (public part of the master signing key). - * @returns {Promise} - */ - pinCurrentMasterKey() { - const ret = wasm.otheruseridentity_pinCurrentMasterKey(this.__wbg_ptr); - return ret; - } - /** - * Create a `VerificationRequest` object after the verification - * request content has been sent out. - * @param {RoomId} room_id - * @param {EventId} request_event_id - * @param {VerificationMethod[]} [methods] - * @returns {VerificationRequest} - */ - requestVerification(room_id, request_event_id, methods) { - _assertClass(room_id, RoomId); - _assertClass(request_event_id, EventId); - var ptr0 = isLikeNone(methods) ? 0 : passArrayJsValueToWasm0(methods, wasm.__wbindgen_malloc); - var len0 = WASM_VECTOR_LEN; - const ret = wasm.otheruseridentity_requestVerification(this.__wbg_ptr, room_id.__wbg_ptr, request_event_id.__wbg_ptr, ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return VerificationRequest.__wrap(ret[0]); - } - /** - * Get the self-signing key of the identity. - * @returns {string} - */ - get selfSigningKey() { - let deferred2_0; - let deferred2_1; - try { - const ret = wasm.otheruseridentity_selfSigningKey(this.__wbg_ptr); - var ptr1 = ret[0]; - var len1 = ret[1]; - if (ret[3]) { - ptr1 = 0; - len1 = 0; - throw takeFromExternrefTable0(ret[2]); - } - deferred2_0 = ptr1; - deferred2_1 = len1; - return getStringFromWasm0(ptr1, len1); - } finally { - wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); - } - } - /** - * Send a verification request to the given user. - * - * The returned content needs to be sent out into a DM room with the given - * user. - * - * After the content has been sent out a VerificationRequest can be started - * with the `request_verification` method. - * @param {VerificationMethod[]} [methods] - * @returns {string} - */ - verificationRequestContent(methods) { - let deferred3_0; - let deferred3_1; - try { - var ptr0 = isLikeNone(methods) ? 0 : passArrayJsValueToWasm0(methods, wasm.__wbindgen_malloc); - var len0 = WASM_VECTOR_LEN; - const ret = wasm.otheruseridentity_verificationRequestContent(this.__wbg_ptr, ptr0, len0); - var ptr2 = ret[0]; - var len2 = ret[1]; - if (ret[3]) { - ptr2 = 0; - len2 = 0; - throw takeFromExternrefTable0(ret[2]); - } - deferred3_0 = ptr2; - deferred3_1 = len2; - return getStringFromWasm0(ptr2, len2); - } finally { - wasm.__wbindgen_free(deferred3_0, deferred3_1, 1); - } - } - /** - * Manually verify this user. - * - * This method will attempt to sign the user identity using our private - * cross signing key. - * - * This method fails if we don't have the private part of our user-signing - * key. - * - * Returns a request that needs to be sent out for the user to be marked as - * verified. - * @returns {Promise} - */ - verify() { - const ret = wasm.otheruseridentity_verify(this.__wbg_ptr); - return ret; - } - /** - * True if we verified this identity (with any own identity, at any - * point). - * - * To set this latch back to false, call {@link withdrawVerification}. - * @returns {boolean} - */ - wasPreviouslyVerified() { - const ret = wasm.otheruseridentity_wasPreviouslyVerified(this.__wbg_ptr); - return ret !== 0; - } - /** - * Remove the requirement for this identity to be verified. - * - * If an identity was previously verified and is not anymore it will be - * reported to the user. In order to remove this notice users have to - * verify again or to withdraw the verification requirement. - * @returns {Promise} - */ - withdrawVerification() { - const ret = wasm.otheruseridentity_withdrawVerification(this.__wbg_ptr); - return ret; - } -} -exports.OtherUserIdentity = OtherUserIdentity; -if (Symbol.dispose) OtherUserIdentity.prototype[Symbol.dispose] = OtherUserIdentity.prototype.free; - -/** - * The result of an outbound ECIES channel establishment. - */ -class OutboundCreationResult { - static __wrap(ptr) { - const obj = Object.create(OutboundCreationResult.prototype); - obj.__wbg_ptr = ptr; - OutboundCreationResultFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - OutboundCreationResultFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_outboundcreationresult_free(ptr, 0); - } - /** - * The established ECIES channel. - * @returns {EstablishedEcies} - */ - get channel() { - const ret = wasm.__wbg_get_outboundcreationresult_channel(this.__wbg_ptr); - return EstablishedEcies.__wrap(ret); - } - /** - * The initial encrypted message. - * @returns {string} - */ - get initial_message() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_outboundcreationresult_initial_message(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The established ECIES channel. - * @param {EstablishedEcies} arg0 - */ - set channel(arg0) { - _assertClass(arg0, EstablishedEcies); - var ptr0 = arg0.__destroy_into_raw(); - wasm.__wbg_set_outboundcreationresult_channel(this.__wbg_ptr, ptr0); - } - /** - * The initial encrypted message. - * @param {string} arg0 - */ - set initial_message(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_outboundcreationresult_initial_message(this.__wbg_ptr, ptr0, len0); - } -} -exports.OutboundCreationResult = OutboundCreationResult; -if (Symbol.dispose) OutboundCreationResult.prototype[Symbol.dispose] = OutboundCreationResult.prototype.free; - -/** - * Struct representing a cross signing identity of a user. - * - * This is the user identity of a user that is our own. - */ -class OwnUserIdentity { - static __wrap(ptr) { - const obj = Object.create(OwnUserIdentity.prototype); - obj.__wbg_ptr = ptr; - OwnUserIdentityFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - OwnUserIdentityFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_ownuseridentity_free(ptr, 0); - } - /** - * Was this identity verified since initial observation and is not anymore? - * - * Such a violation should be reported to the local user by the - * application, and resolved by - * - * - Verifying the new identity with {@link requestVerification}, or: - * - Withdrawing the verification requirement with {@link - * withdrawVerification}. - * @returns {boolean} - */ - hasVerificationViolation() { - const ret = wasm.ownuseridentity_hasVerificationViolation(this.__wbg_ptr); - return ret !== 0; - } - /** - * Is this user identity verified? - * @returns {boolean} - */ - isVerified() { - const ret = wasm.ownuseridentity_isVerified(this.__wbg_ptr); - return ret !== 0; - } - /** - * Get the master key of the identity. - * @returns {string} - */ - get masterKey() { - let deferred2_0; - let deferred2_1; - try { - const ret = wasm.ownuseridentity_masterKey(this.__wbg_ptr); - var ptr1 = ret[0]; - var len1 = ret[1]; - if (ret[3]) { - ptr1 = 0; - len1 = 0; - throw takeFromExternrefTable0(ret[2]); - } - deferred2_0 = ptr1; - deferred2_1 = len1; - return getStringFromWasm0(ptr1, len1); - } finally { - wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); - } - } - /** - * Send a verification request to our other devices. - * @param {VerificationMethod[]} [methods] - * @returns {Promise<[VerificationRequest, OutgoingVerificationRequest]>} - */ - requestVerification(methods) { - var ptr0 = isLikeNone(methods) ? 0 : passArrayJsValueToWasm0(methods, wasm.__wbindgen_malloc); - var len0 = WASM_VECTOR_LEN; - const ret = wasm.ownuseridentity_requestVerification(this.__wbg_ptr, ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Get the self-signing key of the identity. - * @returns {string} - */ - get selfSigningKey() { - let deferred2_0; - let deferred2_1; - try { - const ret = wasm.ownuseridentity_selfSigningKey(this.__wbg_ptr); - var ptr1 = ret[0]; - var len1 = ret[1]; - if (ret[3]) { - ptr1 = 0; - len1 = 0; - throw takeFromExternrefTable0(ret[2]); - } - deferred2_0 = ptr1; - deferred2_1 = len1; - return getStringFromWasm0(ptr1, len1); - } finally { - wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); - } - } - /** - * Does our user identity trust our own device, i.e. have we signed our own - * device keys with our self-signing key? - * @returns {Promise} - */ - trustsOurOwnDevice() { - const ret = wasm.ownuseridentity_trustsOurOwnDevice(this.__wbg_ptr); - return ret; - } - /** - * Get the user-signing key of the identity. This is only present for our - * own user identity. - * @returns {string} - */ - get userSigningKey() { - let deferred2_0; - let deferred2_1; - try { - const ret = wasm.ownuseridentity_userSigningKey(this.__wbg_ptr); - var ptr1 = ret[0]; - var len1 = ret[1]; - if (ret[3]) { - ptr1 = 0; - len1 = 0; - throw takeFromExternrefTable0(ret[2]); - } - deferred2_0 = ptr1; - deferred2_1 = len1; - return getStringFromWasm0(ptr1, len1); - } finally { - wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); - } - } - /** - * Mark our user identity as verified. - * - * This will mark the identity locally as verified and sign it with our own - * device. - * - * Returns a signature upload request that needs to be sent out. - * @returns {Promise} - */ - verify() { - const ret = wasm.ownuseridentity_verify(this.__wbg_ptr); - return ret; - } - /** - * True if we verified our own identity at some point in the past. - * - * To reset this latch back to `false`, call {@link withdrawVerification}. - * @returns {boolean} - */ - wasPreviouslyVerified() { - const ret = wasm.ownuseridentity_wasPreviouslyVerified(this.__wbg_ptr); - return ret !== 0; - } - /** - * Remove the requirement for this identity to be verified. - * - * If an identity was previously verified and is not any longer, it will be - * reported to the user. In order to remove this notice users have to - * verify again or to withdraw the verification requirement. - * @returns {Promise} - */ - withdrawVerification() { - const ret = wasm.ownuseridentity_withdrawVerification(this.__wbg_ptr); - return ret; - } -} -exports.OwnUserIdentity = OwnUserIdentity; -if (Symbol.dispose) OwnUserIdentity.prototype[Symbol.dispose] = OwnUserIdentity.prototype.free; - -/** - * A pickled version of an `InboundGroupSession`. - * - * Holds all the information that needs to be stored in a database to restore - * an InboundGroupSession. - */ -class PickledInboundGroupSession { - static __unwrap(jsValue) { - if (!(jsValue instanceof PickledInboundGroupSession)) { - return 0; - } - return jsValue.__destroy_into_raw(); - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - PickledInboundGroupSessionFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_pickledinboundgroupsession_free(ptr, 0); - } - /** - * Flag remembering if the session has been backed up. - * @returns {boolean} - */ - get backedUp() { - const ret = wasm.__wbg_get_pickledinboundgroupsession_backedUp(this.__wbg_ptr); - return ret !== 0; - } - /** - * Flag remembering if the session was directly sent to us by the sender - * or if it was imported. - * @returns {boolean} - */ - get imported() { - const ret = wasm.__wbg_get_pickledinboundgroupsession_imported(this.__wbg_ptr); - return ret !== 0; - } - /** - * The pickle string holding the Megolm Session, as returned by - * `olm_pickle_inbound_group_session` in libolm. - * @returns {string} - */ - get pickle() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_pickledinboundgroupsession_pickle(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The id of the room that the session is used in. - * - * Nullable so that a `PickledInboundGroupSession` can be constructed - * incrementally. Must be populated! - * @returns {RoomId | undefined} - */ - get roomId() { - const ret = wasm.__wbg_get_pickledinboundgroupsession_roomId(this.__wbg_ptr); - return ret === 0 ? undefined : RoomId.__wrap(ret); - } - /** - * The public curve25519 key of the account that sent us the session. - * @returns {string} - */ - get senderKey() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_pickledinboundgroupsession_senderKey(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The public ed25519 key of the account that is believed to have initiated - * the session, if known. - * - * If the session was received directly from the creator via an - * Olm-encrypted `m.room_key` event, this value is taken from the `keys` - * property of the plaintext payload of that event (see - * [`m.olm.v1.curve25519-aes-sha2`]). - * - * If the session was forwarded to us using an [`m.forwarded_room_key`], - * this value is a copy of the `sender_claimed_ed25519_key` from the - * content of the event. - * - * [`m.olm.v1.curve25519-aes-sha2`]: https://spec.matrix.org/v1.9/client-server-api/#molmv1curve25519-aes-sha2 - * [`m.forwarded_room_key`]: https://spec.matrix.org/v1.9/client-server-api/#mforwarded_room_key - * @returns {string | undefined} - */ - get senderSigningKey() { - const ret = wasm.__wbg_get_pickledinboundgroupsession_senderSigningKey(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * Construct a new `PickledInboundGroupSession`, with default values. - */ - constructor() { - const ret = wasm.pickledinboundgroupsession_new(); - this.__wbg_ptr = ret; - PickledInboundGroupSessionFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Flag remembering if the session has been backed up. - * @param {boolean} arg0 - */ - set backedUp(arg0) { - wasm.__wbg_set_pickledinboundgroupsession_backedUp(this.__wbg_ptr, arg0); - } - /** - * Flag remembering if the session was directly sent to us by the sender - * or if it was imported. - * @param {boolean} arg0 - */ - set imported(arg0) { - wasm.__wbg_set_pickledinboundgroupsession_imported(this.__wbg_ptr, arg0); - } - /** - * The pickle string holding the Megolm Session, as returned by - * `olm_pickle_inbound_group_session` in libolm. - * @param {string} arg0 - */ - set pickle(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_pickledinboundgroupsession_pickle(this.__wbg_ptr, ptr0, len0); - } - /** - * The id of the room that the session is used in. - * - * Nullable so that a `PickledInboundGroupSession` can be constructed - * incrementally. Must be populated! - * @param {RoomId | null} [arg0] - */ - set roomId(arg0) { - let ptr0 = 0; - if (!isLikeNone(arg0)) { - _assertClass(arg0, RoomId); - ptr0 = arg0.__destroy_into_raw(); - } - wasm.__wbg_set_pickledinboundgroupsession_roomId(this.__wbg_ptr, ptr0); - } - /** - * The public curve25519 key of the account that sent us the session. - * @param {string} arg0 - */ - set senderKey(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_pickledinboundgroupsession_senderKey(this.__wbg_ptr, ptr0, len0); - } - /** - * The public ed25519 key of the account that is believed to have initiated - * the session, if known. - * - * If the session was received directly from the creator via an - * Olm-encrypted `m.room_key` event, this value is taken from the `keys` - * property of the plaintext payload of that event (see - * [`m.olm.v1.curve25519-aes-sha2`]). - * - * If the session was forwarded to us using an [`m.forwarded_room_key`], - * this value is a copy of the `sender_claimed_ed25519_key` from the - * content of the event. - * - * [`m.olm.v1.curve25519-aes-sha2`]: https://spec.matrix.org/v1.9/client-server-api/#molmv1curve25519-aes-sha2 - * [`m.forwarded_room_key`]: https://spec.matrix.org/v1.9/client-server-api/#mforwarded_room_key - * @param {string | null} [arg0] - */ - set senderSigningKey(arg0) { - var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_pickledinboundgroupsession_senderSigningKey(this.__wbg_ptr, ptr0, len0); - } -} -exports.PickledInboundGroupSession = PickledInboundGroupSession; -if (Symbol.dispose) PickledInboundGroupSession.prototype[Symbol.dispose] = PickledInboundGroupSession.prototype.free; - -/** - * A pickled version of a `Session`. - * - * Holds all the information that needs to be stored in a database to restore - * an Olm Session. Can be imported into the rust store with {@link - * Migration::migrateOlmSessions}. - */ -class PickledSession { - static __unwrap(jsValue) { - if (!(jsValue instanceof PickledSession)) { - return 0; - } - return jsValue.__destroy_into_raw(); - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - PickledSessionFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_pickledsession_free(ptr, 0); - } - /** - * Was the session created using a fallback key? - * @returns {boolean} - */ - get createdUsingFallbackKey() { - const ret = wasm.__wbg_get_pickledsession_createdUsingFallbackKey(this.__wbg_ptr); - return ret !== 0; - } - /** - * When the session was created. - * @returns {Date} - */ - get creationTime() { - const ret = wasm.__wbg_get_pickledsession_creationTime(this.__wbg_ptr); - return ret; - } - /** - * When the session was last used. - * @returns {Date} - */ - get lastUseTime() { - const ret = wasm.__wbg_get_pickledsession_lastUseTime(this.__wbg_ptr); - return ret; - } - /** - * The pickle string holding the Olm Session, as returned by - * `olm_pickle_session` in libolm. - * @returns {string} - */ - get pickle() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_pickledsession_pickle(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The base64-encoded public curve25519 key of the other user that we share - * this session with. - * @returns {string} - */ - get senderKey() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_pickledsession_senderKey(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Construct a new `PickledSession`, with default values. - */ - constructor() { - const ret = wasm.pickledsession_new(); - this.__wbg_ptr = ret; - PickledSessionFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Was the session created using a fallback key? - * @param {boolean} arg0 - */ - set createdUsingFallbackKey(arg0) { - wasm.__wbg_set_pickledsession_createdUsingFallbackKey(this.__wbg_ptr, arg0); - } - /** - * When the session was created. - * @param {Date} arg0 - */ - set creationTime(arg0) { - wasm.__wbg_set_pickledsession_creationTime(this.__wbg_ptr, arg0); - } - /** - * When the session was last used. - * @param {Date} arg0 - */ - set lastUseTime(arg0) { - wasm.__wbg_set_pickledsession_lastUseTime(this.__wbg_ptr, arg0); - } - /** - * The pickle string holding the Olm Session, as returned by - * `olm_pickle_session` in libolm. - * @param {string} arg0 - */ - set pickle(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_pickledsession_pickle(this.__wbg_ptr, ptr0, len0); - } - /** - * The base64-encoded public curve25519 key of the other user that we share - * this session with. - * @param {string} arg0 - */ - set senderKey(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_pickledsession_senderKey(this.__wbg_ptr, ptr0, len0); - } -} -exports.PickledSession = PickledSession; -if (Symbol.dispose) PickledSession.prototype[Symbol.dispose] = PickledSession.prototype.free; - -/** - * A class representing a public-key decryption instance. - * - * This implements the decryption part of the - * `m.megolm_backup.v1.curve25519-aes-sha2` algorithm described in the Matrix - * {@link https://spec.matrix.org/v1.11/client-server-api/#backup-algorithm-mmegolm_backupv1curve25519-aes-sha2 | spec}. - * - * @see {@link PkEncryption} - * - * More details can be found in the official {@link https://docs.rs/vodozemac/latest/vodozemac/pk_encryption/ | vodozemac documentation}. - */ -class PkDecryption { - static __wrap(ptr) { - const obj = Object.create(PkDecryption.prototype); - obj.__wbg_ptr = ptr; - PkDecryptionFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - PkDecryptionFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_pkdecryption_free(ptr, 0); - } - /** - * Decrypts an encrypted message and returns the raw `Uint8Array`. - * @param {PkMessage} message - * @returns {Uint8Array} - */ - decrypt(message) { - _assertClass(message, PkMessage); - const ret = wasm.pkdecryption_decrypt(this.__wbg_ptr, message.__wbg_ptr); - if (ret[3]) { - throw takeFromExternrefTable0(ret[2]); - } - var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - return v1; - } - /** - * Decrypts an encrypted message and returns the plaintext as a UTF-8 - * string. - * @param {PkMessage} message - * @returns {string} - */ - decryptString(message) { - let deferred2_0; - let deferred2_1; - try { - _assertClass(message, PkMessage); - const ret = wasm.pkdecryption_decryptString(this.__wbg_ptr, message.__wbg_ptr); - var ptr1 = ret[0]; - var len1 = ret[1]; - if (ret[3]) { - ptr1 = 0; - len1 = 0; - throw takeFromExternrefTable0(ret[2]); - } - deferred2_0 = ptr1; - deferred2_1 = len1; - return getStringFromWasm0(ptr1, len1); - } finally { - wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); - } - } - /** - * Creates a `PkDecryption` instance from a secret key. - * @param {Curve25519SecretKey} key - * @returns {PkDecryption} - */ - static fromKey(key) { - _assertClass(key, Curve25519SecretKey); - const ret = wasm.pkdecryption_fromKey(key.__wbg_ptr); - return PkDecryption.__wrap(ret); - } - /** - * Creates a new `PkDecryption` instance with a newly generated key pair. - */ - constructor() { - const ret = wasm.pkdecryption_new(); - this.__wbg_ptr = ret; - PkDecryptionFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Returns the public key associated with this decryption instance. - * - * This can be used to construct a {@link PkEncryption} object to encrypt a - * message for this `PkDecryption` object. - * @returns {Curve25519PublicKey} - */ - publicKey() { - const ret = wasm.pkdecryption_publicKey(this.__wbg_ptr); - return Curve25519PublicKey.__wrap(ret); - } - /** - * Returns the secret key associated with this `PkDecryption` instance. - * @returns {Curve25519SecretKey} - */ - secretKey() { - const ret = wasm.pkdecryption_secretKey(this.__wbg_ptr); - return Curve25519SecretKey.__wrap(ret); - } -} -exports.PkDecryption = PkDecryption; -if (Symbol.dispose) PkDecryption.prototype[Symbol.dispose] = PkDecryption.prototype.free; - -/** - * A class representing a public-key encryption instance. - * - * This implements the encryption part of the - * `m.megolm_backup.v1.curve25519-aes-sha2` algorithm described in the Matrix - * {@link https://spec.matrix.org/v1.11/client-server-api/#backup-algorithm-mmegolm_backupv1curve25519-aes-sha2 | spec}. - * - * @see {@link PkDecryption} - * - * More details can be found in the official {@link https://docs.rs/vodozemac/latest/vodozemac/pk_encryption/ | vodozemac documentation}. - */ -class PkEncryption { - static __wrap(ptr) { - const obj = Object.create(PkEncryption.prototype); - obj.__wbg_ptr = ptr; - PkEncryptionFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - PkEncryptionFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_pkencryption_free(ptr, 0); - } - /** - * Encrypts a byte message and returns an encrypted {@link PkMessage}. - * @param {Uint8Array} message - * @returns {PkMessage} - */ - encrypt(message) { - const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.pkencryption_encrypt(this.__wbg_ptr, ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return PkMessage.__wrap(ret[0]); - } - /** - * Encrypts a string message and returns an encrypted {@link PkMessage}. - * @param {string} message - * @returns {PkMessage} - */ - encryptString(message) { - const ptr0 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.pkencryption_encryptString(this.__wbg_ptr, ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return PkMessage.__wrap(ret[0]); - } - /** - * Creates a new `PkEncryption` instance from a public key. - * @param {Curve25519PublicKey} public_key - * @returns {PkEncryption} - */ - static fromKey(public_key) { - _assertClass(public_key, Curve25519PublicKey); - const ret = wasm.pkencryption_fromKey(public_key.__wbg_ptr); - return PkEncryption.__wrap(ret); - } -} -exports.PkEncryption = PkEncryption; -if (Symbol.dispose) PkEncryption.prototype[Symbol.dispose] = PkEncryption.prototype.free; - -/** - * A class representing an encrypted message using {@link PkEncryption}. - */ -class PkMessage { - static __wrap(ptr) { - const obj = Object.create(PkMessage.prototype); - obj.__wbg_ptr = ptr; - PkMessageFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - PkMessageFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_pkmessage_free(ptr, 0); - } - /** - * Returns the raw ciphertext as a `Uint8Array`. - * @returns {Uint8Array} - */ - ciphertext() { - const ret = wasm.pkmessage_ciphertext(this.__wbg_ptr); - var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - return v1; - } - /** - * Returns the ephemeral public key used during encryption. - * @returns {Curve25519PublicKey} - */ - ephemeralKey() { - const ret = wasm.pkmessage_ephemeralKey(this.__wbg_ptr); - return Curve25519PublicKey.__wrap(ret); - } - /** - * Constructs a `PkMessage` from a base64-encoded representation. - * @param {Base64EncodedPkMessage} message - * @returns {PkMessage} - */ - static fromBase64(message) { - _assertClass(message, Base64EncodedPkMessage); - const ret = wasm.pkmessage_fromBase64(message.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return PkMessage.__wrap(ret[0]); - } - /** - * Constructs a `PkMessage` from its parts: ciphertext, MAC, and ephemeral - * key. - * @param {Uint8Array} ciphertext - * @param {Uint8Array} mac - * @param {Curve25519PublicKey} ephemeral_key - * @returns {PkMessage} - */ - static fromParts(ciphertext, mac, ephemeral_key) { - const ptr0 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passArray8ToWasm0(mac, wasm.__wbindgen_malloc); - const len1 = WASM_VECTOR_LEN; - _assertClass(ephemeral_key, Curve25519PublicKey); - const ret = wasm.pkmessage_fromParts(ptr0, len0, ptr1, len1, ephemeral_key.__wbg_ptr); - return PkMessage.__wrap(ret); - } - /** - * Returns the raw message authentication code (MAC) as a `Uint8Array`. - * @returns {Uint8Array} - */ - mac() { - const ret = wasm.pkmessage_mac(this.__wbg_ptr); - var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - return v1; - } - /** - * Converts the `PkMessage` into a base64-encoded representation. - * @returns {Base64EncodedPkMessage} - */ - toBase64() { - const ret = wasm.pkmessage_toBase64(this.__wbg_ptr); - return Base64EncodedPkMessage.__wrap(ret); - } -} -exports.PkMessage = PkMessage; -if (Symbol.dispose) PkMessage.prototype[Symbol.dispose] = PkMessage.prototype.free; - -/** - * Represents a to-device event sent in the clear. - */ -class PlainTextToDeviceEvent { - static __wrap(ptr) { - const obj = Object.create(PlainTextToDeviceEvent.prototype); - obj.__wbg_ptr = ptr; - PlainTextToDeviceEventFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - PlainTextToDeviceEventFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_plaintexttodeviceevent_free(ptr, 0); - } - /** - * The to-device message, containing `type`, `sender` and `content` fields, - * encoded as JSON. - * @returns {string} - */ - get rawEvent() { - const ret = wasm.__wbg_get_plaintexttodeviceevent_rawEvent(this.__wbg_ptr); - return ret; - } - /** - * The type of processed to-device event. Always {@link - * ProcessedToDeviceEventType.PlainText} for this type. - * @returns {ProcessedToDeviceEventType} - */ - get type() { - const ret = wasm.plaintexttodeviceevent_type(this.__wbg_ptr); - return ret; - } -} -exports.PlainTextToDeviceEvent = PlainTextToDeviceEvent; -if (Symbol.dispose) PlainTextToDeviceEvent.prototype[Symbol.dispose] = PlainTextToDeviceEvent.prototype.free; - -/** - * The type of a {@link ProcessedToDeviceEvent}. - * @enum {0 | 1 | 2 | 3} - */ -const ProcessedToDeviceEventType = exports.ProcessedToDeviceEventType = Object.freeze({ - /** - * A successfully-decrypted encrypted to-device message. - */ - Decrypted: 0, - "0": "Decrypted", - /** - * An encrypted to-device message which could not be decrypted. - */ - UnableToDecrypt: 1, - "1": "UnableToDecrypt", - /** - * An unencrypted to-device message (sent in clear). - */ - PlainText: 2, - "2": "PlainText", - /** - * An invalid to-device message that was ignored because it is missing some - * required information to be processed (like no event `type` for - * example) - */ - Invalid: 3, - "3": "Invalid" -}); - -/** - * A request that will upload a dehydrated device to the server. - */ -class PutDehydratedDeviceRequest { - static __wrap(ptr) { - const obj = Object.create(PutDehydratedDeviceRequest.prototype); - obj.__wbg_ptr = ptr; - PutDehydratedDeviceRequestFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - PutDehydratedDeviceRequestFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_putdehydrateddevicerequest_free(ptr, 0); - } - /** - * A JSON-encoded object containing the rest of the payload: `rooms`. - * - * It represents the body of the HTTP request. - * @returns {string} - */ - get body() { - const ret = wasm.__wbg_get_putdehydrateddevicerequest_body(this.__wbg_ptr); - return ret; - } - /** - * Create a new `PutDehydratedDeviceRequest` - * @param {string} body - */ - constructor(body) { - const ret = wasm.putdehydrateddevicerequest_new(body); - this.__wbg_ptr = ret; - PutDehydratedDeviceRequestFinalization.register(this, this.__wbg_ptr, this); - return this; - } -} -exports.PutDehydratedDeviceRequest = PutDehydratedDeviceRequest; -if (Symbol.dispose) PutDehydratedDeviceRequest.prototype[Symbol.dispose] = PutDehydratedDeviceRequest.prototype.free; - -/** - * QR code based verification. - */ -class Qr { - static __wrap(ptr) { - const obj = Object.create(Qr.prototype); - obj.__wbg_ptr = ptr; - QrFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - QrFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_qr_free(ptr, 0); - } - /** - * Cancel the verification flow. - * - * Returns either an `OutgoingVerificationRequest` which should be sent - * out, or `undefined` if the verification is already cancelled. - * @returns {OutgoingVerificationRequest | undefined} - */ - cancel() { - const ret = wasm.qr_cancel(this.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Get info about the cancellation if the verification flow has - * been cancelled. - * @returns {CancelInfo | undefined} - */ - cancelInfo() { - const ret = wasm.qr_cancelInfo(this.__wbg_ptr); - return ret === 0 ? undefined : CancelInfo.__wrap(ret); - } - /** - * Cancel the verification. - * - * This cancels the verification with given code (e.g. `m.user`). - * - * Returns either an `OutgoingVerificationRequest` which should be sent - * out, or `undefined` if the verification is already cancelled. - * @param {string} code - * @returns {OutgoingVerificationRequest | undefined} - */ - cancelWithCode(code) { - const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.qr_cancelWithCode(this.__wbg_ptr, ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Confirm that the other side has scanned our QR code. - * - * Returns either an `OutgoingVerificationRequest` which should be sent - * out, or `undefined` if the verification is already confirmed. - * @returns {OutgoingVerificationRequest | undefined} - */ - confirmScanning() { - const ret = wasm.qr_confirmScanning(this.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Get the unique ID that identifies this QR verification flow, - * be either a to-device request ID or a room event ID. - * @returns {string} - */ - get flowId() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.qr_flowId(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Has the scanning of the QR code been confirmed by us? - * @returns {boolean} - */ - hasBeenConfirmed() { - const ret = wasm.qr_hasBeenConfirmed(this.__wbg_ptr); - return ret !== 0; - } - /** - * Has the QR verification been scanned by the other side. - * - * When the verification object is in this state it’s required - * that the user confirms that the other side has scanned the QR - * code. - * @returns {boolean} - */ - hasBeenScanned() { - const ret = wasm.qr_hasBeenScanned(this.__wbg_ptr); - return ret !== 0; - } - /** - * Has the verification flow been cancelled? - * @returns {boolean} - */ - isCancelled() { - const ret = wasm.qr_isCancelled(this.__wbg_ptr); - return ret !== 0; - } - /** - * Has the verification flow completed? - * @returns {boolean} - */ - isDone() { - const ret = wasm.qr_isDone(this.__wbg_ptr); - return ret !== 0; - } - /** - * Is this a verification that is verifying one of our own devices? - * @returns {boolean} - */ - isSelfVerification() { - const ret = wasm.qr_isSelfVerification(this.__wbg_ptr); - return ret !== 0; - } - /** - * Get the device ID of the other side. - * @returns {DeviceId} - */ - get otherDeviceId() { - const ret = wasm.qr_otherDeviceId(this.__wbg_ptr); - return DeviceId.__wrap(ret); - } - /** - * Get the user id of the other user that is participating in - * this verification flow. - * @returns {UserId} - */ - get otherUserId() { - const ret = wasm.qr_otherUserId(this.__wbg_ptr); - return UserId.__wrap(ret); - } - /** - * Notify the other side that we have successfully scanned the QR - * code and that the QR verification flow can start. - * - * This will return some OutgoingContent if the object is in the - * correct state to start the verification flow, otherwise None. - * @returns {OutgoingVerificationRequest | undefined} - */ - reciprocate() { - const ret = wasm.qr_reciprocate(this.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Have we successfully scanned the QR code and are able to send - * a reciprocation event? - * @returns {boolean} - */ - reciprocated() { - const ret = wasm.qr_reciprocated(this.__wbg_ptr); - return ret !== 0; - } - /** - * Register a callback which will be called whenever there is an update to - * the request - * - * The `callback` is called with no parameters. - * @param {() => Promise} callback - */ - registerChangesCallback(callback) { - wasm.qr_registerChangesCallback(this.__wbg_ptr, callback); - } - /** - * Get the room id if the verification is happening inside a - * room. - * @returns {RoomId | undefined} - */ - get roomId() { - const ret = wasm.qr_roomId(this.__wbg_ptr); - return ret === 0 ? undefined : RoomId.__wrap(ret); - } - /** - * Get the current state of this request. - * - * Returns a `QrState`. - * @returns {QrState} - */ - state() { - const ret = wasm.qr_state(this.__wbg_ptr); - return ret; - } - /** - * Generate a the raw bytes that should be encoded as a QR code - * is representing this verification flow. - * - * The `to_qr_code` method can be used to instead output a QrCode - * object that can be rendered. - * @returns {Uint8ClampedArray} - */ - toBytes() { - const ret = wasm.qr_toBytes(this.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Generate a QR code object that is representing this - * verification flow. - * - * The QrCode can then be rendered as an image or as an unicode - * string. - * - * The `to_bytes` method can be used to instead output the raw - * bytes that should be encoded as a QR code. - * - * Returns a `QrCode`. - * @returns {QrCode} - */ - toQrCode() { - const ret = wasm.qr_toQrCode(this.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return QrCode.__wrap(ret[0]); - } - /** - * Get our own user ID. - * @returns {UserId} - */ - get userId() { - const ret = wasm.qr_userId(this.__wbg_ptr); - return UserId.__wrap(ret); - } - /** - * Did we initiate the verification request? - * @returns {boolean} - */ - weStarted() { - const ret = wasm.qr_weStarted(this.__wbg_ptr); - return ret !== 0; - } -} -exports.Qr = Qr; -if (Symbol.dispose) Qr.prototype[Symbol.dispose] = Qr.prototype.free; - -/** - * A QR code. - */ -class QrCode { - static __wrap(ptr) { - const obj = Object.create(QrCode.prototype); - obj.__wbg_ptr = ptr; - QrCodeFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - QrCodeFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_qrcode_free(ptr, 0); - } - /** - * Render the QR code into a `Uint8ClampedArray` where 1 represents a - * dark pixel and 0 a white pixel. - * @returns {Uint8ClampedArray} - */ - renderIntoBuffer() { - const ret = wasm.qrcode_renderIntoBuffer(this.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } -} -exports.QrCode = QrCode; -if (Symbol.dispose) QrCode.prototype[Symbol.dispose] = QrCode.prototype.free; - -/** - * Data for the QR code login mechanism. - * - * The {@link QrCodeData} can be serialized and encoded as a QR code or it can - * be decoded from a QR code. - * - * This type supports both the format originally speicied in - * {link https://github.com/matrix-org/matrix-spec-proposals/pull/4108 MSC4108} as well as the - * updated format found in - * {link https://github.com/matrix-org/matrix-spec-proposals/pull/4388 MSC4388}. - */ -class QrCodeData { - static __wrap(ptr) { - const obj = Object.create(QrCodeData.prototype); - obj.__wbg_ptr = ptr; - QrCodeDataFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - QrCodeDataFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_qrcodedata_free(ptr, 0); - } - /** - * Attempt to decode a base64 encoded string into a {@link QrCodeData} - * object. - * @param {string} data - * @returns {QrCodeData} - */ - static fromBase64(data) { - const ptr0 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.qrcodedata_fromBase64(ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return QrCodeData.__wrap(ret[0]); - } - /** - * Attempt to decode a slice of bytes into a {@link QrCodeData} object. - * - * The slice of bytes would generally be returned by a QR code decoder. - * @param {Uint8Array} bytes - * @returns {QrCodeData} - */ - static fromBytes(bytes) { - const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.qrcodedata_fromBytes(ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return QrCodeData.__wrap(ret[0]); - } - /** - * Get the intent-specific data embedded in the {@link QrCodeData}. - * @returns {QrCodeIntentData} - */ - get intentData() { - const ret = wasm.qrcodedata_intentData(this.__wbg_ptr); - return QrCodeIntentData.__wrap(ret); - } - /** - * Get the mode of this {@link QrCodeData} instance. - * @returns {QrCodeIntent} - */ - get mode() { - const ret = wasm.qrcodedata_mode(this.__wbg_ptr); - return ret; - } - /** - * Create new {@link QrCodeData} from a given public key, a rendezvous URL - * and, optionally, a server name for the homeserver. - * - * If a server name is given, then the {@link QrCodeData} mode will be - * {@link QrCodeIntent.Reciprocate}, i.e. the QR code will contain data for - * the existing device to display the QR code. - * - * If no server name is given, the {@link QrCodeData} mode will be - * {@link QrCodeIntent.Login}, i.e. the QR code will contain data for the - * new device to display the QR code. - * @param {Curve25519PublicKey} public_key - * @param {string} rendezvous_url - * @param {string | null} [server_name] - */ - constructor(public_key, rendezvous_url, server_name) { - _assertClass(public_key, Curve25519PublicKey); - var ptr0 = public_key.__destroy_into_raw(); - const ptr1 = passStringToWasm0(rendezvous_url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - var ptr2 = isLikeNone(server_name) ? 0 : passStringToWasm0(server_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len2 = WASM_VECTOR_LEN; - const ret = wasm.qrcodedata_new(ptr0, ptr1, len1, ptr2, len2); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - this.__wbg_ptr = ret[0]; - QrCodeDataFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Create new {@link QrCodeData} from a given public key, a rendezvous ID - * and, a base homeserver URL. - * - * This creates a QR code which conforms to - * {@link https://github.com/matrix-org/matrix-spec-proposals/pull/4388 MSC4388} of the data - * format for QR login. - * @param {Curve25519PublicKey} public_key - * @param {string} rendezvous_id - * @param {string} base_url - * @param {QrCodeIntent} intent - * @returns {QrCodeData} - */ - static newMsc4388(public_key, rendezvous_id, base_url, intent) { - _assertClass(public_key, Curve25519PublicKey); - var ptr0 = public_key.__destroy_into_raw(); - const ptr1 = passStringToWasm0(rendezvous_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(base_url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ret = wasm.qrcodedata_newMsc4388(ptr0, ptr1, len1, ptr2, len2, intent); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return QrCodeData.__wrap(ret[0]); - } - /** - * Get the Curve25519 public key embedded in the {@link QrCodeData}. - * - * This Curve25519 public key should be used to establish an - * [HPKE](https://www.rfc-editor.org/rfc/rfc9180.html) - * (Hybrid Public Key Encryption) channel with the other device. - * @returns {Curve25519PublicKey} - */ - get publicKey() { - const ret = wasm.qrcodedata_publicKey(this.__wbg_ptr); - return Curve25519PublicKey.__wrap(ret); - } - /** - * Get the URL of the rendezvous server which will be used to exchange - * messages between the two devices. - * @returns {string | undefined} - */ - get rendezvousUrl() { - const ret = wasm.qrcodedata_rendezvousUrl(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * Get the server name of the homeserver which the new device will be - * logged in to. - * - * This will be only available if the existing device has generated the QR - * code and the new device is the one scanning the QR code. - * @returns {string | undefined} - */ - get serverName() { - const ret = wasm.qrcodedata_serverName(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * Encode the {@link QrCodeData} into a string using base64. - * - * This format can be used for debugging purposes and the - * [`QrcodeData::from_base64()`] method can be used to parse the string - * again. - * @returns {string} - */ - toBase64() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.qrcodedata_toBase64(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Encode the {@link QrCodeData} into a list of bytes. - * - * The list of bytes can be used by a QR code generator to create an image - * containing a QR code. - * @returns {Uint8Array} - */ - toBytes() { - const ret = wasm.qrcodedata_toBytes(this.__wbg_ptr); - var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - return v1; - } -} -exports.QrCodeData = QrCodeData; -if (Symbol.dispose) QrCodeData.prototype[Symbol.dispose] = QrCodeData.prototype.free; - -/** - * The mode of the QR code login. - * - * The QR code login mechanism supports both, the new device, as well as the - * existing device to display the QR code. - * - * The different modes have an explicit one-byte identifier which gets added to - * the QR code data. - * @enum {0 | 1} - */ -const QrCodeIntent = exports.QrCodeIntent = Object.freeze({ - /** - * The new device is displaying the QR code. - */ - Login: 0, - "0": "Login", - /** - * The existing device is displaying the QR code. - */ - Reciprocate: 1, - "1": "Reciprocate" -}); - -/** - * Intent and MSC-specific data class for the QR code login support. - */ -class QrCodeIntentData { - static __wrap(ptr) { - const obj = Object.create(QrCodeIntentData.prototype); - obj.__wbg_ptr = ptr; - QrCodeIntentDataFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - QrCodeIntentDataFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_qrcodeintentdata_free(ptr, 0); - } - /** - * The MSC4108-specific intent data. - * - * This will not be `null` only if the {@link QrCodeData} contains data as - * specified in the QR code format of MSC4108. Otherwise it will contain - * MSC4388-specific intent data. - * @returns {Msc4108IntentData | undefined} - */ - get msc4108() { - const ret = wasm.__wbg_get_qrcodeintentdata_msc4108(this.__wbg_ptr); - return ret === 0 ? undefined : Msc4108IntentData.__wrap(ret); - } - /** - * The MSC4833-specific intent data. - * - * This will not be `null` only if the {@link QrCodeData} contains data as - * specified in the QR code format of MSC4388. Otherwise it will contain - * MSC4108-specific intent data. - * @returns {Msc4388IntentData | undefined} - */ - get msc4388() { - const ret = wasm.__wbg_get_qrcodeintentdata_msc4388(this.__wbg_ptr); - return ret === 0 ? undefined : Msc4388IntentData.__wrap(ret); - } - /** - * The MSC4108-specific intent data. - * - * This will not be `null` only if the {@link QrCodeData} contains data as - * specified in the QR code format of MSC4108. Otherwise it will contain - * MSC4388-specific intent data. - * @param {Msc4108IntentData | null} [arg0] - */ - set msc4108(arg0) { - let ptr0 = 0; - if (!isLikeNone(arg0)) { - _assertClass(arg0, Msc4108IntentData); - ptr0 = arg0.__destroy_into_raw(); - } - wasm.__wbg_set_qrcodeintentdata_msc4108(this.__wbg_ptr, ptr0); - } - /** - * The MSC4833-specific intent data. - * - * This will not be `null` only if the {@link QrCodeData} contains data as - * specified in the QR code format of MSC4388. Otherwise it will contain - * MSC4108-specific intent data. - * @param {Msc4388IntentData | null} [arg0] - */ - set msc4388(arg0) { - let ptr0 = 0; - if (!isLikeNone(arg0)) { - _assertClass(arg0, Msc4388IntentData); - ptr0 = arg0.__destroy_into_raw(); - } - wasm.__wbg_set_qrcodeintentdata_msc4388(this.__wbg_ptr, ptr0); - } -} -exports.QrCodeIntentData = QrCodeIntentData; -if (Symbol.dispose) QrCodeIntentData.prototype[Symbol.dispose] = QrCodeIntentData.prototype.free; - -/** - * A scanned QR code. - */ -class QrCodeScan { - static __wrap(ptr) { - const obj = Object.create(QrCodeScan.prototype); - obj.__wbg_ptr = ptr; - QrCodeScanFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - QrCodeScanFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_qrcodescan_free(ptr, 0); - } - /** - * Parse the decoded payload of a QR code in byte slice form. - * - * This method is useful if you would like to do your own custom QR code - * decoding. - * @param {Uint8ClampedArray} buffer - * @returns {QrCodeScan} - */ - static fromBytes(buffer) { - const ret = wasm.qrcodescan_fromBytes(buffer); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return QrCodeScan.__wrap(ret[0]); - } -} -exports.QrCodeScan = QrCodeScan; -if (Symbol.dispose) QrCodeScan.prototype[Symbol.dispose] = QrCodeScan.prototype.free; - -/** - * List of `Qr` states - * @enum {0 | 1 | 2 | 3 | 4 | 5} - */ -const QrState = exports.QrState = Object.freeze({ - /** - * We have received the other device's details (from the - * `m.key.verification.request` or `m.key.verification.ready`) and - * established the shared secret, so can - * display the QR code. - */ - Created: 0, - "0": "Created", - /** - * The other side has scanned our QR code and sent an - * `m.key.verification.start` message with `method: m.reciprocate.v1` with - * matching shared secret. - */ - Scanned: 1, - "1": "Scanned", - /** - * Our user has confirmed that the other device scanned successfully. We - * have sent an `m.key.verification.done`. - */ - Confirmed: 2, - "2": "Confirmed", - /** - * We have scanned the other side's QR code and are able to send a - * `m.key.verification.start` message with `method: m.reciprocate.v1`. - * - * Call `Qr::reciprocate` to build the start message. - * - * Note that, despite the name of this state, we have not necessarily - * yet sent the `m.reciprocate.v1` message. - */ - Reciprocated: 3, - "3": "Reciprocated", - /** - * Verification complete: we have received an `m.key.verification.done` - * from the other side. - */ - Done: 4, - "4": "Done", - /** - * Verification cancelled or failed. - */ - Cancelled: 5, - "5": "Cancelled" -}); - -/** - * A rehydrated device - * - * This device can receive to-device events to get room keys that were send to - * it. - */ -class RehydratedDevice { - static __wrap(ptr) { - const obj = Object.create(RehydratedDevice.prototype); - obj.__wbg_ptr = ptr; - RehydratedDeviceFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - RehydratedDeviceFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_rehydrateddevice_free(ptr, 0); - } - /** - * Receive the to-device events that sent to the dehydrated device - * - * The rehydrated device will decrypt the events and pass the room keys - * into the `OlmMachine`. - * - * # Arguments - * - * * `to_device_events` is a JSON-encoded result of the `events` array from - * `/dehydrated_device/{device_id}/events`. - * * `decryption_settings`: Optionally, the settings to use when decrypting - * to-device events. If not set, to-device events will be decrypted with - * a {@link TrustRequirement} of `Untrusted`. - * - * Returns an array of `RoomKeyInfo`, indicating the room keys that were - * received. - * @param {string} to_device_events - * @param {DecryptionSettings | null} [decryption_settings] - * @returns {Promise} - */ - receiveEvents(to_device_events, decryption_settings) { - const ptr0 = passStringToWasm0(to_device_events, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - let ptr1 = 0; - if (!isLikeNone(decryption_settings)) { - _assertClass(decryption_settings, DecryptionSettings); - ptr1 = decryption_settings.__destroy_into_raw(); - } - const ret = wasm.rehydrateddevice_receiveEvents(this.__wbg_ptr, ptr0, len0, ptr1); - return ret; - } -} -exports.RehydratedDevice = RehydratedDevice; -if (Symbol.dispose) RehydratedDevice.prototype[Symbol.dispose] = RehydratedDevice.prototype.free; - -/** - * Represent the type of a request. - * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6} - */ -const RequestType = exports.RequestType = Object.freeze({ - /** - * Represents a `KeysUploadRequest`. - */ - KeysUpload: 0, - "0": "KeysUpload", - /** - * Represents a `KeysQueryRequest`. - */ - KeysQuery: 1, - "1": "KeysQuery", - /** - * Represents a `KeysClaimRequest`. - */ - KeysClaim: 2, - "2": "KeysClaim", - /** - * Represents a `ToDeviceRequest`. - */ - ToDevice: 3, - "3": "ToDevice", - /** - * Represents a `SignatureUploadRequest`. - */ - SignatureUpload: 4, - "4": "SignatureUpload", - /** - * Represents a `RoomMessageRequest`. - */ - RoomMessage: 5, - "5": "RoomMessage", - /** - * Represents a `KeysBackupRequest`. - */ - KeysBackup: 6, - "6": "KeysBackup" -}); - -/** - * A Matrix [room ID]. - * - * [room ID]: https://spec.matrix.org/v1.2/appendices/#room-ids-and-event-ids - */ -class RoomId { - static __wrap(ptr) { - const obj = Object.create(RoomId.prototype); - obj.__wbg_ptr = ptr; - RoomIdFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - static __unwrap(jsValue) { - if (!(jsValue instanceof RoomId)) { - return 0; - } - return jsValue.__destroy_into_raw(); - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - RoomIdFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_roomid_free(ptr, 0); - } - /** - * Parse/validate and create a new `RoomId`. - * @param {string} id - */ - constructor(id) { - const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.roomid_new(ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - this.__wbg_ptr = ret[0]; - RoomIdFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Return the room ID as a string. - * @returns {string} - */ - toString() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.roomid_toString(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } -} -exports.RoomId = RoomId; -if (Symbol.dispose) RoomId.prototype[Symbol.dispose] = RoomId.prototype.free; - -/** - * Struct holding the number of room keys we have. - */ -class RoomKeyCounts { - static __wrap(ptr) { - const obj = Object.create(RoomKeyCounts.prototype); - obj.__wbg_ptr = ptr; - RoomKeyCountsFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - RoomKeyCountsFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_roomkeycounts_free(ptr, 0); - } - /** - * The number of backed up room keys. - * @returns {number} - */ - get backedUp() { - const ret = wasm.__wbg_get_roomkeycounts_backedUp(this.__wbg_ptr); - return ret; - } - /** - * The total number of room keys. - * @returns {number} - */ - get total() { - const ret = wasm.__wbg_get_roomkeycounts_total(this.__wbg_ptr); - return ret; - } - /** - * The number of backed up room keys. - * @param {number} arg0 - */ - set backedUp(arg0) { - wasm.__wbg_set_roomkeycounts_backedUp(this.__wbg_ptr, arg0); - } - /** - * The total number of room keys. - * @param {number} arg0 - */ - set total(arg0) { - wasm.__wbg_set_roomkeycounts_total(this.__wbg_ptr, arg0); - } -} -exports.RoomKeyCounts = RoomKeyCounts; -if (Symbol.dispose) RoomKeyCounts.prototype[Symbol.dispose] = RoomKeyCounts.prototype.free; - -/** - * The result of a call to {@link OlmMachine.importExportedRoomKeys} or - * {@link OlmMachine.importBackedUpRoomKeys}. - */ -class RoomKeyImportResult { - static __wrap(ptr) { - const obj = Object.create(RoomKeyImportResult.prototype); - obj.__wbg_ptr = ptr; - RoomKeyImportResultFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - RoomKeyImportResultFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_roomkeyimportresult_free(ptr, 0); - } - /** - * The number of room keys that were imported. - * @returns {number} - */ - get importedCount() { - const ret = wasm.__wbg_get_roomkeyimportresult_importedCount(this.__wbg_ptr); - return ret >>> 0; - } - /** - * The total number of room keys that were found in the export. - * @returns {number} - */ - get totalCount() { - const ret = wasm.__wbg_get_roomkeyimportresult_totalCount(this.__wbg_ptr); - return ret >>> 0; - } - /** - * The keys that were imported. - * - * A Map from room id to a Map of the sender key to a Set of session ids. - * - * Typescript type: `Map>`. - * @returns {Map>>} - */ - keys() { - const ret = wasm.roomkeyimportresult_keys(this.__wbg_ptr); - return ret; - } -} -exports.RoomKeyImportResult = RoomKeyImportResult; -if (Symbol.dispose) RoomKeyImportResult.prototype[Symbol.dispose] = RoomKeyImportResult.prototype.free; - -/** - * Information on a room key that has been received or imported. - */ -class RoomKeyInfo { - static __wrap(ptr) { - const obj = Object.create(RoomKeyInfo.prototype); - obj.__wbg_ptr = ptr; - RoomKeyInfoFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - RoomKeyInfoFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_roomkeyinfo_free(ptr, 0); - } - /** - * The {@link EncryptionAlgorithm} that this key is used for. Will be one - * of the `m.megolm.*` algorithms. - * @returns {EncryptionAlgorithm} - */ - get algorithm() { - const ret = wasm.roomkeyinfo_algorithm(this.__wbg_ptr); - return ret; - } - /** - * The room where the key is used. - * @returns {RoomId} - */ - get roomId() { - const ret = wasm.roomkeyinfo_roomId(this.__wbg_ptr); - return RoomId.__wrap(ret); - } - /** - * The Curve25519 key of the device which initiated the session originally. - * @returns {Curve25519PublicKey} - */ - get senderKey() { - const ret = wasm.roomkeyinfo_senderKey(this.__wbg_ptr); - return Curve25519PublicKey.__wrap(ret); - } - /** - * The ID of the session that the key is for. - * @returns {string} - */ - get sessionId() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.roomkeyinfo_sessionId(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } -} -exports.RoomKeyInfo = RoomKeyInfo; -if (Symbol.dispose) RoomKeyInfo.prototype[Symbol.dispose] = RoomKeyInfo.prototype.free; - -/** - * Information on a received `m.room_key.withheld` event. - */ -class RoomKeyWithheldInfo { - static __wrap(ptr) { - const obj = Object.create(RoomKeyWithheldInfo.prototype); - obj.__wbg_ptr = ptr; - RoomKeyWithheldInfoFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - RoomKeyWithheldInfoFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_roomkeywithheldinfo_free(ptr, 0); - } - /** - * The encryption algorithm of the session that is being withheld. - * - * This may be from an `m.room_key.withheld` event, or from a shared room - * key bundle under MSC4268. - * @returns {EncryptionAlgorithm} - */ - get algorithm() { - const ret = wasm.roomkeywithheldinfo_algorithm(this.__wbg_ptr); - return ret; - } - /** - * The room ID of the session that is being withheld. - * @returns {RoomId} - */ - get roomId() { - const ret = wasm.roomkeywithheldinfo_roomId(this.__wbg_ptr); - return RoomId.__wrap(ret); - } - /** - * The User ID of the sender of the withheld information. - * - * This may be the sender of an `m.room_key.withheld` event, or the sender - * of a shared room key bundle under MSC4268. - * @returns {UserId} - */ - get sender() { - const ret = wasm.roomkeywithheldinfo_sender(this.__wbg_ptr); - return UserId.__wrap(ret); - } - /** - * The session ID of the session that is being withheld. - * @returns {string} - */ - get sessionId() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.roomkeywithheldinfo_sessionId(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The `code` indicating why the key was withheld, such as `m.unverified`. - * - * This may be from an `m.room_key.withheld` event (such as - * `m.unverified`), or from a shared room key bundle under MSC4268. - * @returns {string} - */ - get withheldCode() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.roomkeywithheldinfo_withheldCode(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } -} -exports.RoomKeyWithheldInfo = RoomKeyWithheldInfo; -if (Symbol.dispose) RoomKeyWithheldInfo.prototype[Symbol.dispose] = RoomKeyWithheldInfo.prototype.free; - -/** - * A customized owned request type for sending out room messages - * ([specification]). - * - * [specification]: https://spec.matrix.org/unstable/client-server-api/#put_matrixclientv3roomsroomidsendeventtypetxnid - */ -class RoomMessageRequest { - static __wrap(ptr) { - const obj = Object.create(RoomMessageRequest.prototype); - obj.__wbg_ptr = ptr; - RoomMessageRequestFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - RoomMessageRequestFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_roommessagerequest_free(ptr, 0); - } - /** - * A JSON-encoded object containing the message's content. - * @returns {string} - */ - get body() { - const ret = wasm.__wbg_get_roommessagerequest_body(this.__wbg_ptr); - return ret; - } - /** - * A string representing the type of event to be sent. - * @returns {string} - */ - get event_type() { - const ret = wasm.__wbg_get_roommessagerequest_event_type(this.__wbg_ptr); - return ret; - } - /** - * The request ID. - * @returns {string} - */ - get id() { - const ret = wasm.__wbg_get_roommessagerequest_id(this.__wbg_ptr); - return ret; - } - /** - * A string representing the room to send the event to. - * @returns {string} - */ - get room_id() { - const ret = wasm.__wbg_get_roommessagerequest_room_id(this.__wbg_ptr); - return ret; - } - /** - * A string representing the transaction ID for this event. - * - * Clients should generate an ID unique across requests with the same - * access token; it will be used by the server to ensure idempotency of - * requests. - * @returns {string} - */ - get txn_id() { - const ret = wasm.__wbg_get_roommessagerequest_txn_id(this.__wbg_ptr); - return ret; - } - /** - * Create a new `RoomMessageRequest`. - * @param {string} id - * @param {string} room_id - * @param {string} txn_id - * @param {string} event_type - * @param {string} content - */ - constructor(id, room_id, txn_id, event_type, content) { - const ret = wasm.roommessagerequest_new(id, room_id, txn_id, event_type, content); - this.__wbg_ptr = ret; - RoomMessageRequestFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Get its request type. - * @returns {RequestType} - */ - get type() { - const ret = wasm.roommessagerequest_type(this.__wbg_ptr); - return ret; - } -} -exports.RoomMessageRequest = RoomMessageRequest; -if (Symbol.dispose) RoomMessageRequest.prototype[Symbol.dispose] = RoomMessageRequest.prototype.free; - -/** - * Information on a room which is waiting for a key bundle to arrive. - */ -class RoomPendingKeyBundleDetails { - static __wrap(ptr) { - const obj = Object.create(RoomPendingKeyBundleDetails.prototype); - obj.__wbg_ptr = ptr; - RoomPendingKeyBundleDetailsFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - RoomPendingKeyBundleDetailsFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_roompendingkeybundledetails_free(ptr, 0); - } - /** - * The time that the invite was accepted. - * @returns {number} - */ - get inviteAcceptedAtMillis() { - const ret = wasm.roompendingkeybundledetails_inviteAcceptedAtMillis(this.__wbg_ptr); - return ret; - } - /** - * The ID of the user that invited us - * @returns {UserId} - */ - get inviterId() { - const ret = wasm.roompendingkeybundledetails_inviterId(this.__wbg_ptr); - return UserId.__wrap(ret); - } - /** - * The room that is waiting for a key bundle. - * @returns {RoomId} - */ - get roomId() { - const ret = wasm.roompendingkeybundledetails_roomId(this.__wbg_ptr); - return RoomId.__wrap(ret); - } -} -exports.RoomPendingKeyBundleDetails = RoomPendingKeyBundleDetails; -if (Symbol.dispose) RoomPendingKeyBundleDetails.prototype[Symbol.dispose] = RoomPendingKeyBundleDetails.prototype.free; - -/** - * Room encryption settings which are modified by state events or user options - */ -class RoomSettings { - static __wrap(ptr) { - const obj = Object.create(RoomSettings.prototype); - obj.__wbg_ptr = ptr; - RoomSettingsFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - RoomSettingsFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_roomsettings_free(ptr, 0); - } - /** - * The encryption algorithm that should be used in the room. - * - * Should be one of the members of {@link EncryptionAlgorithm}. - * @returns {EncryptionAlgorithm} - */ - get algorithm() { - const ret = wasm.__wbg_get_roomsettings_algorithm(this.__wbg_ptr); - return ret; - } - /** - * Whether state event encryption is enabled. - * @returns {boolean} - */ - get encryptStateEvents() { - const ret = wasm.__wbg_get_roomsettings_encryptStateEvents(this.__wbg_ptr); - return ret !== 0; - } - /** - * Whether untrusted devices should receive room keys. If this is `false`, - * they will be excluded from the conversation. - * @returns {boolean} - */ - get onlyAllowTrustedDevices() { - const ret = wasm.__wbg_get_roomsettings_onlyAllowTrustedDevices(this.__wbg_ptr); - return ret !== 0; - } - /** - * The maximum number of messages an encryption session should be used for, - * before it is rotated. - * @returns {number | undefined} - */ - get sessionRotationPeriodMessages() { - const ret = wasm.__wbg_get_roomsettings_sessionRotationPeriodMessages(this.__wbg_ptr); - return ret[0] === 0 ? undefined : ret[1]; - } - /** - * The maximum time, in milliseconds, that an encryption session should be - * used for, before it is rotated. - * @returns {number | undefined} - */ - get sessionRotationPeriodMs() { - const ret = wasm.__wbg_get_roomsettings_sessionRotationPeriodMs(this.__wbg_ptr); - return ret[0] === 0 ? undefined : ret[1]; - } - /** - * Create a new `RoomSettings` with default values. - */ - constructor() { - const ret = wasm.roomsettings_new(); - this.__wbg_ptr = ret; - RoomSettingsFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * The encryption algorithm that should be used in the room. - * - * Should be one of the members of {@link EncryptionAlgorithm}. - * @param {EncryptionAlgorithm} arg0 - */ - set algorithm(arg0) { - wasm.__wbg_set_roomsettings_algorithm(this.__wbg_ptr, arg0); - } - /** - * Whether state event encryption is enabled. - * @param {boolean} arg0 - */ - set encryptStateEvents(arg0) { - wasm.__wbg_set_roomsettings_encryptStateEvents(this.__wbg_ptr, arg0); - } - /** - * Whether untrusted devices should receive room keys. If this is `false`, - * they will be excluded from the conversation. - * @param {boolean} arg0 - */ - set onlyAllowTrustedDevices(arg0) { - wasm.__wbg_set_roomsettings_onlyAllowTrustedDevices(this.__wbg_ptr, arg0); - } - /** - * The maximum number of messages an encryption session should be used for, - * before it is rotated. - * @param {number | null} [arg0] - */ - set sessionRotationPeriodMessages(arg0) { - wasm.__wbg_set_roomsettings_sessionRotationPeriodMessages(this.__wbg_ptr, !isLikeNone(arg0), isLikeNone(arg0) ? 0 : arg0); - } - /** - * The maximum time, in milliseconds, that an encryption session should be - * used for, before it is rotated. - * @param {number | null} [arg0] - */ - set sessionRotationPeriodMs(arg0) { - wasm.__wbg_set_roomsettings_sessionRotationPeriodMs(this.__wbg_ptr, !isLikeNone(arg0), isLikeNone(arg0) ? 0 : arg0); - } -} -exports.RoomSettings = RoomSettings; -if (Symbol.dispose) RoomSettings.prototype[Symbol.dispose] = RoomSettings.prototype.free; - -/** - * Short Authentication String (SAS) verification. - */ -class Sas { - static __wrap(ptr) { - const obj = Object.create(Sas.prototype); - obj.__wbg_ptr = ptr; - SasFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - SasFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_sas_free(ptr, 0); - } - /** - * Accept the SAS verification. - * - * This does nothing (and returns `undefined`) if the verification was - * already accepted, otherwise it returns an `OutgoingVerificationRequest` - * that needs to be sent out. - * @returns {OutgoingVerificationRequest | undefined} - */ - accept() { - const ret = wasm.sas_accept(this.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Are we in a state where we can show the short auth string? - * @returns {boolean} - */ - canBePresented() { - const ret = wasm.sas_canBePresented(this.__wbg_ptr); - return ret !== 0; - } - /** - * Cancel the verification. - * - * Returns either an `OutgoingVerificationRequest` which should be sent - * out, or `undefined` if the verification is already cancelled. - * @returns {OutgoingVerificationRequest | undefined} - */ - cancel() { - const ret = wasm.sas_cancel(this.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Get info about the cancellation if the verification flow has - * been cancelled. - * @returns {CancelInfo | undefined} - */ - cancelInfo() { - const ret = wasm.sas_cancelInfo(this.__wbg_ptr); - return ret === 0 ? undefined : CancelInfo.__wrap(ret); - } - /** - * Cancel the verification. - * - * This cancels the verification with given code (e.g. `m.user`). - * - * Returns either an `OutgoingVerificationRequest` which should be sent - * out, or `undefined` if the verification is already cancelled. - * @param {string} code - * @returns {OutgoingVerificationRequest | undefined} - */ - cancelWithCode(code) { - const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.sas_cancelWithCode(this.__wbg_ptr, ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Confirm the SAS verification. - * - * This confirms that the short auth strings match on both sides. - * - * Does nothing if we’re not in a state where we can confirm the - * short auth string. - * - * Returns a `Promise` for an array of `OutgoingVerificationRequest`s. - * @returns {Promise} - */ - confirm() { - const ret = wasm.sas_confirm(this.__wbg_ptr); - return ret; - } - /** - * Get the decimal version of the short auth string. - * - * Returns None if we can’t yet present the short auth string, - * otherwise a tuple containing three 4-digit integers that - * represent the short auth string. - * @returns {Uint16Array | undefined} - */ - decimals() { - const ret = wasm.sas_decimals(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getArrayU16FromWasm0(ret[0], ret[1]).slice(); - wasm.__wbindgen_free(ret[0], ret[1] * 2, 2); - } - return v1; - } - /** - * Get our own device ID. - * @returns {DeviceId} - */ - get deviceId() { - const ret = wasm.sas_deviceId(this.__wbg_ptr); - return DeviceId.__wrap(ret); - } - /** - * Get the emoji version of the short auth string. - * - * Returns `undefined` if we can't yet present the short auth string, - * otherwise an array of seven `Emoji` objects. - * @returns {Emoji[] | undefined} - */ - emoji() { - const ret = wasm.sas_emoji(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getArrayJsValueFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 4, 4); - } - return v1; - } - /** - * Get the index of the emoji representing the short auth string - * - * Returns `undefined` if we can’t yet present the short auth - * string, otherwise seven `u8` numbers in the range from 0 to 63 - * inclusive which can be converted to an emoji using [the - * relevant specification - * entry](https://spec.matrix.org/unstable/client-server-api/#sas-method-emoji). - * @returns {Uint8Array | undefined} - */ - emojiIndex() { - const ret = wasm.sas_emojiIndex(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * Get the unique ID that identifies this SAS verification flow, - * be either a to-device request ID or a room event ID. - * @returns {string} - */ - get flowId() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.sas_flowId(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Has the verification been accepted by both parties? - * @returns {boolean} - */ - hasBeenAccepted() { - const ret = wasm.sas_hasBeenAccepted(this.__wbg_ptr); - return ret !== 0; - } - /** - * Have we confirmed that the short auth string matches? - * @returns {boolean} - */ - haveWeConfirmed() { - const ret = wasm.sas_haveWeConfirmed(this.__wbg_ptr); - return ret !== 0; - } - /** - * Is the SAS flow cancelled? - * @returns {boolean} - */ - isCancelled() { - const ret = wasm.sas_isCancelled(this.__wbg_ptr); - return ret !== 0; - } - /** - * Is the SAS flow done? - * @returns {boolean} - */ - isDone() { - const ret = wasm.sas_isDone(this.__wbg_ptr); - return ret !== 0; - } - /** - * Is this a verification that is verifying one of our own - * devices? - * @returns {boolean} - */ - isSelfVerification() { - const ret = wasm.sas_isSelfVerification(this.__wbg_ptr); - return ret !== 0; - } - /** - * Get the device ID of the other side. - * @returns {DeviceId} - */ - get otherDeviceId() { - const ret = wasm.sas_otherDeviceId(this.__wbg_ptr); - return DeviceId.__wrap(ret); - } - /** - * Get the user id of the other side. - * @returns {UserId} - */ - get otherUserId() { - const ret = wasm.sas_otherUserId(this.__wbg_ptr); - return UserId.__wrap(ret); - } - /** - * Register a callback which will be called whenever there is an update to - * the request. - * - * The `callback` is called with no parameters. - * @param {() => Promise} callback - */ - registerChangesCallback(callback) { - wasm.sas_registerChangesCallback(this.__wbg_ptr, callback); - } - /** - * Get the room ID if the verification is happening inside a - * room. - * @returns {RoomId | undefined} - */ - get roomId() { - const ret = wasm.sas_roomId(this.__wbg_ptr); - return ret === 0 ? undefined : RoomId.__wrap(ret); - } - /** - * Did this verification flow start from a verification request? - * @returns {boolean} - */ - startedFromRequest() { - const ret = wasm.sas_startedFromRequest(this.__wbg_ptr); - return ret !== 0; - } - /** - * Does this verification flow support displaying emoji for the - * short authentication string? - * @returns {boolean} - */ - supportsEmoji() { - const ret = wasm.sas_supportsEmoji(this.__wbg_ptr); - return ret !== 0; - } - /** - * Has the SAS verification flow timed out? - * @returns {boolean} - */ - timedOut() { - const ret = wasm.sas_timedOut(this.__wbg_ptr); - return ret !== 0; - } - /** - * Get our own user ID. - * @returns {UserId} - */ - get userId() { - const ret = wasm.sas_userId(this.__wbg_ptr); - return UserId.__wrap(ret); - } - /** - * True if we initiated the verification flow (ie, we sent the - * `m.key.verification.request`). - * @returns {boolean} - */ - weStarted() { - const ret = wasm.sas_weStarted(this.__wbg_ptr); - return ret !== 0; - } -} -exports.Sas = Sas; -if (Symbol.dispose) Sas.prototype[Symbol.dispose] = Sas.prototype.free; - -/** - * Struct containing the bundle of secrets to fully activate a new device for - * end-to-end encryption. - */ -class SecretsBundle { - static __wrap(ptr) { - const obj = Object.create(SecretsBundle.prototype); - obj.__wbg_ptr = ptr; - SecretsBundleFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - SecretsBundleFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_secretsbundle_free(ptr, 0); - } - /** - * The bundle of the backup decryption key and backup version if any. - * @returns {BackupSecretsBundle | undefined} - */ - get backupBundle() { - const ret = wasm.secretsbundle_backupBundle(this.__wbg_ptr); - return ret === 0 ? undefined : BackupSecretsBundle.__wrap(ret); - } - /** - * Deserialize the [`SecretsBundle`] from a JSON object. - * @param {unknown} json - * @returns {SecretsBundle} - */ - static from_json(json) { - const ret = wasm.secretsbundle_from_json(json); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return SecretsBundle.__wrap(ret[0]); - } - /** - * The seed of the master key encoded as unpadded base64. - * @returns {string} - */ - get masterKey() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.secretsbundle_masterKey(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The seed of the self signing key encoded as unpadded base64. - * @returns {string} - */ - get selfSigningKey() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.secretsbundle_selfSigningKey(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Serialize the [`SecretsBundle`] to a JSON object. - * @returns {unknown} - */ - to_json() { - const ret = wasm.secretsbundle_to_json(this.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * The seed of the user signing key encoded as unpadded base64. - * @returns {string} - */ - get userSigningKey() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.secretsbundle_userSigningKey(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } -} -exports.SecretsBundle = SecretsBundle; -if (Symbol.dispose) SecretsBundle.prototype[Symbol.dispose] = SecretsBundle.prototype.free; - -/** - * A Matrix-spec compliant [server name]. - * - * It consists of a host and an optional port (separated by a colon if - * present). - * - * [server name]: https://spec.matrix.org/v1.2/appendices/#server-name - */ -class ServerName { - static __wrap(ptr) { - const obj = Object.create(ServerName.prototype); - obj.__wbg_ptr = ptr; - ServerNameFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - ServerNameFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_servername_free(ptr, 0); - } - /** - * Returns the host of the server name. - * - * That is: Return the part of the server before `:` or the - * full server name if there is no port. - * @returns {string} - */ - get host() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.servername_host(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Returns true if and only if the server name is an IPv4 or IPv6 - * address. - * @returns {boolean} - */ - isIpLiteral() { - const ret = wasm.servername_isIpLiteral(this.__wbg_ptr); - return ret !== 0; - } - /** - * Parse/validate and create a new `ServerName`. - * @param {string} name - */ - constructor(name) { - const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.servername_new(ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - this.__wbg_ptr = ret[0]; - ServerNameFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Returns the port of the server name if any. - * @returns {number | undefined} - */ - get port() { - const ret = wasm.servername_port(this.__wbg_ptr); - return ret === 0xFFFFFF ? undefined : ret; - } -} -exports.ServerName = ServerName; -if (Symbol.dispose) ServerName.prototype[Symbol.dispose] = ServerName.prototype.free; - -/** - * Take a look at [`matrix_sdk_common::deserialized_responses::ShieldState`] - * for more info. - * @enum {0 | 1 | 2} - */ -const ShieldColor = exports.ShieldColor = Object.freeze({ - /** - * Important warning - */ - Red: 0, - "0": "Red", - /** - * Low warning - */ - Grey: 1, - "1": "Grey", - /** - * No warning - */ - None: 2, - "2": "None" -}); - -/** - * Take a look at [`matrix_sdk_common::deserialized_responses::ShieldState`] - * for more info. - */ -class ShieldState { - static __wrap(ptr) { - const obj = Object.create(ShieldState.prototype); - obj.__wbg_ptr = ptr; - ShieldStateFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - ShieldStateFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_shieldstate_free(ptr, 0); - } - /** - * A machine-readable representation of the authenticity for a - * `ShieldState`. - * @returns {ShieldStateCode | undefined} - */ - get code() { - const ret = wasm.__wbg_get_shieldstate_code(this.__wbg_ptr); - return ret === 6 ? undefined : ret; - } - /** - * The shield color - * @returns {ShieldColor} - */ - get color() { - const ret = wasm.__wbg_get_shieldstate_color(this.__wbg_ptr); - return ret; - } - /** - * A machine-readable representation of the authenticity for a - * `ShieldState`. - * @param {ShieldStateCode | null} [arg0] - */ - set code(arg0) { - wasm.__wbg_set_shieldstate_code(this.__wbg_ptr, isLikeNone(arg0) ? 6 : arg0); - } - /** - * The shield color - * @param {ShieldColor} arg0 - */ - set color(arg0) { - wasm.__wbg_set_shieldstate_color(this.__wbg_ptr, arg0); - } - /** - * Error message that can be displayed as a tooltip - * @returns {string | undefined} - */ - get message() { - const ret = wasm.shieldstate_message(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } -} -exports.ShieldState = ShieldState; -if (Symbol.dispose) ShieldState.prototype[Symbol.dispose] = ShieldState.prototype.free; - -/** - * A machine-readable representation of the authenticity for a `ShieldState`. - * @enum {0 | 1 | 2 | 3 | 4 | 5} - */ -const ShieldStateCode = exports.ShieldStateCode = Object.freeze({ - /** - * Not enough information available to check the authenticity. - */ - AuthenticityNotGuaranteed: 0, - "0": "AuthenticityNotGuaranteed", - /** - * The sending device isn't yet known by the Client. - */ - UnknownDevice: 1, - "1": "UnknownDevice", - /** - * The sending device hasn't been verified by the sender. - */ - UnsignedDevice: 2, - "2": "UnsignedDevice", - /** - * The sender hasn't been verified by the Client's user. - */ - UnverifiedIdentity: 3, - "3": "UnverifiedIdentity", - /** - * The sender was previously verified but changed their identity. - */ - VerificationViolation: 4, - "4": "VerificationViolation", - /** - * The `sender` field on the event does not match the owner of the device - * that established the Megolm session. - */ - MismatchedSender: 5, - "5": "MismatchedSender" -}); - -/** - * Represents a potentially decoded signature (but not a validated - * one). - */ -class Signature { - static __wrap(ptr) { - const obj = Object.create(Signature.prototype); - obj.__wbg_ptr = ptr; - SignatureFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - SignatureFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_signature_free(ptr, 0); - } - /** - * Get the Ed25519 signature, if this is one. - * @returns {Ed25519Signature | undefined} - */ - get ed25519() { - const ret = wasm.signature_ed25519(this.__wbg_ptr); - return ret === 0 ? undefined : Ed25519Signature.__wrap(ret); - } - /** - * Convert the signature to a base64 encoded string. - * @returns {string} - */ - toBase64() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.signature_toBase64(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } -} -exports.Signature = Signature; -if (Symbol.dispose) Signature.prototype[Symbol.dispose] = Signature.prototype.free; - -/** - * The result of a signature check. - * @enum {0 | 1 | 2 | 3} - */ -const SignatureState = exports.SignatureState = Object.freeze({ - /** - * The signature is missing. - */ - Missing: 0, - "0": "Missing", - /** - * The signature is invalid. - */ - Invalid: 1, - "1": "Invalid", - /** - * The signature is valid but the device or user identity that created the - * signature is not trusted. - */ - ValidButNotTrusted: 2, - "2": "ValidButNotTrusted", - /** - * The signature is valid and the device or user identity that created the - * signature is trusted. - */ - ValidAndTrusted: 3, - "3": "ValidAndTrusted" -}); - -/** - * Data for a request to the `/keys/signatures/upload` API endpoint - * ([specification]). - * - * Publishes cross-signing signatures for the user. - * - * [specification]: https://spec.matrix.org/unstable/client-server-api/#post_matrixclientv3keyssignaturesupload - */ -class SignatureUploadRequest { - static __wrap(ptr) { - const obj = Object.create(SignatureUploadRequest.prototype); - obj.__wbg_ptr = ptr; - SignatureUploadRequestFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - SignatureUploadRequestFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_signatureuploadrequest_free(ptr, 0); - } - /** - * A JSON-encoded object containing the payload of the request - * - * It represents the body of the HTTP request. - * @returns {string} - */ - get body() { - const ret = wasm.__wbg_get_signatureuploadrequest_body(this.__wbg_ptr); - return ret; - } - /** - * The request ID. - * Some signature upload will have to an `id` field, some won't. - * They have one when they are created automatically during an interactive - * verification, otherwise they don't. - * @returns {string | undefined} - */ - get id() { - const ret = wasm.__wbg_get_signatureuploadrequest_id(this.__wbg_ptr); - return ret; - } - /** - * Create a new `SignatureUploadRequest`. - * @param {string} id - * @param {string} signed_keys - */ - constructor(id, signed_keys) { - const ret = wasm.signatureuploadrequest_new(id, signed_keys); - this.__wbg_ptr = ret; - SignatureUploadRequestFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Get its request type. - * @returns {RequestType} - */ - get type() { - const ret = wasm.signatureuploadrequest_type(this.__wbg_ptr); - return ret; - } -} -exports.SignatureUploadRequest = SignatureUploadRequest; -if (Symbol.dispose) SignatureUploadRequest.prototype[Symbol.dispose] = SignatureUploadRequest.prototype.free; - -/** - * The result of a signature verification of a signed JSON object. - */ -class SignatureVerification { - static __wrap(ptr) { - const obj = Object.create(SignatureVerification.prototype); - obj.__wbg_ptr = ptr; - SignatureVerificationFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - SignatureVerificationFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_signatureverification_free(ptr, 0); - } - /** - * Give the backup signature state from the current device. - * See SignatureState for values - * @returns {SignatureState} - */ - get deviceState() { - const ret = wasm.signatureverification_deviceState(this.__wbg_ptr); - return ret; - } - /** - * Is the result considered to be trusted? - * - * This tells us if the result has a valid signature from any of the - * following: - * - * * Our own device - * * Our own user identity, provided the identity is trusted as well - * * Any of our own devices, provided the device is trusted as well - * @returns {boolean} - */ - trusted() { - const ret = wasm.signatureverification_trusted(this.__wbg_ptr); - return ret !== 0; - } - /** - * Give the backup signature state from the current user identity. - * See SignatureState for values - * @returns {SignatureState} - */ - get userState() { - const ret = wasm.signatureverification_userState(this.__wbg_ptr); - return ret; - } -} -exports.SignatureVerification = SignatureVerification; -if (Symbol.dispose) SignatureVerification.prototype[Symbol.dispose] = SignatureVerification.prototype.free; - -/** - * A collection of `Signature`. - */ -class Signatures { - static __wrap(ptr) { - const obj = Object.create(Signatures.prototype); - obj.__wbg_ptr = ptr; - SignaturesFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - SignaturesFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_signatures_free(ptr, 0); - } - /** - * Add the given signature from the given signer and the given key ID to - * the collection. - * @param {UserId} signer - * @param {DeviceKeyId} key_id - * @param {Ed25519Signature} signature - * @returns {MaybeSignature | undefined} - */ - addSignature(signer, key_id, signature) { - _assertClass(signer, UserId); - _assertClass(key_id, DeviceKeyId); - _assertClass(signature, Ed25519Signature); - const ret = wasm.signatures_addSignature(this.__wbg_ptr, signer.__wbg_ptr, key_id.__wbg_ptr, signature.__wbg_ptr); - return ret === 0 ? undefined : MaybeSignature.__wrap(ret); - } - /** - * Get the json with all signatures - * @returns {string} - */ - asJSON() { - const ret = wasm.signatures_asJSON(this.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Remove all the signatures we currently hold. - */ - clear() { - wasm.signatures_clear(this.__wbg_ptr); - } - /** - * How many signatures do we currently hold. - * @returns {number} - */ - get count() { - const ret = wasm.signatures_count(this.__wbg_ptr); - return ret >>> 0; - } - /** - * Get the map of signatures that belong to the given user. - * @param {UserId} signer - * @returns {Map | undefined} - */ - get(signer) { - _assertClass(signer, UserId); - const ret = wasm.signatures_get(this.__wbg_ptr, signer.__wbg_ptr); - return ret; - } - /** - * Try to find an Ed25519 signature from the given signer with - * the given key ID. - * @param {UserId} signer - * @param {DeviceKeyId} key_id - * @returns {Ed25519Signature | undefined} - */ - getSignature(signer, key_id) { - _assertClass(signer, UserId); - _assertClass(key_id, DeviceKeyId); - const ret = wasm.signatures_getSignature(this.__wbg_ptr, signer.__wbg_ptr, key_id.__wbg_ptr); - return ret === 0 ? undefined : Ed25519Signature.__wrap(ret); - } - /** - * Do we hold any signatures or is our collection completely - * empty. - * @returns {boolean} - */ - isEmpty() { - const ret = wasm.signatures_isEmpty(this.__wbg_ptr); - return ret !== 0; - } - /** - * Creates a new, empty, signatures collection. - */ - constructor() { - const ret = wasm.signatures_new(); - this.__wbg_ptr = ret; - SignaturesFinalization.register(this, this.__wbg_ptr, this); - return this; - } -} -exports.Signatures = Signatures; -if (Symbol.dispose) Signatures.prototype[Symbol.dispose] = Signatures.prototype.free; - -/** - * A struct containing an open connection to a CryptoStore. - * - * Opening the CryptoStore can take some time, due to the PBKDF calculation - * involved, so if multiple operations are being done on the same store, it is - * more efficient to open it once. - */ -class StoreHandle { - static __wrap(ptr) { - const obj = Object.create(StoreHandle.prototype); - obj.__wbg_ptr = ptr; - StoreHandleFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - StoreHandleFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_storehandle_free(ptr, 0); - } - /** - * Open a crypto store. - * - * The created store will be based on IndexedDB if a `store_name` is - * provided; otherwise it will be based on a memory store and once the - * objects is dropped, the keys will be lost. - * - * # Arguments - * - * * `store_name` - The name that should be used to open the IndexedDB - * based database. If this isn't provided, a memory-only store will be - * used. *Note* the memory-only store will lose your E2EE keys when the - * `StoreHandle` gets dropped. - * - * * `store_passphrase` - The passphrase that should be used to encrypt the - * store, for IndexedDB-based stores - * - * * `logger` - An optional logger instance to use for writing log messages - * during the open operation. An instance of `JsLogger`. - * @param {string | null | undefined} store_name - * @param {string | null | undefined} store_passphrase - * @param {JsLogger} [logger] - * @returns {Promise} - */ - static open(store_name, store_passphrase, logger) { - var ptr0 = isLikeNone(store_name) ? 0 : passStringToWasm0(store_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - var ptr1 = isLikeNone(store_passphrase) ? 0 : passStringToWasm0(store_passphrase, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len1 = WASM_VECTOR_LEN; - const ret = wasm.storehandle_open(ptr0, len0, ptr1, len1, isLikeNone(logger) ? 0 : addToExternrefTable0(logger)); - return ret; - } - /** - * Open a crypto store based on IndexedDB, using the given key for - * encryption. - * - * # Arguments - * - * * `store_name` - The name that should be used to open the IndexedDB - * based database. - * - * * `store_key` - The key that should be used to encrypt the store, for - * IndexedDB-based stores. Must be a 32-byte array. - * - * * `logger` - An optional logger instance to use for writing log messages - * during the open operation. An instance of `JsLogger`. - * @param {string} store_name - * @param {Uint8Array} store_key - * @param {JsLogger} [logger] - * @returns {Promise} - */ - static openWithKey(store_name, store_key, logger) { - const ptr0 = passStringToWasm0(store_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passArray8ToWasm0(store_key, wasm.__wbindgen_malloc); - const len1 = WASM_VECTOR_LEN; - const ret = wasm.storehandle_openWithKey(ptr0, len0, ptr1, len1, isLikeNone(logger) ? 0 : addToExternrefTable0(logger)); - return ret; - } -} -exports.StoreHandle = StoreHandle; -if (Symbol.dispose) StoreHandle.prototype[Symbol.dispose] = StoreHandle.prototype.free; - -/** - * Information on a stored room key bundle data event. - */ -class StoredRoomKeyBundleData { - static __wrap(ptr) { - const obj = Object.create(StoredRoomKeyBundleData.prototype); - obj.__wbg_ptr = ptr; - StoredRoomKeyBundleDataFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - StoredRoomKeyBundleDataFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_storedroomkeybundledata_free(ptr, 0); - } - /** - * The JSON-encoded encryption info for the key bundle. - * - * @deprecated Should not be used within applications. - * @returns {string} - */ - get encryptionInfo() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.storedroomkeybundledata_encryptionInfo(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The room that these keys are for. - * @returns {RoomId} - */ - get roomId() { - const ret = wasm.storedroomkeybundledata_roomId(this.__wbg_ptr); - return RoomId.__wrap(ret); - } - /** - * The user that sent us this data. - * @returns {UserId} - */ - get senderUser() { - const ret = wasm.storedroomkeybundledata_senderUser(this.__wbg_ptr); - return UserId.__wrap(ret); - } - /** - * The location of the bundle. - * @returns {string} - */ - get url() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.storedroomkeybundledata_url(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } -} -exports.StoredRoomKeyBundleData = StoredRoomKeyBundleData; -if (Symbol.dispose) StoredRoomKeyBundleData.prototype[Symbol.dispose] = StoredRoomKeyBundleData.prototype.free; - -/** - * Struct containing information on how a to-device message was decrypted. - */ -class ToDeviceEncryptionInfo { - static __wrap(ptr) { - const obj = Object.create(ToDeviceEncryptionInfo.prototype); - obj.__wbg_ptr = ptr; - ToDeviceEncryptionInfoFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - ToDeviceEncryptionInfoFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_todeviceencryptioninfo_free(ptr, 0); - } - /** - * The base64-encoded public Curve25519 key of the device that encrypted - * the message. - * @returns {string} - */ - get senderCurve25519Key() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_todeviceencryptioninfo_senderCurve25519Key(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The device ID of the device that sent us the to-device message. - * - * Could be `undefined` in the case where the to-device message sender - * checks are delayed. There is no delay for to-device messages other - * than `m.room_key`, so this will always be truthy for other - * message types (the decryption would fail if the sender device keys - * cannot be found). - * - * Note this is untrusted data unless {@link isSenderVerified} is true. - * @returns {DeviceId | undefined} - */ - get senderDevice() { - const ret = wasm.__wbg_get_todeviceencryptioninfo_senderDevice(this.__wbg_ptr); - return ret === 0 ? undefined : DeviceId.__wrap(ret); - } - /** - * The user ID of the sender of the event. - * - * Note this is untrusted data unless {@link isSenderVerified} is true. - * @returns {UserId} - */ - get sender() { - const ret = wasm.__wbg_get_todeviceencryptioninfo_sender(this.__wbg_ptr); - return UserId.__wrap(ret); - } - /** - * The base64-encoded public Curve25519 key of the device that encrypted - * the message. - * @param {string} arg0 - */ - set senderCurve25519Key(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_todeviceencryptioninfo_senderCurve25519Key(this.__wbg_ptr, ptr0, len0); - } - /** - * The device ID of the device that sent us the to-device message. - * - * Could be `undefined` in the case where the to-device message sender - * checks are delayed. There is no delay for to-device messages other - * than `m.room_key`, so this will always be truthy for other - * message types (the decryption would fail if the sender device keys - * cannot be found). - * - * Note this is untrusted data unless {@link isSenderVerified} is true. - * @param {DeviceId | null} [arg0] - */ - set senderDevice(arg0) { - let ptr0 = 0; - if (!isLikeNone(arg0)) { - _assertClass(arg0, DeviceId); - ptr0 = arg0.__destroy_into_raw(); - } - wasm.__wbg_set_todeviceencryptioninfo_senderDevice(this.__wbg_ptr, ptr0); - } - /** - * The user ID of the sender of the event. - * - * Note this is untrusted data unless {@link isSenderVerified} is true. - * @param {UserId} arg0 - */ - set sender(arg0) { - _assertClass(arg0, UserId); - var ptr0 = arg0.__destroy_into_raw(); - wasm.__wbg_set_todeviceencryptioninfo_sender(this.__wbg_ptr, ptr0); - } - /** - * Returns whether the sender device is in a verified state. - * This reflects the state at the time of decryption. - * @returns {boolean} - */ - isSenderVerified() { - const ret = wasm.todeviceencryptioninfo_isSenderVerified(this.__wbg_ptr); - return ret !== 0; - } -} -exports.ToDeviceEncryptionInfo = ToDeviceEncryptionInfo; -if (Symbol.dispose) ToDeviceEncryptionInfo.prototype[Symbol.dispose] = ToDeviceEncryptionInfo.prototype.free; - -/** - * Data for a request to the `/sendToDevice` API endpoint - * ([specification]). - * - * Send an event to a single device or to a group of devices. - * - * [specification]: https://spec.matrix.org/unstable/client-server-api/#put_matrixclientv3sendtodeviceeventtypetxnid - */ -class ToDeviceRequest { - static __wrap(ptr) { - const obj = Object.create(ToDeviceRequest.prototype); - obj.__wbg_ptr = ptr; - ToDeviceRequestFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - ToDeviceRequestFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_todevicerequest_free(ptr, 0); - } - /** - * A JSON-encoded object containing the rest of the payload: `messages`. - * - * It represents the body of the HTTP request. - * @returns {string} - */ - get body() { - const ret = wasm.__wbg_get_todevicerequest_body(this.__wbg_ptr); - return ret; - } - /** - * A string representing the type of event being sent to each devices. - * @returns {string} - */ - get event_type() { - const ret = wasm.__wbg_get_todevicerequest_event_type(this.__wbg_ptr); - return ret; - } - /** - * The request ID. - * For to-device request this would be the same value as `txn_id`. It is - * exposed also as `id` so that the js bindings are consistent with the - * other request types by using this field to mark as sent. - * @returns {string} - */ - get id() { - const ret = wasm.__wbg_get_todevicerequest_id(this.__wbg_ptr); - return ret; - } - /** - * A string representing a request identifier unique to the access token - * used to send the request. - * @returns {string} - */ - get txn_id() { - const ret = wasm.__wbg_get_todevicerequest_txn_id(this.__wbg_ptr); - return ret; - } - /** - * Create a new `ToDeviceRequest`. - * @param {string} id - * @param {string} event_type - * @param {string} txn_id - * @param {string} body - */ - constructor(id, event_type, txn_id, body) { - const ret = wasm.todevicerequest_new(id, event_type, txn_id, body); - this.__wbg_ptr = ret; - ToDeviceRequestFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Get its request type. - * @returns {RequestType} - */ - get type() { - const ret = wasm.todevicerequest_type(this.__wbg_ptr); - return ret; - } -} -exports.ToDeviceRequest = ToDeviceRequest; -if (Symbol.dispose) ToDeviceRequest.prototype[Symbol.dispose] = ToDeviceRequest.prototype.free; - -/** - * Metadata about a to-device event that could not be decrypted. - */ -class ToDeviceUnableToDecryptInfo { - static __wrap(ptr) { - const obj = Object.create(ToDeviceUnableToDecryptInfo.prototype); - obj.__wbg_ptr = ptr; - ToDeviceUnableToDecryptInfoFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - ToDeviceUnableToDecryptInfoFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_todeviceunabletodecryptinfo_free(ptr, 0); - } - /** - * Reason code for the decryption failure - * @returns {ToDeviceUnableToDecryptReason} - */ - get reason() { - const ret = wasm.__wbg_get_todeviceunabletodecryptinfo_reason(this.__wbg_ptr); - return ret; - } - /** - * Reason code for the decryption failure - * @param {ToDeviceUnableToDecryptReason} arg0 - */ - set reason(arg0) { - wasm.__wbg_set_todeviceunabletodecryptinfo_reason(this.__wbg_ptr, arg0); - } -} -exports.ToDeviceUnableToDecryptInfo = ToDeviceUnableToDecryptInfo; -if (Symbol.dispose) ToDeviceUnableToDecryptInfo.prototype[Symbol.dispose] = ToDeviceUnableToDecryptInfo.prototype.free; - -/** - * Reason code for a to-device decryption failure - * @enum {0 | 1 | 2 | 3} - */ -const ToDeviceUnableToDecryptReason = exports.ToDeviceUnableToDecryptReason = Object.freeze({ - /** - * An error occurred while encrypting the event. This covers all - * `OlmError` types. - */ - DecryptionFailure: 0, - "0": "DecryptionFailure", - /** - * We refused to decrypt the message because the sender's device is not - * verified, or more generally, the sender's identity did not match the - * trust requirement we were asked to provide. - */ - UnverifiedSenderDevice: 1, - "1": "UnverifiedSenderDevice", - /** - * We have no `OlmMachine`. This should not happen unless we forget to set - * things up by calling `OlmMachine::activate()`. - */ - NoOlmMachine: 2, - "2": "NoOlmMachine", - /** - * The Matrix SDK was compiled without encryption support. - */ - EncryptionIsDisabled: 3, - "3": "EncryptionIsDisabled" -}); - -/** - * Type to install and to manipulate the tracing layer. - */ -class Tracing { - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - TracingFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_tracing_free(ptr, 0); - } - /** - * Check whether the `tracing` feature has been enabled. - * - * @deprecated: `tracing` is now always enabled. - * @returns {boolean} - */ - static isAvailable() { - const ret = wasm.tracing_isAvailable(); - return ret !== 0; - } - /** - * Install the tracing layer. - * @param {LoggerLevel} min_level - */ - constructor(min_level) { - const ret = wasm.tracing_new(min_level); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - this.__wbg_ptr = ret[0]; - TracingFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Re-define the minimum logger level. - * @param {LoggerLevel} min_level - */ - set minLevel(min_level) { - const ret = wasm.tracing_set_minLevel(this.__wbg_ptr, min_level); - if (ret[1]) { - throw takeFromExternrefTable0(ret[0]); - } - } - /** - * Turn the logger off, i.e. it no longer emits logs. - */ - turnOff() { - const ret = wasm.tracing_turnOff(this.__wbg_ptr); - if (ret[1]) { - throw takeFromExternrefTable0(ret[0]); - } - } - /** - * Turn the logger on, i.e. it emits logs again if it was turned - * off. - */ - turnOn() { - const ret = wasm.tracing_turnOn(this.__wbg_ptr); - if (ret[1]) { - throw takeFromExternrefTable0(ret[0]); - } - } -} -exports.Tracing = Tracing; -if (Symbol.dispose) Tracing.prototype[Symbol.dispose] = Tracing.prototype.free; - -/** - * The trust level required to decrypt an event - * @enum {0 | 1 | 2} - */ -const TrustRequirement = exports.TrustRequirement = Object.freeze({ - /** - * Decrypt events from everyone regardless of trust - */ - Untrusted: 0, - "0": "Untrusted", - /** - * Only decrypt events from cross-signed or legacy devices - */ - CrossSignedOrLegacy: 1, - "1": "CrossSignedOrLegacy", - /** - * Only decrypt events from cross-signed devices - */ - CrossSigned: 2, - "2": "CrossSigned" -}); - -/** - * Represents an encrypted to-device event that could not be decrypted. - */ -class UTDToDeviceEvent { - static __wrap(ptr) { - const obj = Object.create(UTDToDeviceEvent.prototype); - obj.__wbg_ptr = ptr; - UTDToDeviceEventFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - UTDToDeviceEventFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_utdtodeviceevent_free(ptr, 0); - } - /** - * The original message (of type `m.room.encrypted`) that failed to be - * decrypted, encoded as JSON. - * @returns {string} - */ - get rawEvent() { - const ret = wasm.__wbg_get_utdtodeviceevent_rawEvent(this.__wbg_ptr); - return ret; - } - /** - * Information on the reason we failed to decrypt - * @returns {ToDeviceUnableToDecryptInfo} - */ - get utdInfo() { - const ret = wasm.__wbg_get_utdtodeviceevent_utdInfo(this.__wbg_ptr); - return ToDeviceUnableToDecryptInfo.__wrap(ret); - } - /** - * The type of processed to-device event. Always {@link - * ProcessedToDeviceEventType.UnableToDecrypt} for this type. - * @returns {ProcessedToDeviceEventType} - */ - get type() { - const ret = wasm.utdtodeviceevent_type(this.__wbg_ptr); - return ret; - } -} -exports.UTDToDeviceEvent = UTDToDeviceEvent; -if (Symbol.dispose) UTDToDeviceEvent.prototype[Symbol.dispose] = UTDToDeviceEvent.prototype.free; - -/** - * Other Requests * - * Request that will publish a cross signing identity. - * - * This uploads the public cross signing key triplet. - */ -class UploadSigningKeysRequest { - static __wrap(ptr) { - const obj = Object.create(UploadSigningKeysRequest.prototype); - obj.__wbg_ptr = ptr; - UploadSigningKeysRequestFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - UploadSigningKeysRequestFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_uploadsigningkeysrequest_free(ptr, 0); - } - /** - * A JSON-encoded object containing the rest of the payload: `master_key`, - * `self_signing_key`, `user_signing_key`. - * - * It represents the body of the HTTP request. - * @returns {string} - */ - get body() { - const ret = wasm.__wbg_get_uploadsigningkeysrequest_body(this.__wbg_ptr); - return ret; - } - /** - * Create a new `UploadSigningKeysRequest`. - * @param {string} body - */ - constructor(body) { - const ret = wasm.uploadsigningkeysrequest_new(body); - this.__wbg_ptr = ret; - UploadSigningKeysRequestFinalization.register(this, this.__wbg_ptr, this); - return this; - } -} -exports.UploadSigningKeysRequest = UploadSigningKeysRequest; -if (Symbol.dispose) UploadSigningKeysRequest.prototype[Symbol.dispose] = UploadSigningKeysRequest.prototype.free; - -/** - * A read only view over all devices belonging to a user. - */ -class UserDevices { - static __wrap(ptr) { - const obj = Object.create(UserDevices.prototype); - obj.__wbg_ptr = ptr; - UserDevicesFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - UserDevicesFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_userdevices_free(ptr, 0); - } - /** - * Iterator over all the devices of the user devices. - * @returns {Device[]} - */ - devices() { - const ret = wasm.userdevices_devices(this.__wbg_ptr); - return ret; - } - /** - * Get the specific device with the given device ID. - * @param {DeviceId} device_id - * @returns {Device | undefined} - */ - get(device_id) { - _assertClass(device_id, DeviceId); - const ret = wasm.userdevices_get(this.__wbg_ptr, device_id.__wbg_ptr); - return ret === 0 ? undefined : Device.__wrap(ret); - } - /** - * Returns true if there is at least one devices of this user - * that is considered to be verified, false otherwise. - * - * This won't consider your own device as verified, as your own - * device is always implicitly verified. - * @returns {boolean} - */ - isAnyVerified() { - const ret = wasm.userdevices_isAnyVerified(this.__wbg_ptr); - return ret !== 0; - } - /** - * Array over all the device IDs of the user devices. - * @returns {DeviceId[]} - */ - keys() { - const ret = wasm.userdevices_keys(this.__wbg_ptr); - return ret; - } -} -exports.UserDevices = UserDevices; -if (Symbol.dispose) UserDevices.prototype[Symbol.dispose] = UserDevices.prototype.free; - -/** - * A Matrix [user ID]. - * - * [user ID]: https://spec.matrix.org/v1.2/appendices/#user-identifiers - */ -class UserId { - static __wrap(ptr) { - const obj = Object.create(UserId.prototype); - obj.__wbg_ptr = ptr; - UserIdFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - static __unwrap(jsValue) { - if (!(jsValue instanceof UserId)) { - return 0; - } - return jsValue.__destroy_into_raw(); - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - UserIdFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_userid_free(ptr, 0); - } - /** - * Create a clone of this `UserId`. - * - * This can be useful when passing a `UserId` instance to methods such as - * {@link OlmMachine.updateTrackedUsers} which destroy the instance. - * @returns {UserId} - */ - clone() { - const ret = wasm.userid_clone(this.__wbg_ptr); - return UserId.__wrap(ret); - } - /** - * Whether this user ID is a historical one. - * - * A historical user ID is one that doesn't conform to the latest - * specification of the user ID grammar but is still accepted - * because it was previously allowed. - * @returns {boolean} - */ - isHistorical() { - const ret = wasm.userid_isHistorical(this.__wbg_ptr); - return ret !== 0; - } - /** - * Returns the user's localpart. - * @returns {string} - */ - get localpart() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.userid_localpart(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Parse/validate and create a new `UserId`. - * @param {string} id - */ - constructor(id) { - const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.userid_new(ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - this.__wbg_ptr = ret[0]; - UserIdFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Returns the server name of the user ID. - * @returns {ServerName} - */ - get serverName() { - const ret = wasm.userid_serverName(this.__wbg_ptr); - return ServerName.__wrap(ret); - } - /** - * Return the user ID as a string. - * @returns {string} - */ - toString() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.userid_toString(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } -} -exports.UserId = UserId; -if (Symbol.dispose) UserId.prototype[Symbol.dispose] = UserId.prototype.free; - -/** - * List of available verification methods. - * @enum {0 | 1 | 2 | 3} - */ -const VerificationMethod = exports.VerificationMethod = Object.freeze({ - /** - * The `m.sas.v1` verification method. - * - * SAS means Short Authentication String. - */ - SasV1: 0, - "0": "SasV1", - /** - * The `m.qr_code.scan.v1` verification method. - */ - QrCodeScanV1: 1, - "1": "QrCodeScanV1", - /** - * The `m.qr_code.show.v1` verification method. - */ - QrCodeShowV1: 2, - "2": "QrCodeShowV1", - /** - * The `m.reciprocate.v1` verification method. - */ - ReciprocateV1: 3, - "3": "ReciprocateV1" -}); - -/** - * An object controlling key verification requests. - * - * Interactive verification flows usually start with a verification - * request, this object lets you send and reply to such a - * verification request. - * - * After the initial handshake the verification flow transitions into - * one of the verification methods. - */ -class VerificationRequest { - static __wrap(ptr) { - const obj = Object.create(VerificationRequest.prototype); - obj.__wbg_ptr = ptr; - VerificationRequestFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - VerificationRequestFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_verificationrequest_free(ptr, 0); - } - /** - * Accept the verification request. - * - * This method will accept the request and signal that it - * supports the `m.sas.v1`, the `m.qr_code.show.v1`, and - * `m.reciprocate.v1` method. - * - * `m.qr_code.show.v1` will only be signaled if the `qrcode` - * feature is enabled. This feature is disabled by default. If - * it's enabled and QR code scanning should be supported or QR - * code showing shouldn't be supported the `accept_with_methods` - * method should be used instead. - * - * It returns either a `ToDeviceRequest`, a `RoomMessageRequest` - * or `undefined`. - * @returns {OutgoingVerificationRequest | undefined} - */ - accept() { - const ret = wasm.verificationrequest_accept(this.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Accept the verification request signaling that our client - * supports the given verification methods. - * - * `methods` represents the methods that we should advertise as - * supported by us. - * - * It returns either a `ToDeviceRequest`, a `RoomMessageRequest` - * or `undefined`. - * @param {VerificationMethod[]} methods - * @returns {OutgoingVerificationRequest | undefined} - */ - acceptWithMethods(methods) { - const ptr0 = passArrayJsValueToWasm0(methods, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.verificationrequest_acceptWithMethods(this.__wbg_ptr, ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Cancel the verification request. - * - * It returns either a `ToDeviceRequest`, a `RoomMessageRequest` - * or `undefined`. - * @returns {OutgoingVerificationRequest | undefined} - */ - cancel() { - const ret = wasm.verificationrequest_cancel(this.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Get info about the cancellation if the verification request - * has been cancelled. - * @returns {CancelInfo | undefined} - */ - get cancelInfo() { - const ret = wasm.verificationrequest_cancelInfo(this.__wbg_ptr); - return ret === 0 ? undefined : CancelInfo.__wrap(ret); - } - /** - * Get the unique ID of this verification request. - * @returns {string} - */ - get flowId() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.verificationrequest_flowId(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Generate a QR code that can be used by another client to start - * a QR code based verification. - * - * Returns a `Qr` or `undefined`. - * @returns {Promise} - */ - generateQrCode() { - const ret = wasm.verificationrequest_generateQrCode(this.__wbg_ptr); - return ret; - } - /** - * If this request has transitioned into a concrete verification - * flow (and not yet been completed or cancelled), returns a `Verification` - * object. - * - * Returns: a `Sas`, a `Qr`, or `undefined`. - * @returns {Sas | Qr | undefined} - */ - getVerification() { - const ret = wasm.verificationrequest_getVerification(this.__wbg_ptr); - return ret; - } - /** - * Has the verification flow that was started with this request - * been cancelled? - * @returns {boolean} - */ - isCancelled() { - const ret = wasm.verificationrequest_isCancelled(this.__wbg_ptr); - return ret !== 0; - } - /** - * Has the verification flow that was started with this request - * finished? - * @returns {boolean} - */ - isDone() { - const ret = wasm.verificationrequest_isDone(this.__wbg_ptr); - return ret !== 0; - } - /** - * Has the verification request been answered by another device? - * @returns {boolean} - */ - isPassive() { - const ret = wasm.verificationrequest_isPassive(this.__wbg_ptr); - return ret !== 0; - } - /** - * Is the verification request ready to start a verification flow? - * @returns {boolean} - */ - isReady() { - const ret = wasm.verificationrequest_isReady(this.__wbg_ptr); - return ret !== 0; - } - /** - * Is this a verification that is verifying one of our own - * devices? - * @returns {boolean} - */ - isSelfVerification() { - const ret = wasm.verificationrequest_isSelfVerification(this.__wbg_ptr); - return ret !== 0; - } - /** - * The ID of the other device that is participating in this - * verification. - * @returns {DeviceId | undefined} - */ - get otherDeviceId() { - const ret = wasm.verificationrequest_otherDeviceId(this.__wbg_ptr); - return ret === 0 ? undefined : DeviceId.__wrap(ret); - } - /** - * The ID of the other user that is participating in this - * verification request. - * @returns {UserId} - */ - get otherUserId() { - const ret = wasm.verificationrequest_otherUserId(this.__wbg_ptr); - return UserId.__wrap(ret); - } - /** - * Get our own supported verification methods that we advertised. - * - * Will be present only we requested the verification or if we’re - * in the ready state. - * @returns {VerificationMethod[] | undefined} - */ - get ourSupportedMethods() { - const ret = wasm.verificationrequest_ourSupportedMethods(this.__wbg_ptr); - if (ret[3]) { - throw takeFromExternrefTable0(ret[2]); - } - let v1; - if (ret[0] !== 0) { - v1 = getArrayJsValueFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 4, 4); - } - return v1; - } - /** - * Our own user id. - * @returns {UserId} - */ - get ownUserId() { - const ret = wasm.verificationrequest_ownUserId(this.__wbg_ptr); - return UserId.__wrap(ret); - } - /** - * Get the current phase of this request. - * - * Returns a `VerificationRequestPhase`. - * @returns {VerificationRequestPhase} - */ - phase() { - const ret = wasm.verificationrequest_phase(this.__wbg_ptr); - return ret; - } - /** - * Register a callback which will be called whenever there is an update to - * the request. - * - * The `callback` is called with no parameters. - * @param {() => Promise} callback - */ - registerChangesCallback(callback) { - wasm.verificationrequest_registerChangesCallback(this.__wbg_ptr, callback); - } - /** - * Create an event content that can be sent as a room event to - * request verification from the other side. This should be used - * only for verifications of other users and it should be sent to - * a room we consider to be a DM with the other user. - * @param {UserId} own_user_id - * @param {DeviceId} own_device_id - * @param {UserId} other_user_id - * @param {VerificationMethod[]} [methods] - * @returns {string} - */ - static request(own_user_id, own_device_id, other_user_id, methods) { - let deferred3_0; - let deferred3_1; - try { - _assertClass(own_user_id, UserId); - _assertClass(own_device_id, DeviceId); - _assertClass(other_user_id, UserId); - var ptr0 = isLikeNone(methods) ? 0 : passArrayJsValueToWasm0(methods, wasm.__wbindgen_malloc); - var len0 = WASM_VECTOR_LEN; - const ret = wasm.verificationrequest_request(own_user_id.__wbg_ptr, own_device_id.__wbg_ptr, other_user_id.__wbg_ptr, ptr0, len0); - var ptr2 = ret[0]; - var len2 = ret[1]; - if (ret[3]) { - ptr2 = 0; - len2 = 0; - throw takeFromExternrefTable0(ret[2]); - } - deferred3_0 = ptr2; - deferred3_1 = len2; - return getStringFromWasm0(ptr2, len2); - } finally { - wasm.__wbindgen_free(deferred3_0, deferred3_1, 1); - } - } - /** - * Get the room ID if the verification is happening inside a - * room. - * @returns {RoomId | undefined} - */ - get roomId() { - const ret = wasm.verificationrequest_roomId(this.__wbg_ptr); - return ret === 0 ? undefined : RoomId.__wrap(ret); - } - /** - * Start a QR code verification by providing a scanned QR code - * for this verification flow. - * @param {QrCodeScan} data - * @returns {Promise} - */ - scanQrCode(data) { - _assertClass(data, QrCodeScan); - const ret = wasm.verificationrequest_scanQrCode(this.__wbg_ptr, data.__wbg_ptr); - return ret; - } - /** - * Transition from this verification request into a SAS verification flow. - * - * Returns `Promise<[Sas, OutgoingVerificationRequest] | undefined>` - * @returns {Promise<[Sas, OutgoingVerificationRequest] | undefined>} - */ - startSas() { - const ret = wasm.verificationrequest_startSas(this.__wbg_ptr); - return ret; - } - /** - * Get the supported verification methods of the other side. - * - * Will be present only if the other side requested the - * verification or if we’re in the ready state. - * - * # Returns - * - * `undefined` if we do not yet know the supported methods; otherwise, an - * array of `VerificationMethod`s. - * @returns {VerificationMethod[] | undefined} - */ - get theirSupportedMethods() { - const ret = wasm.verificationrequest_theirSupportedMethods(this.__wbg_ptr); - if (ret[3]) { - throw takeFromExternrefTable0(ret[2]); - } - let v1; - if (ret[0] !== 0) { - v1 = getArrayJsValueFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 4, 4); - } - return v1; - } - /** - * The number of milliseconds remaining before this verification flow times - * out. - * - * Returns zero if the time has already passed. - * @returns {number} - */ - timeRemainingMillis() { - const ret = wasm.verificationrequest_timeRemainingMillis(this.__wbg_ptr); - return ret; - } - /** - * Has the verification flow timed out? - * @returns {boolean} - */ - timedOut() { - const ret = wasm.verificationrequest_timedOut(this.__wbg_ptr); - return ret !== 0; - } - /** - * Did we initiate the verification request? - * @returns {boolean} - */ - weStarted() { - const ret = wasm.verificationrequest_weStarted(this.__wbg_ptr); - return ret !== 0; - } -} -exports.VerificationRequest = VerificationRequest; -if (Symbol.dispose) VerificationRequest.prototype[Symbol.dispose] = VerificationRequest.prototype.free; - -/** - * List of VerificationRequestState phases - * @enum {0 | 1 | 2 | 3 | 4 | 5} - */ -const VerificationRequestPhase = exports.VerificationRequestPhase = Object.freeze({ - /** - * The verification request has been newly created by us. - */ - Created: 0, - "0": "Created", - /** - * The verification request was received from the other party. - */ - Requested: 1, - "1": "Requested", - /** - * The verification request is ready to start a verification flow. - */ - Ready: 2, - "2": "Ready", - /** - * The verification request has transitioned into a concrete verification - * flow. For example it transitioned into the emoji based SAS - * verification. - */ - Transitioned: 3, - "3": "Transitioned", - /** - * The verification flow that was started with this request has finished. - */ - Done: 4, - "4": "Done", - /** - * The verification process has been cancelled. - */ - Cancelled: 5, - "5": "Cancelled" -}); - -/** - * Object containing the versions of the Rust libraries we are using. - */ -class Versions { - static __wrap(ptr) { - const obj = Object.create(Versions.prototype); - obj.__wbg_ptr = ptr; - VersionsFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - VersionsFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_versions_free(ptr, 0); - } - /** - * The build-time output of the `git describe` command of the source tree - * of crate. - * @returns {string} - */ - get git_description() { - const ret = wasm.__wbg_get_versions_git_description(this.__wbg_ptr); - return ret; - } - /** - * The Git commit hash of the crate's source tree at build time. - * @returns {string} - */ - get git_sha() { - const ret = wasm.__wbg_get_versions_git_sha(this.__wbg_ptr); - return ret; - } - /** - * The version of the matrix-sdk-crypto crate. - * @returns {string} - */ - get matrix_sdk_crypto() { - const ret = wasm.__wbg_get_versions_matrix_sdk_crypto(this.__wbg_ptr); - return ret; - } - /** - * The version of the vodozemac crate. - * @returns {string} - */ - get vodozemac() { - const ret = wasm.__wbg_get_versions_vodozemac(this.__wbg_ptr); - return ret; - } -} -exports.Versions = Versions; -if (Symbol.dispose) Versions.prototype[Symbol.dispose] = Versions.prototype.free; - -/** - * Get the versions of the Rust libraries we are using. - * @returns {Versions} - */ -function getVersions() { - const ret = wasm.getVersions(); - return Versions.__wrap(ret); -} - -/** - * Run some stuff when the Wasm module is instantiated. - * - * Right now, it does the following: - * - * * Redirect Rust panics to JavaScript console. - */ -function start() { - wasm.start(); -} -function __wbg_Error_408e67f47ca7b58b(arg0, arg1) { - const ret = Error(getStringFromWasm0(arg0, arg1)); - return ret; -} -function __wbg_Number_3890faa6d3ff057d(arg0) { - const ret = Number(arg0); - return ret; -} -function __wbg_String_8564e559799eccda(arg0, arg1) { - const ret = String(arg1); - const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); -} -function __wbg_Window_241244be8c9776c1(arg0) { - const ret = arg0.Window; - return ret; -} -function __wbg_WorkerGlobalScope_8623a7c9030fbce2(arg0) { - const ret = arg0.WorkerGlobalScope; - return ret; -} -function __wbg___wbindgen_bigint_get_as_i64_c4ecf48528083721(arg0, arg1) { - const v = arg1; - const ret = typeof v === 'bigint' ? v : undefined; - getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true); -} -function __wbg___wbindgen_boolean_get_c9c83ebd41b34df3(arg0) { - const v = arg0; - const ret = typeof v === 'boolean' ? v : undefined; - return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0; -} -function __wbg___wbindgen_debug_string_a57024b9c6e4a48b(arg0, arg1) { - const ret = debugString(arg1); - const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); -} -function __wbg___wbindgen_in_ac983077f137f2e6(arg0, arg1) { - const ret = arg0 in arg1; - return ret; -} -function __wbg___wbindgen_is_bigint_8ffbbef442139384(arg0) { - const ret = typeof arg0 === 'bigint'; - return ret; -} -function __wbg___wbindgen_is_function_5e4570eb24ffa122(arg0) { - const ret = typeof arg0 === 'function'; - return ret; -} -function __wbg___wbindgen_is_null_7d13f41e1a2d5140(arg0) { - const ret = arg0 === null; - return ret; -} -function __wbg___wbindgen_is_object_a2790eb24c211ea0(arg0) { - const val = arg0; - const ret = typeof val === 'object' && val !== null; - return ret; -} -function __wbg___wbindgen_is_string_e6f02f0ea5f20a32(arg0) { - const ret = typeof arg0 === 'string'; - return ret; -} -function __wbg___wbindgen_is_undefined_6cff064c44e0d823(arg0) { - const ret = arg0 === undefined; - return ret; -} -function __wbg___wbindgen_jsval_eq_0a18949a61670320(arg0, arg1) { - const ret = arg0 === arg1; - return ret; -} -function __wbg___wbindgen_jsval_loose_eq_acf2776254a8d832(arg0, arg1) { - const ret = arg0 == arg1; - return ret; -} -function __wbg___wbindgen_number_get_136b9679cab35cfb(arg0, arg1) { - const obj = arg1; - const ret = typeof obj === 'number' ? obj : undefined; - getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true); -} -function __wbg___wbindgen_string_get_d154f1e671052120(arg0, arg1) { - const obj = arg1; - const ret = typeof obj === 'string' ? obj : undefined; - var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len1 = WASM_VECTOR_LEN; - getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); -} -function __wbg___wbindgen_throw_bb96b2010945f0bc(arg0, arg1) { - throw new Error(getStringFromWasm0(arg0, arg1)); -} -function __wbg__wbg_cb_unref_be22cc64ae6946a0(arg0) { - arg0._wbg_cb_unref(); -} -function __wbg_abort_32b500c4f9eab55d() { - return handleError(function (arg0) { - arg0.abort(); - }, arguments); -} -function __wbg_add_18ccb6b4b9da9cd9() { - return handleError(function (arg0, arg1, arg2) { - const ret = arg0.add(arg1, arg2); - return ret; - }, arguments); -} -function __wbg_add_2b945856b580d5ab(arg0, arg1) { - const ret = arg0.add(arg1); - return ret; -} -function __wbg_at_facbe5ae998bba3a(arg0, arg1) { - const ret = arg0.at(arg1); - return ret; -} -function __wbg_backupkeys_new(arg0) { - const ret = BackupKeys.__wrap(arg0); - return ret; -} -function __wbg_bound_e48dc2f851c77207() { - return handleError(function (arg0, arg1, arg2, arg3) { - const ret = IDBKeyRange.bound(arg0, arg1, arg2 !== 0, arg3 !== 0); - return ret; - }, arguments); -} -function __wbg_call_0f2a9af232c18fd2() { - return handleError(function (arg0, arg1, arg2, arg3) { - const ret = arg0.call(arg1, arg2, arg3); - return ret; - }, arguments); -} -function __wbg_call_1c5886ab9c57d1c7() { - return handleError(function (arg0, arg1) { - const ret = arg0.call(arg1); - return ret; - }, arguments); -} -function __wbg_call_35dba3c747ad7521() { - return handleError(function (arg0, arg1, arg2) { - const ret = arg0.call(arg1, arg2); - return ret; - }, arguments); -} -function __wbg_call_39f824e18d9d2414() { - return handleError(function (arg0, arg1, arg2, arg3, arg4) { - const ret = arg0.call(arg1, arg2, arg3, arg4); - return ret; - }, arguments); -} -function __wbg_clearTimeout_3629d6209dfcc46e(arg0) { - const ret = clearTimeout(arg0); - return ret; -} -function __wbg_clear_07a20ccd42c66921() { - return handleError(function (arg0) { - const ret = arg0.clear(); - return ret; - }, arguments); -} -function __wbg_close_0c1f30aeb9a080a7(arg0) { - arg0.close(); -} -function __wbg_code_5c2c992d8a3afb58(arg0) { - const ret = arg0.code; - return ret; -} -function __wbg_commit_ebd6d9676954e0d2() { - return handleError(function (arg0) { - arg0.commit(); - }, arguments); -} -function __wbg_continue_cbf53c725c127fe3() { - return handleError(function (arg0) { - arg0.continue(); - }, arguments); -} -function __wbg_count_be9295f0aceb7d6a() { - return handleError(function (arg0) { - const ret = arg0.count(); - return ret; - }, arguments); -} -function __wbg_count_c48ec9dcdccef1d5() { - return handleError(function (arg0) { - const ret = arg0.count(); - return ret; - }, arguments); -} -function __wbg_createIndex_9e2beb35a103225a() { - return handleError(function (arg0, arg1, arg2, arg3) { - const ret = arg0.createIndex(getStringFromWasm0(arg1, arg2), arg3); - return ret; - }, arguments); -} -function __wbg_createIndex_f8a090296c419c6c() { - return handleError(function (arg0, arg1, arg2, arg3, arg4) { - const ret = arg0.createIndex(getStringFromWasm0(arg1, arg2), arg3, arg4); - return ret; - }, arguments); -} -function __wbg_createObjectStore_d3884936b845900f() { - return handleError(function (arg0, arg1, arg2) { - const ret = arg0.createObjectStore(getStringFromWasm0(arg1, arg2)); - return ret; - }, arguments); -} -function __wbg_crosssigningbootstraprequests_new(arg0) { - const ret = CrossSigningBootstrapRequests.__wrap(arg0); - return ret; -} -function __wbg_crosssigningkeyexport_new(arg0) { - const ret = CrossSigningKeyExport.__wrap(arg0); - return ret; -} -function __wbg_crosssigningstatus_new(arg0) { - const ret = CrossSigningStatus.__wrap(arg0); - return ret; -} -function __wbg_crypto_38df2bab126b63dc(arg0) { - const ret = arg0.crypto; - return ret; -} -function __wbg_debug_1ac2ea5532f70f4c(arg0, arg1) { - arg0.debug(arg1); -} -function __wbg_debug_3853dbaf0bca30f9(arg0) { - console.debug(arg0); -} -function __wbg_decryptedroomevent_new(arg0) { - const ret = DecryptedRoomEvent.__wrap(arg0); - return ret; -} -function __wbg_decryptedtodeviceevent_new(arg0) { - const ret = DecryptedToDeviceEvent.__wrap(arg0); - return ret; -} -function __wbg_dehydrateddevice_new(arg0) { - const ret = DehydratedDevice.__wrap(arg0); - return ret; -} -function __wbg_dehydrateddevicekey_new(arg0) { - const ret = DehydratedDeviceKey.__wrap(arg0); - return ret; -} -function __wbg_deleteObjectStore_ed0e7d0b256bead4() { - return handleError(function (arg0, arg1, arg2) { - arg0.deleteObjectStore(getStringFromWasm0(arg1, arg2)); - }, arguments); -} -function __wbg_delete_03ff02bcb1b57138() { - return handleError(function (arg0) { - const ret = arg0.delete(); - return ret; - }, arguments); -} -function __wbg_delete_27b012593b3f623b() { - return handleError(function (arg0, arg1) { - const ret = arg0.delete(arg1); - return ret; - }, arguments); -} -function __wbg_device_new(arg0) { - const ret = Device.__wrap(arg0); - return ret; -} -function __wbg_deviceid_new(arg0) { - const ret = DeviceId.__wrap(arg0); - return ret; -} -function __wbg_devicekey_new(arg0) { - const ret = DeviceKey.__wrap(arg0); - return ret; -} -function __wbg_devicekeyid_new(arg0) { - const ret = DeviceKeyId.__wrap(arg0); - return ret; -} -function __wbg_done_669171204c3dcae2(arg0) { - const ret = arg0.done; - return ret; -} -function __wbg_emoji_new(arg0) { - const ret = Emoji.__wrap(arg0); - return ret; -} -function __wbg_encryptedattachment_new(arg0) { - const ret = EncryptedAttachment.__wrap(arg0); - return ret; -} -function __wbg_encryptioninfo_new(arg0) { - const ret = EncryptionInfo.__wrap(arg0); - return ret; -} -function __wbg_entries_71601bcb707d5078(arg0) { - const ret = arg0.entries(); - return ret; -} -function __wbg_entries_7774d489e1da5f4f(arg0) { - const ret = Object.entries(arg0); - return ret; -} -function __wbg_error_24e6ac605d438e54() { - return handleError(function (arg0) { - const ret = arg0.error; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); - }, arguments); -} -function __wbg_error_757e9472f8410341(arg0, arg1) { - let deferred0_0; - let deferred0_1; - try { - deferred0_0 = arg0; - deferred0_1 = arg1; - console.error(getStringFromWasm0(arg0, arg1)); - } finally { - wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); - } -} -function __wbg_error_dbd3752906405f8d(arg0, arg1) { - arg0.error(arg1); -} -function __wbg_error_dd408a7b3cb542dd(arg0) { - console.error(arg0); -} -function __wbg_from_74f3d90e0ff11240(arg0) { - const ret = Array.from(arg0); - return ret; -} -function __wbg_getAllKeys_1de66542d233a4a5() { - return handleError(function (arg0) { - const ret = arg0.getAllKeys(); - return ret; - }, arguments); -} -function __wbg_getAllKeys_65d7deed4f9b2d48() { - return handleError(function (arg0, arg1) { - const ret = arg0.getAllKeys(arg1); - return ret; - }, arguments); -} -function __wbg_getAll_358f5970d9bee84b() { - return handleError(function (arg0) { - const ret = arg0.getAll(); - return ret; - }, arguments); -} -function __wbg_getAll_6b556cfcbf040afc() { - return handleError(function (arg0, arg1) { - const ret = arg0.getAll(arg1); - return ret; - }, arguments); -} -function __wbg_getAll_86c18743042fe4ca() { - return handleError(function (arg0) { - const ret = arg0.getAll(); - return ret; - }, arguments); -} -function __wbg_getAll_edf30bc7f595e7ae() { - return handleError(function (arg0, arg1, arg2) { - const ret = arg0.getAll(arg1, arg2 >>> 0); - return ret; - }, arguments); -} -function __wbg_getRandomValues_26c0cdf963e46393() { - return handleError(function (arg0, arg1) { - globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1)); - }, arguments); -} -function __wbg_getRandomValues_436a51d0629d84e1() { - return handleError(function (arg0, arg1) { - globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1)); - }, arguments); -} -function __wbg_getRandomValues_c44a50d8cfdaebeb() { - return handleError(function (arg0, arg1) { - arg0.getRandomValues(arg1); - }, arguments); -} -function __wbg_getTime_63fb0332e6c4ec17(arg0) { - const ret = arg0.getTime(); - return ret; -} -function __wbg_get_4babbbf9303c1945() { - return handleError(function (arg0, arg1) { - const ret = arg0.get(arg1); - return ret; - }, arguments); -} -function __wbg_get_94b5ec70e1f04bdd() { - return handleError(function (arg0, arg1) { - const ret = arg0.get(arg1); - return ret; - }, arguments); -} -function __wbg_get_971a0c45d172643f() { - return handleError(function (arg0, arg1) { - const ret = Reflect.get(arg0, arg1); - return ret; - }, arguments); -} -function __wbg_get_c0c8f8d7da0c03dd(arg0, arg1) { - const ret = arg0[arg1 >>> 0]; - return ret; -} -function __wbg_get_d173c0308df22d37() { - return handleError(function (arg0, arg1) { - const ret = Reflect.get(arg0, arg1); - return ret; - }, arguments); -} -function __wbg_get_unchecked_e20b893aeafc3fca(arg0, arg1) { - const ret = arg0[arg1 >>> 0]; - return ret; -} -function __wbg_get_with_ref_key_6412cf3094599694(arg0, arg1) { - const ret = arg0[arg1]; - return ret; -} -function __wbg_global_94a489d2e6a0c5fd(arg0) { - const ret = arg0.global; - return ret; -} -function __wbg_inboundgroupsession_new(arg0) { - const ret = InboundGroupSession.__wrap(arg0); - return ret; -} -function __wbg_index_bed5a9f21dfebeea() { - return handleError(function (arg0, arg1, arg2) { - const ret = arg0.index(getStringFromWasm0(arg1, arg2)); - return ret; - }, arguments); -} -function __wbg_indexedDB_47c354eb27472a00() { - return handleError(function (arg0) { - const ret = arg0.indexedDB; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); - }, arguments); -} -function __wbg_indexedDB_9e20c97c033151f3() { - return handleError(function (arg0) { - const ret = arg0.indexedDB; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); - }, arguments); -} -function __wbg_indexedDB_ced363f3de8fb099() { - return handleError(function (arg0) { - const ret = arg0.indexedDB; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); - }, arguments); -} -function __wbg_info_726982aff9befe16(arg0) { - console.info(arg0); -} -function __wbg_info_929f1b00bd4820a9(arg0, arg1) { - arg0.info(arg1); -} -function __wbg_instanceof_ArrayBuffer_993d02d2d254cad1(arg0) { - let result; - try { - result = arg0 instanceof ArrayBuffer; - } catch (_) { - result = false; - } - const ret = result; - return ret; -} -function __wbg_instanceof_CursorSys_383984afc1fa1bbc(arg0) { - let result; - try { - result = arg0 instanceof IDBCursorWithValue; - } catch (_) { - result = false; - } - const ret = result; - return ret; -} -function __wbg_instanceof_DomException_55a5af63fefe4042(arg0) { - let result; - try { - result = arg0 instanceof DOMException; - } catch (_) { - result = false; - } - const ret = result; - return ret; -} -function __wbg_instanceof_Error_61d8a02a0f3383a1(arg0) { - let result; - try { - result = arg0 instanceof Error; - } catch (_) { - result = false; - } - const ret = result; - return ret; -} -function __wbg_instanceof_IdbCursor_9bd028886fa2ccf0(arg0) { - let result; - try { - result = arg0 instanceof IDBCursor; - } catch (_) { - result = false; - } - const ret = result; - return ret; -} -function __wbg_instanceof_IdbDatabase_e9dd9f20c51d8d42(arg0) { - let result; - try { - result = arg0 instanceof IDBDatabase; - } catch (_) { - result = false; - } - const ret = result; - return ret; -} -function __wbg_instanceof_IdbOpenDbRequest_b913751ffb9239bb(arg0) { - let result; - try { - result = arg0 instanceof IDBOpenDBRequest; - } catch (_) { - result = false; - } - const ret = result; - return ret; -} -function __wbg_instanceof_IdbRequest_471b050024626dac(arg0) { - let result; - try { - result = arg0 instanceof IDBRequest; - } catch (_) { - result = false; - } - const ret = result; - return ret; -} -function __wbg_instanceof_Map_9a4d6ead180ae3a9(arg0) { - let result; - try { - result = arg0 instanceof Map; - } catch (_) { - result = false; - } - const ret = result; - return ret; -} -function __wbg_instanceof_Promise_e6e764b945c3128a(arg0) { - let result; - try { - result = arg0 instanceof Promise; - } catch (_) { - result = false; - } - const ret = result; - return ret; -} -function __wbg_instanceof_Uint8Array_f935dbb0aa7cdeed(arg0) { - let result; - try { - result = arg0 instanceof Uint8Array; - } catch (_) { - result = false; - } - const ret = result; - return ret; -} -function __wbg_invalidtodeviceevent_new(arg0) { - const ret = InvalidToDeviceEvent.__wrap(arg0); - return ret; -} -function __wbg_isArray_291e8fbbc73f8b2e(arg0) { - const ret = Array.isArray(arg0); - return ret; -} -function __wbg_isArray_6339f732981044bf(arg0) { - const ret = Array.isArray(arg0); - return ret; -} -function __wbg_isSafeInteger_f3d6cd19ccfe4512(arg0) { - const ret = Number.isSafeInteger(arg0); - return ret; -} -function __wbg_item_754b49ed01198c29(arg0, arg1, arg2) { - const ret = arg1.item(arg2 >>> 0); - var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len1 = WASM_VECTOR_LEN; - getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); -} -function __wbg_iterator_5cebbb86e33c6dd6() { - const ret = Symbol.iterator; - return ret; -} -function __wbg_key_18fe06a6310bf3fb() { - return handleError(function (arg0) { - const ret = arg0.key; - return ret; - }, arguments); -} -function __wbg_keysbackuprequest_new(arg0) { - const ret = KeysBackupRequest.__wrap(arg0); - return ret; -} -function __wbg_keysclaimrequest_new(arg0) { - const ret = KeysClaimRequest.__wrap(arg0); - return ret; -} -function __wbg_keysqueryrequest_new(arg0) { - const ret = KeysQueryRequest.__wrap(arg0); - return ret; -} -function __wbg_keysuploadrequest_new(arg0) { - const ret = KeysUploadRequest.__wrap(arg0); - return ret; -} -function __wbg_length_13032799523c5735(arg0) { - const ret = arg0.length; - return ret; -} -function __wbg_length_36bd29c6848c2144(arg0) { - const ret = arg0.length; - return ret; -} -function __wbg_length_ecfa2c63d3d0d82c(arg0) { - const ret = arg0.length; - return ret; -} -function __wbg_lowerBound_66a1695f45ef6c88() { - return handleError(function (arg0, arg1) { - const ret = IDBKeyRange.lowerBound(arg0, arg1 !== 0); - return ret; - }, arguments); -} -function __wbg_maybesignature_new(arg0) { - const ret = MaybeSignature.__wrap(arg0); - return ret; -} -function __wbg_megolmdecryptionerror_new(arg0) { - const ret = MegolmDecryptionError.__wrap(arg0); - return ret; -} -function __wbg_message_88eda073e68b1d26(arg0, arg1) { - const ret = arg1.message; - const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); -} -function __wbg_message_c141d5e68716b595(arg0) { - const ret = arg0.message; - return ret; -} -function __wbg_msCrypto_bd5a034af96bcba6(arg0) { - const ret = arg0.msCrypto; - return ret; -} -function __wbg_name_facbed56940f0fec(arg0, arg1) { - const ret = arg1.name; - const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); -} -function __wbg_new_116be93542d39019() { - const ret = new Array(); - return ret; -} -function __wbg_new_227d7c05414eb861() { - const ret = new Error(); - return ret; -} -function __wbg_new_358857d90afd5a2d(arg0, arg1) { - const ret = new Error(getStringFromWasm0(arg0, arg1)); - return ret; -} -function __wbg_new_418fb92a013d5930(arg0, arg1) { - try { - var state0 = { - a: arg0, - b: arg1 - }; - var cb0 = (arg0, arg1) => { - const a = state0.a; - state0.a = 0; - try { - return wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke___js_sys_8badcad5ae9f3759___Function_fn_wasm_bindgen_ff9af61e2d43a78a___JsValue_____wasm_bindgen_ff9af61e2d43a78a___sys__Undefined___js_sys_8badcad5ae9f3759___Function_fn_wasm_bindgen_ff9af61e2d43a78a___JsValue_____wasm_bindgen_ff9af61e2d43a78a___sys__Undefined_______true_(a, state0.b, arg0, arg1); - } finally { - state0.a = a; - } - }; - const ret = new Promise(cb0); - return ret; - } finally { - state0.a = 0; - } -} -function __wbg_new_77cc4f4f472aeb81(arg0) { - const ret = new Uint8Array(arg0); - return ret; -} -function __wbg_new_cdf041679ded4c5f() { - const ret = new Map(); - return ret; -} -function __wbg_new_d29ccbc1854174b3(arg0) { - const ret = new Set(arg0); - return ret; -} -function __wbg_new_ebe3e0f6837f0879() { - const ret = new Object(); - return ret; -} -function __wbg_new_f9d6489212f3b2b3(arg0) { - const ret = new Date(arg0); - return ret; -} -function __wbg_new_from_slice_3eea173078478cfe(arg0, arg1) { - const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1)); - return ret; -} -function __wbg_new_typed_cceaf62d8d95e9f2(arg0, arg1) { - try { - var state0 = { - a: arg0, - b: arg1 - }; - var cb0 = (arg0, arg1) => { - const a = state0.a; - state0.a = 0; - try { - return wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke___js_sys_8badcad5ae9f3759___Function_fn_wasm_bindgen_ff9af61e2d43a78a___JsValue_____wasm_bindgen_ff9af61e2d43a78a___sys__Undefined___js_sys_8badcad5ae9f3759___Function_fn_wasm_bindgen_ff9af61e2d43a78a___JsValue_____wasm_bindgen_ff9af61e2d43a78a___sys__Undefined_______true_(a, state0.b, arg0, arg1); - } finally { - state0.a = a; - } - }; - const ret = new Promise(cb0); - return ret; - } finally { - state0.a = 0; - } -} -function __wbg_new_with_length_3ffc1c56427c525c(arg0) { - const ret = new Uint8Array(arg0 >>> 0); - return ret; -} -function __wbg_new_with_length_5d351ffdb6e3397d(arg0) { - const ret = new Uint8ClampedArray(arg0 >>> 0); - return ret; -} -function __wbg_next_42cf16ee0dafc9e2() { - return handleError(function (arg0) { - const ret = arg0.next(); - return ret; - }, arguments); -} -function __wbg_next_8f26b64fa5e9f64b(arg0) { - const ret = arg0.next; - return ret; -} -function __wbg_node_84ea875411254db1(arg0) { - const ret = arg0.node; - return ret; -} -function __wbg_now_8b265300afd5f2b9() { - const ret = Date.now(); - return ret; -} -function __wbg_now_e7c6795a7f81e10f(arg0) { - const ret = arg0.now(); - return ret; -} -function __wbg_objectStoreNames_94ee5410bc505cae(arg0) { - const ret = arg0.objectStoreNames; - return ret; -} -function __wbg_objectStore_222b7add2b5c2770() { - return handleError(function (arg0, arg1, arg2) { - const ret = arg0.objectStore(getStringFromWasm0(arg1, arg2)); - return ret; - }, arguments); -} -function __wbg_oldVersion_92fccbad82f5635a(arg0) { - const ret = arg0.oldVersion; - return ret; -} -function __wbg_olmmachine_new(arg0) { - const ret = OlmMachine.__wrap(arg0); - return ret; -} -function __wbg_openCursor_1015e5f363cc8494() { - return handleError(function (arg0) { - const ret = arg0.openCursor(); - return ret; - }, arguments); -} -function __wbg_openCursor_6dd512fe9cbf9f67() { - return handleError(function (arg0, arg1) { - const ret = arg0.openCursor(arg1); - return ret; - }, arguments); -} -function __wbg_openCursor_f34b182699875701() { - return handleError(function (arg0) { - const ret = arg0.openCursor(); - return ret; - }, arguments); -} -function __wbg_open_66c8b00ee562451f() { - return handleError(function (arg0, arg1, arg2) { - const ret = arg0.open(getStringFromWasm0(arg1, arg2)); - return ret; - }, arguments); -} -function __wbg_open_c5ecda93515ce190() { - return handleError(function (arg0, arg1, arg2, arg3) { - const ret = arg0.open(getStringFromWasm0(arg1, arg2), arg3 >>> 0); - return ret; - }, arguments); -} -function __wbg_otheruseridentity_new(arg0) { - const ret = OtherUserIdentity.__wrap(arg0); - return ret; -} -function __wbg_ownuseridentity_new(arg0) { - const ret = OwnUserIdentity.__wrap(arg0); - return ret; -} -function __wbg_parse_1cc93481b0865939() { - return handleError(function (arg0, arg1) { - const ret = JSON.parse(getStringFromWasm0(arg0, arg1)); - return ret; - }, arguments); -} -function __wbg_performance_3fcf6e32a7e1ed0a(arg0) { - const ret = arg0.performance; - return ret; -} -function __wbg_pickledinboundgroupsession_unwrap(arg0) { - const ret = PickledInboundGroupSession.__unwrap(arg0); - return ret; -} -function __wbg_pickledsession_unwrap(arg0) { - const ret = PickledSession.__unwrap(arg0); - return ret; -} -function __wbg_plaintexttodeviceevent_new(arg0) { - const ret = PlainTextToDeviceEvent.__wrap(arg0); - return ret; -} -function __wbg_process_44c7a14e11e9f69e(arg0) { - const ret = arg0.process; - return ret; -} -function __wbg_prototypesetcall_8798824fd302dd72(arg0, arg1, arg2) { - Uint8ClampedArray.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2); -} -function __wbg_prototypesetcall_de8e0d9553586985(arg0, arg1, arg2) { - Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2); -} -function __wbg_push_adb0107829f02d75(arg0, arg1) { - const ret = arg0.push(arg1); - return ret; -} -function __wbg_put_5e0ae8c80bb952a7() { - return handleError(function (arg0, arg1, arg2) { - const ret = arg0.put(arg1, arg2); - return ret; - }, arguments); -} -function __wbg_putdehydrateddevicerequest_new(arg0) { - const ret = PutDehydratedDeviceRequest.__wrap(arg0); - return ret; -} -function __wbg_qr_new(arg0) { - const ret = Qr.__wrap(arg0); - return ret; -} -function __wbg_queueMicrotask_ac694eae12e92dfb(arg0) { - queueMicrotask(arg0); -} -function __wbg_queueMicrotask_be5fe34a8f4cad4d(arg0) { - const ret = arg0.queueMicrotask; - return ret; -} -function __wbg_randomFillSync_6c25eac9869eb53c() { - return handleError(function (arg0, arg1) { - arg0.randomFillSync(arg1); - }, arguments); -} -function __wbg_readyState_599831d0754935af(arg0) { - const ret = arg0.readyState; - return (__wbindgen_enum_IdbRequestReadyState.indexOf(ret) + 1 || 3) - 1; -} -function __wbg_rehydrateddevice_new(arg0) { - const ret = RehydratedDevice.__wrap(arg0); - return ret; -} -function __wbg_request_64abeba15a72c084(arg0) { - const ret = arg0.request; - return ret; -} -function __wbg_request_72a78988f2edecad(arg0) { - const ret = arg0.request; - return ret; -} -function __wbg_require_b4edbdcf3e2a1ef0() { - return handleError(function () { - const ret = module.require; - return ret; - }, arguments); -} -function __wbg_resolve_020f95d838c6ef25(arg0) { - const ret = Promise.resolve(arg0); - return ret; -} -function __wbg_result_0501bea148306f01() { - return handleError(function (arg0) { - const ret = arg0.result; - return ret; - }, arguments); -} -function __wbg_roomid_unwrap(arg0) { - const ret = RoomId.__unwrap(arg0); - return ret; -} -function __wbg_roomkeycounts_new(arg0) { - const ret = RoomKeyCounts.__wrap(arg0); - return ret; -} -function __wbg_roomkeyimportresult_new(arg0) { - const ret = RoomKeyImportResult.__wrap(arg0); - return ret; -} -function __wbg_roomkeyinfo_new(arg0) { - const ret = RoomKeyInfo.__wrap(arg0); - return ret; -} -function __wbg_roomkeywithheldinfo_new(arg0) { - const ret = RoomKeyWithheldInfo.__wrap(arg0); - return ret; -} -function __wbg_roommessagerequest_new(arg0) { - const ret = RoomMessageRequest.__wrap(arg0); - return ret; -} -function __wbg_roompendingkeybundledetails_new(arg0) { - const ret = RoomPendingKeyBundleDetails.__wrap(arg0); - return ret; -} -function __wbg_roomsettings_new(arg0) { - const ret = RoomSettings.__wrap(arg0); - return ret; -} -function __wbg_sas_new(arg0) { - const ret = Sas.__wrap(arg0); - return ret; -} -function __wbg_secretsbundle_new(arg0) { - const ret = SecretsBundle.__wrap(arg0); - return ret; -} -function __wbg_setTimeout_56bcdccbad22fd44() { - return handleError(function (arg0, arg1) { - const ret = setTimeout(arg0, arg1); - return ret; - }, arguments); -} -function __wbg_set_014226dfeca53178(arg0, arg1, arg2) { - const ret = arg0.set(arg1, arg2); - return ret; -} -function __wbg_set_5c15d3c5973de97a(arg0, arg1, arg2) { - arg0.set(getArrayU8FromWasm0(arg1, arg2)); -} -function __wbg_set_6be42768c690e380(arg0, arg1, arg2) { - arg0[arg1] = arg2; -} -function __wbg_set_a80955eb93b145c6(arg0, arg1, arg2) { - arg0[arg1 >>> 0] = arg2; -} -function __wbg_set_onabort_fda794cb1089d6b5(arg0, arg1) { - arg0.onabort = arg1; -} -function __wbg_set_oncomplete_ff31bdacaa1b3558(arg0, arg1) { - arg0.oncomplete = arg1; -} -function __wbg_set_onerror_3dff0f2abceea5e9(arg0, arg1) { - arg0.onerror = arg1; -} -function __wbg_set_onerror_41278ace6abe3973(arg0, arg1) { - arg0.onerror = arg1; -} -function __wbg_set_onsuccess_86d76d6974cd57e4(arg0, arg1) { - arg0.onsuccess = arg1; -} -function __wbg_set_onupgradeneeded_79b60102909f4a5e(arg0, arg1) { - arg0.onupgradeneeded = arg1; -} -function __wbg_set_unique_c03185d3bf563306(arg0, arg1) { - arg0.unique = arg1 !== 0; -} -function __wbg_signatures_new(arg0) { - const ret = Signatures.__wrap(arg0); - return ret; -} -function __wbg_signatureuploadrequest_new(arg0) { - const ret = SignatureUploadRequest.__wrap(arg0); - return ret; -} -function __wbg_signatureverification_new(arg0) { - const ret = SignatureVerification.__wrap(arg0); - return ret; -} -function __wbg_stack_3b0d974bbf31e44f(arg0, arg1) { - const ret = arg1.stack; - const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); -} -function __wbg_static_accessor_GLOBAL_THIS_466428f93b4eaa76() { - const ret = typeof globalThis === 'undefined' ? null : globalThis; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); -} -function __wbg_static_accessor_GLOBAL_c7aea38d4de089bc() { - const ret = typeof global === 'undefined' ? null : global; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); -} -function __wbg_static_accessor_SELF_42d4fae05e59267a() { - const ret = typeof self === 'undefined' ? null : self; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); -} -function __wbg_static_accessor_WINDOW_e0db14a0eba6a812() { - const ret = typeof window === 'undefined' ? null : window; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); -} -function __wbg_storedroomkeybundledata_new(arg0) { - const ret = StoredRoomKeyBundleData.__wrap(arg0); - return ret; -} -function __wbg_storehandle_new(arg0) { - const ret = StoreHandle.__wrap(arg0); - return ret; -} -function __wbg_stringify_f93a4ebae9231922() { - return handleError(function (arg0) { - const ret = JSON.stringify(arg0); - return ret; - }, arguments); -} -function __wbg_subarray_a4cc58201c7359fd(arg0, arg1, arg2) { - const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0); - return ret; -} -function __wbg_target_13424fe1cdc436ac(arg0) { - const ret = arg0.target; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); -} -function __wbg_then_7026b513a94278a8(arg0, arg1) { - const ret = arg0.then(arg1); - return ret; -} -function __wbg_then_72819b8d4e081fb5(arg0, arg1, arg2) { - const ret = arg0.then(arg1, arg2); - return ret; -} -function __wbg_toString_2f0b0aec069cb718(arg0) { - const ret = arg0.toString(); - return ret; -} -function __wbg_todevicerequest_new(arg0) { - const ret = ToDeviceRequest.__wrap(arg0); - return ret; -} -function __wbg_transaction_0458565e8cdfb620(arg0) { - const ret = arg0.transaction; - return ret; -} -function __wbg_transaction_4c999693e6e601bf() { - return handleError(function (arg0, arg1, arg2) { - const ret = arg0.transaction(arg1, __wbindgen_enum_IdbTransactionMode[arg2]); - return ret; - }, arguments); -} -function __wbg_transaction_728366e915610cb0() { - return handleError(function (arg0, arg1, arg2, arg3) { - const ret = arg0.transaction(getStringFromWasm0(arg1, arg2), __wbindgen_enum_IdbTransactionMode[arg3]); - return ret; - }, arguments); -} -function __wbg_transaction_77d93778cbec28c3(arg0) { - const ret = arg0.transaction; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); -} -function __wbg_update_df04b6b83954c5a0() { - return handleError(function (arg0, arg1) { - const ret = arg0.update(arg1); - return ret; - }, arguments); -} -function __wbg_upperBound_916ed065b0d6fe6c() { - return handleError(function (arg0, arg1) { - const ret = IDBKeyRange.upperBound(arg0, arg1 !== 0); - return ret; - }, arguments); -} -function __wbg_userdevices_new(arg0) { - const ret = UserDevices.__wrap(arg0); - return ret; -} -function __wbg_userid_new(arg0) { - const ret = UserId.__wrap(arg0); - return ret; -} -function __wbg_userid_unwrap(arg0) { - const ret = UserId.__unwrap(arg0); - return ret; -} -function __wbg_utdtodeviceevent_new(arg0) { - const ret = UTDToDeviceEvent.__wrap(arg0); - return ret; -} -function __wbg_value_1e2369fab29b420e(arg0) { - const ret = arg0.value; - return ret; -} -function __wbg_value_496e02446340ae74() { - return handleError(function (arg0) { - const ret = arg0.value; - return ret; - }, arguments); -} -function __wbg_values_d512097b1a1a9459(arg0) { - const ret = arg0.values(); - return ret; -} -function __wbg_verificationrequest_new(arg0) { - const ret = VerificationRequest.__wrap(arg0); - return ret; -} -function __wbg_version_26237923fff15d6e(arg0) { - const ret = arg0.version; - return ret; -} -function __wbg_versions_276b2795b1c6a219(arg0) { - const ret = arg0.versions; - return ret; -} -function __wbg_warn_917d7f727ab78481(arg0) { - console.warn(arg0); -} -function __wbg_warn_b62de6508e8608cc(arg0, arg1) { - arg0.warn(arg1); -} -function __wbindgen_cast_0000000000000001(arg0, arg1) { - // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 164, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`. - const ret = makeMutClosure(arg0, arg1, wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke___wasm_bindgen_ff9af61e2d43a78a___JsValue__core_ed718c3d60ebd546___result__Result_____wasm_bindgen_ff9af61e2d43a78a___JsError___true_); - return ret; -} -function __wbindgen_cast_0000000000000002(arg0, arg1) { - // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Event")], shim_idx: 558, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`. - const ret = makeMutClosure(arg0, arg1, wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke___web_sys_4ec35d1b8222c725___features__gen_Event__Event______true_); - return ret; -} -function __wbindgen_cast_0000000000000003(arg0, arg1) { - // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("IDBVersionChangeEvent")], shim_idx: 164, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`. - const ret = makeMutClosure(arg0, arg1, wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke___wasm_bindgen_ff9af61e2d43a78a___JsValue__core_ed718c3d60ebd546___result__Result_____wasm_bindgen_ff9af61e2d43a78a___JsError___true__2); - return ret; -} -function __wbindgen_cast_0000000000000004(arg0, arg1) { - // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 128, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`. - const ret = makeMutClosure(arg0, arg1, wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke_______true_); - return ret; -} -function __wbindgen_cast_0000000000000005(arg0) { - // Cast intrinsic for `F64 -> Externref`. - const ret = arg0; - return ret; -} -function __wbindgen_cast_0000000000000006(arg0) { - // Cast intrinsic for `I64 -> Externref`. - const ret = arg0; - return ret; -} -function __wbindgen_cast_0000000000000007(arg0, arg1) { - // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`. - const ret = getArrayU8FromWasm0(arg0, arg1); - return ret; -} -function __wbindgen_cast_0000000000000008(arg0, arg1) { - // Cast intrinsic for `Ref(String) -> Externref`. - const ret = getStringFromWasm0(arg0, arg1); - return ret; -} -function __wbindgen_cast_0000000000000009(arg0) { - // Cast intrinsic for `U64 -> Externref`. - const ret = BigInt.asUintN(64, arg0); - return ret; -} -function __wbindgen_cast_000000000000000a(arg0, arg1) { - var v0 = getArrayJsValueFromWasm0(arg0, arg1); - wasm.__wbindgen_free(arg0, arg1 * 4, 4); - // Cast intrinsic for `Vector(Externref) -> Externref`. - const ret = v0; - return ret; -} -function __wbindgen_init_externref_table() { - const table = wasm.__wbindgen_externrefs; - const offset = table.grow(4); - table.set(0, undefined); - table.set(offset + 0, undefined); - table.set(offset + 1, null); - table.set(offset + 2, true); - table.set(offset + 3, false); -} -function wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke_______true_(arg0, arg1) { - wasm.wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke_______true_(arg0, arg1); -} -function wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke___web_sys_4ec35d1b8222c725___features__gen_Event__Event______true_(arg0, arg1, arg2) { - wasm.wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke___web_sys_4ec35d1b8222c725___features__gen_Event__Event______true_(arg0, arg1, arg2); -} -function wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke___wasm_bindgen_ff9af61e2d43a78a___JsValue__core_ed718c3d60ebd546___result__Result_____wasm_bindgen_ff9af61e2d43a78a___JsError___true_(arg0, arg1, arg2) { - const ret = wasm.wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke___wasm_bindgen_ff9af61e2d43a78a___JsValue__core_ed718c3d60ebd546___result__Result_____wasm_bindgen_ff9af61e2d43a78a___JsError___true_(arg0, arg1, arg2); - if (ret[1]) { - throw takeFromExternrefTable0(ret[0]); - } -} -function wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke___wasm_bindgen_ff9af61e2d43a78a___JsValue__core_ed718c3d60ebd546___result__Result_____wasm_bindgen_ff9af61e2d43a78a___JsError___true__2(arg0, arg1, arg2) { - const ret = wasm.wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke___wasm_bindgen_ff9af61e2d43a78a___JsValue__core_ed718c3d60ebd546___result__Result_____wasm_bindgen_ff9af61e2d43a78a___JsError___true__2(arg0, arg1, arg2); - if (ret[1]) { - throw takeFromExternrefTable0(ret[0]); - } -} -function wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke___js_sys_8badcad5ae9f3759___Function_fn_wasm_bindgen_ff9af61e2d43a78a___JsValue_____wasm_bindgen_ff9af61e2d43a78a___sys__Undefined___js_sys_8badcad5ae9f3759___Function_fn_wasm_bindgen_ff9af61e2d43a78a___JsValue_____wasm_bindgen_ff9af61e2d43a78a___sys__Undefined_______true_(arg0, arg1, arg2, arg3) { - wasm.wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke___js_sys_8badcad5ae9f3759___Function_fn_wasm_bindgen_ff9af61e2d43a78a___JsValue_____wasm_bindgen_ff9af61e2d43a78a___sys__Undefined___js_sys_8badcad5ae9f3759___Function_fn_wasm_bindgen_ff9af61e2d43a78a___JsValue_____wasm_bindgen_ff9af61e2d43a78a___sys__Undefined_______true_(arg0, arg1, arg2, arg3); -} -const __wbindgen_enum_IdbRequestReadyState = ["pending", "done"]; -const __wbindgen_enum_IdbTransactionMode = ["readonly", "readwrite", "versionchange", "readwriteflush", "cleanup"]; -const AttachmentFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_attachment_free(ptr, 1)); -const BackupDecryptionKeyFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_backupdecryptionkey_free(ptr, 1)); -const BackupKeysFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_backupkeys_free(ptr, 1)); -const BackupSecretsBundleFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_backupsecretsbundle_free(ptr, 1)); -const Base64EncodedPkMessageFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_base64encodedpkmessage_free(ptr, 1)); -const BaseMigrationDataFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_basemigrationdata_free(ptr, 1)); -const CancelInfoFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_cancelinfo_free(ptr, 1)); -const CheckCodeFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_checkcode_free(ptr, 1)); -const CollectStrategyFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_collectstrategy_free(ptr, 1)); -const CrossSigningBootstrapRequestsFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_crosssigningbootstraprequests_free(ptr, 1)); -const CrossSigningKeyExportFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_crosssigningkeyexport_free(ptr, 1)); -const CrossSigningStatusFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_crosssigningstatus_free(ptr, 1)); -const Curve25519PublicKeyFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_curve25519publickey_free(ptr, 1)); -const Curve25519SecretKeyFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_curve25519secretkey_free(ptr, 1)); -const DecryptedRoomEventFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_decryptedroomevent_free(ptr, 1)); -const DecryptedToDeviceEventFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_decryptedtodeviceevent_free(ptr, 1)); -const DecryptionSettingsFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_decryptionsettings_free(ptr, 1)); -const DehydratedDeviceFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_dehydrateddevice_free(ptr, 1)); -const DehydratedDeviceKeyFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_dehydrateddevicekey_free(ptr, 1)); -const DehydratedDevicesFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_dehydrateddevices_free(ptr, 1)); -const DeviceFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_device_free(ptr, 1)); -const DeviceIdFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_deviceid_free(ptr, 1)); -const DeviceKeyFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_devicekey_free(ptr, 1)); -const DeviceKeyAlgorithmFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_devicekeyalgorithm_free(ptr, 1)); -const DeviceKeyIdFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_devicekeyid_free(ptr, 1)); -const DeviceListsFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_devicelists_free(ptr, 1)); -const EciesFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_ecies_free(ptr, 1)); -const Ed25519PublicKeyFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_ed25519publickey_free(ptr, 1)); -const Ed25519SignatureFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_ed25519signature_free(ptr, 1)); -const EmojiFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_emoji_free(ptr, 1)); -const EncryptedAttachmentFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_encryptedattachment_free(ptr, 1)); -const EncryptionInfoFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_encryptioninfo_free(ptr, 1)); -const EncryptionSettingsFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_encryptionsettings_free(ptr, 1)); -const EstablishedEciesFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_establishedecies_free(ptr, 1)); -const EventIdFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_eventid_free(ptr, 1)); -const IdentityKeysFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_identitykeys_free(ptr, 1)); -const InboundCreationResultFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_inboundcreationresult_free(ptr, 1)); -const InboundGroupSessionFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_inboundgroupsession_free(ptr, 1)); -const InvalidToDeviceEventFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_invalidtodeviceevent_free(ptr, 1)); -const KeysBackupRequestFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_keysbackuprequest_free(ptr, 1)); -const KeysClaimRequestFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_keysclaimrequest_free(ptr, 1)); -const KeysQueryRequestFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_keysqueryrequest_free(ptr, 1)); -const KeysUploadRequestFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_keysuploadrequest_free(ptr, 1)); -const MaybeSignatureFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_maybesignature_free(ptr, 1)); -const MegolmDecryptionErrorFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_megolmdecryptionerror_free(ptr, 1)); -const MegolmV1BackupKeyFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_megolmv1backupkey_free(ptr, 1)); -const MigrationFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_migration_free(ptr, 1)); -const Msc4108IntentDataFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_msc4108intentdata_free(ptr, 1)); -const Msc4388IntentDataFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_msc4388intentdata_free(ptr, 1)); -const OlmMachineFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_olmmachine_free(ptr, 1)); -const OtherUserIdentityFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_otheruseridentity_free(ptr, 1)); -const OutboundCreationResultFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_outboundcreationresult_free(ptr, 1)); -const OwnUserIdentityFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_ownuseridentity_free(ptr, 1)); -const PickledInboundGroupSessionFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_pickledinboundgroupsession_free(ptr, 1)); -const PickledSessionFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_pickledsession_free(ptr, 1)); -const PkDecryptionFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_pkdecryption_free(ptr, 1)); -const PkEncryptionFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_pkencryption_free(ptr, 1)); -const PkMessageFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_pkmessage_free(ptr, 1)); -const PlainTextToDeviceEventFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_plaintexttodeviceevent_free(ptr, 1)); -const PutDehydratedDeviceRequestFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_putdehydrateddevicerequest_free(ptr, 1)); -const QrFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_qr_free(ptr, 1)); -const QrCodeFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_qrcode_free(ptr, 1)); -const QrCodeDataFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_qrcodedata_free(ptr, 1)); -const QrCodeIntentDataFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_qrcodeintentdata_free(ptr, 1)); -const QrCodeScanFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_qrcodescan_free(ptr, 1)); -const RehydratedDeviceFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_rehydrateddevice_free(ptr, 1)); -const RoomIdFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_roomid_free(ptr, 1)); -const RoomKeyCountsFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_roomkeycounts_free(ptr, 1)); -const RoomKeyImportResultFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_roomkeyimportresult_free(ptr, 1)); -const RoomKeyInfoFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_roomkeyinfo_free(ptr, 1)); -const RoomKeyWithheldInfoFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_roomkeywithheldinfo_free(ptr, 1)); -const RoomMessageRequestFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_roommessagerequest_free(ptr, 1)); -const RoomPendingKeyBundleDetailsFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_roompendingkeybundledetails_free(ptr, 1)); -const RoomSettingsFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_roomsettings_free(ptr, 1)); -const SasFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_sas_free(ptr, 1)); -const SecretsBundleFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_secretsbundle_free(ptr, 1)); -const ServerNameFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_servername_free(ptr, 1)); -const ShieldStateFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_shieldstate_free(ptr, 1)); -const SignatureFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_signature_free(ptr, 1)); -const SignatureUploadRequestFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_signatureuploadrequest_free(ptr, 1)); -const SignatureVerificationFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_signatureverification_free(ptr, 1)); -const SignaturesFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_signatures_free(ptr, 1)); -const StoreHandleFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_storehandle_free(ptr, 1)); -const StoredRoomKeyBundleDataFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_storedroomkeybundledata_free(ptr, 1)); -const ToDeviceEncryptionInfoFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_todeviceencryptioninfo_free(ptr, 1)); -const ToDeviceRequestFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_todevicerequest_free(ptr, 1)); -const ToDeviceUnableToDecryptInfoFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_todeviceunabletodecryptinfo_free(ptr, 1)); -const TracingFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_tracing_free(ptr, 1)); -const UTDToDeviceEventFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_utdtodeviceevent_free(ptr, 1)); -const UploadSigningKeysRequestFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_uploadsigningkeysrequest_free(ptr, 1)); -const UserDevicesFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_userdevices_free(ptr, 1)); -const UserIdFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_userid_free(ptr, 1)); -const VerificationRequestFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_verificationrequest_free(ptr, 1)); -const VersionsFinalization = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(ptr => wasm.__wbg_versions_free(ptr, 1)); -function addToExternrefTable0(obj) { - const idx = wasm.__externref_table_alloc(); - wasm.__wbindgen_externrefs.set(idx, obj); - return idx; -} -function _assertClass(instance, klass) { - if (!(instance instanceof klass)) { - throw new Error(`expected instance of ${klass.name}`); - } -} -const CLOSURE_DTORS = typeof FinalizationRegistry === 'undefined' ? { - register: () => {}, - unregister: () => {} -} : new FinalizationRegistry(state => wasm.__wbindgen_destroy_closure(state.a, state.b)); -function debugString(val) { - // primitive types - const type = typeof val; - if (type == 'number' || type == 'boolean' || val == null) { - return `${val}`; - } - if (type == 'string') { - return `"${val}"`; - } - if (type == 'symbol') { - const description = val.description; - if (description == null) { - return 'Symbol'; - } else { - return `Symbol(${description})`; - } - } - if (type == 'function') { - const name = val.name; - if (typeof name == 'string' && name.length > 0) { - return `Function(${name})`; - } else { - return 'Function'; - } - } - // objects - if (Array.isArray(val)) { - const length = val.length; - let debug = '['; - if (length > 0) { - debug += debugString(val[0]); - } - for (let i = 1; i < length; i++) { - debug += ', ' + debugString(val[i]); - } - debug += ']'; - return debug; - } - // Test for built-in - const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); - let className; - if (builtInMatches && builtInMatches.length > 1) { - className = builtInMatches[1]; - } else { - // Failed to match the standard '[object ClassName]' - return toString.call(val); - } - if (className == 'Object') { - // we're a user defined class or Object - // JSON.stringify avoids problems with cycles, and is generally much - // easier than looping through ownProperties of `val`. - try { - return 'Object(' + JSON.stringify(val) + ')'; - } catch (_) { - return 'Object'; - } - } - // errors - if (val instanceof Error) { - return `${val.name}: ${val.message}\n${val.stack}`; - } - // TODO we could test for more things here, like `Set`s and `Map`s. - return className; -} -function getArrayJsValueFromWasm0(ptr, len) { - ptr = ptr >>> 0; - const mem = getDataViewMemory0(); - const result = []; - for (let i = ptr; i < ptr + 4 * len; i += 4) { - result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true))); - } - wasm.__externref_drop_slice(ptr, len); - return result; -} -function getArrayU16FromWasm0(ptr, len) { - ptr = ptr >>> 0; - return getUint16ArrayMemory0().subarray(ptr / 2, ptr / 2 + len); -} -function getArrayU8FromWasm0(ptr, len) { - ptr = ptr >>> 0; - return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len); -} -let cachedDataViewMemory0 = null; -function getDataViewMemory0() { - if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer) { - cachedDataViewMemory0 = new DataView(wasm.memory.buffer); - } - return cachedDataViewMemory0; -} -function getStringFromWasm0(ptr, len) { - return decodeText(ptr >>> 0, len); -} -let cachedUint16ArrayMemory0 = null; -function getUint16ArrayMemory0() { - if (cachedUint16ArrayMemory0 === null || cachedUint16ArrayMemory0.byteLength === 0) { - cachedUint16ArrayMemory0 = new Uint16Array(wasm.memory.buffer); - } - return cachedUint16ArrayMemory0; -} -let cachedUint8ArrayMemory0 = null; -function getUint8ArrayMemory0() { - if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) { - cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer); - } - return cachedUint8ArrayMemory0; -} -function handleError(f, args) { - try { - return f.apply(this, args); - } catch (e) { - const idx = addToExternrefTable0(e); - wasm.__wbindgen_exn_store(idx); - } -} -function isLikeNone(x) { - return x === undefined || x === null; -} -function makeMutClosure(arg0, arg1, f) { - const state = { - a: arg0, - b: arg1, - cnt: 1 - }; - const real = (...args) => { - // First up with a closure we increment the internal reference - // count. This ensures that the Rust closure environment won't - // be deallocated while we're invoking it. - state.cnt++; - const a = state.a; - state.a = 0; - try { - return f(a, state.b, ...args); - } finally { - state.a = a; - real._wbg_cb_unref(); - } - }; - real._wbg_cb_unref = () => { - if (--state.cnt === 0) { - wasm.__wbindgen_destroy_closure(state.a, state.b); - state.a = 0; - CLOSURE_DTORS.unregister(state); - } - }; - CLOSURE_DTORS.register(real, state, state); - return real; -} -function passArray8ToWasm0(arg, malloc) { - const ptr = malloc(arg.length * 1, 1) >>> 0; - getUint8ArrayMemory0().set(arg, ptr / 1); - WASM_VECTOR_LEN = arg.length; - return ptr; -} -function passArrayJsValueToWasm0(array, malloc) { - const ptr = malloc(array.length * 4, 4) >>> 0; - for (let i = 0; i < array.length; i++) { - const add = addToExternrefTable0(array[i]); - getDataViewMemory0().setUint32(ptr + 4 * i, add, true); - } - WASM_VECTOR_LEN = array.length; - return ptr; -} -function passStringToWasm0(arg, malloc, realloc) { - if (realloc === undefined) { - const buf = cachedTextEncoder.encode(arg); - const ptr = malloc(buf.length, 1) >>> 0; - getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf); - WASM_VECTOR_LEN = buf.length; - return ptr; - } - let len = arg.length; - let ptr = malloc(len, 1) >>> 0; - const mem = getUint8ArrayMemory0(); - let offset = 0; - for (; offset < len; offset++) { - const code = arg.charCodeAt(offset); - if (code > 0x7F) break; - mem[ptr + offset] = code; - } - if (offset !== len) { - if (offset !== 0) { - arg = arg.slice(offset); - } - ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; - const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len); - const ret = cachedTextEncoder.encodeInto(arg, view); - offset += ret.written; - ptr = realloc(ptr, len, offset, 1) >>> 0; - } - WASM_VECTOR_LEN = offset; - return ptr; -} -function takeFromExternrefTable0(idx) { - const value = wasm.__wbindgen_externrefs.get(idx); - wasm.__externref_table_dealloc(idx); - return value; -} -let cachedTextDecoder = new TextDecoder('utf-8', { - ignoreBOM: true, - fatal: true -}); -cachedTextDecoder.decode(); -const MAX_SAFARI_DECODE_BYTES = 2146435072; -let numBytesDecoded = 0; -function decodeText(ptr, len) { - numBytesDecoded += len; - if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) { - cachedTextDecoder = new TextDecoder('utf-8', { - ignoreBOM: true, - fatal: true - }); - cachedTextDecoder.decode(); - numBytesDecoded = len; - } - return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len)); -} -const cachedTextEncoder = new TextEncoder(); -if (!('encodeInto' in cachedTextEncoder)) { - cachedTextEncoder.encodeInto = function (arg, view) { - const buf = cachedTextEncoder.encode(arg); - view.set(buf); - return { - read: arg.length, - written: buf.length - }; - }; -} -let WASM_VECTOR_LEN = 0; -let wasm; -function __wbg_set_wasm(val) { - wasm = val; -} \ No newline at end of file diff --git a/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.js b/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.js deleted file mode 100644 index cd77fb5..0000000 --- a/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.js +++ /dev/null @@ -1,12182 +0,0 @@ -/** - * A type to encrypt and to decrypt anything that can fit in an - * `Uint8Array`, usually big buffer. - */ -export class Attachment { - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - AttachmentFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_attachment_free(ptr, 0); - } - /** - * Decrypt an `EncryptedAttachment`. - * - * The encrypted attachment can be created manually, or from the - * `encrypt` method. - * - * **Warning**: The encrypted attachment can be used only - * **once**! The encrypted data will still be present, but the - * media encryption info (which contain secrets) will be - * destroyed. It is still possible to get a JSON-encoded backup - * by calling `EncryptedAttachment.mediaEncryptionInfo`. - * @param {EncryptedAttachment} attachment - * @returns {Uint8Array} - */ - static decrypt(attachment) { - _assertClass(attachment, EncryptedAttachment); - const ret = wasm.attachment_decrypt(attachment.__wbg_ptr); - if (ret[3]) { - throw takeFromExternrefTable0(ret[2]); - } - var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - return v1; - } - /** - * Encrypt the content of the `Uint8Array`. - * - * It produces an `EncryptedAttachment`, which can be used to - * retrieve the media encryption information, or the encrypted - * data. - * @param {Uint8Array} array - * @returns {EncryptedAttachment} - */ - static encrypt(array) { - const ptr0 = passArray8ToWasm0(array, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.attachment_encrypt(ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return EncryptedAttachment.__wrap(ret[0]); - } -} -if (Symbol.dispose) Attachment.prototype[Symbol.dispose] = Attachment.prototype.free; - -/** - * The private part of the backup key, the one used for recovery. - */ -export class BackupDecryptionKey { - static __wrap(ptr) { - const obj = Object.create(BackupDecryptionKey.prototype); - obj.__wbg_ptr = ptr; - BackupDecryptionKeyFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - BackupDecryptionKeyFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_backupdecryptionkey_free(ptr, 0); - } - /** - * Create a new random [`BackupDecryptionKey`]. - * @returns {BackupDecryptionKey} - */ - static createRandomKey() { - const ret = wasm.backupdecryptionkey_createRandomKey(); - return BackupDecryptionKey.__wrap(ret); - } - /** - * Try to decrypt a message that was encrypted using the public part of the - * backup key. - * @param {string} ephemeral_key - * @param {string} mac - * @param {string} ciphertext - * @returns {string} - */ - decryptV1(ephemeral_key, mac, ciphertext) { - let deferred5_0; - let deferred5_1; - try { - const ptr0 = passStringToWasm0(ephemeral_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(mac, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(ciphertext, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ret = wasm.backupdecryptionkey_decryptV1(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2); - var ptr4 = ret[0]; - var len4 = ret[1]; - if (ret[3]) { - ptr4 = 0; len4 = 0; - throw takeFromExternrefTable0(ret[2]); - } - deferred5_0 = ptr4; - deferred5_1 = len4; - return getStringFromWasm0(ptr4, len4); - } finally { - wasm.__wbindgen_free(deferred5_0, deferred5_1, 1); - } - } - /** - * Try to create a [`BackupDecryptionKey`] from a base 64 encoded string. - * @param {string} key - * @returns {BackupDecryptionKey} - */ - static fromBase64(key) { - const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.backupdecryptionkey_fromBase64(ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return BackupDecryptionKey.__wrap(ret[0]); - } - /** - * Get the public part of the backup key. - * @returns {MegolmV1BackupKey} - */ - get megolmV1PublicKey() { - const ret = wasm.backupdecryptionkey_megolmV1PublicKey(this.__wbg_ptr); - return MegolmV1BackupKey.__wrap(ret); - } - /** - * Convert the backup decryption key to a base 64 encoded string. - * @returns {string} - */ - toBase64() { - const ret = wasm.backupdecryptionkey_toBase64(this.__wbg_ptr); - return ret; - } -} -if (Symbol.dispose) BackupDecryptionKey.prototype[Symbol.dispose] = BackupDecryptionKey.prototype.free; - -/** - * Stored versions of the backup keys. - */ -export class BackupKeys { - static __wrap(ptr) { - const obj = Object.create(BackupKeys.prototype); - obj.__wbg_ptr = ptr; - BackupKeysFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - BackupKeysFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_backupkeys_free(ptr, 0); - } - /** - * The key used to decrypt backed up room keys, encoded as base64 - * - * @deprecated Use `BackupKeys.decryptionKey.toBase64()` - * @returns {string | undefined} - */ - get decryptionKeyBase64() { - const ret = wasm.backupkeys_decryptionKeyBase64(this.__wbg_ptr); - return ret; - } - /** - * The version that we are using for backups. - * @returns {string | undefined} - */ - get backupVersion() { - const ret = wasm.__wbg_get_backupkeys_backupVersion(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * The key used to decrypt backed up room keys - * @returns {BackupDecryptionKey | undefined} - */ - get decryptionKey() { - const ret = wasm.__wbg_get_backupkeys_decryptionKey(this.__wbg_ptr); - return ret === 0 ? undefined : BackupDecryptionKey.__wrap(ret); - } - /** - * The version that we are using for backups. - * @param {string | null} [arg0] - */ - set backupVersion(arg0) { - var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_backupkeys_backupVersion(this.__wbg_ptr, ptr0, len0); - } - /** - * The key used to decrypt backed up room keys - * @param {BackupDecryptionKey | null} [arg0] - */ - set decryptionKey(arg0) { - let ptr0 = 0; - if (!isLikeNone(arg0)) { - _assertClass(arg0, BackupDecryptionKey); - ptr0 = arg0.__destroy_into_raw(); - } - wasm.__wbg_set_backupkeys_decryptionKey(this.__wbg_ptr, ptr0); - } -} -if (Symbol.dispose) BackupKeys.prototype[Symbol.dispose] = BackupKeys.prototype.free; - -/** - * The backup-specific parts of a secrets bundle. - */ -export class BackupSecretsBundle { - static __wrap(ptr) { - const obj = Object.create(BackupSecretsBundle.prototype); - obj.__wbg_ptr = ptr; - BackupSecretsBundleFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - BackupSecretsBundleFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_backupsecretsbundle_free(ptr, 0); - } - /** - * The backup version which this backup decryption key is used with. - * @returns {string} - */ - get backup_version() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_backupsecretsbundle_backup_version(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The backup decryption key, encoded as unpadded base64. - * @returns {string} - */ - get key() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_backupsecretsbundle_key(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The backup version which this backup decryption key is used with. - * @param {string} arg0 - */ - set backup_version(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_backupsecretsbundle_backup_version(this.__wbg_ptr, ptr0, len0); - } - /** - * The backup decryption key, encoded as unpadded base64. - * @param {string} arg0 - */ - set key(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_backupsecretsbundle_key(this.__wbg_ptr, ptr0, len0); - } -} -if (Symbol.dispose) BackupSecretsBundle.prototype[Symbol.dispose] = BackupSecretsBundle.prototype.free; - -/** - * The base64-encoded variant of a {@link PkMessage}. - * - * This can be useful if the encrypted message should be put into JSON. - */ -export class Base64EncodedPkMessage { - static __wrap(ptr) { - const obj = Object.create(Base64EncodedPkMessage.prototype); - obj.__wbg_ptr = ptr; - Base64EncodedPkMessageFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - Base64EncodedPkMessageFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_base64encodedpkmessage_free(ptr, 0); - } - /** - * Creates a new base64-encoded encrypted message from its parts. - * @param {string} ciphertext - * @param {string} mac - * @param {string} ephemeral_key - */ - constructor(ciphertext, mac, ephemeral_key) { - const ptr0 = passStringToWasm0(ciphertext, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(mac, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(ephemeral_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ret = wasm.base64encodedpkmessage_new(ptr0, len0, ptr1, len1, ptr2, len2); - this.__wbg_ptr = ret; - Base64EncodedPkMessageFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * The base64-encoded ciphertext. - * @returns {string} - */ - get ciphertext() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_base64encodedpkmessage_ciphertext(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The base64-encoded ephemeral public key. - * @returns {string} - */ - get ephemeralKey() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_base64encodedpkmessage_ephemeralKey(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The base64-encoded message authentication code (MAC). - * @returns {string} - */ - get mac() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_base64encodedpkmessage_mac(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The base64-encoded ciphertext. - * @param {string} arg0 - */ - set ciphertext(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_base64encodedpkmessage_ciphertext(this.__wbg_ptr, ptr0, len0); - } - /** - * The base64-encoded ephemeral public key. - * @param {string} arg0 - */ - set ephemeralKey(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_base64encodedpkmessage_ephemeralKey(this.__wbg_ptr, ptr0, len0); - } - /** - * The base64-encoded message authentication code (MAC). - * @param {string} arg0 - */ - set mac(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_base64encodedpkmessage_mac(this.__wbg_ptr, ptr0, len0); - } -} -if (Symbol.dispose) Base64EncodedPkMessage.prototype[Symbol.dispose] = Base64EncodedPkMessage.prototype.free; - -/** - * The base dataset that is important to migrate to the Rust SDK. - * - * Can be imported into the rust store with {@link Migration::migrateBaseData}. - */ -export class BaseMigrationData { - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - BaseMigrationDataFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_basemigrationdata_free(ptr, 0); - } - /** - * Create a new `BaseMigrationData` with default values. - */ - constructor() { - const ret = wasm.basemigrationdata_new(); - this.__wbg_ptr = ret; - BaseMigrationDataFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * The backup recovery key, as a base64-encoded string. - * @returns {string | undefined} - */ - get backupRecoveryKey() { - const ret = wasm.__wbg_get_basemigrationdata_backupRecoveryKey(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * The backup version that is currently active. - * @returns {string | undefined} - */ - get backupVersion() { - const ret = wasm.__wbg_get_basemigrationdata_backupVersion(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * The device ID of the account owner. - * @returns {DeviceId | undefined} - */ - get deviceId() { - const ret = wasm.__wbg_get_basemigrationdata_deviceId(this.__wbg_ptr); - return ret === 0 ? undefined : DeviceId.__wrap(ret); - } - /** - * The pickle string holding the Olm Account, as returned by - * `olm_pickle_account` in libolm. - * @returns {string} - */ - get pickledAccount() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_basemigrationdata_pickledAccount(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The private, base64-encoded, master cross-signing key. - * @returns {string | undefined} - */ - get privateCrossSigningMasterKey() { - const ret = wasm.__wbg_get_basemigrationdata_privateCrossSigningMasterKey(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * The private, base64-encoded, self-signing key. - * @returns {string | undefined} - */ - get privateCrossSigningSelfSigningKey() { - const ret = wasm.__wbg_get_basemigrationdata_privateCrossSigningSelfSigningKey(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * The private, base64-encoded, user-signing key. - * @returns {string | undefined} - */ - get privateCrossSigningUserSigningKey() { - const ret = wasm.__wbg_get_basemigrationdata_privateCrossSigningUserSigningKey(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * The user id of the account owner. - * @returns {UserId | undefined} - */ - get userId() { - const ret = wasm.__wbg_get_basemigrationdata_userId(this.__wbg_ptr); - return ret === 0 ? undefined : UserId.__wrap(ret); - } - /** - * The backup recovery key, as a base64-encoded string. - * @param {string | null} [arg0] - */ - set backupRecoveryKey(arg0) { - var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_basemigrationdata_backupRecoveryKey(this.__wbg_ptr, ptr0, len0); - } - /** - * The backup version that is currently active. - * @param {string | null} [arg0] - */ - set backupVersion(arg0) { - var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_basemigrationdata_backupVersion(this.__wbg_ptr, ptr0, len0); - } - /** - * The device ID of the account owner. - * @param {DeviceId | null} [arg0] - */ - set deviceId(arg0) { - let ptr0 = 0; - if (!isLikeNone(arg0)) { - _assertClass(arg0, DeviceId); - ptr0 = arg0.__destroy_into_raw(); - } - wasm.__wbg_set_basemigrationdata_deviceId(this.__wbg_ptr, ptr0); - } - /** - * The pickle string holding the Olm Account, as returned by - * `olm_pickle_account` in libolm. - * @param {string} arg0 - */ - set pickledAccount(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_basemigrationdata_pickledAccount(this.__wbg_ptr, ptr0, len0); - } - /** - * The private, base64-encoded, master cross-signing key. - * @param {string | null} [arg0] - */ - set privateCrossSigningMasterKey(arg0) { - var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_basemigrationdata_privateCrossSigningMasterKey(this.__wbg_ptr, ptr0, len0); - } - /** - * The private, base64-encoded, self-signing key. - * @param {string | null} [arg0] - */ - set privateCrossSigningSelfSigningKey(arg0) { - var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_basemigrationdata_privateCrossSigningSelfSigningKey(this.__wbg_ptr, ptr0, len0); - } - /** - * The private, base64-encoded, user-signing key. - * @param {string | null} [arg0] - */ - set privateCrossSigningUserSigningKey(arg0) { - var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_basemigrationdata_privateCrossSigningUserSigningKey(this.__wbg_ptr, ptr0, len0); - } - /** - * The user id of the account owner. - * @param {UserId | null} [arg0] - */ - set userId(arg0) { - let ptr0 = 0; - if (!isLikeNone(arg0)) { - _assertClass(arg0, UserId); - ptr0 = arg0.__destroy_into_raw(); - } - wasm.__wbg_set_basemigrationdata_userId(this.__wbg_ptr, ptr0); - } -} -if (Symbol.dispose) BaseMigrationData.prototype[Symbol.dispose] = BaseMigrationData.prototype.free; - -/** - * Information about the cancellation of a verification request or - * verification flow. - */ -export class CancelInfo { - static __wrap(ptr) { - const obj = Object.create(CancelInfo.prototype); - obj.__wbg_ptr = ptr; - CancelInfoFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - CancelInfoFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_cancelinfo_free(ptr, 0); - } - /** - * Get the `code` (e.g. `m.user`) that was used to cancel the - * verification. - * @returns {string} - */ - cancelCode() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.cancelinfo_cancelCode(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Was the verification cancelled by us? - * @returns {boolean} - */ - cancelledbyUs() { - const ret = wasm.cancelinfo_cancelledbyUs(this.__wbg_ptr); - return ret !== 0; - } - /** - * Get the human readable reason of the cancellation. - * @returns {string} - */ - reason() { - const ret = wasm.cancelinfo_reason(this.__wbg_ptr); - return ret; - } -} -if (Symbol.dispose) CancelInfo.prototype[Symbol.dispose] = CancelInfo.prototype.free; - -/** - * A check code that can be used to confirm that two {@link EstablishedEcies} - * objects share the same secret. This is supposed to be shared out-of-band to - * protect against active Man-in-the-middle (MITM) attacks. - * - * Since the initiator device can always tell whether a MITM attack is in - * progress after channel establishment, this code technically carries only a - * single bit of information, representing whether the initiator has determined - * that the channel is "secure" or "not secure". - * - * However, given this will need to be interactively confirmed by the user, - * there is risk that the user would confirm the dialogue without paying - * attention to its content. By expanding this single bit into a deterministic - * two-digit check code, the user is forced to pay more attention by having to - * enter it instead of just clicking through a dialogue. - */ -export class CheckCode { - static __wrap(ptr) { - const obj = Object.create(CheckCode.prototype); - obj.__wbg_ptr = ptr; - CheckCodeFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - CheckCodeFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_checkcode_free(ptr, 0); - } - /** - * Convert the check code to an array of two bytes. - * - * The bytes can be converted to a more user-friendly representation. - * {@link to_digit} and {@link toDigitNoLeadingZero} convert the bytes to a - * two-digit number. - * @returns {Uint8Array} - */ - as_bytes() { - const ret = wasm.checkcode_as_bytes(this.__wbg_ptr); - var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - return v1; - } - /** - * Convert the check code to two base-10 numbers, with no leading zero. - * - * This corresponds to the way the digits are defined in - * {@link https://github.com/matrix-org/matrix-spec-proposals/pull/4388 MSC4388}. - * @returns {number} - */ - toDigitNoLeadingZero() { - const ret = wasm.checkcode_toDigitNoLeadingZero(this.__wbg_ptr); - return ret; - } - /** - * Convert the check code to two base-10 numbers, allowing a leading zero. - * - * This corresponds to the way the digits were used in the initial version - * of {@link https://github.com/matrix-org/matrix-spec-proposals/pull/4108 MSC4108}. - * See {@link toDigitNoLeadingZero} for a more recent implementation. - * - * The number should be displayed with a leading 0 in case the first digit - * is a 0. - * @returns {number} - */ - to_digit() { - const ret = wasm.checkcode_to_digit(this.__wbg_ptr); - return ret; - } -} -if (Symbol.dispose) CheckCode.prototype[Symbol.dispose] = CheckCode.prototype.free; - -/** - * Strategy to collect the devices that should receive room keys for the - * current discussion. - */ -export class CollectStrategy { - static __wrap(ptr) { - const obj = Object.create(CollectStrategy.prototype); - obj.__wbg_ptr = ptr; - CollectStrategyFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - CollectStrategyFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_collectstrategy_free(ptr, 0); - } - /** - * Share with all (unblacklisted) devices. - * @returns {CollectStrategy} - */ - static allDevices() { - const ret = wasm.collectstrategy_allDevices(); - return CollectStrategy.__wrap(ret); - } - /** - * Device based sharing strategy. - * - * @deprecated: use one of {@link allDevices}, {@link - * errorOnUnverifiedUserProblem} or {@link onlyTrustedDevices}. - * @param {boolean} only_allow_trusted_devices - * @param {boolean} error_on_verified_user_problem - * @returns {CollectStrategy} - */ - static deviceBasedStrategy(only_allow_trusted_devices, error_on_verified_user_problem) { - const ret = wasm.collectstrategy_deviceBasedStrategy(only_allow_trusted_devices, error_on_verified_user_problem); - return CollectStrategy.__wrap(ret); - } - /** - * Tests for equality between two [`CollectStrategy`]s. - * @param {CollectStrategy} other - * @returns {boolean} - */ - eq(other) { - _assertClass(other, CollectStrategy); - const ret = wasm.collectstrategy_eq(this.__wbg_ptr, other.__wbg_ptr); - return ret !== 0; - } - /** - * Share with all devices, except that errors for *verified* users cause - * sharing to fail with an error. - * - * In this strategy, if a verified user has an unsigned device, or - * a verified user has replaced their identity, key - * sharing will fail with an error. - * - * Otherwise, keys are shared with unsigned devices as normal. - * - * Once the problematic devices are blacklisted or whitelisted the - * caller can try sharing a second time. - * @returns {CollectStrategy} - */ - static errorOnUnverifiedUserProblem() { - const ret = wasm.collectstrategy_errorOnUnverifiedUserProblem(); - return CollectStrategy.__wrap(ret); - } - /** - * Share based on identity. Only distribute to devices signed by their - * owner. If a user has no published identity he will not receive - * any room keys. - * @returns {CollectStrategy} - */ - static identityBasedStrategy() { - const ret = wasm.collectstrategy_identityBasedStrategy(); - return CollectStrategy.__wrap(ret); - } - /** - * Only share keys with devices that we "trust". A device is trusted if any - * of the following is true: - * - It was manually marked as trusted. - * - It was marked as verified via interactive verification. - * - It is signed by its owner identity, and this identity has been - * trusted via interactive verification. - * - It is the current own device of the user. - * @returns {CollectStrategy} - */ - static onlyTrustedDevices() { - const ret = wasm.collectstrategy_onlyTrustedDevices(); - return CollectStrategy.__wrap(ret); - } -} -if (Symbol.dispose) CollectStrategy.prototype[Symbol.dispose] = CollectStrategy.prototype.free; - -/** - * A set of requests to be executed when bootstrapping cross-signing using - * {@link OlmMachine.bootstrapCrossSigning}. - */ -export class CrossSigningBootstrapRequests { - static __wrap(ptr) { - const obj = Object.create(CrossSigningBootstrapRequests.prototype); - obj.__wbg_ptr = ptr; - CrossSigningBootstrapRequestsFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - CrossSigningBootstrapRequestsFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_crosssigningbootstraprequests_free(ptr, 0); - } - /** - * An optional request to upload a device key. - * - * This will either be `undefined`, or an "outgoing request" as returned by - * {@link OlmMachine.outgoingRequests}. - * - * If it is defined, the request should be sent first, and the result sent - * back with {@link OlmMachine.markRequestAsSent}. - * @returns {any} - */ - get uploadKeysRequest() { - const ret = wasm.__wbg_get_crosssigningbootstraprequests_uploadKeysRequest(this.__wbg_ptr); - return ret; - } - /** - * Request to upload key signatures, including those for the cross-signing - * keys, and maybe some for the optional uploaded key too. - * - * Should be sent last. - * @returns {SignatureUploadRequest} - */ - get uploadSignaturesRequest() { - const ret = wasm.__wbg_get_crosssigningbootstraprequests_uploadSignaturesRequest(this.__wbg_ptr); - return SignatureUploadRequest.__wrap(ret); - } - /** - * Request to upload the cross-signing keys. - * - * Should be sent second. - * @returns {UploadSigningKeysRequest} - */ - get uploadSigningKeysRequest() { - const ret = wasm.__wbg_get_crosssigningbootstraprequests_uploadSigningKeysRequest(this.__wbg_ptr); - return UploadSigningKeysRequest.__wrap(ret); - } -} -if (Symbol.dispose) CrossSigningBootstrapRequests.prototype[Symbol.dispose] = CrossSigningBootstrapRequests.prototype.free; - -/** - * A struct containing private cross signing keys that can be backed - * up or uploaded to the secret store. - */ -export class CrossSigningKeyExport { - static __wrap(ptr) { - const obj = Object.create(CrossSigningKeyExport.prototype); - obj.__wbg_ptr = ptr; - CrossSigningKeyExportFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - CrossSigningKeyExportFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_crosssigningkeyexport_free(ptr, 0); - } - /** - * The seed of the master key encoded as unpadded base64. - * @returns {string | undefined} - */ - get masterKey() { - const ret = wasm.crosssigningkeyexport_masterKey(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * The seed of the self signing key encoded as unpadded base64. - * @returns {string | undefined} - */ - get self_signing_key() { - const ret = wasm.crosssigningkeyexport_self_signing_key(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * The seed of the user signing key encoded as unpadded base64. - * @returns {string | undefined} - */ - get userSigningKey() { - const ret = wasm.crosssigningkeyexport_userSigningKey(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } -} -if (Symbol.dispose) CrossSigningKeyExport.prototype[Symbol.dispose] = CrossSigningKeyExport.prototype.free; - -/** - * Struct representing the state of our private cross signing keys, - * it shows which private cross signing keys we have locally stored. - */ -export class CrossSigningStatus { - static __wrap(ptr) { - const obj = Object.create(CrossSigningStatus.prototype); - obj.__wbg_ptr = ptr; - CrossSigningStatusFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - CrossSigningStatusFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_crosssigningstatus_free(ptr, 0); - } - /** - * Do we have the master key? - * @returns {boolean} - */ - get hasMaster() { - const ret = wasm.crosssigningstatus_hasMaster(this.__wbg_ptr); - return ret !== 0; - } - /** - * Do we have the self signing key? This one is necessary to sign - * our own devices. - * @returns {boolean} - */ - get hasSelfSigning() { - const ret = wasm.crosssigningstatus_hasSelfSigning(this.__wbg_ptr); - return ret !== 0; - } - /** - * Do we have the user signing key? This one is necessary to sign - * other users. - * @returns {boolean} - */ - get hasUserSigning() { - const ret = wasm.crosssigningstatus_hasUserSigning(this.__wbg_ptr); - return ret !== 0; - } -} -if (Symbol.dispose) CrossSigningStatus.prototype[Symbol.dispose] = CrossSigningStatus.prototype.free; - -/** - * A Curve25519 public key. - */ -export class Curve25519PublicKey { - static __wrap(ptr) { - const obj = Object.create(Curve25519PublicKey.prototype); - obj.__wbg_ptr = ptr; - Curve25519PublicKeyFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - Curve25519PublicKeyFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_curve25519publickey_free(ptr, 0); - } - /** - * The number of bytes a Curve25519 public key has. - * @returns {number} - */ - get length() { - const ret = wasm.curve25519publickey_length(this.__wbg_ptr); - return ret >>> 0; - } - /** - * Create a new [`Curve25519PublicKey`] from a base64 encoded string. - * @param {string} key - */ - constructor(key) { - const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.curve25519publickey_new(ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - this.__wbg_ptr = ret[0]; - Curve25519PublicKeyFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Serialize an Curve25519 public key to an unpadded base64 - * representation. - * @returns {string} - */ - toBase64() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.curve25519publickey_toBase64(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } -} -if (Symbol.dispose) Curve25519PublicKey.prototype[Symbol.dispose] = Curve25519PublicKey.prototype.free; - -/** - * A Curve25519 secret key. - */ -export class Curve25519SecretKey { - static __wrap(ptr) { - const obj = Object.create(Curve25519SecretKey.prototype); - obj.__wbg_ptr = ptr; - Curve25519SecretKeyFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - Curve25519SecretKeyFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_curve25519secretkey_free(ptr, 0); - } - /** - * Creates a `Curve25519SecretKey` from a base64-encoded representation of - * the key. - * @param {string} string - * @returns {Curve25519SecretKey} - */ - static fromBase64(string) { - const ptr0 = passStringToWasm0(string, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.curve25519secretkey_fromBase64(ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return Curve25519SecretKey.__wrap(ret[0]); - } - /** - * Creates a `Curve25519SecretKey` from a raw byte slice. - * @param {Uint8Array} slice - * @returns {Curve25519SecretKey} - */ - static fromUint8Array(slice) { - const ptr0 = passArray8ToWasm0(slice, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.curve25519secretkey_fromUint8Array(ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return Curve25519SecretKey.__wrap(ret[0]); - } - /** - * Generates a new random Curve25519 secret key. - * @returns {Curve25519SecretKey} - */ - static new() { - const ret = wasm.curve25519secretkey_new(); - return Curve25519SecretKey.__wrap(ret); - } - /** - * Encodes the secret key into a base64 string. - * @returns {string} - */ - toBase64() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.curve25519secretkey_toBase64(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Converts the secret key into a raw byte vector. - * @returns {Uint8Array} - */ - toUint8Array() { - const ret = wasm.curve25519secretkey_toUint8Array(this.__wbg_ptr); - var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - return v1; - } -} -if (Symbol.dispose) Curve25519SecretKey.prototype[Symbol.dispose] = Curve25519SecretKey.prototype.free; - -/** - * A decrypted room event. - */ -export class DecryptedRoomEvent { - static __wrap(ptr) { - const obj = Object.create(DecryptedRoomEvent.prototype); - obj.__wbg_ptr = ptr; - DecryptedRoomEventFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - DecryptedRoomEventFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_decryptedroomevent_free(ptr, 0); - } - /** - * If the keys for this message were shared-on-invite as part of an - * [MSC4268] key bundle, the ID of the user who sent us the bundle. - * - * [MSC4268]: https://github.com/matrix-org/matrix-spec-proposals/pull/4268 - * @returns {UserId | undefined} - */ - get forwarder() { - const ret = wasm.decryptedroomevent_forwarder(this.__wbg_ptr); - return ret === 0 ? undefined : UserId.__wrap(ret); - } - /** - * If the keys for this message were shared-on-invite as part of an - * [MSC4268] key bundle, the ID of the device from which this bundle - * was sent. - * - * [MSC4268]: https://github.com/matrix-org/matrix-spec-proposals/pull/4268 - * @returns {DeviceId | undefined} - */ - get forwarderDevice() { - const ret = wasm.decryptedroomevent_forwarderDevice(this.__wbg_ptr); - return ret === 0 ? undefined : DeviceId.__wrap(ret); - } - /** - * Returns an empty array - * - * Previously, this returned the chain of Curve25519 keys through which - * this session was forwarded, via `m.forwarded_room_key` events. - * However, that is not cryptographically reliable, and clients should not - * be using it. - * - * @see https://github.com/matrix-org/matrix-spec/issues/1089 - * @returns {string[]} - */ - get forwardingCurve25519KeyChain() { - const ret = wasm.decryptedroomevent_forwardingCurve25519KeyChain(this.__wbg_ptr); - return ret; - } - /** - * The user ID of the event sender, note this is untrusted data - * unless the `verification_state` is as well trusted. - * @returns {UserId} - */ - get sender() { - const ret = wasm.decryptedroomevent_sender(this.__wbg_ptr); - return UserId.__wrap(ret); - } - /** - * The signing Ed25519 key that have created the megolm key that - * was used to decrypt this session. - * @returns {string | undefined} - */ - get senderClaimedEd25519Key() { - const ret = wasm.decryptedroomevent_senderClaimedEd25519Key(this.__wbg_ptr); - return ret; - } - /** - * The Curve25519 key of the device that created the megolm - * decryption key originally. - * @returns {string} - */ - get senderCurve25519Key() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.decryptedroomevent_senderCurve25519Key(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The device ID of the device that sent us the event, note this - * is untrusted data unless `verification_state` is as well - * trusted. - * @returns {DeviceId | undefined} - */ - get senderDevice() { - const ret = wasm.decryptedroomevent_senderDevice(this.__wbg_ptr); - return ret === 0 ? undefined : DeviceId.__wrap(ret); - } - /** - * The verification state of the device that sent us the event. - * Note this is the state of the device at the time of - * decryption. It may change in the future if a device gets - * verified or deleted. - * @param {boolean} strict - * @returns {ShieldState} - */ - shieldState(strict) { - const ret = wasm.decryptedroomevent_shieldState(this.__wbg_ptr, strict); - return ShieldState.__wrap(ret); - } - /** - * The JSON-encoded decrypted event. - * @returns {string} - */ - get event() { - const ret = wasm.__wbg_get_decryptedroomevent_event(this.__wbg_ptr); - return ret; - } -} -if (Symbol.dispose) DecryptedRoomEvent.prototype[Symbol.dispose] = DecryptedRoomEvent.prototype.free; - -/** - * Represents an encrypted to-device event, after it has been decrypted. - */ -export class DecryptedToDeviceEvent { - static __wrap(ptr) { - const obj = Object.create(DecryptedToDeviceEvent.prototype); - obj.__wbg_ptr = ptr; - DecryptedToDeviceEventFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - DecryptedToDeviceEventFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_decryptedtodeviceevent_free(ptr, 0); - } - /** - * The type of processed to-device event. Always {@link - * ProcessedToDeviceEventType.Decrypted} for this type. - * @returns {ProcessedToDeviceEventType} - */ - get type() { - const ret = wasm.decryptedtodeviceevent_type(this.__wbg_ptr); - return ret; - } - /** - * The encryption information for the event. - * @returns {ToDeviceEncryptionInfo} - */ - get encryptionInfo() { - const ret = wasm.__wbg_get_decryptedtodeviceevent_encryptionInfo(this.__wbg_ptr); - return ToDeviceEncryptionInfo.__wrap(ret); - } - /** - * The decrypted event, as if it had been sent in the clear, encoded as - * JSON. - * - * Typically contains properties `type`, `sender` and `content`. - * - * (For room keys or secrets, some part of the content might have been - * zeroized). - * @returns {string} - */ - get rawEvent() { - const ret = wasm.__wbg_get_decryptedtodeviceevent_rawEvent(this.__wbg_ptr); - return ret; - } -} -if (Symbol.dispose) DecryptedToDeviceEvent.prototype[Symbol.dispose] = DecryptedToDeviceEvent.prototype.free; - -/** - * Decryption error codes - * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7} - */ -export const DecryptionErrorCode = Object.freeze({ - /** - * The room key is not known - */ - MissingRoomKey: 0, "0": "MissingRoomKey", - /** - * The room key is known but ratcheted - */ - UnknownMessageIndex: 1, "1": "UnknownMessageIndex", - /** - * Decryption failed because of a mismatch between the identity keys of the - * device we received the room key from and the identity keys recorded in - * the plaintext of the room key to-device message. - */ - MismatchedIdentityKeys: 2, "2": "MismatchedIdentityKeys", - /** - * We weren't able to link the message back to any known device. - */ - UnknownSenderDevice: 3, "3": "UnknownSenderDevice", - /** - * The sender device is not cross-signed. - */ - UnsignedSenderDevice: 4, "4": "UnsignedSenderDevice", - /** - * The sender's identity is unverified, but was previously verified. - */ - SenderIdentityVerificationViolation: 5, "5": "SenderIdentityVerificationViolation", - /** - * Other failure. - */ - UnableToDecrypt: 6, "6": "UnableToDecrypt", - /** - * The `sender` field on the event does not match the owner of the device - * that established the Megolm session. - */ - MismatchedSender: 7, "7": "MismatchedSender", -}); - -/** - * Settings for decrypting messages - */ -export class DecryptionSettings { - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - DecryptionSettingsFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_decryptionsettings_free(ptr, 0); - } - /** - * Create a new `DecryptionSettings` with the given trust requirement. - * @param {TrustRequirement} sender_device_trust_requirement - */ - constructor(sender_device_trust_requirement) { - const ret = wasm.decryptionsettings_new(sender_device_trust_requirement); - this.__wbg_ptr = ret; - DecryptionSettingsFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * The trust level required to decrypt the event - * @returns {TrustRequirement} - */ - get sender_device_trust_requirement() { - const ret = wasm.__wbg_get_decryptionsettings_sender_device_trust_requirement(this.__wbg_ptr); - return ret; - } - /** - * The trust level required to decrypt the event - * @param {TrustRequirement} arg0 - */ - set sender_device_trust_requirement(arg0) { - wasm.__wbg_set_decryptionsettings_sender_device_trust_requirement(this.__wbg_ptr, arg0); - } -} -if (Symbol.dispose) DecryptionSettings.prototype[Symbol.dispose] = DecryptionSettings.prototype.free; - -/** - * A dehydrated device that can be uploaded to the server - */ -export class DehydratedDevice { - static __wrap(ptr) { - const obj = Object.create(DehydratedDevice.prototype); - obj.__wbg_ptr = ptr; - DehydratedDeviceFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - DehydratedDeviceFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_dehydrateddevice_free(ptr, 0); - } - /** - * Create the request to upload the dehydrated device - * @param {string} initial_device_display_name - * @param {DehydratedDeviceKey} dehydrated_device_key - * @returns {Promise} - */ - keysForUpload(initial_device_display_name, dehydrated_device_key) { - _assertClass(dehydrated_device_key, DehydratedDeviceKey); - const ret = wasm.dehydrateddevice_keysForUpload(this.__wbg_ptr, initial_device_display_name, dehydrated_device_key.__wbg_ptr); - return ret; - } -} -if (Symbol.dispose) DehydratedDevice.prototype[Symbol.dispose] = DehydratedDevice.prototype.free; - -/** - * Dehydrated device key - */ -export class DehydratedDeviceKey { - static __wrap(ptr) { - const obj = Object.create(DehydratedDeviceKey.prototype); - obj.__wbg_ptr = ptr; - DehydratedDeviceKeyFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - DehydratedDeviceKeyFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_dehydrateddevicekey_free(ptr, 0); - } - /** - * Generates a dehydrated device key from a given array. - * @param {Uint8Array} array - * @returns {DehydratedDeviceKey} - */ - static createKeyFromArray(array) { - const ret = wasm.dehydrateddevicekey_createKeyFromArray(array); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return DehydratedDeviceKey.__wrap(ret[0]); - } - /** - * Generates a new random dehydrated device key. - * @returns {DehydratedDeviceKey} - */ - static createRandomKey() { - const ret = wasm.dehydrateddevicekey_createRandomKey(); - return DehydratedDeviceKey.__wrap(ret); - } - /** - * Convert the dehydrated device key to a base64-encoded string. - * @returns {string} - */ - toBase64() { - const ret = wasm.dehydrateddevicekey_toBase64(this.__wbg_ptr); - return ret; - } -} -if (Symbol.dispose) DehydratedDeviceKey.prototype[Symbol.dispose] = DehydratedDeviceKey.prototype.free; - -/** - * Struct collecting methods to create and rehydrate dehydrated devices. - */ -export class DehydratedDevices { - static __wrap(ptr) { - const obj = Object.create(DehydratedDevices.prototype); - obj.__wbg_ptr = ptr; - DehydratedDevicesFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - DehydratedDevicesFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_dehydrateddevices_free(ptr, 0); - } - /** - * Create a new {@link DehydratedDevice} which can be uploaded to the - * server. - * @returns {Promise} - */ - create() { - const ret = wasm.dehydrateddevices_create(this.__wbg_ptr); - return ret; - } - /** - * Clear the dehydrated device key saved in the crypto store. - * @returns {Promise} - */ - deleteDehydratedDeviceKey() { - const ret = wasm.dehydrateddevices_deleteDehydratedDeviceKey(this.__wbg_ptr); - return ret; - } - /** - * Get the cached dehydrated device key if any. - * - * `None` if the key was not previously cached (via - * {@link DehydratedDevices.saveDehydratedDeviceKey}). - * @returns {Promise} - */ - getDehydratedDeviceKey() { - const ret = wasm.dehydrateddevices_getDehydratedDeviceKey(this.__wbg_ptr); - return ret; - } - /** - * Rehydrate a dehydrated device. - * @param {DehydratedDeviceKey} dehydrated_device_key - * @param {DeviceId} device_id - * @param {string} device_data - * @returns {Promise} - */ - rehydrate(dehydrated_device_key, device_id, device_data) { - _assertClass(dehydrated_device_key, DehydratedDeviceKey); - _assertClass(device_id, DeviceId); - const ptr0 = passStringToWasm0(device_data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.dehydrateddevices_rehydrate(this.__wbg_ptr, dehydrated_device_key.__wbg_ptr, device_id.__wbg_ptr, ptr0, len0); - return ret; - } - /** - * Store the dehydrated device key in the crypto store. - * @param {DehydratedDeviceKey} dehydrated_device_key - * @returns {Promise} - */ - saveDehydratedDeviceKey(dehydrated_device_key) { - _assertClass(dehydrated_device_key, DehydratedDeviceKey); - const ret = wasm.dehydrateddevices_saveDehydratedDeviceKey(this.__wbg_ptr, dehydrated_device_key.__wbg_ptr); - return ret; - } -} -if (Symbol.dispose) DehydratedDevices.prototype[Symbol.dispose] = DehydratedDevices.prototype.free; - -/** - * A device represents a E2EE capable client of an user. - */ -export class Device { - static __wrap(ptr) { - const obj = Object.create(Device.prototype); - obj.__wbg_ptr = ptr; - DeviceFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - DeviceFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_device_free(ptr, 0); - } - /** - * Get the list of algorithms this device supports. - * - * Returns `Array`. - * @returns {EncryptionAlgorithm[]} - */ - get algorithms() { - const ret = wasm.device_algorithms(this.__wbg_ptr); - return ret; - } - /** - * Get the Curve25519 key of the given device. - * @returns {Curve25519PublicKey | undefined} - */ - get curve25519Key() { - const ret = wasm.device_curve25519Key(this.__wbg_ptr); - return ret === 0 ? undefined : Curve25519PublicKey.__wrap(ret); - } - /** - * The unique ID of the device. - * @returns {DeviceId} - */ - get deviceId() { - const ret = wasm.device_deviceId(this.__wbg_ptr); - return DeviceId.__wrap(ret); - } - /** - * Get the human readable name of the device. - * @returns {string | undefined} - */ - get displayName() { - const ret = wasm.device_displayName(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * Get the Ed25519 key of the given device. - * @returns {Ed25519PublicKey | undefined} - */ - get ed25519Key() { - const ret = wasm.device_ed25519Key(this.__wbg_ptr); - return ret === 0 ? undefined : Ed25519PublicKey.__wrap(ret); - } - /** - * Encrypt a to-device message to be sent to this device, using Olm - * encryption. - * - * Prior to calling this method you must ensure that an Olm session is - * available for the target device. This can be done by calling - * {@link OlmMachine.getMissingSessions}. - * - * The caller is responsible for sending the encrypted - * event to the target device. If multiple messages are - * encrypted for the same device using this method they should be sent in - * the same order as they are encrypted. - * - * # Returns - * - * Returns a promise for a JSON string containing the `content` of an - * encrypted event, which be used to create the payload for a - * `/sendToDevice` API. - * @param {string} event_type - * @param {any} content - * @param {CollectStrategy | null} [share_strategy] - * @returns {Promise} - */ - encryptToDeviceEvent(event_type, content, share_strategy) { - const ptr0 = passStringToWasm0(event_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - let ptr1 = 0; - if (!isLikeNone(share_strategy)) { - _assertClass(share_strategy, CollectStrategy); - ptr1 = share_strategy.__destroy_into_raw(); - } - const ret = wasm.device_encryptToDeviceEvent(this.__wbg_ptr, ptr0, len0, content, ptr1); - return ret; - } - /** - * Timestamp representing the first time this device has been seen (in - * milliseconds). - * @returns {bigint} - */ - firstTimeSeen() { - const ret = wasm.device_firstTimeSeen(this.__wbg_ptr); - return BigInt.asUintN(64, ret); - } - /** - * Get the key of the given key algorithm belonging to this device. - * @param {DeviceKeyAlgorithmName} algorithm - * @returns {DeviceKey | undefined} - */ - getKey(algorithm) { - const ret = wasm.device_getKey(this.__wbg_ptr, algorithm); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return ret[0] === 0 ? undefined : DeviceKey.__wrap(ret[0]); - } - /** - * Is the device locally marked as blacklisted? - * - * Blacklisted devices won’t receive any group sessions. - * @returns {boolean} - */ - isBlacklisted() { - const ret = wasm.device_isBlacklisted(this.__wbg_ptr); - return ret !== 0; - } - /** - * Is this device cross-signed by its owner? - * @returns {boolean} - */ - isCrossSignedByOwner() { - const ret = wasm.device_isCrossSignedByOwner(this.__wbg_ptr); - return ret !== 0; - } - /** - * Is this device considered to be verified using cross signing. - * @returns {boolean} - */ - isCrossSigningTrusted() { - const ret = wasm.device_isCrossSigningTrusted(this.__wbg_ptr); - return ret !== 0; - } - /** - * Whether or not the device is a dehydrated device. - * @returns {boolean} - */ - get isDehydrated() { - const ret = wasm.device_isDehydrated(this.__wbg_ptr); - return ret !== 0; - } - /** - * Is the device deleted? - * @returns {boolean} - */ - isDeleted() { - const ret = wasm.device_isDeleted(this.__wbg_ptr); - return ret !== 0; - } - /** - * Is the device locally marked as trusted? - * @returns {boolean} - */ - isLocallyTrusted() { - const ret = wasm.device_isLocallyTrusted(this.__wbg_ptr); - return ret !== 0; - } - /** - * Is this device considered to be verified. - * - * This method returns true if either the `is_locally_trusted` - * method returns `true` or if the `is_cross_signing_trusted` - * method returns `true`. - * @returns {boolean} - */ - isVerified() { - const ret = wasm.device_isVerified(this.__wbg_ptr); - return ret !== 0; - } - /** - * Get a map containing all the device keys. - * @returns {Map} - */ - get keys() { - const ret = wasm.device_keys(this.__wbg_ptr); - return ret; - } - /** - * Get the trust state of the device. - * @returns {LocalTrust} - */ - get localTrustState() { - const ret = wasm.device_localTrustState(this.__wbg_ptr); - return ret; - } - /** - * Request an interactive verification with this device. - * - * Returns a 2-element array `[VerificationRequest, ToDeviceRequest]`. - * @param {VerificationMethod[]} [methods] - * @returns {[VerificationRequest, ToDeviceRequest]} - */ - requestVerification(methods) { - var ptr0 = isLikeNone(methods) ? 0 : passArrayJsValueToWasm0(methods, wasm.__wbindgen_malloc); - var len0 = WASM_VECTOR_LEN; - const ret = wasm.device_requestVerification(this.__wbg_ptr, ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Set the local trust state of the device to the given state. - * - * This won’t affect any cross signing trust state, this only - * sets a flag marking to have the given trust state. - * - * `trust_state` represents the new trust state that should be - * set for the device. - * @param {LocalTrust} local_state - * @returns {Promise} - */ - setLocalTrust(local_state) { - const ret = wasm.device_setLocalTrust(this.__wbg_ptr, local_state); - return ret; - } - /** - * Get a map containing all the device signatures. - * @returns {Signatures} - */ - get signatures() { - const ret = wasm.device_signatures(this.__wbg_ptr); - return Signatures.__wrap(ret); - } - /** - * The user ID of the device owner. - * @returns {UserId} - */ - get userId() { - const ret = wasm.device_userId(this.__wbg_ptr); - return UserId.__wrap(ret); - } - /** - * Mark this device as verified. - * Works only if the device is owned by the current user. - * - * Returns a signature upload request that needs to be sent out. - * @returns {Promise} - */ - verify() { - const ret = wasm.device_verify(this.__wbg_ptr); - return ret; - } -} -if (Symbol.dispose) Device.prototype[Symbol.dispose] = Device.prototype.free; - -/** - * A Matrix key ID. - * - * Device identifiers in Matrix are completely opaque character - * sequences. This type is provided simply for its semantic value. - */ -export class DeviceId { - static __wrap(ptr) { - const obj = Object.create(DeviceId.prototype); - obj.__wbg_ptr = ptr; - DeviceIdFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - DeviceIdFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_deviceid_free(ptr, 0); - } - /** - * Create a new `DeviceId`. - * @param {string} id - */ - constructor(id) { - const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.deviceid_new(ptr0, len0); - this.__wbg_ptr = ret; - DeviceIdFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Return the device ID as a string. - * @returns {string} - */ - toString() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.deviceid_toString(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } -} -if (Symbol.dispose) DeviceId.prototype[Symbol.dispose] = DeviceId.prototype.free; - -/** - * An enum over the different key types a device can have. - * - * Currently devices have a curve25519 and ed25519 keypair. The keys - * transport format is a base64 encoded string, any unknown key type - * will be left as such a string. - */ -export class DeviceKey { - static __wrap(ptr) { - const obj = Object.create(DeviceKey.prototype); - obj.__wbg_ptr = ptr; - DeviceKeyFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - DeviceKeyFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_devicekey_free(ptr, 0); - } - /** - * Get the value associated to the `Curve25519` device key name. - * @returns {Curve25519PublicKey | undefined} - */ - get curve25519() { - const ret = wasm.devicekey_curve25519(this.__wbg_ptr); - return ret === 0 ? undefined : Curve25519PublicKey.__wrap(ret); - } - /** - * Get the value associated to the `Ed25519` device key name. - * @returns {Ed25519PublicKey | undefined} - */ - get ed25519() { - const ret = wasm.devicekey_ed25519(this.__wbg_ptr); - return ret === 0 ? undefined : Ed25519PublicKey.__wrap(ret); - } - /** - * Get the name of the device key. - * @returns {DeviceKeyName} - */ - get name() { - const ret = wasm.devicekey_name(this.__wbg_ptr); - return ret; - } - /** - * Convert the `DeviceKey` into a base64 encoded string. - * @returns {string} - */ - toBase64() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.devicekey_toBase64(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Get the value associated to the `Unknown` device key name. - * @returns {string | undefined} - */ - get unknown() { - const ret = wasm.devicekey_unknown(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } -} -if (Symbol.dispose) DeviceKey.prototype[Symbol.dispose] = DeviceKey.prototype.free; - -/** - * The basic key algorithms in the specification. - */ -export class DeviceKeyAlgorithm { - static __wrap(ptr) { - const obj = Object.create(DeviceKeyAlgorithm.prototype); - obj.__wbg_ptr = ptr; - DeviceKeyAlgorithmFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - DeviceKeyAlgorithmFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_devicekeyalgorithm_free(ptr, 0); - } - /** - * Read the device key algorithm's name. If the name is - * `Unknown`, one may be interested by the `to_string` method to - * read the original name. - * @returns {DeviceKeyAlgorithmName} - */ - get name() { - const ret = wasm.devicekeyalgorithm_name(this.__wbg_ptr); - return ret; - } - /** - * Return the device key algorithm as a string. - * @returns {string} - */ - toString() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.devicekeyalgorithm_toString(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } -} -if (Symbol.dispose) DeviceKeyAlgorithm.prototype[Symbol.dispose] = DeviceKeyAlgorithm.prototype.free; - -/** - * The basic key algorithm names in the specification. - * @enum {0 | 1 | 3} - */ -export const DeviceKeyAlgorithmName = Object.freeze({ - /** - * The Ed25519 signature algorithm. - */ - Ed25519: 0, "0": "Ed25519", - /** - * The Curve25519 ECDH algorithm. - */ - Curve25519: 1, "1": "Curve25519", - /** - * An unknown device key algorithm. - */ - Unknown: 3, "3": "Unknown", -}); - -/** - * A Matrix device key ID. - * - * A key algorithm and a device ID, combined with a ‘:’. - */ -export class DeviceKeyId { - static __wrap(ptr) { - const obj = Object.create(DeviceKeyId.prototype); - obj.__wbg_ptr = ptr; - DeviceKeyIdFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - DeviceKeyIdFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_devicekeyid_free(ptr, 0); - } - /** - * Returns key algorithm of the device key ID. - * @returns {DeviceKeyAlgorithm} - */ - get algorithm() { - const ret = wasm.devicekeyid_algorithm(this.__wbg_ptr); - return DeviceKeyAlgorithm.__wrap(ret); - } - /** - * Returns device ID of the device key ID. - * @returns {DeviceId} - */ - get deviceId() { - const ret = wasm.devicekeyid_deviceId(this.__wbg_ptr); - return DeviceId.__wrap(ret); - } - /** - * Parse/validate and create a new `DeviceKeyId`. - * @param {string} id - */ - constructor(id) { - const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.devicekeyid_new(ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - this.__wbg_ptr = ret[0]; - DeviceKeyIdFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Return the device key ID as a string. - * @returns {string} - */ - toString() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.devicekeyid_toString(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } -} -if (Symbol.dispose) DeviceKeyId.prototype[Symbol.dispose] = DeviceKeyId.prototype.free; - -/** - * An enum over the different key types a device can have. - * - * Currently devices have a curve25519 and ed25519 keypair. The keys - * transport format is a base64 encoded string, any unknown key type - * will be left as such a string. - * @enum {0 | 1 | 2} - */ -export const DeviceKeyName = Object.freeze({ - /** - * The curve25519 device key. - */ - Curve25519: 0, "0": "Curve25519", - /** - * The ed25519 device key. - */ - Ed25519: 1, "1": "Ed25519", - /** - * An unknown device key. - */ - Unknown: 2, "2": "Unknown", -}); - -/** - * Information on E2E device updates. - */ -export class DeviceLists { - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - DeviceListsFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_devicelists_free(ptr, 0); - } - /** - * List of users who have updated their device identity keys or - * who now share an encrypted room with the client since the - * previous sync - * @returns {UserId[]} - */ - get changed() { - const ret = wasm.devicelists_changed(this.__wbg_ptr); - var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 4, 4); - return v1; - } - /** - * Returns true if there are no device list updates. - * @returns {boolean} - */ - isEmpty() { - const ret = wasm.devicelists_isEmpty(this.__wbg_ptr); - return ret !== 0; - } - /** - * List of users who no longer share encrypted rooms since the - * previous sync response. - * @returns {UserId[]} - */ - get left() { - const ret = wasm.devicelists_left(this.__wbg_ptr); - var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 4, 4); - return v1; - } - /** - * Create an empty `DeviceLists`. - * - * `changed` and `left` must be an array of `UserId`. - * - * Items inside `changed` and `left` will be invalidated by this method. Be - * careful not to use the `UserId`s after this method has been called. - * @param {UserId[] | null} [changed] - * @param {UserId[] | null} [left] - */ - constructor(changed, left) { - var ptr0 = isLikeNone(changed) ? 0 : passArrayJsValueToWasm0(changed, wasm.__wbindgen_malloc); - var len0 = WASM_VECTOR_LEN; - var ptr1 = isLikeNone(left) ? 0 : passArrayJsValueToWasm0(left, wasm.__wbindgen_malloc); - var len1 = WASM_VECTOR_LEN; - const ret = wasm.devicelists_new(ptr0, len0, ptr1, len1); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - this.__wbg_ptr = ret[0]; - DeviceListsFinalization.register(this, this.__wbg_ptr, this); - return this; - } -} -if (Symbol.dispose) DeviceLists.prototype[Symbol.dispose] = DeviceLists.prototype.free; - -/** - * An unestablished ECIES session. - */ -export class Ecies { - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - EciesFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_ecies_free(ptr, 0); - } - /** - * Create a [`EstablishedEcies`] from an initial message encrypted by the - * other side. - * @param {string} initial_message - * @returns {InboundCreationResult} - */ - establish_inbound_channel(initial_message) { - const ptr0 = passStringToWasm0(initial_message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.ecies_establish_inbound_channel(this.__wbg_ptr, ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return InboundCreationResult.__wrap(ret[0]); - } - /** - * Create an [`EstablishedEcies`] session using the other side's Curve25519 - * public key and an initial plaintext. - * - * After the channel has been established, we can encrypt messages to send - * to the other side. The other side uses the initial message to - * establishes the same channel on its side. - * @param {Curve25519PublicKey} public_key - * @param {string} initial_message - * @returns {OutboundCreationResult} - */ - establish_outbound_channel(public_key, initial_message) { - _assertClass(public_key, Curve25519PublicKey); - const ptr0 = passStringToWasm0(initial_message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.ecies_establish_outbound_channel(this.__wbg_ptr, public_key.__wbg_ptr, ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return OutboundCreationResult.__wrap(ret[0]); - } - /** - * Create a new, random, unestablished ECIES session. - * - * This method will use the - * [`MATRIX_QR_CODE_LOGIN`](https://github.com/matrix-org/matrix-spec-proposals/pull/4108) - * info for domain separation when creating the session. - */ - constructor() { - const ret = wasm.ecies_new(); - this.__wbg_ptr = ret; - EciesFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Get our [`Curve25519PublicKey`]. - * - * This public key needs to be sent to the other side to be able to - * establish an ECIES channel. - * @returns {Curve25519PublicKey} - */ - public_key() { - const ret = wasm.ecies_public_key(this.__wbg_ptr); - return Curve25519PublicKey.__wrap(ret); - } -} -if (Symbol.dispose) Ecies.prototype[Symbol.dispose] = Ecies.prototype.free; - -/** - * An Ed25519 public key, used to verify digital signatures. - */ -export class Ed25519PublicKey { - static __wrap(ptr) { - const obj = Object.create(Ed25519PublicKey.prototype); - obj.__wbg_ptr = ptr; - Ed25519PublicKeyFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - Ed25519PublicKeyFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_ed25519publickey_free(ptr, 0); - } - /** - * The number of bytes an Ed25519 public key has. - * @returns {number} - */ - get length() { - const ret = wasm.ed25519publickey_length(this.__wbg_ptr); - return ret >>> 0; - } - /** - * Serialize an Ed25519 public key to an unpadded base64 - * representation. - * @returns {string} - */ - toBase64() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.ed25519publickey_toBase64(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } -} -if (Symbol.dispose) Ed25519PublicKey.prototype[Symbol.dispose] = Ed25519PublicKey.prototype.free; - -/** - * An Ed25519 digital signature, can be used to verify the - * authenticity of a message. - */ -export class Ed25519Signature { - static __wrap(ptr) { - const obj = Object.create(Ed25519Signature.prototype); - obj.__wbg_ptr = ptr; - Ed25519SignatureFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - Ed25519SignatureFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_ed25519signature_free(ptr, 0); - } - /** - * Try to create an Ed25519 signature from an unpadded base64 - * representation. - * @param {string} signature - */ - constructor(signature) { - const ptr0 = passStringToWasm0(signature, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.ed25519signature_new(ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - this.__wbg_ptr = ret[0]; - Ed25519SignatureFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Serialize a Ed25519 signature to an unpadded base64 - * representation. - * @returns {string} - */ - toBase64() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.ed25519signature_toBase64(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } -} -if (Symbol.dispose) Ed25519Signature.prototype[Symbol.dispose] = Ed25519Signature.prototype.free; - -/** - * An emoji that is used for interactive verification using a short - * auth string. - * - * This will contain a single emoji and description from the list of - * emojis from [the specification]. - * - * [the specification]: https://spec.matrix.org/unstable/client-server-api/#sas-method-emoji - */ -export class Emoji { - static __wrap(ptr) { - const obj = Object.create(Emoji.prototype); - obj.__wbg_ptr = ptr; - EmojiFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - EmojiFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_emoji_free(ptr, 0); - } - /** - * The description of the emoji, for example ‘Dog’. - * @returns {string} - */ - get description() { - const ret = wasm.emoji_description(this.__wbg_ptr); - return ret; - } - /** - * The emoji symbol that represents a part of the short auth - * string, for example: 🐶 - * @returns {string} - */ - get symbol() { - const ret = wasm.emoji_symbol(this.__wbg_ptr); - return ret; - } -} -if (Symbol.dispose) Emoji.prototype[Symbol.dispose] = Emoji.prototype.free; - -/** - * An encrypted attachment, usually created from `Attachment.encrypt`. - */ -export class EncryptedAttachment { - static __wrap(ptr) { - const obj = Object.create(EncryptedAttachment.prototype); - obj.__wbg_ptr = ptr; - EncryptedAttachmentFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - EncryptedAttachmentFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_encryptedattachment_free(ptr, 0); - } - /** - * The actual encrypted data. - * - * **Warning**: It returns a **copy** of the entire encrypted - * data; be nice with your memory. - * @returns {Uint8Array} - */ - get encryptedData() { - const ret = wasm.encryptedattachment_encryptedData(this.__wbg_ptr); - var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - return v1; - } - /** - * Check whether the media encryption info has been consumed by - * `Attachment.decrypt` already. - * @returns {boolean} - */ - get hasMediaEncryptionInfoBeenConsumed() { - const ret = wasm.encryptedattachment_hasMediaEncryptionInfoBeenConsumed(this.__wbg_ptr); - return ret !== 0; - } - /** - * Return the media encryption info as a JSON-encoded object. The - * structure is fully valid. - * - * If the media encryption info have been consumed already, it - * will return `null`. - * @returns {string | undefined} - */ - get mediaEncryptionInfo() { - const ret = wasm.encryptedattachment_mediaEncryptionInfo(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * Create a new encrypted attachment manually. - * - * It needs encrypted data, stored in an `Uint8Array`, and a - * [media encryption - * information](https://docs.rs/matrix-sdk-crypto/latest/matrix_sdk_crypto/struct.MediaEncryptionInfo.html), - * as a JSON-encoded object. - * - * The media encryption information aren't stored as a string: - * they are parsed, validated and fully deserialized. - * - * See [the specification to learn - * more](https://spec.matrix.org/unstable/client-server-api/#extensions-to-mroommessage-msgtypes). - * @param {Uint8Array} encrypted_data - * @param {string} media_encryption_info - */ - constructor(encrypted_data, media_encryption_info) { - const ptr0 = passArray8ToWasm0(encrypted_data, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(media_encryption_info, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ret = wasm.encryptedattachment_new(ptr0, len0, ptr1, len1); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - this.__wbg_ptr = ret[0]; - EncryptedAttachmentFinalization.register(this, this.__wbg_ptr, this); - return this; - } -} -if (Symbol.dispose) EncryptedAttachment.prototype[Symbol.dispose] = EncryptedAttachment.prototype.free; - -/** - * An encryption algorithm to be used to encrypt messages sent to a - * room. - * @enum {0 | 1 | 2} - */ -export const EncryptionAlgorithm = Object.freeze({ - /** - * Olm version 1 using Curve25519, AES-256, and SHA-256. - */ - OlmV1Curve25519AesSha2: 0, "0": "OlmV1Curve25519AesSha2", - /** - * Megolm version 1 using AES-256 and SHA-256. - */ - MegolmV1AesSha2: 1, "1": "MegolmV1AesSha2", - /** - * Unsupported algorithm. - * - * Applications should ignore this value if it is received, and should - * never set it. - */ - Unknown: 2, "2": "Unknown", -}); - -/** - * Struct containing information on how a room event was decrypted. - */ -export class EncryptionInfo { - static __wrap(ptr) { - const obj = Object.create(EncryptionInfo.prototype); - obj.__wbg_ptr = ptr; - EncryptionInfoFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - EncryptionInfoFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_encryptioninfo_free(ptr, 0); - } - /** - * The verification state of the device that sent us the event. - * Note this is the state of the device at the time of - * decryption. It may change in the future if a device gets - * verified or deleted. - * - * # Arguments - * - * * `strict` - whether to enable "strict mode" verification. In non-strict - * mode, unverified users are given no shield, and keys that have been - * forwarded or restored from an insecure backup are given a grey shield - * (both get a red shield in strict mode). - * @param {boolean} strict - * @returns {ShieldState} - */ - shieldState(strict) { - const ret = wasm.encryptioninfo_shieldState(this.__wbg_ptr, strict); - return ShieldState.__wrap(ret); - } - /** - * The device ID of the user who sent us the keys with which we decrypted - * this event as part of an MSC4268 key bundle, if present. Only applicable - * for room events. - * @returns {DeviceId | undefined} - */ - get forwarderDevice() { - const ret = wasm.__wbg_get_encryptioninfo_forwarderDevice(this.__wbg_ptr); - return ret === 0 ? undefined : DeviceId.__wrap(ret); - } - /** - * The ID of the user who sent us the keys with which we decrypted this - * event as part of an MSC4268 key bundle, if present. Only applicable for - * room events. - * @returns {UserId | undefined} - */ - get forwarder() { - const ret = wasm.__wbg_get_encryptioninfo_forwarder(this.__wbg_ptr); - return ret === 0 ? undefined : UserId.__wrap(ret); - } - /** - * The signing Ed25519 key that created the megolm key that - * was used to decrypt this session. - * @returns {string | undefined} - */ - get senderClaimedEd25519Key() { - const ret = wasm.__wbg_get_encryptioninfo_senderClaimedEd25519Key(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * The base64-encoded public Curve25519 key of the device that created the - * megolm decryption key originally. - * @returns {string} - */ - get senderCurve25519Key() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_encryptioninfo_senderCurve25519Key(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The device ID of the device that sent us the event. - * - * Note this is untrusted data unless {@link shieldState} shows that the - * sender is verified. - * @returns {DeviceId | undefined} - */ - get senderDevice() { - const ret = wasm.__wbg_get_encryptioninfo_senderDevice(this.__wbg_ptr); - return ret === 0 ? undefined : DeviceId.__wrap(ret); - } - /** - * The user ID of the sender of the event. - * - * Note this is untrusted data unless {@link shieldState} shows that the - * sender is verified. - * @returns {UserId} - */ - get sender() { - const ret = wasm.__wbg_get_encryptioninfo_sender(this.__wbg_ptr); - return UserId.__wrap(ret); - } - /** - * The device ID of the user who sent us the keys with which we decrypted - * this event as part of an MSC4268 key bundle, if present. Only applicable - * for room events. - * @param {DeviceId | null} [arg0] - */ - set forwarderDevice(arg0) { - let ptr0 = 0; - if (!isLikeNone(arg0)) { - _assertClass(arg0, DeviceId); - ptr0 = arg0.__destroy_into_raw(); - } - wasm.__wbg_set_encryptioninfo_forwarderDevice(this.__wbg_ptr, ptr0); - } - /** - * The ID of the user who sent us the keys with which we decrypted this - * event as part of an MSC4268 key bundle, if present. Only applicable for - * room events. - * @param {UserId | null} [arg0] - */ - set forwarder(arg0) { - let ptr0 = 0; - if (!isLikeNone(arg0)) { - _assertClass(arg0, UserId); - ptr0 = arg0.__destroy_into_raw(); - } - wasm.__wbg_set_encryptioninfo_forwarder(this.__wbg_ptr, ptr0); - } - /** - * The signing Ed25519 key that created the megolm key that - * was used to decrypt this session. - * @param {string | null} [arg0] - */ - set senderClaimedEd25519Key(arg0) { - var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_encryptioninfo_senderClaimedEd25519Key(this.__wbg_ptr, ptr0, len0); - } - /** - * The base64-encoded public Curve25519 key of the device that created the - * megolm decryption key originally. - * @param {string} arg0 - */ - set senderCurve25519Key(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_encryptioninfo_senderCurve25519Key(this.__wbg_ptr, ptr0, len0); - } - /** - * The device ID of the device that sent us the event. - * - * Note this is untrusted data unless {@link shieldState} shows that the - * sender is verified. - * @param {DeviceId | null} [arg0] - */ - set senderDevice(arg0) { - let ptr0 = 0; - if (!isLikeNone(arg0)) { - _assertClass(arg0, DeviceId); - ptr0 = arg0.__destroy_into_raw(); - } - wasm.__wbg_set_encryptioninfo_senderDevice(this.__wbg_ptr, ptr0); - } - /** - * The user ID of the sender of the event. - * - * Note this is untrusted data unless {@link shieldState} shows that the - * sender is verified. - * @param {UserId} arg0 - */ - set sender(arg0) { - _assertClass(arg0, UserId); - var ptr0 = arg0.__destroy_into_raw(); - wasm.__wbg_set_encryptioninfo_sender(this.__wbg_ptr, ptr0); - } -} -if (Symbol.dispose) EncryptionInfo.prototype[Symbol.dispose] = EncryptionInfo.prototype.free; - -/** - * Settings for an encrypted room. - * - * This determines the algorithm and rotation periods of a group - * session. - */ -export class EncryptionSettings { - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - EncryptionSettingsFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_encryptionsettings_free(ptr, 0); - } - /** - * Create a new `EncryptionSettings` with default values. - */ - constructor() { - const ret = wasm.encryptionsettings_new(); - this.__wbg_ptr = ret; - EncryptionSettingsFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * The encryption algorithm that should be used in the room. - * @returns {EncryptionAlgorithm} - */ - get algorithm() { - const ret = wasm.__wbg_get_encryptionsettings_algorithm(this.__wbg_ptr); - return ret; - } - /** - * Whether state event encryption is enabled. - * @returns {boolean} - */ - get encryptStateEvents() { - const ret = wasm.__wbg_get_encryptionsettings_encryptStateEvents(this.__wbg_ptr); - return ret !== 0; - } - /** - * The history visibility of the room when the session was - * created. - * @returns {HistoryVisibility} - */ - get historyVisibility() { - const ret = wasm.__wbg_get_encryptionsettings_historyVisibility(this.__wbg_ptr); - return ret; - } - /** - * How many messages should be sent before changing the session. - * @returns {bigint} - */ - get rotationPeriodMessages() { - const ret = wasm.__wbg_get_encryptionsettings_rotationPeriodMessages(this.__wbg_ptr); - return BigInt.asUintN(64, ret); - } - /** - * How long the session should be used before changing it, - * expressed in microseconds. - * @returns {bigint} - */ - get rotationPeriod() { - const ret = wasm.__wbg_get_encryptionsettings_rotationPeriod(this.__wbg_ptr); - return BigInt.asUintN(64, ret); - } - /** - * Should untrusted devices receive the room key, or should they be - * excluded from the conversation. - * @returns {CollectStrategy} - */ - get sharingStrategy() { - const ret = wasm.__wbg_get_encryptionsettings_sharingStrategy(this.__wbg_ptr); - return CollectStrategy.__wrap(ret); - } - /** - * The encryption algorithm that should be used in the room. - * @param {EncryptionAlgorithm} arg0 - */ - set algorithm(arg0) { - wasm.__wbg_set_encryptionsettings_algorithm(this.__wbg_ptr, arg0); - } - /** - * Whether state event encryption is enabled. - * @param {boolean} arg0 - */ - set encryptStateEvents(arg0) { - wasm.__wbg_set_encryptionsettings_encryptStateEvents(this.__wbg_ptr, arg0); - } - /** - * The history visibility of the room when the session was - * created. - * @param {HistoryVisibility} arg0 - */ - set historyVisibility(arg0) { - wasm.__wbg_set_encryptionsettings_historyVisibility(this.__wbg_ptr, arg0); - } - /** - * How many messages should be sent before changing the session. - * @param {bigint} arg0 - */ - set rotationPeriodMessages(arg0) { - wasm.__wbg_set_encryptionsettings_rotationPeriodMessages(this.__wbg_ptr, arg0); - } - /** - * How long the session should be used before changing it, - * expressed in microseconds. - * @param {bigint} arg0 - */ - set rotationPeriod(arg0) { - wasm.__wbg_set_encryptionsettings_rotationPeriod(this.__wbg_ptr, arg0); - } - /** - * Should untrusted devices receive the room key, or should they be - * excluded from the conversation. - * @param {CollectStrategy} arg0 - */ - set sharingStrategy(arg0) { - _assertClass(arg0, CollectStrategy); - var ptr0 = arg0.__destroy_into_raw(); - wasm.__wbg_set_encryptionsettings_sharingStrategy(this.__wbg_ptr, ptr0); - } -} -if (Symbol.dispose) EncryptionSettings.prototype[Symbol.dispose] = EncryptionSettings.prototype.free; - -/** - * An established ECIES session. - * - * This session can be used to encrypt and decrypt messages between the two - * sides of the channel. - */ -export class EstablishedEcies { - static __wrap(ptr) { - const obj = Object.create(EstablishedEcies.prototype); - obj.__wbg_ptr = ptr; - EstablishedEciesFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - EstablishedEciesFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_establishedecies_free(ptr, 0); - } - /** - * Get the [`CheckCode`] which uniquely identifies this - * [`EstablishedEcies`] session. - * - * This check code can be used to verify and confirm that both sides of the - * session are indeed using the same shared secret. - * @returns {CheckCode} - */ - check_code() { - const ret = wasm.establishedecies_check_code(this.__wbg_ptr); - return CheckCode.__wrap(ret); - } - /** - * Decrypt the given message using this [`EstablishedEcies`] session. - * @param {string} message - * @returns {string} - */ - decrypt(message) { - let deferred3_0; - let deferred3_1; - try { - const ptr0 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.establishedecies_decrypt(this.__wbg_ptr, ptr0, len0); - var ptr2 = ret[0]; - var len2 = ret[1]; - if (ret[3]) { - ptr2 = 0; len2 = 0; - throw takeFromExternrefTable0(ret[2]); - } - deferred3_0 = ptr2; - deferred3_1 = len2; - return getStringFromWasm0(ptr2, len2); - } finally { - wasm.__wbindgen_free(deferred3_0, deferred3_1, 1); - } - } - /** - * Encrypt the given plaintext using this [`EstablishedEcies`] session. - * @param {string} message - * @returns {string} - */ - encrypt(message) { - let deferred2_0; - let deferred2_1; - try { - const ptr0 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.establishedecies_encrypt(this.__wbg_ptr, ptr0, len0); - deferred2_0 = ret[0]; - deferred2_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); - } - } - /** - * Get our [`Curve25519PublicKey`]. - * - * This public key needs to be sent to the other side so that it can - * complete the ECIES channel establishment. - * @returns {Curve25519PublicKey} - */ - public_key() { - const ret = wasm.establishedecies_public_key(this.__wbg_ptr); - return Curve25519PublicKey.__wrap(ret); - } -} -if (Symbol.dispose) EstablishedEcies.prototype[Symbol.dispose] = EstablishedEcies.prototype.free; - -/** - * A Matrix [event ID]. - * - * An `EventId` is generated randomly or converted from a string - * slice, and can be converted back into a string as needed. - * - * [event ID]: https://spec.matrix.org/v1.2/appendices/#room-ids-and-event-ids - */ -export class EventId { - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - EventIdFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_eventid_free(ptr, 0); - } - /** - * Returns the event's localpart. - * @returns {string} - */ - get localpart() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.eventid_localpart(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Parse/validate and create a new `EventId`. - * @param {string} id - */ - constructor(id) { - const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.eventid_new(ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - this.__wbg_ptr = ret[0]; - EventIdFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Returns the server name of the event ID. - * @returns {ServerName | undefined} - */ - get serverName() { - const ret = wasm.eventid_serverName(this.__wbg_ptr); - return ret === 0 ? undefined : ServerName.__wrap(ret); - } - /** - * Return the event ID as a string. - * @returns {string} - */ - toString() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.eventid_toString(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } -} -if (Symbol.dispose) EventId.prototype[Symbol.dispose] = EventId.prototype.free; - -/** - * Who can see a room's history. - * @enum {0 | 1 | 2 | 3} - */ -export const HistoryVisibility = Object.freeze({ - /** - * Previous events are accessible to newly joined members from - * the point they were invited onwards. - * - * Events stop being accessible when the member's state changes - * to something other than *invite* or *join*. - */ - Invited: 0, "0": "Invited", - /** - * Previous events are accessible to newly joined members from - * the point they joined the room onwards. - * - * Events stop being accessible when the member's state changes - * to something other than *join*. - */ - Joined: 1, "1": "Joined", - /** - * Previous events are always accessible to newly joined members. - * - * All events in the room are accessible, even those sent when - * the member was not a part of the room. - */ - Shared: 2, "2": "Shared", - /** - * All events while this is the `HistoryVisibility` value may be - * shared by any participating homeserver with anyone, regardless - * of whether they have ever joined the room. - */ - WorldReadable: 3, "3": "WorldReadable", -}); - -/** - * Struct holding the two public identity keys of an account. - */ -export class IdentityKeys { - static __wrap(ptr) { - const obj = Object.create(IdentityKeys.prototype); - obj.__wbg_ptr = ptr; - IdentityKeysFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - IdentityKeysFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_identitykeys_free(ptr, 0); - } - /** - * The Curve25519 public key, used for establish shared secrets. - * @returns {Curve25519PublicKey} - */ - get curve25519() { - const ret = wasm.__wbg_get_identitykeys_curve25519(this.__wbg_ptr); - return Curve25519PublicKey.__wrap(ret); - } - /** - * The Ed25519 public key, used for signing. - * @returns {Ed25519PublicKey} - */ - get ed25519() { - const ret = wasm.__wbg_get_identitykeys_ed25519(this.__wbg_ptr); - return Ed25519PublicKey.__wrap(ret); - } - /** - * The Curve25519 public key, used for establish shared secrets. - * @param {Curve25519PublicKey} arg0 - */ - set curve25519(arg0) { - _assertClass(arg0, Curve25519PublicKey); - var ptr0 = arg0.__destroy_into_raw(); - wasm.__wbg_set_identitykeys_curve25519(this.__wbg_ptr, ptr0); - } - /** - * The Ed25519 public key, used for signing. - * @param {Ed25519PublicKey} arg0 - */ - set ed25519(arg0) { - _assertClass(arg0, Ed25519PublicKey); - var ptr0 = arg0.__destroy_into_raw(); - wasm.__wbg_set_identitykeys_ed25519(this.__wbg_ptr, ptr0); - } -} -if (Symbol.dispose) IdentityKeys.prototype[Symbol.dispose] = IdentityKeys.prototype.free; - -/** - * The result of an inbound ECIES channel establishment. - */ -export class InboundCreationResult { - static __wrap(ptr) { - const obj = Object.create(InboundCreationResult.prototype); - obj.__wbg_ptr = ptr; - InboundCreationResultFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - InboundCreationResultFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_inboundcreationresult_free(ptr, 0); - } - /** - * The established ECIES channel. - * @returns {EstablishedEcies} - */ - get channel() { - const ret = wasm.__wbg_get_inboundcreationresult_channel(this.__wbg_ptr); - return EstablishedEcies.__wrap(ret); - } - /** - * The plaintext of the initial message. - * @returns {string} - */ - get message() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_inboundcreationresult_message(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The established ECIES channel. - * @param {EstablishedEcies} arg0 - */ - set channel(arg0) { - _assertClass(arg0, EstablishedEcies); - var ptr0 = arg0.__destroy_into_raw(); - wasm.__wbg_set_inboundcreationresult_channel(this.__wbg_ptr, ptr0); - } - /** - * The plaintext of the initial message. - * @param {string} arg0 - */ - set message(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_inboundcreationresult_message(this.__wbg_ptr, ptr0, len0); - } -} -if (Symbol.dispose) InboundCreationResult.prototype[Symbol.dispose] = InboundCreationResult.prototype.free; - -/** - * Inbound group session. - * - * Inbound group sessions are used to exchange room messages between a group of - * participants. Inbound group sessions are used to decrypt the room messages. - */ -export class InboundGroupSession { - static __wrap(ptr) { - const obj = Object.create(InboundGroupSession.prototype); - obj.__wbg_ptr = ptr; - InboundGroupSessionFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - InboundGroupSessionFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_inboundgroupsession_free(ptr, 0); - } - /** - * Has the session been imported from a file or server-side backup? As - * opposed to being directly received as an `m.room_key` event. - * @returns {boolean} - */ - hasBeenImported() { - const ret = wasm.inboundgroupsession_hasBeenImported(this.__wbg_ptr); - return ret !== 0; - } - /** - * The room where this session is used in. - * @returns {RoomId} - */ - get roomId() { - const ret = wasm.inboundgroupsession_roomId(this.__wbg_ptr); - return RoomId.__wrap(ret); - } - /** - * The Curve25519 key of the sender of this session, as a - * [Curve25519PublicKey]. - * @returns {Curve25519PublicKey} - */ - get senderKey() { - const ret = wasm.inboundgroupsession_senderKey(this.__wbg_ptr); - return Curve25519PublicKey.__wrap(ret); - } - /** - * Returns the unique identifier for this session. - * @returns {string} - */ - get sessionId() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.inboundgroupsession_sessionId(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } -} -if (Symbol.dispose) InboundGroupSession.prototype[Symbol.dispose] = InboundGroupSession.prototype.free; - -/** - * Represents an invalid to-device event that was ignored (because it is - * missing some mandatory fields, for example). - */ -export class InvalidToDeviceEvent { - static __wrap(ptr) { - const obj = Object.create(InvalidToDeviceEvent.prototype); - obj.__wbg_ptr = ptr; - InvalidToDeviceEventFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - InvalidToDeviceEventFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_invalidtodeviceevent_free(ptr, 0); - } - /** - * The original message as received from sync, encoded as JSON. - * @returns {string} - */ - get rawEvent() { - const ret = wasm.__wbg_get_invalidtodeviceevent_rawEvent(this.__wbg_ptr); - return ret; - } - /** - * The type of processed to-device event. Always {@link - * ProcessedToDeviceEventType.Invalid} for this type. - * @returns {ProcessedToDeviceEventType} - */ - get type() { - const ret = wasm.invalidtodeviceevent_type(this.__wbg_ptr); - return ret; - } -} -if (Symbol.dispose) InvalidToDeviceEvent.prototype[Symbol.dispose] = InvalidToDeviceEvent.prototype.free; - -/** - * A request that will back up a batch of room keys to the server - * ([specification]). - * - * [specification]: https://spec.matrix.org/unstable/client-server-api/#put_matrixclientv3room_keyskeys - */ -export class KeysBackupRequest { - static __wrap(ptr) { - const obj = Object.create(KeysBackupRequest.prototype); - obj.__wbg_ptr = ptr; - KeysBackupRequestFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - KeysBackupRequestFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_keysbackuprequest_free(ptr, 0); - } - /** - * A JSON-encoded object containing the rest of the payload: `rooms`. - * - * It represents the body of the HTTP request. - * @returns {string} - */ - get body() { - const ret = wasm.__wbg_get_keysbackuprequest_body(this.__wbg_ptr); - return ret; - } - /** - * The request ID. - * @returns {string} - */ - get id() { - const ret = wasm.__wbg_get_keysbackuprequest_id(this.__wbg_ptr); - return ret; - } - /** - * The backup version that these room keys should be part of. - * @returns {string} - */ - get version() { - const ret = wasm.__wbg_get_keysbackuprequest_version(this.__wbg_ptr); - return ret; - } - /** - * Create a new `KeysBackupRequest`. - * @param {string} id - * @param {string} body - * @param {string} version - */ - constructor(id, body, version) { - const ret = wasm.keysbackuprequest_new(id, body, version); - this.__wbg_ptr = ret; - KeysBackupRequestFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Get its request type. - * @returns {RequestType} - */ - get type() { - const ret = wasm.keysbackuprequest_type(this.__wbg_ptr); - return ret; - } -} -if (Symbol.dispose) KeysBackupRequest.prototype[Symbol.dispose] = KeysBackupRequest.prototype.free; - -/** - * Data for a request to the `/keys/claim` API endpoint - * ([specification]). - * - * Claims one-time keys that can be used to establish 1-to-1 E2EE - * sessions. - * - * [specification]: https://spec.matrix.org/unstable/client-server-api/#post_matrixclientv3keysclaim - */ -export class KeysClaimRequest { - static __wrap(ptr) { - const obj = Object.create(KeysClaimRequest.prototype); - obj.__wbg_ptr = ptr; - KeysClaimRequestFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - KeysClaimRequestFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_keysclaimrequest_free(ptr, 0); - } - /** - * A JSON-encoded object containing the rest of the payload: `timeout`, - * `one_time_keys`. - * - * It represents the body of the HTTP request. - * @returns {string} - */ - get body() { - const ret = wasm.__wbg_get_keysclaimrequest_body(this.__wbg_ptr); - return ret; - } - /** - * The request ID. - * @returns {string} - */ - get id() { - const ret = wasm.__wbg_get_keysclaimrequest_id(this.__wbg_ptr); - return ret; - } - /** - * Create a new `KeysClaimRequest`. - * @param {string} id - * @param {string} body - */ - constructor(id, body) { - const ret = wasm.keysclaimrequest_new(id, body); - this.__wbg_ptr = ret; - KeysClaimRequestFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Get its request type. - * @returns {RequestType} - */ - get type() { - const ret = wasm.keysclaimrequest_type(this.__wbg_ptr); - return ret; - } -} -if (Symbol.dispose) KeysClaimRequest.prototype[Symbol.dispose] = KeysClaimRequest.prototype.free; - -/** - * Data for a request to the `/keys/query` API endpoint - * ([specification]). - * - * Returns the current devices and identity keys for the given users. - * - * [specification]: https://spec.matrix.org/unstable/client-server-api/#post_matrixclientv3keysquery - */ -export class KeysQueryRequest { - static __wrap(ptr) { - const obj = Object.create(KeysQueryRequest.prototype); - obj.__wbg_ptr = ptr; - KeysQueryRequestFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - KeysQueryRequestFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_keysqueryrequest_free(ptr, 0); - } - /** - * A JSON-encoded object containing the rest of the payload: `timeout`, - * `device_keys`, `token`. - * - * It represents the body of the HTTP request. - * @returns {string} - */ - get body() { - const ret = wasm.__wbg_get_keysqueryrequest_body(this.__wbg_ptr); - return ret; - } - /** - * The request ID. - * @returns {string} - */ - get id() { - const ret = wasm.__wbg_get_keysqueryrequest_id(this.__wbg_ptr); - return ret; - } - /** - * Create a new `KeysQueryRequest`. - * @param {string} id - * @param {string} body - */ - constructor(id, body) { - const ret = wasm.keysqueryrequest_new(id, body); - this.__wbg_ptr = ret; - KeysQueryRequestFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Get its request type. - * @returns {RequestType} - */ - get type() { - const ret = wasm.keysqueryrequest_type(this.__wbg_ptr); - return ret; - } -} -if (Symbol.dispose) KeysQueryRequest.prototype[Symbol.dispose] = KeysQueryRequest.prototype.free; - -/** - * Data for a request to the `/keys/upload` API endpoint - * ([specification]). - * - * Publishes end-to-end encryption keys for the device. - * - * [specification]: https://spec.matrix.org/unstable/client-server-api/#post_matrixclientv3keysupload - */ -export class KeysUploadRequest { - static __wrap(ptr) { - const obj = Object.create(KeysUploadRequest.prototype); - obj.__wbg_ptr = ptr; - KeysUploadRequestFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - KeysUploadRequestFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_keysuploadrequest_free(ptr, 0); - } - /** - * A JSON-encoded object containing the rest of the payload: `device_keys`, - * `one_time_keys`, `fallback_keys`. - * - * It represents the body of the HTTP request. - * @returns {string} - */ - get body() { - const ret = wasm.__wbg_get_keysuploadrequest_body(this.__wbg_ptr); - return ret; - } - /** - * The request ID. - * @returns {string} - */ - get id() { - const ret = wasm.__wbg_get_keysuploadrequest_id(this.__wbg_ptr); - return ret; - } - /** - * Create a new `KeysUploadRequest`. - * @param {string} id - * @param {string} body - */ - constructor(id, body) { - const ret = wasm.keysuploadrequest_new(id, body); - this.__wbg_ptr = ret; - KeysUploadRequestFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Get its request type. - * @returns {RequestType} - */ - get type() { - const ret = wasm.keysuploadrequest_type(this.__wbg_ptr); - return ret; - } -} -if (Symbol.dispose) KeysUploadRequest.prototype[Symbol.dispose] = KeysUploadRequest.prototype.free; - -/** - * The local trust state of a device. - * @enum {0 | 1 | 2 | 3} - */ -export const LocalTrust = Object.freeze({ - /** - * The device has been verified and is trusted. - */ - Verified: 0, "0": "Verified", - /** - * The device been blacklisted from communicating. - */ - BlackListed: 1, "1": "BlackListed", - /** - * The trust state of the device is being ignored. - */ - Ignored: 2, "2": "Ignored", - /** - * The trust state is unset. - */ - Unset: 3, "3": "Unset", -}); - -/** - * Logger level. - * @enum {0 | 1 | 2 | 3 | 4} - */ -export const LoggerLevel = Object.freeze({ - /** - * `TRACE` level. - * - * Designate very low priority, often extremely verbose, - * information. - */ - Trace: 0, "0": "Trace", - /** - * `DEBUG` level. - * - * Designate lower priority information. - */ - Debug: 1, "1": "Debug", - /** - * `INFO` level. - * - * Designate useful information. - */ - Info: 2, "2": "Info", - /** - * `WARN` level. - * - * Designate hazardous situations. - */ - Warn: 3, "3": "Warn", - /** - * `ERROR` level. - * - * Designate very serious errors. - */ - Error: 4, "4": "Error", -}); - -/** - * Represents a signature that is either valid _or_ that could not be - * decoded. - */ -export class MaybeSignature { - static __wrap(ptr) { - const obj = Object.create(MaybeSignature.prototype); - obj.__wbg_ptr = ptr; - MaybeSignatureFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - MaybeSignatureFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_maybesignature_free(ptr, 0); - } - /** - * The base64 encoded string that is claimed to contain a - * signature but could not be decoded, if any. - * @returns {string | undefined} - */ - get invalidSignatureSource() { - const ret = wasm.maybesignature_invalidSignatureSource(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * Check whether the signature could not be successfully decoded. - * @returns {boolean} - */ - isInvalid() { - const ret = wasm.maybesignature_isInvalid(this.__wbg_ptr); - return ret !== 0; - } - /** - * Check whether the signature has been successfully decoded. - * @returns {boolean} - */ - isValid() { - const ret = wasm.maybesignature_isValid(this.__wbg_ptr); - return ret !== 0; - } - /** - * The signature, if successfully decoded. - * @returns {Signature | undefined} - */ - get signature() { - const ret = wasm.maybesignature_signature(this.__wbg_ptr); - return ret === 0 ? undefined : Signature.__wrap(ret); - } -} -if (Symbol.dispose) MaybeSignature.prototype[Symbol.dispose] = MaybeSignature.prototype.free; - -/** - * Js Decryption error with code. - */ -export class MegolmDecryptionError { - static __wrap(ptr) { - const obj = Object.create(MegolmDecryptionError.prototype); - obj.__wbg_ptr = ptr; - MegolmDecryptionErrorFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - MegolmDecryptionErrorFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_megolmdecryptionerror_free(ptr, 0); - } - /** - * Description code for the error. See `DecryptionErrorCode` - * @returns {DecryptionErrorCode} - */ - get code() { - const ret = wasm.__wbg_get_megolmdecryptionerror_code(this.__wbg_ptr); - return ret; - } - /** - * detailed description - * @returns {string} - */ - get description() { - const ret = wasm.__wbg_get_megolmdecryptionerror_description(this.__wbg_ptr); - return ret; - } - /** - * Textual description of the withheld code, if any. - * - * Example: "The sender has disabled encrypting to unverified devices." - * - * `undefined` if we have not received a withheld code for the megolm - * session. - * @returns {string | undefined} - */ - get maybe_withheld() { - const ret = wasm.megolmdecryptionerror_maybe_withheld(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * Creates generic error with description - * @param {string} desc - * @returns {MegolmDecryptionError} - */ - static unable_to_decrypt(desc) { - const ptr0 = passStringToWasm0(desc, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.megolmdecryptionerror_unable_to_decrypt(ptr0, len0); - return MegolmDecryptionError.__wrap(ret); - } - /** - * The withheld code, if any. - * - * Example: "m.unverified" - * - * `undefined` if we have not received a withheld code for the megolm - * session. - * @returns {string | undefined} - */ - get withheldCode() { - const ret = wasm.megolmdecryptionerror_withheldCode(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } -} -if (Symbol.dispose) MegolmDecryptionError.prototype[Symbol.dispose] = MegolmDecryptionError.prototype.free; - -/** - * The public part of the backup key. - */ -export class MegolmV1BackupKey { - static __wrap(ptr) { - const obj = Object.create(MegolmV1BackupKey.prototype); - obj.__wbg_ptr = ptr; - MegolmV1BackupKeyFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - MegolmV1BackupKeyFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_megolmv1backupkey_free(ptr, 0); - } - /** - * Get the full name of the backup algorithm this backup key supports. - * @returns {string} - */ - get algorithm() { - const ret = wasm.megolmv1backupkey_algorithm(this.__wbg_ptr); - return ret; - } - /** - * The actual base64 encoded public key. - * @returns {string} - */ - get publicKeyBase64() { - const ret = wasm.megolmv1backupkey_publicKeyBase64(this.__wbg_ptr); - return ret; - } -} -if (Symbol.dispose) MegolmV1BackupKey.prototype[Symbol.dispose] = MegolmV1BackupKey.prototype.free; - -/** - * Migration routines - * - * The public methods are exposed as static methods on this class, for - * namespacing and to enable easier mocking in unit tests. - */ -export class Migration { - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - MigrationFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_migration_free(ptr, 0); - } - /** - * Import the base dataset from a libolm-based setup to a vodozemac-based - * setup stored in IndexedDB. - * - * Populates the user credentials, Olm account, backup data, etc. This is - * the first step in the migration process. Once this base data is - * imported, further data can be imported with {@link - * migrateOlmSessions}, {@link migrateMegolmSessions}, and TODO room - * settings. - * - * # Arguments - * - * * `data` - The data to be migrated - * * `pickle_key` - The libolm pickle key that was used to pickle the olm - * account objects. - * * `store_handle` - A connection to the CryptoStore which will be used to - * store the vodozemac data. - * * `logger` - An optional logger instance to use for writing log messages - * during the migration operation. An instance of `JsLogger`. - * @param {BaseMigrationData} data - * @param {Uint8Array} pickle_key - * @param {StoreHandle} store_handle - * @param {JsLogger} [logger] - * @returns {Promise} - */ - static migrateBaseData(data, pickle_key, store_handle, logger) { - _assertClass(data, BaseMigrationData); - _assertClass(store_handle, StoreHandle); - const ret = wasm.migration_migrateBaseData(data.__wbg_ptr, pickle_key, store_handle.__wbg_ptr, isLikeNone(logger) ? 0 : addToExternrefTable0(logger)); - return ret; - } - /** - * Migrate Megolm sessions of a libolm-based setup to a vodozemac-based - * setup stored in an indexedDB crypto store. - * - * Before this method can be used, {@link migrateBaseData} must be used to - * import the base data into the crypto store. - * - * This method should be called a number of times, with separate batches of - * `sessions`. If a progress display is given, it can be updated after - * each batch is successfully imported. - * - * # Arguments - * - * * `sessions` - An `Array` of {@link PickledInboundGroupSession}s to - * import. Items inside `sessions` will be invalidated by this method. - * * `pickle_key` - The libolm pickle key that was used to pickle the - * megolm session objects. - * * `store_handle` - A connection to the CryptoStore which will be used to - * store the vodozemac data. - * * `logger` - An optional logger instance to use for writing log messages - * during the migration operation. An instance of `JsLogger`. - * @param {PickledInboundGroupSession[]} sessions - * @param {Uint8Array} pickle_key - * @param {StoreHandle} store_handle - * @param {JsLogger} [logger] - * @returns {Promise} - */ - static migrateMegolmSessions(sessions, pickle_key, store_handle, logger) { - const ptr0 = passArrayJsValueToWasm0(sessions, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(store_handle, StoreHandle); - const ret = wasm.migration_migrateMegolmSessions(ptr0, len0, pickle_key, store_handle.__wbg_ptr, isLikeNone(logger) ? 0 : addToExternrefTable0(logger)); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Migrate Olm sessions of a libolm-based setup to a vodozemac-based setup - * stored in an indexedDB crypto store. - * - * Before this method can be used, {@link migrateBaseData} must be used to - * import the base data into the crypto store. - * - * This method should be called a number of times, with separate batches of - * `sessions`. If a progress display is given, it can be updated after - * each batch is successfully imported. - * - * # Arguments - * - * * `sessions` - An `Array` of {@link PickledSession}s to import. Items - * inside `sessions` will be invalidated by this method. - * * `pickle_key` - The libolm pickle key that was used to pickle the olm - * session objects. - * * `store_handle` - A connection to the CryptoStore which will be used to - * store the vodozemac data. - * * `logger` - An optional logger instance to use for writing log messages - * during the migration operation. An instance of `JsLogger`. - * @param {PickledSession[]} sessions - * @param {Uint8Array} pickle_key - * @param {StoreHandle} store_handle - * @param {JsLogger} [logger] - * @returns {Promise} - */ - static migrateOlmSessions(sessions, pickle_key, store_handle, logger) { - const ptr0 = passArrayJsValueToWasm0(sessions, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(store_handle, StoreHandle); - const ret = wasm.migration_migrateOlmSessions(ptr0, len0, pickle_key, store_handle.__wbg_ptr, isLikeNone(logger) ? 0 : addToExternrefTable0(logger)); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } -} -if (Symbol.dispose) Migration.prototype[Symbol.dispose] = Migration.prototype.free; - -/** - * Intent-specific data in the case the QR code adheres to - * {@link https://github.com/matrix-org/matrix-spec-proposals/pull/4108 MSC4108} of the QR code - * data format. - */ -export class Msc4108IntentData { - static __wrap(ptr) { - const obj = Object.create(Msc4108IntentData.prototype); - obj.__wbg_ptr = ptr; - Msc4108IntentDataFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - Msc4108IntentDataFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_msc4108intentdata_free(ptr, 0); - } - /** - * Get the URL of the rendezvous server which will be used to exchange - * messages between the two devices. - * @returns {string} - */ - get rendezvousUrl() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_msc4108intentdata_rendezvousUrl(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Get the server name of the homeserver which the new device will be - * logged in to. - * - * This will be only available if the existing device has generated the QR - * code and the new device is the one scanning the QR code. - * @returns {string | undefined} - */ - get serverName() { - const ret = wasm.__wbg_get_msc4108intentdata_serverName(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * Get the URL of the rendezvous server which will be used to exchange - * messages between the two devices. - * @param {string} arg0 - */ - set rendezvousUrl(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_msc4108intentdata_rendezvousUrl(this.__wbg_ptr, ptr0, len0); - } - /** - * Get the server name of the homeserver which the new device will be - * logged in to. - * - * This will be only available if the existing device has generated the QR - * code and the new device is the one scanning the QR code. - * @param {string | null} [arg0] - */ - set serverName(arg0) { - var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_msc4108intentdata_serverName(this.__wbg_ptr, ptr0, len0); - } -} -if (Symbol.dispose) Msc4108IntentData.prototype[Symbol.dispose] = Msc4108IntentData.prototype.free; - -/** - * Intent-specific data in the case the QR code adheres to - * {@link https://github.com/matrix-org/matrix-spec-proposals/pull/4388 MSC4388} of the QR code - * data format. - */ -export class Msc4388IntentData { - static __wrap(ptr) { - const obj = Object.create(Msc4388IntentData.prototype); - obj.__wbg_ptr = ptr; - Msc4388IntentDataFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - Msc4388IntentDataFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_msc4388intentdata_free(ptr, 0); - } - /** - * The base URL of the homeserver that the device generating the QR is - * using. - * @returns {string} - */ - get baseUrl() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_msc4388intentdata_baseUrl(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The ID of the rendezvous session, can be used to exchange messages with - * the other device. - * @returns {string} - */ - get rendezvousId() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_msc4388intentdata_rendezvousId(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The base URL of the homeserver that the device generating the QR is - * using. - * @param {string} arg0 - */ - set baseUrl(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_msc4388intentdata_baseUrl(this.__wbg_ptr, ptr0, len0); - } - /** - * The ID of the rendezvous session, can be used to exchange messages with - * the other device. - * @param {string} arg0 - */ - set rendezvousId(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_msc4388intentdata_rendezvousId(this.__wbg_ptr, ptr0, len0); - } -} -if (Symbol.dispose) Msc4388IntentData.prototype[Symbol.dispose] = Msc4388IntentData.prototype.free; - -/** - * State machine implementation of the Olm/Megolm encryption protocol - * used for Matrix end to end encryption. - */ -export class OlmMachine { - static __wrap(ptr) { - const obj = Object.create(OlmMachine.prototype); - obj.__wbg_ptr = ptr; - OlmMachineFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - OlmMachineFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_olmmachine_free(ptr, 0); - } - /** - * Encrypt a batch of room keys and return a request that needs to be sent - * out to backup the room keys. - * - * Returns an optional {@link KeysBackupRequest}. - * @returns {Promise} - */ - backupRoomKeys() { - const ret = wasm.olmmachine_backupRoomKeys(this.__wbg_ptr); - return ret; - } - /** - * Create a new cross signing identity and get the upload request - * to push the new public keys to the server. - * - * Warning: This will delete any existing cross signing keys that - * might exist on the server and thus will reset the trust - * between all the devices. - * - * Uploading these keys will require user interactive auth. - * - * # Arguments - * - * * `reset`, whether the method should create a new identity or use the - * existing one during the request. If set to true, the request will - * attempt to upload a new identity. If set to false, the request will - * attempt to upload the existing identity. Since the uploading process - * requires user interactive authentication, which involves sending out - * the same request multiple times, setting this argument to false - * enables you to reuse the same request. - * - * Returns a {@link CrossSigningBootstrapRequests}. - * @param {boolean} reset - * @returns {Promise} - */ - bootstrapCrossSigning(reset) { - const ret = wasm.olmmachine_bootstrapCrossSigning(this.__wbg_ptr, reset); - return ret; - } - /** - * Assemble, and encrypt, a room key bundle for sharing encrypted history, - * as per {@link https://github.com/matrix-org/matrix-spec-proposals/pull/4268|MSC4268}. - * - * Returns `undefined` if there are no keys to share in the given room, - * otherwise an {@link EncryptedAttachment}. - * - * The data should be uploaded to the media server, and the details then - * passed to {@link shareRoomKeyBundleData}. - * - * @experimental - * @param {RoomId} room_id - * @returns {Promise} - */ - buildRoomKeyBundle(room_id) { - _assertClass(room_id, RoomId); - const ret = wasm.olmmachine_buildRoomKeyBundle(this.__wbg_ptr, room_id.__wbg_ptr); - return ret; - } - /** - * Store the fact that we are no longer waiting for a key bundle in the - * given room. - * - * The counterpart to {@link storeRoomPendingKeyBundle}. Should be called - * when, for example, we leave a room, or have successfully imported a - * bundle. - * - * @experimental - * @param {RoomId} room_id - * @returns {Promise} - */ - clearRoomPendingKeyBundle(room_id) { - _assertClass(room_id, RoomId); - const ret = wasm.olmmachine_clearRoomPendingKeyBundle(this.__wbg_ptr, room_id.__wbg_ptr); - return ret; - } - /** - * Shut down the `OlmMachine`. - * - * The `OlmMachine` cannot be used after this method has been called. - * - * All associated resources will be closed too, like IndexedDB - * connections. - */ - close() { - const ptr = this.__destroy_into_raw(); - wasm.olmmachine_close(ptr); - } - /** - * Get the status of the private cross signing keys. - * - * This can be used to check which private cross signing keys we - * have stored locally. - * @returns {Promise} - */ - crossSigningStatus() { - const ret = wasm.olmmachine_crossSigningStatus(this.__wbg_ptr); - return ret; - } - /** - * Try to decrypt a reader into a list of exported room keys. - * - * `encrypted_exported_room_keys` is the result from - * `encrypt_exported_room_keys`. `passphrase` is the passphrase that was - * used when calling `encrypt_exported_room_keys`. - * @param {string} encrypted_exported_room_keys - * @param {string} passphrase - * @returns {string} - */ - static decryptExportedRoomKeys(encrypted_exported_room_keys, passphrase) { - let deferred4_0; - let deferred4_1; - try { - const ptr0 = passStringToWasm0(encrypted_exported_room_keys, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(passphrase, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_decryptExportedRoomKeys(ptr0, len0, ptr1, len1); - var ptr3 = ret[0]; - var len3 = ret[1]; - if (ret[3]) { - ptr3 = 0; len3 = 0; - throw takeFromExternrefTable0(ret[2]); - } - deferred4_0 = ptr3; - deferred4_1 = len3; - return getStringFromWasm0(ptr3, len3); - } finally { - wasm.__wbindgen_free(deferred4_0, deferred4_1, 1); - } - } - /** - * Decrypt an event from a room timeline. - * - * # Arguments - * - * * `event`, the event that should be decrypted. - * * `room_id`, the ID of the room where the event was sent to. - * - * # Returns - * - * A `Promise` which resolves to a {@link DecryptedRoomEvent} instance, or - * rejects with a {@link MegolmDecryptionError} instance. - * @param {string} event - * @param {RoomId} room_id - * @param {DecryptionSettings} decryption_settings - * @returns {Promise} - */ - decryptRoomEvent(event, room_id, decryption_settings) { - const ptr0 = passStringToWasm0(event, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(room_id, RoomId); - _assertClass(decryption_settings, DecryptionSettings); - const ret = wasm.olmmachine_decryptRoomEvent(this.__wbg_ptr, ptr0, len0, room_id.__wbg_ptr, decryption_settings.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Manage dehydrated devices - * @returns {DehydratedDevices} - */ - dehydratedDevices() { - const ret = wasm.olmmachine_dehydratedDevices(this.__wbg_ptr); - return DehydratedDevices.__wrap(ret); - } - /** - * Delete all secrets with the given secret name from the inbox. - * - * Should be called after handling the secrets with - * `get_secrets_from_inbox`. - * - * # Arguments - * - * * `secret_name` - The name of the secret to delete. - * @param {string} secret_name - * @returns {Promise} - */ - deleteSecretsFromInbox(secret_name) { - const ptr0 = passStringToWasm0(secret_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_deleteSecretsFromInbox(this.__wbg_ptr, ptr0, len0); - return ret; - } - /** - * The time, in milliseconds since the unix epoch, at which the `Account` - * backing this `OlmMachine` was created. - * - * An `Account` is created when an `OlmMachine` is first instantiated - * against a given `Store`, at which point it creates identity keys etc. - * This method returns the timestamp, according to the local clock, at - * which that happened. - * @returns {number} - */ - get deviceCreationTimeMs() { - const ret = wasm.olmmachine_deviceCreationTimeMs(this.__wbg_ptr); - return ret; - } - /** - * The unique device ID that identifies this `OlmMachine`. - * @returns {DeviceId} - */ - get deviceId() { - const ret = wasm.olmmachine_deviceId(this.__wbg_ptr); - return DeviceId.__wrap(ret); - } - /** - * Disable and reset our backup state. - * - * This will remove any pending backup request, remove the backup key and - * reset the backup state of each room key we have. - * - * Returns `Promise`. - * @returns {Promise} - */ - disableBackup() { - const ret = wasm.olmmachine_disableBackup(this.__wbg_ptr); - return ret; - } - /** - * Get the display name of our own device. - * @returns {Promise} - */ - get displayName() { - const ret = wasm.olmmachine_displayName(this.__wbg_ptr); - return ret; - } - /** - * Activate the given backup key to be used with the given backup version. - * - * **Warning**: The caller needs to make sure that the given `BackupKey` is - * trusted, otherwise we might be encrypting room keys that a malicious - * party could decrypt. - * - * The {@link verifyBackup} method can be used to do so. - * - * Returns `Promise`. - * @param {string} public_key_base_64 - * @param {string} version - * @returns {Promise} - */ - enableBackupV1(public_key_base_64, version) { - const ptr0 = passStringToWasm0(public_key_base_64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(version, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_enableBackupV1(this.__wbg_ptr, ptr0, len0, ptr1, len1); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Encrypt the list of exported room keys using the given passphrase. - * - * `exported_room_keys` is a list of sessions that should be encrypted - * (it's generally returned by `export_room_keys`). `passphrase` is the - * passphrase that will be used to encrypt the exported room keys. And - * `rounds` is the number of rounds that should be used for the key - * derivation when the passphrase gets turned into an AES key. More rounds - * are increasingly computationnally intensive and as such help against - * brute-force attacks. Should be at least `10_000`, while values in the - * `100_000` ranges should be preferred. - * @param {string} exported_room_keys - * @param {string} passphrase - * @param {number} rounds - * @returns {string} - */ - static encryptExportedRoomKeys(exported_room_keys, passphrase, rounds) { - let deferred4_0; - let deferred4_1; - try { - const ptr0 = passStringToWasm0(exported_room_keys, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(passphrase, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_encryptExportedRoomKeys(ptr0, len0, ptr1, len1, rounds); - var ptr3 = ret[0]; - var len3 = ret[1]; - if (ret[3]) { - ptr3 = 0; len3 = 0; - throw takeFromExternrefTable0(ret[2]); - } - deferred4_0 = ptr3; - deferred4_1 = len3; - return getStringFromWasm0(ptr3, len3); - } finally { - wasm.__wbindgen_free(deferred4_0, deferred4_1, 1); - } - } - /** - * Encrypt a room message for the given room. - * - * **Note**: A room key needs to be shared with the group of users that are - * members in the given room. If this is not done this method will panic. - * - * The usual flow to encrypt an event using this state machine is as - * follows: - * - * 1. Get the one-time key claim request to establish 1:1 Olm sessions for - * the room members of the room we wish to participate in. This is done - * using the [`get_missing_sessions()`](Self::get_missing_sessions) - * method. This method call should be locked per call. - * - * 2. Share a room key with all the room members using the - * [`share_room_key()`](Self::share_room_key). This method call should - * be locked per room. - * - * 3. Encrypt the event using this method. - * - * 4. Send the encrypted event to the server. - * - * After the room key is shared steps 1 and 2 will become noops, unless - * there's some changes in the room membership or in the list of devices a - * member has. - * - * - * `room_id` is the ID of the room for which the message should - * be encrypted. `event_type` is the type of the event. `content` - * is the plaintext content of the message that should be - * encrypted. - * - * # Panics - * - * Panics if a group session for the given room wasn't shared - * beforehand. - * @param {RoomId} room_id - * @param {string} event_type - * @param {string} content - * @returns {Promise} - */ - encryptRoomEvent(room_id, event_type, content) { - _assertClass(room_id, RoomId); - const ptr0 = passStringToWasm0(event_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_encryptRoomEvent(this.__wbg_ptr, room_id.__wbg_ptr, ptr0, len0, ptr1, len1); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Encrypt a state event for the given room. - * - * This method encrypts a state event for the specified room, using the - * current group session. The event will be encrypted so that only - * authorized room members can decrypt it. - * - * **Note**: A room key must have been shared with the group of users in - * the room before calling this method. If not, this method will panic. - * - * The usual flow to encrypt a state event using this machine is identical - * to that outlined for [`OlmMachine::encrypt_room_event`]. - * - * # Arguments - * - * * `room_id` - The ID of the room for which the state event should be - * encrypted. - * * `event_type` - The type of the state event. - * * `state_key` - The state key for the event. - * * `content` - The plaintext JSON content of the event to encrypt. - * - * # Returns - * - * A `Promise` resolving to a JSON string containing the encrypted event. - * - * # Panics - * - * Panics if a group session for the given room was not previously shared. - * @param {RoomId} room_id - * @param {string} event_type - * @param {string} state_key - * @param {string} content - * @returns {Promise} - */ - encryptStateEvent(room_id, event_type, state_key, content) { - _assertClass(room_id, RoomId); - const ptr0 = passStringToWasm0(event_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(state_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_encryptStateEvent(this.__wbg_ptr, room_id.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Export all the private cross signing keys we have. - * - * The export will contain the seeds for the ed25519 keys as - * unpadded base64 encoded strings. - * - * Returns `undefined` if we don’t have any private cross signing keys; - * otherwise returns a `CrossSigningKeyExport`. - * @returns {Promise} - */ - exportCrossSigningKeys() { - const ret = wasm.olmmachine_exportCrossSigningKeys(this.__wbg_ptr); - return ret; - } - /** - * Export the keys that match the given predicate. - * - * `predicate` is a closure that will be called for every known - * `InboundGroupSession`, which represents a room key. If the closure - * returns `true`, the `InboundGroupSession` will be included in the - * export; otherwise it won't. - * - * Returns a Promise containing a Result containing a String which is a - * JSON-encoded array of ExportedRoomKey objects. - * @param {(session: InboundGroupSession) => boolean} predicate - * @returns {Promise} - */ - exportRoomKeys(predicate) { - const ret = wasm.olmmachine_exportRoomKeys(this.__wbg_ptr, predicate); - return ret; - } - /** - * Export all the secrets we have in the store into a {@link - * SecretsBundle}. - * - * This method will export all the private cross-signing keys and, if - * available, the private part of a backup key and its accompanying - * version. - * - * The method will fail if we don't have all three private cross-signing - * keys available. - * - * **Warning**: Only export this and share it with a trusted recipient, - * i.e. if an existing device is sharing this with a new device. - * @returns {Promise} - */ - exportSecretsBundle() { - const ret = wasm.olmmachine_exportSecretsBundle(this.__wbg_ptr); - return ret; - } - /** - * Get a list of all rooms where we are waiting for a key bundle. - * - * @see getPendingKeyBundleDetailsForRoom - * - * @experimental - * @returns {Promise>} - */ - getAllRoomsPendingKeyBundles() { - const ret = wasm.olmmachine_getAllRoomsPendingKeyBundles(this.__wbg_ptr); - return ret; - } - /** - * Get the backup keys we have saved in our store. - * Returns a `Promise` for {@link BackupKeys}. - * @returns {Promise} - */ - getBackupKeys() { - const ret = wasm.olmmachine_getBackupKeys(this.__wbg_ptr); - return ret; - } - /** - * Get a specific device of a user. - * - * ### Parameters - * - * * `user_id` - The unique ID of the user that the device belongs to. - * - * * `device_id` - The unique ID of the device. - * - * * `timeout_secs` - The amount of time we should wait for a `/keys/query` - * response before returning if the user's device list has been marked as - * stale. **Note**, this assumes that the requests from {@link - * OlmMachine.outgoingRequests} are being processed and sent out. - * - * If unset, we will return immediately even if the device list is stale. - * - * ### Returns - * - * If the device is known, a {@link Device}. Otherwise, `undefined`. - * @param {UserId} user_id - * @param {DeviceId} device_id - * @param {number | null} [timeout_secs] - * @returns {Promise} - */ - getDevice(user_id, device_id, timeout_secs) { - _assertClass(user_id, UserId); - _assertClass(device_id, DeviceId); - const ret = wasm.olmmachine_getDevice(this.__wbg_ptr, user_id.__wbg_ptr, device_id.__wbg_ptr, !isLikeNone(timeout_secs), isLikeNone(timeout_secs) ? 0 : timeout_secs); - return ret; - } - /** - * Get the cross signing user identity of a user. - * - * Returns a promise for an {@link OwnUserIdentity}, a - * {@link OtherUserIdentity}, or `undefined`. - * @param {UserId} user_id - * @returns {Promise} - */ - getIdentity(user_id) { - _assertClass(user_id, UserId); - const ret = wasm.olmmachine_getIdentity(this.__wbg_ptr, user_id.__wbg_ptr); - return ret; - } - /** - * Get the a key claiming request for the user/device pairs that - * we are missing Olm sessions for. - * - * Returns `null` if no key claiming request needs to be sent - * out, otherwise it returns a `KeysClaimRequest` object. - * - * Sessions need to be established between devices so group - * sessions for a room can be shared with them. - * - * This should be called every time a group session needs to be - * shared as well as between sync calls. After a sync some - * devices may request room keys without us having a valid Olm - * session with them, making it impossible to server the room key - * request, thus it’s necessary to check for missing sessions - * between sync as well. - * - * Note: Care should be taken that only one such request at a - * time is in flight, e.g. using a lock. - * - * The response of a successful key claiming requests needs to be - * passed to the `OlmMachine` with the `mark_request_as_sent`. - * - * `users` represents the list of users that we should check if - * we lack a session with one of their devices. This can be an - * empty iterator when calling this method between sync requests. - * - * Items inside `users` will be invalidated by this method. Be careful not - * to use the `UserId`s after this method has been called. - * @param {UserId[]} users - * @returns {Promise} - */ - getMissingSessions(users) { - const ptr0 = passArrayJsValueToWasm0(users, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_getMissingSessions(this.__wbg_ptr, ptr0, len0); - return ret; - } - /** - * See if we have recently accepted an invitation to the given room. - * - * If we have accepted an invite to a room without finding an - * {@link https://github.com/matrix-org/matrix-spec-proposals/pull/4268|MSC4268} - * key bundle, we should accept a key bundle once one arrives. - * - * The data returned here is populated by the application, via {@link - * storeRoomPendingKeyBundle}. - * - * @experimental - * @param {RoomId} room_id - * @returns {Promise} - */ - getPendingKeyBundleDetailsForRoom(room_id) { - _assertClass(room_id, RoomId); - const ret = wasm.olmmachine_getPendingKeyBundleDetailsForRoom(this.__wbg_ptr, room_id.__wbg_ptr); - return ret; - } - /** - * See if we have received an {@link https://github.com/matrix-org/matrix-spec-proposals/pull/4268|MSC4268} - * room key bundle for the given room from the given user. - * - * Before calling this, the application must make sure that we have an - * up-to-date copy of the inviter's cross-signing keys, so that we can - * verify the device that sent us the key bundle data message. (For - * now, the easiest way to do that is by calling {@link queryKeysForUsers} - * for the inviter, and making the resultant request.) - * - * Returns either `undefined` if no suitable bundle has been received, - * or an {@link StoredRoomKeyBundleData}, in which case, the bundle - * should be downloaded, and then passed to {@link - * receiveRoomKeyBundle}. - * - * @experimental - * @param {RoomId} room_id - * @param {UserId} inviter - * @returns {Promise} - */ - getReceivedRoomKeyBundleData(room_id, inviter) { - _assertClass(room_id, RoomId); - _assertClass(inviter, UserId); - const ret = wasm.olmmachine_getReceivedRoomKeyBundleData(this.__wbg_ptr, room_id.__wbg_ptr, inviter.__wbg_ptr); - return ret; - } - /** - * Get encryption info for a decrypted timeline event. - * - * This recalculates the `EncryptionInfo` data that is returned by - * `decryptRoomEvent`, based on the current - * verification status of the sender, etc. - * - * Returns an error for an unencrypted event. - * - * # Arguments - * - * * `event` - The event to get information for. - * * `room_id` - The ID of the room where the event was sent to. - * - * # Returns - * - * {@link EncryptionInfo} - * @param {string} event - * @param {RoomId} room_id - * @returns {Promise} - */ - getRoomEventEncryptionInfo(event, room_id) { - const ptr0 = passStringToWasm0(event, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(room_id, RoomId); - const ret = wasm.olmmachine_getRoomEventEncryptionInfo(this.__wbg_ptr, ptr0, len0, room_id.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Get the stored room settings, such as the encryption algorithm or - * whether to encrypt only for trusted devices. - * - * These settings can be modified via {@link setRoomSettings}. - * - * # Returns - * - * `Promise` - * @param {RoomId} room_id - * @returns {Promise} - */ - getRoomSettings(room_id) { - _assertClass(room_id, RoomId); - const ret = wasm.olmmachine_getRoomSettings(this.__wbg_ptr, room_id.__wbg_ptr); - return ret; - } - /** - * Get all the secrets with the given secret_name we have currently - * stored. - * The only secret this will currently return is the - * `m.megolm_backup.v1` secret. - * - * Usually you would just register a callback with - * [`register_receive_secret_callback`], but if the client is shut down - * before handling them, this method can be used to retrieve them. - * This method should therefore be called at client startup to retrieve any - * secrets received during the previous session. - * - * The secrets are guaranteed to have been received over a 1-to-1 encrypted - * to_device message from one of the user's own verified devices. - * - * Returns a `Promise` for a `Set` of `String` corresponding to the secret - * values. - * - * If the secret is valid and handled, the secret inbox should be cleared - * by calling `delete_secrets_from_inbox`. - * @param {string} secret_name - * @returns {Promise>} - */ - getSecretsFromInbox(secret_name) { - const ptr0 = passStringToWasm0(secret_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_getSecretsFromInbox(this.__wbg_ptr, ptr0, len0); - return ret; - } - /** - * Get a map holding all the devices of a user. - * - * ### Parameters - * - * * `user_id` - The unique ID of the user that the device belongs to. - * - * * `timeout_secs` - The amount of time we should wait for a `/keys/query` - * response before returning if the user's device list has been marked as - * stale. **Note**, this assumes that the requests from {@link - * OlmMachine.outgoingRequests} are being processed and sent out. - * - * If unset, we will return immediately even if the device list is stale. - * - * ### Returns - * - * A {@link UserDevices} object. - * @param {UserId} user_id - * @param {number | null} [timeout_secs] - * @returns {Promise} - */ - getUserDevices(user_id, timeout_secs) { - _assertClass(user_id, UserId); - const ret = wasm.olmmachine_getUserDevices(this.__wbg_ptr, user_id.__wbg_ptr, !isLikeNone(timeout_secs), isLikeNone(timeout_secs) ? 0 : timeout_secs); - return ret; - } - /** - * Get a verification object for the given user ID with the given - * flow ID (a to-device request ID if the verification has been - * requested by a to-device request, or a room event ID if the - * verification has been requested by a room event). - * - * It returns a “`Verification` object”, which is either a `Sas` - * or `Qr` object. - * @param {UserId} user_id - * @param {string} flow_id - * @returns {Sas | Qr | undefined} - */ - getVerification(user_id, flow_id) { - _assertClass(user_id, UserId); - const ptr0 = passStringToWasm0(flow_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_getVerification(this.__wbg_ptr, user_id.__wbg_ptr, ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Get a verification request object with the given flow ID. - * @param {UserId} user_id - * @param {string} flow_id - * @returns {VerificationRequest | undefined} - */ - getVerificationRequest(user_id, flow_id) { - _assertClass(user_id, UserId); - const ptr0 = passStringToWasm0(flow_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_getVerificationRequest(this.__wbg_ptr, user_id.__wbg_ptr, ptr0, len0); - return ret === 0 ? undefined : VerificationRequest.__wrap(ret); - } - /** - * Get all the verification requests of a given user. - * @param {UserId} user_id - * @returns {VerificationRequest[]} - */ - getVerificationRequests(user_id) { - _assertClass(user_id, UserId); - const ret = wasm.olmmachine_getVerificationRequests(this.__wbg_ptr, user_id.__wbg_ptr); - return ret; - } - /** - * Get whether we have previously downloaded all message keys for a - * particular room from the key backup. Typically called in advance of - * building a room key bundle. - * @param {RoomId} room_id - * @returns {Promise} - */ - hasDownloadedAllRoomKeys(room_id) { - _assertClass(room_id, RoomId); - const ret = wasm.olmmachine_hasDownloadedAllRoomKeys(this.__wbg_ptr, room_id.__wbg_ptr); - return ret; - } - /** - * Get the public parts of our Olm identity keys. - * @returns {IdentityKeys} - */ - get identityKeys() { - const ret = wasm.olmmachine_identityKeys(this.__wbg_ptr); - return IdentityKeys.__wrap(ret); - } - /** - * Import the given room keys into our store. - * - * # Arguments - * - * * `backed_up_room_keys`: keys that were retrieved from backup and that - * should be added to our store (provided they are better than our - * current versions of those keys). Specifically, it should be a Map from - * {@link RoomId}, to a Map from session ID to a (decrypted) session data - * structure. - * - * * `progress_listener`: an optional callback that takes 3 arguments: - * `progress` (the number of keys that have successfully been imported), - * `total` (the total number of keys), and `failures` (the number of keys - * that failed to import), and returns nothing. - * - * # Returns - * - * A {@link RoomKeyImportResult}. - * @param {Map>} backed_up_room_keys - * @param {(progress: bigint, total: bigint, failures: bigint) => void | undefined} progress_listener - * @param {string} backup_version - * @returns {Promise} - */ - importBackedUpRoomKeys(backed_up_room_keys, progress_listener, backup_version) { - const ptr0 = passStringToWasm0(backup_version, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_importBackedUpRoomKeys(this.__wbg_ptr, backed_up_room_keys, isLikeNone(progress_listener) ? 0 : addToExternrefTable0(progress_listener), ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Import our private cross signing keys. - * - * The keys should be provided as unpadded-base64-encoded strings. - * - * Returns a `CrossSigningStatus`. - * @param {string | null} [master_key] - * @param {string | null} [self_signing_key] - * @param {string | null} [user_signing_key] - * @returns {Promise} - */ - importCrossSigningKeys(master_key, self_signing_key, user_signing_key) { - var ptr0 = isLikeNone(master_key) ? 0 : passStringToWasm0(master_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - var ptr1 = isLikeNone(self_signing_key) ? 0 : passStringToWasm0(self_signing_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len1 = WASM_VECTOR_LEN; - var ptr2 = isLikeNone(user_signing_key) ? 0 : passStringToWasm0(user_signing_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len2 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_importCrossSigningKeys(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2); - return ret; - } - /** - * Import the given room keys into our store. - * - * `exported_keys` is a JSON-encoded list of previously exported keys that - * should be imported into our store. If we already have a better - * version of a key, the key will _not_ be imported. - * - * `progress_listener` is a closure that takes 2 `BigInt` arguments: - * `progress` and `total`, and returns nothing. - * - * Returns a {@link RoomKeyImportResult}. - * @param {string} exported_room_keys - * @param {(progress: bigint, total: bigint) => void} progress_listener - * @returns {Promise} - */ - importExportedRoomKeys(exported_room_keys, progress_listener) { - const ptr0 = passStringToWasm0(exported_room_keys, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_importExportedRoomKeys(this.__wbg_ptr, ptr0, len0, progress_listener); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Import the given room keys into our store. - * - * Mostly, a deprecated alias for `importExportedRoomKeys`, though the - * return type is different. - * - * Returns a String containing a JSON-encoded object, holding three - * properties: - * * `total_count` (the total number of keys found in the export data). - * * `imported_count` (the number of keys that were imported). - * * `keys` (the keys that were imported; a map from room id to a map of - * the sender key to a list of session ids). - * - * @deprecated Use `importExportedRoomKeys` or `importBackedUpRoomKeys`. - * @param {string} exported_room_keys - * @param {(imported: bigint, total: bigint) => void} progress_listener - * @returns {Promise} - */ - importRoomKeys(exported_room_keys, progress_listener) { - const ptr0 = passStringToWasm0(exported_room_keys, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_importRoomKeys(this.__wbg_ptr, ptr0, len0, progress_listener); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Import and persists secrets from a {@link SecretsBundle}. - * - * This method will import all the private cross-signing keys and, if - * available, the private part of a backup key and its accompanying - * version into the store. - * - * **Warning**: Only import this from a trusted source, i.e. if an existing - * device is sharing this with a new device. The imported cross-signing - * keys will create a {@link OwnUserIdentity} and mark it as verified. - * - * The backup key will be persisted in the store and can be enabled using - * the BackupMachine. - * - * The provided `SecretsBundle` is freed by this method; be careful not to - * use it once this method has been called. - * @param {SecretsBundle} bundle - * @returns {Promise} - */ - importSecretsBundle(bundle) { - _assertClass(bundle, SecretsBundle); - var ptr0 = bundle.__destroy_into_raw(); - const ret = wasm.olmmachine_importSecretsBundle(this.__wbg_ptr, ptr0); - return ret; - } - /** - * Create a new `OlmMachine` backed by an existing store. - * - * # Arguments - * - * * `user_id` - represents the unique ID of the user that owns this - * machine. - * - * * `device_id` - represents the unique ID of the device - * that owns this machine. - * - * * `store_handle` - the connection to the crypto store to be used for - * this machine. - * - * * `logger` - Optional logger to use for all operations on this machine. - * An instance of `JsLogger`. - * - * * `ca_certs_pem` - Optional PEM-formatted string that provides CA - * certificates. These will be used to check X.509 signatures on user - * identities. Any user identity that has a valid signature according to - * the supplied CAs will be considered verified, without any manual - * - * * `raw_x509_signer` - Optional async function for signing some data with - * an X.509 certificate. Used to sign the user's identity so compatible - * clients will recognise this user as verified without manual - * verification taking place. If you supply this you must also supply - * raw_x509_validity. - * - * * `raw_x509_validity` - Optional function returning the validity period - * of the X.509 certificate used for signing, as the number of - * milliseconds since the Unix epoch. If you supply this you must also - * supply raw_x509_signer. - * @param {UserId} user_id - * @param {DeviceId} device_id - * @param {StoreHandle} store_handle - * @param {JsLogger} [logger] - * @param {String} [ca_certs_pem] - * @param {(item: Uint8Array) => Promise<{ signature_bytes: Uint8Array, certificate_chain: string }>} [raw_x509_signer] - * @param {() => number} [raw_x509_validity] - * @returns {Promise} - */ - static initFromStore(user_id, device_id, store_handle, logger, ca_certs_pem, raw_x509_signer, raw_x509_validity) { - _assertClass(user_id, UserId); - _assertClass(device_id, DeviceId); - _assertClass(store_handle, StoreHandle); - var ptr0 = isLikeNone(ca_certs_pem) ? 0 : passStringToWasm0(ca_certs_pem, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_initFromStore(user_id.__wbg_ptr, device_id.__wbg_ptr, store_handle.__wbg_ptr, isLikeNone(logger) ? 0 : addToExternrefTable0(logger), ptr0, len0, isLikeNone(raw_x509_signer) ? 0 : addToExternrefTable0(raw_x509_signer), isLikeNone(raw_x509_validity) ? 0 : addToExternrefTable0(raw_x509_validity)); - return ret; - } - /** - * Create a new `OlmMachine`. - * - * The created machine will keep the encryption keys either in a IndexedDB - * based store, or in a memory store and once the objects is dropped, - * the keys will be lost. - * - * # Arguments - * - * * `user_id` - represents the unique ID of the user that owns this - * machine. - * - * * `device_id` - represents the unique ID of the device - * that owns this machine. - * - * * `store_name` - The name that should be used to open the IndexedDB - * based database. If this isn't provided, a memory-only store will be - * used. *Note* the memory-only store will lose your E2EE keys when the - * `OlmMachine` gets dropped. - * - * * `store_passphrase` - The passphrase that should be used to encrypt the - * IndexedDB-based store. - * - * * `logger` - Optional logger to use for all operations on this machine. - * An instance of `JsLogger`. - * - * * `ca_certs_pem` - Optional PEM-formatted string that provides CA - * certificates. These will be used to check X.509 signatures on user - * identities. Any user identity that has a valid signature according to - * the supplied CAs will be considered verified, without any manual - * verification taking place. A PEM-formatted string. - * - * * `raw_x509_signer` - Optional async function for signing some data with - * an X.509 certificate. Used to sign the user's identity so compatible - * clients will recognise this user as verified without manual - * verification taking place. If you supply this you must also supply - * raw_x509_validity. - * - * * `raw_x509_validity` - Optional function returning the validity period - * of the X.509 certificate used for signing, as the number of - * milliseconds since the Unix epoch. If you supply this you must also - * supply raw_x509_signer. - * @param {UserId} user_id - * @param {DeviceId} device_id - * @param {string} [store_name] - * @param {string} [store_passphrase] - * @param {JsLogger} [logger] - * @param {String} [ca_certs_pem] - * @param {(item: Uint8Array) => Promise<{ signature_bytes: Uint8Array, certificate_chain: string }>} [raw_x509_signer] - * @param {() => number} [raw_x509_validity] - * @returns {Promise} - */ - static initialize(user_id, device_id, store_name, store_passphrase, logger, ca_certs_pem, raw_x509_signer, raw_x509_validity) { - _assertClass(user_id, UserId); - _assertClass(device_id, DeviceId); - var ptr0 = isLikeNone(store_name) ? 0 : passStringToWasm0(store_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - var ptr1 = isLikeNone(store_passphrase) ? 0 : passStringToWasm0(store_passphrase, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len1 = WASM_VECTOR_LEN; - var ptr2 = isLikeNone(ca_certs_pem) ? 0 : passStringToWasm0(ca_certs_pem, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len2 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_initialize(user_id.__wbg_ptr, device_id.__wbg_ptr, ptr0, len0, ptr1, len1, isLikeNone(logger) ? 0 : addToExternrefTable0(logger), ptr2, len2, isLikeNone(raw_x509_signer) ? 0 : addToExternrefTable0(raw_x509_signer), isLikeNone(raw_x509_validity) ? 0 : addToExternrefTable0(raw_x509_validity)); - return ret; - } - /** - * Invalidate the currently active outbound group session for the - * given room. - * - * Returns true if a session was invalidated, false if there was - * no session to invalidate. - * @param {RoomId} room_id - * @returns {Promise} - */ - invalidateGroupSession(room_id) { - _assertClass(room_id, RoomId); - const ret = wasm.olmmachine_invalidateGroupSession(this.__wbg_ptr, room_id.__wbg_ptr); - return ret; - } - /** - * Are we able to encrypt room keys. - * - * This returns true if we have an active `BackupKey` and backup version - * registered with the state machine. - * - * Returns `Promise`. - * @returns {Promise} - */ - isBackupEnabled() { - const ret = wasm.olmmachine_isBackupEnabled(this.__wbg_ptr); - return ret; - } - /** - * Mark all tracked users as dirty. - * - * All users *whose device lists we are tracking* are flagged as needing a - * key query. Users whose devices we are not tracking are ignored. - * @returns {Promise} - */ - markAllTrackedUsersAsDirty() { - const ret = wasm.olmmachine_markAllTrackedUsersAsDirty(this.__wbg_ptr); - return ret; - } - /** - * Mark the request with the given request ID as sent (see - * `outgoing_requests`). - * - * Arguments are: - * - * * `request_id` represents the unique ID of the request that was sent - * out. This is needed to couple the response with the now sent out - * request. - * * `response_type` represents the type of the request that was sent out. - * * `response` represents the response that was received from the server - * after the outgoing request was sent out. - * @param {string} request_id - * @param {RequestType} request_type - * @param {string} response - * @returns {Promise} - */ - markRequestAsSent(request_id, request_type, response) { - const ptr0 = passStringToWasm0(request_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(response, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_markRequestAsSent(this.__wbg_ptr, ptr0, len0, request_type, ptr1, len1); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Constructor will always fail. To create a new `OlmMachine`, please use - * the `initialize` method. - * - * Why this pattern? `initialize` returns a `Promise`. Returning a - * `Promise` from a constructor is not idiomatic in JavaScript. - */ - constructor() { - const ret = wasm.olmmachine_new(); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - this.__wbg_ptr = ret[0]; - OlmMachineFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Get the outgoing requests that need to be sent out. - * - * This returns a list of values, each of which can be any of: - * * {@link KeysUploadRequest}, - * * {@link KeysQueryRequest}, - * * {@link KeysClaimRequest}, - * * {@link ToDeviceRequest}, - * * {@link SignatureUploadRequest}, - * * {@link RoomMessageRequest}, or - * * {@link KeysBackupRequest}. - * - * Those requests need to be sent out to the server and the - * responses need to be passed back to the state machine - * using {@link OlmMachine.markRequestAsSent}. - * @returns {Promise} - */ - outgoingRequests() { - const ret = wasm.olmmachine_outgoingRequests(this.__wbg_ptr); - return ret; - } - /** - * Push a secret to all of our other verified devices - * - * This function assumes that we already have Olm sessions with the other - * devices. This can be done by calling {@link - * OlmMachine.getMissingSessions}. - * - * # Arguments - * - * * `secret_name` - The name of the secret to push. - * @param {string} name - * @returns {Promise} - */ - pushSecretToVerifiedDevices(name) { - const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_pushSecretToVerifiedDevices(this.__wbg_ptr, ptr0, len0); - return ret; - } - /** - * Generate an "out-of-band" key query request for the given set of users. - * - * This can be useful if we need the results from `getIdentity` or - * `getUserDevices` to be as up-to-date as possible. - * - * Returns a `KeysQueryRequest` object. The response of the request should - * be passed to the `OlmMachine` with the `mark_request_as_sent`. - * - * Items inside `users` will be invalidated by this method. Be careful not - * to use the `UserId`s after this method has been called. - * @param {UserId[]} users - * @returns {KeysQueryRequest} - */ - queryKeysForUsers(users) { - const ptr0 = passArrayJsValueToWasm0(users, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_queryKeysForUsers(this.__wbg_ptr, ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return KeysQueryRequest.__wrap(ret[0]); - } - /** - * Import the message keys from a downloaded room key bundle. - * - * After {@link getReceivedRoomKeyBundleData} returns a truthy result, the - * media file should be downloaded and then passed into this method to - * actually do the import. - * - * @experimental - * @param {StoredRoomKeyBundleData} bundle_data - * @param {Uint8Array} encrypted_bundle - * @returns {Promise} - */ - receiveRoomKeyBundle(bundle_data, encrypted_bundle) { - _assertClass(bundle_data, StoredRoomKeyBundleData); - var ptr0 = bundle_data.__destroy_into_raw(); - const ptr1 = passArray8ToWasm0(encrypted_bundle, wasm.__wbindgen_malloc); - const len1 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_receiveRoomKeyBundle(this.__wbg_ptr, ptr0, ptr1, len1); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Handle to-device events and one-time key counts from a sync - * response. - * - * This will decrypt and handle to-device events returning the - * decrypted versions of them. - * - * To decrypt an event from the room timeline call - * `decrypt_room_event`. - * - * # Arguments - * - * * `to_device_events`: the JSON-encoded to-device evens from the `/sync` - * response - * * `changed_devices`: the mapping of changed and left devices, from the - * `/sync` response - * * `one_time_keys_counts`: The number of one-time keys on the server, - * from the `/sync` response. A `Map` from string (encryption algorithm) - * to number (number of keys). Following the sync v2 semantics, a missing - * entry for an algorithm means that there are *zero* keys of that type - * on the server. If the caller has no information about the key counts - * (for example, because it is processing only part of a sync response), - * it should use {@link receiveSyncChangesMsc4186} instead. - * * `unused_fallback_keys`: Optionally, a `Set` of unused fallback keys on - * the server, from the `/sync` response. If this is set, it is used to - * determine if new fallback keys should be uploaded. - * * `decryption_settings`: Optionally, the settings to use when decrypting - * to-device events. If not set, to-device events will be decrypted with - * a {@link TrustRequirement} of `Untrusted`. - * - * # Returns - * - * A list of values, each of which can be any of: - * * {@link DecryptedToDeviceEvent} - * * {@link PlainTextToDeviceEvent} - * * {@link UTDToDeviceEvent} - * * {@link InvalidToDeviceEvent} - * @param {string} to_device_events - * @param {DeviceLists} changed_devices - * @param {Map} one_time_keys_counts - * @param {Set} [unused_fallback_keys] - * @param {DecryptionSettings} [decryption_settings] - * @returns {Promise} - */ - receiveSyncChanges(to_device_events, changed_devices, one_time_keys_counts, unused_fallback_keys, decryption_settings) { - const ptr0 = passStringToWasm0(to_device_events, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(changed_devices, DeviceLists); - let ptr1 = 0; - if (!isLikeNone(decryption_settings)) { - _assertClass(decryption_settings, DecryptionSettings); - ptr1 = decryption_settings.__destroy_into_raw(); - } - const ret = wasm.olmmachine_receiveSyncChanges(this.__wbg_ptr, ptr0, len0, changed_devices.__wbg_ptr, one_time_keys_counts, isLikeNone(unused_fallback_keys) ? 0 : addToExternrefTable0(unused_fallback_keys), ptr1); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Handle the changes to the end-to-end encryption state we received from - * a [MSC4186](https://github.com/matrix-org/matrix-spec-proposals/pull/4186) - * (simplified sliding sync) response. - * - * This behaves exactly like {@link receiveSyncChanges}, except for the - * handling of `one_time_keys_counts`: under MSC4186 semantics, a missing - * entry for an algorithm means that the number of keys on the server is - * *unchanged*, rather than zero. - * - * This is therefore also the method to use when the caller has no - * information about the one-time key counts, for example because it is - * processing only the to-device events or the device list changes from a - * sync response. - * - * # Arguments - * - * * `to_device_events`: the JSON-encoded to-device events from the sync - * response - * * `changed_devices`: the mapping of changed and left devices, from the - * sync response - * * `one_time_keys_counts`: The number of one-time keys on the server, - * from the sync response. A `Map` from string (encryption algorithm) to - * number (number of keys). A missing entry means "unchanged". - * * `unused_fallback_keys`: Optionally, a `Set` of unused fallback keys on - * the server, from the sync response. If this is set, it is used to - * determine if new fallback keys should be uploaded. - * * `decryption_settings`: Optionally, the settings to use when decrypting - * to-device events. If not set, to-device events will be decrypted with - * a {@link TrustRequirement} of `Untrusted`. - * - * # Returns - * - * A list of values, each of which can be any of: - * * {@link DecryptedToDeviceEvent} - * * {@link PlainTextToDeviceEvent} - * * {@link UTDToDeviceEvent} - * * {@link InvalidToDeviceEvent} - * @param {string} to_device_events - * @param {DeviceLists} changed_devices - * @param {Map} one_time_keys_counts - * @param {Set} [unused_fallback_keys] - * @param {DecryptionSettings} [decryption_settings] - * @returns {Promise} - */ - receiveSyncChangesMsc4186(to_device_events, changed_devices, one_time_keys_counts, unused_fallback_keys, decryption_settings) { - const ptr0 = passStringToWasm0(to_device_events, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(changed_devices, DeviceLists); - let ptr1 = 0; - if (!isLikeNone(decryption_settings)) { - _assertClass(decryption_settings, DecryptionSettings); - ptr1 = decryption_settings.__destroy_into_raw(); - } - const ret = wasm.olmmachine_receiveSyncChangesMsc4186(this.__wbg_ptr, ptr0, len0, changed_devices.__wbg_ptr, one_time_keys_counts, isLikeNone(unused_fallback_keys) ? 0 : addToExternrefTable0(unused_fallback_keys), ptr1); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Receive a verification event. - * - * This method can be used to pass verification events that are happening - * in rooms to the `OlmMachine`. The event should be in the decrypted form. - * @param {string} event - * @param {RoomId} room_id - * @returns {Promise} - */ - receiveVerificationEvent(event, room_id) { - const ptr0 = passStringToWasm0(event, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(room_id, RoomId); - const ret = wasm.olmmachine_receiveVerificationEvent(this.__wbg_ptr, ptr0, len0, room_id.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Register a callback which will be called whenever there is an update to - * a device. - * - * `callback` should be a function that takes a single argument (an array - * of user IDs as strings) and returns a Promise. - * @param {(userIds: string[]) => Promise} callback - */ - registerDevicesUpdatedCallback(callback) { - wasm.olmmachine_registerDevicesUpdatedCallback(this.__wbg_ptr, callback); - } - /** - * Register a callback which will be called whenever a secret - * (`m.secret.send`) is received. - * - * The only secret this will currently broadcast is the - * `m.megolm_backup.v1` (the cross signing secrets are handled internally). - * - * To request a secret from other devices, a client sends an - * `m.secret.request` device event with `action` set to `request` and - * `name` set to the identifier of the secret. A device that wishes to - * share the secret will reply with an `m.secret.send` event, encrypted - * using olm. - * - * The secrets are guaranteed to have been received over a 1-to-1 encrypted - * to_device message from a one of the user's own verified devices. - * - * See https://matrix-org.github.io/matrix-rust-sdk/matrix_sdk_crypto/store/struct.Store.html#method.secrets_stream for more information. - * - * `callback` should be a function that takes 2 arguments: the secret name - * (string) and value (string). - * - * **Note**: if the secret is valid and handled on the javascript side, the - * secret inbox should be cleared by calling - * `delete_secrets_from_inbox`. - * @param {(name: string, value: string) => Promise} callback - */ - registerReceiveSecretCallback(callback) { - wasm.olmmachine_registerReceiveSecretCallback(this.__wbg_ptr, callback); - } - /** - * Register a callback which will be called whenever there is an update to - * a room key. - * - * `callback` should be a function that takes a single argument (an array - * of {@link RoomKeyInfo}) and returns a Promise. - * @param {(info: RoomKeyInfo[]) => Promise} callback - */ - registerRoomKeyUpdatedCallback(callback) { - wasm.olmmachine_registerRoomKeyUpdatedCallback(this.__wbg_ptr, callback); - } - /** - * Register a callback which will be called whenever we receive a - * notification that some room keys have been withheld. - * - * `callback` should be a function that takes a single argument (an array - * of {@link RoomKeyWithheldInfo}) and returns a Promise. - * @param {(info: RoomKeyWithheldInfo[]) => Promise} callback - */ - registerRoomKeysWithheldCallback(callback) { - wasm.olmmachine_registerRoomKeysWithheldCallback(this.__wbg_ptr, callback); - } - /** - * Register a callback which will be called whenever there is an update to - * a user identity. - * - * `callback` should be a function that takes a single argument (a {@link - * UserId}) and returns a Promise. - * @param {(id: UserId) => Promise} callback - */ - registerUserIdentityUpdatedCallback(callback) { - wasm.olmmachine_registerUserIdentityUpdatedCallback(this.__wbg_ptr, callback); - } - /** - * Request missing local secrets from our other trusted devices. - * - * "Local secrets" refers to secrets which can be shared between trusted - * devices, such as private cross-signing keys, and the megolm backup - * decryption key. - * - * This method will cause the sdk to generated outgoing secret requests - * (`m.secret.request`) to get the missing secrets. These requests will - * then be returned by a future call to {@link - * OlmMachine#outgoingRequests}. - * - * # Returns - * - * A `Promise` for a `bool` result, which will be true if secrets were - * missing, and a request was generated. - * @returns {Promise} - */ - requestMissingSecretsIfNeeded() { - const ret = wasm.olmmachine_requestMissingSecretsIfNeeded(this.__wbg_ptr); - return ret; - } - /** - * Get the number of backed up room keys and the total number of room keys. - * Returns a {@link RoomKeyCounts}. - * @returns {Promise} - */ - roomKeyCounts() { - const ret = wasm.olmmachine_roomKeyCounts(this.__wbg_ptr); - return ret; - } - /** - * Whether room key forwarding is enabled. - * - * If room key forwarding is enabled, we will automatically reply to - * incoming `m.room_key_request` messages from verified devices by - * forwarding the requested key (if we have it). - * @returns {boolean} - */ - get roomKeyForwardingEnabled() { - const ret = wasm.olmmachine_roomKeyForwardingEnabled(this.__wbg_ptr); - return ret !== 0; - } - /** - * Whether automatic transmission of room key requests is enabled. - * - * Room key requests allow the device to request room keys that it might - * have missed in the original share using `m.room_key_request` - * events. - * @returns {boolean} - */ - get roomKeyRequestsEnabled() { - const ret = wasm.olmmachine_roomKeyRequestsEnabled(this.__wbg_ptr); - return ret !== 0; - } - /** - * Store the backup decryption key in the crypto store. - * - * This is useful if the client wants to support gossiping of the backup - * key. - * - * Returns `Promise`. - * @param {BackupDecryptionKey} decryption_key - * @param {string} version - * @returns {Promise} - */ - saveBackupDecryptionKey(decryption_key, version) { - _assertClass(decryption_key, BackupDecryptionKey); - const ptr0 = passStringToWasm0(version, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_saveBackupDecryptionKey(this.__wbg_ptr, decryption_key.__wbg_ptr, ptr0, len0); - return ret; - } - /** - * Record that we have downloaded all message keys for the given room. - * @param {RoomId} room_id - * @returns {Promise} - */ - setHasDownloadedAllRoomKeys(room_id) { - _assertClass(room_id, RoomId); - const ret = wasm.olmmachine_setHasDownloadedAllRoomKeys(this.__wbg_ptr, room_id.__wbg_ptr); - return ret; - } - /** - * Store encryption settings for the given room. - * - * This method checks if the new settings are "safe" -- ie, that they do - * not represent a downgrade in encryption security from any previous - * settings. Attempts to downgrade security will result in an error. - * - * If the settings are valid, they will be persisted to the crypto store. - * These settings are not used directly by this library, but the saved - * settings can be retrieved via {@link getRoomSettings}. - * @param {RoomId} room_id - * @param {RoomSettings} room_settings - * @returns {Promise} - */ - setRoomSettings(room_id, room_settings) { - _assertClass(room_id, RoomId); - _assertClass(room_settings, RoomSettings); - const ret = wasm.olmmachine_setRoomSettings(this.__wbg_ptr, room_id.__wbg_ptr, room_settings.__wbg_ptr); - return ret; - } - /** - * Enable or disable room key forwarding. - * @param {boolean} enabled - */ - set roomKeyForwardingEnabled(enabled) { - wasm.olmmachine_set_roomKeyForwardingEnabled(this.__wbg_ptr, enabled); - } - /** - * Enable or disable automatic transmission of room key requests. - * @param {boolean} enabled - */ - set roomKeyRequestsEnabled(enabled) { - wasm.olmmachine_set_roomKeyRequestsEnabled(this.__wbg_ptr, enabled); - } - /** - * Get to-device requests to share a room key with users in a room. - * - * `room_id` is the room ID. `users` is an array of `UserId` - * objects. `encryption_settings` are an `EncryptionSettings` - * object. - * - * Note: Care should be taken that only one such request at a - * time is in flight for the same room, e.g. using a lock. - * - * Returns an array of `ToDeviceRequest`s. - * - * Items inside `users` will be invalidated by this method. Be careful not - * to use the `UserId`s after this method has been called. - * @param {RoomId} room_id - * @param {UserId[]} users - * @param {EncryptionSettings} encryption_settings - * @returns {Promise} - */ - shareRoomKey(room_id, users, encryption_settings) { - _assertClass(room_id, RoomId); - const ptr0 = passArrayJsValueToWasm0(users, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(encryption_settings, EncryptionSettings); - const ret = wasm.olmmachine_shareRoomKey(this.__wbg_ptr, room_id.__wbg_ptr, ptr0, len0, encryption_settings.__wbg_ptr); - return ret; - } - /** - * Collect the devices belonging to the given user, and send the details - * of a room key bundle to those devices. - * - * Returns a list of to-device requests which must be sent. - * - * @experimental - * @param {UserId} user - * @param {RoomId} room - * @param {string} url - * @param {string | null | undefined} media_encryption_info - * @param {CollectStrategy} sharing_strategy - * @returns {Promise} - */ - shareRoomKeyBundleData(user, room, url, media_encryption_info, sharing_strategy) { - _assertClass(user, UserId); - _assertClass(room, RoomId); - const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - var ptr1 = isLikeNone(media_encryption_info) ? 0 : passStringToWasm0(media_encryption_info, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len1 = WASM_VECTOR_LEN; - _assertClass(sharing_strategy, CollectStrategy); - var ptr2 = sharing_strategy.__destroy_into_raw(); - const ret = wasm.olmmachine_shareRoomKeyBundleData(this.__wbg_ptr, user.__wbg_ptr, room.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Sign the given message using our device key and if available - * cross-signing master key. - * @param {string} message - * @returns {Promise} - */ - sign(message) { - const ptr0 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_sign(this.__wbg_ptr, ptr0, len0); - return ret; - } - /** - * Store the fact that we have accepted an invitation to the given room, so - * should accept a key bundle if one arrives soon. - * - * This should be called whenever we join a room following an invite, but - * it has no effect other than that the room will be returned by a future - * call to {@link getPendingKeyBundleDetailsForRoom}. - * - * @experimental - * @param {RoomId} room_id - * @param {UserId} inviter - * @returns {Promise} - */ - storeRoomPendingKeyBundle(room_id, inviter) { - _assertClass(room_id, RoomId); - _assertClass(inviter, UserId); - const ret = wasm.olmmachine_storeRoomPendingKeyBundle(this.__wbg_ptr, room_id.__wbg_ptr, inviter.__wbg_ptr); - return ret; - } - /** - * Get the list of users whose devices we are currently tracking. - * - * A user can be marked for tracking using the - * [`update_tracked_users`](#method.update_tracked_users) method. - * - * Returns a `Set`. - * @returns {Promise>} - */ - trackedUsers() { - const ret = wasm.olmmachine_trackedUsers(this.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Update the list of tracked users. - * - * The OlmMachine maintains a list of users whose devices we are keeping - * track of: these are known as "tracked users". These must be users - * that we share a room with, so that the server sends us updates for - * their device lists. - * - * # Arguments - * - * * `users` - An array of user ids that should be added to the list of - * tracked users - * - * Any users that hadn't been seen before will be flagged for a key query - * immediately, and whenever `receive_sync_changes` receives a - * "changed" notification for that user in the future. - * - * Users that were already in the list are unaffected. - * - * Items inside `users` will be invalidated by this method. Be careful not - * to use the `UserId`s after this method has been called. - * @param {UserId[]} users - * @returns {Promise} - */ - updateTrackedUsers(users) { - const ptr0 = passArrayJsValueToWasm0(users, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.olmmachine_updateTrackedUsers(this.__wbg_ptr, ptr0, len0); - return ret; - } - /** - * The unique user ID that owns this `OlmMachine` instance. - * @returns {UserId} - */ - get userId() { - const ret = wasm.olmmachine_userId(this.__wbg_ptr); - return UserId.__wrap(ret); - } - /** - * Check if the given backup has been verified by us or by another of our - * devices that we trust. - * - * The `backup_info` should be a Javascript object with the following - * format: - * - * ```json - * { - * "algorithm": "m.megolm_backup.v1.curve25519-aes-sha2", - * "auth_data": { - * "public_key":"XjhWTCjW7l59pbfx9tlCBQolfnIQWARoKOzjTOPSlWM", - * "signatures": {} - * } - * } - * ``` - * - * Returns a {@link SignatureVerification} object. - * @param {any} backup_info - * @returns {Promise} - */ - verifyBackup(backup_info) { - const ret = wasm.olmmachine_verifyBackup(this.__wbg_ptr, backup_info); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } -} -if (Symbol.dispose) OlmMachine.prototype[Symbol.dispose] = OlmMachine.prototype.free; - -/** - * Struct representing a cross signing identity of a user. - * - * This is the user identity of a user that isn't our own. Other users will - * only contain a master key and a self signing key, meaning that only device - * signatures can be checked with this identity. - * - * This struct wraps a read-only version of the struct and allows verifications - * to be requested to verify our own device with the user identity. - */ -export class OtherUserIdentity { - static __wrap(ptr) { - const obj = Object.create(OtherUserIdentity.prototype); - obj.__wbg_ptr = ptr; - OtherUserIdentityFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - OtherUserIdentityFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_otheruseridentity_free(ptr, 0); - } - /** - * Was this identity verified since initial observation and is not anymore? - * - * Such a violation should be reported to the local user by the - * application, and resolved by - * - * - Verifying the new identity with {@link requestVerification}, or: - * - Withdrawing the verification requirement with {@link - * withdrawVerification}. - * @returns {boolean} - */ - hasVerificationViolation() { - const ret = wasm.otheruseridentity_hasVerificationViolation(this.__wbg_ptr); - return ret !== 0; - } - /** - * Has the identity changed in a way that requires approval from the user? - * - * A user identity needs approval if it changed after the crypto machine - * has already observed ("pinned") a different identity for that user, - * unless it is an explicitly verified identity (using for example - * interactive verification). - * - * This situation can be resolved by: - * - * - Verifying the new identity with {@link requestVerification}, or: - * - Updating the pin to the new identity with {@link pinCurrentMasterKey}. - * @returns {boolean} - */ - identityNeedsUserApproval() { - const ret = wasm.otheruseridentity_identityNeedsUserApproval(this.__wbg_ptr); - return ret !== 0; - } - /** - * Is this user identity verified? - * @returns {boolean} - */ - isVerified() { - const ret = wasm.otheruseridentity_isVerified(this.__wbg_ptr); - return ret !== 0; - } - /** - * Get the master key of the identity. - * @returns {string} - */ - get masterKey() { - let deferred2_0; - let deferred2_1; - try { - const ret = wasm.otheruseridentity_masterKey(this.__wbg_ptr); - var ptr1 = ret[0]; - var len1 = ret[1]; - if (ret[3]) { - ptr1 = 0; len1 = 0; - throw takeFromExternrefTable0(ret[2]); - } - deferred2_0 = ptr1; - deferred2_1 = len1; - return getStringFromWasm0(ptr1, len1); - } finally { - wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); - } - } - /** - * Pin the current identity (public part of the master signing key). - * @returns {Promise} - */ - pinCurrentMasterKey() { - const ret = wasm.otheruseridentity_pinCurrentMasterKey(this.__wbg_ptr); - return ret; - } - /** - * Create a `VerificationRequest` object after the verification - * request content has been sent out. - * @param {RoomId} room_id - * @param {EventId} request_event_id - * @param {VerificationMethod[]} [methods] - * @returns {VerificationRequest} - */ - requestVerification(room_id, request_event_id, methods) { - _assertClass(room_id, RoomId); - _assertClass(request_event_id, EventId); - var ptr0 = isLikeNone(methods) ? 0 : passArrayJsValueToWasm0(methods, wasm.__wbindgen_malloc); - var len0 = WASM_VECTOR_LEN; - const ret = wasm.otheruseridentity_requestVerification(this.__wbg_ptr, room_id.__wbg_ptr, request_event_id.__wbg_ptr, ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return VerificationRequest.__wrap(ret[0]); - } - /** - * Get the self-signing key of the identity. - * @returns {string} - */ - get selfSigningKey() { - let deferred2_0; - let deferred2_1; - try { - const ret = wasm.otheruseridentity_selfSigningKey(this.__wbg_ptr); - var ptr1 = ret[0]; - var len1 = ret[1]; - if (ret[3]) { - ptr1 = 0; len1 = 0; - throw takeFromExternrefTable0(ret[2]); - } - deferred2_0 = ptr1; - deferred2_1 = len1; - return getStringFromWasm0(ptr1, len1); - } finally { - wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); - } - } - /** - * Send a verification request to the given user. - * - * The returned content needs to be sent out into a DM room with the given - * user. - * - * After the content has been sent out a VerificationRequest can be started - * with the `request_verification` method. - * @param {VerificationMethod[]} [methods] - * @returns {string} - */ - verificationRequestContent(methods) { - let deferred3_0; - let deferred3_1; - try { - var ptr0 = isLikeNone(methods) ? 0 : passArrayJsValueToWasm0(methods, wasm.__wbindgen_malloc); - var len0 = WASM_VECTOR_LEN; - const ret = wasm.otheruseridentity_verificationRequestContent(this.__wbg_ptr, ptr0, len0); - var ptr2 = ret[0]; - var len2 = ret[1]; - if (ret[3]) { - ptr2 = 0; len2 = 0; - throw takeFromExternrefTable0(ret[2]); - } - deferred3_0 = ptr2; - deferred3_1 = len2; - return getStringFromWasm0(ptr2, len2); - } finally { - wasm.__wbindgen_free(deferred3_0, deferred3_1, 1); - } - } - /** - * Manually verify this user. - * - * This method will attempt to sign the user identity using our private - * cross signing key. - * - * This method fails if we don't have the private part of our user-signing - * key. - * - * Returns a request that needs to be sent out for the user to be marked as - * verified. - * @returns {Promise} - */ - verify() { - const ret = wasm.otheruseridentity_verify(this.__wbg_ptr); - return ret; - } - /** - * True if we verified this identity (with any own identity, at any - * point). - * - * To set this latch back to false, call {@link withdrawVerification}. - * @returns {boolean} - */ - wasPreviouslyVerified() { - const ret = wasm.otheruseridentity_wasPreviouslyVerified(this.__wbg_ptr); - return ret !== 0; - } - /** - * Remove the requirement for this identity to be verified. - * - * If an identity was previously verified and is not anymore it will be - * reported to the user. In order to remove this notice users have to - * verify again or to withdraw the verification requirement. - * @returns {Promise} - */ - withdrawVerification() { - const ret = wasm.otheruseridentity_withdrawVerification(this.__wbg_ptr); - return ret; - } -} -if (Symbol.dispose) OtherUserIdentity.prototype[Symbol.dispose] = OtherUserIdentity.prototype.free; - -/** - * The result of an outbound ECIES channel establishment. - */ -export class OutboundCreationResult { - static __wrap(ptr) { - const obj = Object.create(OutboundCreationResult.prototype); - obj.__wbg_ptr = ptr; - OutboundCreationResultFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - OutboundCreationResultFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_outboundcreationresult_free(ptr, 0); - } - /** - * The established ECIES channel. - * @returns {EstablishedEcies} - */ - get channel() { - const ret = wasm.__wbg_get_outboundcreationresult_channel(this.__wbg_ptr); - return EstablishedEcies.__wrap(ret); - } - /** - * The initial encrypted message. - * @returns {string} - */ - get initial_message() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_outboundcreationresult_initial_message(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The established ECIES channel. - * @param {EstablishedEcies} arg0 - */ - set channel(arg0) { - _assertClass(arg0, EstablishedEcies); - var ptr0 = arg0.__destroy_into_raw(); - wasm.__wbg_set_outboundcreationresult_channel(this.__wbg_ptr, ptr0); - } - /** - * The initial encrypted message. - * @param {string} arg0 - */ - set initial_message(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_outboundcreationresult_initial_message(this.__wbg_ptr, ptr0, len0); - } -} -if (Symbol.dispose) OutboundCreationResult.prototype[Symbol.dispose] = OutboundCreationResult.prototype.free; - -/** - * Struct representing a cross signing identity of a user. - * - * This is the user identity of a user that is our own. - */ -export class OwnUserIdentity { - static __wrap(ptr) { - const obj = Object.create(OwnUserIdentity.prototype); - obj.__wbg_ptr = ptr; - OwnUserIdentityFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - OwnUserIdentityFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_ownuseridentity_free(ptr, 0); - } - /** - * Was this identity verified since initial observation and is not anymore? - * - * Such a violation should be reported to the local user by the - * application, and resolved by - * - * - Verifying the new identity with {@link requestVerification}, or: - * - Withdrawing the verification requirement with {@link - * withdrawVerification}. - * @returns {boolean} - */ - hasVerificationViolation() { - const ret = wasm.ownuseridentity_hasVerificationViolation(this.__wbg_ptr); - return ret !== 0; - } - /** - * Is this user identity verified? - * @returns {boolean} - */ - isVerified() { - const ret = wasm.ownuseridentity_isVerified(this.__wbg_ptr); - return ret !== 0; - } - /** - * Get the master key of the identity. - * @returns {string} - */ - get masterKey() { - let deferred2_0; - let deferred2_1; - try { - const ret = wasm.ownuseridentity_masterKey(this.__wbg_ptr); - var ptr1 = ret[0]; - var len1 = ret[1]; - if (ret[3]) { - ptr1 = 0; len1 = 0; - throw takeFromExternrefTable0(ret[2]); - } - deferred2_0 = ptr1; - deferred2_1 = len1; - return getStringFromWasm0(ptr1, len1); - } finally { - wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); - } - } - /** - * Send a verification request to our other devices. - * @param {VerificationMethod[]} [methods] - * @returns {Promise<[VerificationRequest, OutgoingVerificationRequest]>} - */ - requestVerification(methods) { - var ptr0 = isLikeNone(methods) ? 0 : passArrayJsValueToWasm0(methods, wasm.__wbindgen_malloc); - var len0 = WASM_VECTOR_LEN; - const ret = wasm.ownuseridentity_requestVerification(this.__wbg_ptr, ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Get the self-signing key of the identity. - * @returns {string} - */ - get selfSigningKey() { - let deferred2_0; - let deferred2_1; - try { - const ret = wasm.ownuseridentity_selfSigningKey(this.__wbg_ptr); - var ptr1 = ret[0]; - var len1 = ret[1]; - if (ret[3]) { - ptr1 = 0; len1 = 0; - throw takeFromExternrefTable0(ret[2]); - } - deferred2_0 = ptr1; - deferred2_1 = len1; - return getStringFromWasm0(ptr1, len1); - } finally { - wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); - } - } - /** - * Does our user identity trust our own device, i.e. have we signed our own - * device keys with our self-signing key? - * @returns {Promise} - */ - trustsOurOwnDevice() { - const ret = wasm.ownuseridentity_trustsOurOwnDevice(this.__wbg_ptr); - return ret; - } - /** - * Get the user-signing key of the identity. This is only present for our - * own user identity. - * @returns {string} - */ - get userSigningKey() { - let deferred2_0; - let deferred2_1; - try { - const ret = wasm.ownuseridentity_userSigningKey(this.__wbg_ptr); - var ptr1 = ret[0]; - var len1 = ret[1]; - if (ret[3]) { - ptr1 = 0; len1 = 0; - throw takeFromExternrefTable0(ret[2]); - } - deferred2_0 = ptr1; - deferred2_1 = len1; - return getStringFromWasm0(ptr1, len1); - } finally { - wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); - } - } - /** - * Mark our user identity as verified. - * - * This will mark the identity locally as verified and sign it with our own - * device. - * - * Returns a signature upload request that needs to be sent out. - * @returns {Promise} - */ - verify() { - const ret = wasm.ownuseridentity_verify(this.__wbg_ptr); - return ret; - } - /** - * True if we verified our own identity at some point in the past. - * - * To reset this latch back to `false`, call {@link withdrawVerification}. - * @returns {boolean} - */ - wasPreviouslyVerified() { - const ret = wasm.ownuseridentity_wasPreviouslyVerified(this.__wbg_ptr); - return ret !== 0; - } - /** - * Remove the requirement for this identity to be verified. - * - * If an identity was previously verified and is not any longer, it will be - * reported to the user. In order to remove this notice users have to - * verify again or to withdraw the verification requirement. - * @returns {Promise} - */ - withdrawVerification() { - const ret = wasm.ownuseridentity_withdrawVerification(this.__wbg_ptr); - return ret; - } -} -if (Symbol.dispose) OwnUserIdentity.prototype[Symbol.dispose] = OwnUserIdentity.prototype.free; - -/** - * A pickled version of an `InboundGroupSession`. - * - * Holds all the information that needs to be stored in a database to restore - * an InboundGroupSession. - */ -export class PickledInboundGroupSession { - static __unwrap(jsValue) { - if (!(jsValue instanceof PickledInboundGroupSession)) { - return 0; - } - return jsValue.__destroy_into_raw(); - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - PickledInboundGroupSessionFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_pickledinboundgroupsession_free(ptr, 0); - } - /** - * Flag remembering if the session has been backed up. - * @returns {boolean} - */ - get backedUp() { - const ret = wasm.__wbg_get_pickledinboundgroupsession_backedUp(this.__wbg_ptr); - return ret !== 0; - } - /** - * Flag remembering if the session was directly sent to us by the sender - * or if it was imported. - * @returns {boolean} - */ - get imported() { - const ret = wasm.__wbg_get_pickledinboundgroupsession_imported(this.__wbg_ptr); - return ret !== 0; - } - /** - * The pickle string holding the Megolm Session, as returned by - * `olm_pickle_inbound_group_session` in libolm. - * @returns {string} - */ - get pickle() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_pickledinboundgroupsession_pickle(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The id of the room that the session is used in. - * - * Nullable so that a `PickledInboundGroupSession` can be constructed - * incrementally. Must be populated! - * @returns {RoomId | undefined} - */ - get roomId() { - const ret = wasm.__wbg_get_pickledinboundgroupsession_roomId(this.__wbg_ptr); - return ret === 0 ? undefined : RoomId.__wrap(ret); - } - /** - * The public curve25519 key of the account that sent us the session. - * @returns {string} - */ - get senderKey() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_pickledinboundgroupsession_senderKey(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The public ed25519 key of the account that is believed to have initiated - * the session, if known. - * - * If the session was received directly from the creator via an - * Olm-encrypted `m.room_key` event, this value is taken from the `keys` - * property of the plaintext payload of that event (see - * [`m.olm.v1.curve25519-aes-sha2`]). - * - * If the session was forwarded to us using an [`m.forwarded_room_key`], - * this value is a copy of the `sender_claimed_ed25519_key` from the - * content of the event. - * - * [`m.olm.v1.curve25519-aes-sha2`]: https://spec.matrix.org/v1.9/client-server-api/#molmv1curve25519-aes-sha2 - * [`m.forwarded_room_key`]: https://spec.matrix.org/v1.9/client-server-api/#mforwarded_room_key - * @returns {string | undefined} - */ - get senderSigningKey() { - const ret = wasm.__wbg_get_pickledinboundgroupsession_senderSigningKey(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * Construct a new `PickledInboundGroupSession`, with default values. - */ - constructor() { - const ret = wasm.pickledinboundgroupsession_new(); - this.__wbg_ptr = ret; - PickledInboundGroupSessionFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Flag remembering if the session has been backed up. - * @param {boolean} arg0 - */ - set backedUp(arg0) { - wasm.__wbg_set_pickledinboundgroupsession_backedUp(this.__wbg_ptr, arg0); - } - /** - * Flag remembering if the session was directly sent to us by the sender - * or if it was imported. - * @param {boolean} arg0 - */ - set imported(arg0) { - wasm.__wbg_set_pickledinboundgroupsession_imported(this.__wbg_ptr, arg0); - } - /** - * The pickle string holding the Megolm Session, as returned by - * `olm_pickle_inbound_group_session` in libolm. - * @param {string} arg0 - */ - set pickle(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_pickledinboundgroupsession_pickle(this.__wbg_ptr, ptr0, len0); - } - /** - * The id of the room that the session is used in. - * - * Nullable so that a `PickledInboundGroupSession` can be constructed - * incrementally. Must be populated! - * @param {RoomId | null} [arg0] - */ - set roomId(arg0) { - let ptr0 = 0; - if (!isLikeNone(arg0)) { - _assertClass(arg0, RoomId); - ptr0 = arg0.__destroy_into_raw(); - } - wasm.__wbg_set_pickledinboundgroupsession_roomId(this.__wbg_ptr, ptr0); - } - /** - * The public curve25519 key of the account that sent us the session. - * @param {string} arg0 - */ - set senderKey(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_pickledinboundgroupsession_senderKey(this.__wbg_ptr, ptr0, len0); - } - /** - * The public ed25519 key of the account that is believed to have initiated - * the session, if known. - * - * If the session was received directly from the creator via an - * Olm-encrypted `m.room_key` event, this value is taken from the `keys` - * property of the plaintext payload of that event (see - * [`m.olm.v1.curve25519-aes-sha2`]). - * - * If the session was forwarded to us using an [`m.forwarded_room_key`], - * this value is a copy of the `sender_claimed_ed25519_key` from the - * content of the event. - * - * [`m.olm.v1.curve25519-aes-sha2`]: https://spec.matrix.org/v1.9/client-server-api/#molmv1curve25519-aes-sha2 - * [`m.forwarded_room_key`]: https://spec.matrix.org/v1.9/client-server-api/#mforwarded_room_key - * @param {string | null} [arg0] - */ - set senderSigningKey(arg0) { - var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_pickledinboundgroupsession_senderSigningKey(this.__wbg_ptr, ptr0, len0); - } -} -if (Symbol.dispose) PickledInboundGroupSession.prototype[Symbol.dispose] = PickledInboundGroupSession.prototype.free; - -/** - * A pickled version of a `Session`. - * - * Holds all the information that needs to be stored in a database to restore - * an Olm Session. Can be imported into the rust store with {@link - * Migration::migrateOlmSessions}. - */ -export class PickledSession { - static __unwrap(jsValue) { - if (!(jsValue instanceof PickledSession)) { - return 0; - } - return jsValue.__destroy_into_raw(); - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - PickledSessionFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_pickledsession_free(ptr, 0); - } - /** - * Was the session created using a fallback key? - * @returns {boolean} - */ - get createdUsingFallbackKey() { - const ret = wasm.__wbg_get_pickledsession_createdUsingFallbackKey(this.__wbg_ptr); - return ret !== 0; - } - /** - * When the session was created. - * @returns {Date} - */ - get creationTime() { - const ret = wasm.__wbg_get_pickledsession_creationTime(this.__wbg_ptr); - return ret; - } - /** - * When the session was last used. - * @returns {Date} - */ - get lastUseTime() { - const ret = wasm.__wbg_get_pickledsession_lastUseTime(this.__wbg_ptr); - return ret; - } - /** - * The pickle string holding the Olm Session, as returned by - * `olm_pickle_session` in libolm. - * @returns {string} - */ - get pickle() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_pickledsession_pickle(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The base64-encoded public curve25519 key of the other user that we share - * this session with. - * @returns {string} - */ - get senderKey() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_pickledsession_senderKey(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Construct a new `PickledSession`, with default values. - */ - constructor() { - const ret = wasm.pickledsession_new(); - this.__wbg_ptr = ret; - PickledSessionFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Was the session created using a fallback key? - * @param {boolean} arg0 - */ - set createdUsingFallbackKey(arg0) { - wasm.__wbg_set_pickledsession_createdUsingFallbackKey(this.__wbg_ptr, arg0); - } - /** - * When the session was created. - * @param {Date} arg0 - */ - set creationTime(arg0) { - wasm.__wbg_set_pickledsession_creationTime(this.__wbg_ptr, arg0); - } - /** - * When the session was last used. - * @param {Date} arg0 - */ - set lastUseTime(arg0) { - wasm.__wbg_set_pickledsession_lastUseTime(this.__wbg_ptr, arg0); - } - /** - * The pickle string holding the Olm Session, as returned by - * `olm_pickle_session` in libolm. - * @param {string} arg0 - */ - set pickle(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_pickledsession_pickle(this.__wbg_ptr, ptr0, len0); - } - /** - * The base64-encoded public curve25519 key of the other user that we share - * this session with. - * @param {string} arg0 - */ - set senderKey(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_pickledsession_senderKey(this.__wbg_ptr, ptr0, len0); - } -} -if (Symbol.dispose) PickledSession.prototype[Symbol.dispose] = PickledSession.prototype.free; - -/** - * A class representing a public-key decryption instance. - * - * This implements the decryption part of the - * `m.megolm_backup.v1.curve25519-aes-sha2` algorithm described in the Matrix - * {@link https://spec.matrix.org/v1.11/client-server-api/#backup-algorithm-mmegolm_backupv1curve25519-aes-sha2 | spec}. - * - * @see {@link PkEncryption} - * - * More details can be found in the official {@link https://docs.rs/vodozemac/latest/vodozemac/pk_encryption/ | vodozemac documentation}. - */ -export class PkDecryption { - static __wrap(ptr) { - const obj = Object.create(PkDecryption.prototype); - obj.__wbg_ptr = ptr; - PkDecryptionFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - PkDecryptionFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_pkdecryption_free(ptr, 0); - } - /** - * Decrypts an encrypted message and returns the raw `Uint8Array`. - * @param {PkMessage} message - * @returns {Uint8Array} - */ - decrypt(message) { - _assertClass(message, PkMessage); - const ret = wasm.pkdecryption_decrypt(this.__wbg_ptr, message.__wbg_ptr); - if (ret[3]) { - throw takeFromExternrefTable0(ret[2]); - } - var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - return v1; - } - /** - * Decrypts an encrypted message and returns the plaintext as a UTF-8 - * string. - * @param {PkMessage} message - * @returns {string} - */ - decryptString(message) { - let deferred2_0; - let deferred2_1; - try { - _assertClass(message, PkMessage); - const ret = wasm.pkdecryption_decryptString(this.__wbg_ptr, message.__wbg_ptr); - var ptr1 = ret[0]; - var len1 = ret[1]; - if (ret[3]) { - ptr1 = 0; len1 = 0; - throw takeFromExternrefTable0(ret[2]); - } - deferred2_0 = ptr1; - deferred2_1 = len1; - return getStringFromWasm0(ptr1, len1); - } finally { - wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); - } - } - /** - * Creates a `PkDecryption` instance from a secret key. - * @param {Curve25519SecretKey} key - * @returns {PkDecryption} - */ - static fromKey(key) { - _assertClass(key, Curve25519SecretKey); - const ret = wasm.pkdecryption_fromKey(key.__wbg_ptr); - return PkDecryption.__wrap(ret); - } - /** - * Creates a new `PkDecryption` instance with a newly generated key pair. - */ - constructor() { - const ret = wasm.pkdecryption_new(); - this.__wbg_ptr = ret; - PkDecryptionFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Returns the public key associated with this decryption instance. - * - * This can be used to construct a {@link PkEncryption} object to encrypt a - * message for this `PkDecryption` object. - * @returns {Curve25519PublicKey} - */ - publicKey() { - const ret = wasm.pkdecryption_publicKey(this.__wbg_ptr); - return Curve25519PublicKey.__wrap(ret); - } - /** - * Returns the secret key associated with this `PkDecryption` instance. - * @returns {Curve25519SecretKey} - */ - secretKey() { - const ret = wasm.pkdecryption_secretKey(this.__wbg_ptr); - return Curve25519SecretKey.__wrap(ret); - } -} -if (Symbol.dispose) PkDecryption.prototype[Symbol.dispose] = PkDecryption.prototype.free; - -/** - * A class representing a public-key encryption instance. - * - * This implements the encryption part of the - * `m.megolm_backup.v1.curve25519-aes-sha2` algorithm described in the Matrix - * {@link https://spec.matrix.org/v1.11/client-server-api/#backup-algorithm-mmegolm_backupv1curve25519-aes-sha2 | spec}. - * - * @see {@link PkDecryption} - * - * More details can be found in the official {@link https://docs.rs/vodozemac/latest/vodozemac/pk_encryption/ | vodozemac documentation}. - */ -export class PkEncryption { - static __wrap(ptr) { - const obj = Object.create(PkEncryption.prototype); - obj.__wbg_ptr = ptr; - PkEncryptionFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - PkEncryptionFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_pkencryption_free(ptr, 0); - } - /** - * Encrypts a byte message and returns an encrypted {@link PkMessage}. - * @param {Uint8Array} message - * @returns {PkMessage} - */ - encrypt(message) { - const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.pkencryption_encrypt(this.__wbg_ptr, ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return PkMessage.__wrap(ret[0]); - } - /** - * Encrypts a string message and returns an encrypted {@link PkMessage}. - * @param {string} message - * @returns {PkMessage} - */ - encryptString(message) { - const ptr0 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.pkencryption_encryptString(this.__wbg_ptr, ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return PkMessage.__wrap(ret[0]); - } - /** - * Creates a new `PkEncryption` instance from a public key. - * @param {Curve25519PublicKey} public_key - * @returns {PkEncryption} - */ - static fromKey(public_key) { - _assertClass(public_key, Curve25519PublicKey); - const ret = wasm.pkencryption_fromKey(public_key.__wbg_ptr); - return PkEncryption.__wrap(ret); - } -} -if (Symbol.dispose) PkEncryption.prototype[Symbol.dispose] = PkEncryption.prototype.free; - -/** - * A class representing an encrypted message using {@link PkEncryption}. - */ -export class PkMessage { - static __wrap(ptr) { - const obj = Object.create(PkMessage.prototype); - obj.__wbg_ptr = ptr; - PkMessageFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - PkMessageFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_pkmessage_free(ptr, 0); - } - /** - * Returns the raw ciphertext as a `Uint8Array`. - * @returns {Uint8Array} - */ - ciphertext() { - const ret = wasm.pkmessage_ciphertext(this.__wbg_ptr); - var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - return v1; - } - /** - * Returns the ephemeral public key used during encryption. - * @returns {Curve25519PublicKey} - */ - ephemeralKey() { - const ret = wasm.pkmessage_ephemeralKey(this.__wbg_ptr); - return Curve25519PublicKey.__wrap(ret); - } - /** - * Constructs a `PkMessage` from a base64-encoded representation. - * @param {Base64EncodedPkMessage} message - * @returns {PkMessage} - */ - static fromBase64(message) { - _assertClass(message, Base64EncodedPkMessage); - const ret = wasm.pkmessage_fromBase64(message.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return PkMessage.__wrap(ret[0]); - } - /** - * Constructs a `PkMessage` from its parts: ciphertext, MAC, and ephemeral - * key. - * @param {Uint8Array} ciphertext - * @param {Uint8Array} mac - * @param {Curve25519PublicKey} ephemeral_key - * @returns {PkMessage} - */ - static fromParts(ciphertext, mac, ephemeral_key) { - const ptr0 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passArray8ToWasm0(mac, wasm.__wbindgen_malloc); - const len1 = WASM_VECTOR_LEN; - _assertClass(ephemeral_key, Curve25519PublicKey); - const ret = wasm.pkmessage_fromParts(ptr0, len0, ptr1, len1, ephemeral_key.__wbg_ptr); - return PkMessage.__wrap(ret); - } - /** - * Returns the raw message authentication code (MAC) as a `Uint8Array`. - * @returns {Uint8Array} - */ - mac() { - const ret = wasm.pkmessage_mac(this.__wbg_ptr); - var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - return v1; - } - /** - * Converts the `PkMessage` into a base64-encoded representation. - * @returns {Base64EncodedPkMessage} - */ - toBase64() { - const ret = wasm.pkmessage_toBase64(this.__wbg_ptr); - return Base64EncodedPkMessage.__wrap(ret); - } -} -if (Symbol.dispose) PkMessage.prototype[Symbol.dispose] = PkMessage.prototype.free; - -/** - * Represents a to-device event sent in the clear. - */ -export class PlainTextToDeviceEvent { - static __wrap(ptr) { - const obj = Object.create(PlainTextToDeviceEvent.prototype); - obj.__wbg_ptr = ptr; - PlainTextToDeviceEventFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - PlainTextToDeviceEventFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_plaintexttodeviceevent_free(ptr, 0); - } - /** - * The to-device message, containing `type`, `sender` and `content` fields, - * encoded as JSON. - * @returns {string} - */ - get rawEvent() { - const ret = wasm.__wbg_get_plaintexttodeviceevent_rawEvent(this.__wbg_ptr); - return ret; - } - /** - * The type of processed to-device event. Always {@link - * ProcessedToDeviceEventType.PlainText} for this type. - * @returns {ProcessedToDeviceEventType} - */ - get type() { - const ret = wasm.plaintexttodeviceevent_type(this.__wbg_ptr); - return ret; - } -} -if (Symbol.dispose) PlainTextToDeviceEvent.prototype[Symbol.dispose] = PlainTextToDeviceEvent.prototype.free; - -/** - * The type of a {@link ProcessedToDeviceEvent}. - * @enum {0 | 1 | 2 | 3} - */ -export const ProcessedToDeviceEventType = Object.freeze({ - /** - * A successfully-decrypted encrypted to-device message. - */ - Decrypted: 0, "0": "Decrypted", - /** - * An encrypted to-device message which could not be decrypted. - */ - UnableToDecrypt: 1, "1": "UnableToDecrypt", - /** - * An unencrypted to-device message (sent in clear). - */ - PlainText: 2, "2": "PlainText", - /** - * An invalid to-device message that was ignored because it is missing some - * required information to be processed (like no event `type` for - * example) - */ - Invalid: 3, "3": "Invalid", -}); - -/** - * A request that will upload a dehydrated device to the server. - */ -export class PutDehydratedDeviceRequest { - static __wrap(ptr) { - const obj = Object.create(PutDehydratedDeviceRequest.prototype); - obj.__wbg_ptr = ptr; - PutDehydratedDeviceRequestFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - PutDehydratedDeviceRequestFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_putdehydrateddevicerequest_free(ptr, 0); - } - /** - * A JSON-encoded object containing the rest of the payload: `rooms`. - * - * It represents the body of the HTTP request. - * @returns {string} - */ - get body() { - const ret = wasm.__wbg_get_putdehydrateddevicerequest_body(this.__wbg_ptr); - return ret; - } - /** - * Create a new `PutDehydratedDeviceRequest` - * @param {string} body - */ - constructor(body) { - const ret = wasm.putdehydrateddevicerequest_new(body); - this.__wbg_ptr = ret; - PutDehydratedDeviceRequestFinalization.register(this, this.__wbg_ptr, this); - return this; - } -} -if (Symbol.dispose) PutDehydratedDeviceRequest.prototype[Symbol.dispose] = PutDehydratedDeviceRequest.prototype.free; - -/** - * QR code based verification. - */ -export class Qr { - static __wrap(ptr) { - const obj = Object.create(Qr.prototype); - obj.__wbg_ptr = ptr; - QrFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - QrFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_qr_free(ptr, 0); - } - /** - * Cancel the verification flow. - * - * Returns either an `OutgoingVerificationRequest` which should be sent - * out, or `undefined` if the verification is already cancelled. - * @returns {OutgoingVerificationRequest | undefined} - */ - cancel() { - const ret = wasm.qr_cancel(this.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Get info about the cancellation if the verification flow has - * been cancelled. - * @returns {CancelInfo | undefined} - */ - cancelInfo() { - const ret = wasm.qr_cancelInfo(this.__wbg_ptr); - return ret === 0 ? undefined : CancelInfo.__wrap(ret); - } - /** - * Cancel the verification. - * - * This cancels the verification with given code (e.g. `m.user`). - * - * Returns either an `OutgoingVerificationRequest` which should be sent - * out, or `undefined` if the verification is already cancelled. - * @param {string} code - * @returns {OutgoingVerificationRequest | undefined} - */ - cancelWithCode(code) { - const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.qr_cancelWithCode(this.__wbg_ptr, ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Confirm that the other side has scanned our QR code. - * - * Returns either an `OutgoingVerificationRequest` which should be sent - * out, or `undefined` if the verification is already confirmed. - * @returns {OutgoingVerificationRequest | undefined} - */ - confirmScanning() { - const ret = wasm.qr_confirmScanning(this.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Get the unique ID that identifies this QR verification flow, - * be either a to-device request ID or a room event ID. - * @returns {string} - */ - get flowId() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.qr_flowId(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Has the scanning of the QR code been confirmed by us? - * @returns {boolean} - */ - hasBeenConfirmed() { - const ret = wasm.qr_hasBeenConfirmed(this.__wbg_ptr); - return ret !== 0; - } - /** - * Has the QR verification been scanned by the other side. - * - * When the verification object is in this state it’s required - * that the user confirms that the other side has scanned the QR - * code. - * @returns {boolean} - */ - hasBeenScanned() { - const ret = wasm.qr_hasBeenScanned(this.__wbg_ptr); - return ret !== 0; - } - /** - * Has the verification flow been cancelled? - * @returns {boolean} - */ - isCancelled() { - const ret = wasm.qr_isCancelled(this.__wbg_ptr); - return ret !== 0; - } - /** - * Has the verification flow completed? - * @returns {boolean} - */ - isDone() { - const ret = wasm.qr_isDone(this.__wbg_ptr); - return ret !== 0; - } - /** - * Is this a verification that is verifying one of our own devices? - * @returns {boolean} - */ - isSelfVerification() { - const ret = wasm.qr_isSelfVerification(this.__wbg_ptr); - return ret !== 0; - } - /** - * Get the device ID of the other side. - * @returns {DeviceId} - */ - get otherDeviceId() { - const ret = wasm.qr_otherDeviceId(this.__wbg_ptr); - return DeviceId.__wrap(ret); - } - /** - * Get the user id of the other user that is participating in - * this verification flow. - * @returns {UserId} - */ - get otherUserId() { - const ret = wasm.qr_otherUserId(this.__wbg_ptr); - return UserId.__wrap(ret); - } - /** - * Notify the other side that we have successfully scanned the QR - * code and that the QR verification flow can start. - * - * This will return some OutgoingContent if the object is in the - * correct state to start the verification flow, otherwise None. - * @returns {OutgoingVerificationRequest | undefined} - */ - reciprocate() { - const ret = wasm.qr_reciprocate(this.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Have we successfully scanned the QR code and are able to send - * a reciprocation event? - * @returns {boolean} - */ - reciprocated() { - const ret = wasm.qr_reciprocated(this.__wbg_ptr); - return ret !== 0; - } - /** - * Register a callback which will be called whenever there is an update to - * the request - * - * The `callback` is called with no parameters. - * @param {() => Promise} callback - */ - registerChangesCallback(callback) { - wasm.qr_registerChangesCallback(this.__wbg_ptr, callback); - } - /** - * Get the room id if the verification is happening inside a - * room. - * @returns {RoomId | undefined} - */ - get roomId() { - const ret = wasm.qr_roomId(this.__wbg_ptr); - return ret === 0 ? undefined : RoomId.__wrap(ret); - } - /** - * Get the current state of this request. - * - * Returns a `QrState`. - * @returns {QrState} - */ - state() { - const ret = wasm.qr_state(this.__wbg_ptr); - return ret; - } - /** - * Generate a the raw bytes that should be encoded as a QR code - * is representing this verification flow. - * - * The `to_qr_code` method can be used to instead output a QrCode - * object that can be rendered. - * @returns {Uint8ClampedArray} - */ - toBytes() { - const ret = wasm.qr_toBytes(this.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Generate a QR code object that is representing this - * verification flow. - * - * The QrCode can then be rendered as an image or as an unicode - * string. - * - * The `to_bytes` method can be used to instead output the raw - * bytes that should be encoded as a QR code. - * - * Returns a `QrCode`. - * @returns {QrCode} - */ - toQrCode() { - const ret = wasm.qr_toQrCode(this.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return QrCode.__wrap(ret[0]); - } - /** - * Get our own user ID. - * @returns {UserId} - */ - get userId() { - const ret = wasm.qr_userId(this.__wbg_ptr); - return UserId.__wrap(ret); - } - /** - * Did we initiate the verification request? - * @returns {boolean} - */ - weStarted() { - const ret = wasm.qr_weStarted(this.__wbg_ptr); - return ret !== 0; - } -} -if (Symbol.dispose) Qr.prototype[Symbol.dispose] = Qr.prototype.free; - -/** - * A QR code. - */ -export class QrCode { - static __wrap(ptr) { - const obj = Object.create(QrCode.prototype); - obj.__wbg_ptr = ptr; - QrCodeFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - QrCodeFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_qrcode_free(ptr, 0); - } - /** - * Render the QR code into a `Uint8ClampedArray` where 1 represents a - * dark pixel and 0 a white pixel. - * @returns {Uint8ClampedArray} - */ - renderIntoBuffer() { - const ret = wasm.qrcode_renderIntoBuffer(this.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } -} -if (Symbol.dispose) QrCode.prototype[Symbol.dispose] = QrCode.prototype.free; - -/** - * Data for the QR code login mechanism. - * - * The {@link QrCodeData} can be serialized and encoded as a QR code or it can - * be decoded from a QR code. - * - * This type supports both the format originally speicied in - * {link https://github.com/matrix-org/matrix-spec-proposals/pull/4108 MSC4108} as well as the - * updated format found in - * {link https://github.com/matrix-org/matrix-spec-proposals/pull/4388 MSC4388}. - */ -export class QrCodeData { - static __wrap(ptr) { - const obj = Object.create(QrCodeData.prototype); - obj.__wbg_ptr = ptr; - QrCodeDataFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - QrCodeDataFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_qrcodedata_free(ptr, 0); - } - /** - * Attempt to decode a base64 encoded string into a {@link QrCodeData} - * object. - * @param {string} data - * @returns {QrCodeData} - */ - static fromBase64(data) { - const ptr0 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.qrcodedata_fromBase64(ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return QrCodeData.__wrap(ret[0]); - } - /** - * Attempt to decode a slice of bytes into a {@link QrCodeData} object. - * - * The slice of bytes would generally be returned by a QR code decoder. - * @param {Uint8Array} bytes - * @returns {QrCodeData} - */ - static fromBytes(bytes) { - const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.qrcodedata_fromBytes(ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return QrCodeData.__wrap(ret[0]); - } - /** - * Get the intent-specific data embedded in the {@link QrCodeData}. - * @returns {QrCodeIntentData} - */ - get intentData() { - const ret = wasm.qrcodedata_intentData(this.__wbg_ptr); - return QrCodeIntentData.__wrap(ret); - } - /** - * Get the mode of this {@link QrCodeData} instance. - * @returns {QrCodeIntent} - */ - get mode() { - const ret = wasm.qrcodedata_mode(this.__wbg_ptr); - return ret; - } - /** - * Create new {@link QrCodeData} from a given public key, a rendezvous URL - * and, optionally, a server name for the homeserver. - * - * If a server name is given, then the {@link QrCodeData} mode will be - * {@link QrCodeIntent.Reciprocate}, i.e. the QR code will contain data for - * the existing device to display the QR code. - * - * If no server name is given, the {@link QrCodeData} mode will be - * {@link QrCodeIntent.Login}, i.e. the QR code will contain data for the - * new device to display the QR code. - * @param {Curve25519PublicKey} public_key - * @param {string} rendezvous_url - * @param {string | null} [server_name] - */ - constructor(public_key, rendezvous_url, server_name) { - _assertClass(public_key, Curve25519PublicKey); - var ptr0 = public_key.__destroy_into_raw(); - const ptr1 = passStringToWasm0(rendezvous_url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - var ptr2 = isLikeNone(server_name) ? 0 : passStringToWasm0(server_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len2 = WASM_VECTOR_LEN; - const ret = wasm.qrcodedata_new(ptr0, ptr1, len1, ptr2, len2); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - this.__wbg_ptr = ret[0]; - QrCodeDataFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Create new {@link QrCodeData} from a given public key, a rendezvous ID - * and, a base homeserver URL. - * - * This creates a QR code which conforms to - * {@link https://github.com/matrix-org/matrix-spec-proposals/pull/4388 MSC4388} of the data - * format for QR login. - * @param {Curve25519PublicKey} public_key - * @param {string} rendezvous_id - * @param {string} base_url - * @param {QrCodeIntent} intent - * @returns {QrCodeData} - */ - static newMsc4388(public_key, rendezvous_id, base_url, intent) { - _assertClass(public_key, Curve25519PublicKey); - var ptr0 = public_key.__destroy_into_raw(); - const ptr1 = passStringToWasm0(rendezvous_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(base_url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ret = wasm.qrcodedata_newMsc4388(ptr0, ptr1, len1, ptr2, len2, intent); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return QrCodeData.__wrap(ret[0]); - } - /** - * Get the Curve25519 public key embedded in the {@link QrCodeData}. - * - * This Curve25519 public key should be used to establish an - * [HPKE](https://www.rfc-editor.org/rfc/rfc9180.html) - * (Hybrid Public Key Encryption) channel with the other device. - * @returns {Curve25519PublicKey} - */ - get publicKey() { - const ret = wasm.qrcodedata_publicKey(this.__wbg_ptr); - return Curve25519PublicKey.__wrap(ret); - } - /** - * Get the URL of the rendezvous server which will be used to exchange - * messages between the two devices. - * @returns {string | undefined} - */ - get rendezvousUrl() { - const ret = wasm.qrcodedata_rendezvousUrl(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * Get the server name of the homeserver which the new device will be - * logged in to. - * - * This will be only available if the existing device has generated the QR - * code and the new device is the one scanning the QR code. - * @returns {string | undefined} - */ - get serverName() { - const ret = wasm.qrcodedata_serverName(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * Encode the {@link QrCodeData} into a string using base64. - * - * This format can be used for debugging purposes and the - * [`QrcodeData::from_base64()`] method can be used to parse the string - * again. - * @returns {string} - */ - toBase64() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.qrcodedata_toBase64(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Encode the {@link QrCodeData} into a list of bytes. - * - * The list of bytes can be used by a QR code generator to create an image - * containing a QR code. - * @returns {Uint8Array} - */ - toBytes() { - const ret = wasm.qrcodedata_toBytes(this.__wbg_ptr); - var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - return v1; - } -} -if (Symbol.dispose) QrCodeData.prototype[Symbol.dispose] = QrCodeData.prototype.free; - -/** - * The mode of the QR code login. - * - * The QR code login mechanism supports both, the new device, as well as the - * existing device to display the QR code. - * - * The different modes have an explicit one-byte identifier which gets added to - * the QR code data. - * @enum {0 | 1} - */ -export const QrCodeIntent = Object.freeze({ - /** - * The new device is displaying the QR code. - */ - Login: 0, "0": "Login", - /** - * The existing device is displaying the QR code. - */ - Reciprocate: 1, "1": "Reciprocate", -}); - -/** - * Intent and MSC-specific data class for the QR code login support. - */ -export class QrCodeIntentData { - static __wrap(ptr) { - const obj = Object.create(QrCodeIntentData.prototype); - obj.__wbg_ptr = ptr; - QrCodeIntentDataFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - QrCodeIntentDataFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_qrcodeintentdata_free(ptr, 0); - } - /** - * The MSC4108-specific intent data. - * - * This will not be `null` only if the {@link QrCodeData} contains data as - * specified in the QR code format of MSC4108. Otherwise it will contain - * MSC4388-specific intent data. - * @returns {Msc4108IntentData | undefined} - */ - get msc4108() { - const ret = wasm.__wbg_get_qrcodeintentdata_msc4108(this.__wbg_ptr); - return ret === 0 ? undefined : Msc4108IntentData.__wrap(ret); - } - /** - * The MSC4833-specific intent data. - * - * This will not be `null` only if the {@link QrCodeData} contains data as - * specified in the QR code format of MSC4388. Otherwise it will contain - * MSC4108-specific intent data. - * @returns {Msc4388IntentData | undefined} - */ - get msc4388() { - const ret = wasm.__wbg_get_qrcodeintentdata_msc4388(this.__wbg_ptr); - return ret === 0 ? undefined : Msc4388IntentData.__wrap(ret); - } - /** - * The MSC4108-specific intent data. - * - * This will not be `null` only if the {@link QrCodeData} contains data as - * specified in the QR code format of MSC4108. Otherwise it will contain - * MSC4388-specific intent data. - * @param {Msc4108IntentData | null} [arg0] - */ - set msc4108(arg0) { - let ptr0 = 0; - if (!isLikeNone(arg0)) { - _assertClass(arg0, Msc4108IntentData); - ptr0 = arg0.__destroy_into_raw(); - } - wasm.__wbg_set_qrcodeintentdata_msc4108(this.__wbg_ptr, ptr0); - } - /** - * The MSC4833-specific intent data. - * - * This will not be `null` only if the {@link QrCodeData} contains data as - * specified in the QR code format of MSC4388. Otherwise it will contain - * MSC4108-specific intent data. - * @param {Msc4388IntentData | null} [arg0] - */ - set msc4388(arg0) { - let ptr0 = 0; - if (!isLikeNone(arg0)) { - _assertClass(arg0, Msc4388IntentData); - ptr0 = arg0.__destroy_into_raw(); - } - wasm.__wbg_set_qrcodeintentdata_msc4388(this.__wbg_ptr, ptr0); - } -} -if (Symbol.dispose) QrCodeIntentData.prototype[Symbol.dispose] = QrCodeIntentData.prototype.free; - -/** - * A scanned QR code. - */ -export class QrCodeScan { - static __wrap(ptr) { - const obj = Object.create(QrCodeScan.prototype); - obj.__wbg_ptr = ptr; - QrCodeScanFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - QrCodeScanFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_qrcodescan_free(ptr, 0); - } - /** - * Parse the decoded payload of a QR code in byte slice form. - * - * This method is useful if you would like to do your own custom QR code - * decoding. - * @param {Uint8ClampedArray} buffer - * @returns {QrCodeScan} - */ - static fromBytes(buffer) { - const ret = wasm.qrcodescan_fromBytes(buffer); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return QrCodeScan.__wrap(ret[0]); - } -} -if (Symbol.dispose) QrCodeScan.prototype[Symbol.dispose] = QrCodeScan.prototype.free; - -/** - * List of `Qr` states - * @enum {0 | 1 | 2 | 3 | 4 | 5} - */ -export const QrState = Object.freeze({ - /** - * We have received the other device's details (from the - * `m.key.verification.request` or `m.key.verification.ready`) and - * established the shared secret, so can - * display the QR code. - */ - Created: 0, "0": "Created", - /** - * The other side has scanned our QR code and sent an - * `m.key.verification.start` message with `method: m.reciprocate.v1` with - * matching shared secret. - */ - Scanned: 1, "1": "Scanned", - /** - * Our user has confirmed that the other device scanned successfully. We - * have sent an `m.key.verification.done`. - */ - Confirmed: 2, "2": "Confirmed", - /** - * We have scanned the other side's QR code and are able to send a - * `m.key.verification.start` message with `method: m.reciprocate.v1`. - * - * Call `Qr::reciprocate` to build the start message. - * - * Note that, despite the name of this state, we have not necessarily - * yet sent the `m.reciprocate.v1` message. - */ - Reciprocated: 3, "3": "Reciprocated", - /** - * Verification complete: we have received an `m.key.verification.done` - * from the other side. - */ - Done: 4, "4": "Done", - /** - * Verification cancelled or failed. - */ - Cancelled: 5, "5": "Cancelled", -}); - -/** - * A rehydrated device - * - * This device can receive to-device events to get room keys that were send to - * it. - */ -export class RehydratedDevice { - static __wrap(ptr) { - const obj = Object.create(RehydratedDevice.prototype); - obj.__wbg_ptr = ptr; - RehydratedDeviceFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - RehydratedDeviceFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_rehydrateddevice_free(ptr, 0); - } - /** - * Receive the to-device events that sent to the dehydrated device - * - * The rehydrated device will decrypt the events and pass the room keys - * into the `OlmMachine`. - * - * # Arguments - * - * * `to_device_events` is a JSON-encoded result of the `events` array from - * `/dehydrated_device/{device_id}/events`. - * * `decryption_settings`: Optionally, the settings to use when decrypting - * to-device events. If not set, to-device events will be decrypted with - * a {@link TrustRequirement} of `Untrusted`. - * - * Returns an array of `RoomKeyInfo`, indicating the room keys that were - * received. - * @param {string} to_device_events - * @param {DecryptionSettings | null} [decryption_settings] - * @returns {Promise} - */ - receiveEvents(to_device_events, decryption_settings) { - const ptr0 = passStringToWasm0(to_device_events, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - let ptr1 = 0; - if (!isLikeNone(decryption_settings)) { - _assertClass(decryption_settings, DecryptionSettings); - ptr1 = decryption_settings.__destroy_into_raw(); - } - const ret = wasm.rehydrateddevice_receiveEvents(this.__wbg_ptr, ptr0, len0, ptr1); - return ret; - } -} -if (Symbol.dispose) RehydratedDevice.prototype[Symbol.dispose] = RehydratedDevice.prototype.free; - -/** - * Represent the type of a request. - * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6} - */ -export const RequestType = Object.freeze({ - /** - * Represents a `KeysUploadRequest`. - */ - KeysUpload: 0, "0": "KeysUpload", - /** - * Represents a `KeysQueryRequest`. - */ - KeysQuery: 1, "1": "KeysQuery", - /** - * Represents a `KeysClaimRequest`. - */ - KeysClaim: 2, "2": "KeysClaim", - /** - * Represents a `ToDeviceRequest`. - */ - ToDevice: 3, "3": "ToDevice", - /** - * Represents a `SignatureUploadRequest`. - */ - SignatureUpload: 4, "4": "SignatureUpload", - /** - * Represents a `RoomMessageRequest`. - */ - RoomMessage: 5, "5": "RoomMessage", - /** - * Represents a `KeysBackupRequest`. - */ - KeysBackup: 6, "6": "KeysBackup", -}); - -/** - * A Matrix [room ID]. - * - * [room ID]: https://spec.matrix.org/v1.2/appendices/#room-ids-and-event-ids - */ -export class RoomId { - static __wrap(ptr) { - const obj = Object.create(RoomId.prototype); - obj.__wbg_ptr = ptr; - RoomIdFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - static __unwrap(jsValue) { - if (!(jsValue instanceof RoomId)) { - return 0; - } - return jsValue.__destroy_into_raw(); - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - RoomIdFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_roomid_free(ptr, 0); - } - /** - * Parse/validate and create a new `RoomId`. - * @param {string} id - */ - constructor(id) { - const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.roomid_new(ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - this.__wbg_ptr = ret[0]; - RoomIdFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Return the room ID as a string. - * @returns {string} - */ - toString() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.roomid_toString(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } -} -if (Symbol.dispose) RoomId.prototype[Symbol.dispose] = RoomId.prototype.free; - -/** - * Struct holding the number of room keys we have. - */ -export class RoomKeyCounts { - static __wrap(ptr) { - const obj = Object.create(RoomKeyCounts.prototype); - obj.__wbg_ptr = ptr; - RoomKeyCountsFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - RoomKeyCountsFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_roomkeycounts_free(ptr, 0); - } - /** - * The number of backed up room keys. - * @returns {number} - */ - get backedUp() { - const ret = wasm.__wbg_get_roomkeycounts_backedUp(this.__wbg_ptr); - return ret; - } - /** - * The total number of room keys. - * @returns {number} - */ - get total() { - const ret = wasm.__wbg_get_roomkeycounts_total(this.__wbg_ptr); - return ret; - } - /** - * The number of backed up room keys. - * @param {number} arg0 - */ - set backedUp(arg0) { - wasm.__wbg_set_roomkeycounts_backedUp(this.__wbg_ptr, arg0); - } - /** - * The total number of room keys. - * @param {number} arg0 - */ - set total(arg0) { - wasm.__wbg_set_roomkeycounts_total(this.__wbg_ptr, arg0); - } -} -if (Symbol.dispose) RoomKeyCounts.prototype[Symbol.dispose] = RoomKeyCounts.prototype.free; - -/** - * The result of a call to {@link OlmMachine.importExportedRoomKeys} or - * {@link OlmMachine.importBackedUpRoomKeys}. - */ -export class RoomKeyImportResult { - static __wrap(ptr) { - const obj = Object.create(RoomKeyImportResult.prototype); - obj.__wbg_ptr = ptr; - RoomKeyImportResultFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - RoomKeyImportResultFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_roomkeyimportresult_free(ptr, 0); - } - /** - * The number of room keys that were imported. - * @returns {number} - */ - get importedCount() { - const ret = wasm.__wbg_get_roomkeyimportresult_importedCount(this.__wbg_ptr); - return ret >>> 0; - } - /** - * The total number of room keys that were found in the export. - * @returns {number} - */ - get totalCount() { - const ret = wasm.__wbg_get_roomkeyimportresult_totalCount(this.__wbg_ptr); - return ret >>> 0; - } - /** - * The keys that were imported. - * - * A Map from room id to a Map of the sender key to a Set of session ids. - * - * Typescript type: `Map>`. - * @returns {Map>>} - */ - keys() { - const ret = wasm.roomkeyimportresult_keys(this.__wbg_ptr); - return ret; - } -} -if (Symbol.dispose) RoomKeyImportResult.prototype[Symbol.dispose] = RoomKeyImportResult.prototype.free; - -/** - * Information on a room key that has been received or imported. - */ -export class RoomKeyInfo { - static __wrap(ptr) { - const obj = Object.create(RoomKeyInfo.prototype); - obj.__wbg_ptr = ptr; - RoomKeyInfoFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - RoomKeyInfoFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_roomkeyinfo_free(ptr, 0); - } - /** - * The {@link EncryptionAlgorithm} that this key is used for. Will be one - * of the `m.megolm.*` algorithms. - * @returns {EncryptionAlgorithm} - */ - get algorithm() { - const ret = wasm.roomkeyinfo_algorithm(this.__wbg_ptr); - return ret; - } - /** - * The room where the key is used. - * @returns {RoomId} - */ - get roomId() { - const ret = wasm.roomkeyinfo_roomId(this.__wbg_ptr); - return RoomId.__wrap(ret); - } - /** - * The Curve25519 key of the device which initiated the session originally. - * @returns {Curve25519PublicKey} - */ - get senderKey() { - const ret = wasm.roomkeyinfo_senderKey(this.__wbg_ptr); - return Curve25519PublicKey.__wrap(ret); - } - /** - * The ID of the session that the key is for. - * @returns {string} - */ - get sessionId() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.roomkeyinfo_sessionId(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } -} -if (Symbol.dispose) RoomKeyInfo.prototype[Symbol.dispose] = RoomKeyInfo.prototype.free; - -/** - * Information on a received `m.room_key.withheld` event. - */ -export class RoomKeyWithheldInfo { - static __wrap(ptr) { - const obj = Object.create(RoomKeyWithheldInfo.prototype); - obj.__wbg_ptr = ptr; - RoomKeyWithheldInfoFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - RoomKeyWithheldInfoFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_roomkeywithheldinfo_free(ptr, 0); - } - /** - * The encryption algorithm of the session that is being withheld. - * - * This may be from an `m.room_key.withheld` event, or from a shared room - * key bundle under MSC4268. - * @returns {EncryptionAlgorithm} - */ - get algorithm() { - const ret = wasm.roomkeywithheldinfo_algorithm(this.__wbg_ptr); - return ret; - } - /** - * The room ID of the session that is being withheld. - * @returns {RoomId} - */ - get roomId() { - const ret = wasm.roomkeywithheldinfo_roomId(this.__wbg_ptr); - return RoomId.__wrap(ret); - } - /** - * The User ID of the sender of the withheld information. - * - * This may be the sender of an `m.room_key.withheld` event, or the sender - * of a shared room key bundle under MSC4268. - * @returns {UserId} - */ - get sender() { - const ret = wasm.roomkeywithheldinfo_sender(this.__wbg_ptr); - return UserId.__wrap(ret); - } - /** - * The session ID of the session that is being withheld. - * @returns {string} - */ - get sessionId() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.roomkeywithheldinfo_sessionId(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The `code` indicating why the key was withheld, such as `m.unverified`. - * - * This may be from an `m.room_key.withheld` event (such as - * `m.unverified`), or from a shared room key bundle under MSC4268. - * @returns {string} - */ - get withheldCode() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.roomkeywithheldinfo_withheldCode(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } -} -if (Symbol.dispose) RoomKeyWithheldInfo.prototype[Symbol.dispose] = RoomKeyWithheldInfo.prototype.free; - -/** - * A customized owned request type for sending out room messages - * ([specification]). - * - * [specification]: https://spec.matrix.org/unstable/client-server-api/#put_matrixclientv3roomsroomidsendeventtypetxnid - */ -export class RoomMessageRequest { - static __wrap(ptr) { - const obj = Object.create(RoomMessageRequest.prototype); - obj.__wbg_ptr = ptr; - RoomMessageRequestFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - RoomMessageRequestFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_roommessagerequest_free(ptr, 0); - } - /** - * A JSON-encoded object containing the message's content. - * @returns {string} - */ - get body() { - const ret = wasm.__wbg_get_roommessagerequest_body(this.__wbg_ptr); - return ret; - } - /** - * A string representing the type of event to be sent. - * @returns {string} - */ - get event_type() { - const ret = wasm.__wbg_get_roommessagerequest_event_type(this.__wbg_ptr); - return ret; - } - /** - * The request ID. - * @returns {string} - */ - get id() { - const ret = wasm.__wbg_get_roommessagerequest_id(this.__wbg_ptr); - return ret; - } - /** - * A string representing the room to send the event to. - * @returns {string} - */ - get room_id() { - const ret = wasm.__wbg_get_roommessagerequest_room_id(this.__wbg_ptr); - return ret; - } - /** - * A string representing the transaction ID for this event. - * - * Clients should generate an ID unique across requests with the same - * access token; it will be used by the server to ensure idempotency of - * requests. - * @returns {string} - */ - get txn_id() { - const ret = wasm.__wbg_get_roommessagerequest_txn_id(this.__wbg_ptr); - return ret; - } - /** - * Create a new `RoomMessageRequest`. - * @param {string} id - * @param {string} room_id - * @param {string} txn_id - * @param {string} event_type - * @param {string} content - */ - constructor(id, room_id, txn_id, event_type, content) { - const ret = wasm.roommessagerequest_new(id, room_id, txn_id, event_type, content); - this.__wbg_ptr = ret; - RoomMessageRequestFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Get its request type. - * @returns {RequestType} - */ - get type() { - const ret = wasm.roommessagerequest_type(this.__wbg_ptr); - return ret; - } -} -if (Symbol.dispose) RoomMessageRequest.prototype[Symbol.dispose] = RoomMessageRequest.prototype.free; - -/** - * Information on a room which is waiting for a key bundle to arrive. - */ -export class RoomPendingKeyBundleDetails { - static __wrap(ptr) { - const obj = Object.create(RoomPendingKeyBundleDetails.prototype); - obj.__wbg_ptr = ptr; - RoomPendingKeyBundleDetailsFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - RoomPendingKeyBundleDetailsFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_roompendingkeybundledetails_free(ptr, 0); - } - /** - * The time that the invite was accepted. - * @returns {number} - */ - get inviteAcceptedAtMillis() { - const ret = wasm.roompendingkeybundledetails_inviteAcceptedAtMillis(this.__wbg_ptr); - return ret; - } - /** - * The ID of the user that invited us - * @returns {UserId} - */ - get inviterId() { - const ret = wasm.roompendingkeybundledetails_inviterId(this.__wbg_ptr); - return UserId.__wrap(ret); - } - /** - * The room that is waiting for a key bundle. - * @returns {RoomId} - */ - get roomId() { - const ret = wasm.roompendingkeybundledetails_roomId(this.__wbg_ptr); - return RoomId.__wrap(ret); - } -} -if (Symbol.dispose) RoomPendingKeyBundleDetails.prototype[Symbol.dispose] = RoomPendingKeyBundleDetails.prototype.free; - -/** - * Room encryption settings which are modified by state events or user options - */ -export class RoomSettings { - static __wrap(ptr) { - const obj = Object.create(RoomSettings.prototype); - obj.__wbg_ptr = ptr; - RoomSettingsFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - RoomSettingsFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_roomsettings_free(ptr, 0); - } - /** - * The encryption algorithm that should be used in the room. - * - * Should be one of the members of {@link EncryptionAlgorithm}. - * @returns {EncryptionAlgorithm} - */ - get algorithm() { - const ret = wasm.__wbg_get_roomsettings_algorithm(this.__wbg_ptr); - return ret; - } - /** - * Whether state event encryption is enabled. - * @returns {boolean} - */ - get encryptStateEvents() { - const ret = wasm.__wbg_get_roomsettings_encryptStateEvents(this.__wbg_ptr); - return ret !== 0; - } - /** - * Whether untrusted devices should receive room keys. If this is `false`, - * they will be excluded from the conversation. - * @returns {boolean} - */ - get onlyAllowTrustedDevices() { - const ret = wasm.__wbg_get_roomsettings_onlyAllowTrustedDevices(this.__wbg_ptr); - return ret !== 0; - } - /** - * The maximum number of messages an encryption session should be used for, - * before it is rotated. - * @returns {number | undefined} - */ - get sessionRotationPeriodMessages() { - const ret = wasm.__wbg_get_roomsettings_sessionRotationPeriodMessages(this.__wbg_ptr); - return ret[0] === 0 ? undefined : ret[1]; - } - /** - * The maximum time, in milliseconds, that an encryption session should be - * used for, before it is rotated. - * @returns {number | undefined} - */ - get sessionRotationPeriodMs() { - const ret = wasm.__wbg_get_roomsettings_sessionRotationPeriodMs(this.__wbg_ptr); - return ret[0] === 0 ? undefined : ret[1]; - } - /** - * Create a new `RoomSettings` with default values. - */ - constructor() { - const ret = wasm.roomsettings_new(); - this.__wbg_ptr = ret; - RoomSettingsFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * The encryption algorithm that should be used in the room. - * - * Should be one of the members of {@link EncryptionAlgorithm}. - * @param {EncryptionAlgorithm} arg0 - */ - set algorithm(arg0) { - wasm.__wbg_set_roomsettings_algorithm(this.__wbg_ptr, arg0); - } - /** - * Whether state event encryption is enabled. - * @param {boolean} arg0 - */ - set encryptStateEvents(arg0) { - wasm.__wbg_set_roomsettings_encryptStateEvents(this.__wbg_ptr, arg0); - } - /** - * Whether untrusted devices should receive room keys. If this is `false`, - * they will be excluded from the conversation. - * @param {boolean} arg0 - */ - set onlyAllowTrustedDevices(arg0) { - wasm.__wbg_set_roomsettings_onlyAllowTrustedDevices(this.__wbg_ptr, arg0); - } - /** - * The maximum number of messages an encryption session should be used for, - * before it is rotated. - * @param {number | null} [arg0] - */ - set sessionRotationPeriodMessages(arg0) { - wasm.__wbg_set_roomsettings_sessionRotationPeriodMessages(this.__wbg_ptr, !isLikeNone(arg0), isLikeNone(arg0) ? 0 : arg0); - } - /** - * The maximum time, in milliseconds, that an encryption session should be - * used for, before it is rotated. - * @param {number | null} [arg0] - */ - set sessionRotationPeriodMs(arg0) { - wasm.__wbg_set_roomsettings_sessionRotationPeriodMs(this.__wbg_ptr, !isLikeNone(arg0), isLikeNone(arg0) ? 0 : arg0); - } -} -if (Symbol.dispose) RoomSettings.prototype[Symbol.dispose] = RoomSettings.prototype.free; - -/** - * Short Authentication String (SAS) verification. - */ -export class Sas { - static __wrap(ptr) { - const obj = Object.create(Sas.prototype); - obj.__wbg_ptr = ptr; - SasFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - SasFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_sas_free(ptr, 0); - } - /** - * Accept the SAS verification. - * - * This does nothing (and returns `undefined`) if the verification was - * already accepted, otherwise it returns an `OutgoingVerificationRequest` - * that needs to be sent out. - * @returns {OutgoingVerificationRequest | undefined} - */ - accept() { - const ret = wasm.sas_accept(this.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Are we in a state where we can show the short auth string? - * @returns {boolean} - */ - canBePresented() { - const ret = wasm.sas_canBePresented(this.__wbg_ptr); - return ret !== 0; - } - /** - * Cancel the verification. - * - * Returns either an `OutgoingVerificationRequest` which should be sent - * out, or `undefined` if the verification is already cancelled. - * @returns {OutgoingVerificationRequest | undefined} - */ - cancel() { - const ret = wasm.sas_cancel(this.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Get info about the cancellation if the verification flow has - * been cancelled. - * @returns {CancelInfo | undefined} - */ - cancelInfo() { - const ret = wasm.sas_cancelInfo(this.__wbg_ptr); - return ret === 0 ? undefined : CancelInfo.__wrap(ret); - } - /** - * Cancel the verification. - * - * This cancels the verification with given code (e.g. `m.user`). - * - * Returns either an `OutgoingVerificationRequest` which should be sent - * out, or `undefined` if the verification is already cancelled. - * @param {string} code - * @returns {OutgoingVerificationRequest | undefined} - */ - cancelWithCode(code) { - const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.sas_cancelWithCode(this.__wbg_ptr, ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Confirm the SAS verification. - * - * This confirms that the short auth strings match on both sides. - * - * Does nothing if we’re not in a state where we can confirm the - * short auth string. - * - * Returns a `Promise` for an array of `OutgoingVerificationRequest`s. - * @returns {Promise} - */ - confirm() { - const ret = wasm.sas_confirm(this.__wbg_ptr); - return ret; - } - /** - * Get the decimal version of the short auth string. - * - * Returns None if we can’t yet present the short auth string, - * otherwise a tuple containing three 4-digit integers that - * represent the short auth string. - * @returns {Uint16Array | undefined} - */ - decimals() { - const ret = wasm.sas_decimals(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getArrayU16FromWasm0(ret[0], ret[1]).slice(); - wasm.__wbindgen_free(ret[0], ret[1] * 2, 2); - } - return v1; - } - /** - * Get our own device ID. - * @returns {DeviceId} - */ - get deviceId() { - const ret = wasm.sas_deviceId(this.__wbg_ptr); - return DeviceId.__wrap(ret); - } - /** - * Get the emoji version of the short auth string. - * - * Returns `undefined` if we can't yet present the short auth string, - * otherwise an array of seven `Emoji` objects. - * @returns {Emoji[] | undefined} - */ - emoji() { - const ret = wasm.sas_emoji(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getArrayJsValueFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 4, 4); - } - return v1; - } - /** - * Get the index of the emoji representing the short auth string - * - * Returns `undefined` if we can’t yet present the short auth - * string, otherwise seven `u8` numbers in the range from 0 to 63 - * inclusive which can be converted to an emoji using [the - * relevant specification - * entry](https://spec.matrix.org/unstable/client-server-api/#sas-method-emoji). - * @returns {Uint8Array | undefined} - */ - emojiIndex() { - const ret = wasm.sas_emojiIndex(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } - /** - * Get the unique ID that identifies this SAS verification flow, - * be either a to-device request ID or a room event ID. - * @returns {string} - */ - get flowId() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.sas_flowId(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Has the verification been accepted by both parties? - * @returns {boolean} - */ - hasBeenAccepted() { - const ret = wasm.sas_hasBeenAccepted(this.__wbg_ptr); - return ret !== 0; - } - /** - * Have we confirmed that the short auth string matches? - * @returns {boolean} - */ - haveWeConfirmed() { - const ret = wasm.sas_haveWeConfirmed(this.__wbg_ptr); - return ret !== 0; - } - /** - * Is the SAS flow cancelled? - * @returns {boolean} - */ - isCancelled() { - const ret = wasm.sas_isCancelled(this.__wbg_ptr); - return ret !== 0; - } - /** - * Is the SAS flow done? - * @returns {boolean} - */ - isDone() { - const ret = wasm.sas_isDone(this.__wbg_ptr); - return ret !== 0; - } - /** - * Is this a verification that is verifying one of our own - * devices? - * @returns {boolean} - */ - isSelfVerification() { - const ret = wasm.sas_isSelfVerification(this.__wbg_ptr); - return ret !== 0; - } - /** - * Get the device ID of the other side. - * @returns {DeviceId} - */ - get otherDeviceId() { - const ret = wasm.sas_otherDeviceId(this.__wbg_ptr); - return DeviceId.__wrap(ret); - } - /** - * Get the user id of the other side. - * @returns {UserId} - */ - get otherUserId() { - const ret = wasm.sas_otherUserId(this.__wbg_ptr); - return UserId.__wrap(ret); - } - /** - * Register a callback which will be called whenever there is an update to - * the request. - * - * The `callback` is called with no parameters. - * @param {() => Promise} callback - */ - registerChangesCallback(callback) { - wasm.sas_registerChangesCallback(this.__wbg_ptr, callback); - } - /** - * Get the room ID if the verification is happening inside a - * room. - * @returns {RoomId | undefined} - */ - get roomId() { - const ret = wasm.sas_roomId(this.__wbg_ptr); - return ret === 0 ? undefined : RoomId.__wrap(ret); - } - /** - * Did this verification flow start from a verification request? - * @returns {boolean} - */ - startedFromRequest() { - const ret = wasm.sas_startedFromRequest(this.__wbg_ptr); - return ret !== 0; - } - /** - * Does this verification flow support displaying emoji for the - * short authentication string? - * @returns {boolean} - */ - supportsEmoji() { - const ret = wasm.sas_supportsEmoji(this.__wbg_ptr); - return ret !== 0; - } - /** - * Has the SAS verification flow timed out? - * @returns {boolean} - */ - timedOut() { - const ret = wasm.sas_timedOut(this.__wbg_ptr); - return ret !== 0; - } - /** - * Get our own user ID. - * @returns {UserId} - */ - get userId() { - const ret = wasm.sas_userId(this.__wbg_ptr); - return UserId.__wrap(ret); - } - /** - * True if we initiated the verification flow (ie, we sent the - * `m.key.verification.request`). - * @returns {boolean} - */ - weStarted() { - const ret = wasm.sas_weStarted(this.__wbg_ptr); - return ret !== 0; - } -} -if (Symbol.dispose) Sas.prototype[Symbol.dispose] = Sas.prototype.free; - -/** - * Struct containing the bundle of secrets to fully activate a new device for - * end-to-end encryption. - */ -export class SecretsBundle { - static __wrap(ptr) { - const obj = Object.create(SecretsBundle.prototype); - obj.__wbg_ptr = ptr; - SecretsBundleFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - SecretsBundleFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_secretsbundle_free(ptr, 0); - } - /** - * The bundle of the backup decryption key and backup version if any. - * @returns {BackupSecretsBundle | undefined} - */ - get backupBundle() { - const ret = wasm.secretsbundle_backupBundle(this.__wbg_ptr); - return ret === 0 ? undefined : BackupSecretsBundle.__wrap(ret); - } - /** - * Deserialize the [`SecretsBundle`] from a JSON object. - * @param {unknown} json - * @returns {SecretsBundle} - */ - static from_json(json) { - const ret = wasm.secretsbundle_from_json(json); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return SecretsBundle.__wrap(ret[0]); - } - /** - * The seed of the master key encoded as unpadded base64. - * @returns {string} - */ - get masterKey() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.secretsbundle_masterKey(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The seed of the self signing key encoded as unpadded base64. - * @returns {string} - */ - get selfSigningKey() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.secretsbundle_selfSigningKey(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Serialize the [`SecretsBundle`] to a JSON object. - * @returns {unknown} - */ - to_json() { - const ret = wasm.secretsbundle_to_json(this.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * The seed of the user signing key encoded as unpadded base64. - * @returns {string} - */ - get userSigningKey() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.secretsbundle_userSigningKey(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } -} -if (Symbol.dispose) SecretsBundle.prototype[Symbol.dispose] = SecretsBundle.prototype.free; - -/** - * A Matrix-spec compliant [server name]. - * - * It consists of a host and an optional port (separated by a colon if - * present). - * - * [server name]: https://spec.matrix.org/v1.2/appendices/#server-name - */ -export class ServerName { - static __wrap(ptr) { - const obj = Object.create(ServerName.prototype); - obj.__wbg_ptr = ptr; - ServerNameFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - ServerNameFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_servername_free(ptr, 0); - } - /** - * Returns the host of the server name. - * - * That is: Return the part of the server before `:` or the - * full server name if there is no port. - * @returns {string} - */ - get host() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.servername_host(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Returns true if and only if the server name is an IPv4 or IPv6 - * address. - * @returns {boolean} - */ - isIpLiteral() { - const ret = wasm.servername_isIpLiteral(this.__wbg_ptr); - return ret !== 0; - } - /** - * Parse/validate and create a new `ServerName`. - * @param {string} name - */ - constructor(name) { - const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.servername_new(ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - this.__wbg_ptr = ret[0]; - ServerNameFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Returns the port of the server name if any. - * @returns {number | undefined} - */ - get port() { - const ret = wasm.servername_port(this.__wbg_ptr); - return ret === 0xFFFFFF ? undefined : ret; - } -} -if (Symbol.dispose) ServerName.prototype[Symbol.dispose] = ServerName.prototype.free; - -/** - * Take a look at [`matrix_sdk_common::deserialized_responses::ShieldState`] - * for more info. - * @enum {0 | 1 | 2} - */ -export const ShieldColor = Object.freeze({ - /** - * Important warning - */ - Red: 0, "0": "Red", - /** - * Low warning - */ - Grey: 1, "1": "Grey", - /** - * No warning - */ - None: 2, "2": "None", -}); - -/** - * Take a look at [`matrix_sdk_common::deserialized_responses::ShieldState`] - * for more info. - */ -export class ShieldState { - static __wrap(ptr) { - const obj = Object.create(ShieldState.prototype); - obj.__wbg_ptr = ptr; - ShieldStateFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - ShieldStateFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_shieldstate_free(ptr, 0); - } - /** - * A machine-readable representation of the authenticity for a - * `ShieldState`. - * @returns {ShieldStateCode | undefined} - */ - get code() { - const ret = wasm.__wbg_get_shieldstate_code(this.__wbg_ptr); - return ret === 6 ? undefined : ret; - } - /** - * The shield color - * @returns {ShieldColor} - */ - get color() { - const ret = wasm.__wbg_get_shieldstate_color(this.__wbg_ptr); - return ret; - } - /** - * A machine-readable representation of the authenticity for a - * `ShieldState`. - * @param {ShieldStateCode | null} [arg0] - */ - set code(arg0) { - wasm.__wbg_set_shieldstate_code(this.__wbg_ptr, isLikeNone(arg0) ? 6 : arg0); - } - /** - * The shield color - * @param {ShieldColor} arg0 - */ - set color(arg0) { - wasm.__wbg_set_shieldstate_color(this.__wbg_ptr, arg0); - } - /** - * Error message that can be displayed as a tooltip - * @returns {string | undefined} - */ - get message() { - const ret = wasm.shieldstate_message(this.__wbg_ptr); - let v1; - if (ret[0] !== 0) { - v1 = getStringFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - } - return v1; - } -} -if (Symbol.dispose) ShieldState.prototype[Symbol.dispose] = ShieldState.prototype.free; - -/** - * A machine-readable representation of the authenticity for a `ShieldState`. - * @enum {0 | 1 | 2 | 3 | 4 | 5} - */ -export const ShieldStateCode = Object.freeze({ - /** - * Not enough information available to check the authenticity. - */ - AuthenticityNotGuaranteed: 0, "0": "AuthenticityNotGuaranteed", - /** - * The sending device isn't yet known by the Client. - */ - UnknownDevice: 1, "1": "UnknownDevice", - /** - * The sending device hasn't been verified by the sender. - */ - UnsignedDevice: 2, "2": "UnsignedDevice", - /** - * The sender hasn't been verified by the Client's user. - */ - UnverifiedIdentity: 3, "3": "UnverifiedIdentity", - /** - * The sender was previously verified but changed their identity. - */ - VerificationViolation: 4, "4": "VerificationViolation", - /** - * The `sender` field on the event does not match the owner of the device - * that established the Megolm session. - */ - MismatchedSender: 5, "5": "MismatchedSender", -}); - -/** - * Represents a potentially decoded signature (but not a validated - * one). - */ -export class Signature { - static __wrap(ptr) { - const obj = Object.create(Signature.prototype); - obj.__wbg_ptr = ptr; - SignatureFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - SignatureFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_signature_free(ptr, 0); - } - /** - * Get the Ed25519 signature, if this is one. - * @returns {Ed25519Signature | undefined} - */ - get ed25519() { - const ret = wasm.signature_ed25519(this.__wbg_ptr); - return ret === 0 ? undefined : Ed25519Signature.__wrap(ret); - } - /** - * Convert the signature to a base64 encoded string. - * @returns {string} - */ - toBase64() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.signature_toBase64(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } -} -if (Symbol.dispose) Signature.prototype[Symbol.dispose] = Signature.prototype.free; - -/** - * The result of a signature check. - * @enum {0 | 1 | 2 | 3} - */ -export const SignatureState = Object.freeze({ - /** - * The signature is missing. - */ - Missing: 0, "0": "Missing", - /** - * The signature is invalid. - */ - Invalid: 1, "1": "Invalid", - /** - * The signature is valid but the device or user identity that created the - * signature is not trusted. - */ - ValidButNotTrusted: 2, "2": "ValidButNotTrusted", - /** - * The signature is valid and the device or user identity that created the - * signature is trusted. - */ - ValidAndTrusted: 3, "3": "ValidAndTrusted", -}); - -/** - * Data for a request to the `/keys/signatures/upload` API endpoint - * ([specification]). - * - * Publishes cross-signing signatures for the user. - * - * [specification]: https://spec.matrix.org/unstable/client-server-api/#post_matrixclientv3keyssignaturesupload - */ -export class SignatureUploadRequest { - static __wrap(ptr) { - const obj = Object.create(SignatureUploadRequest.prototype); - obj.__wbg_ptr = ptr; - SignatureUploadRequestFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - SignatureUploadRequestFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_signatureuploadrequest_free(ptr, 0); - } - /** - * A JSON-encoded object containing the payload of the request - * - * It represents the body of the HTTP request. - * @returns {string} - */ - get body() { - const ret = wasm.__wbg_get_signatureuploadrequest_body(this.__wbg_ptr); - return ret; - } - /** - * The request ID. - * Some signature upload will have to an `id` field, some won't. - * They have one when they are created automatically during an interactive - * verification, otherwise they don't. - * @returns {string | undefined} - */ - get id() { - const ret = wasm.__wbg_get_signatureuploadrequest_id(this.__wbg_ptr); - return ret; - } - /** - * Create a new `SignatureUploadRequest`. - * @param {string} id - * @param {string} signed_keys - */ - constructor(id, signed_keys) { - const ret = wasm.signatureuploadrequest_new(id, signed_keys); - this.__wbg_ptr = ret; - SignatureUploadRequestFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Get its request type. - * @returns {RequestType} - */ - get type() { - const ret = wasm.signatureuploadrequest_type(this.__wbg_ptr); - return ret; - } -} -if (Symbol.dispose) SignatureUploadRequest.prototype[Symbol.dispose] = SignatureUploadRequest.prototype.free; - -/** - * The result of a signature verification of a signed JSON object. - */ -export class SignatureVerification { - static __wrap(ptr) { - const obj = Object.create(SignatureVerification.prototype); - obj.__wbg_ptr = ptr; - SignatureVerificationFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - SignatureVerificationFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_signatureverification_free(ptr, 0); - } - /** - * Give the backup signature state from the current device. - * See SignatureState for values - * @returns {SignatureState} - */ - get deviceState() { - const ret = wasm.signatureverification_deviceState(this.__wbg_ptr); - return ret; - } - /** - * Is the result considered to be trusted? - * - * This tells us if the result has a valid signature from any of the - * following: - * - * * Our own device - * * Our own user identity, provided the identity is trusted as well - * * Any of our own devices, provided the device is trusted as well - * @returns {boolean} - */ - trusted() { - const ret = wasm.signatureverification_trusted(this.__wbg_ptr); - return ret !== 0; - } - /** - * Give the backup signature state from the current user identity. - * See SignatureState for values - * @returns {SignatureState} - */ - get userState() { - const ret = wasm.signatureverification_userState(this.__wbg_ptr); - return ret; - } -} -if (Symbol.dispose) SignatureVerification.prototype[Symbol.dispose] = SignatureVerification.prototype.free; - -/** - * A collection of `Signature`. - */ -export class Signatures { - static __wrap(ptr) { - const obj = Object.create(Signatures.prototype); - obj.__wbg_ptr = ptr; - SignaturesFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - SignaturesFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_signatures_free(ptr, 0); - } - /** - * Add the given signature from the given signer and the given key ID to - * the collection. - * @param {UserId} signer - * @param {DeviceKeyId} key_id - * @param {Ed25519Signature} signature - * @returns {MaybeSignature | undefined} - */ - addSignature(signer, key_id, signature) { - _assertClass(signer, UserId); - _assertClass(key_id, DeviceKeyId); - _assertClass(signature, Ed25519Signature); - const ret = wasm.signatures_addSignature(this.__wbg_ptr, signer.__wbg_ptr, key_id.__wbg_ptr, signature.__wbg_ptr); - return ret === 0 ? undefined : MaybeSignature.__wrap(ret); - } - /** - * Get the json with all signatures - * @returns {string} - */ - asJSON() { - const ret = wasm.signatures_asJSON(this.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Remove all the signatures we currently hold. - */ - clear() { - wasm.signatures_clear(this.__wbg_ptr); - } - /** - * How many signatures do we currently hold. - * @returns {number} - */ - get count() { - const ret = wasm.signatures_count(this.__wbg_ptr); - return ret >>> 0; - } - /** - * Get the map of signatures that belong to the given user. - * @param {UserId} signer - * @returns {Map | undefined} - */ - get(signer) { - _assertClass(signer, UserId); - const ret = wasm.signatures_get(this.__wbg_ptr, signer.__wbg_ptr); - return ret; - } - /** - * Try to find an Ed25519 signature from the given signer with - * the given key ID. - * @param {UserId} signer - * @param {DeviceKeyId} key_id - * @returns {Ed25519Signature | undefined} - */ - getSignature(signer, key_id) { - _assertClass(signer, UserId); - _assertClass(key_id, DeviceKeyId); - const ret = wasm.signatures_getSignature(this.__wbg_ptr, signer.__wbg_ptr, key_id.__wbg_ptr); - return ret === 0 ? undefined : Ed25519Signature.__wrap(ret); - } - /** - * Do we hold any signatures or is our collection completely - * empty. - * @returns {boolean} - */ - isEmpty() { - const ret = wasm.signatures_isEmpty(this.__wbg_ptr); - return ret !== 0; - } - /** - * Creates a new, empty, signatures collection. - */ - constructor() { - const ret = wasm.signatures_new(); - this.__wbg_ptr = ret; - SignaturesFinalization.register(this, this.__wbg_ptr, this); - return this; - } -} -if (Symbol.dispose) Signatures.prototype[Symbol.dispose] = Signatures.prototype.free; - -/** - * A struct containing an open connection to a CryptoStore. - * - * Opening the CryptoStore can take some time, due to the PBKDF calculation - * involved, so if multiple operations are being done on the same store, it is - * more efficient to open it once. - */ -export class StoreHandle { - static __wrap(ptr) { - const obj = Object.create(StoreHandle.prototype); - obj.__wbg_ptr = ptr; - StoreHandleFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - StoreHandleFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_storehandle_free(ptr, 0); - } - /** - * Open a crypto store. - * - * The created store will be based on IndexedDB if a `store_name` is - * provided; otherwise it will be based on a memory store and once the - * objects is dropped, the keys will be lost. - * - * # Arguments - * - * * `store_name` - The name that should be used to open the IndexedDB - * based database. If this isn't provided, a memory-only store will be - * used. *Note* the memory-only store will lose your E2EE keys when the - * `StoreHandle` gets dropped. - * - * * `store_passphrase` - The passphrase that should be used to encrypt the - * store, for IndexedDB-based stores - * - * * `logger` - An optional logger instance to use for writing log messages - * during the open operation. An instance of `JsLogger`. - * @param {string | null | undefined} store_name - * @param {string | null | undefined} store_passphrase - * @param {JsLogger} [logger] - * @returns {Promise} - */ - static open(store_name, store_passphrase, logger) { - var ptr0 = isLikeNone(store_name) ? 0 : passStringToWasm0(store_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - var ptr1 = isLikeNone(store_passphrase) ? 0 : passStringToWasm0(store_passphrase, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len1 = WASM_VECTOR_LEN; - const ret = wasm.storehandle_open(ptr0, len0, ptr1, len1, isLikeNone(logger) ? 0 : addToExternrefTable0(logger)); - return ret; - } - /** - * Open a crypto store based on IndexedDB, using the given key for - * encryption. - * - * # Arguments - * - * * `store_name` - The name that should be used to open the IndexedDB - * based database. - * - * * `store_key` - The key that should be used to encrypt the store, for - * IndexedDB-based stores. Must be a 32-byte array. - * - * * `logger` - An optional logger instance to use for writing log messages - * during the open operation. An instance of `JsLogger`. - * @param {string} store_name - * @param {Uint8Array} store_key - * @param {JsLogger} [logger] - * @returns {Promise} - */ - static openWithKey(store_name, store_key, logger) { - const ptr0 = passStringToWasm0(store_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passArray8ToWasm0(store_key, wasm.__wbindgen_malloc); - const len1 = WASM_VECTOR_LEN; - const ret = wasm.storehandle_openWithKey(ptr0, len0, ptr1, len1, isLikeNone(logger) ? 0 : addToExternrefTable0(logger)); - return ret; - } -} -if (Symbol.dispose) StoreHandle.prototype[Symbol.dispose] = StoreHandle.prototype.free; - -/** - * Information on a stored room key bundle data event. - */ -export class StoredRoomKeyBundleData { - static __wrap(ptr) { - const obj = Object.create(StoredRoomKeyBundleData.prototype); - obj.__wbg_ptr = ptr; - StoredRoomKeyBundleDataFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - StoredRoomKeyBundleDataFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_storedroomkeybundledata_free(ptr, 0); - } - /** - * The JSON-encoded encryption info for the key bundle. - * - * @deprecated Should not be used within applications. - * @returns {string} - */ - get encryptionInfo() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.storedroomkeybundledata_encryptionInfo(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The room that these keys are for. - * @returns {RoomId} - */ - get roomId() { - const ret = wasm.storedroomkeybundledata_roomId(this.__wbg_ptr); - return RoomId.__wrap(ret); - } - /** - * The user that sent us this data. - * @returns {UserId} - */ - get senderUser() { - const ret = wasm.storedroomkeybundledata_senderUser(this.__wbg_ptr); - return UserId.__wrap(ret); - } - /** - * The location of the bundle. - * @returns {string} - */ - get url() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.storedroomkeybundledata_url(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } -} -if (Symbol.dispose) StoredRoomKeyBundleData.prototype[Symbol.dispose] = StoredRoomKeyBundleData.prototype.free; - -/** - * Struct containing information on how a to-device message was decrypted. - */ -export class ToDeviceEncryptionInfo { - static __wrap(ptr) { - const obj = Object.create(ToDeviceEncryptionInfo.prototype); - obj.__wbg_ptr = ptr; - ToDeviceEncryptionInfoFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - ToDeviceEncryptionInfoFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_todeviceencryptioninfo_free(ptr, 0); - } - /** - * The base64-encoded public Curve25519 key of the device that encrypted - * the message. - * @returns {string} - */ - get senderCurve25519Key() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.__wbg_get_todeviceencryptioninfo_senderCurve25519Key(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The device ID of the device that sent us the to-device message. - * - * Could be `undefined` in the case where the to-device message sender - * checks are delayed. There is no delay for to-device messages other - * than `m.room_key`, so this will always be truthy for other - * message types (the decryption would fail if the sender device keys - * cannot be found). - * - * Note this is untrusted data unless {@link isSenderVerified} is true. - * @returns {DeviceId | undefined} - */ - get senderDevice() { - const ret = wasm.__wbg_get_todeviceencryptioninfo_senderDevice(this.__wbg_ptr); - return ret === 0 ? undefined : DeviceId.__wrap(ret); - } - /** - * The user ID of the sender of the event. - * - * Note this is untrusted data unless {@link isSenderVerified} is true. - * @returns {UserId} - */ - get sender() { - const ret = wasm.__wbg_get_todeviceencryptioninfo_sender(this.__wbg_ptr); - return UserId.__wrap(ret); - } - /** - * The base64-encoded public Curve25519 key of the device that encrypted - * the message. - * @param {string} arg0 - */ - set senderCurve25519Key(arg0) { - const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_todeviceencryptioninfo_senderCurve25519Key(this.__wbg_ptr, ptr0, len0); - } - /** - * The device ID of the device that sent us the to-device message. - * - * Could be `undefined` in the case where the to-device message sender - * checks are delayed. There is no delay for to-device messages other - * than `m.room_key`, so this will always be truthy for other - * message types (the decryption would fail if the sender device keys - * cannot be found). - * - * Note this is untrusted data unless {@link isSenderVerified} is true. - * @param {DeviceId | null} [arg0] - */ - set senderDevice(arg0) { - let ptr0 = 0; - if (!isLikeNone(arg0)) { - _assertClass(arg0, DeviceId); - ptr0 = arg0.__destroy_into_raw(); - } - wasm.__wbg_set_todeviceencryptioninfo_senderDevice(this.__wbg_ptr, ptr0); - } - /** - * The user ID of the sender of the event. - * - * Note this is untrusted data unless {@link isSenderVerified} is true. - * @param {UserId} arg0 - */ - set sender(arg0) { - _assertClass(arg0, UserId); - var ptr0 = arg0.__destroy_into_raw(); - wasm.__wbg_set_todeviceencryptioninfo_sender(this.__wbg_ptr, ptr0); - } - /** - * Returns whether the sender device is in a verified state. - * This reflects the state at the time of decryption. - * @returns {boolean} - */ - isSenderVerified() { - const ret = wasm.todeviceencryptioninfo_isSenderVerified(this.__wbg_ptr); - return ret !== 0; - } -} -if (Symbol.dispose) ToDeviceEncryptionInfo.prototype[Symbol.dispose] = ToDeviceEncryptionInfo.prototype.free; - -/** - * Data for a request to the `/sendToDevice` API endpoint - * ([specification]). - * - * Send an event to a single device or to a group of devices. - * - * [specification]: https://spec.matrix.org/unstable/client-server-api/#put_matrixclientv3sendtodeviceeventtypetxnid - */ -export class ToDeviceRequest { - static __wrap(ptr) { - const obj = Object.create(ToDeviceRequest.prototype); - obj.__wbg_ptr = ptr; - ToDeviceRequestFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - ToDeviceRequestFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_todevicerequest_free(ptr, 0); - } - /** - * A JSON-encoded object containing the rest of the payload: `messages`. - * - * It represents the body of the HTTP request. - * @returns {string} - */ - get body() { - const ret = wasm.__wbg_get_todevicerequest_body(this.__wbg_ptr); - return ret; - } - /** - * A string representing the type of event being sent to each devices. - * @returns {string} - */ - get event_type() { - const ret = wasm.__wbg_get_todevicerequest_event_type(this.__wbg_ptr); - return ret; - } - /** - * The request ID. - * For to-device request this would be the same value as `txn_id`. It is - * exposed also as `id` so that the js bindings are consistent with the - * other request types by using this field to mark as sent. - * @returns {string} - */ - get id() { - const ret = wasm.__wbg_get_todevicerequest_id(this.__wbg_ptr); - return ret; - } - /** - * A string representing a request identifier unique to the access token - * used to send the request. - * @returns {string} - */ - get txn_id() { - const ret = wasm.__wbg_get_todevicerequest_txn_id(this.__wbg_ptr); - return ret; - } - /** - * Create a new `ToDeviceRequest`. - * @param {string} id - * @param {string} event_type - * @param {string} txn_id - * @param {string} body - */ - constructor(id, event_type, txn_id, body) { - const ret = wasm.todevicerequest_new(id, event_type, txn_id, body); - this.__wbg_ptr = ret; - ToDeviceRequestFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Get its request type. - * @returns {RequestType} - */ - get type() { - const ret = wasm.todevicerequest_type(this.__wbg_ptr); - return ret; - } -} -if (Symbol.dispose) ToDeviceRequest.prototype[Symbol.dispose] = ToDeviceRequest.prototype.free; - -/** - * Metadata about a to-device event that could not be decrypted. - */ -export class ToDeviceUnableToDecryptInfo { - static __wrap(ptr) { - const obj = Object.create(ToDeviceUnableToDecryptInfo.prototype); - obj.__wbg_ptr = ptr; - ToDeviceUnableToDecryptInfoFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - ToDeviceUnableToDecryptInfoFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_todeviceunabletodecryptinfo_free(ptr, 0); - } - /** - * Reason code for the decryption failure - * @returns {ToDeviceUnableToDecryptReason} - */ - get reason() { - const ret = wasm.__wbg_get_todeviceunabletodecryptinfo_reason(this.__wbg_ptr); - return ret; - } - /** - * Reason code for the decryption failure - * @param {ToDeviceUnableToDecryptReason} arg0 - */ - set reason(arg0) { - wasm.__wbg_set_todeviceunabletodecryptinfo_reason(this.__wbg_ptr, arg0); - } -} -if (Symbol.dispose) ToDeviceUnableToDecryptInfo.prototype[Symbol.dispose] = ToDeviceUnableToDecryptInfo.prototype.free; - -/** - * Reason code for a to-device decryption failure - * @enum {0 | 1 | 2 | 3} - */ -export const ToDeviceUnableToDecryptReason = Object.freeze({ - /** - * An error occurred while encrypting the event. This covers all - * `OlmError` types. - */ - DecryptionFailure: 0, "0": "DecryptionFailure", - /** - * We refused to decrypt the message because the sender's device is not - * verified, or more generally, the sender's identity did not match the - * trust requirement we were asked to provide. - */ - UnverifiedSenderDevice: 1, "1": "UnverifiedSenderDevice", - /** - * We have no `OlmMachine`. This should not happen unless we forget to set - * things up by calling `OlmMachine::activate()`. - */ - NoOlmMachine: 2, "2": "NoOlmMachine", - /** - * The Matrix SDK was compiled without encryption support. - */ - EncryptionIsDisabled: 3, "3": "EncryptionIsDisabled", -}); - -/** - * Type to install and to manipulate the tracing layer. - */ -export class Tracing { - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - TracingFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_tracing_free(ptr, 0); - } - /** - * Check whether the `tracing` feature has been enabled. - * - * @deprecated: `tracing` is now always enabled. - * @returns {boolean} - */ - static isAvailable() { - const ret = wasm.tracing_isAvailable(); - return ret !== 0; - } - /** - * Install the tracing layer. - * @param {LoggerLevel} min_level - */ - constructor(min_level) { - const ret = wasm.tracing_new(min_level); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - this.__wbg_ptr = ret[0]; - TracingFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Re-define the minimum logger level. - * @param {LoggerLevel} min_level - */ - set minLevel(min_level) { - const ret = wasm.tracing_set_minLevel(this.__wbg_ptr, min_level); - if (ret[1]) { - throw takeFromExternrefTable0(ret[0]); - } - } - /** - * Turn the logger off, i.e. it no longer emits logs. - */ - turnOff() { - const ret = wasm.tracing_turnOff(this.__wbg_ptr); - if (ret[1]) { - throw takeFromExternrefTable0(ret[0]); - } - } - /** - * Turn the logger on, i.e. it emits logs again if it was turned - * off. - */ - turnOn() { - const ret = wasm.tracing_turnOn(this.__wbg_ptr); - if (ret[1]) { - throw takeFromExternrefTable0(ret[0]); - } - } -} -if (Symbol.dispose) Tracing.prototype[Symbol.dispose] = Tracing.prototype.free; - -/** - * The trust level required to decrypt an event - * @enum {0 | 1 | 2} - */ -export const TrustRequirement = Object.freeze({ - /** - * Decrypt events from everyone regardless of trust - */ - Untrusted: 0, "0": "Untrusted", - /** - * Only decrypt events from cross-signed or legacy devices - */ - CrossSignedOrLegacy: 1, "1": "CrossSignedOrLegacy", - /** - * Only decrypt events from cross-signed devices - */ - CrossSigned: 2, "2": "CrossSigned", -}); - -/** - * Represents an encrypted to-device event that could not be decrypted. - */ -export class UTDToDeviceEvent { - static __wrap(ptr) { - const obj = Object.create(UTDToDeviceEvent.prototype); - obj.__wbg_ptr = ptr; - UTDToDeviceEventFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - UTDToDeviceEventFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_utdtodeviceevent_free(ptr, 0); - } - /** - * The original message (of type `m.room.encrypted`) that failed to be - * decrypted, encoded as JSON. - * @returns {string} - */ - get rawEvent() { - const ret = wasm.__wbg_get_utdtodeviceevent_rawEvent(this.__wbg_ptr); - return ret; - } - /** - * Information on the reason we failed to decrypt - * @returns {ToDeviceUnableToDecryptInfo} - */ - get utdInfo() { - const ret = wasm.__wbg_get_utdtodeviceevent_utdInfo(this.__wbg_ptr); - return ToDeviceUnableToDecryptInfo.__wrap(ret); - } - /** - * The type of processed to-device event. Always {@link - * ProcessedToDeviceEventType.UnableToDecrypt} for this type. - * @returns {ProcessedToDeviceEventType} - */ - get type() { - const ret = wasm.utdtodeviceevent_type(this.__wbg_ptr); - return ret; - } -} -if (Symbol.dispose) UTDToDeviceEvent.prototype[Symbol.dispose] = UTDToDeviceEvent.prototype.free; - -/** - * Other Requests * - * Request that will publish a cross signing identity. - * - * This uploads the public cross signing key triplet. - */ -export class UploadSigningKeysRequest { - static __wrap(ptr) { - const obj = Object.create(UploadSigningKeysRequest.prototype); - obj.__wbg_ptr = ptr; - UploadSigningKeysRequestFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - UploadSigningKeysRequestFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_uploadsigningkeysrequest_free(ptr, 0); - } - /** - * A JSON-encoded object containing the rest of the payload: `master_key`, - * `self_signing_key`, `user_signing_key`. - * - * It represents the body of the HTTP request. - * @returns {string} - */ - get body() { - const ret = wasm.__wbg_get_uploadsigningkeysrequest_body(this.__wbg_ptr); - return ret; - } - /** - * Create a new `UploadSigningKeysRequest`. - * @param {string} body - */ - constructor(body) { - const ret = wasm.uploadsigningkeysrequest_new(body); - this.__wbg_ptr = ret; - UploadSigningKeysRequestFinalization.register(this, this.__wbg_ptr, this); - return this; - } -} -if (Symbol.dispose) UploadSigningKeysRequest.prototype[Symbol.dispose] = UploadSigningKeysRequest.prototype.free; - -/** - * A read only view over all devices belonging to a user. - */ -export class UserDevices { - static __wrap(ptr) { - const obj = Object.create(UserDevices.prototype); - obj.__wbg_ptr = ptr; - UserDevicesFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - UserDevicesFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_userdevices_free(ptr, 0); - } - /** - * Iterator over all the devices of the user devices. - * @returns {Device[]} - */ - devices() { - const ret = wasm.userdevices_devices(this.__wbg_ptr); - return ret; - } - /** - * Get the specific device with the given device ID. - * @param {DeviceId} device_id - * @returns {Device | undefined} - */ - get(device_id) { - _assertClass(device_id, DeviceId); - const ret = wasm.userdevices_get(this.__wbg_ptr, device_id.__wbg_ptr); - return ret === 0 ? undefined : Device.__wrap(ret); - } - /** - * Returns true if there is at least one devices of this user - * that is considered to be verified, false otherwise. - * - * This won't consider your own device as verified, as your own - * device is always implicitly verified. - * @returns {boolean} - */ - isAnyVerified() { - const ret = wasm.userdevices_isAnyVerified(this.__wbg_ptr); - return ret !== 0; - } - /** - * Array over all the device IDs of the user devices. - * @returns {DeviceId[]} - */ - keys() { - const ret = wasm.userdevices_keys(this.__wbg_ptr); - return ret; - } -} -if (Symbol.dispose) UserDevices.prototype[Symbol.dispose] = UserDevices.prototype.free; - -/** - * A Matrix [user ID]. - * - * [user ID]: https://spec.matrix.org/v1.2/appendices/#user-identifiers - */ -export class UserId { - static __wrap(ptr) { - const obj = Object.create(UserId.prototype); - obj.__wbg_ptr = ptr; - UserIdFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - static __unwrap(jsValue) { - if (!(jsValue instanceof UserId)) { - return 0; - } - return jsValue.__destroy_into_raw(); - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - UserIdFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_userid_free(ptr, 0); - } - /** - * Create a clone of this `UserId`. - * - * This can be useful when passing a `UserId` instance to methods such as - * {@link OlmMachine.updateTrackedUsers} which destroy the instance. - * @returns {UserId} - */ - clone() { - const ret = wasm.userid_clone(this.__wbg_ptr); - return UserId.__wrap(ret); - } - /** - * Whether this user ID is a historical one. - * - * A historical user ID is one that doesn't conform to the latest - * specification of the user ID grammar but is still accepted - * because it was previously allowed. - * @returns {boolean} - */ - isHistorical() { - const ret = wasm.userid_isHistorical(this.__wbg_ptr); - return ret !== 0; - } - /** - * Returns the user's localpart. - * @returns {string} - */ - get localpart() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.userid_localpart(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Parse/validate and create a new `UserId`. - * @param {string} id - */ - constructor(id) { - const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.userid_new(ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - this.__wbg_ptr = ret[0]; - UserIdFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Returns the server name of the user ID. - * @returns {ServerName} - */ - get serverName() { - const ret = wasm.userid_serverName(this.__wbg_ptr); - return ServerName.__wrap(ret); - } - /** - * Return the user ID as a string. - * @returns {string} - */ - toString() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.userid_toString(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } -} -if (Symbol.dispose) UserId.prototype[Symbol.dispose] = UserId.prototype.free; - -/** - * List of available verification methods. - * @enum {0 | 1 | 2 | 3} - */ -export const VerificationMethod = Object.freeze({ - /** - * The `m.sas.v1` verification method. - * - * SAS means Short Authentication String. - */ - SasV1: 0, "0": "SasV1", - /** - * The `m.qr_code.scan.v1` verification method. - */ - QrCodeScanV1: 1, "1": "QrCodeScanV1", - /** - * The `m.qr_code.show.v1` verification method. - */ - QrCodeShowV1: 2, "2": "QrCodeShowV1", - /** - * The `m.reciprocate.v1` verification method. - */ - ReciprocateV1: 3, "3": "ReciprocateV1", -}); - -/** - * An object controlling key verification requests. - * - * Interactive verification flows usually start with a verification - * request, this object lets you send and reply to such a - * verification request. - * - * After the initial handshake the verification flow transitions into - * one of the verification methods. - */ -export class VerificationRequest { - static __wrap(ptr) { - const obj = Object.create(VerificationRequest.prototype); - obj.__wbg_ptr = ptr; - VerificationRequestFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - VerificationRequestFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_verificationrequest_free(ptr, 0); - } - /** - * Accept the verification request. - * - * This method will accept the request and signal that it - * supports the `m.sas.v1`, the `m.qr_code.show.v1`, and - * `m.reciprocate.v1` method. - * - * `m.qr_code.show.v1` will only be signaled if the `qrcode` - * feature is enabled. This feature is disabled by default. If - * it's enabled and QR code scanning should be supported or QR - * code showing shouldn't be supported the `accept_with_methods` - * method should be used instead. - * - * It returns either a `ToDeviceRequest`, a `RoomMessageRequest` - * or `undefined`. - * @returns {OutgoingVerificationRequest | undefined} - */ - accept() { - const ret = wasm.verificationrequest_accept(this.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Accept the verification request signaling that our client - * supports the given verification methods. - * - * `methods` represents the methods that we should advertise as - * supported by us. - * - * It returns either a `ToDeviceRequest`, a `RoomMessageRequest` - * or `undefined`. - * @param {VerificationMethod[]} methods - * @returns {OutgoingVerificationRequest | undefined} - */ - acceptWithMethods(methods) { - const ptr0 = passArrayJsValueToWasm0(methods, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.verificationrequest_acceptWithMethods(this.__wbg_ptr, ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Cancel the verification request. - * - * It returns either a `ToDeviceRequest`, a `RoomMessageRequest` - * or `undefined`. - * @returns {OutgoingVerificationRequest | undefined} - */ - cancel() { - const ret = wasm.verificationrequest_cancel(this.__wbg_ptr); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); - } - /** - * Get info about the cancellation if the verification request - * has been cancelled. - * @returns {CancelInfo | undefined} - */ - get cancelInfo() { - const ret = wasm.verificationrequest_cancelInfo(this.__wbg_ptr); - return ret === 0 ? undefined : CancelInfo.__wrap(ret); - } - /** - * Get the unique ID of this verification request. - * @returns {string} - */ - get flowId() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.verificationrequest_flowId(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Generate a QR code that can be used by another client to start - * a QR code based verification. - * - * Returns a `Qr` or `undefined`. - * @returns {Promise} - */ - generateQrCode() { - const ret = wasm.verificationrequest_generateQrCode(this.__wbg_ptr); - return ret; - } - /** - * If this request has transitioned into a concrete verification - * flow (and not yet been completed or cancelled), returns a `Verification` - * object. - * - * Returns: a `Sas`, a `Qr`, or `undefined`. - * @returns {Sas | Qr | undefined} - */ - getVerification() { - const ret = wasm.verificationrequest_getVerification(this.__wbg_ptr); - return ret; - } - /** - * Has the verification flow that was started with this request - * been cancelled? - * @returns {boolean} - */ - isCancelled() { - const ret = wasm.verificationrequest_isCancelled(this.__wbg_ptr); - return ret !== 0; - } - /** - * Has the verification flow that was started with this request - * finished? - * @returns {boolean} - */ - isDone() { - const ret = wasm.verificationrequest_isDone(this.__wbg_ptr); - return ret !== 0; - } - /** - * Has the verification request been answered by another device? - * @returns {boolean} - */ - isPassive() { - const ret = wasm.verificationrequest_isPassive(this.__wbg_ptr); - return ret !== 0; - } - /** - * Is the verification request ready to start a verification flow? - * @returns {boolean} - */ - isReady() { - const ret = wasm.verificationrequest_isReady(this.__wbg_ptr); - return ret !== 0; - } - /** - * Is this a verification that is verifying one of our own - * devices? - * @returns {boolean} - */ - isSelfVerification() { - const ret = wasm.verificationrequest_isSelfVerification(this.__wbg_ptr); - return ret !== 0; - } - /** - * The ID of the other device that is participating in this - * verification. - * @returns {DeviceId | undefined} - */ - get otherDeviceId() { - const ret = wasm.verificationrequest_otherDeviceId(this.__wbg_ptr); - return ret === 0 ? undefined : DeviceId.__wrap(ret); - } - /** - * The ID of the other user that is participating in this - * verification request. - * @returns {UserId} - */ - get otherUserId() { - const ret = wasm.verificationrequest_otherUserId(this.__wbg_ptr); - return UserId.__wrap(ret); - } - /** - * Get our own supported verification methods that we advertised. - * - * Will be present only we requested the verification or if we’re - * in the ready state. - * @returns {VerificationMethod[] | undefined} - */ - get ourSupportedMethods() { - const ret = wasm.verificationrequest_ourSupportedMethods(this.__wbg_ptr); - if (ret[3]) { - throw takeFromExternrefTable0(ret[2]); - } - let v1; - if (ret[0] !== 0) { - v1 = getArrayJsValueFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 4, 4); - } - return v1; - } - /** - * Our own user id. - * @returns {UserId} - */ - get ownUserId() { - const ret = wasm.verificationrequest_ownUserId(this.__wbg_ptr); - return UserId.__wrap(ret); - } - /** - * Get the current phase of this request. - * - * Returns a `VerificationRequestPhase`. - * @returns {VerificationRequestPhase} - */ - phase() { - const ret = wasm.verificationrequest_phase(this.__wbg_ptr); - return ret; - } - /** - * Register a callback which will be called whenever there is an update to - * the request. - * - * The `callback` is called with no parameters. - * @param {() => Promise} callback - */ - registerChangesCallback(callback) { - wasm.verificationrequest_registerChangesCallback(this.__wbg_ptr, callback); - } - /** - * Create an event content that can be sent as a room event to - * request verification from the other side. This should be used - * only for verifications of other users and it should be sent to - * a room we consider to be a DM with the other user. - * @param {UserId} own_user_id - * @param {DeviceId} own_device_id - * @param {UserId} other_user_id - * @param {VerificationMethod[]} [methods] - * @returns {string} - */ - static request(own_user_id, own_device_id, other_user_id, methods) { - let deferred3_0; - let deferred3_1; - try { - _assertClass(own_user_id, UserId); - _assertClass(own_device_id, DeviceId); - _assertClass(other_user_id, UserId); - var ptr0 = isLikeNone(methods) ? 0 : passArrayJsValueToWasm0(methods, wasm.__wbindgen_malloc); - var len0 = WASM_VECTOR_LEN; - const ret = wasm.verificationrequest_request(own_user_id.__wbg_ptr, own_device_id.__wbg_ptr, other_user_id.__wbg_ptr, ptr0, len0); - var ptr2 = ret[0]; - var len2 = ret[1]; - if (ret[3]) { - ptr2 = 0; len2 = 0; - throw takeFromExternrefTable0(ret[2]); - } - deferred3_0 = ptr2; - deferred3_1 = len2; - return getStringFromWasm0(ptr2, len2); - } finally { - wasm.__wbindgen_free(deferred3_0, deferred3_1, 1); - } - } - /** - * Get the room ID if the verification is happening inside a - * room. - * @returns {RoomId | undefined} - */ - get roomId() { - const ret = wasm.verificationrequest_roomId(this.__wbg_ptr); - return ret === 0 ? undefined : RoomId.__wrap(ret); - } - /** - * Start a QR code verification by providing a scanned QR code - * for this verification flow. - * @param {QrCodeScan} data - * @returns {Promise} - */ - scanQrCode(data) { - _assertClass(data, QrCodeScan); - const ret = wasm.verificationrequest_scanQrCode(this.__wbg_ptr, data.__wbg_ptr); - return ret; - } - /** - * Transition from this verification request into a SAS verification flow. - * - * Returns `Promise<[Sas, OutgoingVerificationRequest] | undefined>` - * @returns {Promise<[Sas, OutgoingVerificationRequest] | undefined>} - */ - startSas() { - const ret = wasm.verificationrequest_startSas(this.__wbg_ptr); - return ret; - } - /** - * Get the supported verification methods of the other side. - * - * Will be present only if the other side requested the - * verification or if we’re in the ready state. - * - * # Returns - * - * `undefined` if we do not yet know the supported methods; otherwise, an - * array of `VerificationMethod`s. - * @returns {VerificationMethod[] | undefined} - */ - get theirSupportedMethods() { - const ret = wasm.verificationrequest_theirSupportedMethods(this.__wbg_ptr); - if (ret[3]) { - throw takeFromExternrefTable0(ret[2]); - } - let v1; - if (ret[0] !== 0) { - v1 = getArrayJsValueFromWasm0(ret[0], ret[1]); - wasm.__wbindgen_free(ret[0], ret[1] * 4, 4); - } - return v1; - } - /** - * The number of milliseconds remaining before this verification flow times - * out. - * - * Returns zero if the time has already passed. - * @returns {number} - */ - timeRemainingMillis() { - const ret = wasm.verificationrequest_timeRemainingMillis(this.__wbg_ptr); - return ret; - } - /** - * Has the verification flow timed out? - * @returns {boolean} - */ - timedOut() { - const ret = wasm.verificationrequest_timedOut(this.__wbg_ptr); - return ret !== 0; - } - /** - * Did we initiate the verification request? - * @returns {boolean} - */ - weStarted() { - const ret = wasm.verificationrequest_weStarted(this.__wbg_ptr); - return ret !== 0; - } -} -if (Symbol.dispose) VerificationRequest.prototype[Symbol.dispose] = VerificationRequest.prototype.free; - -/** - * List of VerificationRequestState phases - * @enum {0 | 1 | 2 | 3 | 4 | 5} - */ -export const VerificationRequestPhase = Object.freeze({ - /** - * The verification request has been newly created by us. - */ - Created: 0, "0": "Created", - /** - * The verification request was received from the other party. - */ - Requested: 1, "1": "Requested", - /** - * The verification request is ready to start a verification flow. - */ - Ready: 2, "2": "Ready", - /** - * The verification request has transitioned into a concrete verification - * flow. For example it transitioned into the emoji based SAS - * verification. - */ - Transitioned: 3, "3": "Transitioned", - /** - * The verification flow that was started with this request has finished. - */ - Done: 4, "4": "Done", - /** - * The verification process has been cancelled. - */ - Cancelled: 5, "5": "Cancelled", -}); - -/** - * Object containing the versions of the Rust libraries we are using. - */ -export class Versions { - static __wrap(ptr) { - const obj = Object.create(Versions.prototype); - obj.__wbg_ptr = ptr; - VersionsFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - VersionsFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_versions_free(ptr, 0); - } - /** - * The build-time output of the `git describe` command of the source tree - * of crate. - * @returns {string} - */ - get git_description() { - const ret = wasm.__wbg_get_versions_git_description(this.__wbg_ptr); - return ret; - } - /** - * The Git commit hash of the crate's source tree at build time. - * @returns {string} - */ - get git_sha() { - const ret = wasm.__wbg_get_versions_git_sha(this.__wbg_ptr); - return ret; - } - /** - * The version of the matrix-sdk-crypto crate. - * @returns {string} - */ - get matrix_sdk_crypto() { - const ret = wasm.__wbg_get_versions_matrix_sdk_crypto(this.__wbg_ptr); - return ret; - } - /** - * The version of the vodozemac crate. - * @returns {string} - */ - get vodozemac() { - const ret = wasm.__wbg_get_versions_vodozemac(this.__wbg_ptr); - return ret; - } -} -if (Symbol.dispose) Versions.prototype[Symbol.dispose] = Versions.prototype.free; - -/** - * Get the versions of the Rust libraries we are using. - * @returns {Versions} - */ -export function getVersions() { - const ret = wasm.getVersions(); - return Versions.__wrap(ret); -} - -/** - * Run some stuff when the Wasm module is instantiated. - * - * Right now, it does the following: - * - * * Redirect Rust panics to JavaScript console. - */ -export function start() { - wasm.start(); -} -export function __wbg_Error_408e67f47ca7b58b(arg0, arg1) { - const ret = Error(getStringFromWasm0(arg0, arg1)); - return ret; -} -export function __wbg_Number_3890faa6d3ff057d(arg0) { - const ret = Number(arg0); - return ret; -} -export function __wbg_String_8564e559799eccda(arg0, arg1) { - const ret = String(arg1); - const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); -} -export function __wbg_Window_241244be8c9776c1(arg0) { - const ret = arg0.Window; - return ret; -} -export function __wbg_WorkerGlobalScope_8623a7c9030fbce2(arg0) { - const ret = arg0.WorkerGlobalScope; - return ret; -} -export function __wbg___wbindgen_bigint_get_as_i64_c4ecf48528083721(arg0, arg1) { - const v = arg1; - const ret = typeof(v) === 'bigint' ? v : undefined; - getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true); -} -export function __wbg___wbindgen_boolean_get_c9c83ebd41b34df3(arg0) { - const v = arg0; - const ret = typeof(v) === 'boolean' ? v : undefined; - return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0; -} -export function __wbg___wbindgen_debug_string_a57024b9c6e4a48b(arg0, arg1) { - const ret = debugString(arg1); - const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); -} -export function __wbg___wbindgen_in_ac983077f137f2e6(arg0, arg1) { - const ret = arg0 in arg1; - return ret; -} -export function __wbg___wbindgen_is_bigint_8ffbbef442139384(arg0) { - const ret = typeof(arg0) === 'bigint'; - return ret; -} -export function __wbg___wbindgen_is_function_5e4570eb24ffa122(arg0) { - const ret = typeof(arg0) === 'function'; - return ret; -} -export function __wbg___wbindgen_is_null_7d13f41e1a2d5140(arg0) { - const ret = arg0 === null; - return ret; -} -export function __wbg___wbindgen_is_object_a2790eb24c211ea0(arg0) { - const val = arg0; - const ret = typeof(val) === 'object' && val !== null; - return ret; -} -export function __wbg___wbindgen_is_string_e6f02f0ea5f20a32(arg0) { - const ret = typeof(arg0) === 'string'; - return ret; -} -export function __wbg___wbindgen_is_undefined_6cff064c44e0d823(arg0) { - const ret = arg0 === undefined; - return ret; -} -export function __wbg___wbindgen_jsval_eq_0a18949a61670320(arg0, arg1) { - const ret = arg0 === arg1; - return ret; -} -export function __wbg___wbindgen_jsval_loose_eq_acf2776254a8d832(arg0, arg1) { - const ret = arg0 == arg1; - return ret; -} -export function __wbg___wbindgen_number_get_136b9679cab35cfb(arg0, arg1) { - const obj = arg1; - const ret = typeof(obj) === 'number' ? obj : undefined; - getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true); -} -export function __wbg___wbindgen_string_get_d154f1e671052120(arg0, arg1) { - const obj = arg1; - const ret = typeof(obj) === 'string' ? obj : undefined; - var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len1 = WASM_VECTOR_LEN; - getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); -} -export function __wbg___wbindgen_throw_bb96b2010945f0bc(arg0, arg1) { - throw new Error(getStringFromWasm0(arg0, arg1)); -} -export function __wbg__wbg_cb_unref_be22cc64ae6946a0(arg0) { - arg0._wbg_cb_unref(); -} -export function __wbg_abort_32b500c4f9eab55d() { return handleError(function (arg0) { - arg0.abort(); -}, arguments); } -export function __wbg_add_18ccb6b4b9da9cd9() { return handleError(function (arg0, arg1, arg2) { - const ret = arg0.add(arg1, arg2); - return ret; -}, arguments); } -export function __wbg_add_2b945856b580d5ab(arg0, arg1) { - const ret = arg0.add(arg1); - return ret; -} -export function __wbg_at_facbe5ae998bba3a(arg0, arg1) { - const ret = arg0.at(arg1); - return ret; -} -export function __wbg_backupkeys_new(arg0) { - const ret = BackupKeys.__wrap(arg0); - return ret; -} -export function __wbg_bound_e48dc2f851c77207() { return handleError(function (arg0, arg1, arg2, arg3) { - const ret = IDBKeyRange.bound(arg0, arg1, arg2 !== 0, arg3 !== 0); - return ret; -}, arguments); } -export function __wbg_call_0f2a9af232c18fd2() { return handleError(function (arg0, arg1, arg2, arg3) { - const ret = arg0.call(arg1, arg2, arg3); - return ret; -}, arguments); } -export function __wbg_call_1c5886ab9c57d1c7() { return handleError(function (arg0, arg1) { - const ret = arg0.call(arg1); - return ret; -}, arguments); } -export function __wbg_call_35dba3c747ad7521() { return handleError(function (arg0, arg1, arg2) { - const ret = arg0.call(arg1, arg2); - return ret; -}, arguments); } -export function __wbg_call_39f824e18d9d2414() { return handleError(function (arg0, arg1, arg2, arg3, arg4) { - const ret = arg0.call(arg1, arg2, arg3, arg4); - return ret; -}, arguments); } -export function __wbg_clearTimeout_3629d6209dfcc46e(arg0) { - const ret = clearTimeout(arg0); - return ret; -} -export function __wbg_clear_07a20ccd42c66921() { return handleError(function (arg0) { - const ret = arg0.clear(); - return ret; -}, arguments); } -export function __wbg_close_0c1f30aeb9a080a7(arg0) { - arg0.close(); -} -export function __wbg_code_5c2c992d8a3afb58(arg0) { - const ret = arg0.code; - return ret; -} -export function __wbg_commit_ebd6d9676954e0d2() { return handleError(function (arg0) { - arg0.commit(); -}, arguments); } -export function __wbg_continue_cbf53c725c127fe3() { return handleError(function (arg0) { - arg0.continue(); -}, arguments); } -export function __wbg_count_be9295f0aceb7d6a() { return handleError(function (arg0) { - const ret = arg0.count(); - return ret; -}, arguments); } -export function __wbg_count_c48ec9dcdccef1d5() { return handleError(function (arg0) { - const ret = arg0.count(); - return ret; -}, arguments); } -export function __wbg_createIndex_9e2beb35a103225a() { return handleError(function (arg0, arg1, arg2, arg3) { - const ret = arg0.createIndex(getStringFromWasm0(arg1, arg2), arg3); - return ret; -}, arguments); } -export function __wbg_createIndex_f8a090296c419c6c() { return handleError(function (arg0, arg1, arg2, arg3, arg4) { - const ret = arg0.createIndex(getStringFromWasm0(arg1, arg2), arg3, arg4); - return ret; -}, arguments); } -export function __wbg_createObjectStore_d3884936b845900f() { return handleError(function (arg0, arg1, arg2) { - const ret = arg0.createObjectStore(getStringFromWasm0(arg1, arg2)); - return ret; -}, arguments); } -export function __wbg_crosssigningbootstraprequests_new(arg0) { - const ret = CrossSigningBootstrapRequests.__wrap(arg0); - return ret; -} -export function __wbg_crosssigningkeyexport_new(arg0) { - const ret = CrossSigningKeyExport.__wrap(arg0); - return ret; -} -export function __wbg_crosssigningstatus_new(arg0) { - const ret = CrossSigningStatus.__wrap(arg0); - return ret; -} -export function __wbg_crypto_38df2bab126b63dc(arg0) { - const ret = arg0.crypto; - return ret; -} -export function __wbg_debug_1ac2ea5532f70f4c(arg0, arg1) { - arg0.debug(arg1); -} -export function __wbg_debug_3853dbaf0bca30f9(arg0) { - console.debug(arg0); -} -export function __wbg_decryptedroomevent_new(arg0) { - const ret = DecryptedRoomEvent.__wrap(arg0); - return ret; -} -export function __wbg_decryptedtodeviceevent_new(arg0) { - const ret = DecryptedToDeviceEvent.__wrap(arg0); - return ret; -} -export function __wbg_dehydrateddevice_new(arg0) { - const ret = DehydratedDevice.__wrap(arg0); - return ret; -} -export function __wbg_dehydrateddevicekey_new(arg0) { - const ret = DehydratedDeviceKey.__wrap(arg0); - return ret; -} -export function __wbg_deleteObjectStore_ed0e7d0b256bead4() { return handleError(function (arg0, arg1, arg2) { - arg0.deleteObjectStore(getStringFromWasm0(arg1, arg2)); -}, arguments); } -export function __wbg_delete_03ff02bcb1b57138() { return handleError(function (arg0) { - const ret = arg0.delete(); - return ret; -}, arguments); } -export function __wbg_delete_27b012593b3f623b() { return handleError(function (arg0, arg1) { - const ret = arg0.delete(arg1); - return ret; -}, arguments); } -export function __wbg_device_new(arg0) { - const ret = Device.__wrap(arg0); - return ret; -} -export function __wbg_deviceid_new(arg0) { - const ret = DeviceId.__wrap(arg0); - return ret; -} -export function __wbg_devicekey_new(arg0) { - const ret = DeviceKey.__wrap(arg0); - return ret; -} -export function __wbg_devicekeyid_new(arg0) { - const ret = DeviceKeyId.__wrap(arg0); - return ret; -} -export function __wbg_done_669171204c3dcae2(arg0) { - const ret = arg0.done; - return ret; -} -export function __wbg_emoji_new(arg0) { - const ret = Emoji.__wrap(arg0); - return ret; -} -export function __wbg_encryptedattachment_new(arg0) { - const ret = EncryptedAttachment.__wrap(arg0); - return ret; -} -export function __wbg_encryptioninfo_new(arg0) { - const ret = EncryptionInfo.__wrap(arg0); - return ret; -} -export function __wbg_entries_71601bcb707d5078(arg0) { - const ret = arg0.entries(); - return ret; -} -export function __wbg_entries_7774d489e1da5f4f(arg0) { - const ret = Object.entries(arg0); - return ret; -} -export function __wbg_error_24e6ac605d438e54() { return handleError(function (arg0) { - const ret = arg0.error; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); -}, arguments); } -export function __wbg_error_757e9472f8410341(arg0, arg1) { - let deferred0_0; - let deferred0_1; - try { - deferred0_0 = arg0; - deferred0_1 = arg1; - console.error(getStringFromWasm0(arg0, arg1)); - } finally { - wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); - } -} -export function __wbg_error_dbd3752906405f8d(arg0, arg1) { - arg0.error(arg1); -} -export function __wbg_error_dd408a7b3cb542dd(arg0) { - console.error(arg0); -} -export function __wbg_from_74f3d90e0ff11240(arg0) { - const ret = Array.from(arg0); - return ret; -} -export function __wbg_getAllKeys_1de66542d233a4a5() { return handleError(function (arg0) { - const ret = arg0.getAllKeys(); - return ret; -}, arguments); } -export function __wbg_getAllKeys_65d7deed4f9b2d48() { return handleError(function (arg0, arg1) { - const ret = arg0.getAllKeys(arg1); - return ret; -}, arguments); } -export function __wbg_getAll_358f5970d9bee84b() { return handleError(function (arg0) { - const ret = arg0.getAll(); - return ret; -}, arguments); } -export function __wbg_getAll_6b556cfcbf040afc() { return handleError(function (arg0, arg1) { - const ret = arg0.getAll(arg1); - return ret; -}, arguments); } -export function __wbg_getAll_86c18743042fe4ca() { return handleError(function (arg0) { - const ret = arg0.getAll(); - return ret; -}, arguments); } -export function __wbg_getAll_edf30bc7f595e7ae() { return handleError(function (arg0, arg1, arg2) { - const ret = arg0.getAll(arg1, arg2 >>> 0); - return ret; -}, arguments); } -export function __wbg_getRandomValues_26c0cdf963e46393() { return handleError(function (arg0, arg1) { - globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1)); -}, arguments); } -export function __wbg_getRandomValues_436a51d0629d84e1() { return handleError(function (arg0, arg1) { - globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1)); -}, arguments); } -export function __wbg_getRandomValues_c44a50d8cfdaebeb() { return handleError(function (arg0, arg1) { - arg0.getRandomValues(arg1); -}, arguments); } -export function __wbg_getTime_63fb0332e6c4ec17(arg0) { - const ret = arg0.getTime(); - return ret; -} -export function __wbg_get_4babbbf9303c1945() { return handleError(function (arg0, arg1) { - const ret = arg0.get(arg1); - return ret; -}, arguments); } -export function __wbg_get_94b5ec70e1f04bdd() { return handleError(function (arg0, arg1) { - const ret = arg0.get(arg1); - return ret; -}, arguments); } -export function __wbg_get_971a0c45d172643f() { return handleError(function (arg0, arg1) { - const ret = Reflect.get(arg0, arg1); - return ret; -}, arguments); } -export function __wbg_get_c0c8f8d7da0c03dd(arg0, arg1) { - const ret = arg0[arg1 >>> 0]; - return ret; -} -export function __wbg_get_d173c0308df22d37() { return handleError(function (arg0, arg1) { - const ret = Reflect.get(arg0, arg1); - return ret; -}, arguments); } -export function __wbg_get_unchecked_e20b893aeafc3fca(arg0, arg1) { - const ret = arg0[arg1 >>> 0]; - return ret; -} -export function __wbg_get_with_ref_key_6412cf3094599694(arg0, arg1) { - const ret = arg0[arg1]; - return ret; -} -export function __wbg_global_94a489d2e6a0c5fd(arg0) { - const ret = arg0.global; - return ret; -} -export function __wbg_inboundgroupsession_new(arg0) { - const ret = InboundGroupSession.__wrap(arg0); - return ret; -} -export function __wbg_index_bed5a9f21dfebeea() { return handleError(function (arg0, arg1, arg2) { - const ret = arg0.index(getStringFromWasm0(arg1, arg2)); - return ret; -}, arguments); } -export function __wbg_indexedDB_47c354eb27472a00() { return handleError(function (arg0) { - const ret = arg0.indexedDB; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); -}, arguments); } -export function __wbg_indexedDB_9e20c97c033151f3() { return handleError(function (arg0) { - const ret = arg0.indexedDB; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); -}, arguments); } -export function __wbg_indexedDB_ced363f3de8fb099() { return handleError(function (arg0) { - const ret = arg0.indexedDB; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); -}, arguments); } -export function __wbg_info_726982aff9befe16(arg0) { - console.info(arg0); -} -export function __wbg_info_929f1b00bd4820a9(arg0, arg1) { - arg0.info(arg1); -} -export function __wbg_instanceof_ArrayBuffer_993d02d2d254cad1(arg0) { - let result; - try { - result = arg0 instanceof ArrayBuffer; - } catch (_) { - result = false; - } - const ret = result; - return ret; -} -export function __wbg_instanceof_CursorSys_383984afc1fa1bbc(arg0) { - let result; - try { - result = arg0 instanceof IDBCursorWithValue; - } catch (_) { - result = false; - } - const ret = result; - return ret; -} -export function __wbg_instanceof_DomException_55a5af63fefe4042(arg0) { - let result; - try { - result = arg0 instanceof DOMException; - } catch (_) { - result = false; - } - const ret = result; - return ret; -} -export function __wbg_instanceof_Error_61d8a02a0f3383a1(arg0) { - let result; - try { - result = arg0 instanceof Error; - } catch (_) { - result = false; - } - const ret = result; - return ret; -} -export function __wbg_instanceof_IdbCursor_9bd028886fa2ccf0(arg0) { - let result; - try { - result = arg0 instanceof IDBCursor; - } catch (_) { - result = false; - } - const ret = result; - return ret; -} -export function __wbg_instanceof_IdbDatabase_e9dd9f20c51d8d42(arg0) { - let result; - try { - result = arg0 instanceof IDBDatabase; - } catch (_) { - result = false; - } - const ret = result; - return ret; -} -export function __wbg_instanceof_IdbOpenDbRequest_b913751ffb9239bb(arg0) { - let result; - try { - result = arg0 instanceof IDBOpenDBRequest; - } catch (_) { - result = false; - } - const ret = result; - return ret; -} -export function __wbg_instanceof_IdbRequest_471b050024626dac(arg0) { - let result; - try { - result = arg0 instanceof IDBRequest; - } catch (_) { - result = false; - } - const ret = result; - return ret; -} -export function __wbg_instanceof_Map_9a4d6ead180ae3a9(arg0) { - let result; - try { - result = arg0 instanceof Map; - } catch (_) { - result = false; - } - const ret = result; - return ret; -} -export function __wbg_instanceof_Promise_e6e764b945c3128a(arg0) { - let result; - try { - result = arg0 instanceof Promise; - } catch (_) { - result = false; - } - const ret = result; - return ret; -} -export function __wbg_instanceof_Uint8Array_f935dbb0aa7cdeed(arg0) { - let result; - try { - result = arg0 instanceof Uint8Array; - } catch (_) { - result = false; - } - const ret = result; - return ret; -} -export function __wbg_invalidtodeviceevent_new(arg0) { - const ret = InvalidToDeviceEvent.__wrap(arg0); - return ret; -} -export function __wbg_isArray_291e8fbbc73f8b2e(arg0) { - const ret = Array.isArray(arg0); - return ret; -} -export function __wbg_isArray_6339f732981044bf(arg0) { - const ret = Array.isArray(arg0); - return ret; -} -export function __wbg_isSafeInteger_f3d6cd19ccfe4512(arg0) { - const ret = Number.isSafeInteger(arg0); - return ret; -} -export function __wbg_item_754b49ed01198c29(arg0, arg1, arg2) { - const ret = arg1.item(arg2 >>> 0); - var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len1 = WASM_VECTOR_LEN; - getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); -} -export function __wbg_iterator_5cebbb86e33c6dd6() { - const ret = Symbol.iterator; - return ret; -} -export function __wbg_key_18fe06a6310bf3fb() { return handleError(function (arg0) { - const ret = arg0.key; - return ret; -}, arguments); } -export function __wbg_keysbackuprequest_new(arg0) { - const ret = KeysBackupRequest.__wrap(arg0); - return ret; -} -export function __wbg_keysclaimrequest_new(arg0) { - const ret = KeysClaimRequest.__wrap(arg0); - return ret; -} -export function __wbg_keysqueryrequest_new(arg0) { - const ret = KeysQueryRequest.__wrap(arg0); - return ret; -} -export function __wbg_keysuploadrequest_new(arg0) { - const ret = KeysUploadRequest.__wrap(arg0); - return ret; -} -export function __wbg_length_13032799523c5735(arg0) { - const ret = arg0.length; - return ret; -} -export function __wbg_length_36bd29c6848c2144(arg0) { - const ret = arg0.length; - return ret; -} -export function __wbg_length_ecfa2c63d3d0d82c(arg0) { - const ret = arg0.length; - return ret; -} -export function __wbg_lowerBound_66a1695f45ef6c88() { return handleError(function (arg0, arg1) { - const ret = IDBKeyRange.lowerBound(arg0, arg1 !== 0); - return ret; -}, arguments); } -export function __wbg_maybesignature_new(arg0) { - const ret = MaybeSignature.__wrap(arg0); - return ret; -} -export function __wbg_megolmdecryptionerror_new(arg0) { - const ret = MegolmDecryptionError.__wrap(arg0); - return ret; -} -export function __wbg_message_88eda073e68b1d26(arg0, arg1) { - const ret = arg1.message; - const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); -} -export function __wbg_message_c141d5e68716b595(arg0) { - const ret = arg0.message; - return ret; -} -export function __wbg_msCrypto_bd5a034af96bcba6(arg0) { - const ret = arg0.msCrypto; - return ret; -} -export function __wbg_name_facbed56940f0fec(arg0, arg1) { - const ret = arg1.name; - const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); -} -export function __wbg_new_116be93542d39019() { - const ret = new Array(); - return ret; -} -export function __wbg_new_227d7c05414eb861() { - const ret = new Error(); - return ret; -} -export function __wbg_new_358857d90afd5a2d(arg0, arg1) { - const ret = new Error(getStringFromWasm0(arg0, arg1)); - return ret; -} -export function __wbg_new_418fb92a013d5930(arg0, arg1) { - try { - var state0 = {a: arg0, b: arg1}; - var cb0 = (arg0, arg1) => { - const a = state0.a; - state0.a = 0; - try { - return wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke___js_sys_8badcad5ae9f3759___Function_fn_wasm_bindgen_ff9af61e2d43a78a___JsValue_____wasm_bindgen_ff9af61e2d43a78a___sys__Undefined___js_sys_8badcad5ae9f3759___Function_fn_wasm_bindgen_ff9af61e2d43a78a___JsValue_____wasm_bindgen_ff9af61e2d43a78a___sys__Undefined_______true_(a, state0.b, arg0, arg1); - } finally { - state0.a = a; - } - }; - const ret = new Promise(cb0); - return ret; - } finally { - state0.a = 0; - } -} -export function __wbg_new_77cc4f4f472aeb81(arg0) { - const ret = new Uint8Array(arg0); - return ret; -} -export function __wbg_new_cdf041679ded4c5f() { - const ret = new Map(); - return ret; -} -export function __wbg_new_d29ccbc1854174b3(arg0) { - const ret = new Set(arg0); - return ret; -} -export function __wbg_new_ebe3e0f6837f0879() { - const ret = new Object(); - return ret; -} -export function __wbg_new_f9d6489212f3b2b3(arg0) { - const ret = new Date(arg0); - return ret; -} -export function __wbg_new_from_slice_3eea173078478cfe(arg0, arg1) { - const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1)); - return ret; -} -export function __wbg_new_typed_cceaf62d8d95e9f2(arg0, arg1) { - try { - var state0 = {a: arg0, b: arg1}; - var cb0 = (arg0, arg1) => { - const a = state0.a; - state0.a = 0; - try { - return wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke___js_sys_8badcad5ae9f3759___Function_fn_wasm_bindgen_ff9af61e2d43a78a___JsValue_____wasm_bindgen_ff9af61e2d43a78a___sys__Undefined___js_sys_8badcad5ae9f3759___Function_fn_wasm_bindgen_ff9af61e2d43a78a___JsValue_____wasm_bindgen_ff9af61e2d43a78a___sys__Undefined_______true_(a, state0.b, arg0, arg1); - } finally { - state0.a = a; - } - }; - const ret = new Promise(cb0); - return ret; - } finally { - state0.a = 0; - } -} -export function __wbg_new_with_length_3ffc1c56427c525c(arg0) { - const ret = new Uint8Array(arg0 >>> 0); - return ret; -} -export function __wbg_new_with_length_5d351ffdb6e3397d(arg0) { - const ret = new Uint8ClampedArray(arg0 >>> 0); - return ret; -} -export function __wbg_next_42cf16ee0dafc9e2() { return handleError(function (arg0) { - const ret = arg0.next(); - return ret; -}, arguments); } -export function __wbg_next_8f26b64fa5e9f64b(arg0) { - const ret = arg0.next; - return ret; -} -export function __wbg_node_84ea875411254db1(arg0) { - const ret = arg0.node; - return ret; -} -export function __wbg_now_8b265300afd5f2b9() { - const ret = Date.now(); - return ret; -} -export function __wbg_now_e7c6795a7f81e10f(arg0) { - const ret = arg0.now(); - return ret; -} -export function __wbg_objectStoreNames_94ee5410bc505cae(arg0) { - const ret = arg0.objectStoreNames; - return ret; -} -export function __wbg_objectStore_222b7add2b5c2770() { return handleError(function (arg0, arg1, arg2) { - const ret = arg0.objectStore(getStringFromWasm0(arg1, arg2)); - return ret; -}, arguments); } -export function __wbg_oldVersion_92fccbad82f5635a(arg0) { - const ret = arg0.oldVersion; - return ret; -} -export function __wbg_olmmachine_new(arg0) { - const ret = OlmMachine.__wrap(arg0); - return ret; -} -export function __wbg_openCursor_1015e5f363cc8494() { return handleError(function (arg0) { - const ret = arg0.openCursor(); - return ret; -}, arguments); } -export function __wbg_openCursor_6dd512fe9cbf9f67() { return handleError(function (arg0, arg1) { - const ret = arg0.openCursor(arg1); - return ret; -}, arguments); } -export function __wbg_openCursor_f34b182699875701() { return handleError(function (arg0) { - const ret = arg0.openCursor(); - return ret; -}, arguments); } -export function __wbg_open_66c8b00ee562451f() { return handleError(function (arg0, arg1, arg2) { - const ret = arg0.open(getStringFromWasm0(arg1, arg2)); - return ret; -}, arguments); } -export function __wbg_open_c5ecda93515ce190() { return handleError(function (arg0, arg1, arg2, arg3) { - const ret = arg0.open(getStringFromWasm0(arg1, arg2), arg3 >>> 0); - return ret; -}, arguments); } -export function __wbg_otheruseridentity_new(arg0) { - const ret = OtherUserIdentity.__wrap(arg0); - return ret; -} -export function __wbg_ownuseridentity_new(arg0) { - const ret = OwnUserIdentity.__wrap(arg0); - return ret; -} -export function __wbg_parse_1cc93481b0865939() { return handleError(function (arg0, arg1) { - const ret = JSON.parse(getStringFromWasm0(arg0, arg1)); - return ret; -}, arguments); } -export function __wbg_performance_3fcf6e32a7e1ed0a(arg0) { - const ret = arg0.performance; - return ret; -} -export function __wbg_pickledinboundgroupsession_unwrap(arg0) { - const ret = PickledInboundGroupSession.__unwrap(arg0); - return ret; -} -export function __wbg_pickledsession_unwrap(arg0) { - const ret = PickledSession.__unwrap(arg0); - return ret; -} -export function __wbg_plaintexttodeviceevent_new(arg0) { - const ret = PlainTextToDeviceEvent.__wrap(arg0); - return ret; -} -export function __wbg_process_44c7a14e11e9f69e(arg0) { - const ret = arg0.process; - return ret; -} -export function __wbg_prototypesetcall_8798824fd302dd72(arg0, arg1, arg2) { - Uint8ClampedArray.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2); -} -export function __wbg_prototypesetcall_de8e0d9553586985(arg0, arg1, arg2) { - Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2); -} -export function __wbg_push_adb0107829f02d75(arg0, arg1) { - const ret = arg0.push(arg1); - return ret; -} -export function __wbg_put_5e0ae8c80bb952a7() { return handleError(function (arg0, arg1, arg2) { - const ret = arg0.put(arg1, arg2); - return ret; -}, arguments); } -export function __wbg_putdehydrateddevicerequest_new(arg0) { - const ret = PutDehydratedDeviceRequest.__wrap(arg0); - return ret; -} -export function __wbg_qr_new(arg0) { - const ret = Qr.__wrap(arg0); - return ret; -} -export function __wbg_queueMicrotask_ac694eae12e92dfb(arg0) { - queueMicrotask(arg0); -} -export function __wbg_queueMicrotask_be5fe34a8f4cad4d(arg0) { - const ret = arg0.queueMicrotask; - return ret; -} -export function __wbg_randomFillSync_6c25eac9869eb53c() { return handleError(function (arg0, arg1) { - arg0.randomFillSync(arg1); -}, arguments); } -export function __wbg_readyState_599831d0754935af(arg0) { - const ret = arg0.readyState; - return (__wbindgen_enum_IdbRequestReadyState.indexOf(ret) + 1 || 3) - 1; -} -export function __wbg_rehydrateddevice_new(arg0) { - const ret = RehydratedDevice.__wrap(arg0); - return ret; -} -export function __wbg_request_64abeba15a72c084(arg0) { - const ret = arg0.request; - return ret; -} -export function __wbg_request_72a78988f2edecad(arg0) { - const ret = arg0.request; - return ret; -} -export function __wbg_require_b4edbdcf3e2a1ef0() { return handleError(function () { - const ret = module.require; - return ret; -}, arguments); } -export function __wbg_resolve_020f95d838c6ef25(arg0) { - const ret = Promise.resolve(arg0); - return ret; -} -export function __wbg_result_0501bea148306f01() { return handleError(function (arg0) { - const ret = arg0.result; - return ret; -}, arguments); } -export function __wbg_roomid_unwrap(arg0) { - const ret = RoomId.__unwrap(arg0); - return ret; -} -export function __wbg_roomkeycounts_new(arg0) { - const ret = RoomKeyCounts.__wrap(arg0); - return ret; -} -export function __wbg_roomkeyimportresult_new(arg0) { - const ret = RoomKeyImportResult.__wrap(arg0); - return ret; -} -export function __wbg_roomkeyinfo_new(arg0) { - const ret = RoomKeyInfo.__wrap(arg0); - return ret; -} -export function __wbg_roomkeywithheldinfo_new(arg0) { - const ret = RoomKeyWithheldInfo.__wrap(arg0); - return ret; -} -export function __wbg_roommessagerequest_new(arg0) { - const ret = RoomMessageRequest.__wrap(arg0); - return ret; -} -export function __wbg_roompendingkeybundledetails_new(arg0) { - const ret = RoomPendingKeyBundleDetails.__wrap(arg0); - return ret; -} -export function __wbg_roomsettings_new(arg0) { - const ret = RoomSettings.__wrap(arg0); - return ret; -} -export function __wbg_sas_new(arg0) { - const ret = Sas.__wrap(arg0); - return ret; -} -export function __wbg_secretsbundle_new(arg0) { - const ret = SecretsBundle.__wrap(arg0); - return ret; -} -export function __wbg_setTimeout_56bcdccbad22fd44() { return handleError(function (arg0, arg1) { - const ret = setTimeout(arg0, arg1); - return ret; -}, arguments); } -export function __wbg_set_014226dfeca53178(arg0, arg1, arg2) { - const ret = arg0.set(arg1, arg2); - return ret; -} -export function __wbg_set_5c15d3c5973de97a(arg0, arg1, arg2) { - arg0.set(getArrayU8FromWasm0(arg1, arg2)); -} -export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) { - arg0[arg1] = arg2; -} -export function __wbg_set_a80955eb93b145c6(arg0, arg1, arg2) { - arg0[arg1 >>> 0] = arg2; -} -export function __wbg_set_onabort_fda794cb1089d6b5(arg0, arg1) { - arg0.onabort = arg1; -} -export function __wbg_set_oncomplete_ff31bdacaa1b3558(arg0, arg1) { - arg0.oncomplete = arg1; -} -export function __wbg_set_onerror_3dff0f2abceea5e9(arg0, arg1) { - arg0.onerror = arg1; -} -export function __wbg_set_onerror_41278ace6abe3973(arg0, arg1) { - arg0.onerror = arg1; -} -export function __wbg_set_onsuccess_86d76d6974cd57e4(arg0, arg1) { - arg0.onsuccess = arg1; -} -export function __wbg_set_onupgradeneeded_79b60102909f4a5e(arg0, arg1) { - arg0.onupgradeneeded = arg1; -} -export function __wbg_set_unique_c03185d3bf563306(arg0, arg1) { - arg0.unique = arg1 !== 0; -} -export function __wbg_signatures_new(arg0) { - const ret = Signatures.__wrap(arg0); - return ret; -} -export function __wbg_signatureuploadrequest_new(arg0) { - const ret = SignatureUploadRequest.__wrap(arg0); - return ret; -} -export function __wbg_signatureverification_new(arg0) { - const ret = SignatureVerification.__wrap(arg0); - return ret; -} -export function __wbg_stack_3b0d974bbf31e44f(arg0, arg1) { - const ret = arg1.stack; - const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); -} -export function __wbg_static_accessor_GLOBAL_THIS_466428f93b4eaa76() { - const ret = typeof globalThis === 'undefined' ? null : globalThis; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); -} -export function __wbg_static_accessor_GLOBAL_c7aea38d4de089bc() { - const ret = typeof global === 'undefined' ? null : global; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); -} -export function __wbg_static_accessor_SELF_42d4fae05e59267a() { - const ret = typeof self === 'undefined' ? null : self; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); -} -export function __wbg_static_accessor_WINDOW_e0db14a0eba6a812() { - const ret = typeof window === 'undefined' ? null : window; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); -} -export function __wbg_storedroomkeybundledata_new(arg0) { - const ret = StoredRoomKeyBundleData.__wrap(arg0); - return ret; -} -export function __wbg_storehandle_new(arg0) { - const ret = StoreHandle.__wrap(arg0); - return ret; -} -export function __wbg_stringify_f93a4ebae9231922() { return handleError(function (arg0) { - const ret = JSON.stringify(arg0); - return ret; -}, arguments); } -export function __wbg_subarray_a4cc58201c7359fd(arg0, arg1, arg2) { - const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0); - return ret; -} -export function __wbg_target_13424fe1cdc436ac(arg0) { - const ret = arg0.target; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); -} -export function __wbg_then_7026b513a94278a8(arg0, arg1) { - const ret = arg0.then(arg1); - return ret; -} -export function __wbg_then_72819b8d4e081fb5(arg0, arg1, arg2) { - const ret = arg0.then(arg1, arg2); - return ret; -} -export function __wbg_toString_2f0b0aec069cb718(arg0) { - const ret = arg0.toString(); - return ret; -} -export function __wbg_todevicerequest_new(arg0) { - const ret = ToDeviceRequest.__wrap(arg0); - return ret; -} -export function __wbg_transaction_0458565e8cdfb620(arg0) { - const ret = arg0.transaction; - return ret; -} -export function __wbg_transaction_4c999693e6e601bf() { return handleError(function (arg0, arg1, arg2) { - const ret = arg0.transaction(arg1, __wbindgen_enum_IdbTransactionMode[arg2]); - return ret; -}, arguments); } -export function __wbg_transaction_728366e915610cb0() { return handleError(function (arg0, arg1, arg2, arg3) { - const ret = arg0.transaction(getStringFromWasm0(arg1, arg2), __wbindgen_enum_IdbTransactionMode[arg3]); - return ret; -}, arguments); } -export function __wbg_transaction_77d93778cbec28c3(arg0) { - const ret = arg0.transaction; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); -} -export function __wbg_update_df04b6b83954c5a0() { return handleError(function (arg0, arg1) { - const ret = arg0.update(arg1); - return ret; -}, arguments); } -export function __wbg_upperBound_916ed065b0d6fe6c() { return handleError(function (arg0, arg1) { - const ret = IDBKeyRange.upperBound(arg0, arg1 !== 0); - return ret; -}, arguments); } -export function __wbg_userdevices_new(arg0) { - const ret = UserDevices.__wrap(arg0); - return ret; -} -export function __wbg_userid_new(arg0) { - const ret = UserId.__wrap(arg0); - return ret; -} -export function __wbg_userid_unwrap(arg0) { - const ret = UserId.__unwrap(arg0); - return ret; -} -export function __wbg_utdtodeviceevent_new(arg0) { - const ret = UTDToDeviceEvent.__wrap(arg0); - return ret; -} -export function __wbg_value_1e2369fab29b420e(arg0) { - const ret = arg0.value; - return ret; -} -export function __wbg_value_496e02446340ae74() { return handleError(function (arg0) { - const ret = arg0.value; - return ret; -}, arguments); } -export function __wbg_values_d512097b1a1a9459(arg0) { - const ret = arg0.values(); - return ret; -} -export function __wbg_verificationrequest_new(arg0) { - const ret = VerificationRequest.__wrap(arg0); - return ret; -} -export function __wbg_version_26237923fff15d6e(arg0) { - const ret = arg0.version; - return ret; -} -export function __wbg_versions_276b2795b1c6a219(arg0) { - const ret = arg0.versions; - return ret; -} -export function __wbg_warn_917d7f727ab78481(arg0) { - console.warn(arg0); -} -export function __wbg_warn_b62de6508e8608cc(arg0, arg1) { - arg0.warn(arg1); -} -export function __wbindgen_cast_0000000000000001(arg0, arg1) { - // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 164, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`. - const ret = makeMutClosure(arg0, arg1, wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke___wasm_bindgen_ff9af61e2d43a78a___JsValue__core_ed718c3d60ebd546___result__Result_____wasm_bindgen_ff9af61e2d43a78a___JsError___true_); - return ret; -} -export function __wbindgen_cast_0000000000000002(arg0, arg1) { - // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Event")], shim_idx: 558, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`. - const ret = makeMutClosure(arg0, arg1, wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke___web_sys_4ec35d1b8222c725___features__gen_Event__Event______true_); - return ret; -} -export function __wbindgen_cast_0000000000000003(arg0, arg1) { - // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("IDBVersionChangeEvent")], shim_idx: 164, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`. - const ret = makeMutClosure(arg0, arg1, wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke___wasm_bindgen_ff9af61e2d43a78a___JsValue__core_ed718c3d60ebd546___result__Result_____wasm_bindgen_ff9af61e2d43a78a___JsError___true__2); - return ret; -} -export function __wbindgen_cast_0000000000000004(arg0, arg1) { - // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 128, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`. - const ret = makeMutClosure(arg0, arg1, wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke_______true_); - return ret; -} -export function __wbindgen_cast_0000000000000005(arg0) { - // Cast intrinsic for `F64 -> Externref`. - const ret = arg0; - return ret; -} -export function __wbindgen_cast_0000000000000006(arg0) { - // Cast intrinsic for `I64 -> Externref`. - const ret = arg0; - return ret; -} -export function __wbindgen_cast_0000000000000007(arg0, arg1) { - // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`. - const ret = getArrayU8FromWasm0(arg0, arg1); - return ret; -} -export function __wbindgen_cast_0000000000000008(arg0, arg1) { - // Cast intrinsic for `Ref(String) -> Externref`. - const ret = getStringFromWasm0(arg0, arg1); - return ret; -} -export function __wbindgen_cast_0000000000000009(arg0) { - // Cast intrinsic for `U64 -> Externref`. - const ret = BigInt.asUintN(64, arg0); - return ret; -} -export function __wbindgen_cast_000000000000000a(arg0, arg1) { - var v0 = getArrayJsValueFromWasm0(arg0, arg1); - wasm.__wbindgen_free(arg0, arg1 * 4, 4); - // Cast intrinsic for `Vector(Externref) -> Externref`. - const ret = v0; - return ret; -} -export function __wbindgen_init_externref_table() { - const table = wasm.__wbindgen_externrefs; - const offset = table.grow(4); - table.set(0, undefined); - table.set(offset + 0, undefined); - table.set(offset + 1, null); - table.set(offset + 2, true); - table.set(offset + 3, false); -} -function wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke_______true_(arg0, arg1) { - wasm.wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke_______true_(arg0, arg1); -} - -function wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke___web_sys_4ec35d1b8222c725___features__gen_Event__Event______true_(arg0, arg1, arg2) { - wasm.wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke___web_sys_4ec35d1b8222c725___features__gen_Event__Event______true_(arg0, arg1, arg2); -} - -function wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke___wasm_bindgen_ff9af61e2d43a78a___JsValue__core_ed718c3d60ebd546___result__Result_____wasm_bindgen_ff9af61e2d43a78a___JsError___true_(arg0, arg1, arg2) { - const ret = wasm.wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke___wasm_bindgen_ff9af61e2d43a78a___JsValue__core_ed718c3d60ebd546___result__Result_____wasm_bindgen_ff9af61e2d43a78a___JsError___true_(arg0, arg1, arg2); - if (ret[1]) { - throw takeFromExternrefTable0(ret[0]); - } -} - -function wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke___wasm_bindgen_ff9af61e2d43a78a___JsValue__core_ed718c3d60ebd546___result__Result_____wasm_bindgen_ff9af61e2d43a78a___JsError___true__2(arg0, arg1, arg2) { - const ret = wasm.wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke___wasm_bindgen_ff9af61e2d43a78a___JsValue__core_ed718c3d60ebd546___result__Result_____wasm_bindgen_ff9af61e2d43a78a___JsError___true__2(arg0, arg1, arg2); - if (ret[1]) { - throw takeFromExternrefTable0(ret[0]); - } -} - -function wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke___js_sys_8badcad5ae9f3759___Function_fn_wasm_bindgen_ff9af61e2d43a78a___JsValue_____wasm_bindgen_ff9af61e2d43a78a___sys__Undefined___js_sys_8badcad5ae9f3759___Function_fn_wasm_bindgen_ff9af61e2d43a78a___JsValue_____wasm_bindgen_ff9af61e2d43a78a___sys__Undefined_______true_(arg0, arg1, arg2, arg3) { - wasm.wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke___js_sys_8badcad5ae9f3759___Function_fn_wasm_bindgen_ff9af61e2d43a78a___JsValue_____wasm_bindgen_ff9af61e2d43a78a___sys__Undefined___js_sys_8badcad5ae9f3759___Function_fn_wasm_bindgen_ff9af61e2d43a78a___JsValue_____wasm_bindgen_ff9af61e2d43a78a___sys__Undefined_______true_(arg0, arg1, arg2, arg3); -} - - -const __wbindgen_enum_IdbRequestReadyState = ["pending", "done"]; - - -const __wbindgen_enum_IdbTransactionMode = ["readonly", "readwrite", "versionchange", "readwriteflush", "cleanup"]; -const AttachmentFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_attachment_free(ptr, 1)); -const BackupDecryptionKeyFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_backupdecryptionkey_free(ptr, 1)); -const BackupKeysFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_backupkeys_free(ptr, 1)); -const BackupSecretsBundleFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_backupsecretsbundle_free(ptr, 1)); -const Base64EncodedPkMessageFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_base64encodedpkmessage_free(ptr, 1)); -const BaseMigrationDataFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_basemigrationdata_free(ptr, 1)); -const CancelInfoFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_cancelinfo_free(ptr, 1)); -const CheckCodeFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_checkcode_free(ptr, 1)); -const CollectStrategyFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_collectstrategy_free(ptr, 1)); -const CrossSigningBootstrapRequestsFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_crosssigningbootstraprequests_free(ptr, 1)); -const CrossSigningKeyExportFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_crosssigningkeyexport_free(ptr, 1)); -const CrossSigningStatusFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_crosssigningstatus_free(ptr, 1)); -const Curve25519PublicKeyFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_curve25519publickey_free(ptr, 1)); -const Curve25519SecretKeyFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_curve25519secretkey_free(ptr, 1)); -const DecryptedRoomEventFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_decryptedroomevent_free(ptr, 1)); -const DecryptedToDeviceEventFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_decryptedtodeviceevent_free(ptr, 1)); -const DecryptionSettingsFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_decryptionsettings_free(ptr, 1)); -const DehydratedDeviceFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_dehydrateddevice_free(ptr, 1)); -const DehydratedDeviceKeyFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_dehydrateddevicekey_free(ptr, 1)); -const DehydratedDevicesFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_dehydrateddevices_free(ptr, 1)); -const DeviceFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_device_free(ptr, 1)); -const DeviceIdFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_deviceid_free(ptr, 1)); -const DeviceKeyFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_devicekey_free(ptr, 1)); -const DeviceKeyAlgorithmFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_devicekeyalgorithm_free(ptr, 1)); -const DeviceKeyIdFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_devicekeyid_free(ptr, 1)); -const DeviceListsFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_devicelists_free(ptr, 1)); -const EciesFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_ecies_free(ptr, 1)); -const Ed25519PublicKeyFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_ed25519publickey_free(ptr, 1)); -const Ed25519SignatureFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_ed25519signature_free(ptr, 1)); -const EmojiFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_emoji_free(ptr, 1)); -const EncryptedAttachmentFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_encryptedattachment_free(ptr, 1)); -const EncryptionInfoFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_encryptioninfo_free(ptr, 1)); -const EncryptionSettingsFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_encryptionsettings_free(ptr, 1)); -const EstablishedEciesFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_establishedecies_free(ptr, 1)); -const EventIdFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_eventid_free(ptr, 1)); -const IdentityKeysFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_identitykeys_free(ptr, 1)); -const InboundCreationResultFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_inboundcreationresult_free(ptr, 1)); -const InboundGroupSessionFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_inboundgroupsession_free(ptr, 1)); -const InvalidToDeviceEventFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_invalidtodeviceevent_free(ptr, 1)); -const KeysBackupRequestFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_keysbackuprequest_free(ptr, 1)); -const KeysClaimRequestFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_keysclaimrequest_free(ptr, 1)); -const KeysQueryRequestFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_keysqueryrequest_free(ptr, 1)); -const KeysUploadRequestFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_keysuploadrequest_free(ptr, 1)); -const MaybeSignatureFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_maybesignature_free(ptr, 1)); -const MegolmDecryptionErrorFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_megolmdecryptionerror_free(ptr, 1)); -const MegolmV1BackupKeyFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_megolmv1backupkey_free(ptr, 1)); -const MigrationFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_migration_free(ptr, 1)); -const Msc4108IntentDataFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_msc4108intentdata_free(ptr, 1)); -const Msc4388IntentDataFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_msc4388intentdata_free(ptr, 1)); -const OlmMachineFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_olmmachine_free(ptr, 1)); -const OtherUserIdentityFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_otheruseridentity_free(ptr, 1)); -const OutboundCreationResultFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_outboundcreationresult_free(ptr, 1)); -const OwnUserIdentityFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_ownuseridentity_free(ptr, 1)); -const PickledInboundGroupSessionFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_pickledinboundgroupsession_free(ptr, 1)); -const PickledSessionFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_pickledsession_free(ptr, 1)); -const PkDecryptionFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_pkdecryption_free(ptr, 1)); -const PkEncryptionFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_pkencryption_free(ptr, 1)); -const PkMessageFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_pkmessage_free(ptr, 1)); -const PlainTextToDeviceEventFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_plaintexttodeviceevent_free(ptr, 1)); -const PutDehydratedDeviceRequestFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_putdehydrateddevicerequest_free(ptr, 1)); -const QrFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_qr_free(ptr, 1)); -const QrCodeFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_qrcode_free(ptr, 1)); -const QrCodeDataFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_qrcodedata_free(ptr, 1)); -const QrCodeIntentDataFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_qrcodeintentdata_free(ptr, 1)); -const QrCodeScanFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_qrcodescan_free(ptr, 1)); -const RehydratedDeviceFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_rehydrateddevice_free(ptr, 1)); -const RoomIdFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_roomid_free(ptr, 1)); -const RoomKeyCountsFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_roomkeycounts_free(ptr, 1)); -const RoomKeyImportResultFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_roomkeyimportresult_free(ptr, 1)); -const RoomKeyInfoFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_roomkeyinfo_free(ptr, 1)); -const RoomKeyWithheldInfoFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_roomkeywithheldinfo_free(ptr, 1)); -const RoomMessageRequestFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_roommessagerequest_free(ptr, 1)); -const RoomPendingKeyBundleDetailsFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_roompendingkeybundledetails_free(ptr, 1)); -const RoomSettingsFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_roomsettings_free(ptr, 1)); -const SasFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_sas_free(ptr, 1)); -const SecretsBundleFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_secretsbundle_free(ptr, 1)); -const ServerNameFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_servername_free(ptr, 1)); -const ShieldStateFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_shieldstate_free(ptr, 1)); -const SignatureFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_signature_free(ptr, 1)); -const SignatureUploadRequestFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_signatureuploadrequest_free(ptr, 1)); -const SignatureVerificationFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_signatureverification_free(ptr, 1)); -const SignaturesFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_signatures_free(ptr, 1)); -const StoreHandleFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_storehandle_free(ptr, 1)); -const StoredRoomKeyBundleDataFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_storedroomkeybundledata_free(ptr, 1)); -const ToDeviceEncryptionInfoFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_todeviceencryptioninfo_free(ptr, 1)); -const ToDeviceRequestFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_todevicerequest_free(ptr, 1)); -const ToDeviceUnableToDecryptInfoFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_todeviceunabletodecryptinfo_free(ptr, 1)); -const TracingFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_tracing_free(ptr, 1)); -const UTDToDeviceEventFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_utdtodeviceevent_free(ptr, 1)); -const UploadSigningKeysRequestFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_uploadsigningkeysrequest_free(ptr, 1)); -const UserDevicesFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_userdevices_free(ptr, 1)); -const UserIdFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_userid_free(ptr, 1)); -const VerificationRequestFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_verificationrequest_free(ptr, 1)); -const VersionsFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_versions_free(ptr, 1)); - -function addToExternrefTable0(obj) { - const idx = wasm.__externref_table_alloc(); - wasm.__wbindgen_externrefs.set(idx, obj); - return idx; -} - -function _assertClass(instance, klass) { - if (!(instance instanceof klass)) { - throw new Error(`expected instance of ${klass.name}`); - } -} - -const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(state => wasm.__wbindgen_destroy_closure(state.a, state.b)); - -function debugString(val) { - // primitive types - const type = typeof val; - if (type == 'number' || type == 'boolean' || val == null) { - return `${val}`; - } - if (type == 'string') { - return `"${val}"`; - } - if (type == 'symbol') { - const description = val.description; - if (description == null) { - return 'Symbol'; - } else { - return `Symbol(${description})`; - } - } - if (type == 'function') { - const name = val.name; - if (typeof name == 'string' && name.length > 0) { - return `Function(${name})`; - } else { - return 'Function'; - } - } - // objects - if (Array.isArray(val)) { - const length = val.length; - let debug = '['; - if (length > 0) { - debug += debugString(val[0]); - } - for(let i = 1; i < length; i++) { - debug += ', ' + debugString(val[i]); - } - debug += ']'; - return debug; - } - // Test for built-in - const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); - let className; - if (builtInMatches && builtInMatches.length > 1) { - className = builtInMatches[1]; - } else { - // Failed to match the standard '[object ClassName]' - return toString.call(val); - } - if (className == 'Object') { - // we're a user defined class or Object - // JSON.stringify avoids problems with cycles, and is generally much - // easier than looping through ownProperties of `val`. - try { - return 'Object(' + JSON.stringify(val) + ')'; - } catch (_) { - return 'Object'; - } - } - // errors - if (val instanceof Error) { - return `${val.name}: ${val.message}\n${val.stack}`; - } - // TODO we could test for more things here, like `Set`s and `Map`s. - return className; -} - -function getArrayJsValueFromWasm0(ptr, len) { - ptr = ptr >>> 0; - const mem = getDataViewMemory0(); - const result = []; - for (let i = ptr; i < ptr + 4 * len; i += 4) { - result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true))); - } - wasm.__externref_drop_slice(ptr, len); - return result; -} - -function getArrayU16FromWasm0(ptr, len) { - ptr = ptr >>> 0; - return getUint16ArrayMemory0().subarray(ptr / 2, ptr / 2 + len); -} - -function getArrayU8FromWasm0(ptr, len) { - ptr = ptr >>> 0; - return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len); -} - -let cachedDataViewMemory0 = null; -function getDataViewMemory0() { - if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) { - cachedDataViewMemory0 = new DataView(wasm.memory.buffer); - } - return cachedDataViewMemory0; -} - -function getStringFromWasm0(ptr, len) { - return decodeText(ptr >>> 0, len); -} - -let cachedUint16ArrayMemory0 = null; -function getUint16ArrayMemory0() { - if (cachedUint16ArrayMemory0 === null || cachedUint16ArrayMemory0.byteLength === 0) { - cachedUint16ArrayMemory0 = new Uint16Array(wasm.memory.buffer); - } - return cachedUint16ArrayMemory0; -} - -let cachedUint8ArrayMemory0 = null; -function getUint8ArrayMemory0() { - if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) { - cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer); - } - return cachedUint8ArrayMemory0; -} - -function handleError(f, args) { - try { - return f.apply(this, args); - } catch (e) { - const idx = addToExternrefTable0(e); - wasm.__wbindgen_exn_store(idx); - } -} - -function isLikeNone(x) { - return x === undefined || x === null; -} - -function makeMutClosure(arg0, arg1, f) { - const state = { a: arg0, b: arg1, cnt: 1 }; - const real = (...args) => { - - // First up with a closure we increment the internal reference - // count. This ensures that the Rust closure environment won't - // be deallocated while we're invoking it. - state.cnt++; - const a = state.a; - state.a = 0; - try { - return f(a, state.b, ...args); - } finally { - state.a = a; - real._wbg_cb_unref(); - } - }; - real._wbg_cb_unref = () => { - if (--state.cnt === 0) { - wasm.__wbindgen_destroy_closure(state.a, state.b); - state.a = 0; - CLOSURE_DTORS.unregister(state); - } - }; - CLOSURE_DTORS.register(real, state, state); - return real; -} - -function passArray8ToWasm0(arg, malloc) { - const ptr = malloc(arg.length * 1, 1) >>> 0; - getUint8ArrayMemory0().set(arg, ptr / 1); - WASM_VECTOR_LEN = arg.length; - return ptr; -} - -function passArrayJsValueToWasm0(array, malloc) { - const ptr = malloc(array.length * 4, 4) >>> 0; - for (let i = 0; i < array.length; i++) { - const add = addToExternrefTable0(array[i]); - getDataViewMemory0().setUint32(ptr + 4 * i, add, true); - } - WASM_VECTOR_LEN = array.length; - return ptr; -} - -function passStringToWasm0(arg, malloc, realloc) { - if (realloc === undefined) { - const buf = cachedTextEncoder.encode(arg); - const ptr = malloc(buf.length, 1) >>> 0; - getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf); - WASM_VECTOR_LEN = buf.length; - return ptr; - } - - let len = arg.length; - let ptr = malloc(len, 1) >>> 0; - - const mem = getUint8ArrayMemory0(); - - let offset = 0; - - for (; offset < len; offset++) { - const code = arg.charCodeAt(offset); - if (code > 0x7F) break; - mem[ptr + offset] = code; - } - if (offset !== len) { - if (offset !== 0) { - arg = arg.slice(offset); - } - ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; - const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len); - const ret = cachedTextEncoder.encodeInto(arg, view); - - offset += ret.written; - ptr = realloc(ptr, len, offset, 1) >>> 0; - } - - WASM_VECTOR_LEN = offset; - return ptr; -} - -function takeFromExternrefTable0(idx) { - const value = wasm.__wbindgen_externrefs.get(idx); - wasm.__externref_table_dealloc(idx); - return value; -} - -let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); -cachedTextDecoder.decode(); -const MAX_SAFARI_DECODE_BYTES = 2146435072; -let numBytesDecoded = 0; -function decodeText(ptr, len) { - numBytesDecoded += len; - if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) { - cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); - cachedTextDecoder.decode(); - numBytesDecoded = len; - } - return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len)); -} - -const cachedTextEncoder = new TextEncoder(); - -if (!('encodeInto' in cachedTextEncoder)) { - cachedTextEncoder.encodeInto = function (arg, view) { - const buf = cachedTextEncoder.encode(arg); - view.set(buf); - return { - read: arg.length, - written: buf.length - }; - }; -} - -let WASM_VECTOR_LEN = 0; - - -let wasm; -export function __wbg_set_wasm(val) { - wasm = val; -} diff --git a/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.wasm b/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.wasm deleted file mode 100644 index 7b5993c..0000000 Binary files a/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.wasm and /dev/null differ diff --git a/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.wasm.d.ts b/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.wasm.d.ts index 52cb9a1..2f23726 100644 --- a/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.wasm.d.ts +++ b/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.wasm.d.ts @@ -1,700 +1,404 @@ /* tslint:disable */ /* eslint-disable */ export const memory: WebAssembly.Memory; -export const __wbg_attachment_free: (a: number, b: number) => void; -export const __wbg_backupdecryptionkey_free: (a: number, b: number) => void; -export const __wbg_backupkeys_free: (a: number, b: number) => void; -export const __wbg_backupsecretsbundle_free: (a: number, b: number) => void; -export const __wbg_base64encodedpkmessage_free: (a: number, b: number) => void; -export const __wbg_basemigrationdata_free: (a: number, b: number) => void; -export const __wbg_cancelinfo_free: (a: number, b: number) => void; -export const __wbg_checkcode_free: (a: number, b: number) => void; -export const __wbg_collectstrategy_free: (a: number, b: number) => void; -export const __wbg_crosssigningbootstraprequests_free: (a: number, b: number) => void; -export const __wbg_crosssigningkeyexport_free: (a: number, b: number) => void; -export const __wbg_curve25519publickey_free: (a: number, b: number) => void; -export const __wbg_curve25519secretkey_free: (a: number, b: number) => void; -export const __wbg_decryptedroomevent_free: (a: number, b: number) => void; -export const __wbg_decryptedtodeviceevent_free: (a: number, b: number) => void; -export const __wbg_decryptionsettings_free: (a: number, b: number) => void; -export const __wbg_dehydrateddevice_free: (a: number, b: number) => void; -export const __wbg_dehydrateddevicekey_free: (a: number, b: number) => void; -export const __wbg_dehydrateddevices_free: (a: number, b: number) => void; -export const __wbg_device_free: (a: number, b: number) => void; -export const __wbg_deviceid_free: (a: number, b: number) => void; -export const __wbg_devicekey_free: (a: number, b: number) => void; -export const __wbg_devicekeyalgorithm_free: (a: number, b: number) => void; -export const __wbg_devicekeyid_free: (a: number, b: number) => void; -export const __wbg_devicelists_free: (a: number, b: number) => void; -export const __wbg_ecies_free: (a: number, b: number) => void; -export const __wbg_ed25519publickey_free: (a: number, b: number) => void; -export const __wbg_ed25519signature_free: (a: number, b: number) => void; -export const __wbg_emoji_free: (a: number, b: number) => void; -export const __wbg_encryptedattachment_free: (a: number, b: number) => void; -export const __wbg_encryptioninfo_free: (a: number, b: number) => void; -export const __wbg_encryptionsettings_free: (a: number, b: number) => void; -export const __wbg_establishedecies_free: (a: number, b: number) => void; -export const __wbg_get_backupkeys_backupVersion: (a: number) => [number, number]; -export const __wbg_get_backupkeys_decryptionKey: (a: number) => number; -export const __wbg_get_backupsecretsbundle_backup_version: (a: number) => [number, number]; -export const __wbg_get_backupsecretsbundle_key: (a: number) => [number, number]; -export const __wbg_get_base64encodedpkmessage_ephemeralKey: (a: number) => [number, number]; -export const __wbg_get_basemigrationdata_backupRecoveryKey: (a: number) => [number, number]; -export const __wbg_get_basemigrationdata_backupVersion: (a: number) => [number, number]; -export const __wbg_get_basemigrationdata_deviceId: (a: number) => number; -export const __wbg_get_basemigrationdata_privateCrossSigningMasterKey: (a: number) => [number, number]; -export const __wbg_get_basemigrationdata_privateCrossSigningSelfSigningKey: (a: number) => [number, number]; -export const __wbg_get_basemigrationdata_privateCrossSigningUserSigningKey: (a: number) => [number, number]; -export const __wbg_get_basemigrationdata_userId: (a: number) => number; -export const __wbg_get_crosssigningbootstraprequests_uploadKeysRequest: (a: number) => any; -export const __wbg_get_crosssigningbootstraprequests_uploadSignaturesRequest: (a: number) => number; -export const __wbg_get_crosssigningbootstraprequests_uploadSigningKeysRequest: (a: number) => number; -export const __wbg_get_decryptedroomevent_event: (a: number) => any; -export const __wbg_get_decryptedtodeviceevent_encryptionInfo: (a: number) => number; -export const __wbg_get_decryptedtodeviceevent_rawEvent: (a: number) => any; -export const __wbg_get_decryptionsettings_sender_device_trust_requirement: (a: number) => number; -export const __wbg_get_encryptioninfo_forwarder: (a: number) => number; -export const __wbg_get_encryptioninfo_forwarderDevice: (a: number) => number; -export const __wbg_get_encryptioninfo_sender: (a: number) => number; -export const __wbg_get_encryptioninfo_senderDevice: (a: number) => number; -export const __wbg_get_encryptionsettings_algorithm: (a: number) => number; -export const __wbg_get_encryptionsettings_encryptStateEvents: (a: number) => number; -export const __wbg_get_encryptionsettings_historyVisibility: (a: number) => number; -export const __wbg_get_encryptionsettings_rotationPeriod: (a: number) => bigint; -export const __wbg_get_encryptionsettings_rotationPeriodMessages: (a: number) => bigint; -export const __wbg_get_encryptionsettings_sharingStrategy: (a: number) => number; -export const __wbg_get_identitykeys_curve25519: (a: number) => number; -export const __wbg_get_identitykeys_ed25519: (a: number) => number; -export const __wbg_get_inboundcreationresult_channel: (a: number) => number; -export const __wbg_get_invalidtodeviceevent_rawEvent: (a: number) => any; -export const __wbg_get_keysbackuprequest_body: (a: number) => any; -export const __wbg_get_keysbackuprequest_version: (a: number) => any; -export const __wbg_get_megolmdecryptionerror_code: (a: number) => number; -export const __wbg_get_pickledinboundgroupsession_backedUp: (a: number) => number; -export const __wbg_get_pickledinboundgroupsession_imported: (a: number) => number; -export const __wbg_get_pickledinboundgroupsession_roomId: (a: number) => number; -export const __wbg_get_pickledsession_createdUsingFallbackKey: (a: number) => number; -export const __wbg_get_pickledsession_creationTime: (a: number) => any; -export const __wbg_get_pickledsession_lastUseTime: (a: number) => any; -export const __wbg_get_putdehydrateddevicerequest_body: (a: number) => any; -export const __wbg_get_qrcodeintentdata_msc4108: (a: number) => number; -export const __wbg_get_qrcodeintentdata_msc4388: (a: number) => number; -export const __wbg_get_roomkeycounts_backedUp: (a: number) => number; -export const __wbg_get_roomkeycounts_total: (a: number) => number; -export const __wbg_get_roomkeyimportresult_importedCount: (a: number) => number; -export const __wbg_get_roomkeyimportresult_totalCount: (a: number) => number; -export const __wbg_get_roommessagerequest_body: (a: number) => any; -export const __wbg_get_roomsettings_algorithm: (a: number) => number; -export const __wbg_get_roomsettings_encryptStateEvents: (a: number) => number; -export const __wbg_get_roomsettings_onlyAllowTrustedDevices: (a: number) => number; -export const __wbg_get_roomsettings_sessionRotationPeriodMessages: (a: number) => [number, number]; -export const __wbg_get_roomsettings_sessionRotationPeriodMs: (a: number) => [number, number]; -export const __wbg_get_shieldstate_code: (a: number) => number; -export const __wbg_get_shieldstate_color: (a: number) => number; -export const __wbg_get_signatureuploadrequest_id: (a: number) => any; -export const __wbg_get_todeviceencryptioninfo_sender: (a: number) => number; -export const __wbg_get_todeviceencryptioninfo_senderDevice: (a: number) => number; -export const __wbg_get_todeviceunabletodecryptinfo_reason: (a: number) => number; -export const __wbg_get_utdtodeviceevent_utdInfo: (a: number) => number; -export const __wbg_identitykeys_free: (a: number, b: number) => void; -export const __wbg_inboundcreationresult_free: (a: number, b: number) => void; -export const __wbg_inboundgroupsession_free: (a: number, b: number) => void; -export const __wbg_invalidtodeviceevent_free: (a: number, b: number) => void; -export const __wbg_keysbackuprequest_free: (a: number, b: number) => void; -export const __wbg_keysclaimrequest_free: (a: number, b: number) => void; -export const __wbg_maybesignature_free: (a: number, b: number) => void; -export const __wbg_megolmdecryptionerror_free: (a: number, b: number) => void; -export const __wbg_megolmv1backupkey_free: (a: number, b: number) => void; -export const __wbg_msc4108intentdata_free: (a: number, b: number) => void; -export const __wbg_msc4388intentdata_free: (a: number, b: number) => void; -export const __wbg_olmmachine_free: (a: number, b: number) => void; -export const __wbg_otheruseridentity_free: (a: number, b: number) => void; -export const __wbg_ownuseridentity_free: (a: number, b: number) => void; -export const __wbg_pickledinboundgroupsession_free: (a: number, b: number) => void; -export const __wbg_pickledsession_free: (a: number, b: number) => void; -export const __wbg_pkdecryption_free: (a: number, b: number) => void; -export const __wbg_pkencryption_free: (a: number, b: number) => void; -export const __wbg_pkmessage_free: (a: number, b: number) => void; -export const __wbg_putdehydrateddevicerequest_free: (a: number, b: number) => void; -export const __wbg_qr_free: (a: number, b: number) => void; -export const __wbg_qrcode_free: (a: number, b: number) => void; -export const __wbg_qrcodedata_free: (a: number, b: number) => void; -export const __wbg_qrcodeintentdata_free: (a: number, b: number) => void; -export const __wbg_qrcodescan_free: (a: number, b: number) => void; -export const __wbg_rehydrateddevice_free: (a: number, b: number) => void; -export const __wbg_roomkeycounts_free: (a: number, b: number) => void; -export const __wbg_roomkeyimportresult_free: (a: number, b: number) => void; -export const __wbg_roomkeyinfo_free: (a: number, b: number) => void; -export const __wbg_roomkeywithheldinfo_free: (a: number, b: number) => void; -export const __wbg_roommessagerequest_free: (a: number, b: number) => void; -export const __wbg_roompendingkeybundledetails_free: (a: number, b: number) => void; -export const __wbg_roomsettings_free: (a: number, b: number) => void; -export const __wbg_sas_free: (a: number, b: number) => void; -export const __wbg_secretsbundle_free: (a: number, b: number) => void; -export const __wbg_set_backupkeys_backupVersion: (a: number, b: number, c: number) => void; -export const __wbg_set_backupkeys_decryptionKey: (a: number, b: number) => void; -export const __wbg_set_backupsecretsbundle_backup_version: (a: number, b: number, c: number) => void; -export const __wbg_set_backupsecretsbundle_key: (a: number, b: number, c: number) => void; -export const __wbg_set_base64encodedpkmessage_ephemeralKey: (a: number, b: number, c: number) => void; -export const __wbg_set_basemigrationdata_backupRecoveryKey: (a: number, b: number, c: number) => void; -export const __wbg_set_basemigrationdata_backupVersion: (a: number, b: number, c: number) => void; -export const __wbg_set_basemigrationdata_deviceId: (a: number, b: number) => void; -export const __wbg_set_basemigrationdata_privateCrossSigningMasterKey: (a: number, b: number, c: number) => void; -export const __wbg_set_basemigrationdata_privateCrossSigningSelfSigningKey: (a: number, b: number, c: number) => void; -export const __wbg_set_basemigrationdata_privateCrossSigningUserSigningKey: (a: number, b: number, c: number) => void; -export const __wbg_set_basemigrationdata_userId: (a: number, b: number) => void; -export const __wbg_set_decryptionsettings_sender_device_trust_requirement: (a: number, b: number) => void; -export const __wbg_set_encryptioninfo_forwarder: (a: number, b: number) => void; -export const __wbg_set_encryptioninfo_forwarderDevice: (a: number, b: number) => void; -export const __wbg_set_encryptioninfo_sender: (a: number, b: number) => void; -export const __wbg_set_encryptioninfo_senderDevice: (a: number, b: number) => void; -export const __wbg_set_encryptionsettings_algorithm: (a: number, b: number) => void; -export const __wbg_set_encryptionsettings_encryptStateEvents: (a: number, b: number) => void; -export const __wbg_set_encryptionsettings_historyVisibility: (a: number, b: number) => void; -export const __wbg_set_encryptionsettings_rotationPeriod: (a: number, b: bigint) => void; -export const __wbg_set_encryptionsettings_rotationPeriodMessages: (a: number, b: bigint) => void; -export const __wbg_set_encryptionsettings_sharingStrategy: (a: number, b: number) => void; -export const __wbg_set_identitykeys_curve25519: (a: number, b: number) => void; -export const __wbg_set_identitykeys_ed25519: (a: number, b: number) => void; -export const __wbg_set_inboundcreationresult_channel: (a: number, b: number) => void; -export const __wbg_set_pickledinboundgroupsession_backedUp: (a: number, b: number) => void; -export const __wbg_set_pickledinboundgroupsession_imported: (a: number, b: number) => void; -export const __wbg_set_pickledinboundgroupsession_roomId: (a: number, b: number) => void; -export const __wbg_set_pickledsession_createdUsingFallbackKey: (a: number, b: number) => void; -export const __wbg_set_pickledsession_creationTime: (a: number, b: any) => void; -export const __wbg_set_pickledsession_lastUseTime: (a: number, b: any) => void; -export const __wbg_set_qrcodeintentdata_msc4108: (a: number, b: number) => void; -export const __wbg_set_qrcodeintentdata_msc4388: (a: number, b: number) => void; -export const __wbg_set_roomkeycounts_backedUp: (a: number, b: number) => void; -export const __wbg_set_roomkeycounts_total: (a: number, b: number) => void; -export const __wbg_set_roomsettings_algorithm: (a: number, b: number) => void; -export const __wbg_set_roomsettings_encryptStateEvents: (a: number, b: number) => void; -export const __wbg_set_roomsettings_onlyAllowTrustedDevices: (a: number, b: number) => void; -export const __wbg_set_roomsettings_sessionRotationPeriodMessages: (a: number, b: number, c: number) => void; -export const __wbg_set_roomsettings_sessionRotationPeriodMs: (a: number, b: number, c: number) => void; -export const __wbg_set_shieldstate_code: (a: number, b: number) => void; -export const __wbg_set_shieldstate_color: (a: number, b: number) => void; -export const __wbg_set_todeviceencryptioninfo_sender: (a: number, b: number) => void; -export const __wbg_set_todeviceencryptioninfo_senderDevice: (a: number, b: number) => void; -export const __wbg_set_todeviceunabletodecryptinfo_reason: (a: number, b: number) => void; -export const __wbg_shieldstate_free: (a: number, b: number) => void; -export const __wbg_signature_free: (a: number, b: number) => void; -export const __wbg_signatures_free: (a: number, b: number) => void; -export const __wbg_signatureuploadrequest_free: (a: number, b: number) => void; -export const __wbg_signatureverification_free: (a: number, b: number) => void; -export const __wbg_storedroomkeybundledata_free: (a: number, b: number) => void; -export const __wbg_storehandle_free: (a: number, b: number) => void; -export const __wbg_todeviceencryptioninfo_free: (a: number, b: number) => void; -export const __wbg_todevicerequest_free: (a: number, b: number) => void; -export const __wbg_todeviceunabletodecryptinfo_free: (a: number, b: number) => void; -export const __wbg_tracing_free: (a: number, b: number) => void; -export const __wbg_userdevices_free: (a: number, b: number) => void; -export const __wbg_utdtodeviceevent_free: (a: number, b: number) => void; -export const __wbg_verificationrequest_free: (a: number, b: number) => void; -export const __wbg_versions_free: (a: number, b: number) => void; -export const attachment_decrypt: (a: number) => [number, number, number, number]; -export const attachment_encrypt: (a: number, b: number) => [number, number, number]; -export const backupdecryptionkey_createRandomKey: () => number; -export const backupdecryptionkey_decryptV1: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number, number]; -export const backupdecryptionkey_fromBase64: (a: number, b: number) => [number, number, number]; -export const backupdecryptionkey_megolmV1PublicKey: (a: number) => number; -export const backupdecryptionkey_toBase64: (a: number) => any; -export const backupkeys_decryptionKeyBase64: (a: number) => any; -export const base64encodedpkmessage_new: (a: number, b: number, c: number, d: number, e: number, f: number) => number; -export const basemigrationdata_new: () => number; -export const cancelinfo_cancelCode: (a: number) => [number, number]; -export const cancelinfo_cancelledbyUs: (a: number) => number; -export const cancelinfo_reason: (a: number) => any; -export const checkcode_as_bytes: (a: number) => [number, number]; -export const checkcode_toDigitNoLeadingZero: (a: number) => number; -export const checkcode_to_digit: (a: number) => number; -export const collectstrategy_allDevices: () => number; -export const collectstrategy_deviceBasedStrategy: (a: number, b: number) => number; -export const collectstrategy_eq: (a: number, b: number) => number; -export const collectstrategy_errorOnUnverifiedUserProblem: () => number; -export const collectstrategy_identityBasedStrategy: () => number; -export const collectstrategy_onlyTrustedDevices: () => number; -export const crosssigningkeyexport_masterKey: (a: number) => [number, number]; -export const crosssigningkeyexport_self_signing_key: (a: number) => [number, number]; -export const crosssigningkeyexport_userSigningKey: (a: number) => [number, number]; -export const crosssigningstatus_hasMaster: (a: number) => number; -export const crosssigningstatus_hasSelfSigning: (a: number) => number; -export const crosssigningstatus_hasUserSigning: (a: number) => number; -export const curve25519publickey_length: (a: number) => number; -export const curve25519publickey_new: (a: number, b: number) => [number, number, number]; -export const curve25519publickey_toBase64: (a: number) => [number, number]; -export const curve25519secretkey_fromBase64: (a: number, b: number) => [number, number, number]; -export const curve25519secretkey_fromUint8Array: (a: number, b: number) => [number, number, number]; -export const curve25519secretkey_new: () => number; -export const curve25519secretkey_toBase64: (a: number) => [number, number]; -export const curve25519secretkey_toUint8Array: (a: number) => [number, number]; -export const decryptedroomevent_forwarder: (a: number) => number; -export const decryptedroomevent_forwarderDevice: (a: number) => number; -export const decryptedroomevent_forwardingCurve25519KeyChain: (a: number) => any; -export const decryptedroomevent_sender: (a: number) => number; -export const decryptedroomevent_senderClaimedEd25519Key: (a: number) => any; -export const decryptedroomevent_senderCurve25519Key: (a: number) => [number, number]; -export const decryptedroomevent_senderDevice: (a: number) => number; -export const decryptedroomevent_shieldState: (a: number, b: number) => number; -export const decryptedtodeviceevent_type: (a: number) => number; -export const decryptionsettings_new: (a: number) => number; -export const dehydrateddevice_keysForUpload: (a: number, b: any, c: number) => any; -export const dehydrateddevicekey_createKeyFromArray: (a: any) => [number, number, number]; -export const dehydrateddevicekey_toBase64: (a: number) => any; -export const dehydrateddevices_create: (a: number) => any; -export const dehydrateddevices_deleteDehydratedDeviceKey: (a: number) => any; -export const dehydrateddevices_getDehydratedDeviceKey: (a: number) => any; -export const dehydrateddevices_rehydrate: (a: number, b: number, c: number, d: number, e: number) => any; -export const dehydrateddevices_saveDehydratedDeviceKey: (a: number, b: number) => any; -export const device_algorithms: (a: number) => any; -export const device_curve25519Key: (a: number) => number; -export const device_deviceId: (a: number) => number; -export const device_displayName: (a: number) => [number, number]; -export const device_ed25519Key: (a: number) => number; -export const device_encryptToDeviceEvent: (a: number, b: number, c: number, d: any, e: number) => any; -export const device_firstTimeSeen: (a: number) => bigint; -export const device_getKey: (a: number, b: number) => [number, number, number]; -export const device_isBlacklisted: (a: number) => number; -export const device_isCrossSignedByOwner: (a: number) => number; -export const device_isCrossSigningTrusted: (a: number) => number; -export const device_isDehydrated: (a: number) => number; -export const device_isDeleted: (a: number) => number; -export const device_isLocallyTrusted: (a: number) => number; -export const device_isVerified: (a: number) => number; -export const device_keys: (a: number) => any; -export const device_localTrustState: (a: number) => number; -export const device_requestVerification: (a: number, b: number, c: number) => [number, number, number]; -export const device_setLocalTrust: (a: number, b: number) => any; -export const device_signatures: (a: number) => number; -export const device_userId: (a: number) => number; -export const device_verify: (a: number) => any; -export const deviceid_new: (a: number, b: number) => number; -export const deviceid_toString: (a: number) => [number, number]; -export const devicekey_curve25519: (a: number) => number; -export const devicekey_ed25519: (a: number) => number; -export const devicekey_name: (a: number) => number; -export const devicekey_toBase64: (a: number) => [number, number]; -export const devicekey_unknown: (a: number) => [number, number]; -export const devicekeyalgorithm_name: (a: number) => number; -export const devicekeyalgorithm_toString: (a: number) => [number, number]; -export const devicekeyid_algorithm: (a: number) => number; -export const devicekeyid_deviceId: (a: number) => number; -export const devicekeyid_new: (a: number, b: number) => [number, number, number]; -export const devicekeyid_toString: (a: number) => [number, number]; -export const devicelists_changed: (a: number) => [number, number]; -export const devicelists_isEmpty: (a: number) => number; -export const devicelists_left: (a: number) => [number, number]; -export const devicelists_new: (a: number, b: number, c: number, d: number) => [number, number, number]; -export const ecies_establish_inbound_channel: (a: number, b: number, c: number) => [number, number, number]; -export const ecies_establish_outbound_channel: (a: number, b: number, c: number, d: number) => [number, number, number]; -export const ecies_new: () => number; -export const ecies_public_key: (a: number) => number; -export const ed25519publickey_length: (a: number) => number; -export const ed25519publickey_toBase64: (a: number) => [number, number]; -export const ed25519signature_new: (a: number, b: number) => [number, number, number]; -export const ed25519signature_toBase64: (a: number) => [number, number]; -export const emoji_description: (a: number) => any; -export const emoji_symbol: (a: number) => any; -export const encryptedattachment_encryptedData: (a: number) => [number, number]; -export const encryptedattachment_hasMediaEncryptionInfoBeenConsumed: (a: number) => number; -export const encryptedattachment_mediaEncryptionInfo: (a: number) => [number, number]; -export const encryptedattachment_new: (a: number, b: number, c: number, d: number) => [number, number, number]; -export const encryptioninfo_shieldState: (a: number, b: number) => number; -export const encryptionsettings_new: () => number; -export const establishedecies_check_code: (a: number) => number; -export const establishedecies_decrypt: (a: number, b: number, c: number) => [number, number, number, number]; -export const establishedecies_encrypt: (a: number, b: number, c: number) => [number, number]; -export const establishedecies_public_key: (a: number) => number; -export const eventid_localpart: (a: number) => [number, number]; -export const eventid_new: (a: number, b: number) => [number, number, number]; -export const eventid_serverName: (a: number) => number; -export const getVersions: () => number; -export const inboundgroupsession_hasBeenImported: (a: number) => number; -export const inboundgroupsession_roomId: (a: number) => number; -export const inboundgroupsession_senderKey: (a: number) => number; -export const inboundgroupsession_sessionId: (a: number) => [number, number]; -export const invalidtodeviceevent_type: (a: number) => number; -export const keysbackuprequest_new: (a: any, b: any, c: any) => number; -export const keysbackuprequest_type: (a: number) => number; -export const keysclaimrequest_new: (a: any, b: any) => number; -export const keysclaimrequest_type: (a: number) => number; -export const keysqueryrequest_type: (a: number) => number; -export const keysuploadrequest_type: (a: number) => number; -export const maybesignature_invalidSignatureSource: (a: number) => [number, number]; -export const maybesignature_isInvalid: (a: number) => number; -export const maybesignature_isValid: (a: number) => number; -export const maybesignature_signature: (a: number) => number; -export const megolmdecryptionerror_maybe_withheld: (a: number) => [number, number]; -export const megolmdecryptionerror_unable_to_decrypt: (a: number, b: number) => number; -export const megolmdecryptionerror_withheldCode: (a: number) => [number, number]; -export const megolmv1backupkey_algorithm: (a: number) => any; -export const megolmv1backupkey_publicKeyBase64: (a: number) => any; -export const migration_migrateBaseData: (a: number, b: any, c: number, d: number) => any; -export const migration_migrateMegolmSessions: (a: number, b: number, c: any, d: number, e: number) => [number, number, number]; -export const migration_migrateOlmSessions: (a: number, b: number, c: any, d: number, e: number) => [number, number, number]; -export const olmmachine_backupRoomKeys: (a: number) => any; -export const olmmachine_bootstrapCrossSigning: (a: number, b: number) => any; -export const olmmachine_buildRoomKeyBundle: (a: number, b: number) => any; -export const olmmachine_clearRoomPendingKeyBundle: (a: number, b: number) => any; -export const olmmachine_close: (a: number) => void; -export const olmmachine_crossSigningStatus: (a: number) => any; -export const olmmachine_decryptExportedRoomKeys: (a: number, b: number, c: number, d: number) => [number, number, number, number]; -export const olmmachine_decryptRoomEvent: (a: number, b: number, c: number, d: number, e: number) => [number, number, number]; -export const olmmachine_dehydratedDevices: (a: number) => number; -export const olmmachine_deleteSecretsFromInbox: (a: number, b: number, c: number) => any; -export const olmmachine_deviceCreationTimeMs: (a: number) => number; -export const olmmachine_deviceId: (a: number) => number; -export const olmmachine_disableBackup: (a: number) => any; -export const olmmachine_displayName: (a: number) => any; -export const olmmachine_enableBackupV1: (a: number, b: number, c: number, d: number, e: number) => [number, number, number]; -export const olmmachine_encryptExportedRoomKeys: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number]; -export const olmmachine_encryptRoomEvent: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number]; -export const olmmachine_encryptStateEvent: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number]; -export const olmmachine_exportCrossSigningKeys: (a: number) => any; -export const olmmachine_exportRoomKeys: (a: number, b: any) => any; -export const olmmachine_exportSecretsBundle: (a: number) => any; -export const olmmachine_getAllRoomsPendingKeyBundles: (a: number) => any; -export const olmmachine_getBackupKeys: (a: number) => any; -export const olmmachine_getDevice: (a: number, b: number, c: number, d: number, e: number) => any; -export const olmmachine_getIdentity: (a: number, b: number) => any; -export const olmmachine_getMissingSessions: (a: number, b: number, c: number) => any; -export const olmmachine_getPendingKeyBundleDetailsForRoom: (a: number, b: number) => any; -export const olmmachine_getReceivedRoomKeyBundleData: (a: number, b: number, c: number) => any; -export const olmmachine_getRoomEventEncryptionInfo: (a: number, b: number, c: number, d: number) => [number, number, number]; -export const olmmachine_getRoomSettings: (a: number, b: number) => any; -export const olmmachine_getSecretsFromInbox: (a: number, b: number, c: number) => any; -export const olmmachine_getUserDevices: (a: number, b: number, c: number, d: number) => any; -export const olmmachine_getVerification: (a: number, b: number, c: number, d: number) => [number, number, number]; -export const olmmachine_getVerificationRequest: (a: number, b: number, c: number, d: number) => number; -export const olmmachine_getVerificationRequests: (a: number, b: number) => any; -export const olmmachine_hasDownloadedAllRoomKeys: (a: number, b: number) => any; -export const olmmachine_identityKeys: (a: number) => number; -export const olmmachine_importBackedUpRoomKeys: (a: number, b: any, c: number, d: number, e: number) => [number, number, number]; -export const olmmachine_importCrossSigningKeys: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any; -export const olmmachine_importExportedRoomKeys: (a: number, b: number, c: number, d: any) => [number, number, number]; -export const olmmachine_importRoomKeys: (a: number, b: number, c: number, d: any) => [number, number, number]; -export const olmmachine_importSecretsBundle: (a: number, b: number) => any; -export const olmmachine_initFromStore: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => any; -export const olmmachine_initialize: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => any; -export const olmmachine_invalidateGroupSession: (a: number, b: number) => any; -export const olmmachine_isBackupEnabled: (a: number) => any; -export const olmmachine_markAllTrackedUsersAsDirty: (a: number) => any; -export const olmmachine_markRequestAsSent: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number]; -export const olmmachine_new: () => [number, number, number]; -export const olmmachine_outgoingRequests: (a: number) => any; -export const olmmachine_pushSecretToVerifiedDevices: (a: number, b: number, c: number) => any; -export const olmmachine_queryKeysForUsers: (a: number, b: number, c: number) => [number, number, number]; -export const olmmachine_receiveRoomKeyBundle: (a: number, b: number, c: number, d: number) => [number, number, number]; -export const olmmachine_receiveSyncChanges: (a: number, b: number, c: number, d: number, e: any, f: number, g: number) => [number, number, number]; -export const olmmachine_receiveSyncChangesMsc4186: (a: number, b: number, c: number, d: number, e: any, f: number, g: number) => [number, number, number]; -export const olmmachine_receiveVerificationEvent: (a: number, b: number, c: number, d: number) => [number, number, number]; -export const olmmachine_registerDevicesUpdatedCallback: (a: number, b: any) => void; -export const olmmachine_registerReceiveSecretCallback: (a: number, b: any) => void; -export const olmmachine_registerRoomKeyUpdatedCallback: (a: number, b: any) => void; -export const olmmachine_registerRoomKeysWithheldCallback: (a: number, b: any) => void; -export const olmmachine_registerUserIdentityUpdatedCallback: (a: number, b: any) => void; -export const olmmachine_requestMissingSecretsIfNeeded: (a: number) => any; -export const olmmachine_roomKeyCounts: (a: number) => any; -export const olmmachine_roomKeyForwardingEnabled: (a: number) => number; -export const olmmachine_roomKeyRequestsEnabled: (a: number) => number; -export const olmmachine_saveBackupDecryptionKey: (a: number, b: number, c: number, d: number) => any; -export const olmmachine_setHasDownloadedAllRoomKeys: (a: number, b: number) => any; -export const olmmachine_setRoomSettings: (a: number, b: number, c: number) => any; -export const olmmachine_set_roomKeyForwardingEnabled: (a: number, b: number) => void; -export const olmmachine_set_roomKeyRequestsEnabled: (a: number, b: number) => void; -export const olmmachine_shareRoomKey: (a: number, b: number, c: number, d: number, e: number) => any; -export const olmmachine_shareRoomKeyBundleData: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number]; -export const olmmachine_sign: (a: number, b: number, c: number) => any; -export const olmmachine_storeRoomPendingKeyBundle: (a: number, b: number, c: number) => any; -export const olmmachine_trackedUsers: (a: number) => [number, number, number]; -export const olmmachine_updateTrackedUsers: (a: number, b: number, c: number) => any; -export const olmmachine_userId: (a: number) => number; -export const olmmachine_verifyBackup: (a: number, b: any) => [number, number, number]; -export const otheruseridentity_hasVerificationViolation: (a: number) => number; -export const otheruseridentity_identityNeedsUserApproval: (a: number) => number; -export const otheruseridentity_isVerified: (a: number) => number; -export const otheruseridentity_masterKey: (a: number) => [number, number, number, number]; -export const otheruseridentity_pinCurrentMasterKey: (a: number) => any; -export const otheruseridentity_requestVerification: (a: number, b: number, c: number, d: number, e: number) => [number, number, number]; -export const otheruseridentity_selfSigningKey: (a: number) => [number, number, number, number]; -export const otheruseridentity_verificationRequestContent: (a: number, b: number, c: number) => [number, number, number, number]; -export const otheruseridentity_verify: (a: number) => any; -export const otheruseridentity_wasPreviouslyVerified: (a: number) => number; -export const otheruseridentity_withdrawVerification: (a: number) => any; -export const ownuseridentity_hasVerificationViolation: (a: number) => number; -export const ownuseridentity_isVerified: (a: number) => number; -export const ownuseridentity_masterKey: (a: number) => [number, number, number, number]; -export const ownuseridentity_requestVerification: (a: number, b: number, c: number) => [number, number, number]; -export const ownuseridentity_selfSigningKey: (a: number) => [number, number, number, number]; -export const ownuseridentity_trustsOurOwnDevice: (a: number) => any; -export const ownuseridentity_userSigningKey: (a: number) => [number, number, number, number]; -export const ownuseridentity_verify: (a: number) => any; -export const ownuseridentity_wasPreviouslyVerified: (a: number) => number; -export const ownuseridentity_withdrawVerification: (a: number) => any; -export const pickledinboundgroupsession_new: () => number; -export const pickledsession_new: () => number; -export const pkdecryption_decrypt: (a: number, b: number) => [number, number, number, number]; -export const pkdecryption_decryptString: (a: number, b: number) => [number, number, number, number]; -export const pkdecryption_fromKey: (a: number) => number; -export const pkdecryption_new: () => number; -export const pkdecryption_publicKey: (a: number) => number; -export const pkdecryption_secretKey: (a: number) => number; -export const pkencryption_encrypt: (a: number, b: number, c: number) => [number, number, number]; -export const pkencryption_encryptString: (a: number, b: number, c: number) => [number, number, number]; -export const pkencryption_fromKey: (a: number) => number; -export const pkmessage_ciphertext: (a: number) => [number, number]; -export const pkmessage_ephemeralKey: (a: number) => number; -export const pkmessage_fromBase64: (a: number) => [number, number, number]; -export const pkmessage_fromParts: (a: number, b: number, c: number, d: number, e: number) => number; -export const pkmessage_mac: (a: number) => [number, number]; -export const pkmessage_toBase64: (a: number) => number; -export const plaintexttodeviceevent_type: (a: number) => number; -export const putdehydrateddevicerequest_new: (a: any) => number; -export const qr_cancel: (a: number) => [number, number, number]; -export const qr_cancelInfo: (a: number) => number; -export const qr_cancelWithCode: (a: number, b: number, c: number) => [number, number, number]; -export const qr_confirmScanning: (a: number) => [number, number, number]; -export const qr_flowId: (a: number) => [number, number]; -export const qr_hasBeenConfirmed: (a: number) => number; -export const qr_hasBeenScanned: (a: number) => number; -export const qr_isCancelled: (a: number) => number; -export const qr_isDone: (a: number) => number; -export const qr_isSelfVerification: (a: number) => number; -export const qr_otherDeviceId: (a: number) => number; -export const qr_otherUserId: (a: number) => number; -export const qr_reciprocate: (a: number) => [number, number, number]; -export const qr_reciprocated: (a: number) => number; -export const qr_registerChangesCallback: (a: number, b: any) => void; -export const qr_roomId: (a: number) => number; -export const qr_state: (a: number) => number; -export const qr_toBytes: (a: number) => [number, number, number]; -export const qr_toQrCode: (a: number) => [number, number, number]; -export const qr_userId: (a: number) => number; -export const qr_weStarted: (a: number) => number; -export const qrcode_renderIntoBuffer: (a: number) => [number, number, number]; -export const qrcodedata_fromBase64: (a: number, b: number) => [number, number, number]; -export const qrcodedata_fromBytes: (a: number, b: number) => [number, number, number]; -export const qrcodedata_intentData: (a: number) => number; -export const qrcodedata_mode: (a: number) => number; -export const qrcodedata_new: (a: number, b: number, c: number, d: number, e: number) => [number, number, number]; -export const qrcodedata_newMsc4388: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number]; -export const qrcodedata_publicKey: (a: number) => number; -export const qrcodedata_rendezvousUrl: (a: number) => [number, number]; -export const qrcodedata_serverName: (a: number) => [number, number]; -export const qrcodedata_toBase64: (a: number) => [number, number]; -export const qrcodedata_toBytes: (a: number) => [number, number]; -export const qrcodescan_fromBytes: (a: any) => [number, number, number]; -export const rehydrateddevice_receiveEvents: (a: number, b: number, c: number, d: number) => any; -export const roomid_new: (a: number, b: number) => [number, number, number]; -export const roomkeyimportresult_keys: (a: number) => any; -export const roomkeyinfo_algorithm: (a: number) => number; -export const roomkeyinfo_roomId: (a: number) => number; -export const roomkeyinfo_senderKey: (a: number) => number; -export const roomkeyinfo_sessionId: (a: number) => [number, number]; -export const roomkeywithheldinfo_algorithm: (a: number) => number; -export const roomkeywithheldinfo_roomId: (a: number) => number; -export const roomkeywithheldinfo_sender: (a: number) => number; -export const roomkeywithheldinfo_sessionId: (a: number) => [number, number]; -export const roomkeywithheldinfo_withheldCode: (a: number) => [number, number]; -export const roommessagerequest_new: (a: any, b: any, c: any, d: any, e: any) => number; -export const roommessagerequest_type: (a: number) => number; -export const roompendingkeybundledetails_inviteAcceptedAtMillis: (a: number) => number; -export const roompendingkeybundledetails_inviterId: (a: number) => number; -export const roompendingkeybundledetails_roomId: (a: number) => number; -export const roomsettings_new: () => number; -export const sas_accept: (a: number) => [number, number, number]; -export const sas_canBePresented: (a: number) => number; -export const sas_cancel: (a: number) => [number, number, number]; -export const sas_cancelInfo: (a: number) => number; -export const sas_cancelWithCode: (a: number, b: number, c: number) => [number, number, number]; -export const sas_confirm: (a: number) => any; -export const sas_decimals: (a: number) => [number, number]; -export const sas_deviceId: (a: number) => number; -export const sas_emoji: (a: number) => [number, number]; -export const sas_emojiIndex: (a: number) => [number, number]; -export const sas_flowId: (a: number) => [number, number]; -export const sas_hasBeenAccepted: (a: number) => number; -export const sas_haveWeConfirmed: (a: number) => number; -export const sas_isCancelled: (a: number) => number; -export const sas_isDone: (a: number) => number; -export const sas_isSelfVerification: (a: number) => number; -export const sas_otherDeviceId: (a: number) => number; -export const sas_otherUserId: (a: number) => number; -export const sas_registerChangesCallback: (a: number, b: any) => void; -export const sas_roomId: (a: number) => number; -export const sas_startedFromRequest: (a: number) => number; -export const sas_supportsEmoji: (a: number) => number; -export const sas_timedOut: (a: number) => number; -export const sas_userId: (a: number) => number; -export const sas_weStarted: (a: number) => number; -export const secretsbundle_backupBundle: (a: number) => number; -export const secretsbundle_from_json: (a: any) => [number, number, number]; -export const secretsbundle_masterKey: (a: number) => [number, number]; -export const secretsbundle_selfSigningKey: (a: number) => [number, number]; -export const secretsbundle_to_json: (a: number) => [number, number, number]; -export const secretsbundle_userSigningKey: (a: number) => [number, number]; -export const servername_host: (a: number) => [number, number]; -export const servername_isIpLiteral: (a: number) => number; -export const servername_new: (a: number, b: number) => [number, number, number]; -export const servername_port: (a: number) => number; -export const shieldstate_message: (a: number) => [number, number]; -export const signature_ed25519: (a: number) => number; -export const signature_toBase64: (a: number) => [number, number]; -export const signatures_addSignature: (a: number, b: number, c: number, d: number) => number; -export const signatures_asJSON: (a: number) => [number, number, number]; -export const signatures_clear: (a: number) => void; -export const signatures_count: (a: number) => number; -export const signatures_get: (a: number, b: number) => any; -export const signatures_getSignature: (a: number, b: number, c: number) => number; -export const signatures_isEmpty: (a: number) => number; -export const signatures_new: () => number; -export const signatureuploadrequest_new: (a: any, b: any) => number; -export const signatureuploadrequest_type: (a: number) => number; -export const signatureverification_deviceState: (a: number) => number; -export const signatureverification_trusted: (a: number) => number; -export const signatureverification_userState: (a: number) => number; -export const start: () => void; -export const storedroomkeybundledata_encryptionInfo: (a: number) => [number, number]; -export const storedroomkeybundledata_roomId: (a: number) => number; -export const storedroomkeybundledata_senderUser: (a: number) => number; -export const storedroomkeybundledata_url: (a: number) => [number, number]; -export const storehandle_open: (a: number, b: number, c: number, d: number, e: number) => any; -export const storehandle_openWithKey: (a: number, b: number, c: number, d: number, e: number) => any; -export const todeviceencryptioninfo_isSenderVerified: (a: number) => number; -export const todevicerequest_new: (a: any, b: any, c: any, d: any) => number; -export const todevicerequest_type: (a: number) => number; -export const tracing_isAvailable: () => number; -export const tracing_new: (a: number) => [number, number, number]; -export const tracing_set_minLevel: (a: number, b: number) => [number, number]; -export const tracing_turnOff: (a: number) => [number, number]; -export const tracing_turnOn: (a: number) => [number, number]; -export const userdevices_devices: (a: number) => any; -export const userdevices_get: (a: number, b: number) => number; -export const userdevices_isAnyVerified: (a: number) => number; -export const userdevices_keys: (a: number) => any; -export const userid_clone: (a: number) => number; -export const userid_isHistorical: (a: number) => number; -export const userid_localpart: (a: number) => [number, number]; -export const userid_new: (a: number, b: number) => [number, number, number]; -export const userid_serverName: (a: number) => number; -export const utdtodeviceevent_type: (a: number) => number; -export const verificationrequest_accept: (a: number) => [number, number, number]; -export const verificationrequest_acceptWithMethods: (a: number, b: number, c: number) => [number, number, number]; -export const verificationrequest_cancel: (a: number) => [number, number, number]; -export const verificationrequest_cancelInfo: (a: number) => number; -export const verificationrequest_flowId: (a: number) => [number, number]; -export const verificationrequest_generateQrCode: (a: number) => any; -export const verificationrequest_getVerification: (a: number) => any; -export const verificationrequest_isCancelled: (a: number) => number; -export const verificationrequest_isDone: (a: number) => number; -export const verificationrequest_isPassive: (a: number) => number; -export const verificationrequest_isReady: (a: number) => number; -export const verificationrequest_isSelfVerification: (a: number) => number; -export const verificationrequest_otherDeviceId: (a: number) => number; -export const verificationrequest_otherUserId: (a: number) => number; -export const verificationrequest_ourSupportedMethods: (a: number) => [number, number, number, number]; -export const verificationrequest_ownUserId: (a: number) => number; -export const verificationrequest_phase: (a: number) => number; -export const verificationrequest_registerChangesCallback: (a: number, b: any) => void; -export const verificationrequest_request: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number]; -export const verificationrequest_roomId: (a: number) => number; -export const verificationrequest_scanQrCode: (a: number, b: number) => any; -export const verificationrequest_startSas: (a: number) => any; -export const verificationrequest_theirSupportedMethods: (a: number) => [number, number, number, number]; -export const verificationrequest_timeRemainingMillis: (a: number) => number; -export const verificationrequest_timedOut: (a: number) => number; -export const verificationrequest_weStarted: (a: number) => number; -export const ring_core_0_17_14__bn_mul_mont: (a: number, b: number, c: number, d: number, e: number, f: number) => void; -export const uploadsigningkeysrequest_new: (a: any) => number; -export const dehydrateddevicekey_createRandomKey: () => number; -export const __wbg_get_base64encodedpkmessage_ciphertext: (a: number) => [number, number]; -export const __wbg_get_base64encodedpkmessage_mac: (a: number) => [number, number]; -export const __wbg_get_basemigrationdata_pickledAccount: (a: number) => [number, number]; -export const __wbg_get_encryptioninfo_senderCurve25519Key: (a: number) => [number, number]; -export const __wbg_get_inboundcreationresult_message: (a: number) => [number, number]; -export const __wbg_get_msc4108intentdata_rendezvousUrl: (a: number) => [number, number]; -export const __wbg_get_msc4388intentdata_baseUrl: (a: number) => [number, number]; -export const __wbg_get_msc4388intentdata_rendezvousId: (a: number) => [number, number]; -export const __wbg_get_outboundcreationresult_initial_message: (a: number) => [number, number]; -export const __wbg_get_pickledinboundgroupsession_pickle: (a: number) => [number, number]; -export const __wbg_get_pickledinboundgroupsession_senderKey: (a: number) => [number, number]; -export const __wbg_get_pickledsession_pickle: (a: number) => [number, number]; -export const __wbg_get_pickledsession_senderKey: (a: number) => [number, number]; -export const __wbg_get_todeviceencryptioninfo_senderCurve25519Key: (a: number) => [number, number]; -export const __wbg_set_outboundcreationresult_channel: (a: number, b: number) => void; -export const __wbg_migration_free: (a: number, b: number) => void; -export const __wbg_get_uploadsigningkeysrequest_body: (a: number) => any; -export const __wbg_get_pickledinboundgroupsession_senderSigningKey: (a: number) => [number, number]; -export const __wbg_get_msc4108intentdata_serverName: (a: number) => [number, number]; -export const __wbg_get_encryptioninfo_senderClaimedEd25519Key: (a: number) => [number, number]; -export const __wbg_get_outboundcreationresult_channel: (a: number) => number; -export const keysuploadrequest_new: (a: any, b: any) => number; -export const keysqueryrequest_new: (a: any, b: any) => number; -export const __wbg_set_pickledsession_pickle: (a: number, b: number, c: number) => void; -export const __wbg_set_pickledinboundgroupsession_senderSigningKey: (a: number, b: number, c: number) => void; -export const __wbg_set_pickledsession_senderKey: (a: number, b: number, c: number) => void; -export const __wbg_set_pickledinboundgroupsession_pickle: (a: number, b: number, c: number) => void; -export const __wbg_set_basemigrationdata_pickledAccount: (a: number, b: number, c: number) => void; -export const __wbg_set_pickledinboundgroupsession_senderKey: (a: number, b: number, c: number) => void; -export const __wbg_set_msc4108intentdata_serverName: (a: number, b: number, c: number) => void; -export const __wbg_set_msc4108intentdata_rendezvousUrl: (a: number, b: number, c: number) => void; -export const __wbg_set_msc4388intentdata_rendezvousId: (a: number, b: number, c: number) => void; -export const __wbg_set_msc4388intentdata_baseUrl: (a: number, b: number, c: number) => void; -export const __wbg_set_encryptioninfo_senderCurve25519Key: (a: number, b: number, c: number) => void; -export const __wbg_set_encryptioninfo_senderClaimedEd25519Key: (a: number, b: number, c: number) => void; -export const __wbg_set_todeviceencryptioninfo_senderCurve25519Key: (a: number, b: number, c: number) => void; -export const __wbg_set_base64encodedpkmessage_mac: (a: number, b: number, c: number) => void; -export const __wbg_set_base64encodedpkmessage_ciphertext: (a: number, b: number, c: number) => void; -export const __wbg_set_inboundcreationresult_message: (a: number, b: number, c: number) => void; -export const __wbg_set_outboundcreationresult_initial_message: (a: number, b: number, c: number) => void; -export const __wbg_servername_free: (a: number, b: number) => void; -export const __wbg_eventid_free: (a: number, b: number) => void; -export const __wbg_get_versions_git_description: (a: number) => any; -export const __wbg_get_versions_vodozemac: (a: number) => any; -export const __wbg_get_utdtodeviceevent_rawEvent: (a: number) => any; -export const __wbg_get_plaintexttodeviceevent_rawEvent: (a: number) => any; -export const __wbg_get_versions_git_sha: (a: number) => any; -export const __wbg_get_todevicerequest_id: (a: number) => any; -export const __wbg_get_versions_matrix_sdk_crypto: (a: number) => any; -export const __wbg_get_todevicerequest_body: (a: number) => any; -export const __wbg_get_keysclaimrequest_id: (a: number) => any; -export const __wbg_get_todevicerequest_event_type: (a: number) => any; -export const __wbg_keysqueryrequest_free: (a: number, b: number) => void; -export const __wbg_get_keysqueryrequest_id: (a: number) => any; -export const __wbg_get_keysqueryrequest_body: (a: number) => any; -export const __wbg_get_todevicerequest_txn_id: (a: number) => any; -export const __wbg_get_keysbackuprequest_id: (a: number) => any; -export const __wbg_get_keysclaimrequest_body: (a: number) => any; -export const __wbg_keysuploadrequest_free: (a: number, b: number) => void; -export const __wbg_get_keysuploadrequest_id: (a: number) => any; -export const __wbg_get_keysuploadrequest_body: (a: number) => any; -export const __wbg_get_roommessagerequest_txn_id: (a: number) => any; -export const __wbg_get_roommessagerequest_room_id: (a: number) => any; -export const __wbg_get_roommessagerequest_id: (a: number) => any; -export const __wbg_get_roommessagerequest_event_type: (a: number) => any; -export const __wbg_get_signatureuploadrequest_body: (a: number) => any; -export const __wbg_uploadsigningkeysrequest_free: (a: number, b: number) => void; -export const __wbg_get_megolmdecryptionerror_description: (a: number) => any; -export const __wbg_crosssigningstatus_free: (a: number, b: number) => void; -export const __wbg_plaintexttodeviceevent_free: (a: number, b: number) => void; -export const userid_toString: (a: number) => [number, number]; -export const __wbg_userid_free: (a: number, b: number) => void; -export const roomid_toString: (a: number) => [number, number]; -export const eventid_toString: (a: number) => [number, number]; -export const __wbg_roomid_free: (a: number, b: number) => void; -export const __wbg_outboundcreationresult_free: (a: number, b: number) => void; -export const wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke___wasm_bindgen_ff9af61e2d43a78a___JsValue__core_ed718c3d60ebd546___result__Result_____wasm_bindgen_ff9af61e2d43a78a___JsError___true_: (a: number, b: number, c: any) => [number, number]; -export const wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke___wasm_bindgen_ff9af61e2d43a78a___JsValue__core_ed718c3d60ebd546___result__Result_____wasm_bindgen_ff9af61e2d43a78a___JsError___true__2: (a: number, b: number, c: any) => [number, number]; -export const wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke___js_sys_8badcad5ae9f3759___Function_fn_wasm_bindgen_ff9af61e2d43a78a___JsValue_____wasm_bindgen_ff9af61e2d43a78a___sys__Undefined___js_sys_8badcad5ae9f3759___Function_fn_wasm_bindgen_ff9af61e2d43a78a___JsValue_____wasm_bindgen_ff9af61e2d43a78a___sys__Undefined_______true_: (a: number, b: number, c: any, d: any) => void; -export const wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke___web_sys_4ec35d1b8222c725___features__gen_Event__Event______true_: (a: number, b: number, c: any) => void; -export const wasm_bindgen_ff9af61e2d43a78a___convert__closures_____invoke_______true_: (a: number, b: number) => void; -export const __wbindgen_malloc: (a: number, b: number) => number; -export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number; -export const __wbindgen_exn_store: (a: number) => void; -export const __externref_table_alloc: () => number; -export const __wbindgen_externrefs: WebAssembly.Table; -export const __wbindgen_free: (a: number, b: number, c: number) => void; -export const __wbindgen_destroy_closure: (a: number, b: number) => void; -export const __externref_drop_slice: (a: number, b: number) => void; -export const __externref_table_dealloc: (a: number) => void; -export const __wbindgen_start: () => void; +export function __wbg_backupdecryptionkey_free(a: number): void; +export function __wbg_megolmv1backupkey_free(a: number): void; +export function megolmv1backupkey_publicKeyBase64(a: number): number; +export function megolmv1backupkey_algorithm(a: number): number; +export function backupdecryptionkey_createRandomKey(): number; +export function backupdecryptionkey_fromBase64(a: number, b: number, c: number): void; +export function backupdecryptionkey_toBase64(a: number): number; +export function backupdecryptionkey_megolmV1PublicKey(a: number): number; +export function backupdecryptionkey_decryptV1(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): void; +export function __wbg_roomkeycounts_free(a: number): void; +export function __wbg_get_roomkeycounts_total(a: number): number; +export function __wbg_set_roomkeycounts_total(a: number, b: number): void; +export function __wbg_get_roomkeycounts_backedUp(a: number): number; +export function __wbg_set_roomkeycounts_backedUp(a: number, b: number): void; +export function __wbg_backupkeys_free(a: number): void; +export function __wbg_get_backupkeys_decryptionKey(a: number): number; +export function __wbg_set_backupkeys_decryptionKey(a: number, b: number): void; +export function __wbg_get_backupkeys_backupVersion(a: number, b: number): void; +export function __wbg_set_backupkeys_backupVersion(a: number, b: number, c: number): void; +export function backupkeys_decryptionKeyBase64(a: number): number; +export function userid_new(a: number, b: number, c: number): void; +export function userid_localpart(a: number, b: number): void; +export function userid_serverName(a: number): number; +export function userid_isHistorical(a: number): number; +export function userid_toString(a: number, b: number): void; +export function __wbg_deviceid_free(a: number): void; +export function deviceid_new(a: number, b: number): number; +export function deviceid_toString(a: number, b: number): void; +export function __wbg_devicekeyid_free(a: number): void; +export function devicekeyid_new(a: number, b: number, c: number): void; +export function devicekeyid_algorithm(a: number): number; +export function devicekeyid_deviceId(a: number): number; +export function devicekeyid_toString(a: number, b: number): void; +export function __wbg_devicekeyalgorithm_free(a: number): void; +export function devicekeyalgorithm_name(a: number): number; +export function devicekeyalgorithm_toString(a: number, b: number): void; +export function roomid_new(a: number, b: number, c: number): void; +export function roomid_localpart(a: number, b: number): void; +export function roomid_serverName(a: number): number; +export function roomid_toString(a: number, b: number): void; +export function servername_new(a: number, b: number, c: number): void; +export function servername_host(a: number, b: number): void; +export function servername_port(a: number): number; +export function servername_isIpLiteral(a: number): number; +export function eventid_new(a: number, b: number, c: number): void; +export function eventid_localpart(a: number, b: number): void; +export function eventid_serverName(a: number): number; +export function eventid_toString(a: number, b: number): void; +export function __wbg_olmmachine_free(a: number): void; +export function olmmachine_new(a: number): void; +export function olmmachine_initialize(a: number, b: number, c: number, d: number, e: number, f: number): number; +export function olmmachine_userId(a: number): number; +export function olmmachine_deviceId(a: number): number; +export function olmmachine_identityKeys(a: number): number; +export function olmmachine_displayName(a: number): number; +export function olmmachine_trackedUsers(a: number, b: number): void; +export function olmmachine_updateTrackedUsers(a: number, b: number, c: number): void; +export function olmmachine_receiveSyncChanges(a: number, b: number, c: number, d: number, e: number, f: number, g: number): void; +export function olmmachine_outgoingRequests(a: number): number; +export function olmmachine_markRequestAsSent(a: number, b: number, c: number, d: number, e: number, f: number, g: number): void; +export function olmmachine_encryptRoomEvent(a: number, b: number, c: number, d: number, e: number, f: number, g: number): void; +export function olmmachine_decryptRoomEvent(a: number, b: number, c: number, d: number, e: number): void; +export function olmmachine_getRoomEventEncryptionInfo(a: number, b: number, c: number, d: number, e: number): void; +export function olmmachine_crossSigningStatus(a: number): number; +export function olmmachine_exportCrossSigningKeys(a: number): number; +export function olmmachine_importCrossSigningKeys(a: number, b: number, c: number, d: number, e: number, f: number, g: number): number; +export function olmmachine_bootstrapCrossSigning(a: number, b: number): number; +export function olmmachine_getIdentity(a: number, b: number): number; +export function olmmachine_sign(a: number, b: number, c: number): number; +export function olmmachine_invalidateGroupSession(a: number, b: number): number; +export function olmmachine_shareRoomKey(a: number, b: number, c: number, d: number, e: number): void; +export function olmmachine_queryKeysForUsers(a: number, b: number, c: number): void; +export function olmmachine_getMissingSessions(a: number, b: number, c: number): void; +export function olmmachine_getUserDevices(a: number, b: number): number; +export function olmmachine_getDevice(a: number, b: number, c: number): number; +export function olmmachine_getVerification(a: number, b: number, c: number, d: number, e: number): void; +export function olmmachine_getVerificationRequest(a: number, b: number, c: number, d: number): number; +export function olmmachine_getVerificationRequests(a: number, b: number): number; +export function olmmachine_receiveVerificationEvent(a: number, b: number, c: number, d: number, e: number): void; +export function olmmachine_exportRoomKeys(a: number, b: number): number; +export function olmmachine_importRoomKeys(a: number, b: number, c: number, d: number, e: number): void; +export function olmmachine_saveBackupDecryptionKey(a: number, b: number, c: number, d: number): number; +export function olmmachine_getBackupKeys(a: number): number; +export function olmmachine_verifyBackup(a: number, b: number, c: number): void; +export function olmmachine_enableBackupV1(a: number, b: number, c: number, d: number, e: number, f: number): void; +export function olmmachine_isBackupEnabled(a: number): number; +export function olmmachine_disableBackup(a: number): number; +export function olmmachine_backupRoomKeys(a: number): number; +export function olmmachine_roomKeyCounts(a: number): number; +export function olmmachine_encryptExportedRoomKeys(a: number, b: number, c: number, d: number, e: number, f: number): void; +export function olmmachine_decryptExportedRoomKeys(a: number, b: number, c: number, d: number, e: number): void; +export function olmmachine_registerRoomKeyUpdatedCallback(a: number, b: number): number; +export function olmmachine_registerUserIdentityUpdatedCallback(a: number, b: number): number; +export function olmmachine_close(a: number): void; +export function __wbg_crosssigningstatus_free(a: number): void; +export function crosssigningstatus_hasMaster(a: number): number; +export function crosssigningstatus_hasSelfSigning(a: number): number; +export function crosssigningstatus_hasUserSigning(a: number): number; +export function __wbg_inboundgroupsession_free(a: number): void; +export function inboundgroupsession_roomId(a: number): number; +export function inboundgroupsession_senderKey(a: number): number; +export function inboundgroupsession_sessionId(a: number, b: number): void; +export function inboundgroupsession_hasBeenImported(a: number): number; +export function __wbg_crosssigningkeyexport_free(a: number): void; +export function crosssigningkeyexport_masterKey(a: number, b: number): void; +export function crosssigningkeyexport_self_signing_key(a: number, b: number): void; +export function crosssigningkeyexport_userSigningKey(a: number, b: number): void; +export function __wbg_roomkeyinfo_free(a: number): void; +export function roomkeyinfo_algorithm(a: number): number; +export function roomkeyinfo_roomId(a: number): number; +export function roomkeyinfo_senderKey(a: number): number; +export function roomkeyinfo_sessionId(a: number, b: number): void; +export function __wbg_signatures_free(a: number): void; +export function signatures_new(): number; +export function signatures_addSignature(a: number, b: number, c: number, d: number): number; +export function signatures_getSignature(a: number, b: number, c: number): number; +export function signatures_get(a: number, b: number): number; +export function signatures_clear(a: number): void; +export function signatures_isEmpty(a: number): number; +export function signatures_count(a: number): number; +export function signatures_asJSON(a: number, b: number): void; +export function __wbg_signature_free(a: number): void; +export function signature_ed25519(a: number): number; +export function signature_toBase64(a: number, b: number): void; +export function __wbg_maybesignature_free(a: number): void; +export function maybesignature_isValid(a: number): number; +export function maybesignature_isInvalid(a: number): number; +export function maybesignature_signature(a: number): number; +export function maybesignature_invalidSignatureSource(a: number, b: number): void; +export function __wbg_signatureverification_free(a: number): void; +export function signatureverification_deviceState(a: number): number; +export function signatureverification_userState(a: number): number; +export function signatureverification_trusted(a: number): number; +export function __wbg_sas_free(a: number): void; +export function sas_userId(a: number): number; +export function sas_deviceId(a: number): number; +export function sas_otherUserId(a: number): number; +export function sas_otherDeviceId(a: number): number; +export function sas_flowId(a: number, b: number): void; +export function sas_roomId(a: number): number; +export function sas_supportsEmoji(a: number): number; +export function sas_startedFromRequest(a: number): number; +export function sas_isSelfVerification(a: number): number; +export function sas_haveWeConfirmed(a: number): number; +export function sas_hasBeenAccepted(a: number): number; +export function sas_cancelInfo(a: number): number; +export function sas_weStarted(a: number): number; +export function sas_accept(a: number, b: number): void; +export function sas_confirm(a: number): number; +export function sas_cancel(a: number, b: number): void; +export function sas_cancelWithCode(a: number, b: number, c: number): void; +export function sas_timedOut(a: number): number; +export function sas_canBePresented(a: number): number; +export function sas_isDone(a: number): number; +export function sas_isCancelled(a: number): number; +export function sas_emoji(a: number): number; +export function sas_emojiIndex(a: number): number; +export function sas_decimals(a: number): number; +export function sas_registerChangesCallback(a: number, b: number): void; +export function __wbg_qr_free(a: number): void; +export function qr_state(a: number): number; +export function qr_hasBeenScanned(a: number): number; +export function qr_hasBeenConfirmed(a: number): number; +export function qr_userId(a: number): number; +export function qr_otherUserId(a: number): number; +export function qr_otherDeviceId(a: number): number; +export function qr_weStarted(a: number): number; +export function qr_cancelInfo(a: number): number; +export function qr_isDone(a: number): number; +export function qr_isCancelled(a: number): number; +export function qr_isSelfVerification(a: number): number; +export function qr_reciprocated(a: number): number; +export function qr_flowId(a: number, b: number): void; +export function qr_roomId(a: number): number; +export function qr_toQrCode(a: number, b: number): void; +export function qr_toBytes(a: number, b: number): void; +export function qr_reciprocate(a: number, b: number): void; +export function qr_confirmScanning(a: number, b: number): void; +export function qr_cancel(a: number, b: number): void; +export function qr_cancelWithCode(a: number, b: number, c: number): void; +export function qr_registerChangesCallback(a: number, b: number): void; +export function __wbg_cancelinfo_free(a: number): void; +export function cancelinfo_reason(a: number): number; +export function cancelinfo_cancelCode(a: number): number; +export function cancelinfo_cancelledbyUs(a: number): number; +export function __wbg_emoji_free(a: number): void; +export function emoji_symbol(a: number): number; +export function emoji_description(a: number): number; +export function __wbg_qrcode_free(a: number): void; +export function qrcode_renderIntoBuffer(a: number, b: number): void; +export function __wbg_qrcodescan_free(a: number): void; +export function qrcodescan_fromBytes(a: number, b: number): void; +export function __wbg_verificationrequest_free(a: number): void; +export function verificationrequest_request(a: number, b: number, c: number, d: number, e: number): void; +export function verificationrequest_ownUserId(a: number): number; +export function verificationrequest_otherUserId(a: number): number; +export function verificationrequest_otherDeviceId(a: number): number; +export function verificationrequest_roomId(a: number): number; +export function verificationrequest_cancelInfo(a: number): number; +export function verificationrequest_isPassive(a: number): number; +export function verificationrequest_isReady(a: number): number; +export function verificationrequest_timedOut(a: number): number; +export function verificationrequest_timeRemainingMillis(a: number): number; +export function verificationrequest_theirSupportedMethods(a: number, b: number): void; +export function verificationrequest_ourSupportedMethods(a: number, b: number): void; +export function verificationrequest_flowId(a: number, b: number): void; +export function verificationrequest_isSelfVerification(a: number): number; +export function verificationrequest_weStarted(a: number): number; +export function verificationrequest_isDone(a: number): number; +export function verificationrequest_phase(a: number): number; +export function verificationrequest_getVerification(a: number): number; +export function verificationrequest_registerChangesCallback(a: number, b: number): void; +export function verificationrequest_isCancelled(a: number): number; +export function verificationrequest_acceptWithMethods(a: number, b: number, c: number): void; +export function verificationrequest_accept(a: number, b: number): void; +export function verificationrequest_cancel(a: number, b: number): void; +export function verificationrequest_startSas(a: number): number; +export function verificationrequest_generateQrCode(a: number): number; +export function verificationrequest_scanQrCode(a: number, b: number): number; +export function __wbg_userid_free(a: number): void; +export function __wbg_roomid_free(a: number): void; +export function __wbg_eventid_free(a: number): void; +export function __wbg_servername_free(a: number): void; +export function __wbg_megolmdecryptionerror_free(a: number): void; +export function __wbg_get_megolmdecryptionerror_code(a: number): number; +export function __wbg_get_megolmdecryptionerror_description(a: number): number; +export function __wbg_get_megolmdecryptionerror_maybe_withheld(a: number): number; +export function __wbg_decryptedroomevent_free(a: number): void; +export function __wbg_get_decryptedroomevent_event(a: number): number; +export function decryptedroomevent_sender(a: number): number; +export function decryptedroomevent_senderDevice(a: number): number; +export function decryptedroomevent_senderCurve25519Key(a: number): number; +export function decryptedroomevent_senderClaimedEd25519Key(a: number): number; +export function decryptedroomevent_forwardingCurve25519KeyChain(a: number): number; +export function decryptedroomevent_shieldState(a: number, b: number): number; +export function __wbg_encryptioninfo_free(a: number): void; +export function encryptioninfo_sender(a: number): number; +export function encryptioninfo_senderDevice(a: number): number; +export function encryptioninfo_senderCurve25519Key(a: number): number; +export function encryptioninfo_senderClaimedEd25519Key(a: number): number; +export function encryptioninfo_shieldState(a: number, b: number): number; +export function __wbg_devicelists_free(a: number): void; +export function devicelists_new(a: number, b: number, c: number): void; +export function devicelists_isEmpty(a: number): number; +export function devicelists_changed(a: number): number; +export function devicelists_left(a: number): number; +export function __wbg_tracing_free(a: number): void; +export function tracing_isAvailable(): number; +export function tracing_new(a: number, b: number): void; +export function tracing_set_minLevel(a: number, b: number): void; +export function tracing_turnOn(a: number): void; +export function tracing_turnOff(a: number): void; +export function __wbg_ed25519publickey_free(a: number): void; +export function ed25519publickey_length(a: number): number; +export function ed25519publickey_toBase64(a: number, b: number): void; +export function __wbg_ed25519signature_free(a: number): void; +export function ed25519signature_new(a: number, b: number, c: number): void; +export function ed25519signature_toBase64(a: number, b: number): void; +export function __wbg_curve25519publickey_free(a: number): void; +export function curve25519publickey_length(a: number): number; +export function curve25519publickey_toBase64(a: number, b: number): void; +export function __wbg_identitykeys_free(a: number): void; +export function __wbg_get_identitykeys_ed25519(a: number): number; +export function __wbg_set_identitykeys_ed25519(a: number, b: number): void; +export function __wbg_get_identitykeys_curve25519(a: number): number; +export function __wbg_set_identitykeys_curve25519(a: number, b: number): void; +export function __wbg_devicekey_free(a: number): void; +export function devicekey_name(a: number): number; +export function devicekey_curve25519(a: number): number; +export function devicekey_ed25519(a: number): number; +export function devicekey_unknown(a: number, b: number): void; +export function devicekey_toBase64(a: number, b: number): void; +export function __wbg_attachment_free(a: number): void; +export function attachment_encrypt(a: number, b: number, c: number): void; +export function attachment_decrypt(a: number, b: number): void; +export function __wbg_encryptedattachment_free(a: number): void; +export function encryptedattachment_new(a: number, b: number, c: number, d: number, e: number): void; +export function encryptedattachment_encryptedData(a: number, b: number): void; +export function encryptedattachment_mediaEncryptionInfo(a: number, b: number): void; +export function encryptedattachment_hasMediaEncryptionInfoBeenConsumed(a: number): number; +export function __wbg_device_free(a: number): void; +export function device_requestVerification(a: number, b: number, c: number): void; +export function device_isVerified(a: number): number; +export function device_isCrossSigningTrusted(a: number): number; +export function device_isCrossSignedByOwner(a: number): number; +export function device_setLocalTrust(a: number, b: number): number; +export function device_userId(a: number): number; +export function device_deviceId(a: number): number; +export function device_displayName(a: number, b: number): void; +export function device_getKey(a: number, b: number, c: number): void; +export function device_curve25519Key(a: number): number; +export function device_ed25519Key(a: number): number; +export function device_keys(a: number): number; +export function device_algorithms(a: number): number; +export function device_signatures(a: number): number; +export function device_localTrustState(a: number): number; +export function device_isLocallyTrusted(a: number): number; +export function device_isBlacklisted(a: number): number; +export function device_isDeleted(a: number): number; +export function device_firstTimeSeen(a: number): number; +export function device_verify(a: number): number; +export function __wbg_userdevices_free(a: number): void; +export function userdevices_get(a: number, b: number): number; +export function userdevices_isAnyVerified(a: number): number; +export function userdevices_keys(a: number): number; +export function userdevices_devices(a: number): number; +export function __wbg_ownuseridentity_free(a: number): void; +export function ownuseridentity_isVerified(a: number): number; +export function ownuseridentity_verify(a: number): number; +export function ownuseridentity_requestVerification(a: number, b: number, c: number): void; +export function ownuseridentity_trustsOurOwnDevice(a: number): number; +export function ownuseridentity_masterKey(a: number, b: number): void; +export function ownuseridentity_selfSigningKey(a: number, b: number): void; +export function ownuseridentity_userSigningKey(a: number, b: number): void; +export function __wbg_useridentity_free(a: number): void; +export function useridentity_isVerified(a: number): number; +export function useridentity_verify(a: number): number; +export function useridentity_requestVerification(a: number, b: number, c: number, d: number, e: number): void; +export function useridentity_verificationRequestContent(a: number, b: number, c: number): void; +export function useridentity_masterKey(a: number, b: number): void; +export function useridentity_selfSigningKey(a: number, b: number): void; +export function __wbg_keysuploadrequest_free(a: number): void; +export function __wbg_get_keysuploadrequest_id(a: number): number; +export function __wbg_get_keysuploadrequest_body(a: number): number; +export function keysuploadrequest_type(a: number): number; +export function __wbg_keysqueryrequest_free(a: number): void; +export function __wbg_get_keysqueryrequest_id(a: number): number; +export function __wbg_get_keysqueryrequest_body(a: number): number; +export function keysqueryrequest_type(a: number): number; +export function __wbg_keysclaimrequest_free(a: number): void; +export function __wbg_get_keysclaimrequest_id(a: number): number; +export function __wbg_get_keysclaimrequest_body(a: number): number; +export function keysclaimrequest_new(a: number, b: number): number; +export function keysclaimrequest_type(a: number): number; +export function __wbg_todevicerequest_free(a: number): void; +export function __wbg_get_todevicerequest_id(a: number): number; +export function __wbg_get_todevicerequest_event_type(a: number): number; +export function __wbg_get_todevicerequest_txn_id(a: number): number; +export function __wbg_get_todevicerequest_body(a: number): number; +export function todevicerequest_new(a: number, b: number, c: number, d: number): number; +export function todevicerequest_type(a: number): number; +export function __wbg_signatureuploadrequest_free(a: number): void; +export function __wbg_get_signatureuploadrequest_id(a: number): number; +export function __wbg_get_signatureuploadrequest_body(a: number): number; +export function signatureuploadrequest_type(a: number): number; +export function __wbg_roommessagerequest_free(a: number): void; +export function __wbg_get_roommessagerequest_id(a: number): number; +export function __wbg_get_roommessagerequest_room_id(a: number): number; +export function __wbg_get_roommessagerequest_txn_id(a: number): number; +export function __wbg_get_roommessagerequest_event_type(a: number): number; +export function __wbg_get_roommessagerequest_body(a: number): number; +export function roommessagerequest_new(a: number, b: number, c: number, d: number, e: number): number; +export function roommessagerequest_type(a: number): number; +export function __wbg_keysbackuprequest_free(a: number): void; +export function __wbg_get_keysbackuprequest_id(a: number): number; +export function __wbg_get_keysbackuprequest_body(a: number): number; +export function __wbg_get_keysbackuprequest_version(a: number): number; +export function keysbackuprequest_new(a: number, b: number, c: number): number; +export function keysbackuprequest_type(a: number): number; +export function __wbg_signingkeysuploadrequest_free(a: number): void; +export function __wbg_get_signingkeysuploadrequest_id(a: number): number; +export function __wbg_get_signingkeysuploadrequest_body(a: number): number; +export function signingkeysuploadrequest_type(a: number): number; +export function __wbg_versions_free(a: number): void; +export function __wbg_get_versions_vodozemac(a: number): number; +export function __wbg_get_versions_matrix_sdk_crypto(a: number): number; +export function getVersions(): number; +export function start(): void; +export function keysuploadrequest_new(a: number, b: number): number; +export function keysqueryrequest_new(a: number, b: number): number; +export function signatureuploadrequest_new(a: number, b: number): number; +export function signingkeysuploadrequest_new(a: number, b: number): number; +export function __wbg_encryptionsettings_free(a: number): void; +export function __wbg_get_encryptionsettings_algorithm(a: number): number; +export function __wbg_set_encryptionsettings_algorithm(a: number, b: number): void; +export function __wbg_get_encryptionsettings_rotationPeriod(a: number): number; +export function __wbg_set_encryptionsettings_rotationPeriod(a: number, b: number): void; +export function __wbg_get_encryptionsettings_rotationPeriodMessages(a: number): number; +export function __wbg_set_encryptionsettings_rotationPeriodMessages(a: number, b: number): void; +export function __wbg_get_encryptionsettings_historyVisibility(a: number): number; +export function __wbg_set_encryptionsettings_historyVisibility(a: number, b: number): void; +export function __wbg_get_encryptionsettings_onlyAllowTrustedDevices(a: number): number; +export function __wbg_set_encryptionsettings_onlyAllowTrustedDevices(a: number, b: number): void; +export function encryptionsettings_new(): number; +export function __wbg_shieldstate_free(a: number): void; +export function __wbg_get_shieldstate_color(a: number): number; +export function __wbg_set_shieldstate_color(a: number, b: number): void; +export function shieldstate_message(a: number, b: number): void; +export function __wbindgen_malloc(a: number): number; +export function __wbindgen_realloc(a: number, b: number, c: number): number; +export const __wbindgen_export_2: WebAssembly.Table; +export function __wbindgen_add_to_stack_pointer(a: number): number; +export function wasm_bindgen__convert__closures__invoke1_mut__h474cf18ac0185d15(a: number, b: number, c: number, d: number): void; +export function _dyn_core__ops__function__Fn__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h189b63f7e686b922(a: number, b: number, c: number): void; +export function _dyn_core__ops__function__Fn_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__he114b8a0bf164eec(a: number, b: number): void; +export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h12b54e1b31ffecd6(a: number, b: number, c: number): void; +export function _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hfaf4f1753631bb25(a: number, b: number): void; +export function __wbindgen_free(a: number, b: number): void; +export function __wbindgen_exn_store(a: number): void; +export function wasm_bindgen__convert__closures__invoke2_mut__h55cae04c68820562(a: number, b: number, c: number, d: number): void; +export function __wbindgen_start(): void; diff --git a/node_modules/base-x/README.md b/node_modules/base-x/README.md index 537f1b9..10faf66 100644 --- a/node_modules/base-x/README.md +++ b/node_modules/base-x/README.md @@ -16,8 +16,7 @@ Base58 ``` javascript var BASE58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' -import basex from 'base-x' -var bs58 = basex(BASE58) +var bs58 = require('base-x')(BASE58) var decoded = bs58.decode('5Kd3NBUAdUnhyzenEwVLy9pBKxSwXvE9FMPyR4UKZvpe6E3AgLr') diff --git a/node_modules/base-x/package.json b/node_modules/base-x/package.json index 2eba6a4..6da5e65 100644 --- a/node_modules/base-x/package.json +++ b/node_modules/base-x/package.json @@ -1,8 +1,7 @@ { "name": "base-x", - "version": "5.0.1", + "version": "4.0.1", "description": "Fast base encoding / decoding of any given alphabet", - "type": "module", "keywords": [ "base-x", "base58", @@ -24,35 +23,24 @@ "files": [ "src" ], - "main": "src/cjs/index.cjs", - "module": "src/esm/index.js", - "types": "src/cjs/index.d.ts", - "exports": { - ".": { - "require": "./src/cjs/index.cjs", - "import": "./src/esm/index.js", - "types": "./src/cjs/index.d.ts" - } - }, + "main": "src/index.js", + "types": "src/index.d.ts", "repository": { "type": "git", "url": "https://github.com/cryptocoinjs/base-x.git" }, "scripts": { - "build": "npm run clean && tsc -p ./tsconfig.json && tsc -p ./tsconfig.cjs.json; npm run standard -- --fix", - "clean": "rimraf src", - "postbuild": "find src/cjs -type f -name \"*.js\" -exec bash -c 'mv \"$0\" \"${0%.js}.cjs\"' {} \\;", + "build": "tsc -p ./tsconfig.json ; standard --fix", "gitdiff": "npm run build && git diff --exit-code", "prepublish": "npm run gitdiff", - "standard": "standard --ignore test", + "standard": "standard", "test": "npm run unit && npm run standard", "unit": "tape test/*.js" }, "devDependencies": { "@types/node": "12.0.10", - "rimraf": "^3.0.2", - "standard": "^17.1.0", - "tape": "^5.3.0", - "typescript": "^5.4.5" + "standard": "^10.0.3", + "tape": "^4.5.1", + "typescript": "3.5.2" } } diff --git a/node_modules/base-x/src/cjs/index.cjs b/node_modules/base-x/src/cjs/index.cjs deleted file mode 100644 index 45c7330..0000000 --- a/node_modules/base-x/src/cjs/index.cjs +++ /dev/null @@ -1,126 +0,0 @@ -'use strict' -// base-x encoding / decoding -// Copyright (c) 2018 base-x contributors -// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp) -// Distributed under the MIT software license, see the accompanying -// file LICENSE or http://www.opensource.org/licenses/mit-license.php. -Object.defineProperty(exports, '__esModule', { value: true }) -function base (ALPHABET) { - if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') } - const BASE_MAP = new Uint8Array(256) - for (let j = 0; j < BASE_MAP.length; j++) { - BASE_MAP[j] = 255 - } - for (let i = 0; i < ALPHABET.length; i++) { - const x = ALPHABET.charAt(i) - const xc = x.charCodeAt(0) - if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') } - BASE_MAP[xc] = i - } - const BASE = ALPHABET.length - const LEADER = ALPHABET.charAt(0) - const FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up - const iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up - function encode (source) { - // eslint-disable-next-line no-empty - if (source instanceof Uint8Array) { } else if (ArrayBuffer.isView(source)) { - source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength) - } else if (Array.isArray(source)) { - source = Uint8Array.from(source) - } - if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') } - if (source.length === 0) { return '' } - // Skip & count leading zeroes. - let zeroes = 0 - let length = 0 - let pbegin = 0 - const pend = source.length - while (pbegin !== pend && source[pbegin] === 0) { - pbegin++ - zeroes++ - } - // Allocate enough space in big-endian base58 representation. - const size = ((pend - pbegin) * iFACTOR + 1) >>> 0 - const b58 = new Uint8Array(size) - // Process the bytes. - while (pbegin !== pend) { - let carry = source[pbegin] - // Apply "b58 = b58 * 256 + ch". - let i = 0 - for (let it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) { - carry += (256 * b58[it1]) >>> 0 - b58[it1] = (carry % BASE) >>> 0 - carry = (carry / BASE) >>> 0 - } - if (carry !== 0) { throw new Error('Non-zero carry') } - length = i - pbegin++ - } - // Skip leading zeroes in base58 result. - let it2 = size - length - while (it2 !== size && b58[it2] === 0) { - it2++ - } - // Translate the result into a string. - let str = LEADER.repeat(zeroes) - for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]) } - return str - } - function decodeUnsafe (source) { - if (typeof source !== 'string') { throw new TypeError('Expected String') } - if (source.length === 0) { return new Uint8Array() } - let psz = 0 - // Skip and count leading '1's. - let zeroes = 0 - let length = 0 - while (source[psz] === LEADER) { - zeroes++ - psz++ - } - // Allocate enough space in big-endian base256 representation. - const size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up. - const b256 = new Uint8Array(size) - // Process the characters. - while (psz < source.length) { - // Find code of next character - const charCode = source.charCodeAt(psz) - // Base map can not be indexed using char code - if (charCode > 255) { return } - // Decode character - let carry = BASE_MAP[charCode] - // Invalid character - if (carry === 255) { return } - let i = 0 - for (let it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) { - carry += (BASE * b256[it3]) >>> 0 - b256[it3] = (carry % 256) >>> 0 - carry = (carry / 256) >>> 0 - } - if (carry !== 0) { throw new Error('Non-zero carry') } - length = i - psz++ - } - // Skip leading zeroes in b256. - let it4 = size - length - while (it4 !== size && b256[it4] === 0) { - it4++ - } - const vch = new Uint8Array(zeroes + (size - it4)) - let j = zeroes - while (it4 !== size) { - vch[j++] = b256[it4++] - } - return vch - } - function decode (string) { - const buffer = decodeUnsafe(string) - if (buffer) { return buffer } - throw new Error('Non-base' + BASE + ' character') - } - return { - encode, - decodeUnsafe, - decode - } -} -exports.default = base diff --git a/node_modules/base-x/src/cjs/index.d.ts b/node_modules/base-x/src/cjs/index.d.ts deleted file mode 100644 index 4fd9617..0000000 --- a/node_modules/base-x/src/cjs/index.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -declare function base(ALPHABET: string): base.BaseConverter; -export default base; -declare namespace base { - interface BaseConverter { - encode(buffer: Uint8Array | number[]): string; - decodeUnsafe(string: string): Uint8Array | undefined; - decode(string: string): Uint8Array; - } -} diff --git a/node_modules/base-x/src/esm/index.js b/node_modules/base-x/src/esm/index.js deleted file mode 100644 index 1593e17..0000000 --- a/node_modules/base-x/src/esm/index.js +++ /dev/null @@ -1,124 +0,0 @@ -// base-x encoding / decoding -// Copyright (c) 2018 base-x contributors -// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp) -// Distributed under the MIT software license, see the accompanying -// file LICENSE or http://www.opensource.org/licenses/mit-license.php. -function base (ALPHABET) { - if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') } - const BASE_MAP = new Uint8Array(256) - for (let j = 0; j < BASE_MAP.length; j++) { - BASE_MAP[j] = 255 - } - for (let i = 0; i < ALPHABET.length; i++) { - const x = ALPHABET.charAt(i) - const xc = x.charCodeAt(0) - if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') } - BASE_MAP[xc] = i - } - const BASE = ALPHABET.length - const LEADER = ALPHABET.charAt(0) - const FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up - const iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up - function encode (source) { - // eslint-disable-next-line no-empty - if (source instanceof Uint8Array) { } else if (ArrayBuffer.isView(source)) { - source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength) - } else if (Array.isArray(source)) { - source = Uint8Array.from(source) - } - if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') } - if (source.length === 0) { return '' } - // Skip & count leading zeroes. - let zeroes = 0 - let length = 0 - let pbegin = 0 - const pend = source.length - while (pbegin !== pend && source[pbegin] === 0) { - pbegin++ - zeroes++ - } - // Allocate enough space in big-endian base58 representation. - const size = ((pend - pbegin) * iFACTOR + 1) >>> 0 - const b58 = new Uint8Array(size) - // Process the bytes. - while (pbegin !== pend) { - let carry = source[pbegin] - // Apply "b58 = b58 * 256 + ch". - let i = 0 - for (let it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) { - carry += (256 * b58[it1]) >>> 0 - b58[it1] = (carry % BASE) >>> 0 - carry = (carry / BASE) >>> 0 - } - if (carry !== 0) { throw new Error('Non-zero carry') } - length = i - pbegin++ - } - // Skip leading zeroes in base58 result. - let it2 = size - length - while (it2 !== size && b58[it2] === 0) { - it2++ - } - // Translate the result into a string. - let str = LEADER.repeat(zeroes) - for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]) } - return str - } - function decodeUnsafe (source) { - if (typeof source !== 'string') { throw new TypeError('Expected String') } - if (source.length === 0) { return new Uint8Array() } - let psz = 0 - // Skip and count leading '1's. - let zeroes = 0 - let length = 0 - while (source[psz] === LEADER) { - zeroes++ - psz++ - } - // Allocate enough space in big-endian base256 representation. - const size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up. - const b256 = new Uint8Array(size) - // Process the characters. - while (psz < source.length) { - // Find code of next character - const charCode = source.charCodeAt(psz) - // Base map can not be indexed using char code - if (charCode > 255) { return } - // Decode character - let carry = BASE_MAP[charCode] - // Invalid character - if (carry === 255) { return } - let i = 0 - for (let it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) { - carry += (BASE * b256[it3]) >>> 0 - b256[it3] = (carry % 256) >>> 0 - carry = (carry / 256) >>> 0 - } - if (carry !== 0) { throw new Error('Non-zero carry') } - length = i - psz++ - } - // Skip leading zeroes in b256. - let it4 = size - length - while (it4 !== size && b256[it4] === 0) { - it4++ - } - const vch = new Uint8Array(zeroes + (size - it4)) - let j = zeroes - while (it4 !== size) { - vch[j++] = b256[it4++] - } - return vch - } - function decode (string) { - const buffer = decodeUnsafe(string) - if (buffer) { return buffer } - throw new Error('Non-base' + BASE + ' character') - } - return { - encode, - decodeUnsafe, - decode - } -} -export default base diff --git a/node_modules/bs58/README.md b/node_modules/bs58/README.md index 76a4ff0..ca0aa19 100644 --- a/node_modules/bs58/README.md +++ b/node_modules/bs58/README.md @@ -24,7 +24,7 @@ API **example**: ```js -import bs58 from 'bs58' +const bs58 = require('bs58') const bytes = Uint8Array.from([ 0, 60, 23, 110, 101, 155, 234, @@ -45,7 +45,7 @@ console.log(address) **example**: ```js -import bs58 from 'bs58' +const bs58 = require('bs58') const address = '16UjcYNBG9GTK4uq2f7yYEbuifqCzoLMGS' const bytes = bs58.decode(address) @@ -65,7 +65,7 @@ npm install -g browserify then run: ```bash -browserify node_modules/bs58/cjs/index.cjs -o bs58.bundle.js --standalone bs58 +browserify node_modules/bs58/index.js -o bs58.bundle.js --standalone bs58 ``` Hack / Test diff --git a/node_modules/bs58/package.json b/node_modules/bs58/package.json index bdc7d2a..6e53086 100644 --- a/node_modules/bs58/package.json +++ b/node_modules/bs58/package.json @@ -1,7 +1,6 @@ { "name": "bs58", - "version": "6.0.0", - "type": "module", + "version": "5.0.0", "description": "Base 58 encoding / decoding", "keywords": [ "base58", @@ -16,39 +15,25 @@ ], "license": "MIT", "devDependencies": { - "@types/node": "^20.14.8", - "rimraf": "^5.0.7", - "tape": "^5.3.0", - "ts-standard": "^12.0.2", - "typescript": "^5.5.2" + "standard": "^16.0.4", + "tape": "^4.6.3" }, "repository": { "url": "https://github.com/cryptocoinjs/bs58", "type": "git" }, "files": [ - "src" + "index.js", + "index.d.ts" ], - "main": "src/cjs/index.cjs", - "module": "src/esm/index.js", - "types": "src/cjs/index.d.ts", - "exports": { - ".": { - "import": "./src/esm/index.js", - "require": "./src/cjs/index.cjs", - "types": "./src/cjs/index.d.ts" - } - }, + "main": "index.js", + "types": "index.d.ts", "scripts": { - "build": "npm run clean && tsc -p ./tsconfig.json && tsc -p ./tsconfig.cjs.json", - "clean": "rimraf src", - "gitdiff": "npm run build && git diff --exit-code", - "postbuild": "find src/cjs -type f -name \"*.js\" -exec bash -c 'mv \"$0\" \"${0%.js}.cjs\"' {} \\;", - "standard": "ts-standard --ignore src --ignore test", + "standard": "standard", "test": "npm run standard && npm run unit", "unit": "tape test/index.js" }, "dependencies": { - "base-x": "^5.0.0" + "base-x": "^4.0.0" } } diff --git a/node_modules/bs58/src/cjs/index.cjs b/node_modules/bs58/src/cjs/index.cjs deleted file mode 100644 index 0a5d975..0000000 --- a/node_modules/bs58/src/cjs/index.cjs +++ /dev/null @@ -1,8 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var base_x_1 = __importDefault(require("base-x")); -var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'; -exports.default = (0, base_x_1.default)(ALPHABET); diff --git a/node_modules/bs58/src/cjs/index.d.ts b/node_modules/bs58/src/cjs/index.d.ts deleted file mode 100644 index 6aeee88..0000000 --- a/node_modules/bs58/src/cjs/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import basex from 'base-x'; -declare const _default: basex.BaseConverter; -export default _default; diff --git a/node_modules/bs58/src/esm/index.js b/node_modules/bs58/src/esm/index.js deleted file mode 100644 index 84a71b1..0000000 --- a/node_modules/bs58/src/esm/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import basex from 'base-x'; -var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'; -export default basex(ALPHABET); diff --git a/node_modules/content-type/README.md b/node_modules/content-type/README.md index ae275e0..c1a922a 100644 --- a/node_modules/content-type/README.md +++ b/node_modules/content-type/README.md @@ -1,57 +1,81 @@ # content-type -[![NPM version][npm-image]][npm-url] -[![NPM downloads][downloads-image]][downloads-url] -[![Build status][build-image]][build-url] -[![Build coverage][coverage-image]][coverage-url] -[![License][license-image]][license-url] +[![NPM Version][npm-version-image]][npm-url] +[![NPM Downloads][npm-downloads-image]][npm-url] +[![Node.js Version][node-image]][node-url] +[![Build Status][ci-image]][ci-url] +[![Coverage Status][coveralls-image]][coveralls-url] -Create and parse HTTP `Content-Type` header. +Create and parse HTTP Content-Type header according to RFC 7231 ## Installation ```sh -npm install content-type +$ npm install content-type ``` ## API ```js -const contentType = require("content-type"); +var contentType = require('content-type') ``` -### contentType.parse(string, options?) +### contentType.parse(string) ```js -const obj = contentType.parse("image/svg+xml; charset=utf-8"); +var obj = contentType.parse('image/svg+xml; charset=utf-8') ``` -Parse a `Content-Type` header. This will return an object with the following properties (examples are shown for the string `'image/svg+xml; charset=utf-8'`): +Parse a `Content-Type` header. This will return an object with the following +properties (examples are shown for the string `'image/svg+xml; charset=utf-8'`): -- `type`: The media type. Example: `'image/svg+xml'`. -- `parameters`: An object of the parameters in the media type (parameter name is always lower case). Example: `{charset: 'utf-8'}`. + - `type`: The media type (the type and subtype, always lower case). + Example: `'image/svg+xml'` -The parser is lenient and does not error. You should validate `type` and `parameters` before trusting them. + - `parameters`: An object of the parameters in the media type (name of parameter + always lower case). Example: `{charset: 'utf-8'}` -#### Options +Throws a `TypeError` if the string is missing or invalid. -- `parameters` (default: `true`): Set to `false` to skip parameters. -- `comma` (default: `false`): Set to `true` to stop on a comma. This can be used to parse the media range in an `Accept` header. -- `start` (default: `0`): Set index to start parsing from. +### contentType.parse(req) + +```js +var obj = contentType.parse(req) +``` + +Parse the `Content-Type` header from the given `req`. Short-cut for +`contentType.parse(req.headers['content-type'])`. + +Throws a `TypeError` if the `Content-Type` header is missing or invalid. + +### contentType.parse(res) + +```js +var obj = contentType.parse(res) +``` + +Parse the `Content-Type` header set on the given `res`. Short-cut for +`contentType.parse(res.getHeader('content-type'))`. + +Throws a `TypeError` if the `Content-Type` header is missing or invalid. ### contentType.format(obj) ```js -const str = contentType.format({ - type: "image/svg+xml", - parameters: { charset: "utf-8" }, -}); +var str = contentType.format({ + type: 'image/svg+xml', + parameters: { charset: 'utf-8' } +}) ``` -Format an object into a `Content-Type` header. This will return a string of the content type for the given object with the following properties (examples are shown that produce the string `'image/svg+xml; charset=utf-8'`): +Format an object into a `Content-Type` header. This will return a string of the +content type for the given object with the following properties (examples are +shown that produce the string `'image/svg+xml; charset=utf-8'`): -- `type`: The media type. Example: `'image/svg+xml'`. -- `parameters`: An optional object of the parameters in the media type. Example: `{charset: 'utf-8'}`. + - `type`: The media type (will be lower-cased). Example: `'image/svg+xml'` + + - `parameters`: An object of the parameters in the media type (name of the + parameter will be lower-cased). Example: `{charset: 'utf-8'}` Throws a `TypeError` if the object contains an invalid type or parameter names. @@ -59,13 +83,12 @@ Throws a `TypeError` if the object contains an invalid type or parameter names. [MIT](LICENSE) -[npm-image]: https://img.shields.io/npm/v/content-type +[ci-image]: https://badgen.net/github/checks/jshttp/content-type/master?label=ci +[ci-url]: https://github.com/jshttp/content-type/actions/workflows/ci.yml +[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/content-type/master +[coveralls-url]: https://coveralls.io/r/jshttp/content-type?branch=master +[node-image]: https://badgen.net/npm/node/content-type +[node-url]: https://nodejs.org/en/download +[npm-downloads-image]: https://badgen.net/npm/dm/content-type [npm-url]: https://npmjs.org/package/content-type -[downloads-image]: https://img.shields.io/npm/dm/content-type -[downloads-url]: https://npmjs.org/package/content-type -[build-image]: https://img.shields.io/github/actions/workflow/status/jshttp/content-type/ci.yml?branch=master -[build-url]: https://github.com/jshttp/content-type/actions/workflows/ci.yml?query=branch%3Amaster -[coverage-image]: https://img.shields.io/codecov/c/gh/jshttp/content-type -[coverage-url]: https://codecov.io/gh/jshttp/content-type -[license-image]: http://img.shields.io/npm/l/content-type.svg?style=flat -[license-url]: LICENSE +[npm-version-image]: https://badgen.net/npm/v/content-type diff --git a/node_modules/content-type/dist/index.d.ts b/node_modules/content-type/dist/index.d.ts deleted file mode 100644 index c153445..0000000 --- a/node_modules/content-type/dist/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/*! - * content-type - * Copyright(c) 2015 Douglas Christopher Wilson - * MIT Licensed - */ -/** - * The content type object contains a type string and optional parameters. - */ -export interface ContentType { - type: string; - index: number; - parameters: Record; -} -/** - * Format an object into a `Content-Type` header. - */ -export declare function format(obj: Partial): string; -/** - * Options for parsing a `Content-Type` header. - */ -export interface ParseOptions { - /** - * Exit early on the first semicolon, returning only the type. - * This is useful for parsing the MIME from `Content-Type` headers. - * - * @default false - */ - parameters?: boolean; - /** - * Exits early on a comma, returning the first value and parameters. - * This is useful for parsing `Accept` headers. - * - * @default false - */ - comma?: boolean; - /** - * The index to start parsing from. - * - * @default 0 - */ - start?: number; -} -/** - * Parse a `Content-Type` header. - */ -export declare function parse(header: string, options?: ParseOptions): ContentType; diff --git a/node_modules/content-type/dist/index.js b/node_modules/content-type/dist/index.js deleted file mode 100644 index 6f3a3e7..0000000 --- a/node_modules/content-type/dist/index.js +++ /dev/null @@ -1,176 +0,0 @@ -"use strict"; -/*! - * content-type - * Copyright(c) 2015 Douglas Christopher Wilson - * MIT Licensed - */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.format = format; -exports.parse = parse; -const TEXT_REGEXP = /^[\u0009\u0020-\u007e\u0080-\u00ff]*$/; -const TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; -/** - * RegExp to match chars that must be quoted-pair in RFC 9110 sec 5.6.4 - */ -const QUOTE_REGEXP = /[\\"]/g; -/** - * RegExp to match type in RFC 9110 sec 8.3.1 - * - * media-type = type "/" subtype - * type = token - * subtype = token - */ -const TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; -/** - * Null object perf optimization. Faster than `Object.create(null)` and `{ __proto__: null }`. - */ -const NullObject = /* @__PURE__ */ (() => { - const C = function () { }; - C.prototype = Object.create(null); - return C; -})(); -/** - * Format an object into a `Content-Type` header. - */ -function format(obj) { - const { type, parameters } = obj; - if (!type || !TYPE_REGEXP.test(type)) { - throw new TypeError(`Invalid type: ${type}`); - } - let result = type; - if (parameters) { - for (const param of Object.keys(parameters)) { - if (!TOKEN_REGEXP.test(param)) { - throw new TypeError(`Invalid parameter name: ${param}`); - } - result += `; ${param}=${qstring(parameters[param])}`; - } - } - return result; -} -/** - * Parse a `Content-Type` header. - */ -function parse(header, options) { - const stopChar = options?.comma === true ? COMMA : 65536; // Sentinel for "no stop char". - const len = header.length; - let index = skipOWS(header, options?.start ?? 0, len); - const valueStart = index; - index = skipValue(header, index, len, stopChar); - const valueEnd = trailingOWS(header, valueStart, index); - const type = header.slice(valueStart, valueEnd).toLowerCase(); - if (options?.parameters === false) { - return { type, index, parameters: new NullObject() }; - } - return parseParameters(header, type, index, len, stopChar); -} -const SP = 32; // " " -const HTAB = 9; // "\t" -const SEMI = 59; // ";" -const EQ = 61; // "=" -const DQUOTE = 34; // '"' -const BSLASH = 92; // "\\" -const COMMA = 44; // "," -/** - * Parses the parameters of a `Content-Type` header starting at the given index. - */ -function parseParameters(header, type, index, len, stopChar) { - const parameters = new NullObject(); - parameter: while (index < len) { - if (header.charCodeAt(index) === stopChar) - break; - index = skipOWS(header, index + 1 /* Skip over ; */, len); - const keyStart = index; - while (index < len) { - const code = header.charCodeAt(index); - if (code === stopChar) - break parameter; - if (code === SEMI) - continue parameter; - if (code === EQ) { - const keyEnd = trailingOWS(header, keyStart, index); - const key = header.slice(keyStart, keyEnd).toLowerCase(); - index = skipOWS(header, index + 1, len); - if (index < len && header.charCodeAt(index) === DQUOTE) { - index++; - let value = ""; - while (index < len) { - const code = header.charCodeAt(index++); - if (code === DQUOTE) { - index = skipValue(header, index, len, stopChar); - if (parameters[key] === undefined) - parameters[key] = value; - break; - } - if (code === BSLASH && index < len) { - value += header[index++]; - continue; - } - value += String.fromCharCode(code); - } - continue parameter; - } - const valueStart = index; - index = skipValue(header, index, len, stopChar); - if (parameters[key] === undefined) { - const valueEnd = trailingOWS(header, valueStart, index); - parameters[key] = header.slice(valueStart, valueEnd); - } - continue parameter; - } - index++; - } - } - return { type, index, parameters }; -} -/** - * Skip over characters until a semicolon or other exit character. - */ -function skipValue(str, index, len, stopChar) { - while (index < len) { - const code = str.charCodeAt(index); - if (code === SEMI || code === stopChar) - break; - index++; - } - return index; -} -/** - * Skip optional whitespace (OWS) in an HTTP header value. - * - * OWS is defined in RFC 9110 sec 5.6.3 as SP (" ") or HTAB ("\t"). - */ -function skipOWS(header, index, len) { - while (index < len) { - const char = header.charCodeAt(index); - if (char !== SP && char !== HTAB) - break; - index++; - } - return index; -} -/** - * Trim optional whitespace (OWS) from the end of a substring. - * - * OWS is defined in RFC 9110 sec 5.6.3 as SP (" ") or HTAB ("\t"). - */ -function trailingOWS(header, start, end) { - while (end > start) { - const char = header.charCodeAt(end - 1); - if (char !== SP && char !== HTAB) - break; - end--; - } - return end; -} -/** - * Serialize a parameter value. - */ -function qstring(str) { - if (TOKEN_REGEXP.test(str)) - return str; - if (TEXT_REGEXP.test(str)) - return `"${str.replace(QUOTE_REGEXP, "\\$&")}"`; - throw new TypeError(`Invalid parameter value: ${str}`); -} -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/content-type/dist/index.js.map b/node_modules/content-type/dist/index.js.map deleted file mode 100644 index 2f89192..0000000 --- a/node_modules/content-type/dist/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAyCH,wBAoBC;AA+BD,sBAeC;AAzGD,MAAM,WAAW,GAAG,uCAAuC,CAAC;AAC5D,MAAM,YAAY,GAAG,+BAA+B,CAAC;AAErD;;GAEG;AACH,MAAM,YAAY,GAAG,QAAQ,CAAC;AAE9B;;;;;;GAMG;AACH,MAAM,WAAW,GACf,4DAA4D,CAAC;AAE/D;;GAEG;AACH,MAAM,UAAU,GAAG,eAAe,CAAC,CAAC,GAAG,EAAE;IACvC,MAAM,CAAC,GAAG,cAAa,CAAC,CAAC;IACzB,CAAC,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAClC,OAAO,CAAC,CAAC;AACX,CAAC,CAAC,EAAgC,CAAC;AAWnC;;GAEG;AACH,SAAgB,MAAM,CAAC,GAAyB;IAC9C,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,GAAG,CAAC;IAEjC,IAAI,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,SAAS,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC;IAC/C,CAAC;IAED,IAAI,MAAM,GAAG,IAAI,CAAC;IAElB,IAAI,UAAU,EAAE,CAAC;QACf,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YAC5C,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC9B,MAAM,IAAI,SAAS,CAAC,2BAA2B,KAAK,EAAE,CAAC,CAAC;YAC1D,CAAC;YAED,MAAM,IAAI,KAAK,KAAK,IAAI,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QACvD,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AA4BD;;GAEG;AACH,SAAgB,KAAK,CAAC,MAAc,EAAE,OAAsB;IAC1D,MAAM,QAAQ,GAAG,OAAO,EAAE,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAM,CAAC,CAAC,+BAA+B;IAC1F,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC;IAC1B,IAAI,KAAK,GAAG,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;IAEtD,MAAM,UAAU,GAAG,KAAK,CAAC;IACzB,KAAK,GAAG,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;IAChD,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;IACxD,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC;IAE9D,IAAI,OAAO,EAAE,UAAU,KAAK,KAAK,EAAE,CAAC;QAClC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,UAAU,EAAE,EAAE,CAAC;IACvD,CAAC;IAED,OAAO,eAAe,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;AAC7D,CAAC;AAED,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM;AACrB,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,OAAO;AACvB,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC,MAAM;AACvB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM;AACrB,MAAM,MAAM,GAAG,EAAE,CAAC,CAAC,MAAM;AACzB,MAAM,MAAM,GAAG,EAAE,CAAC,CAAC,OAAO;AAC1B,MAAM,KAAK,GAAG,EAAE,CAAC,CAAC,MAAM;AAExB;;GAEG;AACH,SAAS,eAAe,CACtB,MAAc,EACd,IAAY,EACZ,KAAa,EACb,GAAW,EACX,QAAgB;IAEhB,MAAM,UAAU,GAA2B,IAAI,UAAU,EAAE,CAAC;IAE5D,SAAS,EAAE,OAAO,KAAK,GAAG,GAAG,EAAE,CAAC;QAC9B,IAAI,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,QAAQ;YAAE,MAAM;QAEjD,KAAK,GAAG,OAAO,CAAC,MAAM,EAAE,KAAK,GAAG,CAAC,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;QAE1D,MAAM,QAAQ,GAAG,KAAK,CAAC;QAEvB,OAAO,KAAK,GAAG,GAAG,EAAE,CAAC;YACnB,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YACtC,IAAI,IAAI,KAAK,QAAQ;gBAAE,MAAM,SAAS,CAAC;YAEvC,IAAI,IAAI,KAAK,IAAI;gBAAE,SAAS,SAAS,CAAC;YAEtC,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;gBAChB,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;gBACpD,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;gBAEzD,KAAK,GAAG,OAAO,CAAC,MAAM,EAAE,KAAK,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;gBAExC,IAAI,KAAK,GAAG,GAAG,IAAI,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,MAAM,EAAE,CAAC;oBACvD,KAAK,EAAE,CAAC;oBAER,IAAI,KAAK,GAAG,EAAE,CAAC;oBACf,OAAO,KAAK,GAAG,GAAG,EAAE,CAAC;wBACnB,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC;wBACxC,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;4BACpB,KAAK,GAAG,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;4BAChD,IAAI,UAAU,CAAC,GAAG,CAAC,KAAK,SAAS;gCAAE,UAAU,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;4BAC3D,MAAM;wBACR,CAAC;wBAED,IAAI,IAAI,KAAK,MAAM,IAAI,KAAK,GAAG,GAAG,EAAE,CAAC;4BACnC,KAAK,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;4BACzB,SAAS;wBACX,CAAC;wBAED,KAAK,IAAI,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;oBACrC,CAAC;oBAED,SAAS,SAAS,CAAC;gBACrB,CAAC;gBAED,MAAM,UAAU,GAAG,KAAK,CAAC;gBACzB,KAAK,GAAG,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;gBAEhD,IAAI,UAAU,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE,CAAC;oBAClC,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;oBACxD,UAAU,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;gBACvD,CAAC;gBAED,SAAS,SAAS,CAAC;YACrB,CAAC;YAED,KAAK,EAAE,CAAC;QACV,CAAC;IACH,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,SAAS,SAAS,CAChB,GAAW,EACX,KAAa,EACb,GAAW,EACX,QAAgB;IAEhB,OAAO,KAAK,GAAG,GAAG,EAAE,CAAC;QACnB,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,QAAQ;YAAE,MAAM;QAC9C,KAAK,EAAE,CAAC;IACV,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,SAAS,OAAO,CAAC,MAAc,EAAE,KAAa,EAAE,GAAW;IACzD,OAAO,KAAK,GAAG,GAAG,EAAE,CAAC;QACnB,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACtC,IAAI,IAAI,KAAK,EAAE,IAAI,IAAI,KAAK,IAAI;YAAE,MAAM;QACxC,KAAK,EAAE,CAAC;IACV,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,SAAS,WAAW,CAAC,MAAc,EAAE,KAAa,EAAE,GAAW;IAC7D,OAAO,GAAG,GAAG,KAAK,EAAE,CAAC;QACnB,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QACxC,IAAI,IAAI,KAAK,EAAE,IAAI,IAAI,KAAK,IAAI;YAAE,MAAM;QACxC,GAAG,EAAE,CAAC;IACR,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;GAEG;AACH,SAAS,OAAO,CAAC,GAAW;IAC1B,IAAI,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IACvC,IAAI,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,CAAC;IAE3E,MAAM,IAAI,SAAS,CAAC,4BAA4B,GAAG,EAAE,CAAC,CAAC;AACzD,CAAC","sourcesContent":["/*!\n * content-type\n * Copyright(c) 2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\nconst TEXT_REGEXP = /^[\\u0009\\u0020-\\u007e\\u0080-\\u00ff]*$/;\nconst TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;\n\n/**\n * RegExp to match chars that must be quoted-pair in RFC 9110 sec 5.6.4\n */\nconst QUOTE_REGEXP = /[\\\\\"]/g;\n\n/**\n * RegExp to match type in RFC 9110 sec 8.3.1\n *\n * media-type = type \"/\" subtype\n * type = token\n * subtype = token\n */\nconst TYPE_REGEXP =\n /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;\n\n/**\n * Null object perf optimization. Faster than `Object.create(null)` and `{ __proto__: null }`.\n */\nconst NullObject = /* @__PURE__ */ (() => {\n const C = function () {};\n C.prototype = Object.create(null);\n return C;\n})() as unknown as { new (): any };\n\n/**\n * The content type object contains a type string and optional parameters.\n */\nexport interface ContentType {\n type: string;\n index: number;\n parameters: Record;\n}\n\n/**\n * Format an object into a `Content-Type` header.\n */\nexport function format(obj: Partial): string {\n const { type, parameters } = obj;\n\n if (!type || !TYPE_REGEXP.test(type)) {\n throw new TypeError(`Invalid type: ${type}`);\n }\n\n let result = type;\n\n if (parameters) {\n for (const param of Object.keys(parameters)) {\n if (!TOKEN_REGEXP.test(param)) {\n throw new TypeError(`Invalid parameter name: ${param}`);\n }\n\n result += `; ${param}=${qstring(parameters[param])}`;\n }\n }\n\n return result;\n}\n\n/**\n * Options for parsing a `Content-Type` header.\n */\nexport interface ParseOptions {\n /**\n * Exit early on the first semicolon, returning only the type.\n * This is useful for parsing the MIME from `Content-Type` headers.\n *\n * @default false\n */\n parameters?: boolean;\n /**\n * Exits early on a comma, returning the first value and parameters.\n * This is useful for parsing `Accept` headers.\n *\n * @default false\n */\n comma?: boolean;\n /**\n * The index to start parsing from.\n *\n * @default 0\n */\n start?: number;\n}\n\n/**\n * Parse a `Content-Type` header.\n */\nexport function parse(header: string, options?: ParseOptions): ContentType {\n const stopChar = options?.comma === true ? COMMA : 65_536; // Sentinel for \"no stop char\".\n const len = header.length;\n let index = skipOWS(header, options?.start ?? 0, len);\n\n const valueStart = index;\n index = skipValue(header, index, len, stopChar);\n const valueEnd = trailingOWS(header, valueStart, index);\n const type = header.slice(valueStart, valueEnd).toLowerCase();\n\n if (options?.parameters === false) {\n return { type, index, parameters: new NullObject() };\n }\n\n return parseParameters(header, type, index, len, stopChar);\n}\n\nconst SP = 32; // \" \"\nconst HTAB = 9; // \"\\t\"\nconst SEMI = 59; // \";\"\nconst EQ = 61; // \"=\"\nconst DQUOTE = 34; // '\"'\nconst BSLASH = 92; // \"\\\\\"\nconst COMMA = 44; // \",\"\n\n/**\n * Parses the parameters of a `Content-Type` header starting at the given index.\n */\nfunction parseParameters(\n header: string,\n type: string,\n index: number,\n len: number,\n stopChar: number,\n): ContentType {\n const parameters: Record = new NullObject();\n\n parameter: while (index < len) {\n if (header.charCodeAt(index) === stopChar) break;\n\n index = skipOWS(header, index + 1 /* Skip over ; */, len);\n\n const keyStart = index;\n\n while (index < len) {\n const code = header.charCodeAt(index);\n if (code === stopChar) break parameter;\n\n if (code === SEMI) continue parameter;\n\n if (code === EQ) {\n const keyEnd = trailingOWS(header, keyStart, index);\n const key = header.slice(keyStart, keyEnd).toLowerCase();\n\n index = skipOWS(header, index + 1, len);\n\n if (index < len && header.charCodeAt(index) === DQUOTE) {\n index++;\n\n let value = \"\";\n while (index < len) {\n const code = header.charCodeAt(index++);\n if (code === DQUOTE) {\n index = skipValue(header, index, len, stopChar);\n if (parameters[key] === undefined) parameters[key] = value;\n break;\n }\n\n if (code === BSLASH && index < len) {\n value += header[index++];\n continue;\n }\n\n value += String.fromCharCode(code);\n }\n\n continue parameter;\n }\n\n const valueStart = index;\n index = skipValue(header, index, len, stopChar);\n\n if (parameters[key] === undefined) {\n const valueEnd = trailingOWS(header, valueStart, index);\n parameters[key] = header.slice(valueStart, valueEnd);\n }\n\n continue parameter;\n }\n\n index++;\n }\n }\n\n return { type, index, parameters };\n}\n\n/**\n * Skip over characters until a semicolon or other exit character.\n */\nfunction skipValue(\n str: string,\n index: number,\n len: number,\n stopChar: number,\n): number {\n while (index < len) {\n const code = str.charCodeAt(index);\n if (code === SEMI || code === stopChar) break;\n index++;\n }\n return index;\n}\n\n/**\n * Skip optional whitespace (OWS) in an HTTP header value.\n *\n * OWS is defined in RFC 9110 sec 5.6.3 as SP (\" \") or HTAB (\"\\t\").\n */\nfunction skipOWS(header: string, index: number, len: number): number {\n while (index < len) {\n const char = header.charCodeAt(index);\n if (char !== SP && char !== HTAB) break;\n index++;\n }\n return index;\n}\n\n/**\n * Trim optional whitespace (OWS) from the end of a substring.\n *\n * OWS is defined in RFC 9110 sec 5.6.3 as SP (\" \") or HTAB (\"\\t\").\n */\nfunction trailingOWS(header: string, start: number, end: number): number {\n while (end > start) {\n const char = header.charCodeAt(end - 1);\n if (char !== SP && char !== HTAB) break;\n end--;\n }\n return end;\n}\n\n/**\n * Serialize a parameter value.\n */\nfunction qstring(str: string): string {\n if (TOKEN_REGEXP.test(str)) return str;\n if (TEXT_REGEXP.test(str)) return `\"${str.replace(QUOTE_REGEXP, \"\\\\$&\")}\"`;\n\n throw new TypeError(`Invalid parameter value: ${str}`);\n}\n"]} \ No newline at end of file diff --git a/node_modules/content-type/package.json b/node_modules/content-type/package.json index 4a403eb..9db19f6 100644 --- a/node_modules/content-type/package.json +++ b/node_modules/content-type/package.json @@ -1,52 +1,42 @@ { "name": "content-type", - "version": "2.1.0", "description": "Create and parse HTTP Content-Type header", + "version": "1.0.5", + "author": "Douglas Christopher Wilson ", + "license": "MIT", "keywords": [ "content-type", "http", "req", "res", - "rfc7231", - "rfc9110" + "rfc7231" ], "repository": "jshttp/content-type", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - }, - "license": "MIT", - "author": "Douglas Christopher Wilson ", - "type": "commonjs", - "exports": "./dist/index.js", - "main": "./dist/index.js", - "typings": "./dist/index.d.ts", - "files": [ - "dist/" - ], - "scripts": { - "bench": "vitest bench", - "build": "ts-scripts build", - "format": "ts-scripts format", - "prepare": "ts-scripts install && npm run build", - "specs": "ts-scripts specs", - "test": "ts-scripts test" - }, "devDependencies": { - "@borderless/ts-scripts": "^0.15.0", - "@vitest/coverage-v8": "^3.0.5", - "typescript": "^5.7.3", - "vitest": "^3.2.4" + "deep-equal": "1.0.1", + "eslint": "8.32.0", + "eslint-config-standard": "15.0.1", + "eslint-plugin-import": "2.27.5", + "eslint-plugin-node": "11.1.0", + "eslint-plugin-promise": "6.1.1", + "eslint-plugin-standard": "4.1.0", + "mocha": "10.2.0", + "nyc": "15.1.0" }, + "files": [ + "LICENSE", + "HISTORY.md", + "README.md", + "index.js" + ], "engines": { - "node": ">=18" + "node": ">= 0.6" }, - "ts-scripts": { - "dist": [ - "dist" - ], - "project": [ - "tsconfig.build.json" - ] + "scripts": { + "lint": "eslint .", + "test": "mocha --reporter spec --check-leaks --bail test/", + "test-ci": "nyc --reporter=lcovonly --reporter=text npm test", + "test-cov": "nyc --reporter=html --reporter=text npm test", + "version": "node scripts/version-history.js && git add HISTORY.md" } } diff --git a/node_modules/is-network-error/index.d.ts b/node_modules/is-network-error/index.d.ts deleted file mode 100644 index 1107c81..0000000 --- a/node_modules/is-network-error/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** -Check if an error is a [Fetch network error](https://developer.mozilla.org/en-US/docs/Web/API/fetch#exceptions) - -@return Returns `true` if the given value is a Fetch network error, otherwise `false`. - -@example -``` -import isNetworkError from 'is-network-error'; - -async function getUnicorns() { - try { - const response = await fetch('unicorns.json'); - return await response.json(); - } catch (error) { - if (isNetworkError(error)) { - return localStorage.getItem('…'); - } - - throw error; - } -} - -console.log(await getUnicorns()); -``` -*/ -export default function isNetworkError(value: unknown): value is TypeError; diff --git a/node_modules/is-network-error/index.js b/node_modules/is-network-error/index.js deleted file mode 100644 index 4ce2be3..0000000 --- a/node_modules/is-network-error/index.js +++ /dev/null @@ -1,47 +0,0 @@ -const objectToString = Object.prototype.toString; - -const isError = value => objectToString.call(value) === '[object Error]'; - -const errorMessages = new Set([ - 'network error', // Chrome - 'NetworkError when attempting to fetch resource.', // Firefox - 'The Internet connection appears to be offline.', // Safari 16 - 'Network request failed', // `cross-fetch` - 'fetch failed', // Undici (Node.js) - 'terminated', // Undici (Node.js) - ' A network error occurred.', // Bun (WebKit) - 'Network connection lost', // Cloudflare Workers (fetch) -]); - -export default function isNetworkError(error) { - const isValid = error - && isError(error) - && error.name === 'TypeError' - && typeof error.message === 'string'; - - if (!isValid) { - return false; - } - - const {message, stack} = error; - - // Safari 17+ has generic message but no stack for network errors - if (message === 'Load failed' || (message.startsWith('Load failed (') && message.endsWith(')'))) { - return stack === undefined - // Sentry adds its own stack trace to the fetch error, so also check for that - || '__sentry_captured__' in error; - } - - // Deno network errors start with specific text - if (message.startsWith('error sending request for url')) { - return true; - } - - // Chrome: exact "Failed to fetch" or with hostname: "Failed to fetch (example.com)" - if (message === 'Failed to fetch' || (message.startsWith('Failed to fetch (') && message.endsWith(')'))) { - return true; - } - - // Standard network error messages - return errorMessages.has(message); -} diff --git a/node_modules/is-network-error/license b/node_modules/is-network-error/license deleted file mode 100644 index fa7ceba..0000000 --- a/node_modules/is-network-error/license +++ /dev/null @@ -1,9 +0,0 @@ -MIT License - -Copyright (c) Sindre Sorhus (https://sindresorhus.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/is-network-error/package.json b/node_modules/is-network-error/package.json deleted file mode 100644 index 9de6fcf..0000000 --- a/node_modules/is-network-error/package.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "name": "is-network-error", - "version": "1.3.2", - "description": "Check if a value is a Fetch network error", - "license": "MIT", - "repository": "sindresorhus/is-network-error", - "funding": "https://github.com/sponsors/sindresorhus", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "https://sindresorhus.com" - }, - "type": "module", - "exports": { - "types": "./index.d.ts", - "default": "./index.js" - }, - "sideEffects": false, - "engines": { - "node": ">=16" - }, - "scripts": { - "test": "xo && ava && tsd" - }, - "files": [ - "index.js", - "index.d.ts" - ], - "keywords": [ - "network", - "error", - "fetch", - "whatwg", - "detect", - "check", - "typeerror" - ], - "devDependencies": { - "ava": "^5.3.1", - "tsd": "^0.29.0", - "xo": "^0.56.0" - } -} diff --git a/node_modules/is-network-error/readme.md b/node_modules/is-network-error/readme.md deleted file mode 100644 index 1de57bc..0000000 --- a/node_modules/is-network-error/readme.md +++ /dev/null @@ -1,44 +0,0 @@ -# is-network-error - -> Check if a value is a [Fetch network error](https://developer.mozilla.org/en-US/docs/Web/API/fetch#exceptions) - -This can be useful when you want to do something specific when a network error happens without catching other Fetch-related errors. - -Unfortunately, Fetch network errors are [not standardized](https://github.com/whatwg/fetch/issues/526) and differ among implementations. This package handles the differences across Node.js, Bun, Deno, and browsers. - -For instance, [`p-retry`](https://github.com/sindresorhus/p-retry) uses this package to retry on network errors. - -## Install - -```sh -npm install is-network-error -``` - -## Usage - -```js -import isNetworkError from 'is-network-error'; - -async function getUnicorns() { - try { - const response = await fetch('unicorns.json'); - return await response.json(); - } catch (error) { - if (isNetworkError(error)) { - return localStorage.getItem('…'); - } - - throw error; - } -} - -console.log(await getUnicorns()); -``` - -## API - -### `isNetworkError(value: unknown): value is TypeError` - -Returns `true` if the given value is a Fetch network error, otherwise `false`. - -This function acts as a type guard, narrowing the type to `TypeError` when it returns `true`. diff --git a/node_modules/matrix-js-sdk/CHANGELOG.md b/node_modules/matrix-js-sdk/CHANGELOG.md index 1cbd2ea..aa94784 100644 --- a/node_modules/matrix-js-sdk/CHANGELOG.md +++ b/node_modules/matrix-js-sdk/CHANGELOG.md @@ -1,1283 +1,3 @@ -Changes in [42.3.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v42.3.0) (2026-09-01) -================================================================================================== -## ✨ Features - -* Don't treat Matrix-shaped errors as OAuth token refresh grant logouts ([#5473](https://github.com/matrix-org/matrix-js-sdk/pull/5473)). Contributed by @hughns. -* Update MatrixRTCSession to increase push notification arrival time on mobile clients for element-call ([#5398](https://github.com/matrix-org/matrix-js-sdk/pull/5398)). Contributed by @escix. -* Add sticky events support to sliding sync (MSC4480) ([#5458](https://github.com/matrix-org/matrix-js-sdk/pull/5458)). Contributed by @eleboucher. -* Validate that an error from OAuth token refresh looks like an OAuth error before treating as logout ([#5472](https://github.com/matrix-org/matrix-js-sdk/pull/5472)). Contributed by @hughns. - -## 🐛 Bug Fixes - -* Make setExtendedProfileProperty not throw if the requested property isn't set ([#5484](https://github.com/matrix-org/matrix-js-sdk/pull/5484)). Contributed by @dbkr. -* make sure `setDefaultKeyId` resolves even if no change is made ([#5485](https://github.com/matrix-org/matrix-js-sdk/pull/5485)). Contributed by @uhoreg. - - -Changes in [42.2.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v42.2.0) (2026-08-18) -================================================================================================== -## 🐛 Bug Fixes - -* Fix pre-initialization thread edits when target is known ([#5440](https://github.com/matrix-org/matrix-js-sdk/pull/5440)). Contributed by @basnijholt. -* Fix package failing to load in Node ESM due to directory import ([#5460](https://github.com/matrix-org/matrix-js-sdk/pull/5460)). Contributed by @syphernl. - - -Changes in [42.1.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v42.1.0) (2026-08-04) -================================================================================================== -## 🦖 Deprecations - -* Remove support for MSC3391 \& MSC3852 ([#5446](https://github.com/matrix-org/matrix-js-sdk/pull/5446)). Contributed by @t3chguy. - -## ✨ Features - -* Allow passing a CA cert PEM when setting up Rust crypto ([#5443](https://github.com/matrix-org/matrix-js-sdk/pull/5443)). Contributed by @andybalaam. -* Improve types for `/room_keys/version` requests ([#5419](https://github.com/matrix-org/matrix-js-sdk/pull/5419)). Contributed by @richvdh. - -## 🐛 Bug Fixes - -* Include existing data when updating user profile cache ([#5427](https://github.com/matrix-org/matrix-js-sdk/pull/5427)). Contributed by @dbkr. -* Fix key backup cached event ordering ([#5281](https://github.com/matrix-org/matrix-js-sdk/pull/5281)). Contributed by @gumadeiras. - - -Changes in [42.0.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v42.0.0) (2026-07-21) -================================================================================================== -## 🚨 BREAKING CHANGES - -* Properly support Matrix v1.18 OAuth2 APIs ([#5390](https://github.com/matrix-org/matrix-js-sdk/pull/5390)). Contributed by @t3chguy. -* Remove unused getContentUri ([#5400](https://github.com/matrix-org/matrix-js-sdk/pull/5400)). Contributed by @t3chguy. - - -Changes in [41.9.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v41.9.0) (2026-07-07) -================================================================================================== -## ✨ Features - -* Add method `CryptoApi.getUserCrossSigningKeys` ([#5389](https://github.com/matrix-org/matrix-js-sdk/pull/5389)). Contributed by @richvdh. - -## 🐛 Bug Fixes - -* Fix restarting delayed events via compatibility path in RoomWidgetClient ([#5380](https://github.com/matrix-org/matrix-js-sdk/pull/5380)). Contributed by @robintown. - - -Changes in [41.8.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v41.8.0) (2026-06-23) -================================================================================================== -## ✨ Features - -* MatrixRTC: Preserve original error as `cause` when wrapping in scheduler ([#5363](https://github.com/matrix-org/matrix-js-sdk/pull/5363)). Contributed by @fkwp. -* Add mechanism to locally enforce MSC1763 retention rules ([#5353](https://github.com/matrix-org/matrix-js-sdk/pull/5353)). Contributed by @Half-Shot. - -## 🐛 Bug Fixes - -* Fall back to local indexeddb backend when worker fails to start ([#5361](https://github.com/matrix-org/matrix-js-sdk/pull/5361)). Contributed by @t3chguy. - - -Changes in [41.7.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v41.7.0) (2026-06-09) -================================================================================================== -## ✨ Features - -* MSC4140: use auth for delayed event management ([#5340](https://github.com/matrix-org/matrix-js-sdk/pull/5340)). Contributed by @AndrewFerr. - -## 🐛 Bug Fixes - -* [Backport staging] SECURITY: Update matrix-sdk-crypto-wasm to v18.3.1 ([#5356](https://github.com/matrix-org/matrix-js-sdk/pull/5356)). Contributed by @RiotRobot. -* fix(MatrixRTCSession): replace no-arg .finally() with .then(fn, fn) to fix crash on React Native / Hermes ([#5307](https://github.com/matrix-org/matrix-js-sdk/pull/5307)). Contributed by @JeanLuX. - - -Changes in [41.6.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v41.6.0) (2026-05-26) -================================================================================================== -## 🐛 Bug Fixes - -* Throw sane error on completeLoginOnNewDevice IdP rejection ([#5321](https://github.com/matrix-org/matrix-js-sdk/pull/5321)). Contributed by @t3chguy. - - -Changes in [41.5.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v41.5.0) (2026-05-12) -================================================================================================== -## ✨ Features - -* MSC4108v2024 iteration and support for sign in on new device ([#5283](https://github.com/matrix-org/matrix-js-sdk/pull/5283)). Contributed by @t3chguy. -* Enable encrypted history sharing by default ([#5300](https://github.com/matrix-org/matrix-js-sdk/pull/5300)). Contributed by @richvdh. -* Restore functional `start` command ([#5298](https://github.com/matrix-org/matrix-js-sdk/pull/5298)). Contributed by @t3chguy. -* Support stable identifiers for MSC4268 and MSC4287 ([#5299](https://github.com/matrix-org/matrix-js-sdk/pull/5299)). Contributed by @andybalaam. -* Implement MSC4429: Profile Updates for Legacy Sync ([#5246](https://github.com/matrix-org/matrix-js-sdk/pull/5246)). Contributed by @Half-Shot. -* Support stable identifiers for MSC4268 ([#5290](https://github.com/matrix-org/matrix-js-sdk/pull/5290)). Contributed by @andybalaam. - - -Changes in [41.4.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v41.4.0) (2026-04-28) -================================================================================================== -## ✨ Features - -* Handle secret pushing for key backups ([#5189](https://github.com/matrix-org/matrix-js-sdk/pull/5189)). Contributed by @uhoreg. -* Add support for `m.recent_emoji` account data event ([#5280](https://github.com/matrix-org/matrix-js-sdk/pull/5280)). Contributed by @t3chguy. -* Adapt LiveKit Identity hash calculation to latest MSC4195 update ([#5268](https://github.com/matrix-org/matrix-js-sdk/pull/5268)). Contributed by @fkwp. -* Support the stable prefix for MSC4287 (key backup preference) ([#5258](https://github.com/matrix-org/matrix-js-sdk/pull/5258)). Contributed by @andybalaam. -* Handle response\_mode=fragment in completeAuthorizationCodeGrant ([#5266](https://github.com/matrix-org/matrix-js-sdk/pull/5266)). Contributed by @t3chguy. -* Allow generating OIDC URIs with response\_mode=fragment ([#5265](https://github.com/matrix-org/matrix-js-sdk/pull/5265)). Contributed by @t3chguy. -* Expose `UserVerificationStatus.known` flag ([#5255](https://github.com/matrix-org/matrix-js-sdk/pull/5255)). Contributed by @richvdh. - -## 🐛 Bug Fixes - -* Allow oidc jwks\_uri to be omitted ([#5271](https://github.com/matrix-org/matrix-js-sdk/pull/5271)). Contributed by @t3chguy. - - -Changes in [41.3.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v41.3.0) (2026-04-07) -================================================================================================== -## 🐛 Bug Fixes - -* Rotate the current room key when we see a member leave ([#5231](https://github.com/matrix-org/matrix-js-sdk/pull/5231)). Contributed by @kaylendog. - - -Changes in [41.2.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v41.2.0) (2026-03-24) -================================================================================================== -## ✨ Features - -* Only share history if room history visibility is shared ([#5216](https://github.com/matrix-org/matrix-js-sdk/pull/5216)). Contributed by @kaylendog. -* History sharing: resume key-bundle import on restart ([#5214](https://github.com/matrix-org/matrix-js-sdk/pull/5214)). Contributed by @richvdh. -* Move `CryptoApi.shareRoomHistoryWithUser` to `CryptoBackend` ([#5218](https://github.com/matrix-org/matrix-js-sdk/pull/5218)). Contributed by @richvdh. - - -Changes in [41.1.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v41.1.0) (2026-03-10) -================================================================================================== -## ✨ Features - -* Throw a specific error when the backup decryption key does not match the public backup ([#5202](https://github.com/matrix-org/matrix-js-sdk/pull/5202)). Contributed by @andybalaam. -* Update getUrlPreview to use /\_matrix/client/v1/media/preview\_url ([#5191](https://github.com/matrix-org/matrix-js-sdk/pull/5191)). Contributed by @Half-Shot. - - -Changes in [41.0.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v41.0.0) (2026-02-24) -================================================================================================== -## 🚨 BREAKING CHANGES - -* Add support for Matrix Spec v1.13 ([#5160](https://github.com/matrix-org/matrix-js-sdk/pull/5160)). Contributed by @t3chguy. - -## ✨ Features - -* Download room keys from backup prior to buliding historic room key bundles ([#5171](https://github.com/matrix-org/matrix-js-sdk/pull/5171)). Contributed by @kaylendog. -* Add support for Matrix Spec v1.13 ([#5160](https://github.com/matrix-org/matrix-js-sdk/pull/5160)). Contributed by @t3chguy. -* Add logging on MSC4108 DELETE request ([#5140](https://github.com/matrix-org/matrix-js-sdk/pull/5140)). Contributed by @reivilibre. -* Add `m.invite_permission_config` account data type ([#5183](https://github.com/matrix-org/matrix-js-sdk/pull/5183)). Contributed by @richvdh. - -## 🐛 Bug Fixes - -* fix(relations): prevent stale m.replace from overriding newer edits ([#5192](https://github.com/matrix-org/matrix-js-sdk/pull/5192)). Contributed by @basnijholt. -* Fix reactive display name disambiguation ([#5135](https://github.com/matrix-org/matrix-js-sdk/pull/5135)). Contributed by @aditya-cherukuru. -* Fix empty string to room compatibility trick to only apply to m.call ([#5172](https://github.com/matrix-org/matrix-js-sdk/pull/5172)). Contributed by @toger5. - - -Changes in [40.2.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v40.2.0) (2026-02-10) -================================================================================================== -## 🦖 Deprecations - -* [MatrixRTC] Remove sending of deprecated `notify` event (we now use `m.rtc.notification`) ([#5167](https://github.com/matrix-org/matrix-js-sdk/pull/5167)). Contributed by @toger5. - -## ✨ Features - -* Use stable /auth\_metadata endpoint where homeserver supports v1.15 ([#5174](https://github.com/matrix-org/matrix-js-sdk/pull/5174)). Contributed by @hughns. -* Support additional\_creators in upgradeRoom (MSC4289) ([#5173](https://github.com/matrix-org/matrix-js-sdk/pull/5173)). Contributed by @andybalaam. -* [MatrixRTC] Minimal change to transition from "" to "ROOM" as the callId/slotId ([#5166](https://github.com/matrix-org/matrix-js-sdk/pull/5166)). Contributed by @toger5. -* [MatrixRTC] Do not send the `livekit_alias` in sticky events ([#5165](https://github.com/matrix-org/matrix-js-sdk/pull/5165)). Contributed by @toger5. -* Improve startup performance by using `promise.all` when processing rooms from sync ([#5095](https://github.com/matrix-org/matrix-js-sdk/pull/5095)). Contributed by @MidhunSureshR. -* Add OAuthGrantType enum for OAuth 2.0 API grant types ([#5161](https://github.com/matrix-org/matrix-js-sdk/pull/5161)). Contributed by @hughns. -* Add support for stable OAuth2.0 aware feature from MSC3824 ([#5159](https://github.com/matrix-org/matrix-js-sdk/pull/5159)). Contributed by @hughns. -* Give RoomWidgetClient the ability to send and receive sticky events ([#5142](https://github.com/matrix-org/matrix-js-sdk/pull/5142)). Contributed by @robintown. - -## 🐛 Bug Fixes - -* [js sdk embedded/widget] Fix race where this.syncApi.injectRoomEvents was called before the syncApi is instantiated ([#5168](https://github.com/matrix-org/matrix-js-sdk/pull/5168)). Contributed by @toger5. -* [MatrixRTC] Fix delayId not resetting on leave ([#5156](https://github.com/matrix-org/matrix-js-sdk/pull/5156)). Contributed by @toger5. - - -Changes in [40.1.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v40.1.0) (2026-01-27) -================================================================================================== -## 🦖 Deprecations - -* Deprecate unused `EventShieldReason` reason codes ([#5127](https://github.com/matrix-org/matrix-js-sdk/pull/5127)). Contributed by @richvdh. - -## ✨ Features - -* Add stable m.oauth UIA stage enum ([#5138](https://github.com/matrix-org/matrix-js-sdk/pull/5138)). Contributed by @hughns. -* Add `MatrixEvent.getKeyForwardingUser` ([#5128](https://github.com/matrix-org/matrix-js-sdk/pull/5128)). Contributed by @richvdh. -* Add types for (unstable) policy servers ([#5116](https://github.com/matrix-org/matrix-js-sdk/pull/5116)). Contributed by @turt2live. - -## 🐛 Bug Fixes - -* [Backport staging] Recalculate room name on loading members ([#5164](https://github.com/matrix-org/matrix-js-sdk/pull/5164)). Contributed by @RiotRobot. -* Avoid rapidly retrying failed requests ([#5146](https://github.com/matrix-org/matrix-js-sdk/pull/5146)). Contributed by @andybalaam. -* [matrixRTC] MatrixRTCSessions, add missing event reemission. ([#5144](https://github.com/matrix-org/matrix-js-sdk/pull/5144)). Contributed by @toger5. -* Use normal base64 encoding for RTC backend identities ([#5129](https://github.com/matrix-org/matrix-js-sdk/pull/5129)). Contributed by @robintown. -* export parseCallNotificationContent and isMyMembership from RTC types ([#5132](https://github.com/matrix-org/matrix-js-sdk/pull/5132)). Contributed by @Half-Shot. - - -Changes in [40.0.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v40.0.0) (2026-01-13) -================================================================================================== -## 🚨 BREAKING CHANGES - -* MatrixRTC Pseudonymous livekit identities ([#5110](https://github.com/matrix-org/matrix-js-sdk/pull/5110)). Contributed by @toger5. - -## 🦖 Deprecations - -* Mark `forwardingCurve25519KeyChain` as deprecated ([#5111](https://github.com/matrix-org/matrix-js-sdk/pull/5111)). Contributed by @richvdh. -* Mark `IEventDecryptionResult` as deprecated ([#5112](https://github.com/matrix-org/matrix-js-sdk/pull/5112)). Contributed by @richvdh. - -## ✨ Features - -* Implement MSC4387: M\_SAFETY error ([#5107](https://github.com/matrix-org/matrix-js-sdk/pull/5107)). Contributed by @Half-Shot. -* Implement \_unstable\_getRTCTransports for MSC4143 ([#5104](https://github.com/matrix-org/matrix-js-sdk/pull/5104)). Contributed by @Half-Shot. -* Use `membershipID` for session events ([#5105](https://github.com/matrix-org/matrix-js-sdk/pull/5105)). Contributed by @toger5. - -## 🐛 Bug Fixes - -* Make MatrixRTC encryption key types narrower for TS 5.9 compatibility ([#5117](https://github.com/matrix-org/matrix-js-sdk/pull/5117)). Contributed by @robintown. -* Re-check outgoing requests after processing them ([#5109](https://github.com/matrix-org/matrix-js-sdk/pull/5109)). Contributed by @andybalaam. -* Make token refresher init itself lazily ([#5106](https://github.com/matrix-org/matrix-js-sdk/pull/5106)). Contributed by @dbkr. - - -Changes in [39.4.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v39.4.0) (2025-12-16) -================================================================================================== -## ✨ Features - -* Import room key bundles received after invite. ([#5080](https://github.com/matrix-org/matrix-js-sdk/pull/5080)). Contributed by @kaylendog. - -## 🐛 Bug Fixes - -* Allow msc4354\_sticky\_key to be optional on sticky events. ([#5073](https://github.com/matrix-org/matrix-js-sdk/pull/5073)). Contributed by @Half-Shot. -* Handle all response fields from /context API being optional ([#5089](https://github.com/matrix-org/matrix-js-sdk/pull/5089)). Contributed by @t3chguy. - - -Changes in [39.3.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v39.3.0) (2025-12-02) -================================================================================================== -## 🐛 Bug Fixes - -* Re-add truthy check on room name/avatar/alias events ([#5081](https://github.com/matrix-org/matrix-js-sdk/pull/5081)). Contributed by @t3chguy. -* Fix invalid state events corrupting room objects ([#5078](https://github.com/matrix-org/matrix-js-sdk/pull/5078)). Contributed by @t3chguy. - - -Changes in [39.2.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v39.2.0) (2025-11-18) -================================================================================================== -## ✨ Features - -* Delayed event management: split endpoints, no auth ([#5066](https://github.com/matrix-org/matrix-js-sdk/pull/5066)). Contributed by @AndrewFerr. -* do not set cache in authenticated fetch ([#5020](https://github.com/matrix-org/matrix-js-sdk/pull/5020)). Contributed by @pkuzco. - -## 🐛 Bug Fixes - -* Fix media switching during legacy calls ([#5069](https://github.com/matrix-org/matrix-js-sdk/pull/5069)). Contributed by @langleyd. - - -Changes in [39.1.2](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v39.1.2) (2025-11-04) -================================================================================================== -Re-release of v39.1.0 to fix npm publishing workflow - - - -Changes in [39.1.1](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v39.1.1) (2025-11-04) -================================================================================================== -Re-release of v39.1.0 to fix npm publishing workflow - -Changes in [39.1.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v39.1.0) (2025-11-04) -================================================================================================== -## ✨ Features - -* [MatrixRTC] Sticky Events support (MSC4354) ([#5017](https://github.com/matrix-org/matrix-js-sdk/pull/5017)). Contributed by @toger5. -* Add `CryptoApi.getSecretStorageStatus` ([#5054](https://github.com/matrix-org/matrix-js-sdk/pull/5054)). Contributed by @richvdh. -* Add parseCallNotificationContent ([#5015](https://github.com/matrix-org/matrix-js-sdk/pull/5015)). Contributed by @toger5. -* MSC4140: support filters on delayed event lookup ([#5038](https://github.com/matrix-org/matrix-js-sdk/pull/5038)). Contributed by @AndrewFerr. - - -Changes in [39.0.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v39.0.0) (2025-10-21) -================================================================================================== -## 🚨 BREAKING CHANGES - -* [MatrixRTC] Multi SFU support + m.rtc.member event type support ([#5022](https://github.com/matrix-org/matrix-js-sdk/pull/5022)). Contributed by @toger5. - -## ✨ Features - -* [MatrixRTC] Multi SFU support + m.rtc.member event type support ([#5022](https://github.com/matrix-org/matrix-js-sdk/pull/5022)). Contributed by @toger5. -* Implement Sticky Events MSC4354 ([#5028](https://github.com/matrix-org/matrix-js-sdk/pull/5028)). Contributed by @Half-Shot. -* feat(client): allow disabling VoIP support ([#5021](https://github.com/matrix-org/matrix-js-sdk/pull/5021)). Contributed by @pkuzco. - -## 🐛 Bug Fixes - -* Only use the first 3 viaServers specified ([#5034](https://github.com/matrix-org/matrix-js-sdk/pull/5034)). Contributed by @t3chguy. -* Fetch the user's device info before processing a verification request ([#5030](https://github.com/matrix-org/matrix-js-sdk/pull/5030)). Contributed by @andybalaam. - - -Changes in [38.4.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v38.4.0) (2025-10-07) -================================================================================================== -## ✨ Features - -* Add call intent to RTC call notifications ([#5010](https://github.com/matrix-org/matrix-js-sdk/pull/5010)). Contributed by @Half-Shot. -* Implement experimental encrypted state events. ([#4994](https://github.com/matrix-org/matrix-js-sdk/pull/4994)). Contributed by @kaylendog. - -## 🐛 Bug Fixes - -* Exclude cancelled requests from in-progress lists ([#5016](https://github.com/matrix-org/matrix-js-sdk/pull/5016)). Contributed by @andybalaam. - - -Changes in [38.3.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v38.3.0) (2025-09-23) -================================================================================================== -## 🐛 Bug Fixes - -* Remove knocked room when membership changes to join ([#4977](https://github.com/matrix-org/matrix-js-sdk/pull/4977)). Contributed by @svajunas-budrys. - - -Changes in [38.2.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v38.2.0) (2025-09-16) -================================================================================================== -Fix [CVE-2025-59160](https://www.cve.org/CVERecord?id=CVE-2025-59160) / [GHSA-mp7c-m3rh-r56v](https://github.com/matrix-org/matrix-js-sdk/security/advisories/GHSA-mp7c-m3rh-r56v) - - - -Changes in [38.1.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v38.1.0) (2025-09-09) -================================================================================================== -## ✨ Features - -* Remove custom `org.matrix.msc4075.rtc.notification.parent` relation type ([#4979](https://github.com/matrix-org/matrix-js-sdk/pull/4979)). Contributed by @toger5. -* MatrixRTC: Add RTC decline event ([#4978](https://github.com/matrix-org/matrix-js-sdk/pull/4978)). Contributed by @toger5. -* Make a MatrixRTCSession emit once the RTCNotification is sent ([#4976](https://github.com/matrix-org/matrix-js-sdk/pull/4976)). Contributed by @toger5. -* Use hydra semantics for unknown room versions ([#4957](https://github.com/matrix-org/matrix-js-sdk/pull/4957)). Contributed by @dbkr. -* Expose the StatusChanged event through the RTCSession ([#4974](https://github.com/matrix-org/matrix-js-sdk/pull/4974)). Contributed by @toger5. -* Add `probablyLeft` event to the MatrixRTCSession ([#4962](https://github.com/matrix-org/matrix-js-sdk/pull/4962)). Contributed by @toger5. - -## 🐛 Bug Fixes - -* Fix `m.topic` format ([#4984](https://github.com/matrix-org/matrix-js-sdk/pull/4984)). Contributed by @tulir. -* Fix stable-suffixed MSC4133 support ([#4983](https://github.com/matrix-org/matrix-js-sdk/pull/4983)). Contributed by @dbkr. -* Fix thread edit aggregation race condition ([#4980](https://github.com/matrix-org/matrix-js-sdk/pull/4980)). Contributed by @basnijholt. - - -Changes in [38.0.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v38.0.0) (2025-08-27) -================================================================================================== -## 🚨 BREAKING CHANGES - -* Release tranche of breaking changes ([#4975](https://github.com/matrix-org/matrix-js-sdk/pull/4975)). -* Remove support for FetchHttpApi `onlyData = false` -* Remove deprecated `IJoinRoomOpts.syncRoom` -* Remove deprecated methods which are unsupported in rust crypto -* Remove deprecated getAuthIssuer method -* Remove deprecated beginKeyVerification method -* Remove deprecated isEncryptedDisabledForUnverifiedDevices getter -* Remove deprecated UndecryptableToDeviceEvent MatrixClient emit -* Remove deprecated defer utility method -* Remove deprecated UIAResponse dummy type -* Remove deprecated MatrixRTCSession MembershipConfig fields -* Remove deprecated findVerificationRequestDMInProgress and storeSessionBackupPrivateKey methods in favour of overloads - -## ✨ Features - -* Allow multiple rtc sessions per room (with different sessionDescriptions) ([#4945](https://github.com/matrix-org/matrix-js-sdk/pull/4945)). Contributed by @toger5. -* Add support for login\_hint in authorization url generation ([#4943](https://github.com/matrix-org/matrix-js-sdk/pull/4943)). Contributed by @odelcroi. -* Only process MatrixRTC sessions associated with calls for `callMembershipsForRoom` ([#4960](https://github.com/matrix-org/matrix-js-sdk/pull/4960)). Contributed by @fkwp. - - -Changes in [37.13.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v37.13.0) (2025-08-11) -==================================================================================================== -This release supports new v12 Matrix rooms and consequently has a breaking change, removing powerLevelNorm from the RoomMember object as this can't be supported with infinite power levels. Apps should use the non-normalised `powerLevel` instead. - -## 🚨 BREAKING CHANGES - -* [Backport staging] Support for creator power level ([#4954](https://github.com/matrix-org/matrix-js-sdk/pull/4954)). Contributed by @RiotRobot. - -## ✨ Features - -* [Backport staging] Support v12 rooms in maySendEvent ([#4956](https://github.com/matrix-org/matrix-js-sdk/pull/4956)). Contributed by @RiotRobot. -* [Backport staging] Support for creator power level ([#4954](https://github.com/matrix-org/matrix-js-sdk/pull/4954)). Contributed by @RiotRobot. -* Experimental support for sharing encrypted history on invite ([#4920](https://github.com/matrix-org/matrix-js-sdk/pull/4920)). Contributed by @richvdh. -* Use the logger associated with MatrixClient in rust sdk ([#4918](https://github.com/matrix-org/matrix-js-sdk/pull/4918)). Contributed by @richvdh. -* Update to matrix-sdk-crypto-wasm 15.1.0, and add new `ShieldStateCode.MismatchedSender` ([#4916](https://github.com/matrix-org/matrix-js-sdk/pull/4916)). Contributed by @richvdh. - -## 🐛 Bug Fixes - -* Fix unknown/broken state in the RTC Membership Manager causing unnecassary error logging. ([#4944](https://github.com/matrix-org/matrix-js-sdk/pull/4944)). Contributed by @toger5. - - -Changes in [37.12.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v37.12.0) (2025-07-29) -==================================================================================================== -## 🦖 Deprecations - -* Deprecate non-functional `IJoinRoomOpts.syncRoom` ([#4913](https://github.com/matrix-org/matrix-js-sdk/pull/4913)). Contributed by @richvdh. - -## ✨ Features - -* Custom abort timeout logic for restarting delayed events that is compatible with the widget api ([#4927](https://github.com/matrix-org/matrix-js-sdk/pull/4927)). Contributed by @toger5. -* Allow sending notification events when starting a call ([#4826](https://github.com/matrix-org/matrix-js-sdk/pull/4826)). Contributed by @robintown. - -## 🐛 Bug Fixes - -* Fix deep import incompatibility (#4924) ([#4925](https://github.com/matrix-org/matrix-js-sdk/pull/4925)). Contributed by @toriningen. -* Fix more incorrect logger use ([#4904](https://github.com/matrix-org/matrix-js-sdk/pull/4904)). Contributed by @richvdh. - - -Changes in [37.11.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v37.11.0) (2025-07-15) -==================================================================================================== -## ✨ Features - -* Update README to make Element sponsorship explicit ([#4901](https://github.com/matrix-org/matrix-js-sdk/pull/4901)). Contributed by @neilisfragile. -* Use client logger in more places (crypto code) ([#4900](https://github.com/matrix-org/matrix-js-sdk/pull/4900)). Contributed by @richvdh. -* Use client logger in `MatrixRTCSessionManager` ([#4898](https://github.com/matrix-org/matrix-js-sdk/pull/4898)). Contributed by @richvdh. -* Use client logger in more places (core code) ([#4899](https://github.com/matrix-org/matrix-js-sdk/pull/4899)). Contributed by @richvdh. -* crypto: Add new `ClientEvent.ReceivedToDeviceMessage` with proper `OlmEncryptionInfo` support ([#4891](https://github.com/matrix-org/matrix-js-sdk/pull/4891)). Contributed by @BillCarsonFr. - - -Changes in [37.10.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v37.10.0) (2025-07-01) -==================================================================================================== -## ✨ Features - -* Update matrix-sdk-crypto-wasm to `15.0.0` ([#4882](https://github.com/matrix-org/matrix-js-sdk/pull/4882)). Contributed by @richvdh. -* Allow customizing the IndexedDB database prefix used by Rust crypto. ([#4878](https://github.com/matrix-org/matrix-js-sdk/pull/4878)). Contributed by @clokep. -* Remove `@matrix-org/olm` from dependency list ([#4876](https://github.com/matrix-org/matrix-js-sdk/pull/4876)). Contributed by @richvdh. -* Redact on ban: Client implementation ([#4867](https://github.com/matrix-org/matrix-js-sdk/pull/4867)). Contributed by @turt2live. - - -Changes in [37.9.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v37.9.0) (2025-06-17) -================================================================================================== -## 🐛 Bug Fixes - -* Ensure we send spec-compliant filter strings by stripping out null values ([#4865](https://github.com/matrix-org/matrix-js-sdk/pull/4865)). Contributed by @t3chguy. -* Fix MatrixRTC membership manager failing to rejoin in a race condition (sync vs not found response) ([#4861](https://github.com/matrix-org/matrix-js-sdk/pull/4861)). Contributed by @toger5. -* Include extraParams in all HTTP requests ([#4860](https://github.com/matrix-org/matrix-js-sdk/pull/4860)). Contributed by @rsb-tbg. - - -Changes in [37.8.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v37.8.0) (2025-06-10) -================================================================================================== -## 🐛 Bug Fixes - -* [Backport staging] Update dependency @matrix-org/matrix-sdk-crypto-wasm to v14.2.1 ([#4869](https://github.com/matrix-org/matrix-js-sdk/pull/4869)). Contributed by @RiotRobot. - - -Changes in [37.7.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v37.7.0) (2025-06-03) -================================================================================================== -## 🦖 Deprecations - -* MatrixRTC: Rename `MembershipConfig` parameters ([#4714](https://github.com/matrix-org/matrix-js-sdk/pull/4714)). Contributed by @toger5. - -## ✨ Features - -* Allow the embedded client to work without update\_state support ([#4849](https://github.com/matrix-org/matrix-js-sdk/pull/4849)). Contributed by @robintown. -* Check for `unknown variant` on to-device sending and fall back to room event encryption. ([#4847](https://github.com/matrix-org/matrix-js-sdk/pull/4847)). Contributed by @toger5. -* Reapply "Distinguish room state and timeline events in embedded clients" ([#4790](https://github.com/matrix-org/matrix-js-sdk/pull/4790)). Contributed by @robintown. - - -Changes in [37.6.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v37.6.0) (2025-05-20) -================================================================================================== -## 🦖 Deprecations - -* Deprecate utils function `defer` in favour of `Promise.withResolvers` ([#4829](https://github.com/matrix-org/matrix-js-sdk/pull/4829)). Contributed by @t3chguy. - -## ✨ Features - -* Update to Node 22 LTS ([#4832](https://github.com/matrix-org/matrix-js-sdk/pull/4832)). Contributed by @t3chguy. - -## 🐛 Bug Fixes - -* Fix autodiscovery handling of 2xx (non-200) codes ([#4833](https://github.com/matrix-org/matrix-js-sdk/pull/4833)). Contributed by @t3chguy. - - -Changes in [37.5.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v37.5.0) (2025-05-06) -================================================================================================== -## ✨ Features - -* Stabilise MSC3765 ([#4767](https://github.com/matrix-org/matrix-js-sdk/pull/4767)). Contributed by @Johennes. -* Inherit `methodFactory` extensions from the parent to the child loggers. ([#4809](https://github.com/matrix-org/matrix-js-sdk/pull/4809)). Contributed by @toger5. - -## 🐛 Bug Fixes - -* [Backport staging] Fix token refresh behaviour for non-expired tokens ([#4827](https://github.com/matrix-org/matrix-js-sdk/pull/4827)). Contributed by @RiotRobot. -* Refactor how token refreshing works to be more resilient ([#4819](https://github.com/matrix-org/matrix-js-sdk/pull/4819)). Contributed by @t3chguy. - - -Changes in [37.4.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v37.4.0) (2025-04-22) -================================================================================================== -## ✨ Features - -* MatrixRTC: Add combined `toDeviceAndRoomKeyTransport` ([#4792](https://github.com/matrix-org/matrix-js-sdk/pull/4792)). Contributed by @toger5. -* Make logging consistent for matrixRTC ([#4788](https://github.com/matrix-org/matrix-js-sdk/pull/4788)). Contributed by @toger5. -* MatrixRTC: ToDevice distribution for media stream keys ([#4785](https://github.com/matrix-org/matrix-js-sdk/pull/4785)). Contributed by @BillCarsonFr. - -## 🐛 Bug Fixes - -* Fix token refresh racing with other requests and not using new token ([#4798](https://github.com/matrix-org/matrix-js-sdk/pull/4798)). Contributed by @t3chguy. -* Fix fallback to MemoryCryptoStore when LocalStorage unavailable ([#4797](https://github.com/matrix-org/matrix-js-sdk/pull/4797)). Contributed by @t3chguy. -* Remove duplicate `deleteSecretStorage` in `RustCrypto.resetEncryption` ([#4789](https://github.com/matrix-org/matrix-js-sdk/pull/4789)). Contributed by @florianduros. -* Fix `RustCrypto.resetEncryption` failure ([#4772](https://github.com/matrix-org/matrix-js-sdk/pull/4772)). Contributed by @florianduros. - - -Changes in [37.3.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v37.3.0) (2025-04-08) -================================================================================================== -## ✨ Features - -* MatrixRTC MembershipManger: remove redundant sendDelayedEventAction and expose status ([#4747](https://github.com/matrix-org/matrix-js-sdk/pull/4747)). Contributed by @toger5. -* Abstract logout-causing error type from tokenRefreshFunction calls ([#4765](https://github.com/matrix-org/matrix-js-sdk/pull/4765)). Contributed by @t3chguy. -* Improve PushProcessor::getPushRuleGlobRegex ([#4764](https://github.com/matrix-org/matrix-js-sdk/pull/4764)). Contributed by @t3chguy. -* Export push processor \& method for converting matrix glob to regexp ([#4763](https://github.com/matrix-org/matrix-js-sdk/pull/4763)). Contributed by @t3chguy. -* Add authenticated media parameter to getMediaConfig ([#4762](https://github.com/matrix-org/matrix-js-sdk/pull/4762)). Contributed by @m004. -* Rust crypto: set a timeout on outgoing HTTP requests ([#4761](https://github.com/matrix-org/matrix-js-sdk/pull/4761)). Contributed by @richvdh. -* Switch sliding sync support to simplified sliding sync ([#4400](https://github.com/matrix-org/matrix-js-sdk/pull/4400)). Contributed by @dbkr. - - -Changes in [37.2.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v37.2.0) (2025-03-25) -================================================================================================== -## ✨ Features - -* Add reportRoom API ([#4753](https://github.com/matrix-org/matrix-js-sdk/pull/4753)). Contributed by @Half-Shot. -* MatrixRTC: New membership manager ([#4726](https://github.com/matrix-org/matrix-js-sdk/pull/4726)). Contributed by @toger5. -* Add disableKeyStorage() to crypto API ([#4742](https://github.com/matrix-org/matrix-js-sdk/pull/4742)). Contributed by @dbkr. - -## 🐛 Bug Fixes - -* Allow port differing in OIDC dynamic registration URIs ([#4749](https://github.com/matrix-org/matrix-js-sdk/pull/4749)). Contributed by @t3chguy. -* OIDC: only pass logo\_uri, policy\_uri, tos\_uri if they conform to "common base" ([#4748](https://github.com/matrix-org/matrix-js-sdk/pull/4748)). Contributed by @t3chguy. - - -Changes in [37.1.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v37.1.0) (2025-03-11) -================================================================================================== -## 🦖 Deprecations - -* MatrixRTC: MembershipManager test cases and deprecation of MatrixRTCSession.room ([#4713](https://github.com/matrix-org/matrix-js-sdk/pull/4713)). Contributed by @toger5. - -## ✨ Features - -* Add `EventType.SecretRequest` and `EventType.SecretSend` ([#4728](https://github.com/matrix-org/matrix-js-sdk/pull/4728)). Contributed by @richvdh. -* Attest npm package provenance ([#4724](https://github.com/matrix-org/matrix-js-sdk/pull/4724)). Contributed by @t3chguy. -* Report backup key import progress on start and improve types ([#4711](https://github.com/matrix-org/matrix-js-sdk/pull/4711)). Contributed by @ajbura. - -## 🐛 Bug Fixes - -* Handle unexpected token refresh failures gracefully ([#4731](https://github.com/matrix-org/matrix-js-sdk/pull/4731)). Contributed by @t3chguy. -* Fix idempotency issue around token refresh ([#4730](https://github.com/matrix-org/matrix-js-sdk/pull/4730)). Contributed by @t3chguy. -* Delete the dehydrated device when resetEncryption is called ([#4727](https://github.com/matrix-org/matrix-js-sdk/pull/4727)). Contributed by @uhoreg. - - -Changes in [37.0.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v37.0.0) (2025-02-25) -================================================================================================== -## 🚨 BREAKING CHANGES - -* Remove deprecated `PrefixedLogger` interface ([#4705](https://github.com/matrix-org/matrix-js-sdk/pull/4705)). Contributed by @richvdh. -* Remove legacy crypto ([#4653](https://github.com/matrix-org/matrix-js-sdk/pull/4653)). Contributed by @florianduros. - -## 🦖 Deprecations - -* Improve types around User Interactive Auth ([#4709](https://github.com/matrix-org/matrix-js-sdk/pull/4709)). Contributed by @t3chguy. - -## ✨ Features - -* Fix typos in client.ts ([#4715](https://github.com/matrix-org/matrix-js-sdk/pull/4715)). Contributed by @toger5. -* Enable key upload to backups where we have the decryption key ([#4677](https://github.com/matrix-org/matrix-js-sdk/pull/4677)). Contributed by @ajbura. -* Remove deprecated `PrefixedLogger` interface ([#4705](https://github.com/matrix-org/matrix-js-sdk/pull/4705)). Contributed by @richvdh. -* `MatrixClient.setAccountData`: await remote echo. ([#4695](https://github.com/matrix-org/matrix-js-sdk/pull/4695)). Contributed by @richvdh. - -## 🐛 Bug Fixes - -* Improve types around User Interactive Auth ([#4709](https://github.com/matrix-org/matrix-js-sdk/pull/4709)). Contributed by @t3chguy. -* Fix `resetEncryption` to remove secrets in 4S ([#4683](https://github.com/matrix-org/matrix-js-sdk/pull/4683)). Contributed by @florianduros. - - -Changes in [36.2.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v36.2.0) (2025-02-11) -================================================================================================== -## 🦖 Deprecations - -* [Backport staging] Deprecate parameter and functions using legacy crypto in `models/event.ts` ([#4700](https://github.com/matrix-org/matrix-js-sdk/pull/4700)). Contributed by @RiotRobot. - -## ✨ Features - -* Improve types around Terms ([#4674](https://github.com/matrix-org/matrix-js-sdk/pull/4674)). Contributed by @t3chguy. -* Provide more options for starting dehydration ([#4664](https://github.com/matrix-org/matrix-js-sdk/pull/4664)). Contributed by @uhoreg. -* Device Dehydration | js-sdk: store/load dehydration key ([#4599](https://github.com/matrix-org/matrix-js-sdk/pull/4599)). Contributed by @BillCarsonFr. -* Add unspecced backup disable flag ([#4661](https://github.com/matrix-org/matrix-js-sdk/pull/4661)). Contributed by @dbkr. -* Switch OIDC primarily to new `/auth_metadata` API ([#4626](https://github.com/matrix-org/matrix-js-sdk/pull/4626)). Contributed by @t3chguy. -* Add `CryptoApi.resetEncryption` ([#4614](https://github.com/matrix-org/matrix-js-sdk/pull/4614)). Contributed by @florianduros. - -## 🐛 Bug Fixes - -* Fix topic types ([#4678](https://github.com/matrix-org/matrix-js-sdk/pull/4678)). Contributed by @Half-Shot. -* Handle empty m.room.topic ([#4673](https://github.com/matrix-org/matrix-js-sdk/pull/4673)). Contributed by @Half-Shot. -* `CryptoApi.resetEncryption` should always create a new key backup ([#4648](https://github.com/matrix-org/matrix-js-sdk/pull/4648)). Contributed by @florianduros. - - -Changes in [36.1.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v36.1.0) (2025-01-28) -================================================================================================== -## ✨ Features - -* Deprecate `MatrixClient.login` and replace with `loginRequest` ([#4632](https://github.com/matrix-org/matrix-js-sdk/pull/4632)). Contributed by @richvdh. -* Use `SyncCryptoCallback` api instead of legacy crypto in sliding sync ([#4624](https://github.com/matrix-org/matrix-js-sdk/pull/4624)). Contributed by @florianduros. -* Distinguish room state and timeline events in embedded clients ([#4574](https://github.com/matrix-org/matrix-js-sdk/pull/4574)). Contributed by @robintown. -* Allow setting default secret storage key id to null ([#4615](https://github.com/matrix-org/matrix-js-sdk/pull/4615)). Contributed by @florianduros. -* Add authenticated media to getAvatarUrl in room and room-member models ([#4616](https://github.com/matrix-org/matrix-js-sdk/pull/4616)). Contributed by @m004. -* Send MSC3981 'recurse' param on `/relations` endpoint on Matrix 1.10 servers ([#4023](https://github.com/matrix-org/matrix-js-sdk/pull/4023)). Contributed by @dbkr. - -## 🐛 Bug Fixes - -* [Backport staging] Revert "Distinguish room state and timeline events in embedded clients (#4574)" ([#4657](https://github.com/matrix-org/matrix-js-sdk/pull/4657)). Contributed by @RiotRobot. -* Change randomString et al to be secure ([#4621](https://github.com/matrix-org/matrix-js-sdk/pull/4621)). Contributed by @dbkr. -* Fix issue with sentinels being incorrect on m.room.member events ([#4609](https://github.com/matrix-org/matrix-js-sdk/pull/4609)). Contributed by @t3chguy. - - -Changes in [36.0.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v36.0.0) (2025-01-14) -================================================================================================== -## 🚨 BREAKING CHANGES - -* Remove support for "legacy" MSC3898 group calling in MatrixRTCSession and CallMembership ([#4583](https://github.com/matrix-org/matrix-js-sdk/pull/4583)). Contributed by @toger5. - -## ✨ Features - -* MatrixRTC: Implement expiry logic for CallMembership and additional test coverage ([#4587](https://github.com/matrix-org/matrix-js-sdk/pull/4587)). Contributed by @toger5. - -## 🐛 Bug Fixes - -* Don't retry on 4xx responses ([#4601](https://github.com/matrix-org/matrix-js-sdk/pull/4601)). Contributed by @dbkr. -* Upgrade matrix-sdk-crypto-wasm to 12.1.0 ([#4596](https://github.com/matrix-org/matrix-js-sdk/pull/4596)). Contributed by @andybalaam. -* Avoid key prompts when resetting crypto ([#4586](https://github.com/matrix-org/matrix-js-sdk/pull/4586)). Contributed by @dbkr. -* Handle when aud OIDC claim is an Array ([#4584](https://github.com/matrix-org/matrix-js-sdk/pull/4584)). Contributed by @liamdiprose. -* Save the key backup key to 4S during `bootstrapSecretStorage ` ([#4542](https://github.com/matrix-org/matrix-js-sdk/pull/4542)). Contributed by @dbkr. -* Only re-prepare MatrixrRTC delayed disconnection event on 404 ([#4575](https://github.com/matrix-org/matrix-js-sdk/pull/4575)). Contributed by @toger5. - - -Changes in [35.1.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v35.1.0) (2024-12-18) -================================================================================================== -This release updates matrix-sdk-crypto-wasm to fix a bug which could prevent loading stored crypto state from storage. - -## 🐛 Bug Fixes - -* Upgrade matrix-sdk-crypto-wasm to 1.11.0 ([#4593](https://github.com/matrix-org/matrix-js-sdk/pull/4593)). - - -Changes in [35.0.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v35.0.0) (2024-12-17) -================================================================================================== -## 🚨 BREAKING CHANGES - -This release contains several breaking changes which will need code changes in your app. Most notably, `initCrypto()` -no longer exists and has been moved to `initLegacyCrypto()` in preparation for the eventual removal of Olm. You can -continue to use legacy Olm crypto for now by calling `initLegacyCrypto()` instead. - -You may also need to make further changes if you use more advanced APIs. See the individual PRs (listed in order of size of change) for specific APIs changed and how to migrate. - -* Rename `MatrixClient.initCrypto` into `MatrixClient.initLegacyCrypto` ([#4567](https://github.com/matrix-org/matrix-js-sdk/pull/4567)). Contributed by @florianduros. -* Support MSC4222 `state_after` ([#4487](https://github.com/matrix-org/matrix-js-sdk/pull/4487)). Contributed by @dbkr. -* Avoid use of Buffer as it does not exist in the Web natively ([#4569](https://github.com/matrix-org/matrix-js-sdk/pull/4569)). Contributed by @t3chguy. - -## 🦖 Deprecations - -* Deprecate remaining legacy functions and move `CryptoEvent.LegacyCryptoStoreMigrationProgress` handler ([#4560](https://github.com/matrix-org/matrix-js-sdk/pull/4560)). Contributed by @florianduros. - -## ✨ Features - -* Rename `MatrixClient.initCrypto` into `MatrixClient.initLegacyCrypto` ([#4567](https://github.com/matrix-org/matrix-js-sdk/pull/4567)). Contributed by @florianduros. -* Avoid use of Buffer as it does not exist in the Web natively ([#4569](https://github.com/matrix-org/matrix-js-sdk/pull/4569)). Contributed by @t3chguy. -* Re-send MatrixRTC media encryption keys for a new joiner even if a rotation is in progress ([#4561](https://github.com/matrix-org/matrix-js-sdk/pull/4561)). Contributed by @hughns. -* Support MSC4222 `state_after` ([#4487](https://github.com/matrix-org/matrix-js-sdk/pull/4487)). Contributed by @dbkr. -* Revert "Fix room state being updated with old (now overwritten) state and emitting for those updates. (#4242)" ([#4532](https://github.com/matrix-org/matrix-js-sdk/pull/4532)). Contributed by @toger5. - -## 🐛 Bug Fixes - -* Fix age field check in event echo processing ([#3635](https://github.com/matrix-org/matrix-js-sdk/pull/3635)). Contributed by @stas-demydiuk. - - -Changes in [34.13.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v34.13.0) (2024-12-03) -==================================================================================================== -## 🦖 Deprecations - -* Deprecate `MatrixClient.isEventSenderVerified` ([#4527](https://github.com/matrix-org/matrix-js-sdk/pull/4527)). Contributed by @florianduros. -* Add `restoreKeybackup` to `CryptoApi`. ([#4476](https://github.com/matrix-org/matrix-js-sdk/pull/4476)). Contributed by @florianduros. - -## ✨ Features - -* Ensure we disambiguate display names which look like MXIDs ([#4540](https://github.com/matrix-org/matrix-js-sdk/pull/4540)). Contributed by @t3chguy. -* Add `CryptoApi.getBackupInfo` ([#4512](https://github.com/matrix-org/matrix-js-sdk/pull/4512)). Contributed by @florianduros. -* Fix local echo in embedded mode ([#4498](https://github.com/matrix-org/matrix-js-sdk/pull/4498)). Contributed by @toger5. -* Add `restoreKeybackup` to `CryptoApi`. ([#4476](https://github.com/matrix-org/matrix-js-sdk/pull/4476)). Contributed by @florianduros. - -## 🐛 Bug Fixes - -* Fix `RustBackupManager` remaining values after current backup removal ([#4537](https://github.com/matrix-org/matrix-js-sdk/pull/4537)). Contributed by @florianduros. - - -Changes in [34.12.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v34.12.0) (2024-11-19) -==================================================================================================== -## 🦖 Deprecations - -* Deprecate `MatrixClient.getKeyBackupVersion` ([#4505](https://github.com/matrix-org/matrix-js-sdk/pull/4505)). Contributed by @florianduros. -* Deprecate unused callbacks in `CryptoCallbacks` ([#4501](https://github.com/matrix-org/matrix-js-sdk/pull/4501)). Contributed by @florianduros. - -## ✨ Features - -* Handle M\_MAX\_DELAY\_EXCEEDED errors ([#4511](https://github.com/matrix-org/matrix-js-sdk/pull/4511)). Contributed by @AndrewFerr. -* Allow configuration of MatrixRTC timers when calling joinRoomSession() ([#4510](https://github.com/matrix-org/matrix-js-sdk/pull/4510)). Contributed by @hughns. -* When state says you've left ongoing call, rejoin ([#4342](https://github.com/matrix-org/matrix-js-sdk/pull/4342)). Contributed by @AndrewFerr. -* Remove redundant type arguments in function call ([#4507](https://github.com/matrix-org/matrix-js-sdk/pull/4507)). Contributed by @AndrewFerr. -* MatrixRTCSession: handle rate limit errors ([#4494](https://github.com/matrix-org/matrix-js-sdk/pull/4494)). Contributed by @AndrewFerr. -* Send/receive error details with widgets ([#4492](https://github.com/matrix-org/matrix-js-sdk/pull/4492)). Contributed by @AndrewFerr. -* Capture HTTP error response headers \& handle Retry-After header (MSC4041) ([#4471](https://github.com/matrix-org/matrix-js-sdk/pull/4471)). Contributed by @AndrewFerr. -* Add RoomWidgetClient.sendToDeviceViaWidgetApi() ([#4475](https://github.com/matrix-org/matrix-js-sdk/pull/4475)). Contributed by @hughns. - - -Changes in [34.11.1](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v34.11.1) (2024-11-12) -==================================================================================================== -# Security -- Fixes for [CVE-2024-50336](https://nvd.nist.gov/vuln/detail/CVE-2024-50336) / [GHSA-xvg8-m4x3-w6xr](https://github.com/matrix-org/matrix-js-sdk/security/advisories/GHSA-xvg8-m4x3-w6xr). - -Changes in [34.11.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v34.11.0) (2024-11-12) -==================================================================================================== -# Security -- Fixes for [CVE-2024-50336](https://nvd.nist.gov/vuln/detail/CVE-2024-50336) / [GHSA-xvg8-m4x3-w6xr](https://github.com/matrix-org/matrix-js-sdk/security/advisories/GHSA-xvg8-m4x3-w6xr). - -Changes in [34.10.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v34.10.0) (2024-11-05) -==================================================================================================== -## 🦖 Deprecations - -* Deprecate `CreateSecretStorageOpts.keyBackupInfo` used in `CryptoApi.bootstrapSecretStorage.` ([#4474](https://github.com/matrix-org/matrix-js-sdk/pull/4474)). Contributed by @florianduros. -* Add CryptoApi.encryptToDeviceMessages() and deprecate Crypto.encryptAndSendToDevices() ([#4380](https://github.com/matrix-org/matrix-js-sdk/pull/4380)). Contributed by @hughns. -* Remove abandoned MSC3886, MSC3903, MSC3906 experimental implementations ([#4469](https://github.com/matrix-org/matrix-js-sdk/pull/4469)). Contributed by @t3chguy. -* Deprecate `MatrixClient.getDehydratedDevice` ([#4467](https://github.com/matrix-org/matrix-js-sdk/pull/4467)). Contributed by @florianduros. -* Deprecate top level crypto events re-export ([#4444](https://github.com/matrix-org/matrix-js-sdk/pull/4444)). Contributed by @florianduros. - -## ✨ Features - -* Add CryptoApi.encryptToDeviceMessages() and deprecate Crypto.encryptAndSendToDevices() ([#4380](https://github.com/matrix-org/matrix-js-sdk/pull/4380)). Contributed by @hughns. -* Do not rotate MatrixRTC media encryption key when a new member joins a session ([#4472](https://github.com/matrix-org/matrix-js-sdk/pull/4472)). Contributed by @hughns. -* Avoid `|` notation in log messages ([#4473](https://github.com/matrix-org/matrix-js-sdk/pull/4473)). Contributed by @richvdh. -* Refactor/simplify Promises in MatrixRTCSession ([#4466](https://github.com/matrix-org/matrix-js-sdk/pull/4466)). Contributed by @AndrewFerr. -* Prepare delayed call leave events more reliably ([#4447](https://github.com/matrix-org/matrix-js-sdk/pull/4447)). Contributed by @AndrewFerr. - -## 🐛 Bug Fixes - -* Fix DelayedEventInfo type ([#4446](https://github.com/matrix-org/matrix-js-sdk/pull/4446)). Contributed by @AndrewFerr. - - -Changes in [34.9.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v34.9.0) (2024-10-22) -================================================================================================== -## 🦖 Deprecations - -* Deprecate the crypto events which are not used by the rust-crypto ([#4442](https://github.com/matrix-org/matrix-js-sdk/pull/4442)). Contributed by @florianduros. - -## 🐛 Bug Fixes - -* Fix the rust crypto import in esm environments. ([#4445](https://github.com/matrix-org/matrix-js-sdk/pull/4445)). Contributed by @saul-jb. -* Fix MatrixRTC sender key wrapping ([#4441](https://github.com/matrix-org/matrix-js-sdk/pull/4441)). Contributed by @hughns. - - -Changes in [34.8.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v34.8.0) (2024-10-15) -================================================================================================== -This release removes insecure functionality, resolving CVE-2024-47080 / GHSA-4jf8-g8wp-cx7c. - -Changes in [34.7.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v34.7.0) (2024-10-08) -================================================================================================== -## 🦖 Deprecations - -* RTCSession cleanup: deprecate getKeysForParticipant() and getEncryption(); add emitEncryptionKeys() ([#4427](https://github.com/matrix-org/matrix-js-sdk/pull/4427)). Contributed by @hughns. - -## ✨ Features - -* Bump matrix-rust-sdk to 9.1.0 ([#4435](https://github.com/matrix-org/matrix-js-sdk/pull/4435)). Contributed by @richvdh. -* Rotate Matrix RTC media encryption key when a new member joins a call for Post Compromise Security ([#4422](https://github.com/matrix-org/matrix-js-sdk/pull/4422)). Contributed by @hughns. -* Update media event content types to include captions ([#4403](https://github.com/matrix-org/matrix-js-sdk/pull/4403)). Contributed by @tulir. -* Update OIDC registration types to match latest MSC2966 state ([#4432](https://github.com/matrix-org/matrix-js-sdk/pull/4432)). Contributed by @t3chguy. -* Add `CryptoApi.pinCurrentUserIdentity` and `UserIdentity.needsUserApproval` ([#4415](https://github.com/matrix-org/matrix-js-sdk/pull/4415)). Contributed by @richvdh. - - -Changes in [34.6.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v34.6.0) (2024-09-24) -================================================================================================== -## 🦖 Deprecations - -* Element-R: Mark unsupported MatrixClient methods as deprecated ([#4389](https://github.com/matrix-org/matrix-js-sdk/pull/4389)). Contributed by @richvdh. - -## ✨ Features - -* Add crypto mode setting for invisible crypto, and apply it to decrypting events ([#4407](https://github.com/matrix-org/matrix-js-sdk/pull/4407)). Contributed by @uhoreg. -* Don't share full key history for RTC per-participant encryption ([#4406](https://github.com/matrix-org/matrix-js-sdk/pull/4406)). Contributed by @hughns. -* Export membership types ([#4405](https://github.com/matrix-org/matrix-js-sdk/pull/4405)). Contributed by @Johennes. -* Fix sending redacts in embedded (widget) mode ([#4398](https://github.com/matrix-org/matrix-js-sdk/pull/4398)). Contributed by @toger5. -* Expose the event ID of a call membership ([#4395](https://github.com/matrix-org/matrix-js-sdk/pull/4395)). Contributed by @robintown. -* MSC4133 - Extended profiles ([#4391](https://github.com/matrix-org/matrix-js-sdk/pull/4391)). Contributed by @Half-Shot. - - -Changes in [34.5.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v34.5.0) (2024-09-10) -================================================================================================== -## 🦖 Deprecations - -* Deprecate unused callback hooks `CryptoCallbacks.onSecretRequested` and `CryptoCallbacks.getDehydrationKey` ([#4376](https://github.com/matrix-org/matrix-js-sdk/pull/4376)). Contributed by @richvdh. - - -Changes in [34.4.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v34.4.0) (2024-08-27) -================================================================================================== -## ✨ Features - -* Use non-legacy calls if any are found ([#4337](https://github.com/matrix-org/matrix-js-sdk/pull/4337)). Contributed by @AndrewFerr. - -## 🐛 Bug Fixes - -* Retry event decryption failures on first failure ([#4346](https://github.com/matrix-org/matrix-js-sdk/pull/4346)). Contributed by @hughns. -* Ensure "type" = "module" ES declaration in pre-release.sh ([#4350](https://github.com/matrix-org/matrix-js-sdk/pull/4350)). Contributed by @BLCK-B. -* Handle MatrixRTC encryption keys arriving out of order ([#4345](https://github.com/matrix-org/matrix-js-sdk/pull/4345)). Contributed by @hughns. -* Resend MatrixRTC encryption keys if a membership has changed ([#4343](https://github.com/matrix-org/matrix-js-sdk/pull/4343)). Contributed by @hughns. - - -Changes in [34.3.1](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v34.3.1) (2024-08-20) -================================================================================================== -# Security -- Fixes for [CVE-2024-42369](https://nvd.nist.gov/vuln/detail/CVE-2024-42369) / [GHSA-vhr5-g3pm-49fm](https://github.com/matrix-org/matrix-js-sdk/security/advisories/GHSA-vhr5-g3pm-49fm). - -Changes in [34.3.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v34.3.0) (2024-08-13) -================================================================================================== -## ✨ Features - -* Bump matrix-widget-api ([#4336](https://github.com/matrix-org/matrix-js-sdk/pull/4336)). Contributed by @AndrewFerr. -* Also check for MSC3757 for session state keys ([#4334](https://github.com/matrix-org/matrix-js-sdk/pull/4334)). Contributed by @AndrewFerr. -* Support Futures via widgets ([#4311](https://github.com/matrix-org/matrix-js-sdk/pull/4311)). Contributed by @AndrewFerr. -* Support MSC4140: Delayed events (Futures) ([#4294](https://github.com/matrix-org/matrix-js-sdk/pull/4294)). Contributed by @AndrewFerr. -* Handle late-arriving `m.room_key.withheld` messages ([#4310](https://github.com/matrix-org/matrix-js-sdk/pull/4310)). Contributed by @richvdh. -* Be specific about what is considered a MSC4143 call member event. ([#4328](https://github.com/matrix-org/matrix-js-sdk/pull/4328)). Contributed by @toger5. -* Add index.ts for matrixrtc module ([#4314](https://github.com/matrix-org/matrix-js-sdk/pull/4314)). Contributed by @toger5. - -## 🐛 Bug Fixes - -* Fix hashed ID server lookups with no Olm ([#4333](https://github.com/matrix-org/matrix-js-sdk/pull/4333)). Contributed by @dbkr. - - -Changes in [34.2.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v34.2.0) (2024-07-30) -================================================================================================== -## 🐛 Bug Fixes - -* Element-R: detect "withheld key" UTD errors, and mark them as such ([#4302](https://github.com/matrix-org/matrix-js-sdk/pull/4302)). Contributed by @richvdh. - - -Changes in [34.1.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v34.1.0) (2024-07-16) -================================================================================================== -## ✨ Features - -* Add ability to choose how many timeline events to sync when peeking ([#4300](https://github.com/matrix-org/matrix-js-sdk/pull/4300)). Contributed by @jgarplind. -* Remove redundant hack for using the old pickle key in rust crypto ([#4282](https://github.com/matrix-org/matrix-js-sdk/pull/4282)). Contributed by @richvdh. -* Add fetching the well known in embedded mode. ([#4259](https://github.com/matrix-org/matrix-js-sdk/pull/4259)). Contributed by @toger5. - -## 🐛 Bug Fixes - -* Fix room state being updated with old (now overwritten) state and emitting for those updates. ([#4242](https://github.com/matrix-org/matrix-js-sdk/pull/4242)). Contributed by @toger5. -* Fix incorrect "Olm is not available" errors ([#4301](https://github.com/matrix-org/matrix-js-sdk/pull/4301)). Contributed by @richvdh. -* Fix build for example script ([#4286](https://github.com/matrix-org/matrix-js-sdk/pull/4286)). Contributed by @richvdh. -* Declare matrix-js-sdk as an ES module ([#4285](https://github.com/matrix-org/matrix-js-sdk/pull/4285)). Contributed by @richvdh. - - -Changes in [34.0.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v34.0.0) (2024-07-08) -================================================================================================== -## 🚨 BREAKING CHANGES - -* Fetch capabilities in the background ([#4246](https://github.com/matrix-org/matrix-js-sdk/pull/4246)). Contributed by @dbkr. - -## ✨ Features - -* Prefix the user+device state key if needed ([#4262](https://github.com/matrix-org/matrix-js-sdk/pull/4262)). Contributed by @AndrewFerr. -* Use legacy call membership if anyone else is ([#4260](https://github.com/matrix-org/matrix-js-sdk/pull/4260)). Contributed by @AndrewFerr. -* Fetch capabilities in the background ([#4246](https://github.com/matrix-org/matrix-js-sdk/pull/4246)). Contributed by @dbkr. -* Use server name instead of homeserver url to allow well-known lookups during QR OIDC reciprocation ([#4233](https://github.com/matrix-org/matrix-js-sdk/pull/4233)). Contributed by @t3chguy. -* Add via parameter for MSC4156 ([#4247](https://github.com/matrix-org/matrix-js-sdk/pull/4247)). Contributed by @Johennes. -* Make the js-sdk compatible with MSC preferred foci and active focus. ([#4195](https://github.com/matrix-org/matrix-js-sdk/pull/4195)). Contributed by @toger5. -* Replace usages of setImmediate with setTimeout for wider compatibility ([#4240](https://github.com/matrix-org/matrix-js-sdk/pull/4240)). Contributed by @t3chguy. - -## 🐛 Bug Fixes - -* [Backport staging] Fix "Unable to restore session" error ([#4299](https://github.com/matrix-org/matrix-js-sdk/pull/4299)). Contributed by @RiotRobot. -* [Backport staging] Fix error when sending encrypted messages in large rooms ([#4297](https://github.com/matrix-org/matrix-js-sdk/pull/4297)). Contributed by @RiotRobot. -* Element-R: Fix resource leaks in verification logic ([#4263](https://github.com/matrix-org/matrix-js-sdk/pull/4263)). Contributed by @richvdh. -* Upgrade Rust Crypto SDK to 6.1.0 ([#4261](https://github.com/matrix-org/matrix-js-sdk/pull/4261)). Contributed by @richvdh. -* Correctly transform base64 with multiple instances of + or / ([#4252](https://github.com/matrix-org/matrix-js-sdk/pull/4252)). Contributed by @robintown. -* Work around spec bug for m.room.avatar state event content type ([#4245](https://github.com/matrix-org/matrix-js-sdk/pull/4245)). Contributed by @t3chguy. - - -Changes in [33.1.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v33.1.0) (2024-06-18) -================================================================================================== -## ✨ Features - -* MSC4108 support OIDC QR code login ([#4134](https://github.com/matrix-org/matrix-js-sdk/pull/4134)). Contributed by @t3chguy. -* Add crypto methods for export and import of secrets bundle ([#4227](https://github.com/matrix-org/matrix-js-sdk/pull/4227)). Contributed by @t3chguy. - -## 🐛 Bug Fixes - -* Fix screen sharing in recent Chrome ([#4243](https://github.com/matrix-org/matrix-js-sdk/pull/4243)). Contributed by @RiotRobot. -* Fix incorrect assumptions about required fields in /search response ([#4228](https://github.com/matrix-org/matrix-js-sdk/pull/4228)). Contributed by @t3chguy. -* Fix the queueToDevice tests for the new fakeindexeddb ([#4225](https://github.com/matrix-org/matrix-js-sdk/pull/4225)). Contributed by @dbkr. - - -Changes in [33.0.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v33.0.0) (2024-06-04) -================================================================================================== -## 🚨 BREAKING CHANGES - -* Remove more deprecated methods, fields, and exports ([#4217](https://github.com/matrix-org/matrix-js-sdk/pull/4217)). Contributed by @t3chguy. -* Remove deprecated methods and fields ([#4201](https://github.com/matrix-org/matrix-js-sdk/pull/4201)). Contributed by @t3chguy. - -## 🦖 Deprecations - -* Remove more deprecated methods, fields, and exports ([#4217](https://github.com/matrix-org/matrix-js-sdk/pull/4217)). Contributed by @t3chguy. -* Remove deprecated methods and fields ([#4201](https://github.com/matrix-org/matrix-js-sdk/pull/4201)). Contributed by @t3chguy. - -## ✨ Features - -* `initRustCrypto`: allow app to pass in the store key directly ([#4210](https://github.com/matrix-org/matrix-js-sdk/pull/4210)). Contributed by @richvdh. -* Preserve ESM for async imports to work correctly ([#4187](https://github.com/matrix-org/matrix-js-sdk/pull/4187)). Contributed by @ms-dosx86. - -## 🐛 Bug Fixes - -* Don't run migration for Rust crypto if the legacy store is empty ([#4218](https://github.com/matrix-org/matrix-js-sdk/pull/4218)). Contributed by @andybalaam. -* Bump matrix-sdk-crypto-wasm to 5.0.0 ([#4216](https://github.com/matrix-org/matrix-js-sdk/pull/4216)). Contributed by @richvdh. -* Wire up verification cancel \& mismatch for rust crypto ([#4202](https://github.com/matrix-org/matrix-js-sdk/pull/4202)). Contributed by @t3chguy. -* Only pass id\_server if we had one to begin with ([#4200](https://github.com/matrix-org/matrix-js-sdk/pull/4200)). Contributed by @t3chguy. - - -Changes in [32.4.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v32.4.0) (2024-05-22) -================================================================================================== -* No changes - - -Changes in [32.3.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v32.3.0) (2024-05-21) -================================================================================================== -## ✨ Features - -* Simplify OIDC types \& export `decodeIdToken` ([#4193](https://github.com/matrix-org/matrix-js-sdk/pull/4193)). Contributed by @t3chguy. -* Add helpers for authenticated media, and associated documentation ([#4185](https://github.com/matrix-org/matrix-js-sdk/pull/4185)). Contributed by @turt2live. - -## 🐛 Bug Fixes - -* Fix state\_events.ts types ([#4196](https://github.com/matrix-org/matrix-js-sdk/pull/4196)). Contributed by @t3chguy. -* Fix sendEventHttpRequest for `m.room.redaction` events without `redacts` ([#4192](https://github.com/matrix-org/matrix-js-sdk/pull/4192)). Contributed by @t3chguy. - - -Changes in [32.2.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v32.2.0) (2024-05-07) -================================================================================================== -## ✨ Features - -* Use a different error code for UTDs when user was not in the room ([#4172](https://github.com/matrix-org/matrix-js-sdk/pull/4172)). Contributed by @uhoreg. -* Modernize window.crypto access constants ([#4169](https://github.com/matrix-org/matrix-js-sdk/pull/4169)). Contributed by @turt2live. -* Improve compliance with MSC3266 ([#4155](https://github.com/matrix-org/matrix-js-sdk/pull/4155)). Contributed by @AndrewFerr. -* Add comment to make clear that RoomStateEvent.Events does not update related objects in the js-sdk ([#4152](https://github.com/matrix-org/matrix-js-sdk/pull/4152)). Contributed by @toger5. -* Crypto: use a new error code for UTDs from device-relative historical events ([#4139](https://github.com/matrix-org/matrix-js-sdk/pull/4139)). Contributed by @richvdh. - -## 🐛 Bug Fixes - -* Element-R: Fix rust migration when ssss secret are stored not encryted in cache (old legacy behavior) ([#4168](https://github.com/matrix-org/matrix-js-sdk/pull/4168)). Contributed by @BillCarsonFr. - - -Changes in [32.1.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v32.1.0) (2024-04-23) -================================================================================================== -## ✨ Features - -* Add support for device dehydration v2 (Element R) ([#4062](https://github.com/matrix-org/matrix-js-sdk/pull/4062)). Contributed by @uhoreg. -* OIDC improvements in prep of OIDC-QR reciprocation ([#4149](https://github.com/matrix-org/matrix-js-sdk/pull/4149)). Contributed by @t3chguy. - -## 🐛 Bug Fixes - -* Validate backup private key before migrating it ([#4114](https://github.com/matrix-org/matrix-js-sdk/pull/4114)). Contributed by @BillCarsonFr. -* ElementR| Retry query backup until it works during migration to avoid spurious correption error popup ([#4113](https://github.com/matrix-org/matrix-js-sdk/pull/4113)). Contributed by @BillCarsonFr. - - -Changes in [32.0.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v32.0.0) (2024-04-09) -================================================================================================== -## 🚨 BREAKING CHANGES - -* Remove various deprecated methods \& re-exports ([#4125](https://github.com/matrix-org/matrix-js-sdk/pull/4125)). Contributed by @t3chguy. -* Remove the logic that throws when the lazy loading options has changed. ([#4124](https://github.com/matrix-org/matrix-js-sdk/pull/4124)). Contributed by @langleyd. -* Fix highlights from threads disappearing on new messages ([#4106](https://github.com/matrix-org/matrix-js-sdk/pull/4106)). Contributed by @dbkr. - -## ✨ Features - -* Add new `decryptExistingEvent` test helper ([#4133](https://github.com/matrix-org/matrix-js-sdk/pull/4133)). Contributed by @richvdh. -* Improve types for `sendEvent` ([#4108](https://github.com/matrix-org/matrix-js-sdk/pull/4108)). Contributed by @t3chguy. -* Remove various deprecated methods \& re-exports ([#4125](https://github.com/matrix-org/matrix-js-sdk/pull/4125)). Contributed by @t3chguy. -* Add new enum for verification methods. ([#4129](https://github.com/matrix-org/matrix-js-sdk/pull/4129)). Contributed by @richvdh. -* Add some test utils in a new entrypoint ([#4127](https://github.com/matrix-org/matrix-js-sdk/pull/4127)). Contributed by @richvdh. -* Improve types for `sendStateEvent` ([#4105](https://github.com/matrix-org/matrix-js-sdk/pull/4105)). Contributed by @t3chguy. - -## 🐛 Bug Fixes - -* Improve types for `IPowerLevelsContent` and `hasSufficientPowerLevelFor` ([#4128](https://github.com/matrix-org/matrix-js-sdk/pull/4128)). Contributed by @galash13. -* Remove the logic that throws when the lazy loading options has changed. ([#4124](https://github.com/matrix-org/matrix-js-sdk/pull/4124)). Contributed by @langleyd. -* Fix highlights from threads disappearing on new messages ([#4106](https://github.com/matrix-org/matrix-js-sdk/pull/4106)). Contributed by @dbkr. -* Extend logic for local notification processing to threads ([#4111](https://github.com/matrix-org/matrix-js-sdk/pull/4111)). Contributed by @dbkr. -* Fix public rooms post request search params and body ([#4110](https://github.com/matrix-org/matrix-js-sdk/pull/4110)). Contributed by @ajbura. -* Fix bugs with the first reply to a thread ([#4104](https://github.com/matrix-org/matrix-js-sdk/pull/4104)). Contributed by @dbkr. - - -Changes in [31.6.1](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v31.6.1) (2024-03-28) -================================================================================================== -## 🐛 Bug Fixes - -* Fix merging of default push rules ([#4136](https://github.com/matrix-org/matrix-js-sdk/pull/4136)). - - -Changes in [31.6.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v31.6.0) (2024-03-26) -================================================================================================== -## ✨ Features - -* Introduce Membership TS type (take 2) ([#4107](https://github.com/matrix-org/matrix-js-sdk/pull/4107)). Contributed by @andybalaam. -* fix automatic DM avatar with functional members ([#4017](https://github.com/matrix-org/matrix-js-sdk/pull/4017)). Contributed by @HarHarLinks. -* Export types describing all specced media event formats ([#4092](https://github.com/matrix-org/matrix-js-sdk/pull/4092)). Contributed by @t3chguy. -* Add `.m.rule.is_room_mention` push rule to DEFAULT\_OVERRIDE\_RULES ([#4100](https://github.com/matrix-org/matrix-js-sdk/pull/4100)). Contributed by @t3chguy. -* Make sending ContentLoaded optional for a widgetClient ([#4086](https://github.com/matrix-org/matrix-js-sdk/pull/4086)). Contributed by @toger5. - -## 🐛 Bug Fixes - -* Migrate own identity local trust to rust crypto ([#4090](https://github.com/matrix-org/matrix-js-sdk/pull/4090)). Contributed by @BillCarsonFr. -* Fix race condition with sliding sync extensions ([#4089](https://github.com/matrix-org/matrix-js-sdk/pull/4089)). Contributed by @zzorba. - - -Changes in [31.5.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v31.5.0) (2024-03-12) -================================================================================================== -## ✨ Features - -* Update MSC2965 OIDC Discovery implementation ([#4064](https://github.com/matrix-org/matrix-js-sdk/pull/4064)). Contributed by @t3chguy. - -## 🐛 Bug Fixes - -* Add basic retry for rust crypto outgoing requests ([#4061](https://github.com/matrix-org/matrix-js-sdk/pull/4061)). Contributed by @BillCarsonFr. - - -Changes in [31.4.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v31.4.0) (2024-02-27) -================================================================================================== -## ✨ Features - -* Validate `account_management_uri` and `account_management_actions_supported` from OIDC Issuer well-known ([#4074](https://github.com/matrix-org/matrix-js-sdk/pull/4074)). Contributed by @t3chguy. -* Allow specifying OIDC url state parameter for passing data to callback ([#4068](https://github.com/matrix-org/matrix-js-sdk/pull/4068)). Contributed by @t3chguy. -* Add getAuthIssuer method for MSC2965 ([#4071](https://github.com/matrix-org/matrix-js-sdk/pull/4071)). Contributed by @t3chguy. -* Allow specifying more OIDC client metadata for dynamic registration ([#4070](https://github.com/matrix-org/matrix-js-sdk/pull/4070)). Contributed by @t3chguy. -* Add unread marker event type ([#4069](https://github.com/matrix-org/matrix-js-sdk/pull/4069)). Contributed by @dbkr. -* Add "AsJson" forms of the key import/export methods ([#4057](https://github.com/matrix-org/matrix-js-sdk/pull/4057)). Contributed by @andybalaam. - -## 🐛 Bug Fixes - -* Ignore memberships of users that are not in the call ([#4065](https://github.com/matrix-org/matrix-js-sdk/pull/4065)). Contributed by @toger5. -* Await encrypted messages ([#4063](https://github.com/matrix-org/matrix-js-sdk/pull/4063)). Contributed by @toger5. -* ElementR | Ensure own user and device trust are updated after migration before giving back control to the app. ([#4059](https://github.com/matrix-org/matrix-js-sdk/pull/4059)). Contributed by @BillCarsonFr. -* Bump matrix-sdk-crypto-wasm to 4.5.0 ([#4060](https://github.com/matrix-org/matrix-js-sdk/pull/4060)). Contributed by @andybalaam. - - -Changes in [31.3.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v31.3.0) (2024-02-13) -================================================================================================== -## ✨ Features - -* Add expire\_ts compatibility to matrixRTC ([#4032](https://github.com/matrix-org/matrix-js-sdk/pull/4032)). Contributed by @toger5. -* Element-R: support for migration of the room list from legacy crypto ([#4036](https://github.com/matrix-org/matrix-js-sdk/pull/4036)). Contributed by @richvdh. -* Element-R: check persistent room list for encryption config ([#4035](https://github.com/matrix-org/matrix-js-sdk/pull/4035)). Contributed by @richvdh. -* Support optional MSC3860 redirects ([#4007](https://github.com/matrix-org/matrix-js-sdk/pull/4007)). Contributed by @turt2live. - -## 🐛 Bug Fixes - -* WebR: migrate the megolm session imported flag ([#4037](https://github.com/matrix-org/matrix-js-sdk/pull/4037)). Contributed by @BillCarsonFr. -* ElementR: fix emoji verification stalling when both ends hit start at the same time ([#4004](https://github.com/matrix-org/matrix-js-sdk/pull/4004)). Contributed by @uhoreg. -* Dependencies: Bump wasm bindings version to 4.3.0 ([#4042](https://github.com/matrix-org/matrix-js-sdk/pull/4042)). Contributed by @BillCarsonFr. -* Element R: emit events when devices have changed ([#4019](https://github.com/matrix-org/matrix-js-sdk/pull/4019)). Contributed by @uhoreg. -* ElementR: report invalid keys rather than failing to restore from backup ([#4006](https://github.com/matrix-org/matrix-js-sdk/pull/4006)). Contributed by @uhoreg. -* Make `timeline` a getter ([#4022](https://github.com/matrix-org/matrix-js-sdk/pull/4022)). Contributed by @florianduros. -* Implement getting verification cancellation info in Rust crypto ([#3947](https://github.com/matrix-org/matrix-js-sdk/pull/3947)). Contributed by @uhoreg. -* Fix crypto migration for megolm sessions with no sender key ([#4024](https://github.com/matrix-org/matrix-js-sdk/pull/4024)). Contributed by @richvdh. - - -Changes in [31.2.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v31.2.0) (2024-01-31) -================================================================================================== -## ✨ Features - -* Emit events during migration from libolm ([#3982](https://github.com/matrix-org/matrix-js-sdk/pull/3982)). Contributed by @richvdh. -* Support for migration from from libolm ([#3978](https://github.com/matrix-org/matrix-js-sdk/pull/3978)). Contributed by @richvdh. - -## 🐛 Bug Fixes - -* ElementR | backup: call expensive `roomKeyCounts` less often ([#4015](https://github.com/matrix-org/matrix-js-sdk/pull/4015)). Contributed by @BillCarsonFr. -* Decrypt and Import full backups in chunk with progress ([#4005](https://github.com/matrix-org/matrix-js-sdk/pull/4005)). Contributed by @BillCarsonFr. -* Fix new threads not appearing. ([#4009](https://github.com/matrix-org/matrix-js-sdk/pull/4009)). Contributed by @dbkr. - - -Changes in [31.1.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v31.1.0) (2024-01-19) -================================================================================================== -## ✨ Features - -* Broaden spec version support ([#4016](https://github.com/matrix-org/matrix-js-sdk/pull/4016)). Contributed by @RiotRobot. - - -Changes in [31.0.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v31.0.0) (2024-01-16) -================================================================================================== -## 🚨 BREAKING CHANGES - -* Bump minimum spec version to v1.5 ([#3970](https://github.com/matrix-org/matrix-js-sdk/pull/3970)). Contributed by @richvdh. - -## ✨ Features - -* Bump minimum spec version to v1.5 ([#3970](https://github.com/matrix-org/matrix-js-sdk/pull/3970)). Contributed by @richvdh. -* Send authenticated /versions request ([#3968](https://github.com/matrix-org/matrix-js-sdk/pull/3968)). Contributed by @dbkr. - -## 🐛 Bug Fixes - -* Revert "Bump matrix-sdk-crypto-wasm to 3.6.0" ([#3991](https://github.com/matrix-org/matrix-js-sdk/pull/3991)). Contributed by @andybalaam. -* #22606 Fix "Remove" button to users without "m.room.redaction" ([#3981](https://github.com/matrix-org/matrix-js-sdk/pull/3981)). Contributed by @rashmitpankhania. -* ElementR: Ensure Encryption order per room ([#3973](https://github.com/matrix-org/matrix-js-sdk/pull/3973)). Contributed by @BillCarsonFr. -* Element-R: fix `bootstrapSecretStorage` not resetting key backup when requested ([#3976](https://github.com/matrix-org/matrix-js-sdk/pull/3976)). Contributed by @uhoreg. - - -Changes in [30.3.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v30.3.0) (2023-12-19) -================================================================================================== -## ✨ Features - -* Element-R: disable sending room key requests ([#3939](https://github.com/matrix-org/matrix-js-sdk/pull/3939)). Contributed by @richvdh. - -## 🐛 Bug Fixes - -* Fix notifications appearing for old events ([#3946](https://github.com/matrix-org/matrix-js-sdk/pull/3946)). Contributed by @dbkr. -* Don't back up keys that we got from backup ([#3934](https://github.com/matrix-org/matrix-js-sdk/pull/3934)). Contributed by @uhoreg. -* Fix upload with empty Content-Type ([#3918](https://github.com/matrix-org/matrix-js-sdk/pull/3918)). Contributed by @JakubOnderka. -* Prevent phantom notifications from events not in a room's timeline ([#3942](https://github.com/matrix-org/matrix-js-sdk/pull/3942)). Contributed by @dbkr. - - -Changes in [30.2.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v30.2.0) (2023-12-05) -================================================================================================== -## ✨ Features - -* Only await key query after lazy members resolved ([#3902](https://github.com/matrix-org/matrix-js-sdk/pull/3902)). Contributed by @BillCarsonFr. - -## 🐛 Bug Fixes - -* Rewrite receipt-handling code ([#3901](https://github.com/matrix-org/matrix-js-sdk/pull/3901)). Contributed by @andybalaam. -* Explicitly free some Rust-side objects ([#3911](https://github.com/matrix-org/matrix-js-sdk/pull/3911)). Contributed by @richvdh. -* Fix type for TimestampToEventResponse.origin\_server\_ts ([#3906](https://github.com/matrix-org/matrix-js-sdk/pull/3906)). Contributed by @Half-Shot. - - -Changes in [30.1.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v30.1.0) (2023-11-21) -================================================================================================== -## ✨ Features - -* Rotate per-participant keys when a member leaves ([#3833](https://github.com/matrix-org/matrix-js-sdk/pull/3833)). Contributed by @dbkr. -* Add E2EE for embedded mode of Element Call ([#3667](https://github.com/matrix-org/matrix-js-sdk/pull/3667)). Contributed by @SimonBrandner. - -## 🐛 Bug Fixes - -* Shorten TimelineWindow when an event is removed ([#3862](https://github.com/matrix-org/matrix-js-sdk/pull/3862)). Contributed by @andybalaam. -* Ignore receipts pointing at missing or invalid events ([#3817](https://github.com/matrix-org/matrix-js-sdk/pull/3817)). Contributed by @andybalaam. -* Fix members being loaded from server on initial sync (defeating lazy loading) ([#3830](https://github.com/matrix-org/matrix-js-sdk/pull/3830)). Contributed by @BillCarsonFr. - - -Changes in [30.0.1](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v30.0.1) (2023-11-13) -================================================================================================== - -## 🐛 Bug Fixes - * Ensure `setUserCreator` is called when a store is assigned ([\#3867](https://github.com/matrix-org/matrix-js-sdk/pull/3867)). Fixes vector-im/element-web#26520. Contributed by @MidhunSureshR. - -Changes in [30.0.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v30.0.0) (2023-11-07) -================================================================================================== - -## 🚨 BREAKING CHANGES - * Refactor & make base64 functions browser-safe ([\#3818](https://github.com/matrix-org/matrix-js-sdk/pull/3818)). - * `IndexedDBStore.startup()` must be called after using it on `sdk.createClient` now. - -## 🦖 Deprecations - * Deprecate `MatrixEvent.toJSON` ([\#3801](https://github.com/matrix-org/matrix-js-sdk/pull/3801)). - -## ✨ Features - * Element-R: Add the git sha of the binding crate to `CryptoApi#getVersion` ([\#3838](https://github.com/matrix-org/matrix-js-sdk/pull/3838)). Contributed by @florianduros. - * Element-R: Wire up `globalBlacklistUnverifiedDevices` field to rust crypto encryption settings ([\#3790](https://github.com/matrix-org/matrix-js-sdk/pull/3790)). Fixes vector-im/element-web#26315. Contributed by @florianduros. - * Element-R: Wire up room rotation ([\#3807](https://github.com/matrix-org/matrix-js-sdk/pull/3807)). Fixes vector-im/element-web#26318. Contributed by @florianduros. - * Element-R: Add current version of the rust-sdk and vodozemac ([\#3825](https://github.com/matrix-org/matrix-js-sdk/pull/3825)). Contributed by @florianduros. - * Element-R: Wire up room history visibility ([\#3805](https://github.com/matrix-org/matrix-js-sdk/pull/3805)). Fixes vector-im/element-web#26319. Contributed by @florianduros. - * Element-R: log when we send to-device messages ([\#3810](https://github.com/matrix-org/matrix-js-sdk/pull/3810)). - -## 🐛 Bug Fixes - * Fix reemitter not being correctly wired on user objects created in storage classes ([\#3796](https://github.com/matrix-org/matrix-js-sdk/pull/3796)). Contributed by @MidhunSureshR. - * Element-R: silence log errors when viewing a pending event ([\#3824](https://github.com/matrix-org/matrix-js-sdk/pull/3824)). - * Don't emit a closed event if the indexeddb is closed by Element ([\#3832](https://github.com/matrix-org/matrix-js-sdk/pull/3832)). Fixes vector-im/element-web#25941. Contributed by @dhenneke. - * Element-R: silence log errors when viewing a decryption failure ([\#3821](https://github.com/matrix-org/matrix-js-sdk/pull/3821)). - -Changes in [29.1.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v29.1.0) (2023-10-24) -================================================================================================== - -## ✨ Features - * OIDC: refresh tokens ([\#3764](https://github.com/matrix-org/matrix-js-sdk/pull/3764)). Contributed by @kerryarchibald. - * OIDC: add `prompt` param to auth url creation ([\#3794](https://github.com/matrix-org/matrix-js-sdk/pull/3794)). Contributed by @kerryarchibald. - * Allow applications to specify their own logger instance ([\#3792](https://github.com/matrix-org/matrix-js-sdk/pull/3792)). Fixes #1899. - * Export AutoDiscoveryError and fix type of ALL_ERRORS ([\#3768](https://github.com/matrix-org/matrix-js-sdk/pull/3768)). - -## 🐛 Bug Fixes - * Fix sending call member events on leave ([\#3799](https://github.com/matrix-org/matrix-js-sdk/pull/3799)). Fixes vector-im/element-call#1763. - * Don't use event.sender in CallMembership ([\#3793](https://github.com/matrix-org/matrix-js-sdk/pull/3793)). - * Element-R: Don't mark QR code verification as done until it's done ([\#3791](https://github.com/matrix-org/matrix-js-sdk/pull/3791)). Fixes vector-im/element-web#26293. - * Element-R: Connect device to key backup when crypto is created ([\#3784](https://github.com/matrix-org/matrix-js-sdk/pull/3784)). Fixes vector-im/element-web#26316. Contributed by @florianduros. - * Element-R: Avoid errors in `VerificationRequest.generateQRCode` when QR code is unavailable ([\#3779](https://github.com/matrix-org/matrix-js-sdk/pull/3779)). Fixes vector-im/element-web#26300. Contributed by @florianduros. - * ElementR: Check key backup when user identity changes ([\#3760](https://github.com/matrix-org/matrix-js-sdk/pull/3760)). Fixes vector-im/element-web#26244. Contributed by @florianduros. - * Element-R: emit `VerificationRequestReceived` on incoming request ([\#3762](https://github.com/matrix-org/matrix-js-sdk/pull/3762)). Fixes vector-im/element-web#26245. - -Changes in [29.0.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v29.0.0) (2023-10-10) -================================================================================================== - -## 🚨 BREAKING CHANGES - * Remove browserify builds ([\#3759](https://github.com/matrix-org/matrix-js-sdk/pull/3759)). - -## ✨ Features - * Export AutoDiscoveryError and fix type of ALL_ERRORS ([\#3768](https://github.com/matrix-org/matrix-js-sdk/pull/3768)). - * Support for stable MSC3882 get_login_token ([\#3416](https://github.com/matrix-org/matrix-js-sdk/pull/3416)). Contributed by @hughns. - * Remove IsUserMention and IsRoomMention from DEFAULT_OVERRIDE_RULES ([\#3752](https://github.com/matrix-org/matrix-js-sdk/pull/3752)). Contributed by @kerryarchibald. - -## 🐛 Bug Fixes - * Fix a case where joinRoom creates a duplicate Room object ([\#3747](https://github.com/matrix-org/matrix-js-sdk/pull/3747)). - * Add membershipID to call memberships ([\#3745](https://github.com/matrix-org/matrix-js-sdk/pull/3745)). - * Fix the warning for messages from unsigned devices ([\#3743](https://github.com/matrix-org/matrix-js-sdk/pull/3743)). - * Stop keep alive, when sync was stoped ([\#3720](https://github.com/matrix-org/matrix-js-sdk/pull/3720)). Contributed by @finsterwalder. - -Changes in [28.2.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v28.2.0) (2023-09-26) -================================================================================================== - -## 🦖 Deprecations - * Implement `getEncryptionInfoForEvent` and deprecate `getEventEncryptionInfo` ([\#3693](https://github.com/matrix-org/matrix-js-sdk/pull/3693)). - * **The Browserify artifact is being deprecated, scheduled for removal in the October 10th release cycle. (#3189)** - -## ✨ Features - * Delete knocked room when knock membership changes ([\#3729](https://github.com/matrix-org/matrix-js-sdk/pull/3729)). Contributed by @maheichyk. - * Introduce MatrixRTCSession lower level group call primitive ([\#3663](https://github.com/matrix-org/matrix-js-sdk/pull/3663)). - * Sync knock rooms ([\#3703](https://github.com/matrix-org/matrix-js-sdk/pull/3703)). Contributed by @maheichyk. - -## 🐛 Bug Fixes - * Dont access indexed db when undefined ([\#3707](https://github.com/matrix-org/matrix-js-sdk/pull/3707)). Contributed by @finsterwalder. - * Don't reset unread count when adding a synthetic receipt ([\#3706](https://github.com/matrix-org/matrix-js-sdk/pull/3706)). Fixes #3684. Contributed by @andybalaam. - -Changes in [28.1.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v28.1.0) (2023-09-12) -============================================================================================================ - -## 🦖 Deprecations - * Deprecate `MatrixClient.checkUserTrust` ([\#3691](https://github.com/matrix-org/matrix-js-sdk/pull/3691)). - * Deprecate `MatrixClient.{prepare,create}KeyBackupVersion` in favour of new `CryptoApi.resetKeyBackup` API ([\#3689](https://github.com/matrix-org/matrix-js-sdk/pull/3689)). - * **The Browserify artifact is being deprecated, scheduled for removal in the October 10th release cycle. (#3189)** - -## ✨ Features - * Allow calls without ICE/TURN/STUN servers ([\#3695](https://github.com/matrix-org/matrix-js-sdk/pull/3695)). - * Emit summary update event ([\#3687](https://github.com/matrix-org/matrix-js-sdk/pull/3687)). Fixes vector-im/element-web#26033. - * ElementR: Update `CryptoApi.userHasCrossSigningKeys` ([\#3646](https://github.com/matrix-org/matrix-js-sdk/pull/3646)). Contributed by @florianduros. - * Add `join_rule` field to /publicRooms response ([\#3673](https://github.com/matrix-org/matrix-js-sdk/pull/3673)). Contributed by @charlynguyen. - * Use sender instead of content.creator field on m.room.create events ([\#3675](https://github.com/matrix-org/matrix-js-sdk/pull/3675)). - -## 🐛 Bug Fixes - * Provide better error for ICE Server SyntaxError ([\#3694](https://github.com/matrix-org/matrix-js-sdk/pull/3694)). Fixes vector-im/element-web#21804. - * Legacy crypto: re-check key backup after `bootstrapSecretStorage` ([\#3692](https://github.com/matrix-org/matrix-js-sdk/pull/3692)). Fixes vector-im/element-web#26115. - -Changes in [28.0.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v28.0.0) (2023-08-29) -================================================================================================== - -## 🚨 BREAKING CHANGES - * Set minimum supported Matrix 1.1 version (drop legacy r0 versions) ([\#3007](https://github.com/matrix-org/matrix-js-sdk/pull/3007)). Fixes vector-im/element-web#16876. - -## 🦖 Deprecations - * **The Browserify artifact is being deprecated, scheduled for removal in the October 10th release cycle. (#3189)** - -## ✨ Features - * ElementR: Add `CryptoApi.requestVerificationDM` ([\#3643](https://github.com/matrix-org/matrix-js-sdk/pull/3643)). Contributed by @florianduros. - * Implement `CryptoApi.checkKeyBackupAndEnable` ([\#3633](https://github.com/matrix-org/matrix-js-sdk/pull/3633)). Fixes vector-im/crypto-internal#111 and vector-im/crypto-internal#112. - -## 🐛 Bug Fixes - * ElementR: Process all verification events, not just requests ([\#3650](https://github.com/matrix-org/matrix-js-sdk/pull/3650)). Contributed by @florianduros. - -Changes in [27.2.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v27.2.0) (2023-08-15) -================================================================================================== - -## 🦖 Deprecations - * **The Browserify artifact is being deprecated, scheduled for removal in the October 10th release cycle. (#3189)** - -## ✨ Features - * Allow knocking rooms ([\#3647](https://github.com/matrix-org/matrix-js-sdk/pull/3647)). Contributed by @charlynguyen. - * Bump pagination limit to account for threaded events ([\#3638](https://github.com/matrix-org/matrix-js-sdk/pull/3638)). - * ElementR: Add `CryptoApi.findVerificationRequestDMInProgress` ([\#3601](https://github.com/matrix-org/matrix-js-sdk/pull/3601)). Contributed by @florianduros. - * Export more into the public interface ([\#3614](https://github.com/matrix-org/matrix-js-sdk/pull/3614)). - -## 🐛 Bug Fixes - * Fix wrong handling of encrypted rooms when loading them from sync accumulator ([\#3640](https://github.com/matrix-org/matrix-js-sdk/pull/3640)). Fixes vector-im/element-web#25803. - * Skip processing thread roots and fetching threads list when support is disabled ([\#3642](https://github.com/matrix-org/matrix-js-sdk/pull/3642)). - * Ensure we don't overinflate the total notification count ([\#3634](https://github.com/matrix-org/matrix-js-sdk/pull/3634)). Fixes vector-im/element-web#25803. - Changes in [27.1.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v27.1.0) (2023-08-01) ================================================================================================== diff --git a/node_modules/matrix-js-sdk/README.md b/node_modules/matrix-js-sdk/README.md index 314f153..ee41f49 100644 --- a/node_modules/matrix-js-sdk/README.md +++ b/node_modules/matrix-js-sdk/README.md @@ -11,24 +11,6 @@ This is the [Matrix](https://matrix.org) Client-Server SDK for JavaScript and TypeScript. This SDK can be run in a browser or in Node.js. ---- - - - - - Element logo - - -
- -Development and maintenance is proudly sponsored by [Element](https://element.io). Element uses the SDK in their flagship [web](https://github.com/element-hq/element-web) and [desktop](https://github.com/element-hq/element-desktop) clients. - -The SDK is also the basis for multiple Matrix projects and we welcome contributions from all. - ---- - -#### Minimum Matrix server version: v1.1 - The Matrix specification is constantly evolving - while this SDK aims for maximum backwards compatibility, it only guarantees that a feature will be supported for at least 4 spec releases. For example, if a feature the js-sdk supports is removed in v1.4 then the feature is _eligible_ for removal from the SDK when v1.8 is released. This SDK has no @@ -37,14 +19,32 @@ endpoints from before Matrix 1.1, for example. # Quickstart -> [!IMPORTANT] -> Servers may require or use authenticated endpoints for media (images, files, avatars, etc). See the -> [Authenticated Media](#authenticated-media) section for information on how to enable support for this. +## In a browser -Using `pnpm` instead of `npm` is recommended. Please see the pnpm [install -guide](https://pnpm.io/installation#using-corepack) if you do not have it already. +### Note, the browserify build has been deprecated. Please use a bundler like webpack or vite instead. -`pnpm add matrix-js-sdk` +Download the browser version from +https://github.com/matrix-org/matrix-js-sdk/releases/latest and add that as a +`