element-web-synapse01pim.gr.jp

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

7249.js.map (126963B)


      1 {"version":3,"file":"bundles/12c8185ea2689492c07b/7249.js","mappings":"yPA6LO,IAAKA,EAAwB,SAAxBA,GAAwB,OAAxBA,EAAwB,gBAAxBA,CAAwB,MAmBxBC,EAAiB,SAAjBA,GAAiB,OAAjBA,EAAAA,EAAiB,mBAAjBA,EAAAA,EAAiB,yBAAjBA,EAAAA,EAAiB,iBAAjBA,EAAAA,EAAiB,qBAAjBA,EAAAA,EAAiB,yBAAjBA,EAAAA,EAAiB,eAAjBA,CAAiB,MA2FjBC,EAAa,SAAbA,GAAa,OAAbA,EAAa,gBAAbA,EAAa,mBAAbA,EAAa,wCAAbA,CAAa,MAkGlB,SAASC,EAA6BC,GACzC,OAAOA,EAAIC,MAAQJ,EAAkBK,QAAUF,EAAIG,YAAcH,EAAII,SACzE,gICzJO,IAAKC,EAAc,SAAdA,GAAc,OAAdA,EAAAA,EAAc,6BAAdA,EAAAA,EAAc,iDAAdA,EAAAA,EAAc,iDAAdA,EAAAA,EAAc,uDAAdA,EAAAA,EAAc,mDAAdA,EAAAA,EAAc,2DAAdA,CAAc,oBATwB,ktBCjM3C,MAAMC,EAKFC,WAAAA,CAAoBC,IAAiBC,EAAAA,EAAAA,GAAAC,KAAA,YAJxB,GAACA,KAIMF,GAAAA,EAIvBA,EAAGG,gBAAkB,KACjBC,EAAAA,GAAOC,IAAI,+BAA+BH,KAAKF,GAAGM,iBAClDN,EAAGO,QAEX,CAEA,kBAAaC,GACT,MAAMC,MAAM,8BAChB,CAEA,aAAaC,GAGT,OAAOR,IACX,CAEA,mBAAaS,GACT,MAAMF,MAAM,4EAChB,CAOA,uBAAaG,GACT,IAAIC,EAAiBhB,EAAAA,GAAeiB,YAQpC,aAPMZ,KAAKa,MAAM,WAAY,CAACC,EAAqBC,eAAiBC,IAChE,MACMC,EADcD,EAAIE,YAAYJ,EAAqBC,eAC9BI,IAAIC,EAA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.pnpm/matrix-js-sdk@42.0.0/node_modules/matrix-js-sdk/src/crypto-api/verification.ts","webpack://element-web/../node_modules/.pnpm/matrix-js-sdk@42.0.0/node_modules/matrix-js-sdk/src/crypto/store/base.ts","webpack://element-web/../node_modules/.pnpm/matrix-js-sdk@42.0.0/node_modules/matrix-js-sdk/src/crypto/store/indexeddb-crypto-store-backend.ts","webpack://element-web/../node_modules/.pnpm/matrix-js-sdk@42.0.0/node_modules/matrix-js-sdk/src/crypto/store/indexeddb-crypto-store.ts","webpack://element-web/../node_modules/.pnpm/matrix-js-sdk@42.0.0/node_modules/matrix-js-sdk/src/crypto/store/localStorage-crypto-store.ts","webpack://element-web/../node_modules/.pnpm/matrix-js-sdk@42.0.0/node_modules/matrix-js-sdk/src/crypto/store/memory-crypto-store.ts","webpack://element-web/../node_modules/.pnpm/matrix-js-sdk@42.0.0/node_modules/matrix-js-sdk/src/models/device.ts"],"sourcesContent":["/*\nCopyright 2023 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { type MatrixEvent } from \"../models/event.ts\";\nimport { type TypedEventEmitter } from \"../models/typed-event-emitter.ts\";\n\n/**\n * An incoming, or outgoing, request to verify a user or a device via cross-signing.\n */\nexport interface VerificationRequest extends TypedEventEmitter<\n    VerificationRequestEvent,\n    VerificationRequestEventHandlerMap\n> {\n    /**\n     * Unique ID for this verification request.\n     *\n     * An ID isn't assigned until the first message is sent, so this may be `undefined` in the early phases.\n     */\n    get transactionId(): string | undefined;\n\n    /**\n     * For an in-room verification, the ID of the room.\n     *\n     * For to-device verifictions, `undefined`.\n     */\n    get roomId(): string | undefined;\n\n    /**\n     * True if this request was initiated by the local client.\n     *\n     * For in-room verifications, the initiator is who sent the `m.key.verification.request` event.\n     * For to-device verifications, the initiator is who sent the `m.key.verification.start` event.\n     */\n    get initiatedByMe(): boolean;\n\n    /** The user id of the other party in this request */\n    get otherUserId(): string;\n\n    /** For verifications via to-device messages: the ID of the other device. Otherwise, undefined. */\n    get otherDeviceId(): string | undefined;\n\n    /** True if the other party in this request is one of this user's own devices. */\n    get isSelfVerification(): boolean;\n\n    /** current phase of the request. */\n    get phase(): VerificationPhase;\n\n    /** True if the request has sent its initial event and needs more events to complete\n     * (ie it is in phase `Requested`, `Ready` or `Started`).\n     */\n    get pending(): boolean;\n\n    /**\n     * True if we have started the process of sending an `m.key.verification.ready` (but have not necessarily received\n     * the remote echo which causes a transition to {@link VerificationPhase.Ready}.\n     */\n    get accepting(): boolean;\n\n    /**\n     * True if we have started the process of sending an `m.key.verification.cancel` (but have not necessarily received\n     * the remote echo which causes a transition to {@link VerificationPhase.Cancelled}).\n     */\n    get declining(): boolean;\n\n    /**\n     * The remaining number of ms before the request will be automatically cancelled.\n     *\n     * `null` indicates that there is no timeout\n     */\n    get timeout(): number | null;\n\n    /** once the phase is Started (and !initiatedByMe) or Ready: common methods supported by both sides */\n    get methods(): string[];\n\n    /** the method picked in the .start event */\n    get chosenMethod(): string | null;\n\n    /**\n     * Checks whether the other party supports a given verification method.\n     * This is useful when setting up the QR code UI, as it is somewhat asymmetrical:\n     * if the other party supports SCAN_QR, we should show a QR code in the UI, and vice versa.\n     * For methods that need to be supported by both ends, use the `methods` property.\n     *\n     * @param method - the method to check\n     * @returns true if the other party said they supported the method\n     */\n    otherPartySupportsMethod(method: string): boolean;\n\n    /**\n     * Accepts the request, sending a .ready event to the other party\n     *\n     * @returns Promise which resolves when the event has been sent.\n     */\n    accept(): Promise<void>;\n\n    /**\n     * Cancels the request, sending a cancellation to the other party\n     *\n     * @param params - Details for the cancellation, including `reason` (defaults to \"User declined\"), and `code`\n     *    (defaults to `m.user`). **Deprecated**: this parameter is ignored by the Rust cryptography implementation.\n     *\n     * @returns Promise which resolves when the event has been sent.\n     */\n    cancel(params?: { reason?: string; code?: string }): Promise<void>;\n\n    /**\n     * Send an `m.key.verification.start` event to start verification via a particular method.\n     *\n     * This is used for SAS (emoji) verification: `method` should be set to `m.sas.v1`. It does not start\n     * QR-code verification, and passing a QR-code method (such as `m.reciprocate.v1`, `m.qr_code.scan.v1`,\n     * or `m.qr_code.show.v1`) will be rejected with an \"Unsupported verification method\" error.\n     *\n     * For QR-code verification, use {@link VerificationRequest#generateQRCode} to display a QR code to the\n     * other device, or {@link VerificationRequest#scanQRCode} to consume a QR code scanned from it. This is\n     * only possible once the `phase` is {@link VerificationPhase.Ready}; when it is, a client can typically\n     * offer the user any of three options: show a QR code, scan the other party's QR code, or fall back to\n     * emoji (SAS) verification via this method.\n     *\n     * @param method - the name of the verification method to use.\n     *\n     * @returns The verifier which will do the actual verification.\n     */\n    startVerification(method: string): Promise<Verifier>;\n\n    /**\n     * Start a QR code verification by providing a scanned QR code for this verification flow.\n     *\n     * Call this once the user has scanned the QR code displayed by the other device (for example, the bytes\n     * produced by that device's {@link VerificationRequest#generateQRCode}). Validates the QR code, and if it\n     * is ok, sends an `m.key.verification.start` event with `method` set to `m.reciprocate.v1`, to tell the\n     * other side the scan was successful.\n     *\n     * See also {@link VerificationRequest#startVerification} which can be used to start other verification methods.\n     *\n     * @param qrCodeData - the decoded QR code.\n     * @returns A verifier; call `.verify()` on it to wait for the other side to complete the verification flow.\n     */\n    scanQRCode(qrCodeData: Uint8ClampedArray): Promise<Verifier>;\n\n    /**\n     * The verifier which is doing the actual verification, once the method has been established.\n     * Only defined when the `phase` is Started.\n     */\n    get verifier(): Verifier | undefined;\n\n    /**\n     * Generate the data for a QR code allowing the other device to verify this one, if it supports it.\n     *\n     * Returns the QR code data only when all of the following hold; otherwise it returns `undefined`:\n     *  - `phase` is {@link VerificationPhase.Ready};\n     *  - the other party advertises support for scanning a QR code (ie, `otherPartySupportsMethod(\"m.qr_code.scan.v1\")`\n     *    is true); and\n     *  - this device has its cross-signing keys available locally. A frequent cause of an unexpected `undefined`\n     *    is that cross-signing has not been set up or the keys have not yet been fetched, so the QR code cannot be\n     *    constructed even though the phase and method checks pass.\n     *\n     * On success, display the returned bytes as a QR code for the other device to scan; if the other side scans it\n     * and confirms, there is nothing further to do on this side.\n     */\n    generateQRCode(): Promise<Uint8ClampedArray | undefined>;\n\n    /**\n     * If this request has been cancelled, the cancellation code (e.g `m.user`) which is responsible for cancelling\n     * this verification.\n     */\n    get cancellationCode(): string | null;\n\n    /**\n     * The id of the user that cancelled the request.\n     *\n     * Only defined when phase is Cancelled\n     */\n    get cancellingUserId(): string | undefined;\n}\n\n/** Events emitted by {@link VerificationRequest}. */\nexport enum VerificationRequestEvent {\n    /**\n     * Fires whenever the state of the request object has changed.\n     *\n     * There is no payload to the event.\n     */\n    Change = \"change\",\n}\n\n/**\n * Listener type map for {@link VerificationRequestEvent}s.\n *\n * @internal\n */\nexport type VerificationRequestEventHandlerMap = {\n    [VerificationRequestEvent.Change]: () => void;\n};\n\n/** The current phase of a verification request. */\nexport enum VerificationPhase {\n    /** Initial state: no event yet exchanged */\n    Unsent = 1,\n\n    /** An `m.key.verification.request` event has been sent or received */\n    Requested,\n\n    /** An `m.key.verification.ready` event has been sent or received, indicating the verification request is accepted. */\n    Ready,\n\n    /**\n     * The verification is in flight.\n     *\n     * This means that an `m.key.verification.start` event has been sent or received, choosing a verification method;\n     * however the verification has not yet completed or been cancelled.\n     */\n    Started,\n\n    /**\n     * An `m.key.verification.cancel` event has been sent or received at any time before the `done` event, cancelling\n     * the verification request\n     */\n    Cancelled,\n\n    /**\n     * The verification request is complete.\n     *\n     * Normally this means that `m.key.verification.done` events have been sent and received.\n     */\n    Done,\n}\n\n/**\n * A `Verifier` is responsible for performing the verification using a particular method, such as via QR code or SAS\n * (emojis).\n *\n * A verifier object can be created by calling `VerificationRequest.beginVerification`; one is also created\n * automatically when a `m.key.verification.start` event is received for an existing VerificationRequest.\n *\n * Once a verifier object is created, the verification can be started by calling the {@link Verifier#verify} method.\n */\nexport interface Verifier extends TypedEventEmitter<VerifierEvent, VerifierEventHandlerMap> {\n    /**\n     * Returns true if the verification has been cancelled, either by us or the other side.\n     */\n    get hasBeenCancelled(): boolean;\n\n    /**\n     * The ID of the other user in the verification process.\n     */\n    get userId(): string;\n\n    /**\n     * Start the key verification, if it has not already been started.\n     *\n     * This means sending a `m.key.verification.start` if we are the first responder, or a `m.key.verification.accept`\n     * if the other side has already sent a start event.\n     *\n     * @returns Promise which resolves when the verification has completed, or rejects if the verification is cancelled\n     *    or times out.\n     */\n    verify(): Promise<void>;\n\n    /**\n     * Cancel a verification.\n     *\n     * We will send an `m.key.verification.cancel` if the verification is still in flight. The verification promise\n     * will reject, and a {@link crypto-api.VerifierEvent.Cancel | VerifierEvent.Cancel} will be emitted.\n     *\n     * @param e - the reason for the cancellation.\n     */\n    cancel(e: Error): void;\n\n    /**\n     * Get the details for an SAS verification, if one is in progress\n     *\n     * Returns `null`, unless this verifier is for a SAS-based verification and we are waiting for the user to confirm\n     * the SAS matches.\n     */\n    getShowSasCallbacks(): ShowSasCallbacks | null;\n\n    /**\n     * Get the details for reciprocating QR code verification, if one is in progress\n     *\n     * Returns `null`, unless this verifier is for reciprocating a QR-code-based verification (ie, the other user has\n     * already scanned our QR code), and we are waiting for the user to confirm.\n     */\n    getReciprocateQrCodeCallbacks(): ShowQrCodeCallbacks | null;\n}\n\n/** Events emitted by {@link Verifier} */\nexport enum VerifierEvent {\n    /**\n     * The verification has been cancelled, by us or the other side.\n     *\n     * The payload is either an {@link Error}, or an (incoming or outgoing) {@link MatrixEvent}, depending on\n     * unspecified reasons.\n     */\n    Cancel = \"cancel\",\n\n    /**\n     * SAS data has been exchanged and should be displayed to the user.\n     *\n     * The payload is the {@link ShowSasCallbacks} object.\n     */\n    ShowSas = \"show_sas\",\n\n    /**\n     * The user should confirm if the other side has scanned our QR code.\n     *\n     * The payload is the {@link ShowQrCodeCallbacks} object.\n     */\n    ShowReciprocateQr = \"show_reciprocate_qr\",\n}\n\n/** Listener type map for {@link VerifierEvent}s. */\nexport type VerifierEventHandlerMap = {\n    [VerifierEvent.Cancel]: (e: Error | MatrixEvent) => void;\n    [VerifierEvent.ShowSas]: (sas: ShowSasCallbacks) => void;\n    [VerifierEvent.ShowReciprocateQr]: (qr: ShowQrCodeCallbacks) => void;\n};\n\n/**\n * Callbacks for user actions to confirm that the other side has scanned our QR code.\n *\n * This is exposed as the payload of a `VerifierEvent.ShowReciprocateQr` event, or can be retrieved directly from the\n * verifier as `reciprocateQREvent`.\n */\nexport interface ShowQrCodeCallbacks {\n    /** The user confirms that the verification data matches */\n    confirm(): void;\n\n    /** Cancel the verification flow */\n    cancel(): void;\n}\n\n/**\n * Callbacks for user actions while a SAS is displayed.\n *\n * This is exposed as the payload of a `VerifierEvent.ShowSas` event, or directly from the verifier as `sasEvent`.\n */\nexport interface ShowSasCallbacks {\n    /** The generated SAS to be shown to the user */\n    sas: GeneratedSas;\n\n    /** Function to call if the user confirms that the SAS matches.\n     *\n     * @returns A Promise that completes once the m.key.verification.mac is queued.\n     */\n    confirm(): Promise<void>;\n\n    /**\n     * Function to call if the user finds the SAS does not match.\n     *\n     * Sends an `m.key.verification.cancel` event with a `m.mismatched_sas` error code.\n     */\n    mismatch(): void;\n\n    /** Cancel the verification flow */\n    cancel(): void;\n}\n\n/** A generated SAS to be shown to the user, in alternative formats */\nexport interface GeneratedSas {\n    /**\n     * The SAS as three numbers between 0 and 8191.\n     *\n     * Only populated if the `decimal` SAS method was negotiated.\n     */\n    decimal?: [number, number, number];\n\n    /**\n     * The SAS as seven emojis.\n     *\n     * Only populated if the `emoji` SAS method was negotiated.\n     */\n    emoji?: EmojiMapping[];\n}\n\n/**\n * An emoji for the generated SAS. A tuple `[emoji, name]` where `emoji` is the emoji itself and `name` is the\n * English name.\n */\nexport type EmojiMapping = [emoji: string, name: string];\n\n/**\n * True if the request is in a state where it can be accepted (ie, that we're in phases {@link VerificationPhase.Unsent}\n * or {@link VerificationPhase.Requested}, and that we're not in the process of sending a `ready` or `cancel`).\n */\nexport function canAcceptVerificationRequest(req: VerificationRequest): boolean {\n    return req.phase < VerificationPhase.Ready && !req.accepting && !req.declining;\n}\n","/*\nCopyright 2021 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { type Logger } from \"../../logger.ts\";\nimport { type CrossSigningKeyInfo } from \"../../crypto-api/index.ts\";\nimport { type AESEncryptedSecretStoragePayload } from \"../../@types/AESEncryptedSecretStoragePayload.ts\";\nimport { type ISignatures } from \"../../@types/signed.ts\";\n\n/**\n * Internal module. Definitions for storage for the crypto module\n */\n\nexport interface SecretStorePrivateKeys {\n    \"m.megolm_backup.v1\": AESEncryptedSecretStoragePayload;\n}\n\n/**\n * Abstraction of things that can store data required for end-to-end encryption\n */\nexport interface CryptoStore {\n    /**\n     * Returns true if this CryptoStore has ever been initialised (ie, it might contain data).\n     *\n     * Unlike the rest of the methods in this interface, can be called before {@link CryptoStore#startup}.\n     *\n     * @internal\n     */\n    containsData(): Promise<boolean>;\n\n    /**\n     * Initialise this crypto store.\n     *\n     * Typically, this involves provisioning storage, and migrating any existing data to the current version of the\n     * storage schema where appropriate.\n     *\n     * Must be called before any of the rest of the methods in this interface.\n     */\n    startup(): Promise<CryptoStore>;\n\n    deleteAllData(): Promise<void>;\n\n    /**\n     * Get data on how much of the libolm to Rust Crypto migration has been done.\n     *\n     * @internal\n     */\n    getMigrationState(): Promise<MigrationState>;\n\n    /**\n     * Set data on how much of the libolm to Rust Crypto migration has been done.\n     *\n     * @internal\n     */\n    setMigrationState(migrationState: MigrationState): Promise<void>;\n\n    // Olm Account\n    getAccount(txn: unknown, func: (accountPickle: string | null) => void): void;\n    storeAccount(txn: unknown, accountPickle: string): void;\n    getCrossSigningKeys(txn: unknown, func: (keys: Record<string, CrossSigningKeyInfo> | null) => void): void;\n    getSecretStorePrivateKey<K extends keyof SecretStorePrivateKeys>(\n        txn: unknown,\n        func: (key: SecretStorePrivateKeys[K] | null) => void,\n        type: K,\n    ): void;\n    storeSecretStorePrivateKey<K extends keyof SecretStorePrivateKeys>(\n        txn: unknown,\n        type: K,\n        key: SecretStorePrivateKeys[K],\n    ): void;\n\n    // Olm Sessions\n    countEndToEndSessions(txn: unknown, func: (count: number) => void): void;\n    getEndToEndSession(\n        deviceKey: string,\n        sessionId: string,\n        txn: unknown,\n        func: (session: ISessionInfo | null) => void,\n    ): void;\n    getEndToEndSessions(\n        deviceKey: string,\n        txn: unknown,\n        func: (sessions: { [sessionId: string]: ISessionInfo }) => void,\n    ): void;\n\n    storeEndToEndSession(deviceKey: string, sessionId: string, sessionInfo: ISessionInfo, txn: unknown): void;\n\n    /**\n     * Get a batch of end-to-end sessions from the database.\n     *\n     * @returns A batch of Olm Sessions, or `null` if no sessions are left.\n     * @internal\n     */\n    getEndToEndSessionsBatch(): Promise<ISessionInfo[] | null>;\n\n    /**\n     * Delete a batch of end-to-end sessions from the database.\n     *\n     * Any sessions in the list which are not found are silently ignored.\n     *\n     * @internal\n     */\n    deleteEndToEndSessionsBatch(sessions: { deviceKey?: string; sessionId?: string }[]): Promise<void>;\n\n    // Inbound Group Sessions\n    getEndToEndInboundGroupSession(\n        senderCurve25519Key: string,\n        sessionId: string,\n        txn: unknown,\n        func: (groupSession: InboundGroupSessionData | null, groupSessionWithheld: IWithheld | null) => void,\n    ): void;\n    storeEndToEndInboundGroupSession(\n        senderCurve25519Key: string,\n        sessionId: string,\n        sessionData: InboundGroupSessionData,\n        txn: unknown,\n    ): void;\n\n    /**\n     * Count the number of Megolm sessions in the database.\n     *\n     * @internal\n     */\n    countEndToEndInboundGroupSessions(): Promise<number>;\n\n    /**\n     * Get a batch of Megolm sessions from the database.\n     *\n     * @returns A batch of Megolm Sessions, or `null` if no sessions are left.\n     * @internal\n     */\n    getEndToEndInboundGroupSessionsBatch(): Promise<SessionExtended[] | null>;\n\n    /**\n     * Delete a batch of Megolm sessions from the database.\n     *\n     * Any sessions in the list which are not found are silently ignored.\n     *\n     * @internal\n     */\n    deleteEndToEndInboundGroupSessionsBatch(sessions: { senderKey: string; sessionId: string }[]): Promise<void>;\n\n    // Device Data\n    getEndToEndRooms(txn: unknown, func: (rooms: Record<string, IRoomEncryption>) => void): void;\n    markSessionsNeedingBackup(sessions: ISession[], txn?: unknown): Promise<void>;\n\n    // Session key backups\n    doTxn<T>(mode: Mode, stores: Iterable<string>, func: (txn: unknown) => T, log?: Logger): Promise<T>;\n}\n\nexport type Mode = \"readonly\" | \"readwrite\";\n\n/** Data on a Megolm session */\nexport interface ISession {\n    senderKey: string;\n    sessionId: string;\n    sessionData?: InboundGroupSessionData;\n}\n\n/** Extended data on a Megolm session */\nexport interface SessionExtended extends ISession {\n    needsBackup: boolean;\n}\n\n/** Data on an Olm session */\nexport interface ISessionInfo {\n    deviceKey?: string;\n    sessionId?: string;\n    session?: string;\n    lastReceivedMessageTs?: number;\n}\n\nexport interface IDeviceData {\n    devices: {\n        [userId: string]: {\n            [deviceId: string]: IDevice;\n        };\n    };\n    trackingStatus: {\n        [userId: string]: TrackingStatus;\n    };\n    crossSigningInfo?: Record<string, ICrossSigningInfo>;\n    syncToken?: string;\n}\n\nexport interface IWithheld {\n    // eslint-disable-next-line camelcase\n    room_id: string;\n    code: string;\n    reason: string;\n}\n\n/**\n * Represents an outgoing room key request\n */\nexport interface OutgoingRoomKeyRequest {\n    /**\n     * Unique id for this request. Used for both an id within the request for later pairing with a cancellation,\n     * and for the transaction id when sending the to_device messages to our local server.\n     */\n    requestId: string;\n    requestTxnId?: string;\n    /**\n     * Transaction id for the cancellation, if any\n     */\n    cancellationTxnId?: string;\n    /**\n     * List of recipients for the request\n     */\n    recipients: IRoomKeyRequestRecipient[];\n    /**\n     * Parameters for the request\n     */\n    requestBody: IRoomKeyRequestBody;\n    /**\n     * current state of this request\n     */\n    state: RoomKeyRequestState;\n}\n\n/**\n * Keys for the `account` object store to store the migration state.\n * Values are defined in `MigrationState`.\n * @internal\n */\nexport const ACCOUNT_OBJECT_KEY_MIGRATION_STATE = \"migrationState\";\n\n/**\n * A record of which steps have been completed in the libolm to Rust Crypto migration.\n *\n * Used by {@link CryptoStore#getMigrationState} and {@link CryptoStore#setMigrationState}.\n *\n * @internal\n */\nexport enum MigrationState {\n    /** No migration steps have yet been completed. */\n    NOT_STARTED,\n\n    /** We have migrated the account data, cross-signing keys, etc. */\n    INITIAL_DATA_MIGRATED,\n\n    /** INITIAL_DATA_MIGRATED, and in addition, we have migrated all the Olm sessions. */\n    OLM_SESSIONS_MIGRATED,\n\n    /** OLM_SESSIONS_MIGRATED, and in addition, we have migrated all the Megolm sessions. */\n    MEGOLM_SESSIONS_MIGRATED,\n\n    /** MEGOLM_SESSIONS_MIGRATED, and in addition, we have migrated all the room settings. */\n    ROOM_SETTINGS_MIGRATED,\n\n    /** ROOM_SETTINGS_MIGRATED, and in addition, we have done the first own keys query in order to\n     * load the public part of the keys that have been migrated */\n    INITIAL_OWN_KEY_QUERY_DONE,\n}\n\n/**\n * The size of batches to be returned by {@link CryptoStore#getEndToEndSessionsBatch} and\n * {@link CryptoStore#getEndToEndInboundGroupSessionsBatch}.\n */\nexport const SESSION_BATCH_SIZE = 50;\n\nexport interface InboundGroupSessionData {\n    room_id: string; // eslint-disable-line camelcase\n    /** pickled Olm.InboundGroupSession */\n    session: string;\n    keysClaimed?: Record<string, string>;\n    /** Devices involved in forwarding this session to us (normally empty). */\n    forwardingCurve25519KeyChain: string[];\n    /** whether this session is untrusted. */\n    untrusted?: boolean;\n    /** whether this session exists during the room being set to shared history. */\n    sharedHistory?: boolean;\n}\n\nexport interface ICrossSigningInfo {\n    keys: Record<string, CrossSigningKeyInfo>;\n    firstUse: boolean;\n    crossSigningVerifiedBefore: boolean;\n}\n\n/* eslint-disable camelcase */\nexport interface IRoomEncryption {\n    algorithm: string;\n    rotation_period_ms?: number;\n    rotation_period_msgs?: number;\n}\n/* eslint-enable camelcase */\n\nexport enum TrackingStatus {\n    NotTracked,\n    PendingDownload,\n    DownloadInProgress,\n    UpToDate,\n}\n\n/**\n *  possible states for a room key request\n *\n * The state machine looks like:\n * ```\n *\n *     |         (cancellation sent)\n *     | .-------------------------------------------------.\n *     | |                                                 |\n *     V V       (cancellation requested)                  |\n *   UNSENT  -----------------------------+                |\n *     |                                  |                |\n *     |                                  |                |\n *     | (send successful)                |  CANCELLATION_PENDING_AND_WILL_RESEND\n *     V                                  |                Λ\n *    SENT                                |                |\n *     |--------------------------------  |  --------------'\n *     |                                  |  (cancellation requested with intent\n *     |                                  |   to resend the original request)\n *     |                                  |\n *     | (cancellation requested)         |\n *     V                                  |\n * CANCELLATION_PENDING                   |\n *     |                                  |\n *     | (cancellation sent)              |\n *     V                                  |\n * (deleted)  <---------------------------+\n * ```\n */\nexport enum RoomKeyRequestState {\n    /** request not yet sent */\n    Unsent,\n    /** request sent, awaiting reply */\n    Sent,\n    /** reply received, cancellation not yet sent */\n    CancellationPending,\n    /**\n     * Cancellation not yet sent and will transition to UNSENT instead of\n     * being deleted once the cancellation has been sent.\n     */\n    CancellationPendingAndWillResend,\n}\n\n/* eslint-disable camelcase */\ninterface IRoomKey {\n    room_id: string;\n    algorithm: string;\n}\n\n/**\n * The parameters of a room key request. The details of the request may\n * vary with the crypto algorithm, but the management and storage layers for\n * outgoing requests expect it to have 'room_id' and 'session_id' properties.\n */\nexport interface IRoomKeyRequestBody extends IRoomKey {\n    session_id: string;\n    sender_key: string;\n}\n\n/* eslint-enable camelcase */\n\nexport interface IRoomKeyRequestRecipient {\n    userId: string;\n    deviceId: string;\n}\n\ninterface IDevice {\n    keys: Record<string, string>;\n    algorithms: string[];\n    verified: DeviceVerification;\n    known: boolean;\n    unsigned?: Record<string, any>;\n    signatures?: ISignatures;\n}\n\n/** State of the verification of the device. */\nexport enum DeviceVerification {\n    Blocked = -1,\n    Unverified = 0,\n    Verified = 1,\n}\n","/*\nCopyright 2017 - 2021 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { type Logger, logger } from \"../../logger.ts\";\nimport {\n    type CryptoStore,\n    type IDeviceData,\n    type ISession,\n    type SessionExtended,\n    type ISessionInfo,\n    type IWithheld,\n    MigrationState,\n    type Mode,\n    type SecretStorePrivateKeys,\n    SESSION_BATCH_SIZE,\n    ACCOUNT_OBJECT_KEY_MIGRATION_STATE,\n    type InboundGroupSessionData,\n    type IRoomEncryption,\n} from \"./base.ts\";\nimport { IndexedDBCryptoStore } from \"./indexeddb-crypto-store.ts\";\nimport { type CrossSigningKeyInfo } from \"../../crypto-api/index.ts\";\n\nconst PROFILE_TRANSACTIONS = false;\n\n/**\n * Implementation of a CryptoStore which is backed by an existing\n * IndexedDB connection. Generally you want IndexedDBCryptoStore\n * which connects to the database and defers to one of these.\n *\n * @internal\n */\nexport class Backend implements CryptoStore {\n    private nextTxnId = 0;\n\n    /**\n     */\n    public constructor(private db: IDBDatabase) {\n        // make sure we close the db on `onversionchange` - otherwise\n        // attempts to delete the database will block (and subsequent\n        // attempts to re-create it will also block).\n        db.onversionchange = (): void => {\n            logger.log(`versionchange for indexeddb ${this.db.name}: closing`);\n            db.close();\n        };\n    }\n\n    public async containsData(): Promise<boolean> {\n        throw Error(\"Not implemented for Backend\");\n    }\n\n    public async startup(): Promise<CryptoStore> {\n        // No work to do, as the startup is done by the caller (e.g IndexedDBCryptoStore)\n        // by passing us a ready IDBDatabase instance\n        return this;\n    }\n\n    public async deleteAllData(): Promise<void> {\n        throw Error(\"This is not implemented, call IDBFactory::deleteDatabase(dbName) instead.\");\n    }\n\n    /**\n     * Get data on how much of the libolm to Rust Crypto migration has been done.\n     *\n     * Implementation of {@link CryptoStore.getMigrationState}.\n     */\n    public async getMigrationState(): Promise<MigrationState> {\n        let migrationState = MigrationState.NOT_STARTED;\n        await this.doTxn(\"readonly\", [IndexedDBCryptoStore.STORE_ACCOUNT], (txn) => {\n            const objectStore = txn.objectStore(IndexedDBCryptoStore.STORE_ACCOUNT);\n            const getReq = objectStore.get(ACCOUNT_OBJECT_KEY_MIGRATION_STATE);\n            getReq.onsuccess = (): void => {\n                migrationState = getReq.result ?? MigrationState.NOT_STARTED;\n            };\n        });\n        return migrationState;\n    }\n\n    /**\n     * Set data on how much of the libolm to Rust Crypto migration has been done.\n     *\n     * Implementation of {@link CryptoStore.setMigrationState}.\n     */\n    public async setMigrationState(migrationState: MigrationState): Promise<void> {\n        await this.doTxn(\"readwrite\", [IndexedDBCryptoStore.STORE_ACCOUNT], (txn) => {\n            const objectStore = txn.objectStore(IndexedDBCryptoStore.STORE_ACCOUNT);\n            objectStore.put(migrationState, ACCOUNT_OBJECT_KEY_MIGRATION_STATE);\n        });\n    }\n\n    // Olm Account\n\n    public getAccount(txn: IDBTransaction, func: (accountPickle: string | null) => void): void {\n        const objectStore = txn.objectStore(\"account\");\n        const getReq = objectStore.get(\"-\");\n        getReq.onsuccess = function (): void {\n            try {\n                func(getReq.result || null);\n            } catch (e) {\n                abortWithException(txn, <Error>e);\n            }\n        };\n    }\n\n    public storeAccount(txn: IDBTransaction, accountPickle: string): void {\n        const objectStore = txn.objectStore(\"account\");\n        objectStore.put(accountPickle, \"-\");\n    }\n\n    public getCrossSigningKeys(\n        txn: IDBTransaction,\n        func: (keys: Record<string, CrossSigningKeyInfo> | null) => void,\n    ): void {\n        const objectStore = txn.objectStore(\"account\");\n        const getReq = objectStore.get(\"crossSigningKeys\");\n        getReq.onsuccess = function (): void {\n            try {\n                func(getReq.result || null);\n            } catch (e) {\n                abortWithException(txn, <Error>e);\n            }\n        };\n    }\n\n    public getSecretStorePrivateKey<K extends keyof SecretStorePrivateKeys>(\n        txn: IDBTransaction,\n        func: (key: SecretStorePrivateKeys[K] | null) => void,\n        type: K,\n    ): void {\n        const objectStore = txn.objectStore(\"account\");\n        const getReq = objectStore.get(`ssss_cache:${type}`);\n        getReq.onsuccess = function (): void {\n            try {\n                func(getReq.result || null);\n            } catch (e) {\n                abortWithException(txn, <Error>e);\n            }\n        };\n    }\n\n    public storeSecretStorePrivateKey<K extends keyof SecretStorePrivateKeys>(\n        txn: IDBTransaction,\n        type: K,\n        key: SecretStorePrivateKeys[K],\n    ): void {\n        const objectStore = txn.objectStore(\"account\");\n        objectStore.put(key, `ssss_cache:${type}`);\n    }\n\n    // Olm Sessions\n\n    public countEndToEndSessions(txn: IDBTransaction, func: (count: number) => void): void {\n        const objectStore = txn.objectStore(\"sessions\");\n        const countReq = objectStore.count();\n        countReq.onsuccess = function (): void {\n            try {\n                func(countReq.result);\n            } catch (e) {\n                abortWithException(txn, <Error>e);\n            }\n        };\n    }\n\n    public getEndToEndSessions(\n        deviceKey: string,\n        txn: IDBTransaction,\n        func: (sessions: { [sessionId: string]: ISessionInfo }) => void,\n    ): void {\n        const objectStore = txn.objectStore(\"sessions\");\n        const idx = objectStore.index(\"deviceKey\");\n        const getReq = idx.openCursor(deviceKey);\n        const results: Parameters<Parameters<Backend[\"getEndToEndSessions\"]>[2]>[0] = {};\n        getReq.onsuccess = function (): void {\n            const cursor = getReq.result;\n            if (cursor) {\n                results[cursor.value.sessionId] = {\n                    session: cursor.value.session,\n                    lastReceivedMessageTs: cursor.value.lastReceivedMessageTs,\n                };\n                cursor.continue();\n            } else {\n                try {\n                    func(results);\n                } catch (e) {\n                    abortWithException(txn, <Error>e);\n                }\n            }\n        };\n    }\n\n    public getEndToEndSession(\n        deviceKey: string,\n        sessionId: string,\n        txn: IDBTransaction,\n        func: (session: ISessionInfo | null) => void,\n    ): void {\n        const objectStore = txn.objectStore(\"sessions\");\n        const getReq = objectStore.get([deviceKey, sessionId]);\n        getReq.onsuccess = function (): void {\n            try {\n                if (getReq.result) {\n                    func({\n                        session: getReq.result.session,\n                        lastReceivedMessageTs: getReq.result.lastReceivedMessageTs,\n                    });\n                } else {\n                    func(null);\n                }\n            } catch (e) {\n                abortWithException(txn, <Error>e);\n            }\n        };\n    }\n\n    public storeEndToEndSession(\n        deviceKey: string,\n        sessionId: string,\n        sessionInfo: ISessionInfo,\n        txn: IDBTransaction,\n    ): void {\n        const objectStore = txn.objectStore(\"sessions\");\n        objectStore.put({\n            deviceKey,\n            sessionId,\n            session: sessionInfo.session,\n            lastReceivedMessageTs: sessionInfo.lastReceivedMessageTs,\n        });\n    }\n\n    /**\n     * Fetch a batch of Olm sessions from the database.\n     *\n     * Implementation of {@link CryptoStore.getEndToEndSessionsBatch}.\n     */\n    public async getEndToEndSessionsBatch(): Promise<null | ISessionInfo[]> {\n        const result: ISessionInfo[] = [];\n        await this.doTxn(\"readonly\", [IndexedDBCryptoStore.STORE_SESSIONS], (txn) => {\n            const objectStore = txn.objectStore(IndexedDBCryptoStore.STORE_SESSIONS);\n            const getReq = objectStore.openCursor();\n            getReq.onsuccess = function (): void {\n                try {\n                    const cursor = getReq.result;\n                    if (cursor) {\n                        result.push(cursor.value);\n                        if (result.length < SESSION_BATCH_SIZE) {\n                            cursor.continue();\n                        }\n                    }\n                } catch (e) {\n                    abortWithException(txn, <Error>e);\n                }\n            };\n        });\n\n        if (result.length === 0) {\n            // No sessions left.\n            return null;\n        }\n\n        return result;\n    }\n\n    /**\n     * Delete a batch of Olm sessions from the database.\n     *\n     * Implementation of {@link CryptoStore.deleteEndToEndSessionsBatch}.\n     *\n     * @internal\n     */\n    public async deleteEndToEndSessionsBatch(sessions: { deviceKey: string; sessionId: string }[]): Promise<void> {\n        await this.doTxn(\"readwrite\", [IndexedDBCryptoStore.STORE_SESSIONS], async (txn) => {\n            try {\n                const objectStore = txn.objectStore(IndexedDBCryptoStore.STORE_SESSIONS);\n                for (const { deviceKey, sessionId } of sessions) {\n                    const req = objectStore.delete([deviceKey, sessionId]);\n                    await new Promise((resolve) => {\n                        req.onsuccess = resolve;\n                    });\n                }\n            } catch (e) {\n                abortWithException(txn, <Error>e);\n            }\n        });\n    }\n\n    // Inbound group sessions\n\n    public getEndToEndInboundGroupSession(\n        senderCurve25519Key: string,\n        sessionId: string,\n        txn: IDBTransaction,\n        func: (groupSession: InboundGroupSessionData | null, groupSessionWithheld: IWithheld | null) => void,\n    ): void {\n        let session: InboundGroupSessionData | null | boolean = false;\n        let withheld: IWithheld | null | boolean = false;\n        const objectStore = txn.objectStore(\"inbound_group_sessions\");\n        const getReq = objectStore.get([senderCurve25519Key, sessionId]);\n        getReq.onsuccess = function (): void {\n            try {\n                if (getReq.result) {\n                    session = getReq.result.session;\n                } else {\n                    session = null;\n                }\n                if (withheld !== false) {\n                    func(session as InboundGroupSessionData, withheld as IWithheld);\n                }\n            } catch (e) {\n                abortWithException(txn, <Error>e);\n            }\n        };\n\n        const withheldObjectStore = txn.objectStore(\"inbound_group_sessions_withheld\");\n        const withheldGetReq = withheldObjectStore.get([senderCurve25519Key, sessionId]);\n        withheldGetReq.onsuccess = function (): void {\n            try {\n                if (withheldGetReq.result) {\n                    withheld = withheldGetReq.result.session;\n                } else {\n                    withheld = null;\n                }\n                if (session !== false) {\n                    func(session as InboundGroupSessionData, withheld as IWithheld);\n                }\n            } catch (e) {\n                abortWithException(txn, <Error>e);\n            }\n        };\n    }\n\n    public storeEndToEndInboundGroupSession(\n        senderCurve25519Key: string,\n        sessionId: string,\n        sessionData: InboundGroupSessionData,\n        txn: IDBTransaction,\n    ): void {\n        const objectStore = txn.objectStore(\"inbound_group_sessions\");\n        objectStore.put({\n            senderCurve25519Key,\n            sessionId,\n            session: sessionData,\n        });\n    }\n\n    /**\n     * Count the number of Megolm sessions in the database.\n     *\n     * Implementation of {@link CryptoStore.countEndToEndInboundGroupSessions}.\n     *\n     * @internal\n     */\n    public async countEndToEndInboundGroupSessions(): Promise<number> {\n        let result = 0;\n        await this.doTxn(\"readonly\", [IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS], (txn) => {\n            const sessionStore = txn.objectStore(IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS);\n            const countReq = sessionStore.count();\n            countReq.onsuccess = (): void => {\n                result = countReq.result;\n            };\n        });\n        return result;\n    }\n\n    /**\n     * Fetch a batch of Megolm sessions from the database.\n     *\n     * Implementation of {@link CryptoStore.getEndToEndInboundGroupSessionsBatch}.\n     */\n    public async getEndToEndInboundGroupSessionsBatch(): Promise<null | SessionExtended[]> {\n        const result: SessionExtended[] = [];\n        await this.doTxn(\n            \"readonly\",\n            [IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS, IndexedDBCryptoStore.STORE_BACKUP],\n            (txn) => {\n                const sessionStore = txn.objectStore(IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS);\n                const backupStore = txn.objectStore(IndexedDBCryptoStore.STORE_BACKUP);\n\n                const getReq = sessionStore.openCursor();\n                getReq.onsuccess = function (): void {\n                    try {\n                        const cursor = getReq.result;\n                        if (cursor) {\n                            const backupGetReq = backupStore.get(cursor.key);\n                            backupGetReq.onsuccess = (): void => {\n                                result.push({\n                                    senderKey: cursor.value.senderCurve25519Key,\n                                    sessionId: cursor.value.sessionId,\n                                    sessionData: cursor.value.session,\n                                    needsBackup: backupGetReq.result !== undefined,\n                                });\n                                if (result.length < SESSION_BATCH_SIZE) {\n                                    cursor.continue();\n                                }\n                            };\n                        }\n                    } catch (e) {\n                        abortWithException(txn, <Error>e);\n                    }\n                };\n            },\n        );\n\n        if (result.length === 0) {\n            // No sessions left.\n            return null;\n        }\n\n        return result;\n    }\n\n    /**\n     * Delete a batch of Megolm sessions from the database.\n     *\n     * Implementation of {@link CryptoStore.deleteEndToEndInboundGroupSessionsBatch}.\n     *\n     * @internal\n     */\n    public async deleteEndToEndInboundGroupSessionsBatch(\n        sessions: { senderKey: string; sessionId: string }[],\n    ): Promise<void> {\n        await this.doTxn(\"readwrite\", [IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS], async (txn) => {\n            try {\n                const objectStore = txn.objectStore(IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS);\n                for (const { senderKey, sessionId } of sessions) {\n                    const req = objectStore.delete([senderKey, sessionId]);\n                    await new Promise((resolve) => {\n                        req.onsuccess = resolve;\n                    });\n                }\n            } catch (e) {\n                abortWithException(txn, <Error>e);\n            }\n        });\n    }\n\n    public getEndToEndDeviceData(txn: IDBTransaction, func: (deviceData: IDeviceData | null) => void): void {\n        const objectStore = txn.objectStore(\"device_data\");\n        const getReq = objectStore.get(\"-\");\n        getReq.onsuccess = function (): void {\n            try {\n                func(getReq.result || null);\n            } catch (e) {\n                abortWithException(txn, <Error>e);\n            }\n        };\n    }\n\n    public getEndToEndRooms(txn: IDBTransaction, func: (rooms: Record<string, IRoomEncryption>) => void): void {\n        const rooms: Parameters<Parameters<Backend[\"getEndToEndRooms\"]>[1]>[0] = {};\n        const objectStore = txn.objectStore(\"rooms\");\n        const getReq = objectStore.openCursor();\n        getReq.onsuccess = function (): void {\n            const cursor = getReq.result;\n            if (cursor) {\n                rooms[cursor.key as string] = cursor.value;\n                cursor.continue();\n            } else {\n                try {\n                    func(rooms);\n                } catch (e) {\n                    abortWithException(txn, <Error>e);\n                }\n            }\n        };\n    }\n\n    public async markSessionsNeedingBackup(sessions: ISession[], txn?: IDBTransaction): Promise<void> {\n        if (!txn) {\n            txn = this.db.transaction(\"sessions_needing_backup\", \"readwrite\");\n        }\n        const objectStore = txn.objectStore(\"sessions_needing_backup\");\n        await Promise.all(\n            sessions.map((session) => {\n                return new Promise((resolve, reject) => {\n                    const req = objectStore.put({\n                        senderCurve25519Key: session.senderKey,\n                        sessionId: session.sessionId,\n                    });\n                    req.onsuccess = resolve;\n                    req.onerror = reject;\n                });\n            }),\n        );\n    }\n\n    public doTxn<T>(\n        mode: Mode,\n        stores: string | string[],\n        func: (txn: IDBTransaction) => T,\n        log: Logger = logger,\n    ): Promise<T> {\n        let startTime: number;\n        let description: string;\n        if (PROFILE_TRANSACTIONS) {\n            const txnId = this.nextTxnId++;\n            startTime = Date.now();\n            description = `${mode} crypto store transaction ${txnId} in ${stores}`;\n            log.debug(`Starting ${description}`);\n        }\n        const txn = this.db.transaction(stores, mode);\n        const promise = promiseifyTxn(txn);\n        const result = func(txn);\n        if (PROFILE_TRANSACTIONS) {\n            promise.then(\n                () => {\n                    const elapsedTime = Date.now() - startTime;\n                    log.debug(`Finished ${description}, took ${elapsedTime} ms`);\n                },\n                () => {\n                    const elapsedTime = Date.now() - startTime;\n                    log.error(`Failed ${description}, took ${elapsedTime} ms`);\n                },\n            );\n        }\n        return promise.then(() => {\n            return result;\n        });\n    }\n}\n\ntype DbMigration = (db: IDBDatabase) => void;\nconst DB_MIGRATIONS: DbMigration[] = [\n    (db): void => {\n        createDatabase(db);\n    },\n    (db): void => {\n        db.createObjectStore(\"account\");\n    },\n    (db): void => {\n        const sessionsStore = db.createObjectStore(\"sessions\", {\n            keyPath: [\"deviceKey\", \"sessionId\"],\n        });\n        sessionsStore.createIndex(\"deviceKey\", \"deviceKey\");\n    },\n    (db): void => {\n        db.createObjectStore(\"inbound_group_sessions\", {\n            keyPath: [\"senderCurve25519Key\", \"sessionId\"],\n        });\n    },\n    (db): void => {\n        db.createObjectStore(\"device_data\");\n    },\n    (db): void => {\n        db.createObjectStore(\"rooms\");\n    },\n    (db): void => {\n        db.createObjectStore(\"sessions_needing_backup\", {\n            keyPath: [\"senderCurve25519Key\", \"sessionId\"],\n        });\n    },\n    (db): void => {\n        db.createObjectStore(\"inbound_group_sessions_withheld\", {\n            keyPath: [\"senderCurve25519Key\", \"sessionId\"],\n        });\n    },\n    (db): void => {\n        const problemsStore = db.createObjectStore(\"session_problems\", {\n            keyPath: [\"deviceKey\", \"time\"],\n        });\n        problemsStore.createIndex(\"deviceKey\", \"deviceKey\");\n\n        db.createObjectStore(\"notified_error_devices\", {\n            keyPath: [\"userId\", \"deviceId\"],\n        });\n    },\n    (db): void => {\n        db.createObjectStore(\"shared_history_inbound_group_sessions\", {\n            keyPath: [\"roomId\"],\n        });\n    },\n    (db): void => {\n        db.createObjectStore(\"parked_shared_history\", {\n            keyPath: [\"roomId\"],\n        });\n    },\n    // Expand as needed.\n];\nexport const VERSION = DB_MIGRATIONS.length;\n\nexport function upgradeDatabase(db: IDBDatabase, oldVersion: number): void {\n    logger.log(`Upgrading IndexedDBCryptoStore from version ${oldVersion}` + ` to ${VERSION}`);\n    DB_MIGRATIONS.forEach((migration, index) => {\n        if (oldVersion <= index) migration(db);\n    });\n}\n\nfunction createDatabase(db: IDBDatabase): void {\n    const outgoingRoomKeyRequestsStore = db.createObjectStore(\"outgoingRoomKeyRequests\", { keyPath: \"requestId\" });\n\n    // we assume that the RoomKeyRequestBody will have room_id and session_id\n    // properties, to make the index efficient.\n    outgoingRoomKeyRequestsStore.createIndex(\"session\", [\"requestBody.room_id\", \"requestBody.session_id\"]);\n\n    outgoingRoomKeyRequestsStore.createIndex(\"state\", \"state\");\n}\n\ninterface IWrappedIDBTransaction extends IDBTransaction {\n    _mx_abortexception: Error; // eslint-disable-line camelcase\n}\n\n/*\n * Aborts a transaction with a given exception\n * The transaction promise will be rejected with this exception.\n */\nfunction abortWithException(txn: IDBTransaction, e: Error): void {\n    // We cheekily stick our exception onto the transaction object here\n    // We could alternatively make the thing we pass back to the app\n    // an object containing the transaction and exception.\n    (txn as IWrappedIDBTransaction)._mx_abortexception = e;\n    try {\n        txn.abort();\n    } catch {\n        // sometimes we won't be able to abort the transaction\n        // (ie. if it's aborted or completed)\n    }\n}\n\nfunction promiseifyTxn<T>(txn: IDBTransaction): Promise<T | null> {\n    return new Promise((resolve, reject) => {\n        txn.oncomplete = (): void => {\n            if ((txn as IWrappedIDBTransaction)._mx_abortexception !== undefined) {\n                reject((txn as IWrappedIDBTransaction)._mx_abortexception);\n            }\n            resolve(null);\n        };\n        txn.onerror = (event): void => {\n            if ((txn as IWrappedIDBTransaction)._mx_abortexception !== undefined) {\n                reject((txn as IWrappedIDBTransaction)._mx_abortexception);\n            } else {\n                logger.log(\"Error performing indexeddb txn\", event);\n                reject(txn.error);\n            }\n        };\n        txn.onabort = (event): void => {\n            if ((txn as IWrappedIDBTransaction)._mx_abortexception !== undefined) {\n                reject((txn as IWrappedIDBTransaction)._mx_abortexception);\n            } else {\n                logger.log(\"Error performing indexeddb txn\", event);\n                reject(txn.error);\n            }\n        };\n    });\n}\n","/*\nCopyright 2017 - 2021 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { logger, type Logger } from \"../../logger.ts\";\nimport { LocalStorageCryptoStore } from \"./localStorage-crypto-store.ts\";\nimport { MemoryCryptoStore } from \"./memory-crypto-store.ts\";\nimport * as IndexedDBCryptoStoreBackend from \"./indexeddb-crypto-store-backend.ts\";\nimport { InvalidCryptoStoreError, InvalidCryptoStoreState } from \"../../errors.ts\";\nimport * as IndexedDBHelpers from \"../../indexeddb-helpers.ts\";\nimport {\n    type CryptoStore,\n    type ISession,\n    type SessionExtended,\n    type ISessionInfo,\n    type IWithheld,\n    MigrationState,\n    type Mode,\n    type SecretStorePrivateKeys,\n    ACCOUNT_OBJECT_KEY_MIGRATION_STATE,\n    type InboundGroupSessionData,\n    type IRoomEncryption,\n} from \"./base.ts\";\nimport { type CrossSigningKeyInfo } from \"../../crypto-api/index.ts\";\n\n/*\n * Internal module. indexeddb storage for e2e.\n */\n\n/**\n * An implementation of CryptoStore, which is normally backed by an indexeddb,\n * but with fallback to MemoryCryptoStore.\n */\nexport class IndexedDBCryptoStore implements CryptoStore {\n    public static STORE_ACCOUNT = \"account\";\n    public static STORE_SESSIONS = \"sessions\";\n    public static STORE_INBOUND_GROUP_SESSIONS = \"inbound_group_sessions\";\n    public static STORE_INBOUND_GROUP_SESSIONS_WITHHELD = \"inbound_group_sessions_withheld\";\n    public static STORE_SHARED_HISTORY_INBOUND_GROUP_SESSIONS = \"shared_history_inbound_group_sessions\";\n    public static STORE_PARKED_SHARED_HISTORY = \"parked_shared_history\";\n    public static STORE_DEVICE_DATA = \"device_data\";\n    public static STORE_ROOMS = \"rooms\";\n    public static STORE_BACKUP = \"sessions_needing_backup\";\n\n    public static exists(indexedDB: IDBFactory, dbName: string): Promise<boolean> {\n        return IndexedDBHelpers.exists(indexedDB, dbName);\n    }\n\n    /**\n     * Utility to check if a legacy crypto store exists and has not been migrated.\n     * Returns true if the store exists and has not been migrated, false otherwise.\n     */\n    public static existsAndIsNotMigrated(indexedDb: IDBFactory, dbName: string): Promise<boolean> {\n        return new Promise<boolean>((resolve, reject) => {\n            let exists = true;\n            const openDBRequest = indexedDb.open(dbName);\n            openDBRequest.onupgradeneeded = (): void => {\n                // Since we did not provide an explicit version when opening, this event\n                // should only fire if the DB did not exist before at any version.\n                exists = false;\n            };\n            openDBRequest.onblocked = (): void => reject(openDBRequest.error);\n            openDBRequest.onsuccess = (): void => {\n                const db = openDBRequest.result;\n                if (!exists) {\n                    db.close();\n                    // The DB did not exist before, but has been created as part of this\n                    // existence check. Delete it now to restore previous state. Delete can\n                    // actually take a while to complete in some browsers, so don't wait for\n                    // it. This won't block future open calls that a store might issue next to\n                    // properly set up the DB.\n                    indexedDb.deleteDatabase(dbName);\n                    resolve(false);\n                } else {\n                    const tx = db.transaction([IndexedDBCryptoStore.STORE_ACCOUNT], \"readonly\");\n                    const objectStore = tx.objectStore(IndexedDBCryptoStore.STORE_ACCOUNT);\n                    const getReq = objectStore.get(ACCOUNT_OBJECT_KEY_MIGRATION_STATE);\n\n                    getReq.onsuccess = (): void => {\n                        const migrationState = getReq.result ?? MigrationState.NOT_STARTED;\n                        resolve(migrationState === MigrationState.NOT_STARTED);\n                    };\n\n                    getReq.onerror = (): void => {\n                        reject(getReq.error);\n                    };\n\n                    db.close();\n                }\n            };\n            openDBRequest.onerror = (): void => reject(openDBRequest.error);\n        });\n    }\n\n    private backendPromise?: Promise<CryptoStore>;\n    private backend?: CryptoStore;\n\n    /**\n     * Create a new IndexedDBCryptoStore\n     *\n     * @param indexedDB -  global indexedDB instance\n     * @param dbName -   name of db to connect to\n     */\n    public constructor(\n        private readonly indexedDB: IDBFactory,\n        private readonly dbName: string,\n    ) {}\n\n    /**\n     * Returns true if this CryptoStore has ever been initialised (ie, it might contain data).\n     *\n     * Implementation of {@link CryptoStore.containsData}.\n     *\n     * @internal\n     */\n    public async containsData(): Promise<boolean> {\n        return IndexedDBCryptoStore.exists(this.indexedDB, this.dbName);\n    }\n\n    /**\n     * Ensure the database exists and is up-to-date, or fall back to\n     * a local storage or in-memory store.\n     *\n     * This must be called before the store can be used.\n     *\n     * @returns resolves to either an IndexedDBCryptoStoreBackend.Backend,\n     * or a MemoryCryptoStore\n     */\n    public startup(): Promise<CryptoStore> {\n        if (this.backendPromise) {\n            return this.backendPromise;\n        }\n\n        this.backendPromise = new Promise<CryptoStore>((resolve, reject) => {\n            if (!this.indexedDB) {\n                reject(new Error(\"no indexeddb support available\"));\n                return;\n            }\n\n            logger.log(`connecting to indexeddb ${this.dbName}`);\n\n            const req = this.indexedDB.open(this.dbName, IndexedDBCryptoStoreBackend.VERSION);\n\n            req.onupgradeneeded = (ev): void => {\n                const db = req.result;\n                const oldVersion = ev.oldVersion;\n                IndexedDBCryptoStoreBackend.upgradeDatabase(db, oldVersion);\n            };\n\n            req.onblocked = (): void => {\n                logger.log(`can't yet open IndexedDBCryptoStore because it is open elsewhere`);\n            };\n\n            req.onerror = (ev): void => {\n                logger.log(\"Error connecting to indexeddb\", ev);\n                reject(req.error);\n            };\n\n            req.onsuccess = (): void => {\n                const db = req.result;\n\n                logger.log(`connected to indexeddb ${this.dbName}`);\n                resolve(new IndexedDBCryptoStoreBackend.Backend(db));\n            };\n        })\n            .then((backend) => {\n                // Edge has IndexedDB but doesn't support compund keys which we use fairly extensively.\n                // Try a dummy query which will fail if the browser doesn't support compund keys, so\n                // we can fall back to a different backend.\n                return backend\n                    .doTxn(\n                        \"readonly\",\n                        [\n                            IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS,\n                            IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS_WITHHELD,\n                        ],\n                        (txn) => {\n                            backend.getEndToEndInboundGroupSession(\"\", \"\", txn, () => {});\n                        },\n                    )\n                    .then(() => backend);\n            })\n            .catch((e) => {\n                if (e.name === \"VersionError\") {\n                    logger.warn(\"Crypto DB is too new for us to use!\", e);\n                    // don't fall back to a different store: the user has crypto data\n                    // in this db so we should use it or nothing at all.\n                    throw new InvalidCryptoStoreError(InvalidCryptoStoreState.TooNew);\n                }\n                logger.warn(\n                    `unable to connect to indexeddb ${this.dbName}` + `: falling back to localStorage store: ${e}`,\n                );\n\n                try {\n                    if (!(globalThis.localStorage instanceof Storage)) {\n                        throw new Error(\"localStorage is not available\");\n                    }\n                    return new LocalStorageCryptoStore(globalThis.localStorage);\n                } catch (e) {\n                    logger.warn(`Unable to open localStorage: falling back to in-memory store: ${e}`);\n                    return new MemoryCryptoStore();\n                }\n            })\n            .then((backend) => {\n                this.backend = backend;\n                return backend;\n            });\n\n        return this.backendPromise;\n    }\n\n    /**\n     * Delete all data from this store.\n     *\n     * @returns resolves when the store has been cleared.\n     */\n    public deleteAllData(): Promise<void> {\n        return new Promise<void>((resolve, reject) => {\n            if (!this.indexedDB) {\n                reject(new Error(\"no indexeddb support available\"));\n                return;\n            }\n\n            logger.log(`Removing indexeddb instance: ${this.dbName}`);\n            const req = this.indexedDB.deleteDatabase(this.dbName);\n\n            req.onblocked = (): void => {\n                logger.log(`can't yet delete IndexedDBCryptoStore because it is open elsewhere`);\n            };\n\n            req.onerror = (ev): void => {\n                logger.log(\"Error deleting data from indexeddb\", ev);\n                reject(req.error);\n            };\n\n            req.onsuccess = (): void => {\n                logger.log(`Removed indexeddb instance: ${this.dbName}`);\n                resolve();\n            };\n        }).catch((e) => {\n            // in firefox, with indexedDB disabled, this fails with a\n            // DOMError. We treat this as non-fatal, so that people can\n            // still use the app.\n            logger.warn(`unable to delete IndexedDBCryptoStore: ${e}`);\n        });\n    }\n\n    /**\n     * Get data on how much of the libolm to Rust Crypto migration has been done.\n     *\n     * Implementation of {@link CryptoStore.getMigrationState}.\n     *\n     * @internal\n     */\n    public getMigrationState(): Promise<MigrationState> {\n        return this.backend!.getMigrationState();\n    }\n\n    /**\n     * Set data on how much of the libolm to Rust Crypto migration has been done.\n     *\n     * Implementation of {@link CryptoStore.setMigrationState}.\n     *\n     * @internal\n     */\n    public setMigrationState(migrationState: MigrationState): Promise<void> {\n        return this.backend!.setMigrationState(migrationState);\n    }\n\n    // Olm Account\n\n    /*\n     * Get the account pickle from the store.\n     * This requires an active transaction. See doTxn().\n     *\n     * @param txn - An active transaction. See doTxn().\n     * @param func - Called with the account pickle\n     */\n    public getAccount(txn: IDBTransaction, func: (accountPickle: string | null) => void): void {\n        this.backend!.getAccount(txn, func);\n    }\n\n    /**\n     * Write the account pickle to the store.\n     * This requires an active transaction. See doTxn().\n     *\n     * @param txn - An active transaction. See doTxn().\n     * @param accountPickle - The new account pickle to store.\n     */\n    public storeAccount(txn: IDBTransaction, accountPickle: string): void {\n        this.backend!.storeAccount(txn, accountPickle);\n    }\n\n    /**\n     * Get the public part of the cross-signing keys (eg. self-signing key,\n     * user signing key).\n     *\n     * @param txn - An active transaction. See doTxn().\n     * @param func - Called with the account keys object:\n     *        `{ key_type: base64 encoded seed }` where key type = user_signing_key_seed or self_signing_key_seed\n     */\n    public getCrossSigningKeys(\n        txn: IDBTransaction,\n        func: (keys: Record<string, CrossSigningKeyInfo> | null) => void,\n    ): void {\n        this.backend!.getCrossSigningKeys(txn, func);\n    }\n\n    /**\n     * @param txn - An active transaction. See doTxn().\n     * @param func - Called with the private key\n     * @param type - A key type\n     */\n    public getSecretStorePrivateKey<K extends keyof SecretStorePrivateKeys>(\n        txn: IDBTransaction,\n        func: (key: SecretStorePrivateKeys[K] | null) => void,\n        type: K,\n    ): void {\n        this.backend!.getSecretStorePrivateKey(txn, func, type);\n    }\n\n    /**\n     * Write the cross-signing private keys back to the store\n     *\n     * @param txn - An active transaction. See doTxn().\n     * @param type - The type of cross-signing private key to store\n     * @param key - keys object as getCrossSigningKeys()\n     */\n    public storeSecretStorePrivateKey<K extends keyof SecretStorePrivateKeys>(\n        txn: IDBTransaction,\n        type: K,\n        key: SecretStorePrivateKeys[K],\n    ): void {\n        this.backend!.storeSecretStorePrivateKey(txn, type, key);\n    }\n\n    // Olm sessions\n\n    /**\n     * Returns the number of end-to-end sessions in the store\n     * @param txn - An active transaction. See doTxn().\n     * @param func - Called with the count of sessions\n     */\n    public countEndToEndSessions(txn: IDBTransaction, func: (count: number) => void): void {\n        this.backend!.countEndToEndSessions(txn, func);\n    }\n\n    /**\n     * Retrieve a specific end-to-end session between the logged-in user\n     * and another device.\n     * @param deviceKey - The public key of the other device.\n     * @param sessionId - The ID of the session to retrieve\n     * @param txn - An active transaction. See doTxn().\n     * @param func - Called with A map from sessionId\n     *     to session information object with 'session' key being the\n     *     Base64 end-to-end session and lastReceivedMessageTs being the\n     *     timestamp in milliseconds at which the session last received\n     *     a message.\n     */\n    public getEndToEndSession(\n        deviceKey: string,\n        sessionId: string,\n        txn: IDBTransaction,\n        func: (session: ISessionInfo | null) => void,\n    ): void {\n        this.backend!.getEndToEndSession(deviceKey, sessionId, txn, func);\n    }\n\n    /**\n     * Retrieve the end-to-end sessions between the logged-in user and another\n     * device.\n     * @param deviceKey - The public key of the other device.\n     * @param txn - An active transaction. See doTxn().\n     * @param func - Called with A map from sessionId\n     *     to session information object with 'session' key being the\n     *     Base64 end-to-end session and lastReceivedMessageTs being the\n     *     timestamp in milliseconds at which the session last received\n     *     a message.\n     */\n    public getEndToEndSessions(\n        deviceKey: string,\n        txn: IDBTransaction,\n        func: (sessions: { [sessionId: string]: ISessionInfo }) => void,\n    ): void {\n        this.backend!.getEndToEndSessions(deviceKey, txn, func);\n    }\n\n    /**\n     * Store a session between the logged-in user and another device\n     * @param deviceKey - The public key of the other device.\n     * @param sessionId - The ID for this end-to-end session.\n     * @param sessionInfo - Session information object\n     * @param txn - An active transaction. See doTxn().\n     */\n    public storeEndToEndSession(\n        deviceKey: string,\n        sessionId: string,\n        sessionInfo: ISessionInfo,\n        txn: IDBTransaction,\n    ): void {\n        this.backend!.storeEndToEndSession(deviceKey, sessionId, sessionInfo, txn);\n    }\n\n    /**\n     * Count the number of Megolm sessions in the database.\n     *\n     * Implementation of {@link CryptoStore.countEndToEndInboundGroupSessions}.\n     *\n     * @internal\n     */\n    public countEndToEndInboundGroupSessions(): Promise<number> {\n        return this.backend!.countEndToEndInboundGroupSessions();\n    }\n\n    /**\n     * Fetch a batch of Olm sessions from the database.\n     *\n     * Implementation of {@link CryptoStore.getEndToEndSessionsBatch}.\n     *\n     * @internal\n     */\n    public getEndToEndSessionsBatch(): Promise<null | ISessionInfo[]> {\n        return this.backend!.getEndToEndSessionsBatch();\n    }\n\n    /**\n     * Delete a batch of Olm sessions from the database.\n     *\n     * Implementation of {@link CryptoStore.deleteEndToEndSessionsBatch}.\n     *\n     * @internal\n     */\n    public deleteEndToEndSessionsBatch(sessions: { deviceKey: string; sessionId: string }[]): Promise<void> {\n        return this.backend!.deleteEndToEndSessionsBatch(sessions);\n    }\n\n    // Inbound group sessions\n\n    /**\n     * Retrieve the end-to-end inbound group session for a given\n     * server key and session ID\n     * @param senderCurve25519Key - The sender's curve 25519 key\n     * @param sessionId - The ID of the session\n     * @param txn - An active transaction. See doTxn().\n     * @param func - Called with A map from sessionId\n     *     to Base64 end-to-end session.\n     */\n    public getEndToEndInboundGroupSession(\n        senderCurve25519Key: string,\n        sessionId: string,\n        txn: IDBTransaction,\n        func: (groupSession: InboundGroupSessionData | null, groupSessionWithheld: IWithheld | null) => void,\n    ): void {\n        this.backend!.getEndToEndInboundGroupSession(senderCurve25519Key, sessionId, txn, func);\n    }\n\n    /**\n     * Writes an end-to-end inbound group session to the store.\n     * If there already exists an inbound group session with the same\n     * senderCurve25519Key and sessionID, it will be overwritten.\n     * @param senderCurve25519Key - The sender's curve 25519 key\n     * @param sessionId - The ID of the session\n     * @param sessionData - The session data structure\n     * @param txn - An active transaction. See doTxn().\n     */\n    public storeEndToEndInboundGroupSession(\n        senderCurve25519Key: string,\n        sessionId: string,\n        sessionData: InboundGroupSessionData,\n        txn: IDBTransaction,\n    ): void {\n        this.backend!.storeEndToEndInboundGroupSession(senderCurve25519Key, sessionId, sessionData, txn);\n    }\n\n    /**\n     * Fetch a batch of Megolm sessions from the database.\n     *\n     * Implementation of {@link CryptoStore.getEndToEndInboundGroupSessionsBatch}.\n     *\n     * @internal\n     */\n    public getEndToEndInboundGroupSessionsBatch(): Promise<SessionExtended[] | null> {\n        return this.backend!.getEndToEndInboundGroupSessionsBatch();\n    }\n\n    /**\n     * Delete a batch of Megolm sessions from the database.\n     *\n     * Implementation of {@link CryptoStore.deleteEndToEndInboundGroupSessionsBatch}.\n     *\n     * @internal\n     */\n    public deleteEndToEndInboundGroupSessionsBatch(\n        sessions: { senderKey: string; sessionId: string }[],\n    ): Promise<void> {\n        return this.backend!.deleteEndToEndInboundGroupSessionsBatch(sessions);\n    }\n\n    /**\n     * Get an object of `roomId->roomInfo` for all e2e rooms in the store\n     * @param txn - An active transaction. See doTxn().\n     * @param func - Function called with the end-to-end encrypted rooms\n     */\n    public getEndToEndRooms(txn: IDBTransaction, func: (rooms: Record<string, IRoomEncryption>) => void): void {\n        this.backend!.getEndToEndRooms(txn, func);\n    }\n\n    /**\n     * Mark sessions as needing to be backed up.\n     * @param sessions - The sessions that need to be backed up.\n     * @param txn - An active transaction. See doTxn(). (optional)\n     * @returns resolves when the sessions are marked\n     */\n    public markSessionsNeedingBackup(sessions: ISession[], txn?: IDBTransaction): Promise<void> {\n        return this.backend!.markSessionsNeedingBackup(sessions, txn);\n    }\n\n    /**\n     * Perform a transaction on the crypto store. Any store methods\n     * that require a transaction (txn) object to be passed in may\n     * only be called within a callback of either this function or\n     * one of the store functions operating on the same transaction.\n     *\n     * @param mode - 'readwrite' if you need to call setter\n     *     functions with this transaction. Otherwise, 'readonly'.\n     * @param stores - List IndexedDBCryptoStore.STORE_*\n     *     options representing all types of object that will be\n     *     accessed or written to with this transaction.\n     * @param func - Function called with the\n     *     transaction object: an opaque object that should be passed\n     *     to store functions.\n     * @param log - A possibly customised log\n     * @returns Promise that resolves with the result of the `func`\n     *     when the transaction is complete. If the backend is\n     *     async (ie. the indexeddb backend) any of the callback\n     *     functions throwing an exception will cause this promise to\n     *     reject with that exception. On synchronous backends, the\n     *     exception will propagate to the caller of the getFoo method.\n     */\n    public doTxn<T>(mode: Mode, stores: Iterable<string>, func: (txn: IDBTransaction) => T, log?: Logger): Promise<T> {\n        return this.backend!.doTxn<T>(mode, stores, func as (txn: unknown) => T, log);\n    }\n}\n","/*\nCopyright 2017 - 2021 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { logger } from \"../../logger.ts\";\nimport { MemoryCryptoStore } from \"./memory-crypto-store.ts\";\nimport {\n    type CryptoStore,\n    type ISession,\n    type SessionExtended,\n    type ISessionInfo,\n    type IWithheld,\n    MigrationState,\n    type Mode,\n    type SecretStorePrivateKeys,\n    SESSION_BATCH_SIZE,\n    type InboundGroupSessionData,\n    type IRoomEncryption,\n} from \"./base.ts\";\nimport { type CrossSigningKeyInfo } from \"../../crypto-api/index.ts\";\n\n/**\n * Internal module. Partial localStorage backed storage for e2e.\n * This is not a full crypto store, just the in-memory store with\n * some things backed by localStorage. It exists because indexedDB\n * is broken in Firefox private mode or set to, \"will not remember\n * history\".\n */\n\nconst E2E_PREFIX = \"crypto.\";\nconst KEY_END_TO_END_MIGRATION_STATE = E2E_PREFIX + \"migration\";\nconst KEY_END_TO_END_ACCOUNT = E2E_PREFIX + \"account\";\nconst KEY_CROSS_SIGNING_KEYS = E2E_PREFIX + \"cross_signing_keys\";\nconst KEY_INBOUND_SESSION_PREFIX = E2E_PREFIX + \"inboundgroupsessions/\";\nconst KEY_INBOUND_SESSION_WITHHELD_PREFIX = E2E_PREFIX + \"inboundgroupsessions.withheld/\";\nconst KEY_ROOMS_PREFIX = E2E_PREFIX + \"rooms/\";\nconst KEY_SESSIONS_NEEDING_BACKUP = E2E_PREFIX + \"sessionsneedingbackup\";\n\nfunction keyEndToEndSessions(deviceKey: string): string {\n    return E2E_PREFIX + \"sessions/\" + deviceKey;\n}\n\nfunction keyEndToEndInboundGroupSession(senderKey: string, sessionId: string): string {\n    return KEY_INBOUND_SESSION_PREFIX + senderKey + \"/\" + sessionId;\n}\n\nfunction keyEndToEndInboundGroupSessionWithheld(senderKey: string, sessionId: string): string {\n    return KEY_INBOUND_SESSION_WITHHELD_PREFIX + senderKey + \"/\" + sessionId;\n}\n\nfunction keyEndToEndRoomsPrefix(roomId: string): string {\n    return KEY_ROOMS_PREFIX + roomId;\n}\n\nexport class LocalStorageCryptoStore extends MemoryCryptoStore implements CryptoStore {\n    public static exists(store: Storage): boolean {\n        const length = store.length;\n        for (let i = 0; i < length; i++) {\n            if (store.key(i)?.startsWith(E2E_PREFIX)) {\n                return true;\n            }\n        }\n        return false;\n    }\n\n    public constructor(private readonly store: Storage) {\n        super();\n    }\n\n    /**\n     * Returns true if this CryptoStore has ever been initialised (ie, it might contain data).\n     *\n     * Implementation of {@link CryptoStore.containsData}.\n     *\n     * @internal\n     */\n    public async containsData(): Promise<boolean> {\n        return LocalStorageCryptoStore.exists(this.store);\n    }\n\n    /**\n     * Get data on how much of the libolm to Rust Crypto migration has been done.\n     *\n     * Implementation of {@link CryptoStore.getMigrationState}.\n     *\n     * @internal\n     */\n    public async getMigrationState(): Promise<MigrationState> {\n        return getJsonItem(this.store, KEY_END_TO_END_MIGRATION_STATE) ?? MigrationState.NOT_STARTED;\n    }\n\n    /**\n     * Set data on how much of the libolm to Rust Crypto migration has been done.\n     *\n     * Implementation of {@link CryptoStore.setMigrationState}.\n     *\n     * @internal\n     */\n    public async setMigrationState(migrationState: MigrationState): Promise<void> {\n        setJsonItem(this.store, KEY_END_TO_END_MIGRATION_STATE, migrationState);\n    }\n\n    // Olm Sessions\n\n    public countEndToEndSessions(txn: unknown, func: (count: number) => void): void {\n        let count = 0;\n        for (let i = 0; i < this.store.length; ++i) {\n            const key = this.store.key(i);\n            if (key?.startsWith(keyEndToEndSessions(\"\"))) {\n                const sessions = getJsonItem(this.store, key);\n                count += Object.keys(sessions ?? {}).length;\n            }\n        }\n        func(count);\n    }\n\n    // eslint-disable-next-line @typescript-eslint/naming-convention\n    private _getEndToEndSessions(deviceKey: string): Record<string, ISessionInfo> {\n        const sessions = getJsonItem(this.store, keyEndToEndSessions(deviceKey));\n        const fixedSessions: Record<string, ISessionInfo> = {};\n\n        // fix up any old sessions to be objects rather than just the base64 pickle\n        for (const [sid, val] of Object.entries(sessions || {})) {\n            if (typeof val === \"string\") {\n                fixedSessions[sid] = {\n                    session: val,\n                };\n            } else {\n                fixedSessions[sid] = val;\n            }\n        }\n\n        return fixedSessions;\n    }\n\n    public getEndToEndSession(\n        deviceKey: string,\n        sessionId: string,\n        txn: unknown,\n        func: (session: ISessionInfo) => void,\n    ): void {\n        const sessions = this._getEndToEndSessions(deviceKey);\n        func(sessions[sessionId] ?? {});\n    }\n\n    public getEndToEndSessions(\n        deviceKey: string,\n        txn: unknown,\n        func: (sessions: { [sessionId: string]: ISessionInfo }) => void,\n    ): void {\n        func(this._getEndToEndSessions(deviceKey) ?? {});\n    }\n\n    public storeEndToEndSession(deviceKey: string, sessionId: string, sessionInfo: ISessionInfo, txn: unknown): void {\n        const sessions = this._getEndToEndSessions(deviceKey) || {};\n        sessions[sessionId] = sessionInfo;\n        setJsonItem(this.store, keyEndToEndSessions(deviceKey), sessions);\n    }\n\n    /**\n     * Fetch a batch of Olm sessions from the database.\n     *\n     * Implementation of {@link CryptoStore.getEndToEndSessionsBatch}.\n     *\n     * @internal\n     */\n    public async getEndToEndSessionsBatch(): Promise<null | ISessionInfo[]> {\n        const result: ISessionInfo[] = [];\n        for (let i = 0; i < this.store.length; ++i) {\n            if (this.store.key(i)?.startsWith(keyEndToEndSessions(\"\"))) {\n                const deviceKey = this.store.key(i)!.split(\"/\")[1];\n                for (const session of Object.values(this._getEndToEndSessions(deviceKey))) {\n                    result.push(session);\n                    if (result.length >= SESSION_BATCH_SIZE) {\n                        return result;\n                    }\n                }\n            }\n        }\n\n        if (result.length === 0) {\n            // No sessions left.\n            return null;\n        }\n\n        // There are fewer sessions than the batch size; return the final batch of sessions.\n        return result;\n    }\n\n    /**\n     * Delete a batch of Olm sessions from the database.\n     *\n     * Implementation of {@link CryptoStore.deleteEndToEndSessionsBatch}.\n     *\n     * @internal\n     */\n    public async deleteEndToEndSessionsBatch(sessions: { deviceKey: string; sessionId: string }[]): Promise<void> {\n        for (const { deviceKey, sessionId } of sessions) {\n            const deviceSessions = this._getEndToEndSessions(deviceKey) || {};\n            delete deviceSessions[sessionId];\n            if (Object.keys(deviceSessions).length === 0) {\n                // No more sessions for this device.\n                this.store.removeItem(keyEndToEndSessions(deviceKey));\n            } else {\n                setJsonItem(this.store, keyEndToEndSessions(deviceKey), deviceSessions);\n            }\n        }\n    }\n\n    // Inbound Group Sessions\n\n    public getEndToEndInboundGroupSession(\n        senderCurve25519Key: string,\n        sessionId: string,\n        txn: unknown,\n        func: (groupSession: InboundGroupSessionData | null, groupSessionWithheld: IWithheld | null) => void,\n    ): void {\n        func(\n            getJsonItem(this.store, keyEndToEndInboundGroupSession(senderCurve25519Key, sessionId)),\n            getJsonItem(this.store, keyEndToEndInboundGroupSessionWithheld(senderCurve25519Key, sessionId)),\n        );\n    }\n\n    public storeEndToEndInboundGroupSession(\n        senderCurve25519Key: string,\n        sessionId: string,\n        sessionData: InboundGroupSessionData,\n        txn: unknown,\n    ): void {\n        setJsonItem(this.store, keyEndToEndInboundGroupSession(senderCurve25519Key, sessionId), sessionData);\n    }\n\n    /**\n     * Count the number of Megolm sessions in the database.\n     *\n     * Implementation of {@link CryptoStore.countEndToEndInboundGroupSessions}.\n     *\n     * @internal\n     */\n    public async countEndToEndInboundGroupSessions(): Promise<number> {\n        let count = 0;\n        for (let i = 0; i < this.store.length; ++i) {\n            const key = this.store.key(i);\n            if (key?.startsWith(KEY_INBOUND_SESSION_PREFIX)) {\n                count += 1;\n            }\n        }\n        return count;\n    }\n\n    /**\n     * Fetch a batch of Megolm sessions from the database.\n     *\n     * Implementation of {@link CryptoStore.getEndToEndInboundGroupSessionsBatch}.\n     *\n     * @internal\n     */\n    public async getEndToEndInboundGroupSessionsBatch(): Promise<SessionExtended[] | null> {\n        const sessionsNeedingBackup = getJsonItem<string[]>(this.store, KEY_SESSIONS_NEEDING_BACKUP) || {};\n        const result: SessionExtended[] = [];\n        for (let i = 0; i < this.store.length; ++i) {\n            const key = this.store.key(i);\n            if (key?.startsWith(KEY_INBOUND_SESSION_PREFIX)) {\n                const key2 = key.slice(KEY_INBOUND_SESSION_PREFIX.length);\n\n                // we can't use split, as the components we are trying to split out\n                // might themselves contain '/' characters. We rely on the\n                // senderKey being a (32-byte) curve25519 key, base64-encoded\n                // (hence 43 characters long).\n\n                result.push({\n                    senderKey: key2.slice(0, 43),\n                    sessionId: key2.slice(44),\n                    sessionData: getJsonItem(this.store, key)!,\n                    needsBackup: key2 in sessionsNeedingBackup,\n                });\n\n                if (result.length >= SESSION_BATCH_SIZE) {\n                    return result;\n                }\n            }\n        }\n\n        if (result.length === 0) {\n            // No sessions left.\n            return null;\n        }\n\n        // There are fewer sessions than the batch size; return the final batch of sessions.\n        return result;\n    }\n\n    /**\n     * Delete a batch of Megolm sessions from the database.\n     *\n     * Implementation of {@link CryptoStore.deleteEndToEndInboundGroupSessionsBatch}.\n     *\n     * @internal\n     */\n    public async deleteEndToEndInboundGroupSessionsBatch(\n        sessions: { senderKey: string; sessionId: string }[],\n    ): Promise<void> {\n        for (const { senderKey, sessionId } of sessions) {\n            const k = keyEndToEndInboundGroupSession(senderKey, sessionId);\n            this.store.removeItem(k);\n        }\n    }\n\n    public getEndToEndRooms(txn: unknown, func: (rooms: Record<string, IRoomEncryption>) => void): void {\n        const result: Record<string, IRoomEncryption> = {};\n        const prefix = keyEndToEndRoomsPrefix(\"\");\n\n        for (let i = 0; i < this.store.length; ++i) {\n            const key = this.store.key(i);\n            if (key?.startsWith(prefix)) {\n                const roomId = key.slice(prefix.length);\n                result[roomId] = getJsonItem(this.store, key)!;\n            }\n        }\n        func(result);\n    }\n\n    public markSessionsNeedingBackup(sessions: ISession[]): Promise<void> {\n        const sessionsNeedingBackup =\n            getJsonItem<{\n                [senderKeySessionId: string]: boolean;\n            }>(this.store, KEY_SESSIONS_NEEDING_BACKUP) || {};\n        for (const session of sessions) {\n            sessionsNeedingBackup[session.senderKey + \"/\" + session.sessionId] = true;\n        }\n        setJsonItem(this.store, KEY_SESSIONS_NEEDING_BACKUP, sessionsNeedingBackup);\n        return Promise.resolve();\n    }\n\n    /**\n     * Delete all data from this store.\n     *\n     * @returns Promise which resolves when the store has been cleared.\n     */\n    public deleteAllData(): Promise<void> {\n        this.store.removeItem(KEY_END_TO_END_ACCOUNT);\n        return Promise.resolve();\n    }\n\n    // Olm account\n\n    public getAccount(txn: unknown, func: (accountPickle: string | null) => void): void {\n        const accountPickle = getJsonItem<string>(this.store, KEY_END_TO_END_ACCOUNT);\n        func(accountPickle);\n    }\n\n    public storeAccount(txn: unknown, accountPickle: string): void {\n        setJsonItem(this.store, KEY_END_TO_END_ACCOUNT, accountPickle);\n    }\n\n    public getCrossSigningKeys(txn: unknown, func: (keys: Record<string, CrossSigningKeyInfo> | null) => void): void {\n        const keys = getJsonItem<Record<string, CrossSigningKeyInfo>>(this.store, KEY_CROSS_SIGNING_KEYS);\n        func(keys);\n    }\n\n    public getSecretStorePrivateKey<K extends keyof SecretStorePrivateKeys>(\n        txn: unknown,\n        func: (key: SecretStorePrivateKeys[K] | null) => void,\n        type: K,\n    ): void {\n        const key = getJsonItem<SecretStorePrivateKeys[K]>(this.store, E2E_PREFIX + `ssss_cache.${type}`);\n        func(key);\n    }\n\n    public storeSecretStorePrivateKey<K extends keyof SecretStorePrivateKeys>(\n        txn: unknown,\n        type: K,\n        key: SecretStorePrivateKeys[K],\n    ): void {\n        setJsonItem(this.store, E2E_PREFIX + `ssss_cache.${type}`, key);\n    }\n\n    public doTxn<T>(mode: Mode, stores: Iterable<string>, func: (txn: unknown) => T): Promise<T> {\n        return Promise.resolve(func(null));\n    }\n}\n\nfunction getJsonItem<T>(store: Storage, key: string): T | null {\n    try {\n        // if the key is absent, store.getItem() returns null, and\n        // JSON.parse(null) === null, so this returns null.\n        return JSON.parse(store.getItem(key)!);\n    } catch (e) {\n        logger.log(\"Error: Failed to get key %s: %s\", key, (<Error>e).message);\n        logger.log((<Error>e).stack);\n    }\n    return null;\n}\n\nfunction setJsonItem<T>(store: Storage, key: string, val: T): void {\n    store.setItem(key, JSON.stringify(val));\n}\n","/*\nCopyright 2017 - 2021 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { safeSet } from \"../../utils.ts\";\nimport {\n    type CryptoStore,\n    type ISession,\n    type SessionExtended,\n    type ISessionInfo,\n    type IWithheld,\n    MigrationState,\n    type Mode,\n    type SecretStorePrivateKeys,\n    SESSION_BATCH_SIZE,\n    type InboundGroupSessionData,\n    type IRoomEncryption,\n} from \"./base.ts\";\nimport { type CrossSigningKeyInfo } from \"../../crypto-api/index.ts\";\n\nfunction encodeSessionKey(senderCurve25519Key: string, sessionId: string): string {\n    return encodeURIComponent(senderCurve25519Key) + \"/\" + encodeURIComponent(sessionId);\n}\n\nfunction decodeSessionKey(key: string): { senderKey: string; sessionId: string } {\n    const keyParts = key.split(\"/\");\n    const senderKey = decodeURIComponent(keyParts[0]);\n    const sessionId = decodeURIComponent(keyParts[1]);\n    return { senderKey, sessionId };\n}\n\n/**\n * Internal module. in-memory storage for e2e.\n */\n\nexport class MemoryCryptoStore implements CryptoStore {\n    private migrationState: MigrationState = MigrationState.NOT_STARTED;\n    private account: string | null = null;\n    private crossSigningKeys: Record<string, CrossSigningKeyInfo> | null = null;\n    private privateKeys: Partial<SecretStorePrivateKeys> = {};\n\n    private sessions: { [deviceKey: string]: { [sessionId: string]: ISessionInfo } } = {};\n    private inboundGroupSessions: { [sessionKey: string]: InboundGroupSessionData } = {};\n    private inboundGroupSessionsWithheld: Record<string, IWithheld> = {};\n    // Opaque device data object\n    private rooms: { [roomId: string]: IRoomEncryption } = {};\n    private sessionsNeedingBackup: { [sessionKey: string]: boolean } = {};\n\n    /**\n     * Returns true if this CryptoStore has ever been initialised (ie, it might contain data).\n     *\n     * Implementation of {@link CryptoStore.containsData}.\n     *\n     * @internal\n     */\n    public async containsData(): Promise<boolean> {\n        // If it contains anything, it should contain an account.\n        return this.account !== null;\n    }\n\n    /**\n     * Ensure the database exists and is up-to-date.\n     *\n     * This must be called before the store can be used.\n     *\n     * @returns resolves to the store.\n     */\n    public async startup(): Promise<CryptoStore> {\n        // No startup work to do for the memory store.\n        return this;\n    }\n\n    /**\n     * Delete all data from this store.\n     *\n     * @returns Promise which resolves when the store has been cleared.\n     */\n    public deleteAllData(): Promise<void> {\n        return Promise.resolve();\n    }\n\n    /**\n     * Get data on how much of the libolm to Rust Crypto migration has been done.\n     *\n     * Implementation of {@link CryptoStore.getMigrationState}.\n     *\n     * @internal\n     */\n    public async getMigrationState(): Promise<MigrationState> {\n        return this.migrationState;\n    }\n\n    /**\n     * Set data on how much of the libolm to Rust Crypto migration has been done.\n     *\n     * Implementation of {@link CryptoStore.setMigrationState}.\n     *\n     * @internal\n     */\n    public async setMigrationState(migrationState: MigrationState): Promise<void> {\n        this.migrationState = migrationState;\n    }\n\n    // Olm Account\n\n    public getAccount(txn: unknown, func: (accountPickle: string | null) => void): void {\n        func(this.account);\n    }\n\n    public storeAccount(txn: unknown, accountPickle: string): void {\n        this.account = accountPickle;\n    }\n\n    public getCrossSigningKeys(txn: unknown, func: (keys: Record<string, CrossSigningKeyInfo> | null) => void): void {\n        func(this.crossSigningKeys);\n    }\n\n    public getSecretStorePrivateKey<K extends keyof SecretStorePrivateKeys>(\n        txn: unknown,\n        func: (key: SecretStorePrivateKeys[K] | null) => void,\n        type: K,\n    ): void {\n        const result = this.privateKeys[type] as SecretStorePrivateKeys[K] | undefined;\n        func(result || null);\n    }\n\n    public storeSecretStorePrivateKey<K extends keyof SecretStorePrivateKeys>(\n        txn: unknown,\n        type: K,\n        key: SecretStorePrivateKeys[K],\n    ): void {\n        this.privateKeys[type] = key;\n    }\n\n    // Olm Sessions\n\n    public countEndToEndSessions(txn: unknown, func: (count: number) => void): void {\n        let count = 0;\n        for (const deviceSessions of Object.values(this.sessions)) {\n            count += Object.keys(deviceSessions).length;\n        }\n        func(count);\n    }\n\n    public getEndToEndSession(\n        deviceKey: string,\n        sessionId: string,\n        txn: unknown,\n        func: (session: ISessionInfo) => void,\n    ): void {\n        const deviceSessions = this.sessions[deviceKey] || {};\n        func(deviceSessions[sessionId] || null);\n    }\n\n    public getEndToEndSessions(\n        deviceKey: string,\n        txn: unknown,\n        func: (sessions: { [sessionId: string]: ISessionInfo }) => void,\n    ): void {\n        func(this.sessions[deviceKey] || {});\n    }\n\n    public storeEndToEndSession(deviceKey: string, sessionId: string, sessionInfo: ISessionInfo, txn: unknown): void {\n        let deviceSessions = this.sessions[deviceKey];\n        if (deviceSessions === undefined) {\n            deviceSessions = {};\n            this.sessions[deviceKey] = deviceSessions;\n        }\n        safeSet(deviceSessions, sessionId, sessionInfo);\n    }\n\n    /**\n     * Fetch a batch of Olm sessions from the database.\n     *\n     * Implementation of {@link CryptoStore.getEndToEndSessionsBatch}.\n     *\n     * @internal\n     */\n    public async getEndToEndSessionsBatch(): Promise<null | ISessionInfo[]> {\n        const result: ISessionInfo[] = [];\n        for (const deviceSessions of Object.values(this.sessions)) {\n            for (const session of Object.values(deviceSessions)) {\n                result.push(session);\n                if (result.length >= SESSION_BATCH_SIZE) {\n                    return result;\n                }\n            }\n        }\n\n        if (result.length === 0) {\n            // No sessions left.\n            return null;\n        }\n\n        // There are fewer sessions than the batch size; return the final batch of sessions.\n        return result;\n    }\n\n    /**\n     * Delete a batch of Olm sessions from the database.\n     *\n     * Implementation of {@link CryptoStore.deleteEndToEndSessionsBatch}.\n     *\n     * @internal\n     */\n    public async deleteEndToEndSessionsBatch(sessions: { deviceKey: string; sessionId: string }[]): Promise<void> {\n        for (const { deviceKey, sessionId } of sessions) {\n            const deviceSessions = this.sessions[deviceKey] || {};\n            delete deviceSessions[sessionId];\n            if (Object.keys(deviceSessions).length === 0) {\n                // No more sessions for this device.\n                delete this.sessions[deviceKey];\n            }\n        }\n    }\n\n    // Inbound Group Sessions\n\n    public getEndToEndInboundGroupSession(\n        senderCurve25519Key: string,\n        sessionId: string,\n        txn: unknown,\n        func: (groupSession: InboundGroupSessionData | null, groupSessionWithheld: IWithheld | null) => void,\n    ): void {\n        const k = encodeSessionKey(senderCurve25519Key, sessionId);\n        func(this.inboundGroupSessions[k] || null, this.inboundGroupSessionsWithheld[k] || null);\n    }\n\n    public storeEndToEndInboundGroupSession(\n        senderCurve25519Key: string,\n        sessionId: string,\n        sessionData: InboundGroupSessionData,\n        txn: unknown,\n    ): void {\n        const k = encodeSessionKey(senderCurve25519Key, sessionId);\n        this.inboundGroupSessions[k] = sessionData;\n    }\n\n    /**\n     * Count the number of Megolm sessions in the database.\n     *\n     * Implementation of {@link CryptoStore.countEndToEndInboundGroupSessions}.\n     *\n     * @internal\n     */\n    public async countEndToEndInboundGroupSessions(): Promise<number> {\n        return Object.keys(this.inboundGroupSessions).length;\n    }\n\n    /**\n     * Fetch a batch of Megolm sessions from the database.\n     *\n     * Implementation of {@link CryptoStore.getEndToEndInboundGroupSessionsBatch}.\n     *\n     * @internal\n     */\n    public async getEndToEndInboundGroupSessionsBatch(): Promise<null | SessionExtended[]> {\n        const result: SessionExtended[] = [];\n        for (const [key, session] of Object.entries(this.inboundGroupSessions)) {\n            result.push({\n                ...decodeSessionKey(key),\n                sessionData: session,\n                needsBackup: key in this.sessionsNeedingBackup,\n            });\n            if (result.length >= SESSION_BATCH_SIZE) {\n                return result;\n            }\n        }\n\n        if (result.length === 0) {\n            // No sessions left.\n            return null;\n        }\n\n        // There are fewer sessions than the batch size; return the final batch of sessions.\n        return result;\n    }\n\n    /**\n     * Delete a batch of Megolm sessions from the database.\n     *\n     * Implementation of {@link CryptoStore.deleteEndToEndInboundGroupSessionsBatch}.\n     *\n     * @internal\n     */\n    public async deleteEndToEndInboundGroupSessionsBatch(\n        sessions: { senderKey: string; sessionId: string }[],\n    ): Promise<void> {\n        for (const { senderKey, sessionId } of sessions) {\n            const k = encodeSessionKey(senderKey, sessionId);\n            delete this.inboundGroupSessions[k];\n        }\n    }\n\n    // E2E rooms\n\n    public getEndToEndRooms(txn: unknown, func: (rooms: Record<string, IRoomEncryption>) => void): void {\n        func(this.rooms);\n    }\n\n    public markSessionsNeedingBackup(sessions: ISession[]): Promise<void> {\n        for (const session of sessions) {\n            const sessionKey = encodeSessionKey(session.senderKey, session.sessionId);\n            this.sessionsNeedingBackup[sessionKey] = true;\n        }\n        return Promise.resolve();\n    }\n\n    // Session key backups\n\n    public doTxn<T>(mode: Mode, stores: Iterable<string>, func: (txn?: unknown) => T): Promise<T> {\n        return Promise.resolve(func(null));\n    }\n}\n","/*\nCopyright 2023 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\n/** State of the verification of the device. */\nexport enum DeviceVerification {\n    Blocked = -1,\n    Unverified = 0,\n    Verified = 1,\n}\n\n/** A map from user ID to device ID to Device */\nexport type DeviceMap = Map<string, Map<string, Device>>;\n\ntype DeviceParameters = Pick<Device, \"deviceId\" | \"userId\" | \"algorithms\" | \"keys\"> & Partial<Device>;\n\n/**\n *  Information on a user's device, as returned by {@link crypto-api!CryptoApi.getUserDeviceInfo}.\n */\nexport class Device {\n    /** id of the device */\n    public readonly deviceId: string;\n\n    /** id of the user that owns the device */\n    public readonly userId: string;\n\n    /** list of algorithms supported by this device */\n    public readonly algorithms: string[];\n\n    /** a map from `<key type>:<id> -> <base64-encoded key>` */\n    public readonly keys: Map<string, string>;\n\n    /** whether the device has been verified/blocked by the user */\n    public readonly verified: DeviceVerification;\n\n    /** a map `<userId, map<algorithm:device_id, signature>>` */\n    public readonly signatures: Map<string, Map<string, string>>;\n\n    /** display name of the device */\n    public readonly displayName?: string;\n\n    /** whether the device is a dehydrated device */\n    public readonly dehydrated: boolean = false;\n\n    public constructor(opts: DeviceParameters) {\n        this.deviceId = opts.deviceId;\n        this.userId = opts.userId;\n        this.algorithms = opts.algorithms;\n        this.keys = opts.keys;\n        this.verified = opts.verified || DeviceVerification.Unverified;\n        this.signatures = opts.signatures || new Map();\n        this.displayName = opts.displayName;\n        this.dehydrated = !!opts.dehydrated;\n    }\n\n    /**\n     * Get the fingerprint for this device (ie, the Ed25519 key)\n     *\n     * @returns base64-encoded fingerprint of this device\n     */\n    public getFingerprint(): string | undefined {\n        return this.keys.get(`ed25519:${this.deviceId}`);\n    }\n\n    /**\n     * Get the identity key for this device (ie, the Curve25519 key)\n     *\n     * @returns base64-encoded identity key of this device\n     */\n    public getIdentityKey(): string | undefined {\n        return this.keys.get(`curve25519:${this.deviceId}`);\n    }\n}\n"],"names":["VerificationRequestEvent","VerificationPhase","VerifierEvent","canAcceptVerificationRequest","req","phase","Ready","accepting","declining","MigrationState","Backend","constructor","db","_defineProperty","this","onversionchange","logger","log","name","close","containsData","Error","startup","deleteAllData","getMigrationState","migrationState","NOT_STARTED","doTxn","IndexedDBCryptoStore","STORE_ACCOUNT","txn","getReq","objectStore","get","ACCOUNT_OBJECT_KEY_MIGRATION_STATE","onsuccess","_getReq$result","result","setMigrationState","put","getAccount","func","e","abortWithException","storeAccount","accountPickle","getCrossSigningKeys","getSecretStorePrivateKey","type","storeSecretStorePrivateKey","key","countEndToEndSessions","countReq","count","getEndToEndSessions","deviceKey","index","openCursor","results","cursor","value","sessionId","session","lastReceivedMessageTs","continue","getEndToEndSession","storeEndToEndSession","sessionInfo","getEndToEndSessionsBatch","STORE_SESSIONS","push","length","SESSION_BATCH_SIZE","deleteEndToEndSessionsBatch","sessions","async","delete","Promise","resolve","getEndToEndInboundGroupSession","senderCurve25519Key","withheld","withheldGetReq","storeEndToEndInboundGroupSession","sessionData","countEndToEndInboundGroupSessions","STORE_INBOUND_GROUP_SESSIONS","getEndToEndInboundGroupSessionsBatch","STORE_BACKUP","sessionStore","backupStore","backupGetReq","senderKey","needsBackup","undefined","deleteEndToEndInboundGroupSessionsBatch","getEndToEndDeviceData","getEndToEndRooms","rooms","markSessionsNeedingBackup","transaction","all","map","reject","onerror","mode","stores","promise","oncomplete","_mx_abortexception","event","error","onabort","promiseifyTxn","then","DB_MIGRATIONS","outgoingRoomKeyRequestsStore","createObjectStore","keyPath","createIndex","createDatabase","VERSION","abort","exists","indexedDB","dbName","IndexedDBHelpers","existsAndIsNotMigrated","indexedDb","openDBRequest","open","onupgradeneeded","onblocked","deleteDatabase","backendPromise","IndexedDBCryptoStoreBackend","ev","oldVersion","forEach","migration","backend","STORE_INBOUND_GROUP_SESSIONS_WITHHELD","catch","warn","InvalidCryptoStoreError","InvalidCryptoStoreState","TooNew","globalThis","localStorage","Storage","LocalStorageCryptoStore","MemoryCryptoStore","E2E_PREFIX","KEY_END_TO_END_MIGRATION_STATE","KEY_END_TO_END_ACCOUNT","KEY_CROSS_SIGNING_KEYS","KEY_INBOUND_SESSION_PREFIX","KEY_INBOUND_SESSION_WITHHELD_PREFIX","KEY_ROOMS_PREFIX","KEY_SESSIONS_NEEDING_BACKUP","keyEndToEndSessions","keyEndToEndInboundGroupSession","store","i","_store$key","startsWith","super","_getJsonItem","getJsonItem","setJsonItem","Object","keys","_getEndToEndSessions","fixedSessions","sid","val","entries","_sessions$sessionId","_this$_getEndToEndSes","_this$store$key","split","values","deviceSessions","removeItem","keyEndToEndInboundGroupSessionWithheld","sessionsNeedingBackup","key2","slice","k","prefix","JSON","parse","getItem","message","stack","setItem","stringify","encodeSessionKey","encodeURIComponent","decodeSessionKey","keyParts","decodeURIComponent","account","crossSigningKeys","privateKeys","safeSet","inboundGroupSessions","inboundGroupSessionsWithheld","_objectSpread","sessionKey","DeviceVerification","Device","opts","deviceId","userId","algorithms","verified","Unverified","signatures","Map","displayName","dehydrated","getFingerprint","getIdentityKey"],"sourceRoot":""}