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
package/lib/interactive-auth.js
CHANGED
|
@@ -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 2016 OpenMarket Ltd
|
|
@@ -20,8 +19,8 @@ limitations under the License.
|
|
|
20
19
|
|
|
21
20
|
import { logger } from "./logger.js";
|
|
22
21
|
import { MatrixError } from "./http-api/index.js";
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
const EMAIL_STAGE_TYPE = "m.login.email.identity";
|
|
23
|
+
const MSISDN_STAGE_TYPE = "m.login.msisdn";
|
|
25
24
|
|
|
26
25
|
/**
|
|
27
26
|
* Data returned in the body of a 401 response from a UIA endpoint.
|
|
@@ -29,7 +28,7 @@ var MSISDN_STAGE_TYPE = "m.login.msisdn";
|
|
|
29
28
|
* @see https://spec.matrix.org/v1.6/client-server-api/#user-interactive-api-in-the-rest-api
|
|
30
29
|
*/
|
|
31
30
|
|
|
32
|
-
export
|
|
31
|
+
export let AuthType = /*#__PURE__*/function (AuthType) {
|
|
33
32
|
AuthType["Password"] = "m.login.password";
|
|
34
33
|
AuthType["Recaptcha"] = "m.login.recaptcha";
|
|
35
34
|
AuthType["Terms"] = "m.login.terms";
|
|
@@ -74,9 +73,9 @@ export class NoAuthFlowFoundError extends Error {
|
|
|
74
73
|
// eslint-disable-next-line @typescript-eslint/naming-convention, camelcase
|
|
75
74
|
required_stages, flows) {
|
|
76
75
|
super(m);
|
|
76
|
+
_defineProperty(this, "name", "NoAuthFlowFoundError");
|
|
77
77
|
this.required_stages = required_stages;
|
|
78
78
|
this.flows = flows;
|
|
79
|
-
_defineProperty(this, "name", "NoAuthFlowFoundError");
|
|
80
79
|
}
|
|
81
80
|
}
|
|
82
81
|
|
|
@@ -107,7 +106,6 @@ export class NoAuthFlowFoundError extends Error {
|
|
|
107
106
|
*/
|
|
108
107
|
export class InteractiveAuth {
|
|
109
108
|
constructor(opts) {
|
|
110
|
-
var _this = this;
|
|
111
109
|
_defineProperty(this, "matrixClient", void 0);
|
|
112
110
|
_defineProperty(this, "inputs", void 0);
|
|
113
111
|
_defineProperty(this, "clientSecret", void 0);
|
|
@@ -130,25 +128,25 @@ export class InteractiveAuth {
|
|
|
130
128
|
/**
|
|
131
129
|
* Requests a new email token and sets the email sid for the validation session
|
|
132
130
|
*/
|
|
133
|
-
_defineProperty(this, "requestEmailToken",
|
|
134
|
-
if (!
|
|
135
|
-
logger.trace("Requesting email token. Attempt: " +
|
|
131
|
+
_defineProperty(this, "requestEmailToken", async () => {
|
|
132
|
+
if (!this.requestingEmailToken) {
|
|
133
|
+
logger.trace("Requesting email token. Attempt: " + this.emailAttempt);
|
|
136
134
|
// If we've picked a flow with email auth, we send the email
|
|
137
135
|
// now because we want the request to fail as soon as possible
|
|
138
136
|
// if the email address is not valid (ie. already taken or not
|
|
139
137
|
// registered, depending on what the operation is).
|
|
140
|
-
|
|
138
|
+
this.requestingEmailToken = true;
|
|
141
139
|
try {
|
|
142
|
-
|
|
143
|
-
|
|
140
|
+
const requestTokenResult = await this.requestEmailTokenCallback(this.inputs.emailAddress, this.clientSecret, this.emailAttempt++, this.data.session);
|
|
141
|
+
this.emailSid = requestTokenResult.sid;
|
|
144
142
|
logger.trace("Email token request succeeded");
|
|
145
143
|
} finally {
|
|
146
|
-
|
|
144
|
+
this.requestingEmailToken = false;
|
|
147
145
|
}
|
|
148
146
|
} else {
|
|
149
147
|
logger.warn("Could not request email token: Already requesting");
|
|
150
148
|
}
|
|
151
|
-
})
|
|
149
|
+
});
|
|
152
150
|
this.matrixClient = opts.matrixClient;
|
|
153
151
|
this.data = opts.authData || {
|
|
154
152
|
flows: []
|
|
@@ -172,33 +170,27 @@ export class InteractiveAuth {
|
|
|
172
170
|
* or rejects with the error on failure. Rejects with NoAuthFlowFoundError if
|
|
173
171
|
* no suitable authentication flow can be found
|
|
174
172
|
*/
|
|
175
|
-
attemptAuth() {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
//
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
});
|
|
197
|
-
} else {
|
|
198
|
-
_this2.startNextAuthStage();
|
|
199
|
-
}
|
|
200
|
-
return promise;
|
|
201
|
-
})();
|
|
173
|
+
async attemptAuth() {
|
|
174
|
+
// This promise will be quite long-lived and will resolve when the
|
|
175
|
+
// request is authenticated and completes successfully.
|
|
176
|
+
this.attemptAuthDeferred = Promise.withResolvers();
|
|
177
|
+
// pluck the promise out now, as doRequest may clear before we return
|
|
178
|
+
const promise = this.attemptAuthDeferred.promise;
|
|
179
|
+
|
|
180
|
+
// if we have no flows, try a request to acquire the flows
|
|
181
|
+
if (!this.data?.flows?.length) {
|
|
182
|
+
this.busyChangedCallback?.(true);
|
|
183
|
+
// use the existing sessionId, if one is present.
|
|
184
|
+
const auth = this.data.session ? {
|
|
185
|
+
session: this.data.session
|
|
186
|
+
} : null;
|
|
187
|
+
this.doRequest(auth).finally(() => {
|
|
188
|
+
this.busyChangedCallback?.(false);
|
|
189
|
+
});
|
|
190
|
+
} else {
|
|
191
|
+
this.startNextAuthStage();
|
|
192
|
+
}
|
|
193
|
+
return promise;
|
|
202
194
|
}
|
|
203
195
|
|
|
204
196
|
/**
|
|
@@ -206,36 +198,33 @@ export class InteractiveAuth {
|
|
|
206
198
|
* completed out-of-band. If so, the attemptAuth promise will
|
|
207
199
|
* be resolved.
|
|
208
200
|
*/
|
|
209
|
-
poll() {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
if (isUrl) {
|
|
229
|
-
creds.id_server = new URL(isUrl).host;
|
|
230
|
-
}
|
|
231
|
-
authDict = {
|
|
232
|
-
type: EMAIL_STAGE_TYPE,
|
|
233
|
-
threepid_creds: creds
|
|
234
|
-
};
|
|
201
|
+
async poll() {
|
|
202
|
+
if (!this.data.session) return;
|
|
203
|
+
// likewise don't poll if there is no auth session in progress
|
|
204
|
+
if (!this.attemptAuthDeferred) return;
|
|
205
|
+
// if we currently have a request in flight, there's no point making
|
|
206
|
+
// another just to check what the status is
|
|
207
|
+
if (this.submitPromise) return;
|
|
208
|
+
let authDict = {};
|
|
209
|
+
if (this.currentStage == EMAIL_STAGE_TYPE) {
|
|
210
|
+
// The email can be validated out-of-band, but we need to provide the
|
|
211
|
+
// creds so the HS can go & check it.
|
|
212
|
+
if (this.emailSid) {
|
|
213
|
+
const creds = {
|
|
214
|
+
sid: this.emailSid,
|
|
215
|
+
client_secret: this.clientSecret
|
|
216
|
+
};
|
|
217
|
+
const isUrl = this.matrixClient.getIdentityServerUrl();
|
|
218
|
+
if (isUrl) {
|
|
219
|
+
creds.id_server = new URL(isUrl).host;
|
|
235
220
|
}
|
|
221
|
+
authDict = {
|
|
222
|
+
type: EMAIL_STAGE_TYPE,
|
|
223
|
+
threepid_creds: creds
|
|
224
|
+
};
|
|
236
225
|
}
|
|
237
|
-
|
|
238
|
-
|
|
226
|
+
}
|
|
227
|
+
this.submitAuthDict(authDict, true);
|
|
239
228
|
}
|
|
240
229
|
|
|
241
230
|
/**
|
|
@@ -244,8 +233,7 @@ export class InteractiveAuth {
|
|
|
244
233
|
* @returns session id
|
|
245
234
|
*/
|
|
246
235
|
getSessionId() {
|
|
247
|
-
|
|
248
|
-
return (_this$data = this.data) === null || _this$data === void 0 ? void 0 : _this$data.session;
|
|
236
|
+
return this.data?.session;
|
|
249
237
|
}
|
|
250
238
|
|
|
251
239
|
/**
|
|
@@ -265,8 +253,7 @@ export class InteractiveAuth {
|
|
|
265
253
|
* @returns any parameters from the server for this stage
|
|
266
254
|
*/
|
|
267
255
|
getStageParams(loginType) {
|
|
268
|
-
|
|
269
|
-
return (_this$data2 = this.data) === null || _this$data2 === void 0 || (_this$data2 = _this$data2.params) === null || _this$data2 === void 0 ? void 0 : _this$data2[loginType];
|
|
256
|
+
return this.data?.params?.[loginType];
|
|
270
257
|
}
|
|
271
258
|
getChosenFlow() {
|
|
272
259
|
return this.chosenFlow;
|
|
@@ -284,53 +271,45 @@ export class InteractiveAuth {
|
|
|
284
271
|
* in the attemptAuth promise being rejected. This can be set to true
|
|
285
272
|
* for requests that just poll to see if auth has been completed elsewhere.
|
|
286
273
|
*/
|
|
287
|
-
submitAuthDict(authData) {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
throw new Error("submitAuthDict() called before attemptAuth()");
|
|
295
|
-
}
|
|
296
|
-
if (!background) {
|
|
297
|
-
var _this4$busyChangedCal;
|
|
298
|
-
(_this4$busyChangedCal = _this4.busyChangedCallback) === null || _this4$busyChangedCal === void 0 || _this4$busyChangedCal.call(_this4, true);
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
// if we're currently trying a request, wait for it to finish
|
|
302
|
-
// as otherwise we can get multiple 200 responses which can mean
|
|
303
|
-
// things like multiple logins for register requests.
|
|
304
|
-
// (but discard any exceptions as we only care when its done,
|
|
305
|
-
// not whether it worked or not)
|
|
306
|
-
while (_this4.submitPromise) {
|
|
307
|
-
try {
|
|
308
|
-
yield _this4.submitPromise;
|
|
309
|
-
} catch (_unused) {}
|
|
310
|
-
}
|
|
274
|
+
async submitAuthDict(authData, background = false) {
|
|
275
|
+
if (!this.attemptAuthDeferred) {
|
|
276
|
+
throw new Error("submitAuthDict() called before attemptAuth()");
|
|
277
|
+
}
|
|
278
|
+
if (!background) {
|
|
279
|
+
this.busyChangedCallback?.(true);
|
|
280
|
+
}
|
|
311
281
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
} else {
|
|
319
|
-
auth = authData;
|
|
320
|
-
}
|
|
282
|
+
// if we're currently trying a request, wait for it to finish
|
|
283
|
+
// as otherwise we can get multiple 200 responses which can mean
|
|
284
|
+
// things like multiple logins for register requests.
|
|
285
|
+
// (but discard any exceptions as we only care when its done,
|
|
286
|
+
// not whether it worked or not)
|
|
287
|
+
while (this.submitPromise) {
|
|
321
288
|
try {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
289
|
+
await this.submitPromise;
|
|
290
|
+
} catch {}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// use the sessionid from the last request, if one is present.
|
|
294
|
+
let auth;
|
|
295
|
+
if (this.data?.session) {
|
|
296
|
+
auth = Object.assign({
|
|
297
|
+
session: this.data.session
|
|
298
|
+
}, authData);
|
|
299
|
+
} else {
|
|
300
|
+
auth = authData;
|
|
301
|
+
}
|
|
302
|
+
try {
|
|
303
|
+
// NB. the 'background' flag is deprecated by the busyChanged
|
|
304
|
+
// callback and is here for backwards compat
|
|
305
|
+
this.submitPromise = this.doRequest(auth, background);
|
|
306
|
+
await this.submitPromise;
|
|
307
|
+
} finally {
|
|
308
|
+
this.submitPromise = null;
|
|
309
|
+
if (!background) {
|
|
310
|
+
this.busyChangedCallback?.(false);
|
|
332
311
|
}
|
|
333
|
-
}
|
|
312
|
+
}
|
|
334
313
|
}
|
|
335
314
|
|
|
336
315
|
/**
|
|
@@ -365,79 +344,72 @@ export class InteractiveAuth {
|
|
|
365
344
|
* This can be set to true for requests that just poll to see if auth has
|
|
366
345
|
* been completed elsewhere.
|
|
367
346
|
*/
|
|
368
|
-
doRequest(auth) {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
//
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
(_this5$attemptAuthDef = _this5.attemptAuthDeferred) === null || _this5$attemptAuthDef === void 0 || _this5$attemptAuthDef.reject(error);
|
|
389
|
-
} else {
|
|
390
|
-
// We ignore all failures here (even non-UI auth related ones)
|
|
391
|
-
// since we don't want to suddenly fail if the internet connection
|
|
392
|
-
// had a blip whilst we were polling
|
|
393
|
-
logger.log("Background poll request failed doing UI auth: ignoring", error);
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
if (matrixError && !matrixError.data) {
|
|
397
|
-
matrixError.data = {};
|
|
398
|
-
}
|
|
399
|
-
// if the error didn't come with flows, completed flows or session ID,
|
|
400
|
-
// copy over the ones we have. Synapse sometimes sends responses without
|
|
401
|
-
// any UI auth data (eg. when polling for email validation, if the email
|
|
402
|
-
// has not yet been validated). This appears to be a Synapse bug, which
|
|
403
|
-
// we workaround here.
|
|
404
|
-
if (matrixError && !matrixError.data.flows && !matrixError.data.completed && !matrixError.data.session) {
|
|
405
|
-
matrixError.data.flows = _this5.data.flows;
|
|
406
|
-
matrixError.data.completed = _this5.data.completed;
|
|
407
|
-
matrixError.data.session = _this5.data.session;
|
|
408
|
-
}
|
|
409
|
-
if (matrixError) {
|
|
410
|
-
_this5.data = matrixError.data;
|
|
347
|
+
async doRequest(auth, background = false) {
|
|
348
|
+
try {
|
|
349
|
+
const result = await this.requestCallback(auth, background);
|
|
350
|
+
this.attemptAuthDeferred.resolve(result);
|
|
351
|
+
this.attemptAuthDeferred = null;
|
|
352
|
+
} catch (error) {
|
|
353
|
+
const matrixError = error instanceof MatrixError ? error : null;
|
|
354
|
+
|
|
355
|
+
// sometimes UI auth errors don't come with flows
|
|
356
|
+
const errorFlows = matrixError?.data?.flows ?? null;
|
|
357
|
+
const haveFlows = this.data?.flows || Boolean(errorFlows);
|
|
358
|
+
if (!matrixError || matrixError.httpStatus !== 401 || !matrixError.data || !haveFlows) {
|
|
359
|
+
// doesn't look like an interactive-auth failure.
|
|
360
|
+
if (!background) {
|
|
361
|
+
this.attemptAuthDeferred?.reject(error);
|
|
362
|
+
} else {
|
|
363
|
+
// We ignore all failures here (even non-UI auth related ones)
|
|
364
|
+
// since we don't want to suddenly fail if the internet connection
|
|
365
|
+
// had a blip whilst we were polling
|
|
366
|
+
logger.log("Background poll request failed doing UI auth: ignoring", error);
|
|
411
367
|
}
|
|
368
|
+
}
|
|
369
|
+
if (matrixError && !matrixError.data) {
|
|
370
|
+
matrixError.data = {};
|
|
371
|
+
}
|
|
372
|
+
// if the error didn't come with flows, completed flows or session ID,
|
|
373
|
+
// copy over the ones we have. Synapse sometimes sends responses without
|
|
374
|
+
// any UI auth data (eg. when polling for email validation, if the email
|
|
375
|
+
// has not yet been validated). This appears to be a Synapse bug, which
|
|
376
|
+
// we workaround here.
|
|
377
|
+
if (matrixError && !matrixError.data.flows && !matrixError.data.completed && !matrixError.data.session) {
|
|
378
|
+
matrixError.data.flows = this.data.flows;
|
|
379
|
+
matrixError.data.completed = this.data.completed;
|
|
380
|
+
matrixError.data.session = this.data.session;
|
|
381
|
+
}
|
|
382
|
+
if (matrixError) {
|
|
383
|
+
this.data = matrixError.data;
|
|
384
|
+
}
|
|
385
|
+
try {
|
|
386
|
+
this.startNextAuthStage();
|
|
387
|
+
} catch (e) {
|
|
388
|
+
this.attemptAuthDeferred.reject(e);
|
|
389
|
+
this.attemptAuthDeferred = null;
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
if (!this.emailSid && this.chosenFlow?.stages.includes(AuthType.Email)) {
|
|
412
393
|
try {
|
|
413
|
-
|
|
394
|
+
await this.requestEmailToken();
|
|
395
|
+
// NB. promise is not resolved here - at some point, doRequest
|
|
396
|
+
// will be called again and if the user has jumped through all
|
|
397
|
+
// the hoops correctly, auth will be complete and the request
|
|
398
|
+
// will succeed.
|
|
399
|
+
// Also, we should expose the fact that this request has compledted
|
|
400
|
+
// so clients can know that the email has actually been sent.
|
|
414
401
|
} catch (e) {
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
// will be called again and if the user has jumped through all
|
|
424
|
-
// the hoops correctly, auth will be complete and the request
|
|
425
|
-
// will succeed.
|
|
426
|
-
// Also, we should expose the fact that this request has compledted
|
|
427
|
-
// so clients can know that the email has actually been sent.
|
|
428
|
-
} catch (e) {
|
|
429
|
-
// we failed to request an email token, so fail the request.
|
|
430
|
-
// This could be due to the email already beeing registered
|
|
431
|
-
// (or not being registered, depending on what we're trying
|
|
432
|
-
// to do) or it could be a network failure. Either way, pass
|
|
433
|
-
// the failure up as the user can't complete auth if we can't
|
|
434
|
-
// send the email, for whatever reason.
|
|
435
|
-
_this5.attemptAuthDeferred.reject(e);
|
|
436
|
-
_this5.attemptAuthDeferred = null;
|
|
437
|
-
}
|
|
402
|
+
// we failed to request an email token, so fail the request.
|
|
403
|
+
// This could be due to the email already beeing registered
|
|
404
|
+
// (or not being registered, depending on what we're trying
|
|
405
|
+
// to do) or it could be a network failure. Either way, pass
|
|
406
|
+
// the failure up as the user can't complete auth if we can't
|
|
407
|
+
// send the email, for whatever reason.
|
|
408
|
+
this.attemptAuthDeferred.reject(e);
|
|
409
|
+
this.attemptAuthDeferred = null;
|
|
438
410
|
}
|
|
439
411
|
}
|
|
440
|
-
}
|
|
412
|
+
}
|
|
441
413
|
}
|
|
442
414
|
|
|
443
415
|
/**
|
|
@@ -447,8 +419,7 @@ export class InteractiveAuth {
|
|
|
447
419
|
* @throws {@link NoAuthFlowFoundError} If no suitable authentication flow can be found
|
|
448
420
|
*/
|
|
449
421
|
startNextAuthStage() {
|
|
450
|
-
|
|
451
|
-
var nextStage = this.chooseStage();
|
|
422
|
+
const nextStage = this.chooseStage();
|
|
452
423
|
if (!nextStage) {
|
|
453
424
|
throw new Error("No incomplete flows from the server");
|
|
454
425
|
}
|
|
@@ -459,11 +430,10 @@ export class InteractiveAuth {
|
|
|
459
430
|
});
|
|
460
431
|
return;
|
|
461
432
|
}
|
|
462
|
-
if (
|
|
463
|
-
var _this$data5, _this$data6;
|
|
433
|
+
if (this.data?.errcode || this.data?.error) {
|
|
464
434
|
this.stateUpdatedCallback(nextStage, {
|
|
465
|
-
errcode:
|
|
466
|
-
error:
|
|
435
|
+
errcode: this.data?.errcode || "",
|
|
436
|
+
error: this.data?.error || ""
|
|
467
437
|
});
|
|
468
438
|
return;
|
|
469
439
|
}
|
|
@@ -484,7 +454,7 @@ export class InteractiveAuth {
|
|
|
484
454
|
this.chosenFlow = this.chooseFlow();
|
|
485
455
|
}
|
|
486
456
|
logger.log("Active flow => %s", JSON.stringify(this.chosenFlow));
|
|
487
|
-
|
|
457
|
+
const nextStage = this.firstUncompletedStage(this.chosenFlow);
|
|
488
458
|
logger.log("Next stage: %s", nextStage);
|
|
489
459
|
return nextStage;
|
|
490
460
|
}
|
|
@@ -492,7 +462,7 @@ export class InteractiveAuth {
|
|
|
492
462
|
// Returns a low number for flows we consider best. Counts increase for longer flows and even more so
|
|
493
463
|
// for flows which contain stages not listed in `supportedStages`.
|
|
494
464
|
scoreFlow(flow) {
|
|
495
|
-
|
|
465
|
+
let score = flow.stages.length;
|
|
496
466
|
if (this.supportedStages !== undefined) {
|
|
497
467
|
// Add 10 points to the score for each unsupported stage in the flow.
|
|
498
468
|
score += flow.stages.filter(stage => !this.supportedStages.has(stage)).length * 10;
|
|
@@ -516,20 +486,19 @@ export class InteractiveAuth {
|
|
|
516
486
|
* @throws {@link NoAuthFlowFoundError} If no suitable authentication flow can be found
|
|
517
487
|
*/
|
|
518
488
|
chooseFlow() {
|
|
519
|
-
|
|
520
|
-
var flows = ((_this$data7 = this.data) === null || _this$data7 === void 0 ? void 0 : _this$data7.flows) || [];
|
|
489
|
+
const flows = this.data?.flows || [];
|
|
521
490
|
|
|
522
491
|
// we've been given an email or we've already done an email part
|
|
523
|
-
|
|
524
|
-
|
|
492
|
+
const haveEmail = Boolean(this.inputs.emailAddress) || Boolean(this.emailSid);
|
|
493
|
+
const haveMsisdn = Boolean(this.inputs.phoneCountry) && Boolean(this.inputs.phoneNumber);
|
|
525
494
|
|
|
526
495
|
// Flows are not represented in a significant order, so we can choose any we support best
|
|
527
496
|
// Sort flows based on how many unsupported stages they contain ascending
|
|
528
497
|
flows.sort((a, b) => this.scoreFlow(a) - this.scoreFlow(b));
|
|
529
|
-
for (
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
for (
|
|
498
|
+
for (const flow of flows) {
|
|
499
|
+
let flowHasEmail = false;
|
|
500
|
+
let flowHasMsisdn = false;
|
|
501
|
+
for (const stage of flow.stages) {
|
|
533
502
|
if (stage === EMAIL_STAGE_TYPE) {
|
|
534
503
|
flowHasEmail = true;
|
|
535
504
|
} else if (stage == MSISDN_STAGE_TYPE) {
|
|
@@ -540,7 +509,7 @@ export class InteractiveAuth {
|
|
|
540
509
|
return flow;
|
|
541
510
|
}
|
|
542
511
|
}
|
|
543
|
-
|
|
512
|
+
const requiredStages = [];
|
|
544
513
|
if (haveEmail) requiredStages.push(EMAIL_STAGE_TYPE);
|
|
545
514
|
if (haveMsisdn) requiredStages.push(MSISDN_STAGE_TYPE);
|
|
546
515
|
// Throw an error with a fairly generic description, but with more
|
|
@@ -555,8 +524,7 @@ export class InteractiveAuth {
|
|
|
555
524
|
* @returns login type
|
|
556
525
|
*/
|
|
557
526
|
firstUncompletedStage(flow) {
|
|
558
|
-
|
|
559
|
-
var completed = ((_this$data8 = this.data) === null || _this$data8 === void 0 ? void 0 : _this$data8.completed) || [];
|
|
527
|
+
const completed = this.data?.completed || [];
|
|
560
528
|
return flow.stages.find(stageType => !completed.includes(stageType));
|
|
561
529
|
}
|
|
562
530
|
}
|