matrix-js-sdk 41.8.0 → 41.9.0
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/CHANGELOG.md +11 -0
- package/README.md +1 -1
- package/lib/@types/AESEncryptedSecretStoragePayload.js +3 -1
- package/lib/@types/IIdentityServerProvider.js +3 -1
- package/lib/@types/PushRules.js +7 -7
- package/lib/@types/PushRules.js.map +1 -1
- package/lib/@types/auth.js +4 -4
- package/lib/@types/auth.js.map +1 -1
- package/lib/@types/beacon.js +2 -2
- package/lib/@types/beacon.js.map +1 -1
- package/lib/@types/common.js +3 -1
- package/lib/@types/crypto.js +3 -1
- package/lib/@types/event.js +20 -20
- package/lib/@types/event.js.map +1 -1
- package/lib/@types/events.js +3 -1
- package/lib/@types/extensible_events.js +6 -6
- package/lib/@types/extensible_events.js.map +1 -1
- package/lib/@types/global.d.js.map +1 -1
- package/lib/@types/json.js +3 -1
- package/lib/@types/local_notifications.js +3 -1
- package/lib/@types/location.js +4 -4
- package/lib/@types/location.js.map +1 -1
- package/lib/@types/matrix-sdk-crypto-wasm.d.js +3 -1
- package/lib/@types/media.js +3 -1
- package/lib/@types/membership.js +1 -1
- package/lib/@types/membership.js.map +1 -1
- package/lib/@types/partials.js +6 -6
- package/lib/@types/partials.js.map +1 -1
- package/lib/@types/polls.js +5 -5
- package/lib/@types/polls.js.map +1 -1
- package/lib/@types/read_receipts.js +2 -2
- package/lib/@types/read_receipts.js.map +1 -1
- package/lib/@types/registration.js +3 -1
- package/lib/@types/requests.js +1 -1
- package/lib/@types/requests.js.map +1 -1
- package/lib/@types/retention.js +1 -1
- package/lib/@types/retention.js.map +1 -1
- package/lib/@types/search.js +1 -1
- package/lib/@types/search.js.map +1 -1
- package/lib/@types/signed.js +3 -1
- package/lib/@types/spaces.js +3 -1
- package/lib/@types/state_events.js +3 -1
- package/lib/@types/synapse.js +3 -1
- package/lib/@types/sync.js +1 -1
- package/lib/@types/sync.js.map +1 -1
- package/lib/@types/threepids.js +1 -1
- package/lib/@types/threepids.js.map +1 -1
- package/lib/@types/topic.js +1 -1
- package/lib/@types/topic.js.map +1 -1
- package/lib/@types/uia.js +3 -1
- package/lib/NamespacedValue.js +8 -8
- package/lib/NamespacedValue.js.map +1 -1
- package/lib/ReEmitter.js +9 -16
- package/lib/ReEmitter.js.map +1 -1
- package/lib/ToDeviceMessageQueue.js +49 -57
- package/lib/ToDeviceMessageQueue.js.map +1 -1
- package/lib/autodiscovery.js +232 -247
- package/lib/autodiscovery.js.map +1 -1
- package/lib/base64.js +1 -1
- package/lib/base64.js.map +1 -1
- package/lib/browser-index.d.ts +2 -2
- package/lib/browser-index.d.ts.map +1 -1
- package/lib/browser-index.js +5 -5
- package/lib/browser-index.js.map +1 -1
- package/lib/capabilityPoller.js +19 -22
- package/lib/capabilityPoller.js.map +1 -1
- package/lib/client.d.ts +2 -8
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +2043 -2487
- package/lib/client.js.map +1 -1
- package/lib/common-crypto/CryptoBackend.js +2 -2
- package/lib/common-crypto/CryptoBackend.js.map +1 -1
- package/lib/common-crypto/key-passphrase.js.map +1 -1
- package/lib/content-helpers.js +43 -48
- package/lib/content-helpers.js.map +1 -1
- package/lib/content-repo.js +14 -24
- package/lib/content-repo.js.map +1 -1
- package/lib/crypto/store/base.js +6 -6
- package/lib/crypto/store/base.js.map +1 -1
- package/lib/crypto/store/indexeddb-crypto-store-backend.js +190 -238
- package/lib/crypto/store/indexeddb-crypto-store-backend.js.map +1 -1
- package/lib/crypto/store/indexeddb-crypto-store.js +25 -30
- package/lib/crypto/store/indexeddb-crypto-store.js.map +1 -1
- package/lib/crypto/store/localStorage-crypto-store.js +113 -145
- package/lib/crypto/store/localStorage-crypto-store.js.map +1 -1
- package/lib/crypto/store/memory-crypto-store.js +74 -105
- package/lib/crypto/store/memory-crypto-store.js.map +1 -1
- package/lib/crypto-api/CryptoEvent.js +1 -1
- package/lib/crypto-api/CryptoEvent.js.map +1 -1
- package/lib/crypto-api/CryptoEventHandlerMap.js +3 -1
- package/lib/crypto-api/index.d.ts +15 -6
- package/lib/crypto-api/index.d.ts.map +1 -1
- package/lib/crypto-api/index.js +22 -22
- package/lib/crypto-api/index.js.map +1 -1
- package/lib/crypto-api/key-passphrase.js +15 -23
- package/lib/crypto-api/key-passphrase.js.map +1 -1
- package/lib/crypto-api/keybackup.js +3 -1
- package/lib/crypto-api/recovery-key.js +11 -12
- package/lib/crypto-api/recovery-key.js.map +1 -1
- package/lib/crypto-api/verification.js +3 -3
- package/lib/crypto-api/verification.js.map +1 -1
- package/lib/digest.js +7 -14
- package/lib/digest.js.map +1 -1
- package/lib/embedded.d.ts.map +1 -1
- package/lib/embedded.js +380 -505
- package/lib/embedded.js.map +1 -1
- package/lib/errors.js +2 -2
- package/lib/errors.js.map +1 -1
- package/lib/event-mapper.js +10 -12
- package/lib/event-mapper.js.map +1 -1
- package/lib/extensible_events_v1/ExtensibleEvent.js.map +1 -1
- package/lib/extensible_events_v1/InvalidEventError.js.map +1 -1
- package/lib/extensible_events_v1/MessageEvent.js +11 -13
- package/lib/extensible_events_v1/MessageEvent.js.map +1 -1
- package/lib/extensible_events_v1/PollEndEvent.js +3 -4
- package/lib/extensible_events_v1/PollEndEvent.js.map +1 -1
- package/lib/extensible_events_v1/PollResponseEvent.js +5 -6
- package/lib/extensible_events_v1/PollResponseEvent.js.map +1 -1
- package/lib/extensible_events_v1/PollStartEvent.js +8 -10
- package/lib/extensible_events_v1/PollStartEvent.js.map +1 -1
- package/lib/extensible_events_v1/utilities.js.map +1 -1
- package/lib/feature.js +18 -31
- package/lib/feature.js.map +1 -1
- package/lib/filter-component.d.ts.map +1 -1
- package/lib/filter-component.js +20 -26
- package/lib/filter-component.js.map +1 -1
- package/lib/filter.js +14 -17
- package/lib/filter.js.map +1 -1
- package/lib/http-api/errors.js +28 -43
- package/lib/http-api/errors.js.map +1 -1
- package/lib/http-api/fetch.js +141 -159
- package/lib/http-api/fetch.js.map +1 -1
- package/lib/http-api/index.js +17 -20
- package/lib/http-api/index.js.map +1 -1
- package/lib/http-api/interface.js +1 -1
- package/lib/http-api/interface.js.map +1 -1
- package/lib/http-api/method.js +1 -1
- package/lib/http-api/method.js.map +1 -1
- package/lib/http-api/prefix.js +3 -3
- package/lib/http-api/prefix.js.map +1 -1
- package/lib/http-api/refresh.js +74 -94
- package/lib/http-api/refresh.js.map +1 -1
- package/lib/http-api/utils.d.ts +1 -1
- package/lib/http-api/utils.d.ts.map +1 -1
- package/lib/http-api/utils.js +34 -42
- package/lib/http-api/utils.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/indexeddb-helpers.js +3 -3
- package/lib/indexeddb-helpers.js.map +1 -1
- package/lib/indexeddb-worker.js.map +1 -1
- package/lib/interactive-auth.d.ts +5 -5
- package/lib/interactive-auth.d.ts.map +1 -1
- package/lib/interactive-auth.js +172 -204
- package/lib/interactive-auth.js.map +1 -1
- package/lib/logger.js +21 -57
- package/lib/logger.js.map +1 -1
- package/lib/matrix.js +7 -11
- package/lib/matrix.js.map +1 -1
- package/lib/matrixrtc/CallMembership.js +80 -74
- package/lib/matrixrtc/CallMembership.js.map +1 -1
- package/lib/matrixrtc/EncryptionManager.js +1 -1
- package/lib/matrixrtc/EncryptionManager.js.map +1 -1
- package/lib/matrixrtc/IKeyTransport.js +1 -1
- package/lib/matrixrtc/IKeyTransport.js.map +1 -1
- package/lib/matrixrtc/IMembershipManager.js +1 -1
- package/lib/matrixrtc/IMembershipManager.js.map +1 -1
- package/lib/matrixrtc/LivekitTransport.d.ts +1 -1
- package/lib/matrixrtc/LivekitTransport.js +4 -4
- package/lib/matrixrtc/LivekitTransport.js.map +1 -1
- package/lib/matrixrtc/MatrixRTCSession.js +137 -187
- package/lib/matrixrtc/MatrixRTCSession.js.map +1 -1
- package/lib/matrixrtc/MatrixRTCSessionManager.js +36 -41
- package/lib/matrixrtc/MatrixRTCSessionManager.js.map +1 -1
- package/lib/matrixrtc/MembershipManager.js +332 -378
- package/lib/matrixrtc/MembershipManager.js.map +1 -1
- package/lib/matrixrtc/MembershipManagerActionScheduler.js +54 -63
- package/lib/matrixrtc/MembershipManagerActionScheduler.js.map +1 -1
- package/lib/matrixrtc/RTCEncryptionManager.js +119 -143
- package/lib/matrixrtc/RTCEncryptionManager.js.map +1 -1
- package/lib/matrixrtc/ToDeviceKeyTransport.js +53 -58
- package/lib/matrixrtc/ToDeviceKeyTransport.js.map +1 -1
- package/lib/matrixrtc/index.js.map +1 -1
- package/lib/matrixrtc/membershipData/common.js +1 -1
- package/lib/matrixrtc/membershipData/common.js.map +1 -1
- package/lib/matrixrtc/membershipData/index.js.map +1 -1
- package/lib/matrixrtc/membershipData/rtc.js +15 -23
- package/lib/matrixrtc/membershipData/rtc.js.map +1 -1
- package/lib/matrixrtc/membershipData/session.js +4 -5
- package/lib/matrixrtc/membershipData/session.js.map +1 -1
- package/lib/matrixrtc/types.js +4 -6
- package/lib/matrixrtc/types.js.map +1 -1
- package/lib/matrixrtc/utils.js +4 -11
- package/lib/matrixrtc/utils.js.map +1 -1
- package/lib/models/MSC3089Branch.js +91 -116
- package/lib/models/MSC3089Branch.js.map +1 -1
- package/lib/models/MSC3089TreeSpace.js +209 -245
- package/lib/models/MSC3089TreeSpace.js.map +1 -1
- package/lib/models/ToDeviceMessage.js +3 -1
- package/lib/models/beacon.js +14 -13
- package/lib/models/beacon.js.map +1 -1
- package/lib/models/compare-event-ordering.js +13 -13
- package/lib/models/compare-event-ordering.js.map +1 -1
- package/lib/models/device.js +3 -3
- package/lib/models/device.js.map +1 -1
- package/lib/models/event-context.js +5 -8
- package/lib/models/event-context.js.map +1 -1
- package/lib/models/event-status.js +1 -1
- package/lib/models/event-status.js.map +1 -1
- package/lib/models/event-timeline-set.js +88 -94
- package/lib/models/event-timeline-set.js.map +1 -1
- package/lib/models/event-timeline.js +28 -30
- package/lib/models/event-timeline.js.map +1 -1
- package/lib/models/event.js +182 -226
- package/lib/models/event.js.map +1 -1
- package/lib/models/invites-ignorer-types.js +4 -4
- package/lib/models/invites-ignorer-types.js.map +1 -1
- package/lib/models/invites-ignorer.js +159 -179
- package/lib/models/invites-ignorer.js.map +1 -1
- package/lib/models/poll.js +71 -81
- package/lib/models/poll.js.map +1 -1
- package/lib/models/profile-keys.js +2 -2
- package/lib/models/profile-keys.js.map +1 -1
- package/lib/models/read-receipt.js +40 -56
- package/lib/models/read-receipt.js.map +1 -1
- package/lib/models/related-relations.js.map +1 -1
- package/lib/models/relations-container.js +22 -23
- package/lib/models/relations-container.js.map +1 -1
- package/lib/models/relations.js +133 -159
- package/lib/models/relations.js.map +1 -1
- package/lib/models/room-member.js +24 -29
- package/lib/models/room-member.js.map +1 -1
- package/lib/models/room-receipts.js +29 -43
- package/lib/models/room-receipts.js.map +1 -1
- package/lib/models/room-retention.js +74 -83
- package/lib/models/room-retention.js.map +1 -1
- package/lib/models/room-state.js +143 -172
- package/lib/models/room-state.js.map +1 -1
- package/lib/models/room-sticky-events.d.ts +1 -0
- package/lib/models/room-sticky-events.d.ts.map +1 -1
- package/lib/models/room-sticky-events.js +45 -65
- package/lib/models/room-sticky-events.js.map +1 -1
- package/lib/models/room-summary.js.map +1 -1
- package/lib/models/room.d.ts.map +1 -1
- package/lib/models/room.js +765 -909
- package/lib/models/room.js.map +1 -1
- package/lib/models/search-result.js +5 -5
- package/lib/models/search-result.js.map +1 -1
- package/lib/models/thread.js +225 -285
- package/lib/models/thread.js.map +1 -1
- package/lib/models/typed-event-emitter.js +7 -18
- package/lib/models/typed-event-emitter.js.map +1 -1
- package/lib/models/user.js +8 -8
- package/lib/models/user.js.map +1 -1
- package/lib/oidc/authorize.js +208 -241
- package/lib/oidc/authorize.js.map +1 -1
- package/lib/oidc/discovery.js +23 -36
- package/lib/oidc/discovery.js.map +1 -1
- package/lib/oidc/error.js +1 -1
- package/lib/oidc/error.js.map +1 -1
- package/lib/oidc/index.js +1 -0
- package/lib/oidc/index.js.map +1 -1
- package/lib/oidc/register.js +60 -66
- package/lib/oidc/register.js.map +1 -1
- package/lib/oidc/tokenRefresher.js +77 -91
- package/lib/oidc/tokenRefresher.js.map +1 -1
- package/lib/oidc/validate.js +18 -18
- package/lib/oidc/validate.js.map +1 -1
- package/lib/pushprocessor.js +71 -82
- package/lib/pushprocessor.js.map +1 -1
- package/lib/randomstring.js +9 -9
- package/lib/randomstring.js.map +1 -1
- package/lib/realtime-callbacks.js +25 -28
- package/lib/realtime-callbacks.js.map +1 -1
- package/lib/receipt-accumulator.d.ts +2 -0
- package/lib/receipt-accumulator.d.ts.map +1 -1
- package/lib/receipt-accumulator.js +14 -22
- package/lib/receipt-accumulator.js.map +1 -1
- package/lib/rendezvous/MSC4108SignInWithQR.js +271 -302
- package/lib/rendezvous/MSC4108SignInWithQR.js.map +1 -1
- package/lib/rendezvous/RendezvousChannel.js +3 -1
- package/lib/rendezvous/RendezvousCode.js +3 -1
- package/lib/rendezvous/RendezvousError.js.map +1 -1
- package/lib/rendezvous/RendezvousFailureReason.js +2 -2
- package/lib/rendezvous/RendezvousFailureReason.js.map +1 -1
- package/lib/rendezvous/RendezvousIntent.js +1 -1
- package/lib/rendezvous/RendezvousIntent.js.map +1 -1
- package/lib/rendezvous/RendezvousTransport.js +3 -1
- package/lib/rendezvous/channels/MSC4108SecureChannel.js +123 -147
- package/lib/rendezvous/channels/MSC4108SecureChannel.js.map +1 -1
- package/lib/rendezvous/index.js +44 -69
- package/lib/rendezvous/index.js.map +1 -1
- package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts +1 -1
- package/lib/rendezvous/transports/MSC4108RendezvousSession.js +134 -152
- package/lib/rendezvous/transports/MSC4108RendezvousSession.js.map +1 -1
- package/lib/retentionPolicy.js +6 -9
- package/lib/retentionPolicy.js.map +1 -1
- package/lib/room-hierarchy.js +52 -60
- package/lib/room-hierarchy.js.map +1 -1
- package/lib/rust-crypto/CrossSigningIdentity.js +94 -104
- package/lib/rust-crypto/CrossSigningIdentity.js.map +1 -1
- package/lib/rust-crypto/DehydratedDeviceManager.js +157 -190
- package/lib/rust-crypto/DehydratedDeviceManager.js.map +1 -1
- package/lib/rust-crypto/KeyClaimManager.js +18 -22
- package/lib/rust-crypto/KeyClaimManager.js.map +1 -1
- package/lib/rust-crypto/OutgoingRequestProcessor.js +109 -139
- package/lib/rust-crypto/OutgoingRequestProcessor.js.map +1 -1
- package/lib/rust-crypto/OutgoingRequestsManager.js +66 -80
- package/lib/rust-crypto/OutgoingRequestsManager.js.map +1 -1
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts +1 -1
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.js +196 -224
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.js.map +1 -1
- package/lib/rust-crypto/RoomEncryptor.js +127 -143
- package/lib/rust-crypto/RoomEncryptor.js.map +1 -1
- package/lib/rust-crypto/backup.js +453 -549
- package/lib/rust-crypto/backup.js.map +1 -1
- package/lib/rust-crypto/constants.js +1 -1
- package/lib/rust-crypto/constants.js.map +1 -1
- package/lib/rust-crypto/device-converter.js +15 -28
- package/lib/rust-crypto/device-converter.js.map +1 -1
- package/lib/rust-crypto/index.js +103 -116
- package/lib/rust-crypto/index.js.map +1 -1
- package/lib/rust-crypto/libolm_migration.js +303 -365
- package/lib/rust-crypto/libolm_migration.js.map +1 -1
- package/lib/rust-crypto/rust-crypto.d.ts +5 -1
- package/lib/rust-crypto/rust-crypto.d.ts.map +1 -1
- package/lib/rust-crypto/rust-crypto.js +1067 -1332
- package/lib/rust-crypto/rust-crypto.js.map +1 -1
- package/lib/rust-crypto/secret-storage.js +12 -25
- package/lib/rust-crypto/secret-storage.js.map +1 -1
- package/lib/rust-crypto/verification.js +137 -189
- package/lib/rust-crypto/verification.js.map +1 -1
- package/lib/scheduler.js +44 -19
- package/lib/scheduler.js.map +1 -1
- package/lib/secret-storage.js +179 -213
- package/lib/secret-storage.js.map +1 -1
- package/lib/serverCapabilities.js +6 -9
- package/lib/serverCapabilities.js.map +1 -1
- package/lib/service-types.js +1 -1
- package/lib/service-types.js.map +1 -1
- package/lib/sliding-sync-sdk.d.ts.map +1 -1
- package/lib/sliding-sync-sdk.js +368 -424
- package/lib/sliding-sync-sdk.js.map +1 -1
- package/lib/sliding-sync.js +135 -171
- package/lib/sliding-sync.js.map +1 -1
- package/lib/store/index.js +3 -1
- package/lib/store/indexeddb-backend.js +3 -1
- package/lib/store/indexeddb-local-backend.js +194 -253
- package/lib/store/indexeddb-local-backend.js.map +1 -1
- package/lib/store/indexeddb-remote-backend.js +33 -63
- package/lib/store/indexeddb-remote-backend.js.map +1 -1
- package/lib/store/indexeddb-store-worker.js +22 -23
- package/lib/store/indexeddb-store-worker.js.map +1 -1
- package/lib/store/indexeddb.js +44 -71
- package/lib/store/indexeddb.js.map +1 -1
- package/lib/store/local-storage-events-emitter.js +2 -2
- package/lib/store/local-storage-events-emitter.js.map +1 -1
- package/lib/store/memory.js +34 -57
- package/lib/store/memory.js.map +1 -1
- package/lib/store/stub.js +22 -35
- package/lib/store/stub.js.map +1 -1
- package/lib/sync-accumulator.js +54 -66
- package/lib/sync-accumulator.js.map +1 -1
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +905 -998
- package/lib/sync.js.map +1 -1
- package/lib/testing.js +63 -105
- package/lib/testing.js.map +1 -1
- package/lib/thread-utils.js +1 -4
- package/lib/thread-utils.js.map +1 -1
- package/lib/timeline-window.js +89 -102
- package/lib/timeline-window.js.map +1 -1
- package/lib/types.js +1 -1
- package/lib/types.js.map +1 -1
- package/lib/utils/decryptAESSecretStorageItem.js +14 -25
- package/lib/utils/decryptAESSecretStorageItem.js.map +1 -1
- package/lib/utils/encryptAESSecretStorageItem.js +27 -38
- package/lib/utils/encryptAESSecretStorageItem.js.map +1 -1
- package/lib/utils/internal/deriveKeys.js +25 -32
- package/lib/utils/internal/deriveKeys.js.map +1 -1
- package/lib/utils/roomVersion.js +1 -1
- package/lib/utils/roomVersion.js.map +1 -1
- package/lib/utils.js +83 -135
- package/lib/utils.js.map +1 -1
- package/lib/version-support.js +3 -3
- package/lib/version-support.js.map +1 -1
- package/lib/webrtc/audioContext.js +5 -6
- package/lib/webrtc/audioContext.js.map +1 -1
- package/lib/webrtc/call.js +1081 -1250
- package/lib/webrtc/call.js.map +1 -1
- package/lib/webrtc/callEventHandler.js +202 -214
- package/lib/webrtc/callEventHandler.js.map +1 -1
- package/lib/webrtc/callEventTypes.js +2 -2
- package/lib/webrtc/callEventTypes.js.map +1 -1
- package/lib/webrtc/callFeed.js +18 -20
- package/lib/webrtc/callFeed.js.map +1 -1
- package/lib/webrtc/groupCall.js +513 -602
- package/lib/webrtc/groupCall.js.map +1 -1
- package/lib/webrtc/groupCallEventHandler.js +59 -62
- package/lib/webrtc/groupCallEventHandler.js.map +1 -1
- package/lib/webrtc/mediaHandler.js +198 -232
- package/lib/webrtc/mediaHandler.js.map +1 -1
- package/lib/webrtc/stats/callFeedStatsReporter.js +16 -20
- package/lib/webrtc/stats/callFeedStatsReporter.js.map +1 -1
- package/lib/webrtc/stats/callStatsReportGatherer.js +67 -75
- package/lib/webrtc/stats/callStatsReportGatherer.js.map +1 -1
- package/lib/webrtc/stats/callStatsReportSummary.js +3 -1
- package/lib/webrtc/stats/connectionStats.js.map +1 -1
- package/lib/webrtc/stats/connectionStatsBuilder.js +2 -2
- package/lib/webrtc/stats/connectionStatsBuilder.js.map +1 -1
- package/lib/webrtc/stats/connectionStatsReportBuilder.js +20 -24
- package/lib/webrtc/stats/connectionStatsReportBuilder.js.map +1 -1
- package/lib/webrtc/stats/groupCallStats.js +6 -8
- package/lib/webrtc/stats/groupCallStats.js.map +1 -1
- package/lib/webrtc/stats/media/mediaSsrcHandler.js +7 -8
- package/lib/webrtc/stats/media/mediaSsrcHandler.js.map +1 -1
- package/lib/webrtc/stats/media/mediaTrackHandler.js +7 -9
- package/lib/webrtc/stats/media/mediaTrackHandler.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 +7 -7
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.js.map +1 -1
- package/lib/webrtc/stats/statsReport.js +1 -1
- package/lib/webrtc/stats/statsReport.js.map +1 -1
- package/lib/webrtc/stats/statsReportEmitter.js.map +1 -1
- package/lib/webrtc/stats/summaryStatsReportGatherer.js +14 -14
- package/lib/webrtc/stats/summaryStatsReportGatherer.js.map +1 -1
- package/lib/webrtc/stats/trackStatsBuilder.js +32 -34
- package/lib/webrtc/stats/trackStatsBuilder.js.map +1 -1
- package/lib/webrtc/stats/transportStats.js +3 -1
- package/lib/webrtc/stats/transportStatsBuilder.js +9 -9
- package/lib/webrtc/stats/transportStatsBuilder.js.map +1 -1
- package/lib/webrtc/stats/valueFormatter.js +1 -1
- package/lib/webrtc/stats/valueFormatter.js.map +1 -1
- package/package.json +18 -33
- package/src/@types/global.d.ts +2 -2
- package/src/ToDeviceMessageQueue.ts +2 -2
- package/src/browser-index.ts +4 -4
- package/src/client.ts +15 -20
- package/src/crypto-api/index.ts +17 -6
- package/src/embedded.ts +4 -6
- package/src/filter-component.ts +1 -0
- package/src/http-api/utils.ts +1 -1
- package/src/interactive-auth.ts +11 -5
- package/src/matrixrtc/LivekitTransport.ts +1 -1
- package/src/matrixrtc/MatrixRTCSession.ts +1 -1
- package/src/models/MSC3089Branch.ts +1 -1
- package/src/models/room-sticky-events.ts +1 -0
- package/src/models/room.ts +9 -11
- package/src/receipt-accumulator.ts +2 -0
- package/src/rendezvous/index.ts +1 -1
- package/src/rendezvous/transports/MSC4108RendezvousSession.ts +2 -2
- package/src/rust-crypto/PerSessionKeyBackupDownloader.ts +1 -1
- package/src/rust-crypto/index.ts +6 -6
- package/src/rust-crypto/rust-crypto.ts +31 -7
- package/src/rust-crypto/verification.ts +1 -1
- package/src/sliding-sync-sdk.ts +5 -7
- package/src/store/indexeddb-local-backend.ts +3 -3
- package/src/sync.ts +6 -8
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
1
|
/*
|
|
3
2
|
Copyright 2023 The Matrix.org Foundation C.I.C.
|
|
4
3
|
|
|
@@ -23,8 +22,8 @@ limitations under the License.
|
|
|
23
22
|
*
|
|
24
23
|
* @internal
|
|
25
24
|
*/
|
|
26
|
-
export function secretStorageContainsCrossSigningKeys(
|
|
27
|
-
return
|
|
25
|
+
export async function secretStorageContainsCrossSigningKeys(secretStorage) {
|
|
26
|
+
return secretStorageCanAccessSecrets(secretStorage, ["m.cross_signing.master", "m.cross_signing.user_signing", "m.cross_signing.self_signing"]);
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
/**
|
|
@@ -37,27 +36,15 @@ export function secretStorageContainsCrossSigningKeys(_x) {
|
|
|
37
36
|
*
|
|
38
37
|
* @internal
|
|
39
38
|
*/
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
_secretStorageCanAccessSecrets = _asyncToGenerator(function* (secretStorage, secretNames) {
|
|
51
|
-
var defaultKeyId = yield secretStorage.getDefaultKeyId();
|
|
52
|
-
if (!defaultKeyId) return false;
|
|
53
|
-
for (var secretName of secretNames) {
|
|
54
|
-
// check which keys this particular secret is encrypted with
|
|
55
|
-
var record = (yield secretStorage.isStored(secretName)) || {};
|
|
56
|
-
// if it's not encrypted with the right key, there is no point continuing
|
|
57
|
-
if (!(defaultKeyId in record)) return false;
|
|
58
|
-
}
|
|
59
|
-
return true;
|
|
60
|
-
});
|
|
61
|
-
return _secretStorageCanAccessSecrets.apply(this, arguments);
|
|
39
|
+
export async function secretStorageCanAccessSecrets(secretStorage, secretNames) {
|
|
40
|
+
const defaultKeyId = await secretStorage.getDefaultKeyId();
|
|
41
|
+
if (!defaultKeyId) return false;
|
|
42
|
+
for (const secretName of secretNames) {
|
|
43
|
+
// check which keys this particular secret is encrypted with
|
|
44
|
+
const record = (await secretStorage.isStored(secretName)) || {};
|
|
45
|
+
// if it's not encrypted with the right key, there is no point continuing
|
|
46
|
+
if (!(defaultKeyId in record)) return false;
|
|
47
|
+
}
|
|
48
|
+
return true;
|
|
62
49
|
}
|
|
63
50
|
//# sourceMappingURL=secret-storage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secret-storage.js","names":[
|
|
1
|
+
{"version":3,"file":"secret-storage.js","names":[],"sources":["../../src/rust-crypto/secret-storage.ts"],"sourcesContent":["/*\nCopyright 2023 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { type SecretStorageKey, type ServerSideSecretStorage } from \"../secret-storage.ts\";\n\n/**\n * Check that the private cross signing keys (master, self signing, user signing) are stored in the secret storage and encrypted with the default secret storage key.\n *\n * @param secretStorage - The secret store using account data\n * @returns True if the cross-signing keys are all stored and encrypted with the same secret storage key.\n *\n * @internal\n */\nexport async function secretStorageContainsCrossSigningKeys(secretStorage: ServerSideSecretStorage): Promise<boolean> {\n return secretStorageCanAccessSecrets(secretStorage, [\n \"m.cross_signing.master\",\n \"m.cross_signing.user_signing\",\n \"m.cross_signing.self_signing\",\n ]);\n}\n\n/**\n *\n * Check that the secret storage can access the given secrets using the default key.\n *\n * @param secretStorage - The secret store using account data\n * @param secretNames - The secret names to check\n * @returns True if all the given secrets are accessible and encrypted with the given key.\n *\n * @internal\n */\nexport async function secretStorageCanAccessSecrets(\n secretStorage: ServerSideSecretStorage,\n secretNames: SecretStorageKey[],\n): Promise<boolean> {\n const defaultKeyId = await secretStorage.getDefaultKeyId();\n if (!defaultKeyId) return false;\n\n for (const secretName of secretNames) {\n // check which keys this particular secret is encrypted with\n const record = (await secretStorage.isStored(secretName)) || {};\n // if it's not encrypted with the right key, there is no point continuing\n if (!(defaultKeyId in record)) return false;\n }\n\n return true;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAe,qCAAqC,CAAC,aAAsC,EAAoB;EAClH,OAAO,6BAA6B,CAAC,aAAa,EAAE,CAChD,wBAAwB,EACxB,8BAA8B,EAC9B,8BAA8B,CACjC,CAAC;AACN;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAe,6BAA6B,CAC/C,aAAsC,EACtC,WAA+B,EACf;EAChB,MAAM,YAAY,GAAG,MAAM,aAAa,CAAC,eAAe,CAAC,CAAC;EAC1D,IAAI,CAAC,YAAY,EAAE,OAAO,KAAK;EAE/B,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE;IAClC;IACA,MAAM,MAAM,GAAG,CAAC,MAAM,aAAa,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAC/D;IACA,IAAI,EAAE,YAAY,IAAI,MAAM,CAAC,EAAE,OAAO,KAAK;EAC/C;EAEA,OAAO,IAAI;AACf","ignoreList":[]}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
2
|
/*
|
|
5
3
|
Copyright 2023 The Matrix.org Foundation C.I.C.
|
|
@@ -41,11 +39,6 @@ export class RustVerificationRequest extends TypedEventEmitter {
|
|
|
41
39
|
*/
|
|
42
40
|
constructor(logger, olmMachine, inner, outgoingRequestProcessor, supportedVerificationMethods) {
|
|
43
41
|
super();
|
|
44
|
-
this.logger = logger;
|
|
45
|
-
this.olmMachine = olmMachine;
|
|
46
|
-
this.inner = inner;
|
|
47
|
-
this.outgoingRequestProcessor = outgoingRequestProcessor;
|
|
48
|
-
this.supportedVerificationMethods = supportedVerificationMethods;
|
|
49
42
|
/** a reëmitter which relays VerificationRequestEvent.Changed events emitted by the verifier */
|
|
50
43
|
_defineProperty(this, "reEmitter", void 0);
|
|
51
44
|
/** Are we in the process of sending an `m.key.verification.ready` event? */
|
|
@@ -53,6 +46,11 @@ export class RustVerificationRequest extends TypedEventEmitter {
|
|
|
53
46
|
/** Are we in the process of sending an `m.key.verification.cancellation` event? */
|
|
54
47
|
_defineProperty(this, "_cancelling", false);
|
|
55
48
|
_defineProperty(this, "_verifier", void 0);
|
|
49
|
+
this.logger = logger;
|
|
50
|
+
this.olmMachine = olmMachine;
|
|
51
|
+
this.inner = inner;
|
|
52
|
+
this.outgoingRequestProcessor = outgoingRequestProcessor;
|
|
53
|
+
this.supportedVerificationMethods = supportedVerificationMethods;
|
|
56
54
|
this.reEmitter = new TypedReEmitter(this);
|
|
57
55
|
|
|
58
56
|
// Obviously, the Rust object maintains a reference to the callback function. If the callback function maintains
|
|
@@ -61,18 +59,15 @@ export class RustVerificationRequest extends TypedEventEmitter {
|
|
|
61
59
|
//
|
|
62
60
|
// To avoid this reference cycle, use a weak reference in the callback function. If the `RustVerificationRequest`
|
|
63
61
|
// gets garbage-collected, then there is nothing to update!
|
|
64
|
-
|
|
65
|
-
inner.registerChangesCallback(
|
|
66
|
-
var _weakThis$deref;
|
|
67
|
-
return (_weakThis$deref = weakThis.deref()) === null || _weakThis$deref === void 0 ? void 0 : _weakThis$deref.onChange();
|
|
68
|
-
}));
|
|
62
|
+
const weakThis = new WeakRef(this);
|
|
63
|
+
inner.registerChangesCallback(async () => weakThis.deref()?.onChange());
|
|
69
64
|
}
|
|
70
65
|
|
|
71
66
|
/**
|
|
72
67
|
* Hook which is called when the underlying rust class notifies us that there has been a change.
|
|
73
68
|
*/
|
|
74
69
|
onChange() {
|
|
75
|
-
|
|
70
|
+
const verification = this.inner.getVerification();
|
|
76
71
|
|
|
77
72
|
// Set the _verifier object (wrapping the rust `Verification` as a js-sdk Verifier) if:
|
|
78
73
|
// - we now have a `Verification` where we lacked one before
|
|
@@ -114,8 +109,7 @@ export class RustVerificationRequest extends TypedEventEmitter {
|
|
|
114
109
|
* For to-device verifications, `undefined`.
|
|
115
110
|
*/
|
|
116
111
|
get roomId() {
|
|
117
|
-
|
|
118
|
-
return (_this$inner$roomId = this.inner.roomId) === null || _this$inner$roomId === void 0 ? void 0 : _this$inner$roomId.toString();
|
|
112
|
+
return this.inner.roomId?.toString();
|
|
119
113
|
}
|
|
120
114
|
|
|
121
115
|
/**
|
|
@@ -135,20 +129,16 @@ export class RustVerificationRequest extends TypedEventEmitter {
|
|
|
135
129
|
|
|
136
130
|
/** For verifications via to-device messages: the ID of the other device. Otherwise, undefined. */
|
|
137
131
|
get otherDeviceId() {
|
|
138
|
-
|
|
139
|
-
return (_this$inner$otherDevi = this.inner.otherDeviceId) === null || _this$inner$otherDevi === void 0 ? void 0 : _this$inner$otherDevi.toString();
|
|
132
|
+
return this.inner.otherDeviceId?.toString();
|
|
140
133
|
}
|
|
141
134
|
|
|
142
135
|
/** Get the other device involved in the verification, if it is known */
|
|
143
|
-
getOtherDevice() {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
return yield _this.olmMachine.getDevice(_this.inner.otherUserId, otherDeviceId, 5);
|
|
151
|
-
})();
|
|
136
|
+
async getOtherDevice() {
|
|
137
|
+
const otherDeviceId = this.inner.otherDeviceId;
|
|
138
|
+
if (!otherDeviceId) {
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
141
|
+
return await this.olmMachine.getDevice(this.inner.otherUserId, otherDeviceId, 5);
|
|
152
142
|
}
|
|
153
143
|
|
|
154
144
|
/** True if the other party in this request is one of this user's own devices. */
|
|
@@ -158,7 +148,7 @@ export class RustVerificationRequest extends TypedEventEmitter {
|
|
|
158
148
|
|
|
159
149
|
/** current phase of the request. */
|
|
160
150
|
get phase() {
|
|
161
|
-
|
|
151
|
+
const phase = this.inner.phase();
|
|
162
152
|
switch (phase) {
|
|
163
153
|
case RustSdkCryptoJs.VerificationRequestPhase.Created:
|
|
164
154
|
case RustSdkCryptoJs.VerificationRequestPhase.Requested:
|
|
@@ -178,7 +168,7 @@ export class RustVerificationRequest extends TypedEventEmitter {
|
|
|
178
168
|
case RustSdkCryptoJs.VerificationRequestPhase.Cancelled:
|
|
179
169
|
return VerificationPhase.Cancelled;
|
|
180
170
|
}
|
|
181
|
-
throw new Error(
|
|
171
|
+
throw new Error(`Unknown verification phase ${phase}`);
|
|
182
172
|
}
|
|
183
173
|
|
|
184
174
|
/** True if the request has sent its initial event and needs more events to complete
|
|
@@ -186,7 +176,7 @@ export class RustVerificationRequest extends TypedEventEmitter {
|
|
|
186
176
|
*/
|
|
187
177
|
get pending() {
|
|
188
178
|
if (this.inner.isPassive()) return false;
|
|
189
|
-
|
|
179
|
+
const phase = this.phase;
|
|
190
180
|
return phase !== VerificationPhase.Done && phase !== VerificationPhase.Cancelled;
|
|
191
181
|
}
|
|
192
182
|
|
|
@@ -223,7 +213,7 @@ export class RustVerificationRequest extends TypedEventEmitter {
|
|
|
223
213
|
/** the method picked in the .start event */
|
|
224
214
|
get chosenMethod() {
|
|
225
215
|
if (this.phase !== VerificationPhase.Started) return null;
|
|
226
|
-
|
|
216
|
+
const verification = this.inner.getVerification();
|
|
227
217
|
if (verification instanceof RustSdkCryptoJs.Sas) {
|
|
228
218
|
return VerificationMethod.Sas;
|
|
229
219
|
} else if (verification instanceof RustSdkCryptoJs.Qr) {
|
|
@@ -243,12 +233,12 @@ export class RustVerificationRequest extends TypedEventEmitter {
|
|
|
243
233
|
* @returns true if the other party said they supported the method
|
|
244
234
|
*/
|
|
245
235
|
otherPartySupportsMethod(method) {
|
|
246
|
-
|
|
236
|
+
const theirMethods = this.inner.theirSupportedMethods;
|
|
247
237
|
if (theirMethods === undefined) {
|
|
248
238
|
// no message from the other side yet
|
|
249
239
|
return false;
|
|
250
240
|
}
|
|
251
|
-
|
|
241
|
+
const requiredMethod = verificationMethodsByIdentifier[method];
|
|
252
242
|
return theirMethods.some(m => m === requiredMethod);
|
|
253
243
|
}
|
|
254
244
|
|
|
@@ -257,25 +247,22 @@ export class RustVerificationRequest extends TypedEventEmitter {
|
|
|
257
247
|
*
|
|
258
248
|
* @returns Promise which resolves when the event has been sent.
|
|
259
249
|
*/
|
|
260
|
-
accept() {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
if (req) {
|
|
270
|
-
yield _this2.outgoingRequestProcessor.makeOutgoingRequest(req);
|
|
271
|
-
}
|
|
272
|
-
} finally {
|
|
273
|
-
_this2._accepting = false;
|
|
250
|
+
async accept() {
|
|
251
|
+
if (this.inner.phase() !== RustSdkCryptoJs.VerificationRequestPhase.Requested || this._accepting) {
|
|
252
|
+
throw new Error(`Cannot accept a verification request in phase ${this.phase}`);
|
|
253
|
+
}
|
|
254
|
+
this._accepting = true;
|
|
255
|
+
try {
|
|
256
|
+
const req = this.inner.acceptWithMethods(this.supportedVerificationMethods.map(verificationMethodIdentifierToMethod));
|
|
257
|
+
if (req) {
|
|
258
|
+
await this.outgoingRequestProcessor.makeOutgoingRequest(req);
|
|
274
259
|
}
|
|
260
|
+
} finally {
|
|
261
|
+
this._accepting = false;
|
|
262
|
+
}
|
|
275
263
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
})();
|
|
264
|
+
// phase may have changed, so emit a 'change' event
|
|
265
|
+
this.emit(VerificationRequestEvent.Change);
|
|
279
266
|
}
|
|
280
267
|
|
|
281
268
|
/**
|
|
@@ -286,24 +273,21 @@ export class RustVerificationRequest extends TypedEventEmitter {
|
|
|
286
273
|
*
|
|
287
274
|
* @returns Promise which resolves when the event has been sent.
|
|
288
275
|
*/
|
|
289
|
-
cancel(params) {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
if (req) {
|
|
301
|
-
yield _this3.outgoingRequestProcessor.makeOutgoingRequest(req);
|
|
302
|
-
}
|
|
303
|
-
} finally {
|
|
304
|
-
_this3._cancelling = false;
|
|
276
|
+
async cancel(params) {
|
|
277
|
+
if (this._cancelling) {
|
|
278
|
+
// already cancelling; do nothing
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
this.logger.info("Cancelling verification request with params:", params);
|
|
282
|
+
this._cancelling = true;
|
|
283
|
+
try {
|
|
284
|
+
const req = this.inner.cancel();
|
|
285
|
+
if (req) {
|
|
286
|
+
await this.outgoingRequestProcessor.makeOutgoingRequest(req);
|
|
305
287
|
}
|
|
306
|
-
}
|
|
288
|
+
} finally {
|
|
289
|
+
this._cancelling = false;
|
|
290
|
+
}
|
|
307
291
|
}
|
|
308
292
|
|
|
309
293
|
/**
|
|
@@ -332,30 +316,26 @@ export class RustVerificationRequest extends TypedEventEmitter {
|
|
|
332
316
|
*
|
|
333
317
|
* @param method - the name of the verification method to use.
|
|
334
318
|
*/
|
|
335
|
-
startVerification(method) {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
throw new Error("Unsupported verification method ".concat(method));
|
|
340
|
-
}
|
|
319
|
+
async startVerification(method) {
|
|
320
|
+
if (method !== VerificationMethod.Sas) {
|
|
321
|
+
throw new Error(`Unsupported verification method ${method}`);
|
|
322
|
+
}
|
|
341
323
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
}
|
|
324
|
+
// make sure that we have a list of the other user's devices (workaround https://github.com/matrix-org/matrix-rust-sdk/issues/2896)
|
|
325
|
+
if (!(await this.getOtherDevice())) {
|
|
326
|
+
throw new Error("startVerification(): other device is unknown");
|
|
327
|
+
}
|
|
328
|
+
const res = await this.inner.startSas();
|
|
329
|
+
if (res) {
|
|
330
|
+
const [, req] = res;
|
|
331
|
+
await this.outgoingRequestProcessor.makeOutgoingRequest(req);
|
|
332
|
+
}
|
|
352
333
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
})();
|
|
334
|
+
// this should have triggered the onChange callback, and we should now have a verifier
|
|
335
|
+
if (!this._verifier) {
|
|
336
|
+
throw new Error("Still no verifier after startSas() call");
|
|
337
|
+
}
|
|
338
|
+
return this._verifier;
|
|
359
339
|
}
|
|
360
340
|
|
|
361
341
|
/**
|
|
@@ -366,24 +346,21 @@ export class RustVerificationRequest extends TypedEventEmitter {
|
|
|
366
346
|
* @param qrCodeData - the decoded QR code.
|
|
367
347
|
* @returns A verifier; call `.verify()` on it to wait for the other side to complete the verification flow.
|
|
368
348
|
*/
|
|
369
|
-
scanQRCode(uint8Array) {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
var scan = RustSdkCryptoJs.QrCodeScan.fromBytes(uint8Array);
|
|
373
|
-
var verifier = yield _this5.inner.scanQrCode(scan);
|
|
349
|
+
async scanQRCode(uint8Array) {
|
|
350
|
+
const scan = RustSdkCryptoJs.QrCodeScan.fromBytes(uint8Array);
|
|
351
|
+
const verifier = await this.inner.scanQrCode(scan);
|
|
374
352
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
353
|
+
// this should have triggered the onChange callback, and we should now have a verifier
|
|
354
|
+
if (!this._verifier) {
|
|
355
|
+
throw new Error("Still no verifier after scanQrCode() call");
|
|
356
|
+
}
|
|
379
357
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
})();
|
|
358
|
+
// we can immediately trigger the reciprocate request
|
|
359
|
+
const req = verifier.reciprocate();
|
|
360
|
+
if (req) {
|
|
361
|
+
await this.outgoingRequestProcessor.makeOutgoingRequest(req);
|
|
362
|
+
}
|
|
363
|
+
return this._verifier;
|
|
387
364
|
}
|
|
388
365
|
|
|
389
366
|
/**
|
|
@@ -412,18 +389,15 @@ export class RustVerificationRequest extends TypedEventEmitter {
|
|
|
412
389
|
*
|
|
413
390
|
* Implementation of {@link Crypto.VerificationRequest#generateQRCode}.
|
|
414
391
|
*/
|
|
415
|
-
generateQRCode() {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
if (!innerVerifier) return;
|
|
425
|
-
return innerVerifier.toBytes();
|
|
426
|
-
})();
|
|
392
|
+
async generateQRCode() {
|
|
393
|
+
// make sure that we have a list of the other user's devices (workaround https://github.com/matrix-org/matrix-rust-sdk/issues/2896)
|
|
394
|
+
if (!(await this.getOtherDevice())) {
|
|
395
|
+
throw new Error("generateQRCode(): other device is unknown");
|
|
396
|
+
}
|
|
397
|
+
const innerVerifier = await this.inner.generateQrCode();
|
|
398
|
+
// If we are unable to generate a QRCode, we return undefined
|
|
399
|
+
if (!innerVerifier) return;
|
|
400
|
+
return innerVerifier.toBytes();
|
|
427
401
|
}
|
|
428
402
|
|
|
429
403
|
/**
|
|
@@ -431,8 +405,7 @@ export class RustVerificationRequest extends TypedEventEmitter {
|
|
|
431
405
|
* this verification.
|
|
432
406
|
*/
|
|
433
407
|
get cancellationCode() {
|
|
434
|
-
|
|
435
|
-
return (_this$inner$cancelInf = (_this$inner$cancelInf2 = this.inner.cancelInfo) === null || _this$inner$cancelInf2 === void 0 ? void 0 : _this$inner$cancelInf2.cancelCode()) !== null && _this$inner$cancelInf !== void 0 ? _this$inner$cancelInf : null;
|
|
408
|
+
return this.inner.cancelInfo?.cancelCode() ?? null;
|
|
436
409
|
}
|
|
437
410
|
|
|
438
411
|
/**
|
|
@@ -441,7 +414,7 @@ export class RustVerificationRequest extends TypedEventEmitter {
|
|
|
441
414
|
* Only defined when phase is Cancelled
|
|
442
415
|
*/
|
|
443
416
|
get cancellingUserId() {
|
|
444
|
-
|
|
417
|
+
const cancelInfo = this.inner.cancelInfo;
|
|
445
418
|
if (!cancelInfo) {
|
|
446
419
|
return undefined;
|
|
447
420
|
} else if (cancelInfo.cancelledbyUs()) {
|
|
@@ -461,19 +434,16 @@ export class RustVerificationRequest extends TypedEventEmitter {
|
|
|
461
434
|
class BaseRustVerifer extends TypedEventEmitter {
|
|
462
435
|
constructor(inner, outgoingRequestProcessor) {
|
|
463
436
|
super();
|
|
464
|
-
this.inner = inner;
|
|
465
|
-
this.outgoingRequestProcessor = outgoingRequestProcessor;
|
|
466
437
|
/** A deferred which completes when the verification completes (or rejects when it is cancelled/fails) */
|
|
467
438
|
_defineProperty(this, "completionDeferred", void 0);
|
|
439
|
+
this.inner = inner;
|
|
440
|
+
this.outgoingRequestProcessor = outgoingRequestProcessor;
|
|
468
441
|
this.completionDeferred = Promise.withResolvers();
|
|
469
442
|
|
|
470
443
|
// As with RustVerificationRequest, we need to avoid a reference cycle.
|
|
471
444
|
// See the comments in RustVerificationRequest.
|
|
472
|
-
|
|
473
|
-
inner.registerChangesCallback(
|
|
474
|
-
var _weakThis$deref2;
|
|
475
|
-
return (_weakThis$deref2 = weakThis.deref()) === null || _weakThis$deref2 === void 0 ? void 0 : _weakThis$deref2.onChange();
|
|
476
|
-
}));
|
|
445
|
+
const weakThis = new WeakRef(this);
|
|
446
|
+
inner.registerChangesCallback(async () => weakThis.deref()?.onChange());
|
|
477
447
|
|
|
478
448
|
// stop the runtime complaining if nobody catches a failure
|
|
479
449
|
this.completionDeferred.promise.catch(() => null);
|
|
@@ -489,8 +459,8 @@ class BaseRustVerifer extends TypedEventEmitter {
|
|
|
489
459
|
if (this.inner.isDone()) {
|
|
490
460
|
this.completionDeferred.resolve(undefined);
|
|
491
461
|
} else if (this.inner.isCancelled()) {
|
|
492
|
-
|
|
493
|
-
this.completionDeferred.reject(new Error(
|
|
462
|
+
const cancelInfo = this.inner.cancelInfo();
|
|
463
|
+
this.completionDeferred.reject(new Error(`Verification cancelled by ${cancelInfo.cancelledbyUs() ? "us" : "them"} with code ${cancelInfo.cancelCode()}: ${cancelInfo.reason()}`));
|
|
494
464
|
}
|
|
495
465
|
this.emit(VerificationRequestEvent.Change);
|
|
496
466
|
}
|
|
@@ -519,7 +489,7 @@ class BaseRustVerifer extends TypedEventEmitter {
|
|
|
519
489
|
*/
|
|
520
490
|
cancel(e) {
|
|
521
491
|
// TODO: something with `e`
|
|
522
|
-
|
|
492
|
+
const req = this.inner.cancel();
|
|
523
493
|
if (req) {
|
|
524
494
|
this.outgoingRequestProcessor.makeOutgoingRequest(req);
|
|
525
495
|
}
|
|
@@ -572,17 +542,14 @@ export class RustQrCodeVerifier extends BaseRustVerifer {
|
|
|
572
542
|
* @returns Promise which resolves when the verification has completed, or rejects if the verification is cancelled
|
|
573
543
|
* or times out.
|
|
574
544
|
*/
|
|
575
|
-
verify() {
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
// Nothing to do here but wait.
|
|
584
|
-
yield _this7.completionDeferred.promise;
|
|
585
|
-
})();
|
|
545
|
+
async verify() {
|
|
546
|
+
// Some applications (hello, matrix-react-sdk) may not check if there is a `ShowQrCodeCallbacks` and instead
|
|
547
|
+
// register a `ShowReciprocateQr` listener which they expect to be called once `.verify` is called.
|
|
548
|
+
if (this.callbacks !== null) {
|
|
549
|
+
this.emit(VerifierEvent.ShowReciprocateQr, this.callbacks);
|
|
550
|
+
}
|
|
551
|
+
// Nothing to do here but wait.
|
|
552
|
+
await this.completionDeferred.promise;
|
|
586
553
|
}
|
|
587
554
|
|
|
588
555
|
/**
|
|
@@ -615,7 +582,7 @@ export class RustQrCodeVerifier extends BaseRustVerifer {
|
|
|
615
582
|
case QrState.Cancelled:
|
|
616
583
|
return VerificationPhase.Cancelled;
|
|
617
584
|
default:
|
|
618
|
-
throw new Error(
|
|
585
|
+
throw new Error(`Unknown qr code state ${this.inner.state()}`);
|
|
619
586
|
}
|
|
620
587
|
}
|
|
621
588
|
|
|
@@ -628,14 +595,11 @@ export class RustQrCodeVerifier extends BaseRustVerifer {
|
|
|
628
595
|
getReciprocateQrCodeCallbacks() {
|
|
629
596
|
return this.callbacks;
|
|
630
597
|
}
|
|
631
|
-
confirmScanning() {
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
yield _this8.outgoingRequestProcessor.makeOutgoingRequest(req);
|
|
637
|
-
}
|
|
638
|
-
})();
|
|
598
|
+
async confirmScanning() {
|
|
599
|
+
const req = this.inner.confirmScanning();
|
|
600
|
+
if (req) {
|
|
601
|
+
await this.outgoingRequestProcessor.makeOutgoingRequest(req);
|
|
602
|
+
}
|
|
639
603
|
}
|
|
640
604
|
}
|
|
641
605
|
|
|
@@ -655,38 +619,31 @@ export class RustSASVerifier extends BaseRustVerifer {
|
|
|
655
619
|
* @returns Promise which resolves when the verification has completed, or rejects if the verification is cancelled
|
|
656
620
|
* or times out.
|
|
657
621
|
*/
|
|
658
|
-
verify() {
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
yield _this9.sendAccept();
|
|
662
|
-
yield _this9.completionDeferred.promise;
|
|
663
|
-
})();
|
|
622
|
+
async verify() {
|
|
623
|
+
await this.sendAccept();
|
|
624
|
+
await this.completionDeferred.promise;
|
|
664
625
|
}
|
|
665
626
|
|
|
666
627
|
/**
|
|
667
628
|
* Send the accept or start event, if it hasn't already been sent
|
|
668
629
|
*/
|
|
669
|
-
sendAccept() {
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
yield _this0.outgoingRequestProcessor.makeOutgoingRequest(req);
|
|
675
|
-
}
|
|
676
|
-
})();
|
|
630
|
+
async sendAccept() {
|
|
631
|
+
const req = this.inner.accept();
|
|
632
|
+
if (req) {
|
|
633
|
+
await this.outgoingRequestProcessor.makeOutgoingRequest(req);
|
|
634
|
+
}
|
|
677
635
|
}
|
|
678
636
|
|
|
679
637
|
/** if we can now show the callbacks, do so */
|
|
680
638
|
onChange() {
|
|
681
|
-
var _this1 = this;
|
|
682
639
|
super.onChange();
|
|
683
640
|
if (this.callbacks === null) {
|
|
684
|
-
|
|
685
|
-
|
|
641
|
+
const emoji = this.inner.emoji();
|
|
642
|
+
const decimal = this.inner.decimals();
|
|
686
643
|
if (emoji === undefined && decimal === undefined) {
|
|
687
644
|
return;
|
|
688
645
|
}
|
|
689
|
-
|
|
646
|
+
const sas = {};
|
|
690
647
|
if (emoji) {
|
|
691
648
|
sas.emoji = emoji.map(e => [e.symbol, e.description]);
|
|
692
649
|
}
|
|
@@ -695,26 +652,20 @@ export class RustSASVerifier extends BaseRustVerifer {
|
|
|
695
652
|
}
|
|
696
653
|
this.callbacks = {
|
|
697
654
|
sas,
|
|
698
|
-
confirm:
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
yield _this1.outgoingRequestProcessor.makeOutgoingRequest(m);
|
|
703
|
-
}
|
|
704
|
-
});
|
|
705
|
-
function confirm() {
|
|
706
|
-
return _confirm.apply(this, arguments);
|
|
655
|
+
confirm: async () => {
|
|
656
|
+
const requests = await this.inner.confirm();
|
|
657
|
+
for (const m of requests) {
|
|
658
|
+
await this.outgoingRequestProcessor.makeOutgoingRequest(m);
|
|
707
659
|
}
|
|
708
|
-
|
|
709
|
-
}(),
|
|
660
|
+
},
|
|
710
661
|
mismatch: () => {
|
|
711
|
-
|
|
662
|
+
const request = this.inner.cancelWithCode("m.mismatched_sas");
|
|
712
663
|
if (request) {
|
|
713
|
-
this.outgoingRequestProcessor.makeOutgoingRequest(request);
|
|
664
|
+
void this.outgoingRequestProcessor.makeOutgoingRequest(request);
|
|
714
665
|
}
|
|
715
666
|
},
|
|
716
667
|
cancel: () => {
|
|
717
|
-
|
|
668
|
+
const request = this.inner.cancelWithCode("m.user");
|
|
718
669
|
if (request) {
|
|
719
670
|
this.outgoingRequestProcessor.makeOutgoingRequest(request);
|
|
720
671
|
}
|
|
@@ -753,11 +704,8 @@ export class RustSASVerifier extends BaseRustVerifer {
|
|
|
753
704
|
|
|
754
705
|
// As with RustVerificationRequest, we need to avoid a reference cycle.
|
|
755
706
|
// See the comments in RustVerificationRequest.
|
|
756
|
-
|
|
757
|
-
inner.registerChangesCallback(
|
|
758
|
-
var _weakThis$deref3;
|
|
759
|
-
return (_weakThis$deref3 = weakThis.deref()) === null || _weakThis$deref3 === void 0 ? void 0 : _weakThis$deref3.onChange();
|
|
760
|
-
}));
|
|
707
|
+
const weakThis = new WeakRef(this);
|
|
708
|
+
inner.registerChangesCallback(async () => weakThis.deref()?.onChange());
|
|
761
709
|
|
|
762
710
|
// replaceInner will only get called if we started the verification at the same time as the other side, and we lost
|
|
763
711
|
// the tie breaker. So we need to re-accept their verification.
|
|
@@ -768,7 +716,7 @@ export class RustSASVerifier extends BaseRustVerifer {
|
|
|
768
716
|
}
|
|
769
717
|
|
|
770
718
|
/** For each specced verification method, the rust-side `VerificationMethod` corresponding to it */
|
|
771
|
-
|
|
719
|
+
const verificationMethodsByIdentifier = {
|
|
772
720
|
[VerificationMethod.Sas]: RustSdkCryptoJs.VerificationMethod.SasV1,
|
|
773
721
|
[VerificationMethod.ScanQrCode]: RustSdkCryptoJs.VerificationMethod.QrCodeScanV1,
|
|
774
722
|
[VerificationMethod.ShowQrCode]: RustSdkCryptoJs.VerificationMethod.QrCodeShowV1,
|
|
@@ -785,9 +733,9 @@ var verificationMethodsByIdentifier = {
|
|
|
785
733
|
* @internal
|
|
786
734
|
*/
|
|
787
735
|
export function verificationMethodIdentifierToMethod(method) {
|
|
788
|
-
|
|
736
|
+
const meth = verificationMethodsByIdentifier[method];
|
|
789
737
|
if (meth === undefined) {
|
|
790
|
-
throw new Error(
|
|
738
|
+
throw new Error(`Unknown verification method ${method}`);
|
|
791
739
|
}
|
|
792
740
|
return meth;
|
|
793
741
|
}
|