@unwanted/matrix-sdk-mini 34.12.0-1 → 34.12.0-3
Sign up to get free protection for your applications and to get access to all the features.
- package/git-revision.txt +1 -1
- package/lib/@types/event.d.ts +0 -19
- package/lib/@types/event.d.ts.map +1 -1
- package/lib/@types/event.js.map +1 -1
- package/lib/@types/global.d.js +0 -2
- package/lib/@types/global.d.js.map +1 -1
- package/lib/browser-index.d.ts.map +1 -1
- package/lib/browser-index.js +0 -11
- package/lib/browser-index.js.map +1 -1
- package/lib/client.d.ts +2 -1224
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +345 -2826
- package/lib/client.js.map +1 -1
- package/lib/embedded.d.ts +0 -22
- package/lib/embedded.d.ts.map +1 -1
- package/lib/embedded.js +24 -167
- package/lib/embedded.js.map +1 -1
- package/lib/event-mapper.d.ts.map +1 -1
- package/lib/event-mapper.js +0 -4
- package/lib/event-mapper.js.map +1 -1
- package/lib/matrix.d.ts +0 -25
- package/lib/matrix.d.ts.map +1 -1
- package/lib/matrix.js +1 -30
- package/lib/matrix.js.map +1 -1
- package/lib/models/MSC3089Branch.d.ts.map +1 -1
- package/lib/models/MSC3089Branch.js +0 -3
- package/lib/models/MSC3089Branch.js.map +1 -1
- package/lib/models/event.d.ts +0 -94
- package/lib/models/event.d.ts.map +1 -1
- package/lib/models/event.js +0 -274
- package/lib/models/event.js.map +1 -1
- package/lib/models/poll.d.ts.map +1 -1
- package/lib/models/poll.js +1 -5
- package/lib/models/poll.js.map +1 -1
- package/lib/models/relations-container.d.ts.map +1 -1
- package/lib/models/relations-container.js +1 -7
- package/lib/models/relations-container.js.map +1 -1
- package/lib/models/relations.d.ts +0 -1
- package/lib/models/relations.d.ts.map +1 -1
- package/lib/models/relations.js +0 -8
- package/lib/models/relations.js.map +1 -1
- package/lib/models/room-state.d.ts.map +1 -1
- package/lib/models/room-state.js +10 -26
- package/lib/models/room-state.js.map +1 -1
- package/lib/models/room.d.ts +0 -18
- package/lib/models/room.d.ts.map +1 -1
- package/lib/models/room.js +94 -148
- package/lib/models/room.js.map +1 -1
- package/lib/models/thread.d.ts.map +1 -1
- package/lib/models/thread.js +0 -1
- package/lib/models/thread.js.map +1 -1
- package/lib/sliding-sync-sdk.d.ts +2 -3
- package/lib/sliding-sync-sdk.d.ts.map +1 -1
- package/lib/sliding-sync-sdk.js +41 -90
- package/lib/sliding-sync-sdk.js.map +1 -1
- package/lib/sync.d.ts +0 -12
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +1 -73
- package/lib/sync.js.map +1 -1
- package/lib/testing.d.ts +0 -48
- package/lib/testing.d.ts.map +1 -1
- package/lib/testing.js +0 -105
- package/lib/testing.js.map +1 -1
- package/package.json +1 -3
- package/src/@types/event.ts +2 -36
- package/src/@types/global.d.ts +0 -3
- package/src/browser-index.ts +0 -11
- package/src/client.ts +52 -2876
- package/src/embedded.ts +3 -132
- package/src/event-mapper.ts +0 -4
- package/src/matrix.ts +0 -41
- package/src/models/MSC3089Branch.ts +0 -3
- package/src/models/event.ts +0 -289
- package/src/models/poll.ts +0 -6
- package/src/models/relations-container.ts +1 -8
- package/src/models/relations.ts +0 -8
- package/src/models/room-state.ts +2 -8
- package/src/models/room.ts +0 -62
- package/src/models/thread.ts +0 -1
- package/src/sliding-sync-sdk.ts +2 -72
- package/src/sync.ts +1 -98
- package/src/testing.ts +0 -108
- package/lib/@types/crypto.d.ts +0 -47
- package/lib/@types/crypto.d.ts.map +0 -1
- package/lib/@types/crypto.js +0 -1
- package/lib/@types/crypto.js.map +0 -1
- package/lib/@types/matrix-sdk-crypto-wasm.d.js +0 -1
- package/lib/@types/matrix-sdk-crypto-wasm.d.js.map +0 -1
- package/lib/common-crypto/CryptoBackend.d.ts +0 -240
- package/lib/common-crypto/CryptoBackend.d.ts.map +0 -1
- package/lib/common-crypto/CryptoBackend.js +0 -73
- package/lib/common-crypto/CryptoBackend.js.map +0 -1
- package/lib/common-crypto/key-passphrase.d.ts +0 -14
- package/lib/common-crypto/key-passphrase.d.ts.map +0 -1
- package/lib/common-crypto/key-passphrase.js +0 -33
- package/lib/common-crypto/key-passphrase.js.map +0 -1
- package/lib/crypto/CrossSigning.d.ts +0 -184
- package/lib/crypto/CrossSigning.d.ts.map +0 -1
- package/lib/crypto/CrossSigning.js +0 -718
- package/lib/crypto/CrossSigning.js.map +0 -1
- package/lib/crypto/DeviceList.d.ts +0 -216
- package/lib/crypto/DeviceList.d.ts.map +0 -1
- package/lib/crypto/DeviceList.js +0 -892
- package/lib/crypto/DeviceList.js.map +0 -1
- package/lib/crypto/EncryptionSetup.d.ts +0 -152
- package/lib/crypto/EncryptionSetup.d.ts.map +0 -1
- package/lib/crypto/EncryptionSetup.js +0 -356
- package/lib/crypto/EncryptionSetup.js.map +0 -1
- package/lib/crypto/OlmDevice.d.ts +0 -457
- package/lib/crypto/OlmDevice.d.ts.map +0 -1
- package/lib/crypto/OlmDevice.js +0 -1241
- package/lib/crypto/OlmDevice.js.map +0 -1
- package/lib/crypto/OutgoingRoomKeyRequestManager.d.ts +0 -109
- package/lib/crypto/OutgoingRoomKeyRequestManager.d.ts.map +0 -1
- package/lib/crypto/OutgoingRoomKeyRequestManager.js +0 -415
- package/lib/crypto/OutgoingRoomKeyRequestManager.js.map +0 -1
- package/lib/crypto/RoomList.d.ts +0 -26
- package/lib/crypto/RoomList.d.ts.map +0 -1
- package/lib/crypto/RoomList.js +0 -71
- package/lib/crypto/RoomList.js.map +0 -1
- package/lib/crypto/SecretSharing.d.ts +0 -24
- package/lib/crypto/SecretSharing.d.ts.map +0 -1
- package/lib/crypto/SecretSharing.js +0 -194
- package/lib/crypto/SecretSharing.js.map +0 -1
- package/lib/crypto/SecretStorage.d.ts +0 -55
- package/lib/crypto/SecretStorage.d.ts.map +0 -1
- package/lib/crypto/SecretStorage.js +0 -118
- package/lib/crypto/SecretStorage.js.map +0 -1
- package/lib/crypto/aes.d.ts +0 -6
- package/lib/crypto/aes.d.ts.map +0 -1
- package/lib/crypto/aes.js +0 -24
- package/lib/crypto/aes.js.map +0 -1
- package/lib/crypto/algorithms/base.d.ts +0 -156
- package/lib/crypto/algorithms/base.d.ts.map +0 -1
- package/lib/crypto/algorithms/base.js +0 -187
- package/lib/crypto/algorithms/base.js.map +0 -1
- package/lib/crypto/algorithms/index.d.ts +0 -4
- package/lib/crypto/algorithms/index.d.ts.map +0 -1
- package/lib/crypto/algorithms/index.js +0 -20
- package/lib/crypto/algorithms/index.js.map +0 -1
- package/lib/crypto/algorithms/megolm.d.ts +0 -385
- package/lib/crypto/algorithms/megolm.d.ts.map +0 -1
- package/lib/crypto/algorithms/megolm.js +0 -1822
- package/lib/crypto/algorithms/megolm.js.map +0 -1
- package/lib/crypto/algorithms/olm.d.ts +0 -5
- package/lib/crypto/algorithms/olm.d.ts.map +0 -1
- package/lib/crypto/algorithms/olm.js +0 -299
- package/lib/crypto/algorithms/olm.js.map +0 -1
- package/lib/crypto/api.d.ts +0 -32
- package/lib/crypto/api.d.ts.map +0 -1
- package/lib/crypto/api.js +0 -22
- package/lib/crypto/api.js.map +0 -1
- package/lib/crypto/backup.d.ts +0 -227
- package/lib/crypto/backup.d.ts.map +0 -1
- package/lib/crypto/backup.js +0 -824
- package/lib/crypto/backup.js.map +0 -1
- package/lib/crypto/crypto.d.ts +0 -3
- package/lib/crypto/crypto.d.ts.map +0 -1
- package/lib/crypto/crypto.js +0 -19
- package/lib/crypto/crypto.js.map +0 -1
- package/lib/crypto/dehydration.d.ts +0 -34
- package/lib/crypto/dehydration.d.ts.map +0 -1
- package/lib/crypto/dehydration.js +0 -252
- package/lib/crypto/dehydration.js.map +0 -1
- package/lib/crypto/device-converter.d.ts +0 -9
- package/lib/crypto/device-converter.d.ts.map +0 -1
- package/lib/crypto/device-converter.js +0 -42
- package/lib/crypto/device-converter.js.map +0 -1
- package/lib/crypto/deviceinfo.d.ts +0 -99
- package/lib/crypto/deviceinfo.d.ts.map +0 -1
- package/lib/crypto/deviceinfo.js +0 -148
- package/lib/crypto/deviceinfo.js.map +0 -1
- package/lib/crypto/index.d.ts +0 -1209
- package/lib/crypto/index.d.ts.map +0 -1
- package/lib/crypto/index.js +0 -4097
- package/lib/crypto/index.js.map +0 -1
- package/lib/crypto/key_passphrase.d.ts +0 -14
- package/lib/crypto/key_passphrase.d.ts.map +0 -1
- package/lib/crypto/key_passphrase.js +0 -44
- package/lib/crypto/key_passphrase.js.map +0 -1
- package/lib/crypto/keybackup.d.ts +0 -18
- package/lib/crypto/keybackup.d.ts.map +0 -1
- package/lib/crypto/keybackup.js +0 -1
- package/lib/crypto/keybackup.js.map +0 -1
- package/lib/crypto/olmlib.d.ts +0 -129
- package/lib/crypto/olmlib.d.ts.map +0 -1
- package/lib/crypto/olmlib.js +0 -492
- package/lib/crypto/olmlib.js.map +0 -1
- package/lib/crypto/recoverykey.d.ts +0 -2
- package/lib/crypto/recoverykey.d.ts.map +0 -1
- package/lib/crypto/recoverykey.js +0 -19
- package/lib/crypto/recoverykey.js.map +0 -1
- package/lib/crypto/store/base.d.ts +0 -252
- package/lib/crypto/store/base.d.ts.map +0 -1
- package/lib/crypto/store/base.js +0 -64
- package/lib/crypto/store/base.js.map +0 -1
- package/lib/crypto/store/indexeddb-crypto-store-backend.d.ts +0 -187
- package/lib/crypto/store/indexeddb-crypto-store-backend.d.ts.map +0 -1
- package/lib/crypto/store/indexeddb-crypto-store-backend.js +0 -1145
- package/lib/crypto/store/indexeddb-crypto-store-backend.js.map +0 -1
- package/lib/crypto/store/indexeddb-crypto-store.d.ts +0 -432
- package/lib/crypto/store/indexeddb-crypto-store.d.ts.map +0 -1
- package/lib/crypto/store/indexeddb-crypto-store.js +0 -728
- package/lib/crypto/store/indexeddb-crypto-store.js.map +0 -1
- package/lib/crypto/store/localStorage-crypto-store.d.ts +0 -119
- package/lib/crypto/store/localStorage-crypto-store.d.ts.map +0 -1
- package/lib/crypto/store/localStorage-crypto-store.js +0 -531
- package/lib/crypto/store/localStorage-crypto-store.js.map +0 -1
- package/lib/crypto/store/memory-crypto-store.d.ts +0 -215
- package/lib/crypto/store/memory-crypto-store.d.ts.map +0 -1
- package/lib/crypto/store/memory-crypto-store.js +0 -622
- package/lib/crypto/store/memory-crypto-store.js.map +0 -1
- package/lib/crypto/verification/Base.d.ts +0 -105
- package/lib/crypto/verification/Base.d.ts.map +0 -1
- package/lib/crypto/verification/Base.js +0 -372
- package/lib/crypto/verification/Base.js.map +0 -1
- package/lib/crypto/verification/Error.d.ts +0 -35
- package/lib/crypto/verification/Error.d.ts.map +0 -1
- package/lib/crypto/verification/Error.js +0 -86
- package/lib/crypto/verification/Error.js.map +0 -1
- package/lib/crypto/verification/IllegalMethod.d.ts +0 -15
- package/lib/crypto/verification/IllegalMethod.d.ts.map +0 -1
- package/lib/crypto/verification/IllegalMethod.js +0 -43
- package/lib/crypto/verification/IllegalMethod.js.map +0 -1
- package/lib/crypto/verification/QRCode.d.ts +0 -51
- package/lib/crypto/verification/QRCode.d.ts.map +0 -1
- package/lib/crypto/verification/QRCode.js +0 -277
- package/lib/crypto/verification/QRCode.js.map +0 -1
- package/lib/crypto/verification/SAS.d.ts +0 -27
- package/lib/crypto/verification/SAS.d.ts.map +0 -1
- package/lib/crypto/verification/SAS.js +0 -485
- package/lib/crypto/verification/SAS.js.map +0 -1
- package/lib/crypto/verification/SASDecimal.d.ts +0 -8
- package/lib/crypto/verification/SASDecimal.d.ts.map +0 -1
- package/lib/crypto/verification/SASDecimal.js +0 -34
- package/lib/crypto/verification/SASDecimal.js.map +0 -1
- package/lib/crypto/verification/request/Channel.d.ts +0 -18
- package/lib/crypto/verification/request/Channel.d.ts.map +0 -1
- package/lib/crypto/verification/request/Channel.js +0 -1
- package/lib/crypto/verification/request/Channel.js.map +0 -1
- package/lib/crypto/verification/request/InRoomChannel.d.ts +0 -113
- package/lib/crypto/verification/request/InRoomChannel.d.ts.map +0 -1
- package/lib/crypto/verification/request/InRoomChannel.js +0 -351
- package/lib/crypto/verification/request/InRoomChannel.js.map +0 -1
- package/lib/crypto/verification/request/ToDeviceChannel.d.ts +0 -105
- package/lib/crypto/verification/request/ToDeviceChannel.d.ts.map +0 -1
- package/lib/crypto/verification/request/ToDeviceChannel.js +0 -328
- package/lib/crypto/verification/request/ToDeviceChannel.js.map +0 -1
- package/lib/crypto/verification/request/VerificationRequest.d.ts +0 -227
- package/lib/crypto/verification/request/VerificationRequest.d.ts.map +0 -1
- package/lib/crypto/verification/request/VerificationRequest.js +0 -937
- package/lib/crypto/verification/request/VerificationRequest.js.map +0 -1
- package/lib/crypto-api/CryptoEvent.d.ts +0 -69
- package/lib/crypto-api/CryptoEvent.d.ts.map +0 -1
- package/lib/crypto-api/CryptoEvent.js +0 -33
- package/lib/crypto-api/CryptoEvent.js.map +0 -1
- package/lib/crypto-api/CryptoEventHandlerMap.d.ts +0 -16
- package/lib/crypto-api/CryptoEventHandlerMap.d.ts.map +0 -1
- package/lib/crypto-api/CryptoEventHandlerMap.js +0 -22
- package/lib/crypto-api/CryptoEventHandlerMap.js.map +0 -1
- package/lib/crypto-api/index.d.ts +0 -978
- package/lib/crypto-api/index.d.ts.map +0 -1
- package/lib/crypto-api/index.js +0 -304
- package/lib/crypto-api/index.js.map +0 -1
- package/lib/crypto-api/key-passphrase.d.ts +0 -11
- package/lib/crypto-api/key-passphrase.d.ts.map +0 -1
- package/lib/crypto-api/key-passphrase.js +0 -51
- package/lib/crypto-api/key-passphrase.js.map +0 -1
- package/lib/crypto-api/keybackup.d.ts +0 -88
- package/lib/crypto-api/keybackup.d.ts.map +0 -1
- package/lib/crypto-api/keybackup.js +0 -1
- package/lib/crypto-api/keybackup.js.map +0 -1
- package/lib/crypto-api/recovery-key.d.ts +0 -11
- package/lib/crypto-api/recovery-key.d.ts.map +0 -1
- package/lib/crypto-api/recovery-key.js +0 -65
- package/lib/crypto-api/recovery-key.js.map +0 -1
- package/lib/crypto-api/verification.d.ts +0 -344
- package/lib/crypto-api/verification.d.ts.map +0 -1
- package/lib/crypto-api/verification.js +0 -91
- package/lib/crypto-api/verification.js.map +0 -1
- package/lib/matrixrtc/CallMembership.d.ts +0 -66
- package/lib/matrixrtc/CallMembership.d.ts.map +0 -1
- package/lib/matrixrtc/CallMembership.js +0 -197
- package/lib/matrixrtc/CallMembership.js.map +0 -1
- package/lib/matrixrtc/LivekitFocus.d.ts +0 -16
- package/lib/matrixrtc/LivekitFocus.d.ts.map +0 -1
- package/lib/matrixrtc/LivekitFocus.js +0 -20
- package/lib/matrixrtc/LivekitFocus.js.map +0 -1
- package/lib/matrixrtc/MatrixRTCSession.d.ts +0 -295
- package/lib/matrixrtc/MatrixRTCSession.d.ts.map +0 -1
- package/lib/matrixrtc/MatrixRTCSession.js +0 -1043
- package/lib/matrixrtc/MatrixRTCSession.js.map +0 -1
- package/lib/matrixrtc/MatrixRTCSessionManager.d.ts +0 -40
- package/lib/matrixrtc/MatrixRTCSessionManager.d.ts.map +0 -1
- package/lib/matrixrtc/MatrixRTCSessionManager.js +0 -146
- package/lib/matrixrtc/MatrixRTCSessionManager.js.map +0 -1
- package/lib/matrixrtc/focus.d.ts +0 -10
- package/lib/matrixrtc/focus.d.ts.map +0 -1
- package/lib/matrixrtc/focus.js +0 -1
- package/lib/matrixrtc/focus.js.map +0 -1
- package/lib/matrixrtc/index.d.ts +0 -7
- package/lib/matrixrtc/index.d.ts.map +0 -1
- package/lib/matrixrtc/index.js +0 -21
- package/lib/matrixrtc/index.js.map +0 -1
- package/lib/matrixrtc/types.d.ts +0 -19
- package/lib/matrixrtc/types.d.ts.map +0 -1
- package/lib/matrixrtc/types.js +0 -1
- package/lib/matrixrtc/types.js.map +0 -1
- package/lib/rendezvous/MSC4108SignInWithQR.d.ts +0 -112
- package/lib/rendezvous/MSC4108SignInWithQR.d.ts.map +0 -1
- package/lib/rendezvous/MSC4108SignInWithQR.js +0 -392
- package/lib/rendezvous/MSC4108SignInWithQR.js.map +0 -1
- package/lib/rendezvous/RendezvousChannel.d.ts +0 -27
- package/lib/rendezvous/RendezvousChannel.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousChannel.js +0 -1
- package/lib/rendezvous/RendezvousChannel.js.map +0 -1
- package/lib/rendezvous/RendezvousCode.d.ts +0 -9
- package/lib/rendezvous/RendezvousCode.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousCode.js +0 -1
- package/lib/rendezvous/RendezvousCode.js.map +0 -1
- package/lib/rendezvous/RendezvousError.d.ts +0 -6
- package/lib/rendezvous/RendezvousError.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousError.js +0 -23
- package/lib/rendezvous/RendezvousError.js.map +0 -1
- package/lib/rendezvous/RendezvousFailureReason.d.ts +0 -31
- package/lib/rendezvous/RendezvousFailureReason.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousFailureReason.js +0 -38
- package/lib/rendezvous/RendezvousFailureReason.js.map +0 -1
- package/lib/rendezvous/RendezvousIntent.d.ts +0 -5
- package/lib/rendezvous/RendezvousIntent.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousIntent.js +0 -22
- package/lib/rendezvous/RendezvousIntent.js.map +0 -1
- package/lib/rendezvous/RendezvousTransport.d.ts +0 -36
- package/lib/rendezvous/RendezvousTransport.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousTransport.js +0 -1
- package/lib/rendezvous/RendezvousTransport.js.map +0 -1
- package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts +0 -58
- package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts.map +0 -1
- package/lib/rendezvous/channels/MSC4108SecureChannel.js +0 -246
- package/lib/rendezvous/channels/MSC4108SecureChannel.js.map +0 -1
- package/lib/rendezvous/channels/index.d.ts +0 -2
- package/lib/rendezvous/channels/index.d.ts.map +0 -1
- package/lib/rendezvous/channels/index.js +0 -18
- package/lib/rendezvous/channels/index.js.map +0 -1
- package/lib/rendezvous/index.d.ts +0 -10
- package/lib/rendezvous/index.d.ts.map +0 -1
- package/lib/rendezvous/index.js +0 -23
- package/lib/rendezvous/index.js.map +0 -1
- package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts +0 -61
- package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts.map +0 -1
- package/lib/rendezvous/transports/MSC4108RendezvousSession.js +0 -253
- package/lib/rendezvous/transports/MSC4108RendezvousSession.js.map +0 -1
- package/lib/rendezvous/transports/index.d.ts +0 -2
- package/lib/rendezvous/transports/index.d.ts.map +0 -1
- package/lib/rendezvous/transports/index.js +0 -18
- package/lib/rendezvous/transports/index.js.map +0 -1
- package/lib/rust-crypto/CrossSigningIdentity.d.ts +0 -33
- package/lib/rust-crypto/CrossSigningIdentity.d.ts.map +0 -1
- package/lib/rust-crypto/CrossSigningIdentity.js +0 -157
- package/lib/rust-crypto/CrossSigningIdentity.js.map +0 -1
- package/lib/rust-crypto/DehydratedDeviceManager.d.ts +0 -98
- package/lib/rust-crypto/DehydratedDeviceManager.d.ts.map +0 -1
- package/lib/rust-crypto/DehydratedDeviceManager.js +0 -285
- package/lib/rust-crypto/DehydratedDeviceManager.js.map +0 -1
- package/lib/rust-crypto/KeyClaimManager.d.ts +0 -33
- package/lib/rust-crypto/KeyClaimManager.d.ts.map +0 -1
- package/lib/rust-crypto/KeyClaimManager.js +0 -82
- package/lib/rust-crypto/KeyClaimManager.js.map +0 -1
- package/lib/rust-crypto/OutgoingRequestProcessor.d.ts +0 -43
- package/lib/rust-crypto/OutgoingRequestProcessor.d.ts.map +0 -1
- package/lib/rust-crypto/OutgoingRequestProcessor.js +0 -195
- package/lib/rust-crypto/OutgoingRequestProcessor.js.map +0 -1
- package/lib/rust-crypto/OutgoingRequestsManager.d.ts +0 -47
- package/lib/rust-crypto/OutgoingRequestsManager.d.ts.map +0 -1
- package/lib/rust-crypto/OutgoingRequestsManager.js +0 -148
- package/lib/rust-crypto/OutgoingRequestsManager.js.map +0 -1
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts +0 -120
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts.map +0 -1
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.js +0 -467
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.js.map +0 -1
- package/lib/rust-crypto/RoomEncryptor.d.ts +0 -98
- package/lib/rust-crypto/RoomEncryptor.d.ts.map +0 -1
- package/lib/rust-crypto/RoomEncryptor.js +0 -299
- package/lib/rust-crypto/RoomEncryptor.js.map +0 -1
- package/lib/rust-crypto/backup.d.ts +0 -254
- package/lib/rust-crypto/backup.d.ts.map +0 -1
- package/lib/rust-crypto/backup.js +0 -837
- package/lib/rust-crypto/backup.js.map +0 -1
- package/lib/rust-crypto/constants.d.ts +0 -3
- package/lib/rust-crypto/constants.d.ts.map +0 -1
- package/lib/rust-crypto/constants.js +0 -19
- package/lib/rust-crypto/constants.js.map +0 -1
- package/lib/rust-crypto/device-converter.d.ts +0 -28
- package/lib/rust-crypto/device-converter.d.ts.map +0 -1
- package/lib/rust-crypto/device-converter.js +0 -123
- package/lib/rust-crypto/device-converter.js.map +0 -1
- package/lib/rust-crypto/index.d.ts +0 -61
- package/lib/rust-crypto/index.d.ts.map +0 -1
- package/lib/rust-crypto/index.js +0 -152
- package/lib/rust-crypto/index.js.map +0 -1
- package/lib/rust-crypto/libolm_migration.d.ts +0 -81
- package/lib/rust-crypto/libolm_migration.d.ts.map +0 -1
- package/lib/rust-crypto/libolm_migration.js +0 -459
- package/lib/rust-crypto/libolm_migration.js.map +0 -1
- package/lib/rust-crypto/rust-crypto.d.ts +0 -556
- package/lib/rust-crypto/rust-crypto.d.ts.map +0 -1
- package/lib/rust-crypto/rust-crypto.js +0 -2016
- package/lib/rust-crypto/rust-crypto.js.map +0 -1
- package/lib/rust-crypto/secret-storage.d.ts +0 -22
- package/lib/rust-crypto/secret-storage.d.ts.map +0 -1
- package/lib/rust-crypto/secret-storage.js +0 -63
- package/lib/rust-crypto/secret-storage.js.map +0 -1
- package/lib/rust-crypto/verification.d.ts +0 -319
- package/lib/rust-crypto/verification.d.ts.map +0 -1
- package/lib/rust-crypto/verification.js +0 -816
- package/lib/rust-crypto/verification.js.map +0 -1
- package/lib/secret-storage.d.ts +0 -370
- package/lib/secret-storage.d.ts.map +0 -1
- package/lib/secret-storage.js +0 -466
- package/lib/secret-storage.js.map +0 -1
- package/lib/webrtc/audioContext.d.ts +0 -15
- package/lib/webrtc/audioContext.d.ts.map +0 -1
- package/lib/webrtc/audioContext.js +0 -46
- package/lib/webrtc/audioContext.js.map +0 -1
- package/lib/webrtc/call.d.ts +0 -560
- package/lib/webrtc/call.d.ts.map +0 -1
- package/lib/webrtc/call.js +0 -2541
- package/lib/webrtc/call.js.map +0 -1
- package/lib/webrtc/callEventHandler.d.ts +0 -37
- package/lib/webrtc/callEventHandler.d.ts.map +0 -1
- package/lib/webrtc/callEventHandler.js +0 -344
- package/lib/webrtc/callEventHandler.js.map +0 -1
- package/lib/webrtc/callEventTypes.d.ts +0 -73
- package/lib/webrtc/callEventTypes.d.ts.map +0 -1
- package/lib/webrtc/callEventTypes.js +0 -13
- package/lib/webrtc/callEventTypes.js.map +0 -1
- package/lib/webrtc/callFeed.d.ts +0 -128
- package/lib/webrtc/callFeed.d.ts.map +0 -1
- package/lib/webrtc/callFeed.js +0 -289
- package/lib/webrtc/callFeed.js.map +0 -1
- package/lib/webrtc/groupCall.d.ts +0 -323
- package/lib/webrtc/groupCall.d.ts.map +0 -1
- package/lib/webrtc/groupCall.js +0 -1337
- package/lib/webrtc/groupCall.js.map +0 -1
- package/lib/webrtc/groupCallEventHandler.d.ts +0 -31
- package/lib/webrtc/groupCallEventHandler.d.ts.map +0 -1
- package/lib/webrtc/groupCallEventHandler.js +0 -178
- package/lib/webrtc/groupCallEventHandler.js.map +0 -1
- package/lib/webrtc/mediaHandler.d.ts +0 -89
- package/lib/webrtc/mediaHandler.d.ts.map +0 -1
- package/lib/webrtc/mediaHandler.js +0 -437
- package/lib/webrtc/mediaHandler.js.map +0 -1
- package/lib/webrtc/stats/callFeedStatsReporter.d.ts +0 -8
- package/lib/webrtc/stats/callFeedStatsReporter.d.ts.map +0 -1
- package/lib/webrtc/stats/callFeedStatsReporter.js +0 -82
- package/lib/webrtc/stats/callFeedStatsReporter.js.map +0 -1
- package/lib/webrtc/stats/callStatsReportGatherer.d.ts +0 -25
- package/lib/webrtc/stats/callStatsReportGatherer.d.ts.map +0 -1
- package/lib/webrtc/stats/callStatsReportGatherer.js +0 -199
- package/lib/webrtc/stats/callStatsReportGatherer.js.map +0 -1
- package/lib/webrtc/stats/callStatsReportSummary.d.ts +0 -17
- package/lib/webrtc/stats/callStatsReportSummary.d.ts.map +0 -1
- package/lib/webrtc/stats/callStatsReportSummary.js +0 -1
- package/lib/webrtc/stats/callStatsReportSummary.js.map +0 -1
- package/lib/webrtc/stats/connectionStats.d.ts +0 -28
- package/lib/webrtc/stats/connectionStats.d.ts.map +0 -1
- package/lib/webrtc/stats/connectionStats.js +0 -26
- package/lib/webrtc/stats/connectionStats.js.map +0 -1
- package/lib/webrtc/stats/connectionStatsBuilder.d.ts +0 -5
- package/lib/webrtc/stats/connectionStatsBuilder.d.ts.map +0 -1
- package/lib/webrtc/stats/connectionStatsBuilder.js +0 -27
- package/lib/webrtc/stats/connectionStatsBuilder.js.map +0 -1
- package/lib/webrtc/stats/connectionStatsReportBuilder.d.ts +0 -7
- package/lib/webrtc/stats/connectionStatsReportBuilder.d.ts.map +0 -1
- package/lib/webrtc/stats/connectionStatsReportBuilder.js +0 -121
- package/lib/webrtc/stats/connectionStatsReportBuilder.js.map +0 -1
- package/lib/webrtc/stats/groupCallStats.d.ts +0 -22
- package/lib/webrtc/stats/groupCallStats.d.ts.map +0 -1
- package/lib/webrtc/stats/groupCallStats.js +0 -78
- package/lib/webrtc/stats/groupCallStats.js.map +0 -1
- package/lib/webrtc/stats/media/mediaSsrcHandler.d.ts +0 -10
- package/lib/webrtc/stats/media/mediaSsrcHandler.d.ts.map +0 -1
- package/lib/webrtc/stats/media/mediaSsrcHandler.js +0 -57
- package/lib/webrtc/stats/media/mediaSsrcHandler.js.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackHandler.d.ts +0 -12
- package/lib/webrtc/stats/media/mediaTrackHandler.d.ts.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackHandler.js +0 -62
- package/lib/webrtc/stats/media/mediaTrackHandler.js.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackStats.d.ts +0 -86
- package/lib/webrtc/stats/media/mediaTrackStats.d.ts.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackStats.js +0 -142
- package/lib/webrtc/stats/media/mediaTrackStats.js.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.d.ts +0 -22
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.d.ts.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.js +0 -76
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.js.map +0 -1
- package/lib/webrtc/stats/statsReport.d.ts +0 -99
- package/lib/webrtc/stats/statsReport.d.ts.map +0 -1
- package/lib/webrtc/stats/statsReport.js +0 -32
- package/lib/webrtc/stats/statsReport.js.map +0 -1
- package/lib/webrtc/stats/statsReportEmitter.d.ts +0 -15
- package/lib/webrtc/stats/statsReportEmitter.d.ts.map +0 -1
- package/lib/webrtc/stats/statsReportEmitter.js +0 -33
- package/lib/webrtc/stats/statsReportEmitter.js.map +0 -1
- package/lib/webrtc/stats/summaryStatsReportGatherer.d.ts +0 -16
- package/lib/webrtc/stats/summaryStatsReportGatherer.d.ts.map +0 -1
- package/lib/webrtc/stats/summaryStatsReportGatherer.js +0 -116
- package/lib/webrtc/stats/summaryStatsReportGatherer.js.map +0 -1
- package/lib/webrtc/stats/trackStatsBuilder.d.ts +0 -19
- package/lib/webrtc/stats/trackStatsBuilder.d.ts.map +0 -1
- package/lib/webrtc/stats/trackStatsBuilder.js +0 -168
- package/lib/webrtc/stats/trackStatsBuilder.js.map +0 -1
- package/lib/webrtc/stats/transportStats.d.ts +0 -11
- package/lib/webrtc/stats/transportStats.d.ts.map +0 -1
- package/lib/webrtc/stats/transportStats.js +0 -1
- package/lib/webrtc/stats/transportStats.js.map +0 -1
- package/lib/webrtc/stats/transportStatsBuilder.d.ts +0 -5
- package/lib/webrtc/stats/transportStatsBuilder.d.ts.map +0 -1
- package/lib/webrtc/stats/transportStatsBuilder.js +0 -34
- package/lib/webrtc/stats/transportStatsBuilder.js.map +0 -1
- package/lib/webrtc/stats/valueFormatter.d.ts +0 -4
- package/lib/webrtc/stats/valueFormatter.d.ts.map +0 -1
- package/lib/webrtc/stats/valueFormatter.js +0 -25
- package/lib/webrtc/stats/valueFormatter.js.map +0 -1
- package/src/@types/crypto.ts +0 -73
- package/src/@types/matrix-sdk-crypto-wasm.d.ts +0 -44
- package/src/common-crypto/CryptoBackend.ts +0 -302
- package/src/common-crypto/README.md +0 -4
- package/src/common-crypto/key-passphrase.ts +0 -43
- package/src/crypto/CrossSigning.ts +0 -773
- package/src/crypto/DeviceList.ts +0 -989
- package/src/crypto/EncryptionSetup.ts +0 -351
- package/src/crypto/OlmDevice.ts +0 -1500
- package/src/crypto/OutgoingRoomKeyRequestManager.ts +0 -485
- package/src/crypto/RoomList.ts +0 -70
- package/src/crypto/SecretSharing.ts +0 -240
- package/src/crypto/SecretStorage.ts +0 -136
- package/src/crypto/aes.ts +0 -23
- package/src/crypto/algorithms/base.ts +0 -236
- package/src/crypto/algorithms/index.ts +0 -20
- package/src/crypto/algorithms/megolm.ts +0 -2216
- package/src/crypto/algorithms/olm.ts +0 -381
- package/src/crypto/api.ts +0 -70
- package/src/crypto/backup.ts +0 -922
- package/src/crypto/crypto.ts +0 -18
- package/src/crypto/dehydration.ts +0 -272
- package/src/crypto/device-converter.ts +0 -45
- package/src/crypto/deviceinfo.ts +0 -158
- package/src/crypto/index.ts +0 -4414
- package/src/crypto/key_passphrase.ts +0 -42
- package/src/crypto/keybackup.ts +0 -47
- package/src/crypto/olmlib.ts +0 -539
- package/src/crypto/recoverykey.ts +0 -18
- package/src/crypto/store/base.ts +0 -348
- package/src/crypto/store/indexeddb-crypto-store-backend.ts +0 -1250
- package/src/crypto/store/indexeddb-crypto-store.ts +0 -845
- package/src/crypto/store/localStorage-crypto-store.ts +0 -579
- package/src/crypto/store/memory-crypto-store.ts +0 -680
- package/src/crypto/verification/Base.ts +0 -409
- package/src/crypto/verification/Error.ts +0 -76
- package/src/crypto/verification/IllegalMethod.ts +0 -50
- package/src/crypto/verification/QRCode.ts +0 -310
- package/src/crypto/verification/SAS.ts +0 -494
- package/src/crypto/verification/SASDecimal.ts +0 -37
- package/src/crypto/verification/request/Channel.ts +0 -34
- package/src/crypto/verification/request/InRoomChannel.ts +0 -371
- package/src/crypto/verification/request/ToDeviceChannel.ts +0 -354
- package/src/crypto/verification/request/VerificationRequest.ts +0 -976
- package/src/crypto-api/CryptoEvent.ts +0 -93
- package/src/crypto-api/CryptoEventHandlerMap.ts +0 -32
- package/src/crypto-api/index.ts +0 -1175
- package/src/crypto-api/key-passphrase.ts +0 -58
- package/src/crypto-api/keybackup.ts +0 -115
- package/src/crypto-api/recovery-key.ts +0 -69
- package/src/crypto-api/verification.ts +0 -408
- package/src/matrixrtc/CallMembership.ts +0 -247
- package/src/matrixrtc/LivekitFocus.ts +0 -39
- package/src/matrixrtc/MatrixRTCSession.ts +0 -1319
- package/src/matrixrtc/MatrixRTCSessionManager.ts +0 -166
- package/src/matrixrtc/focus.ts +0 -25
- package/src/matrixrtc/index.ts +0 -22
- package/src/matrixrtc/types.ts +0 -36
- package/src/rendezvous/MSC4108SignInWithQR.ts +0 -444
- package/src/rendezvous/RendezvousChannel.ts +0 -48
- package/src/rendezvous/RendezvousCode.ts +0 -25
- package/src/rendezvous/RendezvousError.ts +0 -26
- package/src/rendezvous/RendezvousFailureReason.ts +0 -49
- package/src/rendezvous/RendezvousIntent.ts +0 -20
- package/src/rendezvous/RendezvousTransport.ts +0 -58
- package/src/rendezvous/channels/MSC4108SecureChannel.ts +0 -270
- package/src/rendezvous/channels/index.ts +0 -17
- package/src/rendezvous/index.ts +0 -25
- package/src/rendezvous/transports/MSC4108RendezvousSession.ts +0 -270
- package/src/rendezvous/transports/index.ts +0 -17
- package/src/rust-crypto/CrossSigningIdentity.ts +0 -183
- package/src/rust-crypto/DehydratedDeviceManager.ts +0 -306
- package/src/rust-crypto/KeyClaimManager.ts +0 -86
- package/src/rust-crypto/OutgoingRequestProcessor.ts +0 -236
- package/src/rust-crypto/OutgoingRequestsManager.ts +0 -143
- package/src/rust-crypto/PerSessionKeyBackupDownloader.ts +0 -501
- package/src/rust-crypto/RoomEncryptor.ts +0 -352
- package/src/rust-crypto/backup.ts +0 -881
- package/src/rust-crypto/constants.ts +0 -18
- package/src/rust-crypto/device-converter.ts +0 -128
- package/src/rust-crypto/index.ts +0 -237
- package/src/rust-crypto/libolm_migration.ts +0 -530
- package/src/rust-crypto/rust-crypto.ts +0 -2205
- package/src/rust-crypto/secret-storage.ts +0 -60
- package/src/rust-crypto/verification.ts +0 -830
- package/src/secret-storage.ts +0 -693
- package/src/webrtc/audioContext.ts +0 -44
- package/src/webrtc/call.ts +0 -3074
- package/src/webrtc/callEventHandler.ts +0 -425
- package/src/webrtc/callEventTypes.ts +0 -93
- package/src/webrtc/callFeed.ts +0 -364
- package/src/webrtc/groupCall.ts +0 -1735
- package/src/webrtc/groupCallEventHandler.ts +0 -234
- package/src/webrtc/mediaHandler.ts +0 -484
- package/src/webrtc/stats/callFeedStatsReporter.ts +0 -94
- package/src/webrtc/stats/callStatsReportGatherer.ts +0 -219
- package/src/webrtc/stats/callStatsReportSummary.ts +0 -30
- package/src/webrtc/stats/connectionStats.ts +0 -47
- package/src/webrtc/stats/connectionStatsBuilder.ts +0 -28
- package/src/webrtc/stats/connectionStatsReportBuilder.ts +0 -140
- package/src/webrtc/stats/groupCallStats.ts +0 -93
- package/src/webrtc/stats/media/mediaSsrcHandler.ts +0 -57
- package/src/webrtc/stats/media/mediaTrackHandler.ts +0 -76
- package/src/webrtc/stats/media/mediaTrackStats.ts +0 -176
- package/src/webrtc/stats/media/mediaTrackStatsHandler.ts +0 -90
- package/src/webrtc/stats/statsReport.ts +0 -133
- package/src/webrtc/stats/statsReportEmitter.ts +0 -49
- package/src/webrtc/stats/summaryStatsReportGatherer.ts +0 -148
- package/src/webrtc/stats/trackStatsBuilder.ts +0 -207
- package/src/webrtc/stats/transportStats.ts +0 -26
- package/src/webrtc/stats/transportStatsBuilder.ts +0 -48
- package/src/webrtc/stats/valueFormatter.ts +0 -27
package/lib/secret-storage.js
DELETED
@@ -1,466 +0,0 @@
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
2
|
-
/*
|
3
|
-
Copyright 2021-2023 The Matrix.org Foundation C.I.C.
|
4
|
-
|
5
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
you may not use this file except in compliance with the License.
|
7
|
-
You may obtain a copy of the License at
|
8
|
-
|
9
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
|
11
|
-
Unless required by applicable law or agreed to in writing, software
|
12
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
See the License for the specific language governing permissions and
|
15
|
-
limitations under the License.
|
16
|
-
*/
|
17
|
-
|
18
|
-
/**
|
19
|
-
* Implementation of server-side secret storage
|
20
|
-
*
|
21
|
-
* @see https://spec.matrix.org/v1.6/client-server-api/#storage
|
22
|
-
*/
|
23
|
-
|
24
|
-
import { ClientEvent } from "./client.js";
|
25
|
-
import { randomString } from "./randomstring.js";
|
26
|
-
import { logger } from "./logger.js";
|
27
|
-
import encryptAESSecretStorageItem from "./utils/encryptAESSecretStorageItem.js";
|
28
|
-
import decryptAESSecretStorageItem from "./utils/decryptAESSecretStorageItem.js";
|
29
|
-
export var SECRET_STORAGE_ALGORITHM_V1_AES = "m.secret_storage.v1.aes-hmac-sha2";
|
30
|
-
|
31
|
-
/**
|
32
|
-
* Common base interface for Secret Storage Keys.
|
33
|
-
*
|
34
|
-
* The common properties for all encryption keys used in server-side secret storage.
|
35
|
-
*
|
36
|
-
* @see https://spec.matrix.org/v1.6/client-server-api/#key-storage
|
37
|
-
*/
|
38
|
-
|
39
|
-
/**
|
40
|
-
* Properties for a SSSS key using the `m.secret_storage.v1.aes-hmac-sha2` algorithm.
|
41
|
-
*
|
42
|
-
* Corresponds to `AesHmacSha2KeyDescription` in the specification.
|
43
|
-
*
|
44
|
-
* @see https://spec.matrix.org/v1.6/client-server-api/#msecret_storagev1aes-hmac-sha2
|
45
|
-
*/
|
46
|
-
|
47
|
-
/**
|
48
|
-
* Union type for secret storage keys.
|
49
|
-
*
|
50
|
-
* For now, this is only {@link SecretStorageKeyDescriptionAesV1}, but other interfaces may be added in future.
|
51
|
-
*/
|
52
|
-
|
53
|
-
/**
|
54
|
-
* Information on how to generate the key from a passphrase.
|
55
|
-
*
|
56
|
-
* @see https://spec.matrix.org/v1.6/client-server-api/#deriving-keys-from-passphrases
|
57
|
-
*/
|
58
|
-
|
59
|
-
/**
|
60
|
-
* Options for {@link ServerSideSecretStorageImpl#addKey}.
|
61
|
-
*/
|
62
|
-
|
63
|
-
/**
|
64
|
-
* Return type for {@link ServerSideSecretStorageImpl#getKey}.
|
65
|
-
*/
|
66
|
-
|
67
|
-
/**
|
68
|
-
* Return type for {@link ServerSideSecretStorageImpl#addKey}.
|
69
|
-
*/
|
70
|
-
|
71
|
-
/** Interface for managing account data on the server.
|
72
|
-
*
|
73
|
-
* A subset of {@link MatrixClient}.
|
74
|
-
*/
|
75
|
-
|
76
|
-
/**
|
77
|
-
* Application callbacks for use with {@link SecretStorage.ServerSideSecretStorageImpl}
|
78
|
-
*/
|
79
|
-
|
80
|
-
/**
|
81
|
-
* Interface provided by SecretStorage implementations
|
82
|
-
*
|
83
|
-
* Normally this will just be an {@link ServerSideSecretStorageImpl}, but for backwards
|
84
|
-
* compatibility some methods allow other implementations.
|
85
|
-
*/
|
86
|
-
|
87
|
-
/**
|
88
|
-
* Implementation of Server-side secret storage.
|
89
|
-
*
|
90
|
-
* Secret *sharing* is *not* implemented here: this class is strictly about the storage component of
|
91
|
-
* SSSS.
|
92
|
-
*
|
93
|
-
* @see https://spec.matrix.org/v1.6/client-server-api/#storage
|
94
|
-
*/
|
95
|
-
export class ServerSideSecretStorageImpl {
|
96
|
-
/**
|
97
|
-
* Construct a new `SecretStorage`.
|
98
|
-
*
|
99
|
-
* Normally, it is unnecessary to call this directly, since MatrixClient automatically constructs one.
|
100
|
-
* However, it may be useful to construct a new `SecretStorage`, if custom `callbacks` are required, for example.
|
101
|
-
*
|
102
|
-
* @param accountDataAdapter - interface for fetching and setting account data on the server. Normally an instance
|
103
|
-
* of {@link MatrixClient}.
|
104
|
-
* @param callbacks - application level callbacks for retrieving secret keys
|
105
|
-
*/
|
106
|
-
constructor(accountDataAdapter, callbacks) {
|
107
|
-
this.accountDataAdapter = accountDataAdapter;
|
108
|
-
this.callbacks = callbacks;
|
109
|
-
}
|
110
|
-
|
111
|
-
/**
|
112
|
-
* Get the current default key ID for encrypting secrets.
|
113
|
-
*
|
114
|
-
* @returns The default key ID or null if no default key ID is set
|
115
|
-
*/
|
116
|
-
getDefaultKeyId() {
|
117
|
-
var _this = this;
|
118
|
-
return _asyncToGenerator(function* () {
|
119
|
-
var defaultKey = yield _this.accountDataAdapter.getAccountDataFromServer("m.secret_storage.default_key");
|
120
|
-
if (!defaultKey) return null;
|
121
|
-
return defaultKey.key;
|
122
|
-
})();
|
123
|
-
}
|
124
|
-
|
125
|
-
/**
|
126
|
-
* Set the default key ID for encrypting secrets.
|
127
|
-
*
|
128
|
-
* @param keyId - The new default key ID
|
129
|
-
*/
|
130
|
-
setDefaultKeyId(keyId) {
|
131
|
-
return new Promise((resolve, reject) => {
|
132
|
-
var listener = ev => {
|
133
|
-
if (ev.getType() === "m.secret_storage.default_key" && ev.getContent().key === keyId) {
|
134
|
-
this.accountDataAdapter.removeListener(ClientEvent.AccountData, listener);
|
135
|
-
resolve();
|
136
|
-
}
|
137
|
-
};
|
138
|
-
this.accountDataAdapter.on(ClientEvent.AccountData, listener);
|
139
|
-
this.accountDataAdapter.setAccountData("m.secret_storage.default_key", {
|
140
|
-
key: keyId
|
141
|
-
}).catch(e => {
|
142
|
-
this.accountDataAdapter.removeListener(ClientEvent.AccountData, listener);
|
143
|
-
reject(e);
|
144
|
-
});
|
145
|
-
});
|
146
|
-
}
|
147
|
-
|
148
|
-
/**
|
149
|
-
* Add a key for encrypting secrets.
|
150
|
-
*
|
151
|
-
* @param algorithm - the algorithm used by the key.
|
152
|
-
* @param opts - the options for the algorithm. The properties used
|
153
|
-
* depend on the algorithm given.
|
154
|
-
* @param keyId - the ID of the key. If not given, a random
|
155
|
-
* ID will be generated.
|
156
|
-
*
|
157
|
-
* @returns An object with:
|
158
|
-
* keyId: the ID of the key
|
159
|
-
* keyInfo: details about the key (iv, mac, passphrase)
|
160
|
-
*/
|
161
|
-
addKey(algorithm, opts, keyId) {
|
162
|
-
var _this2 = this;
|
163
|
-
return _asyncToGenerator(function* () {
|
164
|
-
if (algorithm !== SECRET_STORAGE_ALGORITHM_V1_AES) {
|
165
|
-
throw new Error("Unknown key algorithm ".concat(algorithm));
|
166
|
-
}
|
167
|
-
var keyInfo = {
|
168
|
-
algorithm
|
169
|
-
};
|
170
|
-
if (opts.name) {
|
171
|
-
keyInfo.name = opts.name;
|
172
|
-
}
|
173
|
-
if (opts.passphrase) {
|
174
|
-
keyInfo.passphrase = opts.passphrase;
|
175
|
-
}
|
176
|
-
var {
|
177
|
-
iv,
|
178
|
-
mac
|
179
|
-
} = yield calculateKeyCheck(opts.key);
|
180
|
-
keyInfo.iv = iv;
|
181
|
-
keyInfo.mac = mac;
|
182
|
-
|
183
|
-
// Create a unique key id. XXX: this is racey.
|
184
|
-
if (!keyId) {
|
185
|
-
do {
|
186
|
-
keyId = randomString(32);
|
187
|
-
} while (yield _this2.accountDataAdapter.getAccountDataFromServer("m.secret_storage.key.".concat(keyId)));
|
188
|
-
}
|
189
|
-
yield _this2.accountDataAdapter.setAccountData("m.secret_storage.key.".concat(keyId), keyInfo);
|
190
|
-
return {
|
191
|
-
keyId,
|
192
|
-
keyInfo
|
193
|
-
};
|
194
|
-
})();
|
195
|
-
}
|
196
|
-
|
197
|
-
/**
|
198
|
-
* Get the key information for a given ID.
|
199
|
-
*
|
200
|
-
* @param keyId - The ID of the key to check
|
201
|
-
* for. Defaults to the default key ID if not provided.
|
202
|
-
* @returns If the key was found, the return value is an array of
|
203
|
-
* the form [keyId, keyInfo]. Otherwise, null is returned.
|
204
|
-
* XXX: why is this an array when addKey returns an object?
|
205
|
-
*/
|
206
|
-
getKey(keyId) {
|
207
|
-
var _this3 = this;
|
208
|
-
return _asyncToGenerator(function* () {
|
209
|
-
if (!keyId) {
|
210
|
-
keyId = yield _this3.getDefaultKeyId();
|
211
|
-
}
|
212
|
-
if (!keyId) {
|
213
|
-
return null;
|
214
|
-
}
|
215
|
-
var keyInfo = yield _this3.accountDataAdapter.getAccountDataFromServer("m.secret_storage.key." + keyId);
|
216
|
-
return keyInfo ? [keyId, keyInfo] : null;
|
217
|
-
})();
|
218
|
-
}
|
219
|
-
|
220
|
-
/**
|
221
|
-
* Check whether we have a key with a given ID.
|
222
|
-
*
|
223
|
-
* @param keyId - The ID of the key to check
|
224
|
-
* for. Defaults to the default key ID if not provided.
|
225
|
-
* @returns Whether we have the key.
|
226
|
-
*/
|
227
|
-
hasKey(keyId) {
|
228
|
-
var _this4 = this;
|
229
|
-
return _asyncToGenerator(function* () {
|
230
|
-
var key = yield _this4.getKey(keyId);
|
231
|
-
return Boolean(key);
|
232
|
-
})();
|
233
|
-
}
|
234
|
-
|
235
|
-
/**
|
236
|
-
* Check whether a key matches what we expect based on the key info
|
237
|
-
*
|
238
|
-
* @param key - the key to check
|
239
|
-
* @param info - the key info
|
240
|
-
*
|
241
|
-
* @returns whether or not the key matches
|
242
|
-
*/
|
243
|
-
checkKey(key, info) {
|
244
|
-
return _asyncToGenerator(function* () {
|
245
|
-
if (info.algorithm === SECRET_STORAGE_ALGORITHM_V1_AES) {
|
246
|
-
if (info.mac) {
|
247
|
-
var {
|
248
|
-
mac
|
249
|
-
} = yield calculateKeyCheck(key, info.iv);
|
250
|
-
return trimTrailingEquals(info.mac) === trimTrailingEquals(mac);
|
251
|
-
} else {
|
252
|
-
// if we have no information, we have to assume the key is right
|
253
|
-
return true;
|
254
|
-
}
|
255
|
-
} else {
|
256
|
-
throw new Error("Unknown algorithm");
|
257
|
-
}
|
258
|
-
})();
|
259
|
-
}
|
260
|
-
|
261
|
-
/**
|
262
|
-
* Store an encrypted secret on the server.
|
263
|
-
*
|
264
|
-
* Details of the encryption keys to be used must previously have been stored in account data
|
265
|
-
* (for example, via {@link ServerSideSecretStorageImpl#addKey}. {@link SecretStorageCallbacks#getSecretStorageKey} will be called to obtain a secret storage
|
266
|
-
* key to decrypt the secret.
|
267
|
-
*
|
268
|
-
* @param name - The name of the secret - i.e., the "event type" to be stored in the account data
|
269
|
-
* @param secret - The secret contents.
|
270
|
-
* @param keys - The IDs of the keys to use to encrypt the secret, or null/undefined to use the default key.
|
271
|
-
*/
|
272
|
-
store(name, secret, keys) {
|
273
|
-
var _this5 = this;
|
274
|
-
return _asyncToGenerator(function* () {
|
275
|
-
var encrypted = {};
|
276
|
-
if (!keys) {
|
277
|
-
var defaultKeyId = yield _this5.getDefaultKeyId();
|
278
|
-
if (!defaultKeyId) {
|
279
|
-
throw new Error("No keys specified and no default key present");
|
280
|
-
}
|
281
|
-
keys = [defaultKeyId];
|
282
|
-
}
|
283
|
-
if (keys.length === 0) {
|
284
|
-
throw new Error("Zero keys given to encrypt with!");
|
285
|
-
}
|
286
|
-
for (var _keyId of keys) {
|
287
|
-
// get key information from key storage
|
288
|
-
var _keyInfo = yield _this5.accountDataAdapter.getAccountDataFromServer("m.secret_storage.key." + _keyId);
|
289
|
-
if (!_keyInfo) {
|
290
|
-
throw new Error("Unknown key: " + _keyId);
|
291
|
-
}
|
292
|
-
|
293
|
-
// encrypt secret, based on the algorithm
|
294
|
-
if (_keyInfo.algorithm === SECRET_STORAGE_ALGORITHM_V1_AES) {
|
295
|
-
var _keys = {
|
296
|
-
[_keyId]: _keyInfo
|
297
|
-
};
|
298
|
-
var [, encryption] = yield _this5.getSecretStorageKey(_keys, name);
|
299
|
-
encrypted[_keyId] = yield encryption.encrypt(secret);
|
300
|
-
} else {
|
301
|
-
logger.warn("unknown algorithm for secret storage key " + _keyId + ": " + _keyInfo.algorithm);
|
302
|
-
// do nothing if we don't understand the encryption algorithm
|
303
|
-
}
|
304
|
-
}
|
305
|
-
|
306
|
-
// save encrypted secret
|
307
|
-
yield _this5.accountDataAdapter.setAccountData(name, {
|
308
|
-
encrypted
|
309
|
-
});
|
310
|
-
})();
|
311
|
-
}
|
312
|
-
|
313
|
-
/**
|
314
|
-
* Get a secret from storage, and decrypt it.
|
315
|
-
*
|
316
|
-
* {@link SecretStorageCallbacks#getSecretStorageKey} will be called to obtain a secret storage
|
317
|
-
* key to decrypt the secret.
|
318
|
-
*
|
319
|
-
* @param name - the name of the secret - i.e., the "event type" stored in the account data
|
320
|
-
*
|
321
|
-
* @returns the decrypted contents of the secret, or "undefined" if `name` is not found in
|
322
|
-
* the user's account data.
|
323
|
-
*/
|
324
|
-
get(name) {
|
325
|
-
var _this6 = this;
|
326
|
-
return _asyncToGenerator(function* () {
|
327
|
-
var secretInfo = yield _this6.accountDataAdapter.getAccountDataFromServer(name);
|
328
|
-
if (!secretInfo) {
|
329
|
-
return;
|
330
|
-
}
|
331
|
-
if (!secretInfo.encrypted) {
|
332
|
-
throw new Error("Content is not encrypted!");
|
333
|
-
}
|
334
|
-
|
335
|
-
// get possible keys to decrypt
|
336
|
-
var keys = {};
|
337
|
-
for (var _keyId2 of Object.keys(secretInfo.encrypted)) {
|
338
|
-
// get key information from key storage
|
339
|
-
var _keyInfo2 = yield _this6.accountDataAdapter.getAccountDataFromServer("m.secret_storage.key." + _keyId2);
|
340
|
-
var _encInfo = secretInfo.encrypted[_keyId2];
|
341
|
-
// only use keys we understand the encryption algorithm of
|
342
|
-
if ((_keyInfo2 === null || _keyInfo2 === void 0 ? void 0 : _keyInfo2.algorithm) === SECRET_STORAGE_ALGORITHM_V1_AES) {
|
343
|
-
if (_encInfo.iv && _encInfo.ciphertext && _encInfo.mac) {
|
344
|
-
keys[_keyId2] = _keyInfo2;
|
345
|
-
}
|
346
|
-
}
|
347
|
-
}
|
348
|
-
if (Object.keys(keys).length === 0) {
|
349
|
-
throw new Error("Could not decrypt ".concat(name, " because none of ") + "the keys it is encrypted with are for a supported algorithm");
|
350
|
-
}
|
351
|
-
|
352
|
-
// fetch private key from app
|
353
|
-
var [keyId, decryption] = yield _this6.getSecretStorageKey(keys, name);
|
354
|
-
var encInfo = secretInfo.encrypted[keyId];
|
355
|
-
return decryption.decrypt(encInfo);
|
356
|
-
})();
|
357
|
-
}
|
358
|
-
|
359
|
-
/**
|
360
|
-
* Check if a secret is stored on the server.
|
361
|
-
*
|
362
|
-
* @param name - the name of the secret
|
363
|
-
*
|
364
|
-
* @returns map of key name to key info the secret is encrypted
|
365
|
-
* with, or null if it is not present or not encrypted with a trusted
|
366
|
-
* key
|
367
|
-
*/
|
368
|
-
isStored(name) {
|
369
|
-
var _this7 = this;
|
370
|
-
return _asyncToGenerator(function* () {
|
371
|
-
// check if secret exists
|
372
|
-
var secretInfo = yield _this7.accountDataAdapter.getAccountDataFromServer(name);
|
373
|
-
if (!(secretInfo !== null && secretInfo !== void 0 && secretInfo.encrypted)) return null;
|
374
|
-
var ret = {};
|
375
|
-
|
376
|
-
// filter secret encryption keys with supported algorithm
|
377
|
-
for (var _keyId3 of Object.keys(secretInfo.encrypted)) {
|
378
|
-
// get key information from key storage
|
379
|
-
var _keyInfo3 = yield _this7.accountDataAdapter.getAccountDataFromServer("m.secret_storage.key." + _keyId3);
|
380
|
-
if (!_keyInfo3) continue;
|
381
|
-
var encInfo = secretInfo.encrypted[_keyId3];
|
382
|
-
|
383
|
-
// only use keys we understand the encryption algorithm of
|
384
|
-
if (_keyInfo3.algorithm === SECRET_STORAGE_ALGORITHM_V1_AES) {
|
385
|
-
if (encInfo.iv && encInfo.ciphertext && encInfo.mac) {
|
386
|
-
ret[_keyId3] = _keyInfo3;
|
387
|
-
}
|
388
|
-
}
|
389
|
-
}
|
390
|
-
return Object.keys(ret).length ? ret : null;
|
391
|
-
})();
|
392
|
-
}
|
393
|
-
getSecretStorageKey(keys, name) {
|
394
|
-
var _this8 = this;
|
395
|
-
return _asyncToGenerator(function* () {
|
396
|
-
if (!_this8.callbacks.getSecretStorageKey) {
|
397
|
-
throw new Error("No getSecretStorageKey callback supplied");
|
398
|
-
}
|
399
|
-
var returned = yield _this8.callbacks.getSecretStorageKey({
|
400
|
-
keys
|
401
|
-
}, name);
|
402
|
-
if (!returned) {
|
403
|
-
throw new Error("getSecretStorageKey callback returned falsey");
|
404
|
-
}
|
405
|
-
if (returned.length < 2) {
|
406
|
-
throw new Error("getSecretStorageKey callback returned invalid data");
|
407
|
-
}
|
408
|
-
var [keyId, privateKey] = returned;
|
409
|
-
if (!keys[keyId]) {
|
410
|
-
throw new Error("App returned unknown key from getSecretStorageKey!");
|
411
|
-
}
|
412
|
-
if (keys[keyId].algorithm === SECRET_STORAGE_ALGORITHM_V1_AES) {
|
413
|
-
var decryption = {
|
414
|
-
encrypt: function encrypt(secret) {
|
415
|
-
return encryptAESSecretStorageItem(secret, privateKey, name);
|
416
|
-
},
|
417
|
-
decrypt: function decrypt(encInfo) {
|
418
|
-
return decryptAESSecretStorageItem(encInfo, privateKey, name);
|
419
|
-
}
|
420
|
-
};
|
421
|
-
return [keyId, decryption];
|
422
|
-
} else {
|
423
|
-
throw new Error("Unknown key type: " + keys[keyId].algorithm);
|
424
|
-
}
|
425
|
-
})();
|
426
|
-
}
|
427
|
-
}
|
428
|
-
|
429
|
-
/** trim trailing instances of '=' from a string
|
430
|
-
*
|
431
|
-
* @internal
|
432
|
-
*
|
433
|
-
* @param input - input string
|
434
|
-
*/
|
435
|
-
export function trimTrailingEquals(input) {
|
436
|
-
// according to Sonar and CodeQL, a regex such as /=+$/ is superlinear.
|
437
|
-
// Not sure I believe it, but it's easy enough to work around.
|
438
|
-
|
439
|
-
// find the number of characters before the trailing =
|
440
|
-
var i = input.length;
|
441
|
-
while (i >= 1 && input.charCodeAt(i - 1) == 0x3d) i--;
|
442
|
-
|
443
|
-
// trim to the calculated length
|
444
|
-
if (i < input.length) {
|
445
|
-
return input.substring(0, i);
|
446
|
-
} else {
|
447
|
-
return input;
|
448
|
-
}
|
449
|
-
}
|
450
|
-
|
451
|
-
// string of zeroes, for calculating the key check
|
452
|
-
var ZERO_STR = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
|
453
|
-
|
454
|
-
/**
|
455
|
-
* Calculate the MAC for checking the key.
|
456
|
-
* See https://spec.matrix.org/v1.11/client-server-api/#msecret_storagev1aes-hmac-sha2, steps 3 and 4.
|
457
|
-
*
|
458
|
-
* @param key - the key to use
|
459
|
-
* @param iv - The initialization vector as a base64-encoded string.
|
460
|
-
* If omitted, a random initialization vector will be created.
|
461
|
-
* @returns An object that contains, `mac` and `iv` properties.
|
462
|
-
*/
|
463
|
-
export function calculateKeyCheck(key, iv) {
|
464
|
-
return encryptAESSecretStorageItem(ZERO_STR, key, "", iv);
|
465
|
-
}
|
466
|
-
//# sourceMappingURL=secret-storage.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"secret-storage.js","names":["ClientEvent","randomString","logger","encryptAESSecretStorageItem","decryptAESSecretStorageItem","SECRET_STORAGE_ALGORITHM_V1_AES","ServerSideSecretStorageImpl","constructor","accountDataAdapter","callbacks","getDefaultKeyId","_this","_asyncToGenerator","defaultKey","getAccountDataFromServer","key","setDefaultKeyId","keyId","Promise","resolve","reject","listener","ev","getType","getContent","removeListener","AccountData","on","setAccountData","catch","e","addKey","algorithm","opts","_this2","Error","concat","keyInfo","name","passphrase","iv","mac","calculateKeyCheck","getKey","_this3","hasKey","_this4","Boolean","checkKey","info","trimTrailingEquals","store","secret","keys","_this5","encrypted","defaultKeyId","length","encryption","getSecretStorageKey","encrypt","warn","get","_this6","secretInfo","Object","encInfo","ciphertext","decryption","decrypt","isStored","_this7","ret","_this8","returned","privateKey","input","i","charCodeAt","substring","ZERO_STR"],"sources":["../src/secret-storage.ts"],"sourcesContent":["/*\nCopyright 2021-2023 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\n/**\n * Implementation of server-side secret storage\n *\n * @see https://spec.matrix.org/v1.6/client-server-api/#storage\n */\n\nimport { TypedEventEmitter } from \"./models/typed-event-emitter.ts\";\nimport { ClientEvent, ClientEventHandlerMap } from \"./client.ts\";\nimport { MatrixEvent } from \"./models/event.ts\";\nimport { randomString } from \"./randomstring.ts\";\nimport { logger } from \"./logger.ts\";\nimport encryptAESSecretStorageItem from \"./utils/encryptAESSecretStorageItem.ts\";\nimport decryptAESSecretStorageItem from \"./utils/decryptAESSecretStorageItem.ts\";\nimport { AESEncryptedSecretStoragePayload } from \"./@types/AESEncryptedSecretStoragePayload.ts\";\n\nexport const SECRET_STORAGE_ALGORITHM_V1_AES = \"m.secret_storage.v1.aes-hmac-sha2\";\n\n/**\n * Common base interface for Secret Storage Keys.\n *\n * The common properties for all encryption keys used in server-side secret storage.\n *\n * @see https://spec.matrix.org/v1.6/client-server-api/#key-storage\n */\nexport interface SecretStorageKeyDescriptionCommon {\n /** A human-readable name for this key. */\n // XXX: according to the spec, this is optional\n name: string;\n\n /** The encryption algorithm used with this key. */\n algorithm: string;\n\n /** Information for deriving this key from a passphrase. */\n // XXX: according to the spec, this is optional\n passphrase: PassphraseInfo;\n}\n\n/**\n * Properties for a SSSS key using the `m.secret_storage.v1.aes-hmac-sha2` algorithm.\n *\n * Corresponds to `AesHmacSha2KeyDescription` in the specification.\n *\n * @see https://spec.matrix.org/v1.6/client-server-api/#msecret_storagev1aes-hmac-sha2\n */\nexport interface SecretStorageKeyDescriptionAesV1 extends SecretStorageKeyDescriptionCommon {\n // XXX: strictly speaking, we should be able to enforce the algorithm here. But\n // this interface ends up being incorrectly used where other algorithms are in use (notably\n // in device-dehydration support), and unpicking that is too much like hard work\n // at the moment.\n // algorithm: \"m.secret_storage.v1.aes-hmac-sha2\";\n\n /** The 16-byte AES initialization vector, encoded as base64. */\n iv: string;\n\n /** The MAC of the result of encrypting 32 bytes of 0, encoded as base64. */\n mac: string;\n}\n\n/**\n * Union type for secret storage keys.\n *\n * For now, this is only {@link SecretStorageKeyDescriptionAesV1}, but other interfaces may be added in future.\n */\nexport type SecretStorageKeyDescription = SecretStorageKeyDescriptionAesV1;\n\n/**\n * Information on how to generate the key from a passphrase.\n *\n * @see https://spec.matrix.org/v1.6/client-server-api/#deriving-keys-from-passphrases\n */\nexport interface PassphraseInfo {\n /** The algorithm to be used to derive the key. */\n algorithm: \"m.pbkdf2\";\n\n /** The number of PBKDF2 iterations to use. */\n iterations: number;\n\n /** The salt to be used for PBKDF2. */\n salt: string;\n\n /** The number of bits to generate. Defaults to 256. */\n bits?: number;\n}\n\n/**\n * Options for {@link ServerSideSecretStorageImpl#addKey}.\n */\nexport interface AddSecretStorageKeyOpts {\n /** Information for deriving the key from a passphrase if any. */\n passphrase?: PassphraseInfo;\n /** Optional name of the key. */\n name?: string;\n /** The private key. Will be used to generate the key check values in the key info; it will not be stored on the server */\n key: Uint8Array;\n}\n\n/**\n * Return type for {@link ServerSideSecretStorageImpl#getKey}.\n */\nexport type SecretStorageKeyTuple = [keyId: string, keyInfo: SecretStorageKeyDescription];\n\n/**\n * Return type for {@link ServerSideSecretStorageImpl#addKey}.\n */\nexport type SecretStorageKeyObject = {\n /** The ID of the key */\n keyId: string;\n /** details about the key */\n keyInfo: SecretStorageKeyDescription;\n};\n\n/** Interface for managing account data on the server.\n *\n * A subset of {@link MatrixClient}.\n */\nexport interface AccountDataClient extends TypedEventEmitter<ClientEvent.AccountData, ClientEventHandlerMap> {\n /**\n * Get account data event of given type for the current user. This variant\n * gets account data directly from the homeserver if the local store is not\n * ready, which can be useful very early in startup before the initial sync.\n *\n * @param eventType - The type of account data\n * @returns The contents of the given account data event, or `null` if the event is not found\n */\n getAccountDataFromServer: <T extends Record<string, any>>(eventType: string) => Promise<T | null>;\n\n /**\n * Set account data event for the current user, with retries\n *\n * @param eventType - The type of account data\n * @param content - the content object to be set\n * @returns an empty object\n */\n setAccountData: (eventType: string, content: any) => Promise<{}>;\n}\n\n/**\n * Application callbacks for use with {@link SecretStorage.ServerSideSecretStorageImpl}\n */\nexport interface SecretStorageCallbacks {\n /**\n * Called to retrieve a secret storage encryption key\n *\n * Before a secret can be stored in server-side storage, it must be encrypted with one or more\n * keys. Similarly, after it has been retrieved from storage, it must be decrypted with one of\n * the keys it was encrypted with. These encryption keys are known as \"secret storage keys\".\n *\n * Descriptions of the secret storage keys are also stored in server-side storage, per the\n * [matrix specification](https://spec.matrix.org/v1.6/client-server-api/#key-storage), so\n * before a key can be used in this way, it must have been stored on the server. This is\n * done via {@link ServerSideSecretStorage#addKey}.\n *\n * Obviously the keys themselves are not stored server-side, so the js-sdk calls this callback\n * in order to retrieve a secret storage key from the application.\n *\n * @param keys - An options object, containing only the property `keys`.\n *\n * @param name - the name of the *secret* (NB: not the encryption key) being stored or retrieved.\n * This is the \"event type\" stored in account data.\n *\n * @returns a pair [`keyId`, `privateKey`], where `keyId` is one of the keys from the `keys` parameter,\n * and `privateKey` is the raw private encryption key, as appropriate for the encryption algorithm.\n * (For `m.secret_storage.v1.aes-hmac-sha2`, it is the input to an HKDF as defined in the\n * [specification](https://spec.matrix.org/v1.6/client-server-api/#msecret_storagev1aes-hmac-sha2).)\n *\n * Alternatively, if none of the keys are known, may return `null` — in which case the original\n * storage/retrieval operation will fail with an exception.\n */\n getSecretStorageKey?: (\n keys: {\n /**\n * details of the secret storage keys required: a map from the key ID\n * (excluding the `m.secret_storage.key.` prefix) to details of the key.\n *\n * When storing a secret, `keys` will contain exactly one entry; this method will be called\n * once for each secret storage key to be used for encryption.\n *\n * For secret retrieval, `keys` may contain several entries, and the application can return\n * any one of the requested keys.\n */\n keys: Record<string, SecretStorageKeyDescription>;\n },\n name: string,\n ) => Promise<[string, Uint8Array] | null>;\n}\n\ninterface SecretInfo {\n encrypted: {\n [keyId: string]: AESEncryptedSecretStoragePayload;\n };\n}\n\ninterface Decryptors {\n encrypt: (plaintext: string) => Promise<AESEncryptedSecretStoragePayload>;\n decrypt: (ciphertext: AESEncryptedSecretStoragePayload) => Promise<string>;\n}\n\n/**\n * Interface provided by SecretStorage implementations\n *\n * Normally this will just be an {@link ServerSideSecretStorageImpl}, but for backwards\n * compatibility some methods allow other implementations.\n */\nexport interface ServerSideSecretStorage {\n /**\n * Add a key for encrypting secrets.\n *\n * @param algorithm - the algorithm used by the key.\n * @param opts - the options for the algorithm. The properties used\n * depend on the algorithm given.\n * @param keyId - the ID of the key. If not given, a random\n * ID will be generated.\n *\n * @returns details about the key.\n */\n addKey(algorithm: string, opts: AddSecretStorageKeyOpts, keyId?: string): Promise<SecretStorageKeyObject>;\n\n /**\n * Get the key information for a given ID.\n *\n * @param keyId - The ID of the key to check\n * for. Defaults to the default key ID if not provided.\n * @returns If the key was found, the return value is an array of\n * the form [keyId, keyInfo]. Otherwise, null is returned.\n * XXX: why is this an array when addKey returns an object?\n */\n getKey(keyId?: string | null): Promise<SecretStorageKeyTuple | null>;\n\n /**\n * Check whether we have a key with a given ID.\n *\n * @param keyId - The ID of the key to check\n * for. Defaults to the default key ID if not provided.\n * @returns Whether we have the key.\n */\n hasKey(keyId?: string): Promise<boolean>;\n\n /**\n * Check whether a key matches what we expect based on the key info\n *\n * @param key - the key to check\n * @param info - the key info\n *\n * @returns whether or not the key matches\n */\n checkKey(key: Uint8Array, info: SecretStorageKeyDescriptionAesV1): Promise<boolean>;\n\n /**\n * Store an encrypted secret on the server.\n *\n * Details of the encryption keys to be used must previously have been stored in account data\n * (for example, via {@link ServerSideSecretStorage#addKey}.\n *\n * @param name - The name of the secret - i.e., the \"event type\" to be stored in the account data\n * @param secret - The secret contents.\n * @param keys - The IDs of the keys to use to encrypt the secret, or null/undefined to use the default key\n * (will throw if no default key is set).\n */\n store(name: string, secret: string, keys?: string[] | null): Promise<void>;\n\n /**\n * Get a secret from storage, and decrypt it.\n *\n * @param name - the name of the secret - i.e., the \"event type\" stored in the account data\n *\n * @returns the decrypted contents of the secret, or \"undefined\" if `name` is not found in\n * the user's account data.\n */\n get(name: string): Promise<string | undefined>;\n\n /**\n * Check if a secret is stored on the server.\n *\n * @param name - the name of the secret\n *\n * @returns map of key name to key info the secret is encrypted\n * with, or null if it is not present or not encrypted with a trusted\n * key\n */\n isStored(name: string): Promise<Record<string, SecretStorageKeyDescriptionAesV1> | null>;\n\n /**\n * Get the current default key ID for encrypting secrets.\n *\n * @returns The default key ID or null if no default key ID is set\n */\n getDefaultKeyId(): Promise<string | null>;\n\n /**\n * Set the default key ID for encrypting secrets.\n *\n * @param keyId - The new default key ID\n */\n setDefaultKeyId(keyId: string): Promise<void>;\n}\n\n/**\n * Implementation of Server-side secret storage.\n *\n * Secret *sharing* is *not* implemented here: this class is strictly about the storage component of\n * SSSS.\n *\n * @see https://spec.matrix.org/v1.6/client-server-api/#storage\n */\nexport class ServerSideSecretStorageImpl implements ServerSideSecretStorage {\n /**\n * Construct a new `SecretStorage`.\n *\n * Normally, it is unnecessary to call this directly, since MatrixClient automatically constructs one.\n * However, it may be useful to construct a new `SecretStorage`, if custom `callbacks` are required, for example.\n *\n * @param accountDataAdapter - interface for fetching and setting account data on the server. Normally an instance\n * of {@link MatrixClient}.\n * @param callbacks - application level callbacks for retrieving secret keys\n */\n public constructor(\n private readonly accountDataAdapter: AccountDataClient,\n private readonly callbacks: SecretStorageCallbacks,\n ) {}\n\n /**\n * Get the current default key ID for encrypting secrets.\n *\n * @returns The default key ID or null if no default key ID is set\n */\n public async getDefaultKeyId(): Promise<string | null> {\n const defaultKey = await this.accountDataAdapter.getAccountDataFromServer<{ key: string }>(\n \"m.secret_storage.default_key\",\n );\n if (!defaultKey) return null;\n return defaultKey.key;\n }\n\n /**\n * Set the default key ID for encrypting secrets.\n *\n * @param keyId - The new default key ID\n */\n public setDefaultKeyId(keyId: string): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n const listener = (ev: MatrixEvent): void => {\n if (ev.getType() === \"m.secret_storage.default_key\" && ev.getContent().key === keyId) {\n this.accountDataAdapter.removeListener(ClientEvent.AccountData, listener);\n resolve();\n }\n };\n this.accountDataAdapter.on(ClientEvent.AccountData, listener);\n\n this.accountDataAdapter.setAccountData(\"m.secret_storage.default_key\", { key: keyId }).catch((e) => {\n this.accountDataAdapter.removeListener(ClientEvent.AccountData, listener);\n reject(e);\n });\n });\n }\n\n /**\n * Add a key for encrypting secrets.\n *\n * @param algorithm - the algorithm used by the key.\n * @param opts - the options for the algorithm. The properties used\n * depend on the algorithm given.\n * @param keyId - the ID of the key. If not given, a random\n * ID will be generated.\n *\n * @returns An object with:\n * keyId: the ID of the key\n * keyInfo: details about the key (iv, mac, passphrase)\n */\n public async addKey(\n algorithm: string,\n opts: AddSecretStorageKeyOpts,\n keyId?: string,\n ): Promise<SecretStorageKeyObject> {\n if (algorithm !== SECRET_STORAGE_ALGORITHM_V1_AES) {\n throw new Error(`Unknown key algorithm ${algorithm}`);\n }\n\n const keyInfo = { algorithm } as SecretStorageKeyDescriptionAesV1;\n\n if (opts.name) {\n keyInfo.name = opts.name;\n }\n\n if (opts.passphrase) {\n keyInfo.passphrase = opts.passphrase;\n }\n\n const { iv, mac } = await calculateKeyCheck(opts.key);\n keyInfo.iv = iv;\n keyInfo.mac = mac;\n\n // Create a unique key id. XXX: this is racey.\n if (!keyId) {\n do {\n keyId = randomString(32);\n } while (\n await this.accountDataAdapter.getAccountDataFromServer<SecretStorageKeyDescription>(\n `m.secret_storage.key.${keyId}`,\n )\n );\n }\n\n await this.accountDataAdapter.setAccountData(`m.secret_storage.key.${keyId}`, keyInfo);\n\n return {\n keyId,\n keyInfo,\n };\n }\n\n /**\n * Get the key information for a given ID.\n *\n * @param keyId - The ID of the key to check\n * for. Defaults to the default key ID if not provided.\n * @returns If the key was found, the return value is an array of\n * the form [keyId, keyInfo]. Otherwise, null is returned.\n * XXX: why is this an array when addKey returns an object?\n */\n public async getKey(keyId?: string | null): Promise<SecretStorageKeyTuple | null> {\n if (!keyId) {\n keyId = await this.getDefaultKeyId();\n }\n if (!keyId) {\n return null;\n }\n\n const keyInfo = await this.accountDataAdapter.getAccountDataFromServer<SecretStorageKeyDescriptionAesV1>(\n \"m.secret_storage.key.\" + keyId,\n );\n return keyInfo ? [keyId, keyInfo] : null;\n }\n\n /**\n * Check whether we have a key with a given ID.\n *\n * @param keyId - The ID of the key to check\n * for. Defaults to the default key ID if not provided.\n * @returns Whether we have the key.\n */\n public async hasKey(keyId?: string): Promise<boolean> {\n const key = await this.getKey(keyId);\n return Boolean(key);\n }\n\n /**\n * Check whether a key matches what we expect based on the key info\n *\n * @param key - the key to check\n * @param info - the key info\n *\n * @returns whether or not the key matches\n */\n public async checkKey(key: Uint8Array, info: SecretStorageKeyDescriptionAesV1): Promise<boolean> {\n if (info.algorithm === SECRET_STORAGE_ALGORITHM_V1_AES) {\n if (info.mac) {\n const { mac } = await calculateKeyCheck(key, info.iv);\n return trimTrailingEquals(info.mac) === trimTrailingEquals(mac);\n } else {\n // if we have no information, we have to assume the key is right\n return true;\n }\n } else {\n throw new Error(\"Unknown algorithm\");\n }\n }\n\n /**\n * Store an encrypted secret on the server.\n *\n * Details of the encryption keys to be used must previously have been stored in account data\n * (for example, via {@link ServerSideSecretStorageImpl#addKey}. {@link SecretStorageCallbacks#getSecretStorageKey} will be called to obtain a secret storage\n * key to decrypt the secret.\n *\n * @param name - The name of the secret - i.e., the \"event type\" to be stored in the account data\n * @param secret - The secret contents.\n * @param keys - The IDs of the keys to use to encrypt the secret, or null/undefined to use the default key.\n */\n public async store(name: string, secret: string, keys?: string[] | null): Promise<void> {\n const encrypted: Record<string, AESEncryptedSecretStoragePayload> = {};\n\n if (!keys) {\n const defaultKeyId = await this.getDefaultKeyId();\n if (!defaultKeyId) {\n throw new Error(\"No keys specified and no default key present\");\n }\n keys = [defaultKeyId];\n }\n\n if (keys.length === 0) {\n throw new Error(\"Zero keys given to encrypt with!\");\n }\n\n for (const keyId of keys) {\n // get key information from key storage\n const keyInfo = await this.accountDataAdapter.getAccountDataFromServer<SecretStorageKeyDescriptionAesV1>(\n \"m.secret_storage.key.\" + keyId,\n );\n if (!keyInfo) {\n throw new Error(\"Unknown key: \" + keyId);\n }\n\n // encrypt secret, based on the algorithm\n if (keyInfo.algorithm === SECRET_STORAGE_ALGORITHM_V1_AES) {\n const keys = { [keyId]: keyInfo };\n const [, encryption] = await this.getSecretStorageKey(keys, name);\n encrypted[keyId] = await encryption.encrypt(secret);\n } else {\n logger.warn(\"unknown algorithm for secret storage key \" + keyId + \": \" + keyInfo.algorithm);\n // do nothing if we don't understand the encryption algorithm\n }\n }\n\n // save encrypted secret\n await this.accountDataAdapter.setAccountData(name, { encrypted });\n }\n\n /**\n * Get a secret from storage, and decrypt it.\n *\n * {@link SecretStorageCallbacks#getSecretStorageKey} will be called to obtain a secret storage\n * key to decrypt the secret.\n *\n * @param name - the name of the secret - i.e., the \"event type\" stored in the account data\n *\n * @returns the decrypted contents of the secret, or \"undefined\" if `name` is not found in\n * the user's account data.\n */\n public async get(name: string): Promise<string | undefined> {\n const secretInfo = await this.accountDataAdapter.getAccountDataFromServer<SecretInfo>(name);\n if (!secretInfo) {\n return;\n }\n if (!secretInfo.encrypted) {\n throw new Error(\"Content is not encrypted!\");\n }\n\n // get possible keys to decrypt\n const keys: Record<string, SecretStorageKeyDescriptionAesV1> = {};\n for (const keyId of Object.keys(secretInfo.encrypted)) {\n // get key information from key storage\n const keyInfo = await this.accountDataAdapter.getAccountDataFromServer<SecretStorageKeyDescriptionAesV1>(\n \"m.secret_storage.key.\" + keyId,\n );\n const encInfo = secretInfo.encrypted[keyId];\n // only use keys we understand the encryption algorithm of\n if (keyInfo?.algorithm === SECRET_STORAGE_ALGORITHM_V1_AES) {\n if (encInfo.iv && encInfo.ciphertext && encInfo.mac) {\n keys[keyId] = keyInfo;\n }\n }\n }\n\n if (Object.keys(keys).length === 0) {\n throw new Error(\n `Could not decrypt ${name} because none of ` +\n `the keys it is encrypted with are for a supported algorithm`,\n );\n }\n\n // fetch private key from app\n const [keyId, decryption] = await this.getSecretStorageKey(keys, name);\n const encInfo = secretInfo.encrypted[keyId];\n\n return decryption.decrypt(encInfo);\n }\n\n /**\n * Check if a secret is stored on the server.\n *\n * @param name - the name of the secret\n *\n * @returns map of key name to key info the secret is encrypted\n * with, or null if it is not present or not encrypted with a trusted\n * key\n */\n public async isStored(name: string): Promise<Record<string, SecretStorageKeyDescriptionAesV1> | null> {\n // check if secret exists\n const secretInfo = await this.accountDataAdapter.getAccountDataFromServer<SecretInfo>(name);\n if (!secretInfo?.encrypted) return null;\n\n const ret: Record<string, SecretStorageKeyDescriptionAesV1> = {};\n\n // filter secret encryption keys with supported algorithm\n for (const keyId of Object.keys(secretInfo.encrypted)) {\n // get key information from key storage\n const keyInfo = await this.accountDataAdapter.getAccountDataFromServer<SecretStorageKeyDescriptionAesV1>(\n \"m.secret_storage.key.\" + keyId,\n );\n if (!keyInfo) continue;\n const encInfo = secretInfo.encrypted[keyId];\n\n // only use keys we understand the encryption algorithm of\n if (keyInfo.algorithm === SECRET_STORAGE_ALGORITHM_V1_AES) {\n if (encInfo.iv && encInfo.ciphertext && encInfo.mac) {\n ret[keyId] = keyInfo;\n }\n }\n }\n return Object.keys(ret).length ? ret : null;\n }\n\n private async getSecretStorageKey(\n keys: Record<string, SecretStorageKeyDescriptionAesV1>,\n name: string,\n ): Promise<[string, Decryptors]> {\n if (!this.callbacks.getSecretStorageKey) {\n throw new Error(\"No getSecretStorageKey callback supplied\");\n }\n\n const returned = await this.callbacks.getSecretStorageKey({ keys }, name);\n\n if (!returned) {\n throw new Error(\"getSecretStorageKey callback returned falsey\");\n }\n if (returned.length < 2) {\n throw new Error(\"getSecretStorageKey callback returned invalid data\");\n }\n\n const [keyId, privateKey] = returned;\n if (!keys[keyId]) {\n throw new Error(\"App returned unknown key from getSecretStorageKey!\");\n }\n\n if (keys[keyId].algorithm === SECRET_STORAGE_ALGORITHM_V1_AES) {\n const decryption = {\n encrypt: function (secret: string): Promise<AESEncryptedSecretStoragePayload> {\n return encryptAESSecretStorageItem(secret, privateKey, name);\n },\n decrypt: function (encInfo: AESEncryptedSecretStoragePayload): Promise<string> {\n return decryptAESSecretStorageItem(encInfo, privateKey, name);\n },\n };\n return [keyId, decryption];\n } else {\n throw new Error(\"Unknown key type: \" + keys[keyId].algorithm);\n }\n }\n}\n\n/** trim trailing instances of '=' from a string\n *\n * @internal\n *\n * @param input - input string\n */\nexport function trimTrailingEquals(input: string): string {\n // according to Sonar and CodeQL, a regex such as /=+$/ is superlinear.\n // Not sure I believe it, but it's easy enough to work around.\n\n // find the number of characters before the trailing =\n let i = input.length;\n while (i >= 1 && input.charCodeAt(i - 1) == 0x3d) i--;\n\n // trim to the calculated length\n if (i < input.length) {\n return input.substring(0, i);\n } else {\n return input;\n }\n}\n\n// string of zeroes, for calculating the key check\nconst ZERO_STR = \"\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\";\n\n/**\n * Calculate the MAC for checking the key.\n * See https://spec.matrix.org/v1.11/client-server-api/#msecret_storagev1aes-hmac-sha2, steps 3 and 4.\n *\n * @param key - the key to use\n * @param iv - The initialization vector as a base64-encoded string.\n * If omitted, a random initialization vector will be created.\n * @returns An object that contains, `mac` and `iv` properties.\n */\nexport function calculateKeyCheck(key: Uint8Array, iv?: string): Promise<AESEncryptedSecretStoragePayload> {\n return encryptAESSecretStorageItem(ZERO_STR, key, \"\", iv);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAGA,SAASA,WAAW,QAA+B,aAAa;AAEhE,SAASC,YAAY,QAAQ,mBAAmB;AAChD,SAASC,MAAM,QAAQ,aAAa;AACpC,OAAOC,2BAA2B,MAAM,wCAAwC;AAChF,OAAOC,2BAA2B,MAAM,wCAAwC;AAGhF,OAAO,IAAMC,+BAA+B,GAAG,mCAAmC;;AAElF;AACA;AACA;AACA;AACA;AACA;AACA;;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;;AAeA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAeA;AACA;AACA;;AAUA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;AACA;;AAsBA;AACA;AACA;;AA2DA;AACA;AACA;AACA;AACA;AACA;;AA8FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,2BAA2B,CAAoC;EACxE;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACWC,WAAWA,CACGC,kBAAqC,EACrCC,SAAiC,EACpD;IAAA,KAFmBD,kBAAqC,GAArCA,kBAAqC;IAAA,KACrCC,SAAiC,GAAjCA,SAAiC;EACnD;;EAEH;AACJ;AACA;AACA;AACA;EACiBC,eAAeA,CAAA,EAA2B;IAAA,IAAAC,KAAA;IAAA,OAAAC,iBAAA;MACnD,IAAMC,UAAU,SAASF,KAAI,CAACH,kBAAkB,CAACM,wBAAwB,CACrE,8BACJ,CAAC;MACD,IAAI,CAACD,UAAU,EAAE,OAAO,IAAI;MAC5B,OAAOA,UAAU,CAACE,GAAG;IAAC;EAC1B;;EAEA;AACJ;AACA;AACA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OAAOA,CAAYR,MAAc,EAA6C;YAC1E,OAAOjD,2BAA2B,CAACiD,MAAM,EAAEuB,UAAU,EAAErC,IAAI,CAAC;UAChE,CAAC;UACD+B,OAAO,EAAE,SAATA,OAAOA,CAAYH,OAAyC,EAAmB;YAC3E,OAAO9D,2BAA2B,CAAC8D,OAAO,EAAES,UAAU,EAAErC,IAAI,CAAC;UACjE;QACJ,CAAC;QACD,OAAO,CAACrB,KAAK,EAAEmD,UAAU,CAAC;MAC9B,CAAC,MAAM;QACH,MAAM,IAAIjC,KAAK,CAAC,oBAAoB,GAAGkB,IAAI,CAACpC,KAAK,CAAC,CAACe,SAAS,CAAC;MACjE;IAAC;EACL;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASkB,kBAAkBA,CAAC0B,KAAa,EAAU;EACtD;EACA;;EAEA;EACA,IAAIC,CAAC,GAAGD,KAAK,CAACnB,MAAM;EACpB,OAAOoB,CAAC,IAAI,CAAC,IAAID,KAAK,CAACE,UAAU,CAACD,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,EAAEA,CAAC,EAAE;;EAErD;EACA,IAAIA,CAAC,GAAGD,KAAK,CAACnB,MAAM,EAAE;IAClB,OAAOmB,KAAK,CAACG,SAAS,CAAC,CAAC,EAAEF,CAAC,CAAC;EAChC,CAAC,MAAM;IACH,OAAOD,KAAK;EAChB;AACJ;;AAEA;AACA,IAAMI,QAAQ,GAAG,kEAAkE;;AAEnF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAStC,iBAAiBA,CAAC3B,GAAe,EAAEyB,EAAW,EAA6C;EACvG,OAAOrC,2BAA2B,CAAC6E,QAAQ,EAAEjE,GAAG,EAAE,EAAE,EAAEyB,EAAE,CAAC;AAC7D","ignoreList":[]}
|
@@ -1,15 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Acquires a reference to the shared AudioContext.
|
3
|
-
* It's highly recommended to reuse this AudioContext rather than creating your
|
4
|
-
* own, because multiple AudioContexts can be problematic in some browsers.
|
5
|
-
* Make sure to call releaseContext when you're done using it.
|
6
|
-
* @returns The shared AudioContext
|
7
|
-
*/
|
8
|
-
export declare const acquireContext: () => AudioContext;
|
9
|
-
/**
|
10
|
-
* Signals that one of the references to the shared AudioContext has been
|
11
|
-
* released, allowing the context and associated hardware resources to be
|
12
|
-
* cleaned up if nothing else is using it.
|
13
|
-
*/
|
14
|
-
export declare const releaseContext: () => void;
|
15
|
-
//# sourceMappingURL=audioContext.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"audioContext.d.ts","sourceRoot":"","sources":["../../src/webrtc/audioContext.ts"],"names":[],"mappings":"AAmBA;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,QAAO,YAIjC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,QAAO,IAMjC,CAAC"}
|
@@ -1,46 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
Copyright 2022 The Matrix.org Foundation C.I.C.
|
3
|
-
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
you may not use this file except in compliance with the License.
|
6
|
-
You may obtain a copy of the License at
|
7
|
-
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
See the License for the specific language governing permissions and
|
14
|
-
limitations under the License.
|
15
|
-
*/
|
16
|
-
|
17
|
-
var audioContext = null;
|
18
|
-
var refCount = 0;
|
19
|
-
|
20
|
-
/**
|
21
|
-
* Acquires a reference to the shared AudioContext.
|
22
|
-
* It's highly recommended to reuse this AudioContext rather than creating your
|
23
|
-
* own, because multiple AudioContexts can be problematic in some browsers.
|
24
|
-
* Make sure to call releaseContext when you're done using it.
|
25
|
-
* @returns The shared AudioContext
|
26
|
-
*/
|
27
|
-
export var acquireContext = () => {
|
28
|
-
if (audioContext === null) audioContext = new AudioContext();
|
29
|
-
refCount++;
|
30
|
-
return audioContext;
|
31
|
-
};
|
32
|
-
|
33
|
-
/**
|
34
|
-
* Signals that one of the references to the shared AudioContext has been
|
35
|
-
* released, allowing the context and associated hardware resources to be
|
36
|
-
* cleaned up if nothing else is using it.
|
37
|
-
*/
|
38
|
-
export var releaseContext = () => {
|
39
|
-
refCount--;
|
40
|
-
if (refCount === 0) {
|
41
|
-
var _audioContext;
|
42
|
-
(_audioContext = audioContext) === null || _audioContext === void 0 || _audioContext.close();
|
43
|
-
audioContext = null;
|
44
|
-
}
|
45
|
-
};
|
46
|
-
//# sourceMappingURL=audioContext.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"audioContext.js","names":["audioContext","refCount","acquireContext","AudioContext","releaseContext","_audioContext","close"],"sources":["../../src/webrtc/audioContext.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\nlet audioContext: AudioContext | null = null;\nlet refCount = 0;\n\n/**\n * Acquires a reference to the shared AudioContext.\n * It's highly recommended to reuse this AudioContext rather than creating your\n * own, because multiple AudioContexts can be problematic in some browsers.\n * Make sure to call releaseContext when you're done using it.\n * @returns The shared AudioContext\n */\nexport const acquireContext = (): AudioContext => {\n if (audioContext === null) audioContext = new AudioContext();\n refCount++;\n return audioContext;\n};\n\n/**\n * Signals that one of the references to the shared AudioContext has been\n * released, allowing the context and associated hardware resources to be\n * cleaned up if nothing else is using it.\n */\nexport const releaseContext = (): void => {\n refCount--;\n if (refCount === 0) {\n audioContext?.close();\n audioContext = null;\n }\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,IAAIA,YAAiC,GAAG,IAAI;AAC5C,IAAIC,QAAQ,GAAG,CAAC;;AAEhB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,IAAMC,cAAc,GAAGA,CAAA,KAAoB;EAC9C,IAAIF,YAAY,KAAK,IAAI,EAAEA,YAAY,GAAG,IAAIG,YAAY,CAAC,CAAC;EAC5DF,QAAQ,EAAE;EACV,OAAOD,YAAY;AACvB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,IAAMI,cAAc,GAAGA,CAAA,KAAY;EACtCH,QAAQ,EAAE;EACV,IAAIA,QAAQ,KAAK,CAAC,EAAE;IAAA,IAAAI,aAAA;IAChB,CAAAA,aAAA,GAAAL,YAAY,cAAAK,aAAA,eAAZA,aAAA,CAAcC,KAAK,CAAC,CAAC;IACrBN,YAAY,GAAG,IAAI;EACvB;AACJ,CAAC","ignoreList":[]}
|