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/autodiscovery.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 2018 New Vector Ltd
|
|
@@ -24,7 +23,7 @@ import { SUPPORTED_MATRIX_VERSIONS } from "./version-support.js";
|
|
|
24
23
|
// Dev note: Auto discovery is part of the spec.
|
|
25
24
|
// See: https://matrix.org/docs/spec/client_server/r0.4.0.html#server-discovery
|
|
26
25
|
|
|
27
|
-
export
|
|
26
|
+
export let AutoDiscoveryAction = /*#__PURE__*/function (AutoDiscoveryAction) {
|
|
28
27
|
AutoDiscoveryAction["SUCCESS"] = "SUCCESS";
|
|
29
28
|
AutoDiscoveryAction["IGNORE"] = "IGNORE";
|
|
30
29
|
AutoDiscoveryAction["PROMPT"] = "PROMPT";
|
|
@@ -32,7 +31,7 @@ export var AutoDiscoveryAction = /*#__PURE__*/function (AutoDiscoveryAction) {
|
|
|
32
31
|
AutoDiscoveryAction["FAIL_ERROR"] = "FAIL_ERROR";
|
|
33
32
|
return AutoDiscoveryAction;
|
|
34
33
|
}({});
|
|
35
|
-
export
|
|
34
|
+
export let AutoDiscoveryError = /*#__PURE__*/function (AutoDiscoveryError) {
|
|
36
35
|
AutoDiscoveryError["Invalid"] = "Invalid homeserver discovery response";
|
|
37
36
|
AutoDiscoveryError["GenericFailure"] = "Failed to get autodiscovery configuration from server";
|
|
38
37
|
AutoDiscoveryError["InvalidHsBaseUrl"] = "Invalid base_url for m.homeserver";
|
|
@@ -63,158 +62,154 @@ export class AutoDiscovery {
|
|
|
63
62
|
* configuration, which may include error states. Rejects on unexpected
|
|
64
63
|
* failure, not when verification fails.
|
|
65
64
|
*/
|
|
66
|
-
static fromDiscoveryConfig(wellknown) {
|
|
67
|
-
|
|
68
|
-
return _asyncToGenerator(function* () {
|
|
69
|
-
var _hsVersions$raw;
|
|
70
|
-
// Step 1 is to get the config, which is provided to us here.
|
|
65
|
+
static async fromDiscoveryConfig(wellknown) {
|
|
66
|
+
// Step 1 is to get the config, which is provided to us here.
|
|
71
67
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
if (!(wellknown !== null && wellknown !== void 0 && wellknown["m.homeserver"])) {
|
|
90
|
-
logger.error("No m.homeserver key in config");
|
|
91
|
-
clientConfig["m.homeserver"].state = AutoDiscovery.FAIL_PROMPT;
|
|
92
|
-
clientConfig["m.homeserver"].error = AutoDiscovery.ERROR_INVALID;
|
|
93
|
-
return Promise.resolve(clientConfig);
|
|
94
|
-
}
|
|
95
|
-
if (!wellknown["m.homeserver"]["base_url"]) {
|
|
96
|
-
logger.error("No m.homeserver base_url in config");
|
|
97
|
-
clientConfig["m.homeserver"].state = AutoDiscovery.FAIL_PROMPT;
|
|
98
|
-
clientConfig["m.homeserver"].error = AutoDiscovery.ERROR_INVALID_HS_BASE_URL;
|
|
99
|
-
return Promise.resolve(clientConfig);
|
|
68
|
+
// We default to an error state to make the first few checks easier to
|
|
69
|
+
// write. We'll update the properties of this object over the duration
|
|
70
|
+
// of this function.
|
|
71
|
+
const clientConfig = {
|
|
72
|
+
"m.homeserver": {
|
|
73
|
+
state: AutoDiscovery.FAIL_ERROR,
|
|
74
|
+
error: AutoDiscovery.ERROR_INVALID,
|
|
75
|
+
base_url: null
|
|
76
|
+
},
|
|
77
|
+
"m.identity_server": {
|
|
78
|
+
// Technically, we don't have a problem with the identity server
|
|
79
|
+
// config at this point.
|
|
80
|
+
state: AutoDiscovery.PROMPT,
|
|
81
|
+
error: null,
|
|
82
|
+
base_url: null
|
|
100
83
|
}
|
|
84
|
+
};
|
|
85
|
+
if (!wellknown?.["m.homeserver"]) {
|
|
86
|
+
logger.error("No m.homeserver key in config");
|
|
87
|
+
clientConfig["m.homeserver"].state = AutoDiscovery.FAIL_PROMPT;
|
|
88
|
+
clientConfig["m.homeserver"].error = AutoDiscovery.ERROR_INVALID;
|
|
89
|
+
return Promise.resolve(clientConfig);
|
|
90
|
+
}
|
|
91
|
+
if (!wellknown["m.homeserver"]["base_url"]) {
|
|
92
|
+
logger.error("No m.homeserver base_url in config");
|
|
93
|
+
clientConfig["m.homeserver"].state = AutoDiscovery.FAIL_PROMPT;
|
|
94
|
+
clientConfig["m.homeserver"].error = AutoDiscovery.ERROR_INVALID_HS_BASE_URL;
|
|
95
|
+
return Promise.resolve(clientConfig);
|
|
96
|
+
}
|
|
101
97
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
98
|
+
// Step 2: Make sure the homeserver URL is valid *looking*. We'll make
|
|
99
|
+
// sure it points to a homeserver in Step 3.
|
|
100
|
+
const hsUrl = this.sanitizeWellKnownUrl(wellknown["m.homeserver"]["base_url"]);
|
|
101
|
+
if (!hsUrl) {
|
|
102
|
+
logger.error("Invalid base_url for m.homeserver");
|
|
103
|
+
clientConfig["m.homeserver"].error = AutoDiscovery.ERROR_INVALID_HS_BASE_URL;
|
|
104
|
+
return Promise.resolve(clientConfig);
|
|
105
|
+
}
|
|
110
106
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
107
|
+
// Step 3: Make sure the homeserver URL points to a homeserver.
|
|
108
|
+
const hsVersions = await this.fetchWellKnownObject(`${hsUrl}/_matrix/client/versions`);
|
|
109
|
+
if (!hsVersions || !Array.isArray(hsVersions.raw?.["versions"])) {
|
|
110
|
+
logger.error("Invalid /versions response");
|
|
111
|
+
clientConfig["m.homeserver"].error = AutoDiscovery.ERROR_INVALID_HOMESERVER;
|
|
116
112
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
113
|
+
// Supply the base_url to the caller because they may be ignoring liveliness
|
|
114
|
+
// errors, like this one.
|
|
115
|
+
clientConfig["m.homeserver"].base_url = hsUrl;
|
|
116
|
+
return Promise.resolve(clientConfig);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Step 3.1: Non-spec check to ensure the server will actually work for us. We need to check if
|
|
120
|
+
// any of the versions in `SUPPORTED_MATRIX_VERSIONS` are listed in the /versions response.
|
|
121
|
+
const hsVersionSet = new Set(hsVersions.raw["versions"]);
|
|
122
|
+
let supportedVersionFound = false;
|
|
123
|
+
for (const version of SUPPORTED_MATRIX_VERSIONS) {
|
|
124
|
+
if (hsVersionSet.has(version)) {
|
|
125
|
+
supportedVersionFound = true;
|
|
126
|
+
break;
|
|
121
127
|
}
|
|
128
|
+
}
|
|
129
|
+
if (!supportedVersionFound) {
|
|
130
|
+
logger.error("Homeserver does not meet version requirements");
|
|
131
|
+
clientConfig["m.homeserver"].error = AutoDiscovery.ERROR_UNSUPPORTED_HOMESERVER_SPEC_VERSION;
|
|
132
|
+
|
|
133
|
+
// Supply the base_url to the caller because they may be ignoring liveliness
|
|
134
|
+
// errors, like this one.
|
|
135
|
+
clientConfig["m.homeserver"].base_url = hsUrl;
|
|
136
|
+
return Promise.resolve(clientConfig);
|
|
137
|
+
}
|
|
122
138
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
139
|
+
// Step 4: Now that the homeserver looks valid, update our client config.
|
|
140
|
+
clientConfig["m.homeserver"] = {
|
|
141
|
+
state: AutoDiscovery.SUCCESS,
|
|
142
|
+
error: null,
|
|
143
|
+
base_url: hsUrl
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
// Step 5: Try to pull out the identity server configuration
|
|
147
|
+
let isUrl = "";
|
|
148
|
+
if (wellknown["m.identity_server"]) {
|
|
149
|
+
// We prepare a failing identity server response to save lines later
|
|
150
|
+
// in this branch.
|
|
151
|
+
const failingClientConfig = {
|
|
152
|
+
"m.homeserver": clientConfig["m.homeserver"],
|
|
153
|
+
"m.identity_server": {
|
|
154
|
+
state: AutoDiscovery.FAIL_PROMPT,
|
|
155
|
+
error: AutoDiscovery.ERROR_INVALID_IS,
|
|
156
|
+
base_url: null
|
|
131
157
|
}
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
// Step 5a: Make sure the URL is valid *looking*. We'll make sure it
|
|
161
|
+
// points to an identity server in Step 5b.
|
|
162
|
+
isUrl = this.sanitizeWellKnownUrl(wellknown["m.identity_server"]["base_url"]);
|
|
163
|
+
if (!isUrl) {
|
|
164
|
+
logger.error("Invalid base_url for m.identity_server");
|
|
165
|
+
failingClientConfig["m.identity_server"].error = AutoDiscovery.ERROR_INVALID_IS_BASE_URL;
|
|
166
|
+
return Promise.resolve(failingClientConfig);
|
|
132
167
|
}
|
|
133
|
-
if (!supportedVersionFound) {
|
|
134
|
-
logger.error("Homeserver does not meet version requirements");
|
|
135
|
-
clientConfig["m.homeserver"].error = AutoDiscovery.ERROR_UNSUPPORTED_HOMESERVER_SPEC_VERSION;
|
|
136
168
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
169
|
+
// Step 5b: Verify there is an identity server listening on the provided
|
|
170
|
+
// URL.
|
|
171
|
+
const isResponse = await this.fetchWellKnownObject(`${isUrl}/_matrix/identity/v2`);
|
|
172
|
+
if (!isResponse?.raw || isResponse.action !== AutoDiscoveryAction.SUCCESS) {
|
|
173
|
+
logger.error("Invalid /v2 response");
|
|
174
|
+
failingClientConfig["m.identity_server"].error = AutoDiscovery.ERROR_INVALID_IDENTITY_SERVER;
|
|
175
|
+
|
|
176
|
+
// Supply the base_url to the caller because they may be ignoring
|
|
177
|
+
// liveliness errors, like this one.
|
|
178
|
+
failingClientConfig["m.identity_server"].base_url = isUrl;
|
|
179
|
+
return Promise.resolve(failingClientConfig);
|
|
141
180
|
}
|
|
181
|
+
}
|
|
142
182
|
|
|
143
|
-
|
|
144
|
-
|
|
183
|
+
// Step 6: Now that the identity server is valid, or never existed,
|
|
184
|
+
// populate the IS section.
|
|
185
|
+
if (isUrl && isUrl.toString().length > 0) {
|
|
186
|
+
clientConfig["m.identity_server"] = {
|
|
145
187
|
state: AutoDiscovery.SUCCESS,
|
|
146
188
|
error: null,
|
|
147
|
-
base_url:
|
|
189
|
+
base_url: isUrl
|
|
148
190
|
};
|
|
191
|
+
}
|
|
149
192
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
//
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
// Step 5a: Make sure the URL is valid *looking*. We'll make sure it
|
|
165
|
-
// points to an identity server in Step 5b.
|
|
166
|
-
isUrl = _this.sanitizeWellKnownUrl(wellknown["m.identity_server"]["base_url"]);
|
|
167
|
-
if (!isUrl) {
|
|
168
|
-
logger.error("Invalid base_url for m.identity_server");
|
|
169
|
-
failingClientConfig["m.identity_server"].error = AutoDiscovery.ERROR_INVALID_IS_BASE_URL;
|
|
170
|
-
return Promise.resolve(failingClientConfig);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
// Step 5b: Verify there is an identity server listening on the provided
|
|
174
|
-
// URL.
|
|
175
|
-
var isResponse = yield _this.fetchWellKnownObject("".concat(isUrl, "/_matrix/identity/v2"));
|
|
176
|
-
if (!(isResponse !== null && isResponse !== void 0 && isResponse.raw) || isResponse.action !== AutoDiscoveryAction.SUCCESS) {
|
|
177
|
-
logger.error("Invalid /v2 response");
|
|
178
|
-
failingClientConfig["m.identity_server"].error = AutoDiscovery.ERROR_INVALID_IDENTITY_SERVER;
|
|
179
|
-
|
|
180
|
-
// Supply the base_url to the caller because they may be ignoring
|
|
181
|
-
// liveliness errors, like this one.
|
|
182
|
-
failingClientConfig["m.identity_server"].base_url = isUrl;
|
|
183
|
-
return Promise.resolve(failingClientConfig);
|
|
193
|
+
// Step 7: Copy any other keys directly into the clientConfig. This is for
|
|
194
|
+
// things like custom configuration of services.
|
|
195
|
+
Object.keys(wellknown).forEach(k => {
|
|
196
|
+
if (k === "m.homeserver" || k === "m.identity_server") {
|
|
197
|
+
// Only copy selected parts of the config to avoid overwriting
|
|
198
|
+
// properties computed by the validation logic above.
|
|
199
|
+
const notProps = ["error", "state", "base_url"];
|
|
200
|
+
for (const prop of Object.keys(wellknown[k])) {
|
|
201
|
+
if (notProps.includes(prop)) continue;
|
|
202
|
+
// @ts-ignore - ts gets unhappy as we're mixing types here
|
|
203
|
+
clientConfig[k][prop] = wellknown[k][prop];
|
|
184
204
|
}
|
|
205
|
+
} else {
|
|
206
|
+
// Just copy the whole thing over otherwise
|
|
207
|
+
clientConfig[k] = wellknown[k];
|
|
185
208
|
}
|
|
209
|
+
});
|
|
186
210
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
if (isUrl && isUrl.toString().length > 0) {
|
|
190
|
-
clientConfig["m.identity_server"] = {
|
|
191
|
-
state: AutoDiscovery.SUCCESS,
|
|
192
|
-
error: null,
|
|
193
|
-
base_url: isUrl
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// Step 7: Copy any other keys directly into the clientConfig. This is for
|
|
198
|
-
// things like custom configuration of services.
|
|
199
|
-
Object.keys(wellknown).forEach(k => {
|
|
200
|
-
if (k === "m.homeserver" || k === "m.identity_server") {
|
|
201
|
-
// Only copy selected parts of the config to avoid overwriting
|
|
202
|
-
// properties computed by the validation logic above.
|
|
203
|
-
var notProps = ["error", "state", "base_url"];
|
|
204
|
-
for (var prop of Object.keys(wellknown[k])) {
|
|
205
|
-
if (notProps.includes(prop)) continue;
|
|
206
|
-
// @ts-ignore - ts gets unhappy as we're mixing types here
|
|
207
|
-
clientConfig[k][prop] = wellknown[k][prop];
|
|
208
|
-
}
|
|
209
|
-
} else {
|
|
210
|
-
// Just copy the whole thing over otherwise
|
|
211
|
-
clientConfig[k] = wellknown[k];
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
// Step 8: Give the config to the caller (finally)
|
|
216
|
-
return Promise.resolve(clientConfig);
|
|
217
|
-
})();
|
|
211
|
+
// Step 8: Give the config to the caller (finally)
|
|
212
|
+
return Promise.resolve(clientConfig);
|
|
218
213
|
}
|
|
219
214
|
|
|
220
215
|
/**
|
|
@@ -229,66 +224,63 @@ export class AutoDiscovery {
|
|
|
229
224
|
* configuration, which may include error states. Rejects on unexpected
|
|
230
225
|
* failure, not when discovery fails.
|
|
231
226
|
*/
|
|
232
|
-
static findClientConfig(domain) {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
throw new Error("'domain' must be a string of non-zero length");
|
|
237
|
-
}
|
|
227
|
+
static async findClientConfig(domain) {
|
|
228
|
+
if (!domain || typeof domain !== "string" || domain.length === 0) {
|
|
229
|
+
throw new Error("'domain' must be a string of non-zero length");
|
|
230
|
+
}
|
|
238
231
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
232
|
+
// We use a .well-known lookup for all cases. According to the spec, we
|
|
233
|
+
// can do other discovery mechanisms if we want such as custom lookups
|
|
234
|
+
// however we won't bother with that here (mostly because the spec only
|
|
235
|
+
// supports .well-known right now).
|
|
236
|
+
//
|
|
237
|
+
// By using .well-known, we need to ensure we at least pull out a URL
|
|
238
|
+
// for the homeserver. We don't really need an identity server configuration
|
|
239
|
+
// but will return one anyways (with state PROMPT) to make development
|
|
240
|
+
// easier for clients. If we can't get a homeserver URL, all bets are
|
|
241
|
+
// off on the rest of the config and we'll assume it is invalid too.
|
|
249
242
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
243
|
+
// We default to an error state to make the first few checks easier to
|
|
244
|
+
// write. We'll update the properties of this object over the duration
|
|
245
|
+
// of this function.
|
|
246
|
+
const clientConfig = {
|
|
247
|
+
"m.homeserver": {
|
|
248
|
+
state: AutoDiscovery.FAIL_ERROR,
|
|
249
|
+
error: AutoDiscovery.ERROR_INVALID,
|
|
250
|
+
base_url: null
|
|
251
|
+
},
|
|
252
|
+
"m.identity_server": {
|
|
253
|
+
// Technically, we don't have a problem with the identity server
|
|
254
|
+
// config at this point.
|
|
255
|
+
state: AutoDiscovery.PROMPT,
|
|
256
|
+
error: null,
|
|
257
|
+
base_url: null
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
// Step 1: Actually request the .well-known JSON file and make sure it
|
|
262
|
+
// at least has a homeserver definition.
|
|
263
|
+
const domainWithProtocol = domain.includes("://") ? domain : `https://${domain}`;
|
|
264
|
+
const wellknown = await this.fetchWellKnownObject(`${domainWithProtocol}/.well-known/matrix/client`);
|
|
265
|
+
if (!wellknown || wellknown.action !== AutoDiscoveryAction.SUCCESS) {
|
|
266
|
+
logger.error("No response or error when parsing .well-known");
|
|
267
|
+
if (wellknown.reason) logger.error(wellknown.reason);
|
|
268
|
+
if (wellknown.action === AutoDiscoveryAction.IGNORE) {
|
|
269
|
+
clientConfig["m.homeserver"] = {
|
|
262
270
|
state: AutoDiscovery.PROMPT,
|
|
263
271
|
error: null,
|
|
264
272
|
base_url: null
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
var domainWithProtocol = domain.includes("://") ? domain : "https://".concat(domain);
|
|
271
|
-
var wellknown = yield _this2.fetchWellKnownObject("".concat(domainWithProtocol, "/.well-known/matrix/client"));
|
|
272
|
-
if (!wellknown || wellknown.action !== AutoDiscoveryAction.SUCCESS) {
|
|
273
|
-
logger.error("No response or error when parsing .well-known");
|
|
274
|
-
if (wellknown.reason) logger.error(wellknown.reason);
|
|
275
|
-
if (wellknown.action === AutoDiscoveryAction.IGNORE) {
|
|
276
|
-
clientConfig["m.homeserver"] = {
|
|
277
|
-
state: AutoDiscovery.PROMPT,
|
|
278
|
-
error: null,
|
|
279
|
-
base_url: null
|
|
280
|
-
};
|
|
281
|
-
} else {
|
|
282
|
-
// this can only ever be FAIL_PROMPT at this point.
|
|
283
|
-
clientConfig["m.homeserver"].state = AutoDiscovery.FAIL_PROMPT;
|
|
284
|
-
clientConfig["m.homeserver"].error = AutoDiscovery.ERROR_INVALID;
|
|
285
|
-
}
|
|
286
|
-
return Promise.resolve(clientConfig);
|
|
273
|
+
};
|
|
274
|
+
} else {
|
|
275
|
+
// this can only ever be FAIL_PROMPT at this point.
|
|
276
|
+
clientConfig["m.homeserver"].state = AutoDiscovery.FAIL_PROMPT;
|
|
277
|
+
clientConfig["m.homeserver"].error = AutoDiscovery.ERROR_INVALID;
|
|
287
278
|
}
|
|
279
|
+
return Promise.resolve(clientConfig);
|
|
280
|
+
}
|
|
288
281
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
})();
|
|
282
|
+
// Step 2: Validate and parse the config
|
|
283
|
+
return AutoDiscovery.fromDiscoveryConfig(wellknown.raw);
|
|
292
284
|
}
|
|
293
285
|
|
|
294
286
|
/**
|
|
@@ -299,17 +291,13 @@ export class AutoDiscovery {
|
|
|
299
291
|
* @returns Promise which resolves to the domain's client config. Can
|
|
300
292
|
* be an empty object.
|
|
301
293
|
*/
|
|
302
|
-
static getRawClientConfig(domain) {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
var response = yield _this3.fetchWellKnownObject("https://".concat(domain, "/.well-known/matrix/client"));
|
|
310
|
-
if (!response) return {};
|
|
311
|
-
return (_response$raw = response.raw) !== null && _response$raw !== void 0 ? _response$raw : {};
|
|
312
|
-
})();
|
|
294
|
+
static async getRawClientConfig(domain) {
|
|
295
|
+
if (!domain || typeof domain !== "string" || domain.length === 0) {
|
|
296
|
+
throw new Error("'domain' must be a string of non-zero length");
|
|
297
|
+
}
|
|
298
|
+
const response = await this.fetchWellKnownObject(`https://${domain}/.well-known/matrix/client`);
|
|
299
|
+
if (!response) return {};
|
|
300
|
+
return response.raw ?? {};
|
|
313
301
|
}
|
|
314
302
|
|
|
315
303
|
/**
|
|
@@ -323,18 +311,17 @@ export class AutoDiscovery {
|
|
|
323
311
|
static sanitizeWellKnownUrl(url) {
|
|
324
312
|
if (!url) return false;
|
|
325
313
|
try {
|
|
326
|
-
|
|
327
|
-
var parsed;
|
|
314
|
+
let parsed;
|
|
328
315
|
try {
|
|
329
316
|
parsed = new URL(url);
|
|
330
317
|
} catch (e) {
|
|
331
318
|
logger.error("Could not parse url", e);
|
|
332
319
|
}
|
|
333
|
-
if (!
|
|
320
|
+
if (!parsed?.hostname) return false;
|
|
334
321
|
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return false;
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
322
|
+
const port = parsed.port ? `:${parsed.port}` : "";
|
|
323
|
+
const path = parsed.pathname ? parsed.pathname : "";
|
|
324
|
+
let saferUrl = `${parsed.protocol}//${parsed.hostname}${port}${path}`;
|
|
338
325
|
if (saferUrl.endsWith("/")) {
|
|
339
326
|
saferUrl = saferUrl.substring(0, saferUrl.length - 1);
|
|
340
327
|
}
|
|
@@ -370,56 +357,54 @@ export class AutoDiscovery {
|
|
|
370
357
|
* @returns Promise which resolves to the returned state.
|
|
371
358
|
* @internal
|
|
372
359
|
*/
|
|
373
|
-
static fetchWellKnownObject(url) {
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
if (response.status === 404) {
|
|
382
|
-
return {
|
|
383
|
-
raw: {},
|
|
384
|
-
action: AutoDiscoveryAction.IGNORE,
|
|
385
|
-
reason: AutoDiscovery.ERROR_MISSING_WELLKNOWN
|
|
386
|
-
};
|
|
387
|
-
}
|
|
388
|
-
if (response.status !== 200) {
|
|
389
|
-
return {
|
|
390
|
-
raw: {},
|
|
391
|
-
action: AutoDiscoveryAction.FAIL_PROMPT,
|
|
392
|
-
reason: "General failure"
|
|
393
|
-
};
|
|
394
|
-
}
|
|
395
|
-
} catch (err) {
|
|
396
|
-
var error = err;
|
|
397
|
-
var reason = "";
|
|
398
|
-
if (typeof error === "object") {
|
|
399
|
-
reason = error === null || error === void 0 ? void 0 : error.message;
|
|
400
|
-
}
|
|
360
|
+
static async fetchWellKnownObject(url) {
|
|
361
|
+
let response;
|
|
362
|
+
try {
|
|
363
|
+
response = await AutoDiscovery.fetch(url, {
|
|
364
|
+
method: Method.Get,
|
|
365
|
+
signal: timeoutSignal(5000)
|
|
366
|
+
});
|
|
367
|
+
if (response.status === 404) {
|
|
401
368
|
return {
|
|
402
|
-
error,
|
|
403
369
|
raw: {},
|
|
404
|
-
action: AutoDiscoveryAction.
|
|
405
|
-
reason:
|
|
370
|
+
action: AutoDiscoveryAction.IGNORE,
|
|
371
|
+
reason: AutoDiscovery.ERROR_MISSING_WELLKNOWN
|
|
406
372
|
};
|
|
407
373
|
}
|
|
408
|
-
|
|
409
|
-
return {
|
|
410
|
-
raw: yield response.json(),
|
|
411
|
-
action: AutoDiscoveryAction.SUCCESS
|
|
412
|
-
};
|
|
413
|
-
} catch (err) {
|
|
414
|
-
var _error = err;
|
|
374
|
+
if (response.status !== 200) {
|
|
415
375
|
return {
|
|
416
|
-
error: _error,
|
|
417
376
|
raw: {},
|
|
418
377
|
action: AutoDiscoveryAction.FAIL_PROMPT,
|
|
419
|
-
reason:
|
|
378
|
+
reason: "General failure"
|
|
420
379
|
};
|
|
421
380
|
}
|
|
422
|
-
}
|
|
381
|
+
} catch (err) {
|
|
382
|
+
const error = err;
|
|
383
|
+
let reason = "";
|
|
384
|
+
if (typeof error === "object") {
|
|
385
|
+
reason = error?.message;
|
|
386
|
+
}
|
|
387
|
+
return {
|
|
388
|
+
error,
|
|
389
|
+
raw: {},
|
|
390
|
+
action: AutoDiscoveryAction.FAIL_PROMPT,
|
|
391
|
+
reason: reason || "General failure"
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
try {
|
|
395
|
+
return {
|
|
396
|
+
raw: await response.json(),
|
|
397
|
+
action: AutoDiscoveryAction.SUCCESS
|
|
398
|
+
};
|
|
399
|
+
} catch (err) {
|
|
400
|
+
const error = err;
|
|
401
|
+
return {
|
|
402
|
+
error,
|
|
403
|
+
raw: {},
|
|
404
|
+
action: AutoDiscoveryAction.FAIL_PROMPT,
|
|
405
|
+
reason: error?.name === "SyntaxError" ? AutoDiscovery.ERROR_INVALID_JSON : AutoDiscovery.ERROR_INVALID
|
|
406
|
+
};
|
|
407
|
+
}
|
|
423
408
|
}
|
|
424
409
|
}
|
|
425
410
|
// Dev note: the constants defined here are related to but not
|