matrix-js-sdk 41.6.0 → 41.7.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/ReEmitter.js +1 -1
- package/lib/ReEmitter.js.map +1 -1
- package/lib/ToDeviceMessageQueue.js +2 -2
- package/lib/ToDeviceMessageQueue.js.map +1 -1
- package/lib/autodiscovery.js +1 -0
- package/lib/autodiscovery.js.map +1 -1
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +77 -3
- package/lib/client.js.map +1 -1
- package/lib/common-crypto/CryptoBackend.js +2 -0
- package/lib/common-crypto/CryptoBackend.js.map +1 -1
- package/lib/crypto/store/indexeddb-crypto-store-backend.js +1 -1
- package/lib/crypto/store/indexeddb-crypto-store-backend.js.map +1 -1
- package/lib/crypto/store/indexeddb-crypto-store.js +2 -0
- package/lib/crypto/store/indexeddb-crypto-store.js.map +1 -1
- package/lib/crypto-api/index.js +58 -58
- package/lib/crypto-api/index.js.map +1 -1
- package/lib/embedded.js +13 -9
- package/lib/embedded.js.map +1 -1
- package/lib/extensible_events_v1/MessageEvent.js +15 -15
- package/lib/extensible_events_v1/MessageEvent.js.map +1 -1
- package/lib/extensible_events_v1/PollEndEvent.js +8 -8
- package/lib/extensible_events_v1/PollEndEvent.js.map +1 -1
- package/lib/extensible_events_v1/PollResponseEvent.js +1 -0
- package/lib/extensible_events_v1/PollResponseEvent.js.map +1 -1
- package/lib/extensible_events_v1/PollStartEvent.js +28 -28
- package/lib/extensible_events_v1/PollStartEvent.js.map +1 -1
- package/lib/filter.js +3 -1
- package/lib/filter.js.map +1 -1
- package/lib/http-api/errors.js +16 -16
- package/lib/http-api/errors.js.map +1 -1
- package/lib/http-api/fetch.js +2 -1
- package/lib/http-api/fetch.js.map +1 -1
- package/lib/http-api/refresh.js +7 -6
- package/lib/http-api/refresh.js.map +1 -1
- package/lib/http-api/utils.d.ts.map +1 -1
- package/lib/http-api/utils.js +1 -5
- package/lib/http-api/utils.js.map +1 -1
- package/lib/interactive-auth.js +11 -1
- package/lib/interactive-auth.js.map +1 -1
- package/lib/logger.js +2 -0
- package/lib/logger.js.map +1 -1
- package/lib/matrixrtc/CallMembership.js +6 -5
- package/lib/matrixrtc/CallMembership.js.map +1 -1
- package/lib/matrixrtc/MatrixRTCSession.d.ts.map +1 -1
- package/lib/matrixrtc/MatrixRTCSession.js +15 -5
- package/lib/matrixrtc/MatrixRTCSession.js.map +1 -1
- package/lib/matrixrtc/MatrixRTCSessionManager.js +3 -2
- package/lib/matrixrtc/MatrixRTCSessionManager.js.map +1 -1
- package/lib/matrixrtc/MembershipManager.js +24 -17
- package/lib/matrixrtc/MembershipManager.js.map +1 -1
- package/lib/matrixrtc/MembershipManagerActionScheduler.js +2 -1
- package/lib/matrixrtc/MembershipManagerActionScheduler.js.map +1 -1
- package/lib/matrixrtc/RTCEncryptionManager.js +6 -4
- package/lib/matrixrtc/RTCEncryptionManager.js.map +1 -1
- package/lib/matrixrtc/ToDeviceKeyTransport.js +4 -4
- package/lib/matrixrtc/ToDeviceKeyTransport.js.map +1 -1
- package/lib/models/MSC3089TreeSpace.js +2 -1
- package/lib/models/MSC3089TreeSpace.js.map +1 -1
- package/lib/models/beacon.js +8 -4
- package/lib/models/beacon.js.map +1 -1
- package/lib/models/device.js +7 -0
- package/lib/models/device.js.map +1 -1
- package/lib/models/event-context.js +2 -1
- package/lib/models/event-context.js.map +1 -1
- package/lib/models/event-timeline-set.js +7 -1
- package/lib/models/event-timeline-set.js.map +1 -1
- package/lib/models/event-timeline.js +5 -1
- package/lib/models/event-timeline.js.map +1 -1
- package/lib/models/event.js +35 -11
- package/lib/models/event.js.map +1 -1
- package/lib/models/poll.js +7 -3
- package/lib/models/poll.js.map +1 -1
- package/lib/models/related-relations.js +2 -0
- package/lib/models/related-relations.js.map +1 -1
- package/lib/models/relations-container.js +2 -2
- package/lib/models/relations-container.js.map +1 -1
- package/lib/models/relations.js +4 -3
- package/lib/models/relations.js.map +1 -1
- package/lib/models/room-member.js +24 -2
- package/lib/models/room-member.js.map +1 -1
- package/lib/models/room-receipts.js +19 -12
- package/lib/models/room-receipts.js.map +1 -1
- package/lib/models/room-state.js +2 -2
- package/lib/models/room-state.js.map +1 -1
- package/lib/models/room-sticky-events.js +1 -0
- package/lib/models/room-sticky-events.js.map +1 -1
- package/lib/models/room.js +35 -4
- package/lib/models/room.js.map +1 -1
- package/lib/models/thread.js +46 -2
- package/lib/models/thread.js.map +1 -1
- package/lib/models/user.js +20 -1
- package/lib/models/user.js.map +1 -1
- package/lib/oidc/tokenRefresher.js +11 -8
- package/lib/oidc/tokenRefresher.js.map +1 -1
- package/lib/pushprocessor.js +1 -1
- package/lib/pushprocessor.js.map +1 -1
- package/lib/rendezvous/MSC4108SignInWithQR.js +6 -1
- package/lib/rendezvous/MSC4108SignInWithQR.js.map +1 -1
- package/lib/rendezvous/channels/MSC4108SecureChannel.js +3 -1
- package/lib/rendezvous/channels/MSC4108SecureChannel.js.map +1 -1
- package/lib/rendezvous/transports/MSC4108RendezvousSession.js +8 -0
- package/lib/rendezvous/transports/MSC4108RendezvousSession.js.map +1 -1
- package/lib/room-hierarchy.js +8 -4
- package/lib/room-hierarchy.js.map +1 -1
- package/lib/rust-crypto/DehydratedDeviceManager.js +3 -2
- package/lib/rust-crypto/DehydratedDeviceManager.js.map +1 -1
- package/lib/rust-crypto/KeyClaimManager.js +2 -1
- package/lib/rust-crypto/KeyClaimManager.js.map +1 -1
- package/lib/rust-crypto/OutgoingRequestsManager.js +12 -12
- package/lib/rust-crypto/OutgoingRequestsManager.js.map +1 -1
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.js +5 -3
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.js.map +1 -1
- package/lib/rust-crypto/RoomEncryptor.js +6 -6
- package/lib/rust-crypto/RoomEncryptor.js.map +1 -1
- package/lib/rust-crypto/backup.js +6 -4
- package/lib/rust-crypto/backup.js.map +1 -1
- package/lib/rust-crypto/rust-crypto.js +18 -10
- package/lib/rust-crypto/rust-crypto.js.map +1 -1
- package/lib/rust-crypto/verification.js +9 -7
- package/lib/rust-crypto/verification.js.map +1 -1
- package/lib/scheduler.js +2 -2
- package/lib/scheduler.js.map +1 -1
- package/lib/serverCapabilities.js +5 -2
- package/lib/serverCapabilities.js.map +1 -1
- package/lib/sliding-sync-sdk.js +6 -3
- package/lib/sliding-sync-sdk.js.map +1 -1
- package/lib/sliding-sync.js +9 -4
- package/lib/sliding-sync.js.map +1 -1
- package/lib/store/indexeddb-local-backend.js +5 -1
- package/lib/store/indexeddb-local-backend.js.map +1 -1
- package/lib/store/indexeddb-remote-backend.js +7 -6
- package/lib/store/indexeddb-remote-backend.js.map +1 -1
- package/lib/store/indexeddb-store-worker.js +2 -1
- package/lib/store/indexeddb-store-worker.js.map +1 -1
- package/lib/store/indexeddb.js +1 -0
- package/lib/store/indexeddb.js.map +1 -1
- package/lib/store/memory.js +4 -0
- package/lib/store/memory.js.map +1 -1
- package/lib/sync-accumulator.js +1 -1
- package/lib/sync-accumulator.js.map +1 -1
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +32 -16
- package/lib/sync.js.map +1 -1
- package/lib/timeline-window.js +6 -2
- package/lib/timeline-window.js.map +1 -1
- package/lib/webrtc/call.js +42 -6
- package/lib/webrtc/call.js.map +1 -1
- package/lib/webrtc/callEventHandler.js +5 -0
- package/lib/webrtc/callEventHandler.js.map +1 -1
- package/lib/webrtc/callFeed.js +15 -0
- package/lib/webrtc/callFeed.js.map +1 -1
- package/lib/webrtc/groupCall.js +24 -8
- package/lib/webrtc/groupCall.js.map +1 -1
- package/lib/webrtc/groupCallEventHandler.js +1 -1
- package/lib/webrtc/groupCallEventHandler.js.map +1 -1
- package/lib/webrtc/mediaHandler.js +7 -3
- package/lib/webrtc/mediaHandler.js.map +1 -1
- package/lib/webrtc/stats/callStatsReportGatherer.js +5 -2
- package/lib/webrtc/stats/callStatsReportGatherer.js.map +1 -1
- package/lib/webrtc/stats/groupCallStats.js +4 -3
- package/lib/webrtc/stats/groupCallStats.js.map +1 -1
- package/lib/webrtc/stats/media/mediaTrackStats.js +3 -3
- package/lib/webrtc/stats/media/mediaTrackStats.js.map +1 -1
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.js +1 -1
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.js.map +1 -1
- package/package.json +125 -138
- package/src/client.ts +4 -1
- package/src/http-api/utils.ts +4 -9
- package/src/matrixrtc/MatrixRTCSession.ts +4 -3
- package/src/sync.ts +5 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
1
2
|
/*
|
|
2
3
|
Copyright 2022 The Matrix.org Foundation C.I.C.
|
|
3
4
|
|
|
@@ -52,6 +53,7 @@ export class DecryptionError extends Error {
|
|
|
52
53
|
constructor(code, msg, details) {
|
|
53
54
|
super(msg);
|
|
54
55
|
this.code = code;
|
|
56
|
+
_defineProperty(this, "detailedString", void 0);
|
|
55
57
|
this.name = "DecryptionError";
|
|
56
58
|
this.detailedString = detailedStringForDecryptionError(this, details);
|
|
57
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CryptoBackend.js","names":["DecryptionError","Error","constructor","code","msg","details","name","detailedString","detailedStringForDecryptionError","err","result","message","Object","keys","map","k","join"],"sources":["../../src/common-crypto/CryptoBackend.ts"],"sourcesContent":["/*\nCopyright 2022 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 { IDeviceLists, IToDeviceEvent, ReceivedToDeviceMessage } from \"../sync-accumulator.ts\";\nimport { type IClearEvent, type MatrixEvent } from \"../models/event.ts\";\nimport { type Room } from \"../models/room.ts\";\nimport { type CryptoApi, type DecryptionFailureCode, type ImportRoomKeysOpts } from \"../crypto-api/index.ts\";\nimport { type KeyBackupInfo, type KeyBackupSession } from \"../crypto-api/keybackup.ts\";\nimport { type IMegolmSessionData } from \"../@types/crypto.ts\";\n\n/**\n * Common interface for the crypto implementations\n *\n * @internal\n */\nexport interface CryptoBackend extends SyncCryptoCallbacks, CryptoApi {\n /**\n * Whether sendMessage in a room with unknown and unverified devices\n * should throw an error and not send the message. This has 'Global' for\n * symmetry with setGlobalBlacklistUnverifiedDevices but there is currently\n * no room-level equivalent for this setting.\n *\n * @remarks This has no effect in Rust Crypto; it exists only for the sake of\n * the accessors in MatrixClient.\n */\n globalErrorOnUnknownDevices: boolean;\n\n /**\n * Shut down any background processes related to crypto\n */\n stop(): void;\n\n /**\n * Encrypt an event according to the configuration of the room.\n *\n * @param event - event to be sent\n *\n * @param room - destination room.\n *\n * @returns Promise which resolves when the event has been\n * encrypted, or null if nothing was needed\n */\n encryptEvent(event: MatrixEvent, room: Room): Promise<void>;\n\n /**\n * Decrypt a received event\n *\n * @returns a promise which resolves once we have finished decrypting.\n * Rejects with an error if there is a problem decrypting the event.\n */\n decryptEvent(event: MatrixEvent): Promise<EventDecryptionResult>;\n\n /**\n * Get a backup decryptor capable of decrypting megolm session data encrypted with the given backup information.\n * @param backupInfo - The backup information\n * @param privKey - The private decryption key.\n */\n getBackupDecryptor(backupInfo: KeyBackupInfo, privKey: Uint8Array): Promise<BackupDecryptor>;\n\n /**\n * Import a list of room keys restored from backup\n *\n * @param keys - a list of session export objects\n * @param backupVersion - the version of the backup these keys came from.\n * @param opts - options object\n * @returns a promise which resolves once the keys have been imported\n */\n importBackedUpRoomKeys(keys: IMegolmSessionData[], backupVersion: string, opts?: ImportRoomKeysOpts): Promise<void>;\n\n ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n //\n // Room key history sharing (MSC4268)\n //\n ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n\n /**\n * Share any shareable E2EE history in the given room with the given recipient,\n * as per [MSC4268](https://github.com/matrix-org/matrix-spec-proposals/pull/4268)\n */\n shareRoomHistoryWithUser(roomId: string, userId: string): Promise<void>;\n\n /**\n * Having accepted an invite for the given room from the given user, attempt to\n * find information about a room key bundle and, if found, download the\n * bundle and import the room keys, as per {@link https://github.com/matrix-org/matrix-spec-proposals/pull/4268|MSC4268}.\n *\n * @param roomId - The room we were invited to, for which we want to check if a room\n * key bundle was received.\n *\n * @param inviter - The user who invited us to the room and is expected to have\n * sent the room key bundle.\n *\n * @returns `true` if the key bundle was successfuly downloaded and imported.\n */\n maybeAcceptKeyBundle(roomId: string, inviter: string): Promise<boolean>;\n\n /**\n * Mark a room as pending a key bundle under MSC4268. The backend will listen for room key bundle messages, and if\n * it sees one matching the room specified, it will automatically import it as long as the message author's ID matches\n * the inviter's ID.\n *\n * @param roomId - The room we were invited to, for which we did not receive a key bundle before accepting the invite.\n * @param inviterId - The user who invited us to the room and is expected to send the room key bundle.\n */\n markRoomAsPendingKeyBundle(roomId: string, inviterId: string): Promise<void>;\n}\n\n/** The methods which crypto implementations should expose to the Sync api\n *\n * @internal\n */\nexport interface SyncCryptoCallbacks {\n /**\n * Called by the /sync loop whenever there are incoming to-device messages.\n *\n * The implementation may preprocess the received messages (eg, decrypt them) and return an\n * updated list of messages for dispatch to the rest of the system.\n *\n * Note that, unlike {@link ClientEvent.ToDeviceEvent} events, this is called on the raw to-device\n * messages, rather than the results of any decryption attempts.\n *\n * @param events - the received to-device messages\n * @returns A list of preprocessed to-device messages. This will not map 1:1 to the input list, as some messages may be invalid or\n * failed to decrypt, and so will be omitted from the output list.\n *\n */\n preprocessToDeviceMessages(events: IToDeviceEvent[]): Promise<ReceivedToDeviceMessage[]>;\n\n /**\n * Called by the /sync loop when one time key counts and unused fallback key details are received.\n *\n * @param oneTimeKeysCounts - the received one time key counts\n * @param unusedFallbackKeys - the received unused fallback keys\n */\n processKeyCounts(oneTimeKeysCounts?: Record<string, number>, unusedFallbackKeys?: string[]): Promise<void>;\n\n /**\n * Handle the notification from /sync that device lists have\n * been changed.\n *\n * @param deviceLists - device_lists field from /sync\n */\n processDeviceLists(deviceLists: IDeviceLists): Promise<void>;\n\n /**\n * Called by the /sync loop whenever an m.room.encryption event is received.\n *\n * This is called before RoomStateEvents are emitted for any of the events in the /sync\n * response (even if the other events technically happened first). This works around a problem\n * if the client uses a RoomStateEvent (typically a membership event) as a trigger to send a message\n * in a new room (or one where encryption has been newly enabled): that would otherwise leave the\n * crypto layer confused because it expects crypto to be set up, but it has not yet been.\n *\n * @param room - in which the event was received\n * @param event - encryption event to be processed\n */\n onCryptoEvent(room: Room, event: MatrixEvent): Promise<void>;\n\n /**\n * Called by the /sync loop after each /sync response is processed.\n *\n * Used to complete batch processing, or to initiate background processes\n *\n * @param syncState - information about the completed sync.\n */\n onSyncCompleted(syncState: OnSyncCompletedData): void;\n\n /**\n * Mark all tracked users' device lists as dirty.\n *\n * This method will cause additional `/keys/query` requests on the server, so should be used only\n * when the client has desynced tracking device list deltas from the server.\n * In MSC4186: Simplified Sliding Sync, this can happen when the server expires the connection.\n */\n markAllTrackedUsersAsDirty(): Promise<void>;\n}\n\n/**\n * @internal\n */\nexport interface OnSyncCompletedData {\n /**\n * The 'next_batch' result from /sync, which will become the 'since' token for the next call to /sync.\n */\n nextSyncToken?: string;\n\n /**\n * True if we are working our way through a backlog of events after connecting.\n */\n catchingUp?: boolean;\n}\n\n/**\n * The result of a (successful) call to {@link CryptoBackend.decryptEvent}\n */\nexport interface EventDecryptionResult {\n /**\n * The plaintext payload for the event (typically containing <tt>type</tt> and <tt>content</tt> fields).\n */\n clearEvent: IClearEvent;\n /**\n * No longer used.\n * See {@link MatrixEvent#getForwardingCurve25519KeyChain}.\n * @deprecated\n */\n forwardingCurve25519KeyChain?: string[];\n /**\n * Key owned by the sender of this event. See {@link MatrixEvent#getSenderKey}.\n */\n senderCurve25519Key?: string;\n /**\n * ed25519 key claimed by the sender of this event. See {@link MatrixEvent#getClaimedEd25519Key}.\n */\n claimedEd25519Key?: string;\n\n /**\n * If another user forwarded the key to this message\n * (eg via [MSC4268](https://github.com/matrix-org/matrix-spec-proposals/pull/4268)),\n * the ID of that user.\n */\n keyForwardedBy?: string;\n}\n\n/**\n * Responsible for decrypting megolm session data retrieved from a remote backup.\n * The result of {@link CryptoBackend#getBackupDecryptor}.\n */\nexport interface BackupDecryptor {\n /**\n * Whether keys retrieved from this backup can be trusted.\n *\n * Depending on the backup algorithm, keys retrieved from the backup can be trusted or not.\n * If false, keys retrieved from the backup must be considered unsafe (authenticity cannot be guaranteed).\n * It could be by design (deniability) or for some technical reason (eg asymmetric encryption).\n */\n readonly sourceTrusted: boolean;\n\n /**\n *\n * Decrypt megolm session data retrieved from backup.\n *\n * @param ciphertexts - a Record of sessionId to session data.\n *\n * @returns An array of decrypted `IMegolmSessionData`\n */\n decryptSessions(ciphertexts: Record<string, KeyBackupSession>): Promise<IMegolmSessionData[]>;\n\n /**\n * Free any resources held by this decryptor.\n *\n * Should be called once the decryptor is no longer needed.\n */\n free(): void;\n}\n\n/**\n * Exception thrown when decryption fails\n *\n * @param code - Reason code for the failure.\n *\n * @param msg - user-visible message describing the problem\n *\n * @param details - key/value pairs reported in the logs but not shown\n * to the user.\n */\nexport class DecryptionError extends Error {\n public readonly detailedString: string;\n\n public constructor(\n public readonly code: DecryptionFailureCode,\n msg: string,\n details?: Record<string, string | Error>,\n ) {\n super(msg);\n this.name = \"DecryptionError\";\n this.detailedString = detailedStringForDecryptionError(this, details);\n }\n}\n\nfunction detailedStringForDecryptionError(err: DecryptionError, details?: Record<string, string | Error>): string {\n let result = err.name + \"[msg: \" + err.message;\n\n if (details) {\n result +=\n \", \" +\n Object.keys(details)\n .map((k) => k + \": \" + details[k])\n .join(\", \");\n }\n\n result += \"]\";\n\n return result;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;;AA6FA;AACA;AACA;AACA;;AAmEA;AACA;AACA;;AAaA;AACA;AACA;;AA6BA;AACA;AACA;AACA;;AA6BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,eAAe,SAASC,KAAK,CAAC;EAGhCC,WAAWA,CACEC,IAA2B,EAC3CC,GAAW,EACXC,OAAwC,EAC1C;IACE,KAAK,CAACD,GAAG,CAAC;IAAC,KAJKD,IAA2B,GAA3BA,IAA2B;IAK3C,IAAI,CAACG,IAAI,GAAG,iBAAiB;IAC7B,IAAI,CAACC,cAAc,GAAGC,gCAAgC,CAAC,IAAI,EAAEH,OAAO,CAAC;EACzE;AACJ;AAEA,SAASG,gCAAgCA,CAACC,GAAoB,EAAEJ,OAAwC,EAAU;EAC9G,IAAIK,MAAM,GAAGD,GAAG,CAACH,IAAI,GAAG,QAAQ,GAAGG,GAAG,CAACE,OAAO;EAE9C,IAAIN,OAAO,EAAE;IACTK,MAAM,IACF,IAAI,GACJE,MAAM,CAACC,IAAI,CAACR,OAAO,CAAC,CACfS,GAAG,CAAEC,CAAC,IAAKA,CAAC,GAAG,IAAI,GAAGV,OAAO,CAACU,CAAC,CAAC,CAAC,CACjCC,IAAI,CAAC,IAAI,CAAC;EACvB;EAEAN,MAAM,IAAI,GAAG;EAEb,OAAOA,MAAM;AACjB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"CryptoBackend.js","names":["DecryptionError","Error","constructor","code","msg","details","_defineProperty","name","detailedString","detailedStringForDecryptionError","err","result","message","Object","keys","map","k","join"],"sources":["../../src/common-crypto/CryptoBackend.ts"],"sourcesContent":["/*\nCopyright 2022 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 { IDeviceLists, IToDeviceEvent, ReceivedToDeviceMessage } from \"../sync-accumulator.ts\";\nimport { type IClearEvent, type MatrixEvent } from \"../models/event.ts\";\nimport { type Room } from \"../models/room.ts\";\nimport { type CryptoApi, type DecryptionFailureCode, type ImportRoomKeysOpts } from \"../crypto-api/index.ts\";\nimport { type KeyBackupInfo, type KeyBackupSession } from \"../crypto-api/keybackup.ts\";\nimport { type IMegolmSessionData } from \"../@types/crypto.ts\";\n\n/**\n * Common interface for the crypto implementations\n *\n * @internal\n */\nexport interface CryptoBackend extends SyncCryptoCallbacks, CryptoApi {\n /**\n * Whether sendMessage in a room with unknown and unverified devices\n * should throw an error and not send the message. This has 'Global' for\n * symmetry with setGlobalBlacklistUnverifiedDevices but there is currently\n * no room-level equivalent for this setting.\n *\n * @remarks This has no effect in Rust Crypto; it exists only for the sake of\n * the accessors in MatrixClient.\n */\n globalErrorOnUnknownDevices: boolean;\n\n /**\n * Shut down any background processes related to crypto\n */\n stop(): void;\n\n /**\n * Encrypt an event according to the configuration of the room.\n *\n * @param event - event to be sent\n *\n * @param room - destination room.\n *\n * @returns Promise which resolves when the event has been\n * encrypted, or null if nothing was needed\n */\n encryptEvent(event: MatrixEvent, room: Room): Promise<void>;\n\n /**\n * Decrypt a received event\n *\n * @returns a promise which resolves once we have finished decrypting.\n * Rejects with an error if there is a problem decrypting the event.\n */\n decryptEvent(event: MatrixEvent): Promise<EventDecryptionResult>;\n\n /**\n * Get a backup decryptor capable of decrypting megolm session data encrypted with the given backup information.\n * @param backupInfo - The backup information\n * @param privKey - The private decryption key.\n */\n getBackupDecryptor(backupInfo: KeyBackupInfo, privKey: Uint8Array): Promise<BackupDecryptor>;\n\n /**\n * Import a list of room keys restored from backup\n *\n * @param keys - a list of session export objects\n * @param backupVersion - the version of the backup these keys came from.\n * @param opts - options object\n * @returns a promise which resolves once the keys have been imported\n */\n importBackedUpRoomKeys(keys: IMegolmSessionData[], backupVersion: string, opts?: ImportRoomKeysOpts): Promise<void>;\n\n ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n //\n // Room key history sharing (MSC4268)\n //\n ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n\n /**\n * Share any shareable E2EE history in the given room with the given recipient,\n * as per [MSC4268](https://github.com/matrix-org/matrix-spec-proposals/pull/4268)\n */\n shareRoomHistoryWithUser(roomId: string, userId: string): Promise<void>;\n\n /**\n * Having accepted an invite for the given room from the given user, attempt to\n * find information about a room key bundle and, if found, download the\n * bundle and import the room keys, as per {@link https://github.com/matrix-org/matrix-spec-proposals/pull/4268|MSC4268}.\n *\n * @param roomId - The room we were invited to, for which we want to check if a room\n * key bundle was received.\n *\n * @param inviter - The user who invited us to the room and is expected to have\n * sent the room key bundle.\n *\n * @returns `true` if the key bundle was successfuly downloaded and imported.\n */\n maybeAcceptKeyBundle(roomId: string, inviter: string): Promise<boolean>;\n\n /**\n * Mark a room as pending a key bundle under MSC4268. The backend will listen for room key bundle messages, and if\n * it sees one matching the room specified, it will automatically import it as long as the message author's ID matches\n * the inviter's ID.\n *\n * @param roomId - The room we were invited to, for which we did not receive a key bundle before accepting the invite.\n * @param inviterId - The user who invited us to the room and is expected to send the room key bundle.\n */\n markRoomAsPendingKeyBundle(roomId: string, inviterId: string): Promise<void>;\n}\n\n/** The methods which crypto implementations should expose to the Sync api\n *\n * @internal\n */\nexport interface SyncCryptoCallbacks {\n /**\n * Called by the /sync loop whenever there are incoming to-device messages.\n *\n * The implementation may preprocess the received messages (eg, decrypt them) and return an\n * updated list of messages for dispatch to the rest of the system.\n *\n * Note that, unlike {@link ClientEvent.ToDeviceEvent} events, this is called on the raw to-device\n * messages, rather than the results of any decryption attempts.\n *\n * @param events - the received to-device messages\n * @returns A list of preprocessed to-device messages. This will not map 1:1 to the input list, as some messages may be invalid or\n * failed to decrypt, and so will be omitted from the output list.\n *\n */\n preprocessToDeviceMessages(events: IToDeviceEvent[]): Promise<ReceivedToDeviceMessage[]>;\n\n /**\n * Called by the /sync loop when one time key counts and unused fallback key details are received.\n *\n * @param oneTimeKeysCounts - the received one time key counts\n * @param unusedFallbackKeys - the received unused fallback keys\n */\n processKeyCounts(oneTimeKeysCounts?: Record<string, number>, unusedFallbackKeys?: string[]): Promise<void>;\n\n /**\n * Handle the notification from /sync that device lists have\n * been changed.\n *\n * @param deviceLists - device_lists field from /sync\n */\n processDeviceLists(deviceLists: IDeviceLists): Promise<void>;\n\n /**\n * Called by the /sync loop whenever an m.room.encryption event is received.\n *\n * This is called before RoomStateEvents are emitted for any of the events in the /sync\n * response (even if the other events technically happened first). This works around a problem\n * if the client uses a RoomStateEvent (typically a membership event) as a trigger to send a message\n * in a new room (or one where encryption has been newly enabled): that would otherwise leave the\n * crypto layer confused because it expects crypto to be set up, but it has not yet been.\n *\n * @param room - in which the event was received\n * @param event - encryption event to be processed\n */\n onCryptoEvent(room: Room, event: MatrixEvent): Promise<void>;\n\n /**\n * Called by the /sync loop after each /sync response is processed.\n *\n * Used to complete batch processing, or to initiate background processes\n *\n * @param syncState - information about the completed sync.\n */\n onSyncCompleted(syncState: OnSyncCompletedData): void;\n\n /**\n * Mark all tracked users' device lists as dirty.\n *\n * This method will cause additional `/keys/query` requests on the server, so should be used only\n * when the client has desynced tracking device list deltas from the server.\n * In MSC4186: Simplified Sliding Sync, this can happen when the server expires the connection.\n */\n markAllTrackedUsersAsDirty(): Promise<void>;\n}\n\n/**\n * @internal\n */\nexport interface OnSyncCompletedData {\n /**\n * The 'next_batch' result from /sync, which will become the 'since' token for the next call to /sync.\n */\n nextSyncToken?: string;\n\n /**\n * True if we are working our way through a backlog of events after connecting.\n */\n catchingUp?: boolean;\n}\n\n/**\n * The result of a (successful) call to {@link CryptoBackend.decryptEvent}\n */\nexport interface EventDecryptionResult {\n /**\n * The plaintext payload for the event (typically containing <tt>type</tt> and <tt>content</tt> fields).\n */\n clearEvent: IClearEvent;\n /**\n * No longer used.\n * See {@link MatrixEvent#getForwardingCurve25519KeyChain}.\n * @deprecated\n */\n forwardingCurve25519KeyChain?: string[];\n /**\n * Key owned by the sender of this event. See {@link MatrixEvent#getSenderKey}.\n */\n senderCurve25519Key?: string;\n /**\n * ed25519 key claimed by the sender of this event. See {@link MatrixEvent#getClaimedEd25519Key}.\n */\n claimedEd25519Key?: string;\n\n /**\n * If another user forwarded the key to this message\n * (eg via [MSC4268](https://github.com/matrix-org/matrix-spec-proposals/pull/4268)),\n * the ID of that user.\n */\n keyForwardedBy?: string;\n}\n\n/**\n * Responsible for decrypting megolm session data retrieved from a remote backup.\n * The result of {@link CryptoBackend#getBackupDecryptor}.\n */\nexport interface BackupDecryptor {\n /**\n * Whether keys retrieved from this backup can be trusted.\n *\n * Depending on the backup algorithm, keys retrieved from the backup can be trusted or not.\n * If false, keys retrieved from the backup must be considered unsafe (authenticity cannot be guaranteed).\n * It could be by design (deniability) or for some technical reason (eg asymmetric encryption).\n */\n readonly sourceTrusted: boolean;\n\n /**\n *\n * Decrypt megolm session data retrieved from backup.\n *\n * @param ciphertexts - a Record of sessionId to session data.\n *\n * @returns An array of decrypted `IMegolmSessionData`\n */\n decryptSessions(ciphertexts: Record<string, KeyBackupSession>): Promise<IMegolmSessionData[]>;\n\n /**\n * Free any resources held by this decryptor.\n *\n * Should be called once the decryptor is no longer needed.\n */\n free(): void;\n}\n\n/**\n * Exception thrown when decryption fails\n *\n * @param code - Reason code for the failure.\n *\n * @param msg - user-visible message describing the problem\n *\n * @param details - key/value pairs reported in the logs but not shown\n * to the user.\n */\nexport class DecryptionError extends Error {\n public readonly detailedString: string;\n\n public constructor(\n public readonly code: DecryptionFailureCode,\n msg: string,\n details?: Record<string, string | Error>,\n ) {\n super(msg);\n this.name = \"DecryptionError\";\n this.detailedString = detailedStringForDecryptionError(this, details);\n }\n}\n\nfunction detailedStringForDecryptionError(err: DecryptionError, details?: Record<string, string | Error>): string {\n let result = err.name + \"[msg: \" + err.message;\n\n if (details) {\n result +=\n \", \" +\n Object.keys(details)\n .map((k) => k + \": \" + details[k])\n .join(\", \");\n }\n\n result += \"]\";\n\n return result;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;;AA6FA;AACA;AACA;AACA;;AAmEA;AACA;AACA;;AAaA;AACA;AACA;;AA6BA;AACA;AACA;AACA;;AA6BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,eAAe,SAASC,KAAK,CAAC;EAGhCC,WAAWA,CACEC,IAA2B,EAC3CC,GAAW,EACXC,OAAwC,EAC1C;IACE,KAAK,CAACD,GAAG,CAAC;IAAC,KAJKD,IAA2B,GAA3BA,IAA2B;IAAAG,eAAA;IAK3C,IAAI,CAACC,IAAI,GAAG,iBAAiB;IAC7B,IAAI,CAACC,cAAc,GAAGC,gCAAgC,CAAC,IAAI,EAAEJ,OAAO,CAAC;EACzE;AACJ;AAEA,SAASI,gCAAgCA,CAACC,GAAoB,EAAEL,OAAwC,EAAU;EAC9G,IAAIM,MAAM,GAAGD,GAAG,CAACH,IAAI,GAAG,QAAQ,GAAGG,GAAG,CAACE,OAAO;EAE9C,IAAIP,OAAO,EAAE;IACTM,MAAM,IACF,IAAI,GACJE,MAAM,CAACC,IAAI,CAACT,OAAO,CAAC,CACfU,GAAG,CAAEC,CAAC,IAAKA,CAAC,GAAG,IAAI,GAAGX,OAAO,CAACW,CAAC,CAAC,CAAC,CACjCC,IAAI,CAAC,IAAI,CAAC;EACvB;EAEAN,MAAM,IAAI,GAAG;EAEb,OAAOA,MAAM;AACjB","ignoreList":[]}
|
|
@@ -32,8 +32,8 @@ export class Backend {
|
|
|
32
32
|
/**
|
|
33
33
|
*/
|
|
34
34
|
constructor(db) {
|
|
35
|
-
_defineProperty(this, "nextTxnId", 0);
|
|
36
35
|
this.db = db;
|
|
36
|
+
_defineProperty(this, "nextTxnId", 0);
|
|
37
37
|
// make sure we close the db on `onversionchange` - otherwise
|
|
38
38
|
// attempts to delete the database will block (and subsequent
|
|
39
39
|
// attempts to re-create it will also block).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexeddb-crypto-store-backend.js","names":["logger","MigrationState","SESSION_BATCH_SIZE","ACCOUNT_OBJECT_KEY_MIGRATION_STATE","IndexedDBCryptoStore","PROFILE_TRANSACTIONS","Backend","constructor","db","_defineProperty","onversionchange","log","concat","name","close","containsData","_asyncToGenerator","Error","startup","_this","deleteAllData","getMigrationState","_this2","migrationState","NOT_STARTED","doTxn","STORE_ACCOUNT","txn","objectStore","getReq","get","onsuccess","_getReq$result","result","setMigrationState","_this3","put","getAccount","func","e","abortWithException","storeAccount","accountPickle","getCrossSigningKeys","getSecretStorePrivateKey","type","storeSecretStorePrivateKey","key","countEndToEndSessions","countReq","count","getEndToEndSessions","deviceKey","idx","index","openCursor","results","cursor","value","sessionId","session","lastReceivedMessageTs","continue","getEndToEndSession","storeEndToEndSession","sessionInfo","getEndToEndSessionsBatch","_this4","STORE_SESSIONS","push","length","deleteEndToEndSessionsBatch","sessions","_this5","_ref","_loop","_ref3","req","delete","Promise","resolve","_x","apply","arguments","getEndToEndInboundGroupSession","senderCurve25519Key","withheld","withheldObjectStore","withheldGetReq","storeEndToEndInboundGroupSession","sessionData","countEndToEndInboundGroupSessions","_this6","STORE_INBOUND_GROUP_SESSIONS","sessionStore","getEndToEndInboundGroupSessionsBatch","_this7","STORE_BACKUP","backupStore","backupGetReq","senderKey","needsBackup","undefined","deleteEndToEndInboundGroupSessionsBatch","_this8","_ref4","_loop2","_ref6","_x2","getEndToEndDeviceData","getEndToEndRooms","rooms","markSessionsNeedingBackup","_this9","transaction","all","map","reject","onerror","mode","stores","startTime","description","txnId","nextTxnId","Date","now","debug","promise","promiseifyTxn","then","elapsedTime","error","DB_MIGRATIONS","createDatabase","createObjectStore","sessionsStore","keyPath","createIndex","problemsStore","VERSION","upgradeDatabase","oldVersion","forEach","migration","outgoingRoomKeyRequestsStore","_mx_abortexception","abort","_unused","oncomplete","event","onabort"],"sources":["../../../src/crypto/store/indexeddb-crypto-store-backend.ts"],"sourcesContent":["/*\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"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAsBA,MAAM,QAAQ,iBAAiB;AACrD,SAOIC,cAAc,EAGdC,kBAAkB,EAClBC,kCAAkC,QAG/B,WAAW;AAClB,SAASC,oBAAoB,QAAQ,6BAA6B;AAG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ItG,GAAmB,EAAqB;EAC9D,OAAO,IAAIoD,OAAO,CAAC,CAACC,OAAO,EAAEqC,MAAM,KAAK;IACpC1F,GAAG,CAAC0H,UAAU,GAAG,MAAY;MACzB,IAAK1H,GAAG,CAA4BuH,kBAAkB,KAAK5C,SAAS,EAAE;QAClEe,MAAM,CAAE1F,GAAG,CAA4BuH,kBAAkB,CAAC;MAC9D;MACAlE,OAAO,CAAC,IAAI,CAAC;IACjB,CAAC;IACDrD,GAAG,CAAC2F,OAAO,GAAIgC,KAAK,IAAW;MAC3B,IAAK3H,GAAG,CAA4BuH,kBAAkB,KAAK5C,SAAS,EAAE;QAClEe,MAAM,CAAE1F,GAAG,CAA4BuH,kBAAkB,CAAC;MAC9D,CAAC,MAAM;QACHlJ,MAAM,CAACW,GAAG,CAAC,gCAAgC,EAAE2I,KAAK,CAAC;QACnDjC,MAAM,CAAC1F,GAAG,CAACyG,KAAK,CAAC;MACrB;IACJ,CAAC;IACDzG,GAAG,CAAC4H,OAAO,GAAID,KAAK,IAAW;MAC3B,IAAK3H,GAAG,CAA4BuH,kBAAkB,KAAK5C,SAAS,EAAE;QAClEe,MAAM,CAAE1F,GAAG,CAA4BuH,kBAAkB,CAAC;MAC9D,CAAC,MAAM;QACHlJ,MAAM,CAACW,GAAG,CAAC,gCAAgC,EAAE2I,KAAK,CAAC;QACnDjC,MAAM,CAAC1F,GAAG,CAACyG,KAAK,CAAC;MACrB;IACJ,CAAC;EACL,CAAC,CAAC;AACN","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"indexeddb-crypto-store-backend.js","names":["logger","MigrationState","SESSION_BATCH_SIZE","ACCOUNT_OBJECT_KEY_MIGRATION_STATE","IndexedDBCryptoStore","PROFILE_TRANSACTIONS","Backend","constructor","db","_defineProperty","onversionchange","log","concat","name","close","containsData","_asyncToGenerator","Error","startup","_this","deleteAllData","getMigrationState","_this2","migrationState","NOT_STARTED","doTxn","STORE_ACCOUNT","txn","objectStore","getReq","get","onsuccess","_getReq$result","result","setMigrationState","_this3","put","getAccount","func","e","abortWithException","storeAccount","accountPickle","getCrossSigningKeys","getSecretStorePrivateKey","type","storeSecretStorePrivateKey","key","countEndToEndSessions","countReq","count","getEndToEndSessions","deviceKey","idx","index","openCursor","results","cursor","value","sessionId","session","lastReceivedMessageTs","continue","getEndToEndSession","storeEndToEndSession","sessionInfo","getEndToEndSessionsBatch","_this4","STORE_SESSIONS","push","length","deleteEndToEndSessionsBatch","sessions","_this5","_ref","_loop","_ref3","req","delete","Promise","resolve","_x","apply","arguments","getEndToEndInboundGroupSession","senderCurve25519Key","withheld","withheldObjectStore","withheldGetReq","storeEndToEndInboundGroupSession","sessionData","countEndToEndInboundGroupSessions","_this6","STORE_INBOUND_GROUP_SESSIONS","sessionStore","getEndToEndInboundGroupSessionsBatch","_this7","STORE_BACKUP","backupStore","backupGetReq","senderKey","needsBackup","undefined","deleteEndToEndInboundGroupSessionsBatch","_this8","_ref4","_loop2","_ref6","_x2","getEndToEndDeviceData","getEndToEndRooms","rooms","markSessionsNeedingBackup","_this9","transaction","all","map","reject","onerror","mode","stores","startTime","description","txnId","nextTxnId","Date","now","debug","promise","promiseifyTxn","then","elapsedTime","error","DB_MIGRATIONS","createDatabase","createObjectStore","sessionsStore","keyPath","createIndex","problemsStore","VERSION","upgradeDatabase","oldVersion","forEach","migration","outgoingRoomKeyRequestsStore","_mx_abortexception","abort","_unused","oncomplete","event","onabort"],"sources":["../../../src/crypto/store/indexeddb-crypto-store-backend.ts"],"sourcesContent":["/*\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"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAsBA,MAAM,QAAQ,iBAAiB;AACrD,SAOIC,cAAc,EAGdC,kBAAkB,EAClBC,kCAAkC,QAG/B,WAAW;AAClB,SAASC,oBAAoB,QAAQ,6BAA6B;AAGlE,IAAMC,oBAAoB,GAAG,KAAK;;AAElC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,OAAO,CAAwB;EAGxC;AACJ;EACWC,WAAWA,CAASC,EAAe,EAAE;IAAA,KAAjBA,EAAe,GAAfA,EAAe;IAAAC,eAAA,oBAJtB,CAAC;IAKjB;IACA;IACA;IACAD,EAAE,CAACE,eAAe,GAAG,MAAY;MAC7BV,MAAM,CAACW,GAAG,gCAAAC,MAAA,CAAgC,IAAI,CAACJ,EAAE,CAACK,IAAI,cAAW,CAAC;MAClEL,EAAE,CAACM,KAAK,CAAC,CAAC;IACd,CAAC;EACL;EAEaC,YAAYA,CAAA,EAAqB;IAAA,OAAAC,iBAAA;MAC1C,MAAMC,KAAK,CAAC,6BAA6B,CAAC;IAAC;EAC/C;EAEaC,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AE2I,KAAK,CAAC;QACnDjC,MAAM,CAAC1F,GAAG,CAACyG,KAAK,CAAC;MACrB;IACJ,CAAC;IACDzG,GAAG,CAAC4H,OAAO,GAAID,KAAK,IAAW;MAC3B,IAAK3H,GAAG,CAA4BuH,kBAAkB,KAAK5C,SAAS,EAAE;QAClEe,MAAM,CAAE1F,GAAG,CAA4BuH,kBAAkB,CAAC;MAC9D,CAAC,MAAM;QACHlJ,MAAM,CAACW,GAAG,CAAC,gCAAgC,EAAE2I,KAAK,CAAC;QACnDjC,MAAM,CAAC1F,GAAG,CAACyG,KAAK,CAAC;MACrB;IACJ,CAAC;EACL,CAAC,CAAC;AACN","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexeddb-crypto-store.js","names":["logger","LocalStorageCryptoStore","MemoryCryptoStore","IndexedDBCryptoStoreBackend","InvalidCryptoStoreError","InvalidCryptoStoreState","IndexedDBHelpers","MigrationState","ACCOUNT_OBJECT_KEY_MIGRATION_STATE","IndexedDBCryptoStore","exists","indexedDB","dbName","existsAndIsNotMigrated","indexedDb","Promise","resolve","reject","openDBRequest","open","onupgradeneeded","onblocked","error","onsuccess","db","result","close","deleteDatabase","tx","transaction","STORE_ACCOUNT","objectStore","getReq","get","_getReq$result","migrationState","NOT_STARTED","onerror","constructor","containsData","_this","_asyncToGenerator","startup","backendPromise","Error","log","concat","req","VERSION","ev","oldVersion","upgradeDatabase","Backend","then","backend","doTxn","STORE_INBOUND_GROUP_SESSIONS","STORE_INBOUND_GROUP_SESSIONS_WITHHELD","txn","getEndToEndInboundGroupSession","catch","e","name","warn","TooNew","globalThis","localStorage","Storage","deleteAllData","getMigrationState","setMigrationState","getAccount","func","storeAccount","accountPickle","getCrossSigningKeys","getSecretStorePrivateKey","type","storeSecretStorePrivateKey","key","countEndToEndSessions","getEndToEndSession","deviceKey","sessionId","getEndToEndSessions","storeEndToEndSession","sessionInfo","countEndToEndInboundGroupSessions","getEndToEndSessionsBatch","deleteEndToEndSessionsBatch","sessions","senderCurve25519Key","storeEndToEndInboundGroupSession","sessionData","getEndToEndInboundGroupSessionsBatch","deleteEndToEndInboundGroupSessionsBatch","getEndToEndRooms","markSessionsNeedingBackup","mode","stores","_defineProperty"],"sources":["../../../src/crypto/store/indexeddb-crypto-store.ts"],"sourcesContent":["/*\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"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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A,CAJ9E3F,oBAAoB,iDAK+B,uCAAuC;AAAA2F,eAAA,CAL1F3F,oBAAoB,iCAMe,uBAAuB;AAAA2F,eAAA,CAN1D3F,oBAAoB,uBAOK,aAAa;AAAA2F,eAAA,CAPtC3F,oBAAoB,iBAQD,OAAO;AAAA2F,eAAA,CAR1B3F,oBAAoB,kBASA,yBAAyB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"indexeddb-crypto-store.js","names":["logger","LocalStorageCryptoStore","MemoryCryptoStore","IndexedDBCryptoStoreBackend","InvalidCryptoStoreError","InvalidCryptoStoreState","IndexedDBHelpers","MigrationState","ACCOUNT_OBJECT_KEY_MIGRATION_STATE","IndexedDBCryptoStore","exists","indexedDB","dbName","existsAndIsNotMigrated","indexedDb","Promise","resolve","reject","openDBRequest","open","onupgradeneeded","onblocked","error","onsuccess","db","result","close","deleteDatabase","tx","transaction","STORE_ACCOUNT","objectStore","getReq","get","_getReq$result","migrationState","NOT_STARTED","onerror","constructor","_defineProperty","containsData","_this","_asyncToGenerator","startup","backendPromise","Error","log","concat","req","VERSION","ev","oldVersion","upgradeDatabase","Backend","then","backend","doTxn","STORE_INBOUND_GROUP_SESSIONS","STORE_INBOUND_GROUP_SESSIONS_WITHHELD","txn","getEndToEndInboundGroupSession","catch","e","name","warn","TooNew","globalThis","localStorage","Storage","deleteAllData","getMigrationState","setMigrationState","getAccount","func","storeAccount","accountPickle","getCrossSigningKeys","getSecretStorePrivateKey","type","storeSecretStorePrivateKey","key","countEndToEndSessions","getEndToEndSession","deviceKey","sessionId","getEndToEndSessions","storeEndToEndSession","sessionInfo","countEndToEndInboundGroupSessions","getEndToEndSessionsBatch","deleteEndToEndSessionsBatch","sessions","senderCurve25519Key","storeEndToEndInboundGroupSession","sessionData","getEndToEndInboundGroupSessionsBatch","deleteEndToEndInboundGroupSessionsBatch","getEndToEndRooms","markSessionsNeedingBackup","mode","stores"],"sources":["../../../src/crypto/store/indexeddb-crypto-store.ts"],"sourcesContent":["/*\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"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,MAAM,QAAqB,iBAAiB;AACrD,SAASC,uBAAuB,QAAQ,gCAAgC;AACxE,SAASC,iBAAiB,QAAQ,0BAA0B;AAC5D,OAAO,KAAKC,2BAA2B,MAAM,qCAAqC;AAClF,SAASC,uBAAuB,EAAEC,uBA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