@textrp/briij-js-sdk 41.0.1 → 43.0.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 +14 -1
- package/LICENSE +177 -177
- package/README.md +85 -3
- package/lib/@types/AESEncryptedSecretStoragePayload.js.map +1 -1
- package/lib/@types/IIdentityServerProvider.js.map +1 -1
- package/lib/@types/PushRules.js +14 -14
- package/lib/@types/PushRules.js.map +1 -1
- package/lib/@types/another-json.d.js.map +1 -1
- package/lib/@types/auth.d.ts +72 -1
- package/lib/@types/auth.d.ts.map +1 -1
- package/lib/@types/auth.js +57 -54
- package/lib/@types/auth.js.map +1 -1
- package/lib/@types/beacon.js +100 -100
- package/lib/@types/beacon.js.map +1 -1
- package/lib/@types/common.js.map +1 -1
- package/lib/@types/crypto.js.map +1 -1
- package/lib/@types/event.d.ts +59 -0
- package/lib/@types/event.d.ts.map +1 -1
- package/lib/@types/event.js +105 -102
- package/lib/@types/event.js.map +1 -1
- package/lib/@types/events.js.map +1 -1
- package/lib/@types/extensible_events.js +53 -53
- package/lib/@types/extensible_events.js.map +1 -1
- package/lib/@types/local_notifications.js.map +1 -1
- package/lib/@types/location.js +41 -41
- package/lib/@types/location.js.map +1 -1
- package/lib/@types/matrix-sdk-crypto-wasm.d.js.map +1 -1
- package/lib/@types/media.js.map +1 -1
- package/lib/@types/membership.js +39 -39
- package/lib/@types/membership.js.map +1 -1
- package/lib/@types/partials.js +25 -25
- package/lib/@types/partials.js.map +1 -1
- package/lib/@types/polls.js +46 -46
- package/lib/@types/polls.js.map +1 -1
- package/lib/@types/read_receipts.js +14 -14
- package/lib/@types/read_receipts.js.map +1 -1
- package/lib/@types/registration.js.map +1 -1
- package/lib/@types/search.js +14 -14
- package/lib/@types/search.js.map +1 -1
- package/lib/@types/signed.js.map +1 -1
- package/lib/@types/spaces.js.map +1 -1
- package/lib/@types/state_events.js.map +1 -1
- package/lib/@types/synapse.js.map +1 -1
- package/lib/@types/sync.js +18 -18
- package/lib/@types/sync.js.map +1 -1
- package/lib/@types/threepids.js +14 -14
- package/lib/@types/threepids.js.map +1 -1
- package/lib/@types/topic.js +47 -47
- package/lib/@types/topic.js.map +1 -1
- package/lib/@types/uia.js.map +1 -1
- package/lib/NamespacedValue.js +20 -20
- package/lib/NamespacedValue.js.map +1 -1
- package/lib/ReEmitter.js +16 -16
- package/lib/ReEmitter.js.map +1 -1
- package/lib/base64.js +32 -32
- package/lib/base64.js.map +1 -1
- package/lib/briij.d.ts +4 -0
- package/lib/briij.d.ts.map +1 -1
- package/lib/briij.js +4 -0
- package/lib/briij.js.map +1 -1
- package/lib/client.d.ts +48 -1
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +262 -108
- package/lib/client.js.map +1 -1
- package/lib/common-crypto/key-passphrase.js +19 -19
- package/lib/common-crypto/key-passphrase.js.map +1 -1
- package/lib/content-helpers.js +57 -57
- package/lib/content-helpers.js.map +1 -1
- package/lib/content-repo.js +36 -36
- package/lib/content-repo.js.map +1 -1
- package/lib/crypto/store/base.js +69 -69
- package/lib/crypto/store/base.js.map +1 -1
- package/lib/crypto/store/indexeddb-crypto-store-backend.js +58 -58
- package/lib/crypto/store/indexeddb-crypto-store-backend.js.map +1 -1
- package/lib/crypto/store/indexeddb-crypto-store.js +193 -193
- package/lib/crypto/store/indexeddb-crypto-store.js.map +1 -1
- package/lib/crypto/store/localStorage-crypto-store.js +72 -72
- package/lib/crypto/store/localStorage-crypto-store.js.map +1 -1
- package/lib/crypto/store/memory-crypto-store.js +74 -74
- package/lib/crypto/store/memory-crypto-store.js.map +1 -1
- package/lib/crypto-api/CryptoEventHandlerMap.js.map +1 -1
- package/lib/crypto-api/key-passphrase.js +22 -22
- package/lib/crypto-api/key-passphrase.js.map +1 -1
- package/lib/crypto-api/keybackup.js.map +1 -1
- package/lib/crypto-api/recovery-key.js +20 -20
- package/lib/crypto-api/recovery-key.js.map +1 -1
- package/lib/digest.js +21 -21
- package/lib/digest.js.map +1 -1
- package/lib/extensible_events_v1/ExtensibleEvent.js +39 -39
- package/lib/extensible_events_v1/ExtensibleEvent.js.map +1 -1
- package/lib/extensible_events_v1/InvalidEventError.js +16 -16
- package/lib/extensible_events_v1/InvalidEventError.js.map +1 -1
- package/lib/extensible_events_v1/MessageEvent.js +39 -39
- package/lib/extensible_events_v1/MessageEvent.js.map +1 -1
- package/lib/extensible_events_v1/PollEndEvent.js +29 -29
- package/lib/extensible_events_v1/PollEndEvent.js.map +1 -1
- package/lib/extensible_events_v1/PollResponseEvent.js +39 -39
- package/lib/extensible_events_v1/PollResponseEvent.js.map +1 -1
- package/lib/extensible_events_v1/PollStartEvent.js +52 -52
- package/lib/extensible_events_v1/PollStartEvent.js.map +1 -1
- package/lib/extensible_events_v1/utilities.js +22 -22
- package/lib/extensible_events_v1/utilities.js.map +1 -1
- package/lib/feature.js +16 -16
- package/lib/feature.js.map +1 -1
- package/lib/http-api/method.js +14 -14
- package/lib/http-api/method.js.map +1 -1
- package/lib/http-api/prefix.js +26 -26
- package/lib/http-api/prefix.js.map +1 -1
- package/lib/indexeddb-helpers.js +21 -21
- package/lib/indexeddb-helpers.js.map +1 -1
- package/lib/indexeddb-worker.js +18 -18
- package/lib/indexeddb-worker.js.map +1 -1
- package/lib/matrixrtc/IKeyTransport.js +17 -17
- package/lib/matrixrtc/IKeyTransport.js.map +1 -1
- package/lib/matrixrtc/IMembershipManager.js +27 -27
- package/lib/matrixrtc/IMembershipManager.js.map +1 -1
- package/lib/matrixrtc/LivekitTransport.js +19 -19
- package/lib/matrixrtc/LivekitTransport.js.map +1 -1
- package/lib/matrixrtc/index.js +14 -14
- package/lib/matrixrtc/index.js.map +1 -1
- package/lib/matrixrtc/utils.js +27 -27
- package/lib/matrixrtc/utils.js.map +1 -1
- package/lib/models/ToDeviceMessage.js.map +1 -1
- package/lib/models/device.js +24 -24
- package/lib/models/device.js.map +1 -1
- package/lib/models/event-status.js +17 -17
- package/lib/models/event-status.js.map +1 -1
- package/lib/models/invites-ignorer-types.js +25 -25
- package/lib/models/invites-ignorer-types.js.map +1 -1
- package/lib/models/profile-keys.js +26 -26
- package/lib/models/profile-keys.js.map +1 -1
- package/lib/models/room-summary.js +26 -26
- package/lib/models/room-summary.js.map +1 -1
- package/lib/models/search-result.js +22 -22
- package/lib/models/search-result.js.map +1 -1
- package/lib/models/typed-event-emitter.js +122 -122
- package/lib/models/typed-event-emitter.js.map +1 -1
- package/lib/oidc/authorize.js +76 -76
- package/lib/oidc/authorize.js.map +1 -1
- package/lib/oidc/error.js +17 -17
- package/lib/oidc/error.js.map +1 -1
- package/lib/oidc/index.js +17 -17
- package/lib/oidc/index.js.map +1 -1
- package/lib/oidc/register.js +41 -41
- package/lib/oidc/register.js.map +1 -1
- package/lib/oidc/tokenRefresher.js +51 -51
- package/lib/oidc/tokenRefresher.js.map +1 -1
- package/lib/oidc/validate.js +59 -59
- package/lib/oidc/validate.js.map +1 -1
- package/lib/randomstring.js +35 -35
- package/lib/randomstring.js.map +1 -1
- package/lib/realtime-callbacks.js +39 -39
- package/lib/realtime-callbacks.js.map +1 -1
- package/lib/receipt-accumulator.js +44 -44
- package/lib/receipt-accumulator.js.map +1 -1
- package/lib/rendezvous/RendezvousChannel.js.map +1 -1
- package/lib/rendezvous/RendezvousCode.js.map +1 -1
- package/lib/rendezvous/RendezvousError.js +14 -14
- package/lib/rendezvous/RendezvousError.js.map +1 -1
- package/lib/rendezvous/RendezvousFailureReason.js +14 -14
- package/lib/rendezvous/RendezvousFailureReason.js.map +1 -1
- package/lib/rendezvous/RendezvousIntent.js +14 -14
- package/lib/rendezvous/RendezvousIntent.js.map +1 -1
- package/lib/rendezvous/RendezvousTransport.js.map +1 -1
- package/lib/rendezvous/channels/MSC4108SecureChannel.js +63 -63
- package/lib/rendezvous/channels/MSC4108SecureChannel.js.map +1 -1
- package/lib/rendezvous/channels/index.js +14 -14
- package/lib/rendezvous/channels/index.js.map +1 -1
- package/lib/rendezvous/index.js +14 -14
- package/lib/rendezvous/index.js.map +1 -1
- package/lib/rendezvous/transports/index.js +14 -14
- package/lib/rendezvous/transports/index.js.map +1 -1
- package/lib/rust-crypto/CrossSigningIdentity.js +29 -29
- package/lib/rust-crypto/CrossSigningIdentity.js.map +1 -1
- package/lib/rust-crypto/OutgoingRequestsManager.js +37 -37
- package/lib/rust-crypto/OutgoingRequestsManager.js.map +1 -1
- package/lib/rust-crypto/device-converter.js +30 -30
- package/lib/rust-crypto/device-converter.js.map +1 -1
- package/lib/rust-crypto/secret-storage.js +30 -30
- package/lib/rust-crypto/secret-storage.js.map +1 -1
- package/lib/service-types.js +14 -14
- package/lib/service-types.js.map +1 -1
- package/lib/store/local-storage-events-emitter.js +21 -21
- package/lib/store/local-storage-events-emitter.js.map +1 -1
- package/lib/sync-accumulator.js +50 -50
- package/lib/sync-accumulator.js.map +1 -1
- package/lib/thread-utils.js +20 -20
- package/lib/thread-utils.js.map +1 -1
- package/lib/types.js +34 -34
- package/lib/types.js.map +1 -1
- package/lib/utils/decryptAESSecretStorageItem.js +22 -22
- package/lib/utils/decryptAESSecretStorageItem.js.map +1 -1
- package/lib/utils/encryptAESSecretStorageItem.js +26 -26
- package/lib/utils/encryptAESSecretStorageItem.js.map +1 -1
- package/lib/utils/internal/deriveKeys.js +21 -21
- package/lib/utils/internal/deriveKeys.js.map +1 -1
- package/lib/utils/roomVersion.js +26 -26
- package/lib/utils/roomVersion.js.map +1 -1
- package/lib/version-support.js +26 -26
- package/lib/version-support.js.map +1 -1
- package/lib/wallet-recovery.d.ts +24 -0
- package/lib/wallet-recovery.d.ts.map +1 -0
- package/lib/wallet-recovery.js +232 -0
- package/lib/wallet-recovery.js.map +1 -0
- package/lib/webrtc/audioContext.js +24 -24
- package/lib/webrtc/audioContext.js.map +1 -1
- package/lib/webrtc/callEventTypes.js.map +1 -1
- package/lib/webrtc/stats/callFeedStatsReporter.js +14 -14
- package/lib/webrtc/stats/callFeedStatsReporter.js.map +1 -1
- package/lib/webrtc/stats/callStatsReportGatherer.js +14 -14
- package/lib/webrtc/stats/callStatsReportGatherer.js.map +1 -1
- package/lib/webrtc/stats/callStatsReportSummary.js.map +1 -1
- package/lib/webrtc/stats/connectionStats.js +14 -14
- package/lib/webrtc/stats/connectionStats.js.map +1 -1
- package/lib/webrtc/stats/connectionStatsBuilder.js +14 -14
- package/lib/webrtc/stats/connectionStatsBuilder.js.map +1 -1
- package/lib/webrtc/stats/connectionStatsReportBuilder.js +14 -14
- package/lib/webrtc/stats/connectionStatsReportBuilder.js.map +1 -1
- package/lib/webrtc/stats/groupCallStats.js +14 -14
- package/lib/webrtc/stats/groupCallStats.js.map +1 -1
- package/lib/webrtc/stats/media/mediaSsrcHandler.js +14 -14
- package/lib/webrtc/stats/media/mediaSsrcHandler.js.map +1 -1
- package/lib/webrtc/stats/media/mediaTrackHandler.js +14 -14
- package/lib/webrtc/stats/media/mediaTrackHandler.js.map +1 -1
- package/lib/webrtc/stats/media/mediaTrackStats.js +27 -27
- package/lib/webrtc/stats/media/mediaTrackStats.js.map +1 -1
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.js +20 -20
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.js.map +1 -1
- package/lib/webrtc/stats/statsReport.js +14 -14
- package/lib/webrtc/stats/statsReport.js.map +1 -1
- package/lib/webrtc/stats/statsReportEmitter.js +14 -14
- package/lib/webrtc/stats/statsReportEmitter.js.map +1 -1
- package/lib/webrtc/stats/trackStatsBuilder.js +4 -4
- package/lib/webrtc/stats/trackStatsBuilder.js.map +1 -1
- package/lib/webrtc/stats/transportStats.js.map +1 -1
- package/lib/webrtc/stats/transportStatsBuilder.js.map +1 -1
- package/lib/webrtc/stats/valueFormatter.js +11 -11
- package/lib/webrtc/stats/valueFormatter.js.map +1 -1
- package/lib/xrpl/identity.d.ts +28 -0
- package/lib/xrpl/identity.d.ts.map +1 -0
- package/lib/xrpl/identity.js +213 -0
- package/lib/xrpl/identity.js.map +1 -0
- package/lib/xrpl/trust.d.ts +8 -0
- package/lib/xrpl/trust.d.ts.map +1 -0
- package/lib/xrpl/trust.js +61 -0
- package/lib/xrpl/trust.js.map +1 -0
- package/lib/xrpl/verification.d.ts +26 -0
- package/lib/xrpl/verification.d.ts.map +1 -0
- package/lib/xrpl/verification.js +295 -0
- package/lib/xrpl/verification.js.map +1 -0
- package/package.json +130 -129
- package/src/@types/AESEncryptedSecretStoragePayload.ts +29 -29
- package/src/@types/IIdentityServerProvider.ts +24 -24
- package/src/@types/PushRules.ts +208 -208
- package/src/@types/another-json.d.ts +19 -19
- package/src/@types/auth.ts +340 -258
- package/src/@types/beacon.ts +140 -140
- package/src/@types/common.ts +24 -24
- package/src/@types/crypto.ts +71 -71
- package/src/@types/event.ts +508 -449
- package/src/@types/events.ts +119 -119
- package/src/@types/extensible_events.ts +147 -147
- package/src/@types/local_notifications.ts +19 -19
- package/src/@types/location.ts +92 -92
- package/src/@types/matrix-sdk-crypto-wasm.d.ts +39 -39
- package/src/@types/media.ts +245 -245
- package/src/@types/membership.ts +57 -57
- package/src/@types/partials.ts +103 -103
- package/src/@types/polls.ts +120 -120
- package/src/@types/read_receipts.ts +61 -61
- package/src/@types/registration.ts +102 -102
- package/src/@types/search.ts +119 -119
- package/src/@types/signed.ts +25 -25
- package/src/@types/spaces.ts +37 -37
- package/src/@types/state_events.ts +153 -153
- package/src/@types/synapse.ts +40 -40
- package/src/@types/sync.ts +27 -27
- package/src/@types/threepids.ts +29 -29
- package/src/@types/topic.ts +69 -69
- package/src/@types/uia.ts +24 -24
- package/src/NamespacedValue.ts +121 -121
- package/src/ReEmitter.ts +93 -93
- package/src/base64.ts +86 -86
- package/src/briij.ts +4 -0
- package/src/client.ts +183 -10
- package/src/common-crypto/README.md +4 -4
- package/src/common-crypto/key-passphrase.ts +43 -43
- package/src/content-helpers.ts +298 -298
- package/src/content-repo.ts +122 -122
- package/src/crypto/store/base.ts +388 -388
- package/src/crypto/store/indexeddb-crypto-store-backend.ts +655 -655
- package/src/crypto/store/indexeddb-crypto-store.ts +555 -555
- package/src/crypto/store/localStorage-crypto-store.ts +409 -409
- package/src/crypto/store/memory-crypto-store.ts +326 -326
- package/src/crypto-api/CryptoEventHandlerMap.ts +42 -42
- package/src/crypto-api/key-passphrase.ts +58 -58
- package/src/crypto-api/keybackup.ts +114 -114
- package/src/crypto-api/recovery-key.ts +69 -69
- package/src/digest.ts +34 -34
- package/src/extensible_events_v1/ExtensibleEvent.ts +58 -58
- package/src/extensible_events_v1/InvalidEventError.ts +24 -24
- package/src/extensible_events_v1/MessageEvent.ts +143 -143
- package/src/extensible_events_v1/PollEndEvent.ts +97 -97
- package/src/extensible_events_v1/PollResponseEvent.ts +148 -148
- package/src/extensible_events_v1/PollStartEvent.ts +207 -207
- package/src/extensible_events_v1/utilities.ts +35 -35
- package/src/feature.ts +88 -88
- package/src/http-api/method.ts +25 -25
- package/src/http-api/prefix.ts +48 -48
- package/src/indexeddb-helpers.ts +50 -50
- package/src/indexeddb-worker.ts +24 -24
- package/src/matrixrtc/IKeyTransport.ts +63 -63
- package/src/matrixrtc/IMembershipManager.ts +120 -120
- package/src/matrixrtc/LivekitTransport.ts +46 -46
- package/src/matrixrtc/index.ts +24 -24
- package/src/matrixrtc/utils.ts +71 -71
- package/src/models/ToDeviceMessage.ts +38 -38
- package/src/models/device.ts +85 -85
- package/src/models/event-status.ts +39 -39
- package/src/models/invites-ignorer-types.ts +58 -58
- package/src/models/profile-keys.ts +33 -33
- package/src/models/room-summary.ts +78 -78
- package/src/models/search-result.ts +57 -57
- package/src/models/typed-event-emitter.ts +246 -246
- package/src/oidc/authorize.ts +279 -279
- package/src/oidc/error.ts +33 -33
- package/src/oidc/index.ts +33 -33
- package/src/oidc/register.ts +163 -163
- package/src/oidc/tokenRefresher.ts +184 -184
- package/src/oidc/validate.ts +265 -265
- package/src/randomstring.ts +103 -103
- package/src/realtime-callbacks.ts +191 -191
- package/src/receipt-accumulator.ts +189 -189
- package/src/rendezvous/RendezvousChannel.ts +48 -48
- package/src/rendezvous/RendezvousCode.ts +25 -25
- package/src/rendezvous/RendezvousError.ts +26 -26
- package/src/rendezvous/RendezvousFailureReason.ts +49 -49
- package/src/rendezvous/RendezvousIntent.ts +20 -20
- package/src/rendezvous/RendezvousTransport.ts +58 -58
- package/src/rendezvous/channels/MSC4108SecureChannel.ts +270 -270
- package/src/rendezvous/channels/index.ts +17 -17
- package/src/rendezvous/index.ts +25 -25
- package/src/rendezvous/transports/index.ts +17 -17
- package/src/rust-crypto/CrossSigningIdentity.ts +195 -195
- package/src/rust-crypto/OutgoingRequestsManager.ts +170 -170
- package/src/rust-crypto/device-converter.ts +128 -128
- package/src/rust-crypto/secret-storage.ts +60 -60
- package/src/service-types.ts +20 -20
- package/src/store/local-storage-events-emitter.ts +46 -46
- package/src/sync-accumulator.ts +779 -779
- package/src/thread-utils.ts +31 -31
- package/src/types.ts +59 -59
- package/src/utils/decryptAESSecretStorageItem.ts +54 -54
- package/src/utils/encryptAESSecretStorageItem.ts +73 -73
- package/src/utils/internal/deriveKeys.ts +63 -63
- package/src/utils/roomVersion.ts +35 -35
- package/src/version-support.ts +50 -50
- package/src/wallet-recovery.ts +252 -0
- package/src/webrtc/audioContext.ts +44 -44
- package/src/webrtc/callEventTypes.ts +101 -101
- package/src/webrtc/stats/callFeedStatsReporter.ts +91 -91
- package/src/webrtc/stats/callStatsReportGatherer.ts +219 -219
- package/src/webrtc/stats/callStatsReportSummary.ts +30 -30
- package/src/webrtc/stats/connectionStats.ts +47 -47
- package/src/webrtc/stats/connectionStatsBuilder.ts +28 -28
- package/src/webrtc/stats/connectionStatsReportBuilder.ts +140 -140
- package/src/webrtc/stats/groupCallStats.ts +93 -93
- package/src/webrtc/stats/media/mediaSsrcHandler.ts +57 -57
- package/src/webrtc/stats/media/mediaTrackHandler.ts +70 -70
- package/src/webrtc/stats/media/mediaTrackStats.ts +176 -176
- package/src/webrtc/stats/media/mediaTrackStatsHandler.ts +90 -90
- package/src/webrtc/stats/statsReport.ts +133 -133
- package/src/webrtc/stats/statsReportEmitter.ts +49 -49
- package/src/webrtc/stats/trackStatsBuilder.ts +207 -207
- package/src/webrtc/stats/transportStats.ts +26 -26
- package/src/webrtc/stats/transportStatsBuilder.ts +48 -48
- package/src/webrtc/stats/valueFormatter.ts +27 -27
- package/src/xrpl/identity.ts +245 -0
- package/src/xrpl/trust.ts +64 -0
- package/src/xrpl/verification.ts +284 -0
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
/*
|
|
4
|
-
Copyright 2023 The Matrix.org Foundation C.I.C.
|
|
5
|
-
|
|
6
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
-
you may not use this file except in compliance with the License.
|
|
8
|
-
You may obtain a copy of the License at
|
|
9
|
-
|
|
10
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
|
|
12
|
-
Unless required by applicable law or agreed to in writing, software
|
|
13
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
-
See the License for the specific language governing permissions and
|
|
16
|
-
limitations under the License.
|
|
3
|
+
/*
|
|
4
|
+
Copyright 2023 The Matrix.org Foundation C.I.C.
|
|
5
|
+
|
|
6
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
you may not use this file except in compliance with the License.
|
|
8
|
+
You may obtain a copy of the License at
|
|
9
|
+
|
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
|
|
12
|
+
Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
See the License for the specific language governing permissions and
|
|
16
|
+
limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import { logDuration } from "../utils.js";
|
|
20
20
|
|
|
21
|
-
/**
|
|
22
|
-
* OutgoingRequestsManager: responsible for processing outgoing requests from the OlmMachine.
|
|
23
|
-
* Ensure that only one loop is going on at once, and that the requests are processed in order.
|
|
21
|
+
/**
|
|
22
|
+
* OutgoingRequestsManager: responsible for processing outgoing requests from the OlmMachine.
|
|
23
|
+
* Ensure that only one loop is going on at once, and that the requests are processed in order.
|
|
24
24
|
*/
|
|
25
25
|
export class OutgoingRequestsManager {
|
|
26
26
|
constructor(logger, olmMachine, outgoingRequestProcessor) {
|
|
@@ -31,33 +31,33 @@ export class OutgoingRequestsManager {
|
|
|
31
31
|
_defineProperty(this, "stopped", false);
|
|
32
32
|
/** whether {@link outgoingRequestLoop} is currently running */
|
|
33
33
|
_defineProperty(this, "outgoingRequestLoopRunning", false);
|
|
34
|
-
/**
|
|
35
|
-
* If there are additional calls to doProcessOutgoingRequests() while there is a current call running
|
|
36
|
-
* we need to remember in order to call `doProcessOutgoingRequests` again (as there could be new requests).
|
|
37
|
-
*
|
|
38
|
-
* If this is defined, it is an indication that we need to do another iteration; in this case the deferred
|
|
39
|
-
* will resolve once that next iteration completes. If it is undefined, there have been no new calls
|
|
40
|
-
* to `doProcessOutgoingRequests` since the current iteration started.
|
|
34
|
+
/**
|
|
35
|
+
* If there are additional calls to doProcessOutgoingRequests() while there is a current call running
|
|
36
|
+
* we need to remember in order to call `doProcessOutgoingRequests` again (as there could be new requests).
|
|
37
|
+
*
|
|
38
|
+
* If this is defined, it is an indication that we need to do another iteration; in this case the deferred
|
|
39
|
+
* will resolve once that next iteration completes. If it is undefined, there have been no new calls
|
|
40
|
+
* to `doProcessOutgoingRequests` since the current iteration started.
|
|
41
41
|
*/
|
|
42
42
|
_defineProperty(this, "nextLoopDeferred", void 0);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
/**
|
|
46
|
-
* Shut down as soon as possible the current loop of outgoing requests processing.
|
|
45
|
+
/**
|
|
46
|
+
* Shut down as soon as possible the current loop of outgoing requests processing.
|
|
47
47
|
*/
|
|
48
48
|
stop() {
|
|
49
49
|
this.stopped = true;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
/**
|
|
53
|
-
* Process the OutgoingRequests from the OlmMachine.
|
|
54
|
-
*
|
|
55
|
-
* This should be called at the end of each sync, to process any OlmMachine OutgoingRequests created by the rust sdk.
|
|
56
|
-
* In some cases if OutgoingRequests need to be sent immediately, this can be called directly.
|
|
57
|
-
*
|
|
58
|
-
* Calls to doProcessOutgoingRequests() are processed synchronously, one after the other, in order.
|
|
59
|
-
* If doProcessOutgoingRequests() is called while another call is still being processed, it will be queued.
|
|
60
|
-
* Multiple calls to doProcessOutgoingRequests() when a call is already processing will be batched together.
|
|
52
|
+
/**
|
|
53
|
+
* Process the OutgoingRequests from the OlmMachine.
|
|
54
|
+
*
|
|
55
|
+
* This should be called at the end of each sync, to process any OlmMachine OutgoingRequests created by the rust sdk.
|
|
56
|
+
* In some cases if OutgoingRequests need to be sent immediately, this can be called directly.
|
|
57
|
+
*
|
|
58
|
+
* Calls to doProcessOutgoingRequests() are processed synchronously, one after the other, in order.
|
|
59
|
+
* If doProcessOutgoingRequests() is called while another call is still being processed, it will be queued.
|
|
60
|
+
* Multiple calls to doProcessOutgoingRequests() when a call is already processing will be batched together.
|
|
61
61
|
*/
|
|
62
62
|
doProcessOutgoingRequests() {
|
|
63
63
|
// Flag that we need at least one more iteration of the loop.
|
|
@@ -115,8 +115,8 @@ export class OutgoingRequestsManager {
|
|
|
115
115
|
})();
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
/**
|
|
119
|
-
* Make a single request to `olmMachine.outgoingRequests` and do the corresponding requests.
|
|
118
|
+
/**
|
|
119
|
+
* Make a single request to `olmMachine.outgoingRequests` and do the corresponding requests.
|
|
120
120
|
*/
|
|
121
121
|
processOutgoingRequests() {
|
|
122
122
|
var _this2 = this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OutgoingRequestsManager.js","names":["logDuration","OutgoingRequestsManager","constructor","logger","olmMachine","outgoingRequestProcessor","_defineProperty","stop","stopped","doProcessOutgoingRequests","nextLoopDeferred","Promise","withResolvers","result","promise","outgoingRequestLoopRunning","outgoingRequestLoop","catch","e","error","_this","_asyncToGenerator","Error","loopTickResolvers","undefined","processOutgoingRequests","then","resolve","reject","_this2","outgoingRequests","successes","_loop","request","v","concat","type","makeOutgoingRequest","_ret","warn"],"sources":["../../src/rust-crypto/OutgoingRequestsManager.ts"],"sourcesContent":["/*\r\nCopyright 2023 The Matrix.org Foundation C.I.C.\r\n\r\nLicensed under the Apache License, Version 2.0 (the \"License\");\r\nyou may not use this file except in compliance with the License.\r\nYou may obtain a copy of the License at\r\n\r\n http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nUnless required by applicable law or agreed to in writing, software\r\ndistributed under the License is distributed on an \"AS IS\" BASIS,\r\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\nSee the License for the specific language governing permissions and\r\nlimitations under the License.\r\n*/\r\n\r\nimport { type OlmMachine, type OutgoingRequest } from \"@matrix-org/matrix-sdk-crypto-wasm\";\r\n\r\nimport { type OutgoingRequestProcessor } from \"./OutgoingRequestProcessor.ts\";\r\nimport { type Logger } from \"../logger.ts\";\r\nimport { logDuration } from \"../utils.ts\";\r\n\r\n/**\r\n * OutgoingRequestsManager: responsible for processing outgoing requests from the OlmMachine.\r\n * Ensure that only one loop is going on at once, and that the requests are processed in order.\r\n */\r\nexport class OutgoingRequestsManager {\r\n /** whether {@link stop} has been called */\r\n private stopped = false;\r\n\r\n /** whether {@link outgoingRequestLoop} is currently running */\r\n private outgoingRequestLoopRunning = false;\r\n\r\n /**\r\n * If there are additional calls to doProcessOutgoingRequests() while there is a current call running\r\n * we need to remember in order to call `doProcessOutgoingRequests` again (as there could be new requests).\r\n *\r\n * If this is defined, it is an indication that we need to do another iteration; in this case the deferred\r\n * will resolve once that next iteration completes. If it is undefined, there have been no new calls\r\n * to `doProcessOutgoingRequests` since the current iteration started.\r\n */\r\n private nextLoopDeferred?: PromiseWithResolvers<void>;\r\n\r\n public constructor(\r\n private readonly logger: Logger,\r\n private readonly olmMachine: OlmMachine,\r\n public readonly outgoingRequestProcessor: OutgoingRequestProcessor,\r\n ) {}\r\n\r\n /**\r\n * Shut down as soon as possible the current loop of outgoing requests processing.\r\n */\r\n public stop(): void {\r\n this.stopped = true;\r\n }\r\n\r\n /**\r\n * Process the OutgoingRequests from the OlmMachine.\r\n *\r\n * This should be called at the end of each sync, to process any OlmMachine OutgoingRequests created by the rust sdk.\r\n * In some cases if OutgoingRequests need to be sent immediately, this can be called directly.\r\n *\r\n * Calls to doProcessOutgoingRequests() are processed synchronously, one after the other, in order.\r\n * If doProcessOutgoingRequests() is called while another call is still being processed, it will be queued.\r\n * Multiple calls to doProcessOutgoingRequests() when a call is already processing will be batched together.\r\n */\r\n public doProcessOutgoingRequests(): Promise<void> {\r\n // Flag that we need at least one more iteration of the loop.\r\n //\r\n // It is important that we do this even if the loop is currently running. There is potential for a race whereby\r\n // a request is added to the queue *after* `OlmMachine.outgoingRequests` checks the queue, but *before* it\r\n // returns. In such a case, the item could sit there unnoticed for some time.\r\n //\r\n // In order to circumvent the race, we set a flag which tells the loop to go round once again even if the\r\n // queue appears to be empty.\r\n if (!this.nextLoopDeferred) {\r\n this.nextLoopDeferred = Promise.withResolvers();\r\n }\r\n\r\n // ... and wait for it to complete.\r\n const result = this.nextLoopDeferred.promise;\r\n\r\n // set the loop going if it is not already.\r\n if (!this.outgoingRequestLoopRunning) {\r\n this.outgoingRequestLoop().catch((e) => {\r\n // this should not happen; outgoingRequestLoop should return any errors via `nextLoopDeferred`.\r\n /* istanbul ignore next */\r\n this.logger.error(\"Uncaught error in outgoing request loop\", e);\r\n });\r\n }\r\n return result;\r\n }\r\n\r\n private async outgoingRequestLoop(): Promise<void> {\r\n /* istanbul ignore if */\r\n if (this.outgoingRequestLoopRunning) {\r\n throw new Error(\"Cannot run two outgoing request loops\");\r\n }\r\n this.outgoingRequestLoopRunning = true;\r\n try {\r\n while (!this.stopped && this.nextLoopDeferred) {\r\n const loopTickResolvers = this.nextLoopDeferred;\r\n\r\n // reset `nextLoopDeferred` so that any future calls to `doProcessOutgoingRequests` are queued\r\n // for another additional iteration.\r\n this.nextLoopDeferred = undefined;\r\n\r\n // make the requests and feed the results back to the `nextLoopDeferred`\r\n await this.processOutgoingRequests().then(loopTickResolvers.resolve, loopTickResolvers.reject);\r\n }\r\n } finally {\r\n this.outgoingRequestLoopRunning = false;\r\n }\r\n\r\n if (this.nextLoopDeferred) {\r\n // the loop was stopped, but there was a call to `doProcessOutgoingRequests`. Make sure that\r\n // we reject the promise in case anything is waiting for it.\r\n this.nextLoopDeferred.reject(new Error(\"OutgoingRequestsManager was stopped\"));\r\n }\r\n }\r\n\r\n /**\r\n * Make a single request to `olmMachine.outgoingRequests` and do the corresponding requests.\r\n */\r\n private async processOutgoingRequests(): Promise<void> {\r\n if (this.stopped) return;\r\n\r\n const outgoingRequests: OutgoingRequest[] = await this.olmMachine.outgoingRequests();\r\n\r\n let successes = 0;\r\n for (const request of outgoingRequests) {\r\n if (this.stopped) return;\r\n try {\r\n await logDuration(this.logger, `Make outgoing request ${request.type}`, async () => {\r\n await this.outgoingRequestProcessor.makeOutgoingRequest(request);\r\n successes++;\r\n });\r\n } catch (e) {\r\n // as part of the loop we silently ignore errors, but log them.\r\n // The rust sdk will retry the request later as it won't have been marked as sent.\r\n this.logger.error(`Failed to process outgoing request ${request.type}: ${e}`);\r\n }\r\n }\r\n\r\n // If we successfully handled any requests this time, more may have been queued as\r\n // part of that handling.\r\n //\r\n // For example, we may have processed a `/keys/claim` request, which\r\n // meant the rust side could establish an Olm session and is now ready to\r\n // send out an `m.secret.send` message.\r\n // (See https://github.com/element-hq/element-web/issues/30988.)\r\n //\r\n // So, if we have successfully processed any requests, flag that we need to make another\r\n // pass around the outgoing-requests loop, to make sure we handle any\r\n // pending requests immediately.\r\n //\r\n // If all requests failed (or there weren't any) we don't want to retry them in a tight\r\n // loop. They will be retried after the next sync.\r\n // (See https://github.com/element-hq/element-web/issues/31790.)\r\n if (successes > 0) {\r\n // We call doProcessOutgoingRequests but since we expect that we are\r\n // already processing outgoing requests, this call will not kick off\r\n // the processing loop, but just set `nextLoopDeferred` and return,\r\n // which will mean we loop one more time.\r\n this.doProcessOutgoingRequests().catch((e) => {\r\n this.logger.warn(\"processOutgoingRequests: Error re-checking outgoing requests\", e);\r\n });\r\n }\r\n }\r\n}\r\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,SAASA,WAAW,QAAQ,aAAa;;AAEzC;AACA;AACA;AACA;AACA,OAAO,MAAMC,uBAAuB,CAAC;EAiB1BC,WAAWA,CACGC,MAAc,EACdC,UAAsB,EACvBC,wBAAkD,EACpE;IAAA,KAHmBF,MAAc,GAAdA,MAAc;IAAA,KACdC,UAAsB,GAAtBA,UAAsB;IAAA,KACvBC,wBAAkD,GAAlDA,wBAAkD;IAnBtE;IAAAC,eAAA,kBACkB,KAAK;IAEvB;IAAAA,eAAA,qCACqC,KAAK;IAE1C;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;IAPIA,eAAA;EAcG;;EAEH;AACJ;AACA;EACWC,IAAIA,CAAA,EAAS;IAChB,IAAI,CAACC,OAAO,GAAG,IAAI;EACvB;;EAEA;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACWC,yBAAyBA,CAAA,EAAkB;IAC9C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,CAAC,IAAI,CAACC,gBAAgB,EAAE;MACxB,IAAI,CAACA,gBAAgB,GAAGC,OAAO,CAACC,aAAa,CAAC,CAAC;IACnD;;IAEA;IACA,IAAMC,MAAM,GAAG,IAAI,CAACH,gBAAgB,CAACI,OAAO;;IAE5C;IACA,IAAI,CAAC,IAAI,C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,EACsB;UACpC,IAAIJ,MAAI,CAACrB,OAAO;YAAA0B,CAAA;UAAA;UAChB,IAAI;YACA,MAAMlC,WAAW,CAAC6B,MAAI,CAAC1B,MAAM,2BAAAgC,MAAA,CAA2BF,OAAO,CAACG,IAAI,gBAAAf,iBAAA,CAAI,aAAY;cAChF,MAAMQ,MAAI,CAACxB,wBAAwB,CAACgC,mBAAmB,CAACJ,OAAO,CAAC;cAChEF,SAAS,EAAE;YACf,CAAC,EAAC;UACN,CAAC,CAAC,OAAOb,CAAC,EAAE;YACR;YACA;YACAW,MAAI,CAAC1B,MAAM,CAACgB,KAAK,uCAAAgB,MAAA,CAAuCF,OAAO,CAACG,IAAI,QAAAD,MAAA,CAAKjB,CAAC,CAAE,CAAC;UACjF;QACJ,CAAC;QAAAoB,IAAA;MAZD,KAAK,IAAML,OAAO,IAAIH,gBAAgB;QAAAQ,IAAA,UAAAN,KAAA,CAAAC,OAAA;QAAA,IAAAK,IAAA,SAAAA,IAAA,CAAAJ,CAAA;MAAA;;MActC;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA,IAAIH,SAAS,GAAG,CAAC,EAAE;QACf;QACA;QACA;QACA;QACAF,MAAI,CAACpB,yBAAyB,CAAC,CAAC,CAACQ,KAAK,CAAEC,CAAC,IAAK;UAC1CW,MAAI,CAAC1B,MAAM,CAACoC,IAAI,CAAC,8DAA8D,EAAErB,CAAC,CAAC;QACvF,CAAC,CAAC;MACN;IAAC;EACL;AACJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"OutgoingRequestsManager.js","names":["logDuration","OutgoingRequestsManager","constructor","logger","olmMachine","outgoingRequestProcessor","_defineProperty","stop","stopped","doProcessOutgoingRequests","nextLoopDeferred","Promise","withResolvers","result","promise","outgoingRequestLoopRunning","outgoingRequestLoop","catch","e","error","_this","_asyncToGenerator","Error","loopTickResolvers","undefined","processOutgoingRequests","then","resolve","reject","_this2","outgoingRequests","successes","_loop","request","v","concat","type","makeOutgoingRequest","_ret","warn"],"sources":["../../src/rust-crypto/OutgoingRequestsManager.ts"],"sourcesContent":["/*\nCopyright 2023 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { type OlmMachine, type OutgoingRequest } from \"@matrix-org/matrix-sdk-crypto-wasm\";\n\nimport { type OutgoingRequestProcessor } from \"./OutgoingRequestProcessor.ts\";\nimport { type Logger } from \"../logger.ts\";\nimport { logDuration } from \"../utils.ts\";\n\n/**\n * OutgoingRequestsManager: responsible for processing outgoing requests from the OlmMachine.\n * Ensure that only one loop is going on at once, and that the requests are processed in order.\n */\nexport class OutgoingRequestsManager {\n /** whether {@link stop} has been called */\n private stopped = false;\n\n /** whether {@link outgoingRequestLoop} is currently running */\n private outgoingRequestLoopRunning = false;\n\n /**\n * If there are additional calls to doProcessOutgoingRequests() while there is a current call running\n * we need to remember in order to call `doProcessOutgoingRequests` again (as there could be new requests).\n *\n * If this is defined, it is an indication that we need to do another iteration; in this case the deferred\n * will resolve once that next iteration completes. If it is undefined, there have been no new calls\n * to `doProcessOutgoingRequests` since the current iteration started.\n */\n private nextLoopDeferred?: PromiseWithResolvers<void>;\n\n public constructor(\n private readonly logger: Logger,\n private readonly olmMachine: OlmMachine,\n public readonly outgoingRequestProcessor: OutgoingRequestProcessor,\n ) {}\n\n /**\n * Shut down as soon as possible the current loop of outgoing requests processing.\n */\n public stop(): void {\n this.stopped = true;\n }\n\n /**\n * Process the OutgoingRequests from the OlmMachine.\n *\n * This should be called at the end of each sync, to process any OlmMachine OutgoingRequests created by the rust sdk.\n * In some cases if OutgoingRequests need to be sent immediately, this can be called directly.\n *\n * Calls to doProcessOutgoingRequests() are processed synchronously, one after the other, in order.\n * If doProcessOutgoingRequests() is called while another call is still being processed, it will be queued.\n * Multiple calls to doProcessOutgoingRequests() when a call is already processing will be batched together.\n */\n public doProcessOutgoingRequests(): Promise<void> {\n // Flag that we need at least one more iteration of the loop.\n //\n // It is important that we do this even if the loop is currently running. There is potential for a race whereby\n // a request is added to the queue *after* `OlmMachine.outgoingRequests` checks the queue, but *before* it\n // returns. In such a case, the item could sit there unnoticed for some time.\n //\n // In order to circumvent the race, we set a flag which tells the loop to go round once again even if the\n // queue appears to be empty.\n if (!this.nextLoopDeferred) {\n this.nextLoopDeferred = Promise.withResolvers();\n }\n\n // ... and wait for it to complete.\n const result = this.nextLoopDeferred.promise;\n\n // set the loop going if it is not already.\n if (!this.outgoingRequestLoopRunning) {\n this.outgoingRequestLoop().catch((e) => {\n // this should not happen; outgoingRequestLoop should return any errors via `nextLoopDeferred`.\n /* istanbul ignore next */\n this.logger.error(\"Uncaught error in outgoing request loop\", e);\n });\n }\n return result;\n }\n\n private async outgoingRequestLoop(): Promise<void> {\n /* istanbul ignore if */\n if (this.outgoingRequestLoopRunning) {\n throw new Error(\"Cannot run two outgoing request loops\");\n }\n this.outgoingRequestLoopRunning = true;\n try {\n while (!this.stopped && this.nextLoopDeferred) {\n const loopTickResolvers = this.nextLoopDeferred;\n\n // reset `nextLoopDeferred` so that any future calls to `doProcessOutgoingRequests` are queued\n // for another additional iteration.\n this.nextLoopDeferred = undefined;\n\n // make the requests and feed the results back to the `nextLoopDeferred`\n await this.processOutgoingRequests().then(loopTickResolvers.resolve, loopTickResolvers.reject);\n }\n } finally {\n this.outgoingRequestLoopRunning = false;\n }\n\n if (this.nextLoopDeferred) {\n // the loop was stopped, but there was a call to `doProcessOutgoingRequests`. Make sure that\n // we reject the promise in case anything is waiting for it.\n this.nextLoopDeferred.reject(new Error(\"OutgoingRequestsManager was stopped\"));\n }\n }\n\n /**\n * Make a single request to `olmMachine.outgoingRequests` and do the corresponding requests.\n */\n private async processOutgoingRequests(): Promise<void> {\n if (this.stopped) return;\n\n const outgoingRequests: OutgoingRequest[] = await this.olmMachine.outgoingRequests();\n\n let successes = 0;\n for (const request of outgoingRequests) {\n if (this.stopped) return;\n try {\n await logDuration(this.logger, `Make outgoing request ${request.type}`, async () => {\n await this.outgoingRequestProcessor.makeOutgoingRequest(request);\n successes++;\n });\n } catch (e) {\n // as part of the loop we silently ignore errors, but log them.\n // The rust sdk will retry the request later as it won't have been marked as sent.\n this.logger.error(`Failed to process outgoing request ${request.type}: ${e}`);\n }\n }\n\n // If we successfully handled any requests this time, more may have been queued as\n // part of that handling.\n //\n // For example, we may have processed a `/keys/claim` request, which\n // meant the rust side could establish an Olm session and is now ready to\n // send out an `m.secret.send` message.\n // (See https://github.com/element-hq/element-web/issues/30988.)\n //\n // So, if we have successfully processed any requests, flag that we need to make another\n // pass around the outgoing-requests loop, to make sure we handle any\n // pending requests immediately.\n //\n // If all requests failed (or there weren't any) we don't want to retry them in a tight\n // loop. They will be retried after the next sync.\n // (See https://github.com/element-hq/element-web/issues/31790.)\n if (successes > 0) {\n // We call doProcessOutgoingRequests but since we expect that we are\n // already processing outgoing requests, this call will not kick off\n // the processing loop, but just set `nextLoopDeferred` and return,\n // which will mean we loop one more time.\n this.doProcessOutgoingRequests().catch((e) => {\n this.logger.warn(\"processOutgoingRequests: Error re-checking outgoing requests\", e);\n });\n }\n }\n}\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,SAASA,WAAW,QAAQ,aAAa;;AAEzC;AACA;AACA;AACA;AACA,OAAO,MAAMC,uBAAuB,CAAC;EAiB1BC,WAAWA,CACGC,MAAc,EACdC,UAAsB,EACvBC,wBAAkD,EACpE;IAAA,KAHmBF,MAAc,GAAdA,MAAc;IAAA,KACdC,UAAsB,GAAtBA,UAAsB;IAAA,KACvBC,wBA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A;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA,IAAIH,SAAS,GAAG,CAAC,EAAE;QACf;QACA;QACA;QACA;QACAF,MAAI,CAACpB,yBAAyB,CAAC,CAAC,CAACQ,KAAK,CAAEC,CAAC,IAAK;UAC1CW,MAAI,CAAC1B,MAAM,CAACoC,IAAI,CAAC,8DAA8D,EAAErB,CAAC,CAAC;QACvF,CAAC,CAAC;MACN;IAAC;EACL;AACJ","ignoreList":[]}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2023 The Matrix.org Foundation C.I.C.
|
|
3
|
-
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
|
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2023 The Matrix.org Foundation C.I.C.
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import * as RustSdkCryptoJs from "@matrix-org/matrix-sdk-crypto-wasm";
|
|
18
18
|
import { Device, DeviceVerification } from "../models/device.js";
|
|
19
|
-
/**
|
|
20
|
-
* Convert a {@link RustSdkCryptoJs.Device} to a {@link Device}
|
|
21
|
-
* @param device - Rust Sdk device
|
|
22
|
-
* @param userId - owner of the device
|
|
23
|
-
*
|
|
24
|
-
* @internal
|
|
19
|
+
/**
|
|
20
|
+
* Convert a {@link RustSdkCryptoJs.Device} to a {@link Device}
|
|
21
|
+
* @param device - Rust Sdk device
|
|
22
|
+
* @param userId - owner of the device
|
|
23
|
+
*
|
|
24
|
+
* @internal
|
|
25
25
|
*/
|
|
26
26
|
export function rustDeviceToJsDevice(device, userId) {
|
|
27
27
|
// Copy rust device keys to Device.keys
|
|
@@ -79,11 +79,11 @@ export function rustDeviceToJsDevice(device, userId) {
|
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
/**
|
|
83
|
-
* Convert {@link DeviceKeys} from `/keys/query` request to a `Map<string, Device>`
|
|
84
|
-
* @param deviceKeys - Device keys object to convert
|
|
85
|
-
*
|
|
86
|
-
* @internal
|
|
82
|
+
/**
|
|
83
|
+
* Convert {@link DeviceKeys} from `/keys/query` request to a `Map<string, Device>`
|
|
84
|
+
* @param deviceKeys - Device keys object to convert
|
|
85
|
+
*
|
|
86
|
+
* @internal
|
|
87
87
|
*/
|
|
88
88
|
export function deviceKeysToDeviceMap(deviceKeys) {
|
|
89
89
|
return new Map(Object.entries(deviceKeys).map(_ref => {
|
|
@@ -94,11 +94,11 @@ export function deviceKeysToDeviceMap(deviceKeys) {
|
|
|
94
94
|
|
|
95
95
|
// Device from `/keys/query` request
|
|
96
96
|
|
|
97
|
-
/**
|
|
98
|
-
* Convert `/keys/query` {@link QueryDevice} device to {@link Device}
|
|
99
|
-
* @param device - Device from `/keys/query` request
|
|
100
|
-
*
|
|
101
|
-
* @internal
|
|
97
|
+
/**
|
|
98
|
+
* Convert `/keys/query` {@link QueryDevice} device to {@link Device}
|
|
99
|
+
* @param device - Device from `/keys/query` request
|
|
100
|
+
*
|
|
101
|
+
* @internal
|
|
102
102
|
*/
|
|
103
103
|
export function downloadDeviceToJsDevice(device) {
|
|
104
104
|
var _device$unsigned;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device-converter.js","names":["RustSdkCryptoJs","Device","DeviceVerification","rustDeviceToJsDevice","device","userId","keys","Map","keyId","key","entries","set","toString","toBase64","verified","Unverified","isBlacklisted","Blocked","isVerified","Verified","signatures","mayBeSignatureMap","get","convertedSignatures","value","isValid","signature","rustAlgorithms","algorithms","Set","forEach","algorithm","EncryptionAlgorithm","MegolmV1AesSha2","add","OlmV1Curve25519AesSha2","deviceId","Array","from","displayName","dehydrated","isDehydrated","deviceKeysToDeviceMap","deviceKeys","Object","map","_ref","downloadDeviceToJsDevice","_device$unsigned","unsigned","device_display_name","device_id","user_id"],"sources":["../../src/rust-crypto/device-converter.ts"],"sourcesContent":["/*\
|
|
1
|
+
{"version":3,"file":"device-converter.js","names":["RustSdkCryptoJs","Device","DeviceVerification","rustDeviceToJsDevice","device","userId","keys","Map","keyId","key","entries","set","toString","toBase64","verified","Unverified","isBlacklisted","Blocked","isVerified","Verified","signatures","mayBeSignatureMap","get","convertedSignatures","value","isValid","signature","rustAlgorithms","algorithms","Set","forEach","algorithm","EncryptionAlgorithm","MegolmV1AesSha2","add","OlmV1Curve25519AesSha2","deviceId","Array","from","displayName","dehydrated","isDehydrated","deviceKeysToDeviceMap","deviceKeys","Object","map","_ref","downloadDeviceToJsDevice","_device$unsigned","unsigned","device_display_name","device_id","user_id"],"sources":["../../src/rust-crypto/device-converter.ts"],"sourcesContent":["/*\nCopyright 2023 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport * as RustSdkCryptoJs from \"@matrix-org/matrix-sdk-crypto-wasm\";\n\nimport { Device, DeviceVerification } from \"../models/device.ts\";\nimport { type DeviceKeys } from \"../client.ts\";\n\n/**\n * Convert a {@link RustSdkCryptoJs.Device} to a {@link Device}\n * @param device - Rust Sdk device\n * @param userId - owner of the device\n *\n * @internal\n */\nexport function rustDeviceToJsDevice(device: RustSdkCryptoJs.Device, userId: RustSdkCryptoJs.UserId): Device {\n // Copy rust device keys to Device.keys\n const keys = new Map<string, string>();\n for (const [keyId, key] of device.keys.entries()) {\n keys.set(keyId.toString(), key.toBase64());\n }\n\n // Compute verified from device state\n let verified: DeviceVerification = DeviceVerification.Unverified;\n if (device.isBlacklisted()) {\n verified = DeviceVerification.Blocked;\n } else if (device.isVerified()) {\n verified = DeviceVerification.Verified;\n }\n\n // Convert rust signatures to Device.signatures\n const signatures = new Map<string, Map<string, string>>();\n const mayBeSignatureMap: Map<string, RustSdkCryptoJs.MaybeSignature> | undefined = device.signatures.get(userId);\n if (mayBeSignatureMap) {\n const convertedSignatures = new Map<string, string>();\n // Convert maybeSignatures map to a Map<string, string>\n for (const [key, value] of mayBeSignatureMap.entries()) {\n if (value.isValid() && value.signature) {\n convertedSignatures.set(key, value.signature.toBase64());\n }\n }\n\n signatures.set(userId.toString(), convertedSignatures);\n }\n\n // Convert rust algorithms to algorithms\n const rustAlgorithms: RustSdkCryptoJs.EncryptionAlgorithm[] = device.algorithms;\n // Use set to ensure that algorithms are not duplicated\n const algorithms = new Set<string>();\n rustAlgorithms.forEach((algorithm) => {\n switch (algorithm) {\n case RustSdkCryptoJs.EncryptionAlgorithm.MegolmV1AesSha2:\n algorithms.add(\"m.megolm.v1.aes-sha2\");\n break;\n case RustSdkCryptoJs.EncryptionAlgorithm.OlmV1Curve25519AesSha2:\n default:\n algorithms.add(\"m.olm.v1.curve25519-aes-sha2\");\n break;\n }\n });\n\n return new Device({\n deviceId: device.deviceId.toString(),\n userId: userId.toString(),\n keys,\n algorithms: Array.from(algorithms),\n verified,\n signatures,\n displayName: device.displayName,\n dehydrated: device.isDehydrated,\n });\n}\n\n/**\n * Convert {@link DeviceKeys} from `/keys/query` request to a `Map<string, Device>`\n * @param deviceKeys - Device keys object to convert\n *\n * @internal\n */\nexport function deviceKeysToDeviceMap(deviceKeys: DeviceKeys): Map<string, Device> {\n return new Map(\n Object.entries(deviceKeys).map(([deviceId, device]) => [deviceId, downloadDeviceToJsDevice(device)]),\n );\n}\n\n// Device from `/keys/query` request\ntype QueryDevice = DeviceKeys[keyof DeviceKeys];\n\n/**\n * Convert `/keys/query` {@link QueryDevice} device to {@link Device}\n * @param device - Device from `/keys/query` request\n *\n * @internal\n */\nexport function downloadDeviceToJsDevice(device: QueryDevice): Device {\n const keys = new Map(Object.entries(device.keys));\n const displayName = device.unsigned?.device_display_name;\n\n const signatures = new Map<string, Map<string, string>>();\n if (device.signatures) {\n for (const userId in device.signatures) {\n signatures.set(userId, new Map(Object.entries(device.signatures[userId])));\n }\n }\n\n return new Device({\n deviceId: device.device_id,\n userId: device.user_id,\n keys,\n algorithms: device.algorithms,\n verified: DeviceVerification.Unverified,\n signatures,\n displayName,\n });\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,eAAe,MAAM,oCAAoC;AAErE,SAASC,MAAM,EAAEC,kBAAkB,QAAQ,qBAAqB;AAGhE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,oBAAoBA,CAACC,MAA8B,EAAEC,MAA8B,EAAU;EACzG;EACA,IAAMC,IAAI,GAAG,IAAIC,GAAG,CAAiB,CAAC;EACtC,KAAK,IAAM,CAACC,KAAK,EAAEC,GAAG,CAAC,IAAIL,MAAM,CAACE,IAAI,CAACI,OAAO,CAAC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AAM,CAACgB,UAAU,EAAE;IACnB,KAAK,IAAMf,MAAM,IAAID,MAAM,CAACgB,UAAU,EAAE;MACpCA,UAAU,CAACT,GAAG,CAACN,MAAM,EAAE,IAAIE,GAAG,CAACqC,MAAM,CAAClC,OAAO,CAACN,MAAM,CAACgB,UAAU,CAACf,MAAM,CAAC,CAAC,CAAC,CAAC;IAC9E;EACJ;EAEA,OAAO,IAAIJ,MAAM,CAAC;IACdmC,QAAQ,EAAEhC,MAAM,CAAC+C,SAAS;IAC1B9C,MAAM,EAAED,MAAM,CAACgD,OAAO;IACtB9C,IAAI;IACJsB,UAAU,EAAExB,MAAM,CAACwB,UAAU;IAC7Bd,QAAQ,EAAEZ,kBAAkB,CAACa,UAAU;IACvCK,UAAU;IACVmB;EACJ,CAAC,CAAC;AACN","ignoreList":[]}
|
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
-
/*
|
|
3
|
-
Copyright 2023 The Matrix.org Foundation C.I.C.
|
|
4
|
-
|
|
5
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
you may not use this file except in compliance with the License.
|
|
7
|
-
You may obtain a copy of the License at
|
|
8
|
-
|
|
9
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
|
|
11
|
-
Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
See the License for the specific language governing permissions and
|
|
15
|
-
limitations under the License.
|
|
2
|
+
/*
|
|
3
|
+
Copyright 2023 The Matrix.org Foundation C.I.C.
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* Check that the private cross signing keys (master, self signing, user signing) are stored in the secret storage and encrypted with the default secret storage key.
|
|
20
|
-
*
|
|
21
|
-
* @param secretStorage - The secret store using account data
|
|
22
|
-
* @returns True if the cross-signing keys are all stored and encrypted with the same secret storage key.
|
|
23
|
-
*
|
|
24
|
-
* @internal
|
|
18
|
+
/**
|
|
19
|
+
* Check that the private cross signing keys (master, self signing, user signing) are stored in the secret storage and encrypted with the default secret storage key.
|
|
20
|
+
*
|
|
21
|
+
* @param secretStorage - The secret store using account data
|
|
22
|
+
* @returns True if the cross-signing keys are all stored and encrypted with the same secret storage key.
|
|
23
|
+
*
|
|
24
|
+
* @internal
|
|
25
25
|
*/
|
|
26
26
|
export function secretStorageContainsCrossSigningKeys(_x) {
|
|
27
27
|
return _secretStorageContainsCrossSigningKeys.apply(this, arguments);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
/**
|
|
31
|
-
*
|
|
32
|
-
* Check that the secret storage can access the given secrets using the default key.
|
|
33
|
-
*
|
|
34
|
-
* @param secretStorage - The secret store using account data
|
|
35
|
-
* @param secretNames - The secret names to check
|
|
36
|
-
* @returns True if all the given secrets are accessible and encrypted with the given key.
|
|
37
|
-
*
|
|
38
|
-
* @internal
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* Check that the secret storage can access the given secrets using the default key.
|
|
33
|
+
*
|
|
34
|
+
* @param secretStorage - The secret store using account data
|
|
35
|
+
* @param secretNames - The secret names to check
|
|
36
|
+
* @returns True if all the given secrets are accessible and encrypted with the given key.
|
|
37
|
+
*
|
|
38
|
+
* @internal
|
|
39
39
|
*/
|
|
40
40
|
function _secretStorageContainsCrossSigningKeys() {
|
|
41
41
|
_secretStorageContainsCrossSigningKeys = _asyncToGenerator(function* (secretStorage) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secret-storage.js","names":["secretStorageContainsCrossSigningKeys","_x","_secretStorageContainsCrossSigningKeys","apply","arguments","_asyncToGenerator","secretStorage","secretStorageCanAccessSecrets","_x2","_x3","_secretStorageCanAccessSecrets","secretNames","defaultKeyId","getDefaultKeyId","secretName","record","isStored"],"sources":["../../src/rust-crypto/secret-storage.ts"],"sourcesContent":["/*\
|
|
1
|
+
{"version":3,"file":"secret-storage.js","names":["secretStorageContainsCrossSigningKeys","_x","_secretStorageContainsCrossSigningKeys","apply","arguments","_asyncToGenerator","secretStorage","secretStorageCanAccessSecrets","_x2","_x3","_secretStorageCanAccessSecrets","secretNames","defaultKeyId","getDefaultKeyId","secretName","record","isStored"],"sources":["../../src/rust-crypto/secret-storage.ts"],"sourcesContent":["/*\nCopyright 2023 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { type SecretStorageKey, type ServerSideSecretStorage } from \"../secret-storage.ts\";\n\n/**\n * Check that the private cross signing keys (master, self signing, user signing) are stored in the secret storage and encrypted with the default secret storage key.\n *\n * @param secretStorage - The secret store using account data\n * @returns True if the cross-signing keys are all stored and encrypted with the same secret storage key.\n *\n * @internal\n */\nexport async function secretStorageContainsCrossSigningKeys(secretStorage: ServerSideSecretStorage): Promise<boolean> {\n return secretStorageCanAccessSecrets(secretStorage, [\n \"m.cross_signing.master\",\n \"m.cross_signing.user_signing\",\n \"m.cross_signing.self_signing\",\n ]);\n}\n\n/**\n *\n * Check that the secret storage can access the given secrets using the default key.\n *\n * @param secretStorage - The secret store using account data\n * @param secretNames - The secret names to check\n * @returns True if all the given secrets are accessible and encrypted with the given key.\n *\n * @internal\n */\nexport async function secretStorageCanAccessSecrets(\n secretStorage: ServerSideSecretStorage,\n secretNames: SecretStorageKey[],\n): Promise<boolean> {\n const defaultKeyId = await secretStorage.getDefaultKeyId();\n if (!defaultKeyId) return false;\n\n for (const secretName of secretNames) {\n // check which keys this particular secret is encrypted with\n const record = (await secretStorage.isStored(secretName)) || {};\n // if it's not encrypted with the right key, there is no point continuing\n if (!(defaultKeyId in record)) return false;\n }\n\n return true;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAsBA,qCAAqCA,CAAAC,EAAA;EAAA,OAAAC,sCAAA,CAAAC,KAAA,OAAAC,SAAA;AAAA;;AAQ3D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AATA,SAAAF,uCAAA;EAAAA,sCAAA,GAAAG,iBAAA,CARO,WAAqDC,aAAsC,EAAoB;IAClH,OAAOC,6BAA6B,CAACD,aAAa,EAAE,CAChD,wBAAwB,EACxB,8BAA8B,EAC9B,8BAA8B,CACjC,CAAC;EACN,CAAC;EAAA,OAAAJ,sCAAA,CAAAC,KAAA,OAAAC,SAAA;AAAA;AAYD,gBAAsBG,6BAA6BA,CAAAC,GAAA,EAAAC,GAAA;EAAA,OAAAC,8BAAA,CAAAP,KAAA,OAAAC,SAAA;AAAA;AAelD,SAAAM,+BAAA;EAAAA,8BAAA,GAAAL,iBAAA,CAfM,WACHC,aAAsC,EACtCK,WAA+B,EACf;IAChB,IAAMC,YAAY,SAASN,aAAa,CAACO,eAAe,CAAC,CAAC;IAC1D,IAAI,CAACD,YAAY,EAAE,OAAO,KAAK;IAE/B,KAAK,IAAME,UAAU,IAAIH,WAAW,EAAE;MAClC;MACA,IAAMI,MAAM,GAAG,OAAOT,aAAa,CAACU,QAAQ,CAACF,UAAU,CAAC,KAAK,CAAC,CAAC;MAC/D;MACA,IAAI,EAAEF,YAAY,IAAIG,MAAM,CAAC,EAAE,OAAO,KAAK;IAC/C;IAEA,OAAO,IAAI;EACf,CAAC;EAAA,OAAAL,8BAAA,CAAAP,KAAA,OAAAC,SAAA;AAAA","ignoreList":[]}
|
package/lib/service-types.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2019 - 2021 The Matrix.org Foundation C.I.C.
|
|
3
|
-
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
|
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2019 - 2021 The Matrix.org Foundation C.I.C.
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
export var SERVICE_TYPES = /*#__PURE__*/function (SERVICE_TYPES) {
|
package/lib/service-types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-types.js","names":["SERVICE_TYPES"],"sources":["../src/service-types.ts"],"sourcesContent":["/*\
|
|
1
|
+
{"version":3,"file":"service-types.js","names":["SERVICE_TYPES"],"sources":["../src/service-types.ts"],"sourcesContent":["/*\nCopyright 2019 - 2021 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 SERVICE_TYPES {\n IS = \"SERVICE_TYPE_IS\", // An identity server\n IM = \"SERVICE_TYPE_IM\", // An integration manager\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,WAAYA,aAAa,0BAAbA,aAAa;EAAbA,aAAa;EACG;EADhBA,aAAa,4BAEG;EAAA,OAFhBA,aAAa;AAAA","ignoreList":[]}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2021 The Matrix.org Foundation C.I.C.
|
|
3
|
-
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
|
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2021 The Matrix.org Foundation C.I.C.
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { TypedEventEmitter } from "../models/typed-event-emitter.js";
|
|
@@ -24,13 +24,13 @@ export var LocalStorageErrors = /*#__PURE__*/function (LocalStorageErrors) {
|
|
|
24
24
|
LocalStorageErrors["QuotaExceededError"] = "QuotaExceededError";
|
|
25
25
|
return LocalStorageErrors;
|
|
26
26
|
}({});
|
|
27
|
-
/**
|
|
28
|
-
* Used in element-web as a temporary hack to handle all the localStorage errors on the highest level possible
|
|
29
|
-
* As of 15.11.2021 (DD/MM/YYYY) we're not properly handling local storage exceptions anywhere.
|
|
30
|
-
* This store, as an event emitter, is used to re-emit local storage exceptions so that we can handle them
|
|
31
|
-
* and show some kind of a "It's dead Jim" modal to the users, telling them that hey,
|
|
32
|
-
* maybe you should check out your disk, as it's probably dying and your session may die with it.
|
|
33
|
-
* See: https://github.com/vector-im/element-web/issues/18423
|
|
27
|
+
/**
|
|
28
|
+
* Used in element-web as a temporary hack to handle all the localStorage errors on the highest level possible
|
|
29
|
+
* As of 15.11.2021 (DD/MM/YYYY) we're not properly handling local storage exceptions anywhere.
|
|
30
|
+
* This store, as an event emitter, is used to re-emit local storage exceptions so that we can handle them
|
|
31
|
+
* and show some kind of a "It's dead Jim" modal to the users, telling them that hey,
|
|
32
|
+
* maybe you should check out your disk, as it's probably dying and your session may die with it.
|
|
33
|
+
* See: https://github.com/vector-im/element-web/issues/18423
|
|
34
34
|
*/
|
|
35
35
|
class LocalStorageErrorsEventsEmitter extends TypedEventEmitter {}
|
|
36
36
|
export var localStorageErrorsEventsEmitter = new LocalStorageErrorsEventsEmitter();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-storage-events-emitter.js","names":["TypedEventEmitter","LocalStorageErrors","LocalStorageErrorsEventsEmitter","localStorageErrorsEventsEmitter"],"sources":["../../src/store/local-storage-events-emitter.ts"],"sourcesContent":["/*\
|
|
1
|
+
{"version":3,"file":"local-storage-events-emitter.js","names":["TypedEventEmitter","LocalStorageErrors","LocalStorageErrorsEventsEmitter","localStorageErrorsEventsEmitter"],"sources":["../../src/store/local-storage-events-emitter.ts"],"sourcesContent":["/*\nCopyright 2021 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 { TypedEventEmitter } from \"../models/typed-event-emitter.ts\";\n\nexport enum LocalStorageErrors {\n Global = \"Global\",\n SetItemError = \"setItem\",\n GetItemError = \"getItem\",\n RemoveItemError = \"removeItem\",\n ClearError = \"clear\",\n QuotaExceededError = \"QuotaExceededError\",\n}\n\ntype EventHandlerMap = {\n [LocalStorageErrors.Global]: (error: Error) => void;\n [LocalStorageErrors.SetItemError]: (error: Error) => void;\n [LocalStorageErrors.GetItemError]: (error: Error) => void;\n [LocalStorageErrors.RemoveItemError]: (error: Error) => void;\n [LocalStorageErrors.ClearError]: (error: Error) => void;\n [LocalStorageErrors.QuotaExceededError]: (error: Error) => void;\n};\n\n/**\n * Used in element-web as a temporary hack to handle all the localStorage errors on the highest level possible\n * As of 15.11.2021 (DD/MM/YYYY) we're not properly handling local storage exceptions anywhere.\n * This store, as an event emitter, is used to re-emit local storage exceptions so that we can handle them\n * and show some kind of a \"It's dead Jim\" modal to the users, telling them that hey,\n * maybe you should check out your disk, as it's probably dying and your session may die with it.\n * See: https://github.com/vector-im/element-web/issues/18423\n */\nclass LocalStorageErrorsEventsEmitter extends TypedEventEmitter<LocalStorageErrors, EventHandlerMap> {}\nexport const localStorageErrorsEventsEmitter = new LocalStorageErrorsEventsEmitter();\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,iBAAiB,QAAQ,kCAAkC;AAEpE,WAAYC,kBAAkB,0BAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA;AAkB9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,+BAA+B,SAASF,iBAAiB,CAAsC;AACrG,OAAO,IAAMG,+BAA+B,GAAG,IAAID,+BAA+B,CAAC,CAAC","ignoreList":[]}
|