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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MSC4108SignInWithQR.js","names":["QrCodeIntent","ClientRendezvousFailureReason","MSC4108FailureReason","RendezvousError","logger","MatrixError","sleep","generateScope","OAuthGrantType","startDeviceAuthorization","waitForDeviceAuthorization","PayloadType","isDeviceAuthorizationGrantProtocolPayload","payload","protocol","MSC4108SignInWithQR","checkCode","_this$channel","channel","getCheckCode","constructor","didScanCode","client","onFailure","_defineProperty","ourIntent","Reciprocate","Login","code","_code","generateCode","_this","_asyncToGenerator","getDomain","isExistingDevice","isNewDevice","negotiateProtocols","_this2","info","concat","connect","_oidcClientConfig","oidcClientConfig","getAuthMetadata","e","error","grant_types_supported","includes","DeviceAuthorization","send","type","Protocols","protocols","homeserver","Failure","reason","UnsupportedProtocol","receive","UnexpectedMessageReceived","serverName","deviceAuthorizationGrant","input","_this3","_dagResponse$verifica","Error","metadata","clientId","deviceId","scope","dagResponse","grantInProgress","Protocol","device_id","device_authorization_grant","verification_uri","verification_uri_complete","verificationUri","userCode","user_code","dag","expectingNewDeviceId","verificationUriComplete","deviceAlreadyExists","_this3$client","getDevice","err","httpStatus","DeviceAlreadyExists","completeLoginOnNewDevice","_ref","_this4","ProtocolAccepted","res","session","Unknown","AuthorizationExpired","UserCancelled","shareSecrets","_this5","Success","Secrets","secrets","Declined","UserDeclined","timeout","Date","now","_this5$client","device","secretsBundle","getCrypto","exportSecretsBundle","cancelled","_objectSpread","DeviceNotFound","_this6","secureReceive","_this7","secureSend","declineLoginOnExistingDevice","_this8","cancel","_this9","_this9$onFailure","call","close","_this0"],"sources":["../../src/rendezvous/MSC4108SignInWithQR.ts"],"sourcesContent":["/*\nCopyright 2024 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 { QrCodeIntent } from \"@matrix-org/matrix-sdk-crypto-wasm\";\n\nimport {\n ClientRendezvousFailureReason,\n MSC4108FailureReason,\n RendezvousError,\n type RendezvousFailureListener,\n} from \"./index.ts\";\nimport { type MatrixClient } from \"../client.ts\";\nimport { logger } from \"../logger.ts\";\nimport { type MSC4108SecureChannel } from \"./channels/MSC4108SecureChannel.ts\";\nimport { MatrixError } from \"../http-api/index.ts\";\nimport { sleep } from \"../utils.ts\";\nimport {\n type DeviceAccessTokenResponse,\n type DeviceAuthorizationResponse,\n generateScope,\n OAuthGrantType,\n startDeviceAuthorization,\n type ValidatedAuthMetadata,\n waitForDeviceAuthorization,\n type OidcClientConfig,\n} from \"../oidc/index.ts\";\nimport { type CryptoApi } from \"../crypto-api/index.ts\";\n\n/**\n * Enum representing the payload types transmissible over [MSC4108](https://github.com/matrix-org/matrix-spec-proposals/pull/4108)\n * secure channels.\n * @experimental Note that this is UNSTABLE and may have breaking changes without notice.\n */\nexport enum PayloadType {\n Protocols = \"m.login.protocols\",\n Protocol = \"m.login.protocol\",\n Failure = \"m.login.failure\",\n Success = \"m.login.success\",\n Secrets = \"m.login.secrets\",\n ProtocolAccepted = \"m.login.protocol_accepted\",\n Declined = \"m.login.declined\",\n}\n\n/**\n * Type representing the base payload format for [MSC4108](https://github.com/matrix-org/matrix-spec-proposals/pull/4108)\n * messages sent over the secure channel.\n * @experimental Note that this is UNSTABLE and may have breaking changes without notice.\n */\nexport interface MSC4108Payload {\n type: PayloadType;\n}\n\ninterface ProtocolsPayload extends MSC4108Payload {\n type: PayloadType.Protocols;\n protocols: string[];\n homeserver: string;\n}\n\ninterface ProtocolPayload extends MSC4108Payload {\n type: PayloadType.Protocol;\n protocol: Exclude<string, \"device_authorization_grant\">;\n device_id: string;\n}\n\ninterface DeviceAuthorizationGrantProtocolPayload extends ProtocolPayload {\n protocol: \"device_authorization_grant\";\n device_authorization_grant: {\n verification_uri: string;\n verification_uri_complete?: string;\n };\n}\n\nfunction isDeviceAuthorizationGrantProtocolPayload(\n payload: ProtocolPayload,\n): payload is DeviceAuthorizationGrantProtocolPayload {\n return payload.protocol === \"device_authorization_grant\";\n}\n\ninterface FailurePayload extends MSC4108Payload {\n type: PayloadType.Failure;\n reason: MSC4108FailureReason;\n homeserver?: string;\n}\n\ninterface DeclinedPayload extends MSC4108Payload {\n type: PayloadType.Declined;\n}\n\ninterface SuccessPayload extends MSC4108Payload {\n type: PayloadType.Success;\n}\n\ninterface AcceptedPayload extends MSC4108Payload {\n type: PayloadType.ProtocolAccepted;\n}\n\ninterface SecretsPayload extends MSC4108Payload, Awaited<ReturnType<NonNullable<CryptoApi[\"exportSecretsBundle\"]>>> {\n type: PayloadType.Secrets;\n}\n\n/**\n * Prototype of the unstable [MSC4108](https://github.com/matrix-org/matrix-spec-proposals/pull/4108)\n * sign in with QR + OIDC flow.\n * @experimental Note that this is UNSTABLE and may have breaking changes without notice.\n */\nexport class MSC4108SignInWithQR {\n private readonly ourIntent: QrCodeIntent;\n private _code?: Uint8Array;\n private expectingNewDeviceId?: string;\n private metadata?: ValidatedAuthMetadata;\n private grantInProgress?: DeviceAuthorizationResponse;\n\n /**\n * Returns the check code for the secure channel or undefined if not generated yet.\n */\n public get checkCode(): string | undefined {\n return this.channel?.getCheckCode();\n }\n\n /**\n * @param channel - The secure channel used for communication\n * @param client - The Matrix client in used on the device already logged in\n * @param didScanCode - Whether this side of the channel scanned the QR code from the other party\n * @param onFailure - Callback for when the rendezvous fails\n */\n public constructor(\n private readonly channel: MSC4108SecureChannel,\n private readonly didScanCode: boolean,\n private readonly client?: MatrixClient,\n public onFailure?: RendezvousFailureListener,\n ) {\n this.ourIntent = client ? QrCodeIntent.Reciprocate : QrCodeIntent.Login;\n }\n\n /**\n * Returns the code representing the rendezvous suitable for rendering in a QR code or undefined if not generated yet.\n */\n public get code(): Uint8Array | undefined {\n return this._code;\n }\n\n /**\n * Generate the code including doing partial set up of the channel where required.\n */\n public async generateCode(): Promise<void> {\n if (this._code) {\n return;\n }\n\n if (this.ourIntent === QrCodeIntent.Reciprocate && this.client) {\n this._code = await this.channel.generateCode(this.ourIntent, this.client.getDomain()!);\n } else if (this.ourIntent === QrCodeIntent.Login) {\n this._code = await this.channel.generateCode(this.ourIntent);\n }\n }\n\n /**\n * Returns true if the device is the already logged in device reciprocating a new login on the other side of the channel.\n */\n public get isExistingDevice(): boolean {\n return this.ourIntent === QrCodeIntent.Reciprocate;\n }\n\n /**\n * Returns true if the device is the new device logging in being reciprocated by the device on the other side of the channel.\n */\n public get isNewDevice(): boolean {\n return !this.isExistingDevice;\n }\n\n /**\n * The first step in the OIDC QR login process.\n * To be called after the QR code has been rendered or scanned.\n * The scanning device has to discover the homeserver details, if they scanned the code then they already have it.\n * If the new device is the one rendering the QR code then it has to wait be sent the homeserver details via the rendezvous channel.\n */\n public async negotiateProtocols(): Promise<{ serverName?: string }> {\n logger.info(`negotiateProtocols(isNewDevice=${this.isNewDevice} didScanCode=${this.didScanCode})`);\n await this.channel.connect();\n\n if (this.didScanCode) {\n // Secure Channel step 6 completed, we trust the channel\n\n if (this.isNewDevice) {\n // MSC4108-Flow: ExistingScanned - take homeserver from QR code which should already be set\n } else {\n // MSC4108-Flow: NewScanned -send protocols message\n let oidcClientConfig: OidcClientConfig | undefined;\n try {\n oidcClientConfig = await this.client!.getAuthMetadata();\n } catch (e) {\n logger.error(\"Failed to discover OIDC metadata\", e);\n }\n\n if (oidcClientConfig?.grant_types_supported.includes(OAuthGrantType.DeviceAuthorization)) {\n await this.send<ProtocolsPayload>({\n type: PayloadType.Protocols,\n protocols: [\"device_authorization_grant\"],\n homeserver: this.client!.getDomain()!,\n });\n } else {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnsupportedProtocol,\n });\n throw new RendezvousError(\n \"Device code grant unsupported\",\n MSC4108FailureReason.UnsupportedProtocol,\n );\n }\n }\n } else if (this.isNewDevice) {\n // MSC4108-Flow: ExistingScanned - wait for protocols message\n logger.info(\"Waiting for protocols message\");\n const payload = await this.receive<ProtocolsPayload>();\n\n if (payload?.type === PayloadType.Failure) {\n throw new RendezvousError(\"Failed\", payload.reason);\n }\n\n if (payload?.type !== PayloadType.Protocols) {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnexpectedMessageReceived,\n });\n throw new RendezvousError(\n \"Unexpected message received\",\n MSC4108FailureReason.UnexpectedMessageReceived,\n );\n }\n\n return { serverName: payload.homeserver };\n } else {\n // MSC4108-Flow: NewScanned - nothing to do\n }\n return {};\n }\n\n /**\n * The second & third step in the OIDC QR login process.\n * To be called after `negotiateProtocols` for the existing device.\n * To be called after OIDC negotiation for the new device.\n *\n * @param input - Required for the new device to start the device authorization grant, not required for the existing device reciprocating the login\n */\n public async deviceAuthorizationGrant(input?: {\n metadata: ValidatedAuthMetadata;\n clientId: string;\n deviceId: string;\n }): Promise<{\n verificationUri?: string;\n userCode?: string;\n }> {\n if (this.isNewDevice) {\n if (!input) {\n throw new Error(\"Input must be provided for new device\");\n }\n\n const { metadata, clientId, deviceId } = input;\n\n const scope = generateScope(deviceId);\n\n // MSC4108-Flow: NewDevice - start device authorization grant\n const dagResponse = await startDeviceAuthorization({\n clientId,\n scope,\n metadata,\n });\n\n this.metadata = metadata;\n this.grantInProgress = dagResponse;\n\n const protocol: DeviceAuthorizationGrantProtocolPayload = {\n type: PayloadType.Protocol,\n protocol: \"device_authorization_grant\",\n device_id: deviceId,\n device_authorization_grant: {\n verification_uri: dagResponse.verification_uri,\n verification_uri_complete: dagResponse.verification_uri_complete,\n },\n };\n\n await this.send(protocol);\n\n return {\n verificationUri: dagResponse.verification_uri_complete ?? dagResponse.verification_uri,\n userCode: dagResponse.user_code,\n };\n } else {\n // The user needs to do step 7 for the out-of-band confirmation\n // but, first we receive the protocol chosen by the other device so that\n // the confirmation_uri is ready to go\n logger.info(\"Waiting for protocol message\");\n const payload = await this.receive<ProtocolPayload | DeviceAuthorizationGrantProtocolPayload>();\n\n if (payload?.type === PayloadType.Failure) {\n throw new RendezvousError(\"Failed\", payload.reason);\n }\n\n if (payload?.type !== PayloadType.Protocol) {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnexpectedMessageReceived,\n });\n throw new RendezvousError(\n \"Unexpected message received\",\n MSC4108FailureReason.UnexpectedMessageReceived,\n );\n }\n\n if (isDeviceAuthorizationGrantProtocolPayload(payload)) {\n const { device_authorization_grant: dag, device_id: expectingNewDeviceId } = payload;\n const { verification_uri: verificationUri, verification_uri_complete: verificationUriComplete } = dag;\n\n let deviceAlreadyExists = true;\n try {\n await this.client?.getDevice(expectingNewDeviceId);\n } catch (err: MatrixError | unknown) {\n if (err instanceof MatrixError && err.httpStatus === 404) {\n deviceAlreadyExists = false;\n }\n }\n\n if (deviceAlreadyExists) {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.DeviceAlreadyExists,\n });\n throw new RendezvousError(\n \"Specified device ID already exists\",\n MSC4108FailureReason.DeviceAlreadyExists,\n );\n }\n\n this.expectingNewDeviceId = expectingNewDeviceId;\n\n return { verificationUri: verificationUriComplete ?? verificationUri };\n }\n\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnsupportedProtocol,\n });\n throw new RendezvousError(\n \"Received a request for an unsupported protocol\",\n MSC4108FailureReason.UnsupportedProtocol,\n );\n }\n }\n\n /**\n * The fourth step in the OIDC QR login process.\n * The reciprocating device must perform step 5 for this method to resolve.\n * To be called after {@link deviceAuthorizationGrant} only on the new device.\n */\n public async completeLoginOnNewDevice({\n clientId,\n }: {\n clientId: string;\n }): Promise<DeviceAccessTokenResponse | undefined> {\n if (!this.isNewDevice || !this.grantInProgress || !this.metadata) {\n throw new Error(\"Can only complete login on new device\");\n }\n\n logger.info(\"Waiting for protocol accepted message\");\n // wait for accepted message\n const payload = await this.receive<AcceptedPayload | FailurePayload>();\n\n if (!payload) {\n throw new RendezvousError(\n \"No response from existing device\",\n MSC4108FailureReason.UnexpectedMessageReceived,\n );\n }\n if (payload.type === PayloadType.Failure) {\n throw new RendezvousError(\"Failed\", (payload as FailurePayload).reason);\n }\n if (payload.type !== PayloadType.ProtocolAccepted) {\n throw new RendezvousError(\"Unexpected message received\", MSC4108FailureReason.UnexpectedMessageReceived);\n }\n\n // poll for DAG\n const res = await waitForDeviceAuthorization({\n session: this.grantInProgress,\n metadata: this.metadata,\n clientId,\n });\n\n if (!res) {\n throw new RendezvousError(\n \"No response from device authorization endpoint\",\n ClientRendezvousFailureReason.Unknown,\n );\n }\n\n if (\"error\" in res) {\n let reason: MSC4108FailureReason = MSC4108FailureReason.UnexpectedMessageReceived;\n if (res.error === \"expired_token\") {\n reason = MSC4108FailureReason.AuthorizationExpired;\n } else if (res.error === \"access_denied\") {\n reason = MSC4108FailureReason.UserCancelled;\n }\n const payload: FailurePayload = {\n type: PayloadType.Failure,\n reason,\n };\n await this.send(payload);\n\n throw new RendezvousError(\"Rejection from device authorization endpoint\", reason);\n }\n\n return res;\n }\n\n /**\n * The fifth (and final) step in the OIDC QR login process.\n * To be called after the new device has completed authentication.\n */\n public async shareSecrets(): Promise<{ secrets?: Omit<SecretsPayload, \"type\"> }> {\n if (this.isNewDevice) {\n await this.send<SuccessPayload>({\n type: PayloadType.Success,\n });\n // then wait for secrets\n logger.info(\"Waiting for secrets message\");\n const payload = await this.receive<SecretsPayload>();\n if (payload?.type === PayloadType.Failure) {\n throw new RendezvousError(\"Failed\", payload.reason);\n }\n\n if (payload?.type !== PayloadType.Secrets) {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnexpectedMessageReceived,\n });\n throw new RendezvousError(\n \"Unexpected message received\",\n MSC4108FailureReason.UnexpectedMessageReceived,\n );\n }\n return { secrets: payload };\n // then done?\n } else {\n if (!this.expectingNewDeviceId) {\n throw new Error(\"No new device ID expected\");\n }\n await this.send<AcceptedPayload>({\n type: PayloadType.ProtocolAccepted,\n });\n\n logger.info(\"Waiting for outcome message\");\n const payload = await this.receive<SuccessPayload | DeclinedPayload>();\n\n if (payload?.type === PayloadType.Failure) {\n throw new RendezvousError(\"Failed\", payload.reason);\n }\n\n if (payload?.type === PayloadType.Declined) {\n throw new RendezvousError(\"User declined\", ClientRendezvousFailureReason.UserDeclined);\n }\n\n if (payload?.type !== PayloadType.Success) {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnexpectedMessageReceived,\n });\n throw new RendezvousError(\"Unexpected message\", MSC4108FailureReason.UnexpectedMessageReceived);\n }\n\n const timeout = Date.now() + 10000; // wait up to 10 seconds\n do {\n // is the device visible via the Homeserver?\n try {\n const device = await this.client?.getDevice(this.expectingNewDeviceId);\n\n if (device) {\n // if so, return the secrets\n const secretsBundle = await this.client!.getCrypto()!.exportSecretsBundle!();\n if (this.channel.cancelled) {\n throw new RendezvousError(\"User cancelled\", MSC4108FailureReason.UserCancelled);\n }\n // send secrets\n await this.send<SecretsPayload>({\n type: PayloadType.Secrets,\n ...secretsBundle,\n });\n return { secrets: secretsBundle };\n // let the other side close the rendezvous session\n }\n } catch (err: MatrixError | unknown) {\n if (err instanceof MatrixError && err.httpStatus === 404) {\n // not found, so keep waiting until timeout\n } else {\n throw err;\n }\n }\n await sleep(1000);\n } while (Date.now() < timeout);\n\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.DeviceNotFound,\n });\n throw new RendezvousError(\"New device not found\", MSC4108FailureReason.DeviceNotFound);\n }\n }\n\n private async receive<T extends MSC4108Payload>(): Promise<T | FailurePayload | undefined> {\n return (await this.channel.secureReceive()) as T | undefined;\n }\n\n private async send<T extends MSC4108Payload>(payload: T): Promise<void> {\n await this.channel.secureSend(payload);\n }\n\n /**\n * Decline the login on the existing device.\n */\n public async declineLoginOnExistingDevice(): Promise<void> {\n if (!this.isExistingDevice) {\n throw new Error(\"Can only decline login on existing device\");\n }\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UserCancelled,\n });\n }\n\n /**\n * Cancels the rendezvous session.\n * @param reason the reason for the cancellation\n */\n public async cancel(reason: MSC4108FailureReason | ClientRendezvousFailureReason): Promise<void> {\n this.onFailure?.(reason);\n await this.channel.cancel(reason);\n }\n\n /**\n * Closes the rendezvous session.\n */\n public async close(): Promise<void> {\n await this.channel.close();\n }\n}\n"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,YAAY,QAAQ,oCAAoC;AAEjE,SACIC,6BAA6B,EAC7BC,oBAAoB,EACpBC,eAAe,QAEZ,YAAY;AAEnB,SAASC,MAAM,QAAQ,cAAc;AAErC,SAASC,WAAW,QAAQ,sBAAsB;AAClD,SAASC,KAAK,QAAQ,aAAa;AACnC,SAGIC,aAAa,EACbC,cAAc,EACdC,wBAAwB,EAExBC,0BAA0B,QAEvB,kBAAkB;AAGzB;AACA;AACA;AACA;AACA;AACA,WAAYC,WAAW,0BAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAA,OAAXA,WAAW;AAAA;;AAUvB;AACA;AACA;AACA;AACA;;AAyBA,SAASC,yCAAyCA,CAC9CC,OAAwB,EAC0B;EAClD,OAAOA,OAAO,CAACC,QAAQ,KAAK,4BAA4B;AAC5D;AAwBA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,mBAAmB,CAAC;EAO7B;AACJ;AACA;EACI,IAAWC,SAASA,CAAA,EAAuB;IAAA,IAAAC,aAAA;IACvC,QAAAA,aAAA,GAAO,IAAI,CAACC,OAAO,cAAAD,aAAA,uBAAZA,aAAA,CAAcE,YAAY,CAAC,CAAC;EACvC;;EAEA;AACJ;AAC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AAO,CAACkG,aAAa,CAAC,CAAC;IAAmB;EACjE;EAEcnE,IAAIA,CAA2BpC,OAAU,EAAiB;IAAA,IAAAwG,MAAA;IAAA,OAAArF,iBAAA;MACpE,MAAMqF,MAAI,CAACnG,OAAO,CAACoG,UAAU,CAACzG,OAAO,CAAC;IAAC;EAC3C;;EAEA;AACJ;AACA;EACiB0G,4BAA4BA,CAAA,EAAkB;IAAA,IAAAC,MAAA;IAAA,OAAAxF,iBAAA;MACvD,IAAI,CAACwF,MAAI,CAACtF,gBAAgB,EAAE;QACxB,MAAM,IAAI8B,KAAK,CAAC,2CAA2C,CAAC;MAChE;MACA,MAAMwD,MAAI,CAACvE,IAAI,CAAiB;QAC5BC,IAAI,EAAEvC,WAAW,CAAC2C,OAAO;QACzBC,MAAM,EAAErD,oBAAoB,CAAC8F;MACjC,CAAC,CAAC;IAAC;EACP;;EAEA;AACJ;AACA;AACA;EACiByB,MAAMA,CAAClE,MAA4D,EAAiB;IAAA,IAAAmE,MAAA;IAAA,OAAA1F,iBAAA;MAAA,IAAA2F,gBAAA;MAC7F,CAAAA,gBAAA,GAAAD,MAAI,CAACnG,SAAS,cAAAoG,gBAAA,eAAdA,gBAAA,CAAAC,IAAA,CAAAF,MAAI,EAAanE,MAAM,CAAC;MACxB,MAAMmE,MAAI,CAACxG,OAAO,CAACuG,MAAM,CAAClE,MAAM,CAAC;IAAC;EACtC;;EAEA;AACJ;AACA;EACiBsE,KAAKA,CAAA,EAAkB;IAAA,IAAAC,MAAA;IAAA,OAAA9F,iBAAA;MAChC,MAAM8F,MAAI,CAAC5G,OAAO,CAAC2G,KAAK,CAAC,CAAC;IAAC;EAC/B;AACJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"MSC4108SignInWithQR.js","names":[],"sources":["../../src/rendezvous/MSC4108SignInWithQR.ts"],"sourcesContent":["/*\nCopyright 2024 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 { QrCodeIntent } from \"@matrix-org/matrix-sdk-crypto-wasm\";\n\nimport {\n ClientRendezvousFailureReason,\n MSC4108FailureReason,\n RendezvousError,\n type RendezvousFailureListener,\n} from \"./index.ts\";\nimport { type MatrixClient } from \"../client.ts\";\nimport { logger } from \"../logger.ts\";\nimport { type MSC4108SecureChannel } from \"./channels/MSC4108SecureChannel.ts\";\nimport { MatrixError } from \"../http-api/index.ts\";\nimport { sleep } from \"../utils.ts\";\nimport {\n type DeviceAccessTokenResponse,\n type DeviceAuthorizationResponse,\n generateScope,\n OAuthGrantType,\n startDeviceAuthorization,\n type ValidatedAuthMetadata,\n waitForDeviceAuthorization,\n type OidcClientConfig,\n} from \"../oidc/index.ts\";\nimport { type CryptoApi } from \"../crypto-api/index.ts\";\n\n/**\n * Enum representing the payload types transmissible over [MSC4108](https://github.com/matrix-org/matrix-spec-proposals/pull/4108)\n * secure channels.\n * @experimental Note that this is UNSTABLE and may have breaking changes without notice.\n */\nexport enum PayloadType {\n Protocols = \"m.login.protocols\",\n Protocol = \"m.login.protocol\",\n Failure = \"m.login.failure\",\n Success = \"m.login.success\",\n Secrets = \"m.login.secrets\",\n ProtocolAccepted = \"m.login.protocol_accepted\",\n Declined = \"m.login.declined\",\n}\n\n/**\n * Type representing the base payload format for [MSC4108](https://github.com/matrix-org/matrix-spec-proposals/pull/4108)\n * messages sent over the secure channel.\n * @experimental Note that this is UNSTABLE and may have breaking changes without notice.\n */\nexport interface MSC4108Payload {\n type: PayloadType;\n}\n\ninterface ProtocolsPayload extends MSC4108Payload {\n type: PayloadType.Protocols;\n protocols: string[];\n homeserver: string;\n}\n\ninterface ProtocolPayload extends MSC4108Payload {\n type: PayloadType.Protocol;\n protocol: Exclude<string, \"device_authorization_grant\">;\n device_id: string;\n}\n\ninterface DeviceAuthorizationGrantProtocolPayload extends ProtocolPayload {\n protocol: \"device_authorization_grant\";\n device_authorization_grant: {\n verification_uri: string;\n verification_uri_complete?: string;\n };\n}\n\nfunction isDeviceAuthorizationGrantProtocolPayload(\n payload: ProtocolPayload,\n): payload is DeviceAuthorizationGrantProtocolPayload {\n return payload.protocol === \"device_authorization_grant\";\n}\n\ninterface FailurePayload extends MSC4108Payload {\n type: PayloadType.Failure;\n reason: MSC4108FailureReason;\n homeserver?: string;\n}\n\ninterface DeclinedPayload extends MSC4108Payload {\n type: PayloadType.Declined;\n}\n\ninterface SuccessPayload extends MSC4108Payload {\n type: PayloadType.Success;\n}\n\ninterface AcceptedPayload extends MSC4108Payload {\n type: PayloadType.ProtocolAccepted;\n}\n\ninterface SecretsPayload extends MSC4108Payload, Awaited<ReturnType<NonNullable<CryptoApi[\"exportSecretsBundle\"]>>> {\n type: PayloadType.Secrets;\n}\n\n/**\n * Prototype of the unstable [MSC4108](https://github.com/matrix-org/matrix-spec-proposals/pull/4108)\n * sign in with QR + OIDC flow.\n * @experimental Note that this is UNSTABLE and may have breaking changes without notice.\n */\nexport class MSC4108SignInWithQR {\n private readonly ourIntent: QrCodeIntent;\n private _code?: Uint8Array;\n private expectingNewDeviceId?: string;\n private metadata?: ValidatedAuthMetadata;\n private grantInProgress?: DeviceAuthorizationResponse;\n\n /**\n * Returns the check code for the secure channel or undefined if not generated yet.\n */\n public get checkCode(): string | undefined {\n return this.channel?.getCheckCode();\n }\n\n /**\n * @param channel - The secure channel used for communication\n * @param client - The Matrix client in used on the device already logged in\n * @param didScanCode - Whether this side of the channel scanned the QR code from the other party\n * @param onFailure - Callback for when the rendezvous fails\n */\n public constructor(\n private readonly channel: MSC4108SecureChannel,\n private readonly didScanCode: boolean,\n private readonly client?: MatrixClient,\n public onFailure?: RendezvousFailureListener,\n ) {\n this.ourIntent = client ? QrCodeIntent.Reciprocate : QrCodeIntent.Login;\n }\n\n /**\n * Returns the code representing the rendezvous suitable for rendering in a QR code or undefined if not generated yet.\n */\n public get code(): Uint8Array | undefined {\n return this._code;\n }\n\n /**\n * Generate the code including doing partial set up of the channel where required.\n */\n public async generateCode(): Promise<void> {\n if (this._code) {\n return;\n }\n\n if (this.ourIntent === QrCodeIntent.Reciprocate && this.client) {\n this._code = await this.channel.generateCode(this.ourIntent, this.client.getDomain()!);\n } else if (this.ourIntent === QrCodeIntent.Login) {\n this._code = await this.channel.generateCode(this.ourIntent);\n }\n }\n\n /**\n * Returns true if the device is the already logged in device reciprocating a new login on the other side of the channel.\n */\n public get isExistingDevice(): boolean {\n return this.ourIntent === QrCodeIntent.Reciprocate;\n }\n\n /**\n * Returns true if the device is the new device logging in being reciprocated by the device on the other side of the channel.\n */\n public get isNewDevice(): boolean {\n return !this.isExistingDevice;\n }\n\n /**\n * The first step in the OIDC QR login process.\n * To be called after the QR code has been rendered or scanned.\n * The scanning device has to discover the homeserver details, if they scanned the code then they already have it.\n * If the new device is the one rendering the QR code then it has to wait be sent the homeserver details via the rendezvous channel.\n */\n public async negotiateProtocols(): Promise<{ serverName?: string }> {\n logger.info(`negotiateProtocols(isNewDevice=${this.isNewDevice} didScanCode=${this.didScanCode})`);\n await this.channel.connect();\n\n if (this.didScanCode) {\n // Secure Channel step 6 completed, we trust the channel\n\n if (this.isNewDevice) {\n // MSC4108-Flow: ExistingScanned - take homeserver from QR code which should already be set\n } else {\n // MSC4108-Flow: NewScanned -send protocols message\n let oidcClientConfig: OidcClientConfig | undefined;\n try {\n oidcClientConfig = await this.client!.getAuthMetadata();\n } catch (e) {\n logger.error(\"Failed to discover OIDC metadata\", e);\n }\n\n if (oidcClientConfig?.grant_types_supported.includes(OAuthGrantType.DeviceAuthorization)) {\n await this.send<ProtocolsPayload>({\n type: PayloadType.Protocols,\n protocols: [\"device_authorization_grant\"],\n homeserver: this.client!.getDomain()!,\n });\n } else {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnsupportedProtocol,\n });\n throw new RendezvousError(\n \"Device code grant unsupported\",\n MSC4108FailureReason.UnsupportedProtocol,\n );\n }\n }\n } else if (this.isNewDevice) {\n // MSC4108-Flow: ExistingScanned - wait for protocols message\n logger.info(\"Waiting for protocols message\");\n const payload = await this.receive<ProtocolsPayload>();\n\n if (payload?.type === PayloadType.Failure) {\n throw new RendezvousError(\"Failed\", payload.reason);\n }\n\n if (payload?.type !== PayloadType.Protocols) {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnexpectedMessageReceived,\n });\n throw new RendezvousError(\n \"Unexpected message received\",\n MSC4108FailureReason.UnexpectedMessageReceived,\n );\n }\n\n return { serverName: payload.homeserver };\n } else {\n // MSC4108-Flow: NewScanned - nothing to do\n }\n return {};\n }\n\n /**\n * The second & third step in the OIDC QR login process.\n * To be called after `negotiateProtocols` for the existing device.\n * To be called after OIDC negotiation for the new device.\n *\n * @param input - Required for the new device to start the device authorization grant, not required for the existing device reciprocating the login\n */\n public async deviceAuthorizationGrant(input?: {\n metadata: ValidatedAuthMetadata;\n clientId: string;\n deviceId: string;\n }): Promise<{\n verificationUri?: string;\n userCode?: string;\n }> {\n if (this.isNewDevice) {\n if (!input) {\n throw new Error(\"Input must be provided for new device\");\n }\n\n const { metadata, clientId, deviceId } = input;\n\n const scope = generateScope(deviceId);\n\n // MSC4108-Flow: NewDevice - start device authorization grant\n const dagResponse = await startDeviceAuthorization({\n clientId,\n scope,\n metadata,\n });\n\n this.metadata = metadata;\n this.grantInProgress = dagResponse;\n\n const protocol: DeviceAuthorizationGrantProtocolPayload = {\n type: PayloadType.Protocol,\n protocol: \"device_authorization_grant\",\n device_id: deviceId,\n device_authorization_grant: {\n verification_uri: dagResponse.verification_uri,\n verification_uri_complete: dagResponse.verification_uri_complete,\n },\n };\n\n await this.send(protocol);\n\n return {\n verificationUri: dagResponse.verification_uri_complete ?? dagResponse.verification_uri,\n userCode: dagResponse.user_code,\n };\n } else {\n // The user needs to do step 7 for the out-of-band confirmation\n // but, first we receive the protocol chosen by the other device so that\n // the confirmation_uri is ready to go\n logger.info(\"Waiting for protocol message\");\n const payload = await this.receive<ProtocolPayload | DeviceAuthorizationGrantProtocolPayload>();\n\n if (payload?.type === PayloadType.Failure) {\n throw new RendezvousError(\"Failed\", payload.reason);\n }\n\n if (payload?.type !== PayloadType.Protocol) {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnexpectedMessageReceived,\n });\n throw new RendezvousError(\n \"Unexpected message received\",\n MSC4108FailureReason.UnexpectedMessageReceived,\n );\n }\n\n if (isDeviceAuthorizationGrantProtocolPayload(payload)) {\n const { device_authorization_grant: dag, device_id: expectingNewDeviceId } = payload;\n const { verification_uri: verificationUri, verification_uri_complete: verificationUriComplete } = dag;\n\n let deviceAlreadyExists = true;\n try {\n await this.client?.getDevice(expectingNewDeviceId);\n } catch (err: MatrixError | unknown) {\n if (err instanceof MatrixError && err.httpStatus === 404) {\n deviceAlreadyExists = false;\n }\n }\n\n if (deviceAlreadyExists) {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.DeviceAlreadyExists,\n });\n throw new RendezvousError(\n \"Specified device ID already exists\",\n MSC4108FailureReason.DeviceAlreadyExists,\n );\n }\n\n this.expectingNewDeviceId = expectingNewDeviceId;\n\n return { verificationUri: verificationUriComplete ?? verificationUri };\n }\n\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnsupportedProtocol,\n });\n throw new RendezvousError(\n \"Received a request for an unsupported protocol\",\n MSC4108FailureReason.UnsupportedProtocol,\n );\n }\n }\n\n /**\n * The fourth step in the OIDC QR login process.\n * The reciprocating device must perform step 5 for this method to resolve.\n * To be called after {@link deviceAuthorizationGrant} only on the new device.\n */\n public async completeLoginOnNewDevice({\n clientId,\n }: {\n clientId: string;\n }): Promise<DeviceAccessTokenResponse | undefined> {\n if (!this.isNewDevice || !this.grantInProgress || !this.metadata) {\n throw new Error(\"Can only complete login on new device\");\n }\n\n logger.info(\"Waiting for protocol accepted message\");\n // wait for accepted message\n const payload = await this.receive<AcceptedPayload | FailurePayload>();\n\n if (!payload) {\n throw new RendezvousError(\n \"No response from existing device\",\n MSC4108FailureReason.UnexpectedMessageReceived,\n );\n }\n if (payload.type === PayloadType.Failure) {\n throw new RendezvousError(\"Failed\", (payload as FailurePayload).reason);\n }\n if (payload.type !== PayloadType.ProtocolAccepted) {\n throw new RendezvousError(\"Unexpected message received\", MSC4108FailureReason.UnexpectedMessageReceived);\n }\n\n // poll for DAG\n const res = await waitForDeviceAuthorization({\n session: this.grantInProgress,\n metadata: this.metadata,\n clientId,\n });\n\n if (!res) {\n throw new RendezvousError(\n \"No response from device authorization endpoint\",\n ClientRendezvousFailureReason.Unknown,\n );\n }\n\n if (\"error\" in res) {\n let reason: MSC4108FailureReason = MSC4108FailureReason.UnexpectedMessageReceived;\n if (res.error === \"expired_token\") {\n reason = MSC4108FailureReason.AuthorizationExpired;\n } else if (res.error === \"access_denied\") {\n reason = MSC4108FailureReason.UserCancelled;\n }\n const payload: FailurePayload = {\n type: PayloadType.Failure,\n reason,\n };\n await this.send(payload);\n\n throw new RendezvousError(\"Rejection from device authorization endpoint\", reason);\n }\n\n return res;\n }\n\n /**\n * The fifth (and final) step in the OIDC QR login process.\n * To be called after the new device has completed authentication.\n */\n public async shareSecrets(): Promise<{ secrets?: Omit<SecretsPayload, \"type\"> }> {\n if (this.isNewDevice) {\n await this.send<SuccessPayload>({\n type: PayloadType.Success,\n });\n // then wait for secrets\n logger.info(\"Waiting for secrets message\");\n const payload = await this.receive<SecretsPayload>();\n if (payload?.type === PayloadType.Failure) {\n throw new RendezvousError(\"Failed\", payload.reason);\n }\n\n if (payload?.type !== PayloadType.Secrets) {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnexpectedMessageReceived,\n });\n throw new RendezvousError(\n \"Unexpected message received\",\n MSC4108FailureReason.UnexpectedMessageReceived,\n );\n }\n return { secrets: payload };\n // then done?\n } else {\n if (!this.expectingNewDeviceId) {\n throw new Error(\"No new device ID expected\");\n }\n await this.send<AcceptedPayload>({\n type: PayloadType.ProtocolAccepted,\n });\n\n logger.info(\"Waiting for outcome message\");\n const payload = await this.receive<SuccessPayload | DeclinedPayload>();\n\n if (payload?.type === PayloadType.Failure) {\n throw new RendezvousError(\"Failed\", payload.reason);\n }\n\n if (payload?.type === PayloadType.Declined) {\n throw new RendezvousError(\"User declined\", ClientRendezvousFailureReason.UserDeclined);\n }\n\n if (payload?.type !== PayloadType.Success) {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnexpectedMessageReceived,\n });\n throw new RendezvousError(\"Unexpected message\", MSC4108FailureReason.UnexpectedMessageReceived);\n }\n\n const timeout = Date.now() + 10000; // wait up to 10 seconds\n do {\n // is the device visible via the Homeserver?\n try {\n const device = await this.client?.getDevice(this.expectingNewDeviceId);\n\n if (device) {\n // if so, return the secrets\n const secretsBundle = await this.client!.getCrypto()!.exportSecretsBundle!();\n if (this.channel.cancelled) {\n throw new RendezvousError(\"User cancelled\", MSC4108FailureReason.UserCancelled);\n }\n // send secrets\n await this.send<SecretsPayload>({\n type: PayloadType.Secrets,\n ...secretsBundle,\n });\n return { secrets: secretsBundle };\n // let the other side close the rendezvous session\n }\n } catch (err: MatrixError | unknown) {\n if (err instanceof MatrixError && err.httpStatus === 404) {\n // not found, so keep waiting until timeout\n } else {\n throw err;\n }\n }\n await sleep(1000);\n } while (Date.now() < timeout);\n\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.DeviceNotFound,\n });\n throw new RendezvousError(\"New device not found\", MSC4108FailureReason.DeviceNotFound);\n }\n }\n\n private async receive<T extends MSC4108Payload>(): Promise<T | FailurePayload | undefined> {\n return (await this.channel.secureReceive()) as T | undefined;\n }\n\n private async send<T extends MSC4108Payload>(payload: T): Promise<void> {\n await this.channel.secureSend(payload);\n }\n\n /**\n * Decline the login on the existing device.\n */\n public async declineLoginOnExistingDevice(): Promise<void> {\n if (!this.isExistingDevice) {\n throw new Error(\"Can only decline login on existing device\");\n }\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UserCancelled,\n });\n }\n\n /**\n * Cancels the rendezvous session.\n * @param reason the reason for the cancellation\n */\n public async cancel(reason: MSC4108FailureReason | ClientRendezvousFailureReason): Promise<void> {\n this.onFailure?.(reason);\n await this.channel.cancel(reason);\n }\n\n /**\n * Closes the rendezvous session.\n */\n public async close(): Promise<void> {\n await this.channel.close();\n }\n}\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAS,YAAY,QAAQ,oCAAoC;AAEjE,SACI,6BAA6B,EAC7B,oBAAoB,EACpB,eAAe,QAEZ,YAAY;AAEnB,SAAS,MAAM,QAAQ,cAAc;AAErC,SAAS,WAAW,QAAQ,sBAAsB;AAClD,SAAS,KAAK,QAAQ,aAAa;AACnC,SAGI,aAAa,EACb,cAAc,EACd,wBAAwB,EAExB,0BAA0B,QAEvB,kBAAkB;AAGzB;AACA;AACA;AACA;AACA;AACA,WAAY,WAAW,0BAAX,WAAW;EAAX,WAAW;EAAX,WAAW;EAAX,WAAW;EAAX,WAAW;EAAX,WAAW;EAAX,WAAW;EAAX,WAAW;EAAA,OAAX,WAAW;AAAA;;AAUvB;AACA;AACA;AACA;AACA;;AAyBA,SAAS,yCAAyC,CAC9C,OAAwB,EAC0B;EAClD,OAAO,OAAO,CAAC,QAAQ,KAAK,4BAA4B;AAC5D;AAwBA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAM,mBAAmB,CAAC;EAO7B;AACJ;AACA;EACI,IAAW,SAAS,GAAuB;IACvC,OAAO,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,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EACI,MAAa,MAAM,CAAC,MAA4D,EAAiB;IAC7F,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC;IACxB,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;EACrC;;EAEA;AACJ;AACA;EACI,MAAa,KAAK,GAAkB;IAChC,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;EAC9B;AACJ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RendezvousError.js","names":[
|
|
1
|
+
{"version":3,"file":"RendezvousError.js","names":[],"sources":["../../src/rendezvous/RendezvousError.ts"],"sourcesContent":["/*\nCopyright 2022 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { type RendezvousFailureReason } from \"./index.ts\";\n\nexport class RendezvousError extends Error {\n public constructor(\n message: string,\n public readonly code: RendezvousFailureReason,\n ) {\n super(message);\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAO,MAAM,eAAe,SAAS,KAAK,CAAC;EAChC,WAAW,CACd,OAAe,EACC,IAA6B,EAC/C;IACE,KAAK,CAAC,OAAO,CAAC;IAAC,KAFC,IAA6B,GAA7B,IAA6B;EAGjD;AACJ","ignoreList":[]}
|
|
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
export
|
|
17
|
+
export let MSC4108FailureReason = /*#__PURE__*/function (MSC4108FailureReason) {
|
|
18
18
|
MSC4108FailureReason["AuthorizationExpired"] = "authorization_expired";
|
|
19
19
|
MSC4108FailureReason["DeviceAlreadyExists"] = "device_already_exists";
|
|
20
20
|
MSC4108FailureReason["DeviceNotFound"] = "device_not_found";
|
|
@@ -23,7 +23,7 @@ export var MSC4108FailureReason = /*#__PURE__*/function (MSC4108FailureReason) {
|
|
|
23
23
|
MSC4108FailureReason["UserCancelled"] = "user_cancelled";
|
|
24
24
|
return MSC4108FailureReason;
|
|
25
25
|
}({});
|
|
26
|
-
export
|
|
26
|
+
export let ClientRendezvousFailureReason = /*#__PURE__*/function (ClientRendezvousFailureReason) {
|
|
27
27
|
/** The sign in request has expired */
|
|
28
28
|
ClientRendezvousFailureReason["Expired"] = "expired";
|
|
29
29
|
/** The homeserver is lacking support for the required features */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RendezvousFailureReason.js","names":[
|
|
1
|
+
{"version":3,"file":"RendezvousFailureReason.js","names":[],"sources":["../../src/rendezvous/RendezvousFailureReason.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\nexport type RendezvousFailureListener = (reason: RendezvousFailureReason) => void;\n\nexport type RendezvousFailureReason = MSC4108FailureReason | ClientRendezvousFailureReason;\n\nexport enum MSC4108FailureReason {\n AuthorizationExpired = \"authorization_expired\",\n DeviceAlreadyExists = \"device_already_exists\",\n DeviceNotFound = \"device_not_found\",\n UnexpectedMessageReceived = \"unexpected_message_received\",\n UnsupportedProtocol = \"unsupported_protocol\",\n UserCancelled = \"user_cancelled\",\n}\n\nexport enum ClientRendezvousFailureReason {\n /** The sign in request has expired */\n Expired = \"expired\",\n /** The homeserver is lacking support for the required features */\n HomeserverLacksSupport = \"homeserver_lacks_support\",\n /** The secure channel verification failed meaning that it might be compromised */\n InsecureChannelDetected = \"insecure_channel_detected\",\n /** An invalid/incompatible QR code was scanned */\n InvalidCode = \"invalid_code\",\n /** The other device is not signed in */\n OtherDeviceNotSignedIn = \"other_device_not_signed_in\",\n /** The other device is already signed in */\n OtherDeviceAlreadySignedIn = \"other_device_already_signed_in\",\n /** Other */\n Unknown = \"unknown\",\n /** The user declined the sign in request */\n UserDeclined = \"user_declined\",\n /** The rendezvous request is missing an ETag header */\n ETagMissing = \"etag_missing\",\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,WAAY,oBAAoB,0BAApB,oBAAoB;EAApB,oBAAoB;EAApB,oBAAoB;EAApB,oBAAoB;EAApB,oBAAoB;EAApB,oBAAoB;EAApB,oBAAoB;EAAA,OAApB,oBAAoB;AAAA;AAShC,WAAY,6BAA6B,0BAA7B,6BAA6B;EACrC;EADQ,6BAA6B;EAGrC;EAHQ,6BAA6B;EAKrC;EALQ,6BAA6B;EAOrC;EAPQ,6BAA6B;EASrC;EATQ,6BAA6B;EAWrC;EAXQ,6BAA6B;EAarC;EAbQ,6BAA6B;EAerC;EAfQ,6BAA6B;EAiBrC;EAjBQ,6BAA6B;EAAA,OAA7B,6BAA6B;AAAA","ignoreList":[]}
|
|
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
export
|
|
17
|
+
export let RendezvousIntent = /*#__PURE__*/function (RendezvousIntent) {
|
|
18
18
|
RendezvousIntent["LOGIN_ON_NEW_DEVICE"] = "login.start";
|
|
19
19
|
RendezvousIntent["RECIPROCATE_LOGIN_ON_EXISTING_DEVICE"] = "login.reciprocate";
|
|
20
20
|
return RendezvousIntent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RendezvousIntent.js","names":[
|
|
1
|
+
{"version":3,"file":"RendezvousIntent.js","names":[],"sources":["../../src/rendezvous/RendezvousIntent.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\nexport enum RendezvousIntent {\n LOGIN_ON_NEW_DEVICE = \"login.start\",\n RECIPROCATE_LOGIN_ON_EXISTING_DEVICE = \"login.reciprocate\",\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,WAAY,gBAAgB,0BAAhB,gBAAgB;EAAhB,gBAAgB;EAAhB,gBAAgB;EAAA,OAAhB,gBAAgB;AAAA","ignoreList":[]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
2
|
/*
|
|
4
3
|
Copyright 2024 The Matrix.org Foundation C.I.C.
|
|
@@ -28,12 +27,12 @@ import { logger } from "../../logger.js";
|
|
|
28
27
|
*/
|
|
29
28
|
export class MSC4108SecureChannel {
|
|
30
29
|
constructor(rendezvousSession, theirPublicKey, onFailure) {
|
|
31
|
-
this.rendezvousSession = rendezvousSession;
|
|
32
|
-
this.theirPublicKey = theirPublicKey;
|
|
33
|
-
this.onFailure = onFailure;
|
|
34
30
|
_defineProperty(this, "secureChannel", void 0);
|
|
35
31
|
_defineProperty(this, "establishedChannel", void 0);
|
|
36
32
|
_defineProperty(this, "connected", false);
|
|
33
|
+
this.rendezvousSession = rendezvousSession;
|
|
34
|
+
this.theirPublicKey = theirPublicKey;
|
|
35
|
+
this.onFailure = onFailure;
|
|
37
36
|
this.secureChannel = new Ecies();
|
|
38
37
|
}
|
|
39
38
|
|
|
@@ -43,196 +42,173 @@ export class MSC4108SecureChannel {
|
|
|
43
42
|
* @param serverName the name of the homeserver to connect to, as defined by server discovery in the spec, required for `Reciprocate` mode.
|
|
44
43
|
*/
|
|
45
44
|
|
|
46
|
-
generateCode(mode, serverName) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
})();
|
|
45
|
+
async generateCode(mode, serverName) {
|
|
46
|
+
const {
|
|
47
|
+
url
|
|
48
|
+
} = this.rendezvousSession;
|
|
49
|
+
if (!url) {
|
|
50
|
+
throw new Error("No rendezvous session URL");
|
|
51
|
+
}
|
|
52
|
+
return new QrCodeData(this.secureChannel.public_key(), url, mode === QrCodeIntent.Reciprocate ? serverName : undefined).toBytes();
|
|
55
53
|
}
|
|
56
54
|
|
|
57
55
|
/**
|
|
58
56
|
* Returns the check code for the secure channel or undefined if not generated yet.
|
|
59
57
|
*/
|
|
60
58
|
getCheckCode() {
|
|
61
|
-
|
|
62
|
-
var x = (_this$establishedChan = this.establishedChannel) === null || _this$establishedChan === void 0 ? void 0 : _this$establishedChan.check_code();
|
|
59
|
+
const x = this.establishedChannel?.check_code();
|
|
63
60
|
if (!x) {
|
|
64
61
|
return undefined;
|
|
65
62
|
}
|
|
66
|
-
return Array.from(x.as_bytes()).map(b =>
|
|
63
|
+
return Array.from(x.as_bytes()).map(b => `${b % 10}`).join("");
|
|
67
64
|
}
|
|
68
65
|
|
|
69
66
|
/**
|
|
70
67
|
* Connects and establishes a secure channel with the other device.
|
|
71
68
|
*/
|
|
72
|
-
connect() {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
69
|
+
async connect() {
|
|
70
|
+
if (this.connected) {
|
|
71
|
+
throw new Error("Channel already connected");
|
|
72
|
+
}
|
|
73
|
+
if (this.theirPublicKey) {
|
|
74
|
+
// We are the scanning device
|
|
75
|
+
const result = this.secureChannel.establish_outbound_channel(this.theirPublicKey, "MATRIX_QR_CODE_LOGIN_INITIATE");
|
|
76
|
+
this.establishedChannel = result.channel;
|
|
77
|
+
|
|
78
|
+
/*
|
|
79
|
+
Secure Channel step 4. Device S sends the initial message
|
|
80
|
+
Nonce := 0
|
|
81
|
+
SH := ECDH(Ss, Gp)
|
|
82
|
+
EncKey := HKDF_SHA256(SH, "MATRIX_QR_CODE_LOGIN|" || Gp || "|" || Sp, 0, 32)
|
|
83
|
+
TaggedCiphertext := ChaCha20Poly1305_Encrypt(EncKey, Nonce, "MATRIX_QR_CODE_LOGIN_INITIATE")
|
|
84
|
+
Nonce := Nonce + 2
|
|
85
|
+
LoginInitiateMessage := UnpaddedBase64(TaggedCiphertext) || "|" || UnpaddedBase64(Sp)
|
|
86
|
+
*/
|
|
87
|
+
{
|
|
88
|
+
logger.info("Sending LoginInitiateMessage");
|
|
89
|
+
await this.rendezvousSession.send(result.initial_message);
|
|
77
90
|
}
|
|
78
|
-
if (_this2.theirPublicKey) {
|
|
79
|
-
// We are the scanning device
|
|
80
|
-
var result = _this2.secureChannel.establish_outbound_channel(_this2.theirPublicKey, "MATRIX_QR_CODE_LOGIN_INITIATE");
|
|
81
|
-
_this2.establishedChannel = result.channel;
|
|
82
|
-
|
|
83
|
-
/*
|
|
84
|
-
Secure Channel step 4. Device S sends the initial message
|
|
85
|
-
Nonce := 0
|
|
86
|
-
SH := ECDH(Ss, Gp)
|
|
87
|
-
EncKey := HKDF_SHA256(SH, "MATRIX_QR_CODE_LOGIN|" || Gp || "|" || Sp, 0, 32)
|
|
88
|
-
TaggedCiphertext := ChaCha20Poly1305_Encrypt(EncKey, Nonce, "MATRIX_QR_CODE_LOGIN_INITIATE")
|
|
89
|
-
Nonce := Nonce + 2
|
|
90
|
-
LoginInitiateMessage := UnpaddedBase64(TaggedCiphertext) || "|" || UnpaddedBase64(Sp)
|
|
91
|
-
*/
|
|
92
|
-
{
|
|
93
|
-
logger.info("Sending LoginInitiateMessage");
|
|
94
|
-
yield _this2.rendezvousSession.send(result.initial_message);
|
|
95
|
-
}
|
|
96
91
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
throw new RendezvousError("No response from other device", MSC4108FailureReason.UnexpectedMessageReceived);
|
|
111
|
-
}
|
|
112
|
-
var candidateLoginOkMessage = yield _this2.decrypt(ciphertext);
|
|
113
|
-
if (candidateLoginOkMessage !== "MATRIX_QR_CODE_LOGIN_OK") {
|
|
114
|
-
throw new RendezvousError("Invalid response from other device", ClientRendezvousFailureReason.InsecureChannelDetected);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// Step 6 is now complete. We trust the channel
|
|
118
|
-
}
|
|
119
|
-
} else {
|
|
120
|
-
/*
|
|
121
|
-
Secure Channel step 5. Device G confirms
|
|
122
|
-
Nonce_S := 0
|
|
123
|
-
(TaggedCiphertext, Sp) := Unpack(LoginInitiateMessage)
|
|
124
|
-
SH := ECDH(Gs, Sp)
|
|
125
|
-
EncKey := HKDF_SHA256(SH, "MATRIX_QR_CODE_LOGIN|" || Gp || "|" || Sp, 0, 32)
|
|
126
|
-
Plaintext := ChaCha20Poly1305_Decrypt(EncKey, Nonce_S, TaggedCiphertext)
|
|
127
|
-
Nonce_S := Nonce_S + 2
|
|
128
|
-
*/
|
|
129
|
-
// wait for the other side to send us their public key
|
|
130
|
-
logger.info("Waiting for LoginInitiateMessage");
|
|
131
|
-
var loginInitiateMessage = yield _this2.rendezvousSession.receive();
|
|
132
|
-
if (!loginInitiateMessage) {
|
|
92
|
+
/*
|
|
93
|
+
Secure Channel step 6. Verification by Device S
|
|
94
|
+
Nonce_G := 1
|
|
95
|
+
(TaggedCiphertext, Sp) := Unpack(Message)
|
|
96
|
+
Plaintext := ChaCha20Poly1305_Decrypt(EncKey, Nonce_G, TaggedCiphertext)
|
|
97
|
+
Nonce_G := Nonce_G + 2
|
|
98
|
+
unless Plaintext == "MATRIX_QR_CODE_LOGIN_OK":
|
|
99
|
+
FAIL
|
|
100
|
+
*/
|
|
101
|
+
{
|
|
102
|
+
logger.info("Waiting for LoginOkMessage");
|
|
103
|
+
const ciphertext = await this.rendezvousSession.receive();
|
|
104
|
+
if (!ciphertext) {
|
|
133
105
|
throw new RendezvousError("No response from other device", MSC4108FailureReason.UnexpectedMessageReceived);
|
|
134
106
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
candidateLoginInitiateMessage = _this2$secureChannel$.message;
|
|
138
|
-
_this2.establishedChannel = channel;
|
|
139
|
-
if (candidateLoginInitiateMessage !== "MATRIX_QR_CODE_LOGIN_INITIATE") {
|
|
107
|
+
const candidateLoginOkMessage = await this.decrypt(ciphertext);
|
|
108
|
+
if (candidateLoginOkMessage !== "MATRIX_QR_CODE_LOGIN_OK") {
|
|
140
109
|
throw new RendezvousError("Invalid response from other device", ClientRendezvousFailureReason.InsecureChannelDetected);
|
|
141
110
|
}
|
|
142
|
-
logger.info("LoginInitiateMessage received");
|
|
143
|
-
logger.info("Sending LoginOkMessage");
|
|
144
|
-
var loginOkMessage = yield _this2.encrypt("MATRIX_QR_CODE_LOGIN_OK");
|
|
145
|
-
yield _this2.rendezvousSession.send(loginOkMessage);
|
|
146
|
-
|
|
147
|
-
// Step 5 is complete. We don't yet trust the channel
|
|
148
111
|
|
|
149
|
-
//
|
|
112
|
+
// Step 6 is now complete. We trust the channel
|
|
150
113
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
114
|
+
} else {
|
|
115
|
+
/*
|
|
116
|
+
Secure Channel step 5. Device G confirms
|
|
117
|
+
Nonce_S := 0
|
|
118
|
+
(TaggedCiphertext, Sp) := Unpack(LoginInitiateMessage)
|
|
119
|
+
SH := ECDH(Gs, Sp)
|
|
120
|
+
EncKey := HKDF_SHA256(SH, "MATRIX_QR_CODE_LOGIN|" || Gp || "|" || Sp, 0, 32)
|
|
121
|
+
Plaintext := ChaCha20Poly1305_Decrypt(EncKey, Nonce_S, TaggedCiphertext)
|
|
122
|
+
Nonce_S := Nonce_S + 2
|
|
123
|
+
*/
|
|
124
|
+
// wait for the other side to send us their public key
|
|
125
|
+
logger.info("Waiting for LoginInitiateMessage");
|
|
126
|
+
const loginInitiateMessage = await this.rendezvousSession.receive();
|
|
127
|
+
if (!loginInitiateMessage) {
|
|
128
|
+
throw new RendezvousError("No response from other device", MSC4108FailureReason.UnexpectedMessageReceived);
|
|
159
129
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
throw new Error("Channel closed");
|
|
130
|
+
const {
|
|
131
|
+
channel,
|
|
132
|
+
message: candidateLoginInitiateMessage
|
|
133
|
+
} = this.secureChannel.establish_inbound_channel(loginInitiateMessage);
|
|
134
|
+
this.establishedChannel = channel;
|
|
135
|
+
if (candidateLoginInitiateMessage !== "MATRIX_QR_CODE_LOGIN_INITIATE") {
|
|
136
|
+
throw new RendezvousError("Invalid response from other device", ClientRendezvousFailureReason.InsecureChannelDetected);
|
|
168
137
|
}
|
|
169
|
-
|
|
170
|
-
|
|
138
|
+
logger.info("LoginInitiateMessage received");
|
|
139
|
+
logger.info("Sending LoginOkMessage");
|
|
140
|
+
const loginOkMessage = await this.encrypt("MATRIX_QR_CODE_LOGIN_OK");
|
|
141
|
+
await this.rendezvousSession.send(loginOkMessage);
|
|
142
|
+
|
|
143
|
+
// Step 5 is complete. We don't yet trust the channel
|
|
144
|
+
|
|
145
|
+
// next step will be for the user to confirm the check code on the other device
|
|
146
|
+
}
|
|
147
|
+
this.connected = true;
|
|
148
|
+
}
|
|
149
|
+
async decrypt(ciphertext) {
|
|
150
|
+
if (!this.establishedChannel) {
|
|
151
|
+
throw new Error("Channel closed");
|
|
152
|
+
}
|
|
153
|
+
return this.establishedChannel.decrypt(ciphertext);
|
|
154
|
+
}
|
|
155
|
+
async encrypt(plaintext) {
|
|
156
|
+
if (!this.establishedChannel) {
|
|
157
|
+
throw new Error("Channel closed");
|
|
158
|
+
}
|
|
159
|
+
return this.establishedChannel.encrypt(plaintext);
|
|
171
160
|
}
|
|
172
161
|
|
|
173
162
|
/**
|
|
174
163
|
* Sends a payload securely to the other device.
|
|
175
164
|
* @param payload the payload to encrypt and send
|
|
176
165
|
*/
|
|
177
|
-
secureSend(payload) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
logger.debug("=> {\"type\": ".concat(JSON.stringify(payload.type), ", ...}"));
|
|
185
|
-
yield _this5.rendezvousSession.send(yield _this5.encrypt(stringifiedPayload));
|
|
186
|
-
})();
|
|
166
|
+
async secureSend(payload) {
|
|
167
|
+
if (!this.connected) {
|
|
168
|
+
throw new Error("Channel closed");
|
|
169
|
+
}
|
|
170
|
+
const stringifiedPayload = JSON.stringify(payload);
|
|
171
|
+
logger.debug(`=> {"type": ${JSON.stringify(payload.type)}, ...}`);
|
|
172
|
+
await this.rendezvousSession.send(await this.encrypt(stringifiedPayload));
|
|
187
173
|
}
|
|
188
174
|
|
|
189
175
|
/**
|
|
190
176
|
* Receives an encrypted payload from the other device and decrypts it.
|
|
191
177
|
*/
|
|
192
|
-
secureReceive() {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
logger.debug("<= {\"type\": ".concat(JSON.stringify(json.type), ", ...}"));
|
|
205
|
-
return json;
|
|
206
|
-
})();
|
|
178
|
+
async secureReceive() {
|
|
179
|
+
if (!this.establishedChannel) {
|
|
180
|
+
throw new Error("Channel closed");
|
|
181
|
+
}
|
|
182
|
+
const ciphertext = await this.rendezvousSession.receive();
|
|
183
|
+
if (!ciphertext) {
|
|
184
|
+
return undefined;
|
|
185
|
+
}
|
|
186
|
+
const plaintext = await this.decrypt(ciphertext);
|
|
187
|
+
const json = JSON.parse(plaintext);
|
|
188
|
+
logger.debug(`<= {"type": ${JSON.stringify(json.type)}, ...}`);
|
|
189
|
+
return json;
|
|
207
190
|
}
|
|
208
191
|
|
|
209
192
|
/**
|
|
210
193
|
* Closes the secure channel.
|
|
211
194
|
*/
|
|
212
|
-
close() {
|
|
213
|
-
|
|
214
|
-
return _asyncToGenerator(function* () {
|
|
215
|
-
yield _this7.rendezvousSession.close();
|
|
216
|
-
})();
|
|
195
|
+
async close() {
|
|
196
|
+
await this.rendezvousSession.close();
|
|
217
197
|
}
|
|
218
198
|
|
|
219
199
|
/**
|
|
220
200
|
* Cancels the secure channel.
|
|
221
201
|
* @param reason the reason for the cancellation
|
|
222
202
|
*/
|
|
223
|
-
cancel(reason) {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
} finally {
|
|
231
|
-
if (reason !== ClientRendezvousFailureReason.UserDeclined && reason !== MSC4108FailureReason.UserCancelled) {
|
|
232
|
-
yield _this8.close();
|
|
233
|
-
}
|
|
203
|
+
async cancel(reason) {
|
|
204
|
+
try {
|
|
205
|
+
await this.rendezvousSession.cancel(reason);
|
|
206
|
+
this.onFailure?.(reason);
|
|
207
|
+
} finally {
|
|
208
|
+
if (reason !== ClientRendezvousFailureReason.UserDeclined && reason !== MSC4108FailureReason.UserCancelled) {
|
|
209
|
+
await this.close();
|
|
234
210
|
}
|
|
235
|
-
}
|
|
211
|
+
}
|
|
236
212
|
}
|
|
237
213
|
|
|
238
214
|
/**
|