@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,20 +1,20 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
/*
|
|
5
|
-
Copyright 2022 - 2023 The Matrix.org Foundation C.I.C.
|
|
6
|
-
|
|
7
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
you may not use this file except in compliance with the License.
|
|
9
|
-
You may obtain a copy of the License at
|
|
10
|
-
|
|
11
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
|
|
13
|
-
Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
See the License for the specific language governing permissions and
|
|
17
|
-
limitations under the License.
|
|
4
|
+
/*
|
|
5
|
+
Copyright 2022 - 2023 The Matrix.org Foundation C.I.C.
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
import { NamespacedValue } from "matrix-events-sdk";
|
|
@@ -24,16 +24,16 @@ import { M_POLL_KIND_DISCLOSED, M_POLL_KIND_UNDISCLOSED, M_POLL_START } from "..
|
|
|
24
24
|
import { InvalidEventError } from "./InvalidEventError.js";
|
|
25
25
|
import { ExtensibleEvent } from "./ExtensibleEvent.js";
|
|
26
26
|
|
|
27
|
-
/**
|
|
28
|
-
* Represents a poll answer. Note that this is represented as a subtype and is
|
|
29
|
-
* not registered as a parsable event - it is implied for usage exclusively
|
|
30
|
-
* within the PollStartEvent parsing.
|
|
27
|
+
/**
|
|
28
|
+
* Represents a poll answer. Note that this is represented as a subtype and is
|
|
29
|
+
* not registered as a parsable event - it is implied for usage exclusively
|
|
30
|
+
* within the PollStartEvent parsing.
|
|
31
31
|
*/
|
|
32
32
|
export class PollAnswerSubevent extends MessageEvent {
|
|
33
33
|
constructor(wireFormat) {
|
|
34
34
|
super(wireFormat);
|
|
35
|
-
/**
|
|
36
|
-
* The answer ID.
|
|
35
|
+
/**
|
|
36
|
+
* The answer ID.
|
|
37
37
|
*/
|
|
38
38
|
_defineProperty(this, "id", void 0);
|
|
39
39
|
var id = wireFormat.content.id;
|
|
@@ -51,11 +51,11 @@ export class PollAnswerSubevent extends MessageEvent {
|
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
/**
|
|
55
|
-
* Creates a new PollAnswerSubevent from ID and text.
|
|
56
|
-
* @param id - The answer ID (unique within the poll).
|
|
57
|
-
* @param text - The text.
|
|
58
|
-
* @returns The representative answer.
|
|
54
|
+
/**
|
|
55
|
+
* Creates a new PollAnswerSubevent from ID and text.
|
|
56
|
+
* @param id - The answer ID (unique within the poll).
|
|
57
|
+
* @param text - The text.
|
|
58
|
+
* @returns The representative answer.
|
|
59
59
|
*/
|
|
60
60
|
static from(id, text) {
|
|
61
61
|
return new PollAnswerSubevent({
|
|
@@ -68,39 +68,39 @@ export class PollAnswerSubevent extends MessageEvent {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
/**
|
|
72
|
-
* Represents a poll start event.
|
|
71
|
+
/**
|
|
72
|
+
* Represents a poll start event.
|
|
73
73
|
*/
|
|
74
74
|
export class PollStartEvent extends ExtensibleEvent {
|
|
75
|
-
/**
|
|
76
|
-
* Creates a new PollStartEvent from a pure format. Note that the event is *not*
|
|
77
|
-
* parsed here: it will be treated as a literal m.poll.start primary typed event.
|
|
78
|
-
* @param wireFormat - The event.
|
|
75
|
+
/**
|
|
76
|
+
* Creates a new PollStartEvent from a pure format. Note that the event is *not*
|
|
77
|
+
* parsed here: it will be treated as a literal m.poll.start primary typed event.
|
|
78
|
+
* @param wireFormat - The event.
|
|
79
79
|
*/
|
|
80
80
|
constructor(wireFormat) {
|
|
81
81
|
super(wireFormat);
|
|
82
|
-
/**
|
|
83
|
-
* The question being asked, as a MessageEvent node.
|
|
82
|
+
/**
|
|
83
|
+
* The question being asked, as a MessageEvent node.
|
|
84
84
|
*/
|
|
85
85
|
_defineProperty(this, "question", void 0);
|
|
86
|
-
/**
|
|
87
|
-
* The interpreted kind of poll. Note that this will infer a value that is known to the
|
|
88
|
-
* SDK rather than verbatim - this means unknown types will be represented as undisclosed
|
|
89
|
-
* polls.
|
|
90
|
-
*
|
|
91
|
-
* To get the raw kind, use rawKind.
|
|
86
|
+
/**
|
|
87
|
+
* The interpreted kind of poll. Note that this will infer a value that is known to the
|
|
88
|
+
* SDK rather than verbatim - this means unknown types will be represented as undisclosed
|
|
89
|
+
* polls.
|
|
90
|
+
*
|
|
91
|
+
* To get the raw kind, use rawKind.
|
|
92
92
|
*/
|
|
93
93
|
_defineProperty(this, "kind", void 0);
|
|
94
|
-
/**
|
|
95
|
-
* The true kind as provided by the event sender. Might not be valid.
|
|
94
|
+
/**
|
|
95
|
+
* The true kind as provided by the event sender. Might not be valid.
|
|
96
96
|
*/
|
|
97
97
|
_defineProperty(this, "rawKind", void 0);
|
|
98
|
-
/**
|
|
99
|
-
* The maximum number of selections a user is allowed to make.
|
|
98
|
+
/**
|
|
99
|
+
* The maximum number of selections a user is allowed to make.
|
|
100
100
|
*/
|
|
101
101
|
_defineProperty(this, "maxSelections", void 0);
|
|
102
|
-
/**
|
|
103
|
-
* The possible answers for the poll.
|
|
102
|
+
/**
|
|
103
|
+
* The possible answers for the poll.
|
|
104
104
|
*/
|
|
105
105
|
_defineProperty(this, "answers", void 0);
|
|
106
106
|
var poll = M_POLL_START.findIn(this.wireContent);
|
|
@@ -148,13 +148,13 @@ export class PollStartEvent extends ExtensibleEvent {
|
|
|
148
148
|
};
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
/**
|
|
152
|
-
* Creates a new PollStartEvent from question, answers, and metadata.
|
|
153
|
-
* @param question - The question to ask.
|
|
154
|
-
* @param answers - The answers. Should be unique within each other.
|
|
155
|
-
* @param kind - The kind of poll.
|
|
156
|
-
* @param maxSelections - The maximum number of selections. Must be 1 or higher.
|
|
157
|
-
* @returns The representative poll start event.
|
|
151
|
+
/**
|
|
152
|
+
* Creates a new PollStartEvent from question, answers, and metadata.
|
|
153
|
+
* @param question - The question to ask.
|
|
154
|
+
* @param answers - The answers. Should be unique within each other.
|
|
155
|
+
* @param kind - The kind of poll.
|
|
156
|
+
* @param maxSelections - The maximum number of selections. Must be 1 or higher.
|
|
157
|
+
* @returns The representative poll start event.
|
|
158
158
|
*/
|
|
159
159
|
static from(question, answers, kind) {
|
|
160
160
|
var maxSelections = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PollStartEvent.js","names":["NamespacedValue","MessageEvent","isEventTypeSame","M_TEXT","M_POLL_KIND_DISCLOSED","M_POLL_KIND_UNDISCLOSED","M_POLL_START","InvalidEventError","ExtensibleEvent","PollAnswerSubevent","constructor","wireFormat","_defineProperty","id","content","serialize","type","_objectSpread","serializeMMessageOnly","from","text","name","PollStartEvent","poll","findIn","wireContent","question","rawKind","kind","matches","maxSelections","Number","isFinite","max_selections","Array","isArray","answers","slice","map","a","length","isEquivalentTo","primaryEventType","concat","i","join","arguments","undefined","makeId","LETTERS","charAt","Math","floor","random"],"sources":["../../src/extensible_events_v1/PollStartEvent.ts"],"sourcesContent":["/*\r\nCopyright 2022 - 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 { NamespacedValue } from \"matrix-events-sdk\";\r\n\r\nimport { MessageEvent } from \"./MessageEvent.ts\";\r\nimport { type ExtensibleEventType, type IPartialEvent, isEventTypeSame, M_TEXT } from \"../@types/extensible_events.ts\";\r\nimport {\r\n type KnownPollKind,\r\n M_POLL_KIND_DISCLOSED,\r\n M_POLL_KIND_UNDISCLOSED,\r\n M_POLL_START,\r\n type PollStartEventContent,\r\n type PollStartSubtype,\r\n type PollAnswer,\r\n} from \"../@types/polls.ts\";\r\nimport { InvalidEventError } from \"./InvalidEventError.ts\";\r\nimport { ExtensibleEvent } from \"./ExtensibleEvent.ts\";\r\n\r\n/**\r\n * Represents a poll answer. Note that this is represented as a subtype and is\r\n * not registered as a parsable event - it is implied for usage exclusively\r\n * within the PollStartEvent parsing.\r\n */\r\nexport class PollAnswerSubevent extends MessageEvent {\r\n /**\r\n * The answer ID.\r\n */\r\n public readonly id: string;\r\n\r\n public constructor(wireFormat: IPartialEvent<PollAnswer>) {\r\n super(wireFormat);\r\n\r\n const id = wireFormat.content.id;\r\n if (!id || typeof id !== \"string\") {\r\n throw new InvalidEventError(\"Answer ID must be a non-empty string\");\r\n }\r\n this.id = id;\r\n }\r\n\r\n public serialize(): IPartialEvent<object> {\r\n return {\r\n type: \"org.matrix.sdk.poll.answer\",\r\n content: {\r\n id: this.id,\r\n ...this.serializeMMessageOnly(),\r\n },\r\n };\r\n }\r\n\r\n /**\r\n * Creates a new PollAnswerSubevent from ID and text.\r\n * @param id - The answer ID (unique within the poll).\r\n * @param text - The text.\r\n * @returns The representative answer.\r\n */\r\n public static from(id: string, text: string): PollAnswerSubevent {\r\n return new PollAnswerSubevent({\r\n type: \"org.matrix.sdk.poll.answer\",\r\n content: {\r\n id: id,\r\n [M_TEXT.name]: text,\r\n },\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Represents a poll start event.\r\n */\r\nexport class PollStartEvent extends ExtensibleEvent<PollStartEventContent> {\r\n /**\r\n * The question being asked, as a MessageEvent node.\r\n */\r\n public readonly question: MessageEvent;\r\n\r\n /**\r\n * The interpreted kind of poll. Note that this will infer a value that is known to the\r\n * SDK rather than verbatim - this means unknown types will be represented as undisclosed\r\n * polls.\r\n *\r\n * To get the raw kind, use rawKind.\r\n */\r\n public readonly kind: KnownPollKind;\r\n\r\n /**\r\n * The true kind as provided by the event sender. Might not be valid.\r\n */\r\n public readonly rawKind: string;\r\n\r\n /**\r\n * The maximum number of selections a user is allowed to make.\r\n */\r\n public readonly maxSelections: number;\r\n\r\n /**\r\n * The possible answers for the poll.\r\n */\r\n public readonly answers: PollAnswerSubevent[];\r\n\r\n /**\r\n * Creates a new PollStartEvent from a pure format. Note that the event is *not*\r\n * parsed here: it will be treated as a literal m.poll.start primary typed event.\r\n * @param wireFormat - The event.\r\n */\r\n public constructor(wireFormat: IPartialEvent<PollStartEventContent>) {\r\n super(wireFormat);\r\n\r\n const poll = M_POLL_START.findIn<PollStartSubtype>(this.wireContent);\r\n\r\n if (!poll?.question) {\r\n throw new InvalidEventError(\"A question is required\");\r\n }\r\n\r\n this.question = new MessageEvent({ type: \"org.matrix.sdk.poll.question\", content: poll.question });\r\n\r\n this.rawKind = poll.kind;\r\n if (M_POLL_KIND_DISCLOSED.matches(this.rawKind)) {\r\n this.kind = M_POLL_KIND_DISCLOSED;\r\n } else {\r\n this.kind = M_POLL_KIND_UNDISCLOSED; // default & assumed value\r\n }\r\n\r\n this.maxSelections =\r\n Number.isFinite(poll.max_selections) && poll.max_selections! > 0 ? poll.max_selections! : 1;\r\n\r\n if (!Array.isArray(poll.answers)) {\r\n throw new InvalidEventError(\"Poll answers must be an array\");\r\n }\r\n const answers = poll.answers.slice(0, 20).map(\r\n (a) =>\r\n new PollAnswerSubevent({\r\n type: \"org.matrix.sdk.poll.answer\",\r\n content: a,\r\n }),\r\n );\r\n if (answers.length <= 0) {\r\n throw new InvalidEventError(\"No answers available\");\r\n }\r\n this.answers = answers;\r\n }\r\n\r\n public isEquivalentTo(primaryEventType: ExtensibleEventType): boolean {\r\n return isEventTypeSame(primaryEventType, M_POLL_START);\r\n }\r\n\r\n public serialize(): IPartialEvent<object> {\r\n return {\r\n type: M_POLL_START.name,\r\n content: {\r\n [M_POLL_START.name]: {\r\n question: this.question.serialize().content,\r\n kind: this.rawKind,\r\n max_selections: this.maxSelections,\r\n answers: this.answers.map((a) => a.serialize().content),\r\n },\r\n [M_TEXT.name]: `${this.question.text}\\n${this.answers.map((a, i) => `${i + 1}. ${a.text}`).join(\"\\n\")}`,\r\n },\r\n };\r\n }\r\n\r\n /**\r\n * Creates a new PollStartEvent from question, answers, and metadata.\r\n * @param question - The question to ask.\r\n * @param answers - The answers. Should be unique within each other.\r\n * @param kind - The kind of poll.\r\n * @param maxSelections - The maximum number of selections. Must be 1 or higher.\r\n * @returns The representative poll start event.\r\n */\r\n public static from(\r\n question: string,\r\n answers: string[],\r\n kind: KnownPollKind | string,\r\n maxSelections = 1,\r\n ): PollStartEvent {\r\n return new PollStartEvent({\r\n type: M_POLL_START.name,\r\n content: {\r\n [M_TEXT.name]: question, // unused by parsing\r\n [M_POLL_START.name]: {\r\n question: { [M_TEXT.name]: question },\r\n kind: kind instanceof NamespacedValue ? kind.name : kind,\r\n max_selections: maxSelections,\r\n answers: answers.map((a) => ({ id: makeId(), [M_TEXT.name]: a })),\r\n },\r\n },\r\n });\r\n }\r\n}\r\n\r\nconst LETTERS = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\";\r\nfunction makeId(): string {\r\n return [...Array(16)].map(() => LETTERS.charAt(Math.floor(Math.random() * LETTERS.length))).join(\"\");\r\n}\r\n"],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,eAAe,QAAQ,mBAAmB;AAEnD,SAASC,YAAY,QAAQ,mBAAmB;AAChD,SAAuDC,eAAe,EAAEC,MAAM,QAAQ,gCAAgC;AACtH,SAEIC,qBAAqB,EACrBC,uBAAuB,EACvBC,YAAY,QAIT,oBAAoB;AAC3B,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,eAAe,QAAQ,sBAAsB;;AAEtD;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,kBAAkB,SAASR,YAAY,CAAC;EAM1CS,WAAWA,CAACC,UAAqC,EAAE;IACtD,KAAK,CAACA,UAAU,CAAC;IANrB;AACJ;AACA;IAFIC,eAAA;IAQI,IAAMC,EAAE,GAAGF,UAAU,CAACG,OAAO,CAACD,EA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AC;QACpE;MACJ;IACJ,CAAC,CAAC;EACN;AACJ;AAEA,IAAMU,OAAO,GAAG,gEAAgE;AAChF,SAASD,MAAMA,CAAA,EAAW;EACtB,OAAO,CAAC,GAAGd,KAAK,CAAC,EAAE,CAAC,CAAC,CAACI,GAAG,CAAC,MAAMW,OAAO,CAACC,MAAM,CAACC,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,MAAM,CAAC,CAAC,GAAGJ,OAAO,CAACT,MAAM,CAAC,CAAC,CAAC,CAACK,IAAI,CAAC,EAAE,CAAC;AACxG","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"PollStartEvent.js","names":["NamespacedValue","MessageEvent","isEventTypeSame","M_TEXT","M_POLL_KIND_DISCLOSED","M_POLL_KIND_UNDISCLOSED","M_POLL_START","InvalidEventError","ExtensibleEvent","PollAnswerSubevent","constructor","wireFormat","_defineProperty","id","content","serialize","type","_objectSpread","serializeMMessageOnly","from","text","name","PollStartEvent","poll","findIn","wireContent","question","rawKind","kind","matches","maxSelections","Number","isFinite","max_selections","Array","isArray","answers","slice","map","a","length","isEquivalentTo","primaryEventType","concat","i","join","arguments","undefined","makeId","LETTERS","charAt","Math","floor","random"],"sources":["../../src/extensible_events_v1/PollStartEvent.ts"],"sourcesContent":["/*\nCopyright 2022 - 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 { NamespacedValue } from \"matrix-events-sdk\";\n\nimport { MessageEvent } from \"./MessageEvent.ts\";\nimport { type ExtensibleEventType, type IPartialEvent, isEventTypeSame, M_TEXT } from \"../@types/extensible_events.ts\";\nimport {\n type KnownPollKind,\n M_POLL_KIND_DISCLOSED,\n M_POLL_KIND_UNDISCLOSED,\n M_POLL_START,\n type PollStartEventContent,\n type PollStartSubtype,\n type PollAnswer,\n} from \"../@types/polls.ts\";\nimport { InvalidEventError } from \"./InvalidEventError.ts\";\nimport { ExtensibleEvent } from \"./ExtensibleEvent.ts\";\n\n/**\n * Represents a poll answer. Note that this is represented as a subtype and is\n * not registered as a parsable event - it is implied for usage exclusively\n * within the PollStartEvent parsing.\n */\nexport class PollAnswerSubevent extends MessageEvent {\n /**\n * The answer ID.\n */\n public readonly id: string;\n\n public constructor(wireFormat: IPartialEvent<PollAnswer>) {\n super(wireFormat);\n\n const id = wireFormat.content.id;\n if (!id || typeof id !== \"string\") {\n throw new InvalidEventError(\"Answer ID must be a non-empty string\");\n }\n this.id = id;\n }\n\n public serialize(): IPartialEvent<object> {\n return {\n type: \"org.matrix.sdk.poll.answer\",\n content: {\n id: this.id,\n ...this.serializeMMessageOnly(),\n },\n };\n }\n\n /**\n * Creates a new PollAnswerSubevent from ID and text.\n * @param id - The answer ID (unique within the poll).\n * @param text - The text.\n * @returns The representative answer.\n */\n public static from(id: string, text: string): PollAnswerSubevent {\n return new PollAnswerSubevent({\n type: \"org.matrix.sdk.poll.answer\",\n content: {\n id: id,\n [M_TEXT.name]: text,\n },\n });\n }\n}\n\n/**\n * Represents a poll start event.\n */\nexport class PollStartEvent extends ExtensibleEvent<PollStartEventContent> {\n /**\n * The question being asked, as a MessageEvent node.\n */\n public readonly question: MessageEvent;\n\n /**\n * The interpreted kind of poll. Note that this will infer a value that is known to the\n * SDK rather than verbatim - this means unknown types will be represented as undisclosed\n * polls.\n *\n * To get the raw kind, use rawKind.\n */\n public readonly kind: KnownPollKind;\n\n /**\n * The true kind as provided by the event sender. Might not be valid.\n */\n public readonly rawKind: string;\n\n /**\n * The maximum number of selections a user is allowed to make.\n */\n public readonly maxSelections: number;\n\n /**\n * The possible answers for the poll.\n */\n public readonly answers: PollAnswerSubevent[];\n\n /**\n * Creates a new PollStartEvent from a pure format. Note that the event is *not*\n * parsed here: it will be treated as a literal m.poll.start primary typed event.\n * @param wireFormat - The event.\n */\n public constructor(wireFormat: IPartialEvent<PollStartEventContent>) {\n super(wireFormat);\n\n const poll = M_POLL_START.findIn<PollStartSubtype>(this.wireContent);\n\n if (!poll?.question) {\n throw new InvalidEventError(\"A question is required\");\n }\n\n this.question = new MessageEvent({ type: \"org.matrix.sdk.poll.question\", content: poll.question });\n\n this.rawKind = poll.kind;\n if (M_POLL_KIND_DISCLOSED.matches(this.rawKind)) {\n this.kind = M_POLL_KIND_DISCLOSED;\n } else {\n this.kind = M_POLL_KIND_UNDISCLOSED; // default & assumed value\n }\n\n this.maxSelections =\n Number.isFinite(poll.max_selections) && poll.max_selections! > 0 ? poll.max_selections! : 1;\n\n if (!Array.isArray(poll.answers)) {\n throw new InvalidEventError(\"Poll answers must be an array\");\n }\n const answers = poll.answers.slice(0, 20).map(\n (a) =>\n new PollAnswerSubevent({\n type: \"org.matrix.sdk.poll.answer\",\n content: a,\n }),\n );\n if (answers.length <= 0) {\n throw new InvalidEventError(\"No answers available\");\n }\n this.answers = answers;\n }\n\n public isEquivalentTo(primaryEventType: ExtensibleEventType): boolean {\n return isEventTypeSame(primaryEventType, M_POLL_START);\n }\n\n public serialize(): IPartialEvent<object> {\n return {\n type: M_POLL_START.name,\n content: {\n [M_POLL_START.name]: {\n question: this.question.serialize().content,\n kind: this.rawKind,\n max_selections: this.maxSelections,\n answers: this.answers.map((a) => a.serialize().content),\n },\n [M_TEXT.name]: `${this.question.text}\\n${this.answers.map((a, i) => `${i + 1}. ${a.text}`).join(\"\\n\")}`,\n },\n };\n }\n\n /**\n * Creates a new PollStartEvent from question, answers, and metadata.\n * @param question - The question to ask.\n * @param answers - The answers. Should be unique within each other.\n * @param kind - The kind of poll.\n * @param maxSelections - The maximum number of selections. Must be 1 or higher.\n * @returns The representative poll start event.\n */\n public static from(\n question: string,\n answers: string[],\n kind: KnownPollKind | string,\n maxSelections = 1,\n ): PollStartEvent {\n return new PollStartEvent({\n type: M_POLL_START.name,\n content: {\n [M_TEXT.name]: question, // unused by parsing\n [M_POLL_START.name]: {\n question: { [M_TEXT.name]: question },\n kind: kind instanceof NamespacedValue ? kind.name : kind,\n max_selections: maxSelections,\n answers: answers.map((a) => ({ id: makeId(), [M_TEXT.name]: a })),\n },\n },\n });\n }\n}\n\nconst LETTERS = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\";\nfunction makeId(): string {\n return [...Array(16)].map(() => LETTERS.charAt(Math.floor(Math.random() * LETTERS.length))).join(\"\");\n}\n"],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,eAAe,QAAQ,mBAAmB;AAEnD,SAASC,YAAY,QAAQ,mBAAmB;AAChD,SAAuDC,eAAe,EAAEC,MAAM,QAAQ,gCAAgC;AACtH,SAEIC,qBAAqB,EACrBC,uBAAuB,EACvBC,YAAY,QAIT,oBAAoB;AAC3B,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,eAAe,QAAQ,sBAAsB;;AAEtD;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,kBAAkB,SAASR,YAAY,CAAC;EAM1CS,WAAWA,CAACC,UAAqC,EAAE;IACtD,KAAK,CAACA,UAAU,CAAC;IANrB;AACJ;AACA;IAFIC,eAAA;IAQI,IAAMC,EAAE,GAAGF,UAAU,CAACG,OAAO,CAACD,EAAE;IAChC,IAAI,CAACA,EAAE,IAAI,OAAOA,EAAE,KAAK,QAAQ,EAAE;MAC/B,MAAM,IAAIN,iBAAiB,CAAC,sCAAsC,CAAC;IACvE;IACA,IAAI,CAACM,EAAE,GAAGA,EAAE;EAChB;EAEOE,SAASA,CAAA,EAA0B;IACtC,OAAO;MACHC,IAAI,EAAE,4BAA4B;MAClCF,OAAO,EAAAG,aAAA;QACHJ,EAAE,E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AAGJ,OAAO,CAACT,MAAM,CAAC,CAAC,CAAC,CAACK,IAAI,CAAC,EAAE,CAAC;AACxG","ignoreList":[]}
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2021 - 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 2021 - 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
|
-
/**
|
|
18
|
-
* Determines if the given optional was provided a value.
|
|
19
|
-
* @param s - The optional to test.
|
|
20
|
-
* @returns True if the value is defined.
|
|
17
|
+
/**
|
|
18
|
+
* Determines if the given optional was provided a value.
|
|
19
|
+
* @param s - The optional to test.
|
|
20
|
+
* @returns True if the value is defined.
|
|
21
21
|
*/
|
|
22
22
|
export function isProvided(s) {
|
|
23
23
|
return s !== null && s !== undefined;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
/**
|
|
27
|
-
* Determines if the given optional string is a defined string.
|
|
28
|
-
* @param s - The input string.
|
|
29
|
-
* @returns True if the input is a defined string.
|
|
26
|
+
/**
|
|
27
|
+
* Determines if the given optional string is a defined string.
|
|
28
|
+
* @param s - The input string.
|
|
29
|
+
* @returns True if the input is a defined string.
|
|
30
30
|
*/
|
|
31
31
|
export function isOptionalAString(s) {
|
|
32
32
|
return isProvided(s) && typeof s === "string";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.js","names":["isProvided","s","undefined","isOptionalAString"],"sources":["../../src/extensible_events_v1/utilities.ts"],"sourcesContent":["/*\
|
|
1
|
+
{"version":3,"file":"utilities.js","names":["isProvided","s","undefined","isOptionalAString"],"sources":["../../src/extensible_events_v1/utilities.ts"],"sourcesContent":["/*\nCopyright 2021 - 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 Optional } from \"matrix-events-sdk\";\n\n/**\n * Determines if the given optional was provided a value.\n * @param s - The optional to test.\n * @returns True if the value is defined.\n */\nexport function isProvided<T>(s: Optional<T>): s is T {\n return s !== null && s !== undefined;\n}\n\n/**\n * Determines if the given optional string is a defined string.\n * @param s - The input string.\n * @returns True if the input is a defined string.\n */\nexport function isOptionalAString(s: Optional<string>): s is string {\n return isProvided(s) && typeof s === \"string\";\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,UAAUA,CAAIC,CAAc,EAAU;EAClD,OAAOA,CAAC,KAAK,IAAI,IAAIA,CAAC,KAAKC,SAAS;AACxC;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAACF,CAAmB,EAAe;EAChE,OAAOD,UAAU,CAACC,CAAC,CAAC,IAAI,OAAOA,CAAC,KAAK,QAAQ;AACjD","ignoreList":[]}
|
package/lib/feature.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
-
/*
|
|
3
|
-
Copyright 2022 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 2022 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
18
|
export var ServerSupport = /*#__PURE__*/function (ServerSupport) {
|
|
@@ -24,8 +24,8 @@ export var ServerSupport = /*#__PURE__*/function (ServerSupport) {
|
|
|
24
24
|
export var Feature = /*#__PURE__*/function (Feature) {
|
|
25
25
|
Feature["Thread"] = "Thread";
|
|
26
26
|
Feature["ThreadUnreadNotifications"] = "ThreadUnreadNotifications";
|
|
27
|
-
/**
|
|
28
|
-
* @deprecated this is now exposed as a capability not a feature
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated this is now exposed as a capability not a feature
|
|
29
29
|
*/
|
|
30
30
|
Feature["LoginTokenRequest"] = "LoginTokenRequest";
|
|
31
31
|
Feature["RelationBasedRedactions"] = "RelationBasedRedactions";
|
package/lib/feature.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature.js","names":["ServerSupport","Feature","featureSupportResolver","Thread","unstablePrefixes","matrixVersion","ThreadUnreadNotifications","LoginTokenRequest","RelationBasedRedactions","AccountDataDeletion","RelationsRecursion","IntentionalMentions","buildFeatureSupportMap","_x","_buildFeatureSupportMap","apply","arguments","_asyncToGenerator","versions","supportMap","Map","feature","supportCondition","Object","entries","_versions$versions$in","_versions$versions","_supportCondition$uns","_supportCondition$uns2","supportMatrixVersion","includes","supportUnstablePrefixes","every","unstablePrefix","_versions$unstable_fe","unstable_features","set","Stable","Unstable","Unsupported"],"sources":["../src/feature.ts"],"sourcesContent":["/*\
|
|
1
|
+
{"version":3,"file":"feature.js","names":["ServerSupport","Feature","featureSupportResolver","Thread","unstablePrefixes","matrixVersion","ThreadUnreadNotifications","LoginTokenRequest","RelationBasedRedactions","AccountDataDeletion","RelationsRecursion","IntentionalMentions","buildFeatureSupportMap","_x","_buildFeatureSupportMap","apply","arguments","_asyncToGenerator","versions","supportMap","Map","feature","supportCondition","Object","entries","_versions$versions$in","_versions$versions","_supportCondition$uns","_supportCondition$uns2","supportMatrixVersion","includes","supportUnstablePrefixes","every","unstablePrefix","_versions$unstable_fe","unstable_features","set","Stable","Unstable","Unsupported"],"sources":["../src/feature.ts"],"sourcesContent":["/*\nCopyright 2022 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { type IServerVersions } from \"./client.ts\";\n\nexport enum ServerSupport {\n Stable,\n Unstable,\n Unsupported,\n}\n\nexport enum Feature {\n Thread = \"Thread\",\n ThreadUnreadNotifications = \"ThreadUnreadNotifications\",\n /**\n * @deprecated this is now exposed as a capability not a feature\n */\n LoginTokenRequest = \"LoginTokenRequest\",\n RelationBasedRedactions = \"RelationBasedRedactions\",\n AccountDataDeletion = \"AccountDataDeletion\",\n RelationsRecursion = \"RelationsRecursion\",\n IntentionalMentions = \"IntentionalMentions\",\n}\n\ntype FeatureSupportCondition = {\n unstablePrefixes?: string[];\n matrixVersion?: string;\n};\n\nconst featureSupportResolver: Record<string, FeatureSupportCondition> = {\n [Feature.Thread]: {\n unstablePrefixes: [\"org.matrix.msc3440\"],\n matrixVersion: \"v1.3\",\n },\n [Feature.ThreadUnreadNotifications]: {\n unstablePrefixes: [\"org.matrix.msc3771\", \"org.matrix.msc3773\"],\n matrixVersion: \"v1.4\",\n },\n [Feature.LoginTokenRequest]: {\n unstablePrefixes: [\"org.matrix.msc3882\"],\n },\n [Feature.RelationBasedRedactions]: {\n unstablePrefixes: [\"org.matrix.msc3912\"],\n },\n [Feature.AccountDataDeletion]: {\n unstablePrefixes: [\"org.matrix.msc3391\"],\n },\n [Feature.RelationsRecursion]: {\n unstablePrefixes: [\"org.matrix.msc3981\"],\n matrixVersion: \"v1.10\",\n },\n [Feature.IntentionalMentions]: {\n unstablePrefixes: [\"org.matrix.msc3952_intentional_mentions\"],\n matrixVersion: \"v1.7\",\n },\n};\n\nexport async function buildFeatureSupportMap(versions: IServerVersions): Promise<Map<Feature, ServerSupport>> {\n const supportMap = new Map<Feature, ServerSupport>();\n for (const [feature, supportCondition] of Object.entries(featureSupportResolver)) {\n const supportMatrixVersion = versions.versions?.includes(supportCondition.matrixVersion || \"\") ?? false;\n const supportUnstablePrefixes =\n supportCondition.unstablePrefixes?.every((unstablePrefix) => {\n return versions.unstable_features?.[unstablePrefix] === true;\n }) ?? false;\n if (supportMatrixVersion) {\n supportMap.set(feature as Feature, ServerSupport.Stable);\n } else if (supportUnstablePrefixes) {\n supportMap.set(feature as Feature, ServerSupport.Unstable);\n } else {\n supportMap.set(feature as Feature, ServerSupport.Unsupported);\n }\n }\n return supportMap;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,WAAYA,aAAa,0BAAbA,aAAa;EAAbA,aAAa,CAAbA,aAAa;EAAbA,aAAa,CAAbA,aAAa;EAAbA,aAAa,CAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA;AAMzB,WAAYC,OAAO,0BAAPA,OAAO;EAAPA,OAAO;EAAPA,OAAO;EAGf;AACJ;AACA;EALYA,OAAO;EAAPA,OAAO;EAAPA,OAAO;EAAPA,OAAO;EAAPA,OAAO;EAAA,OAAPA,OAAO;AAAA;AAkBnB,IAAMC,sBAA+D,GAAG;EACpE,CAACD,OAAO,CAACE,MAAM,GAAG;IACdC,gBAAgB,EAAE,CAAC,oBAAoB,CAAC;IACxCC,aAAa,EAAE;EACnB,CAAC;EACD,CAACJ,OAAO,CAACK,yBAAyB,GAAG;IACjCF,gBAAgB,EAAE,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;IAC9DC,aAAa,EAAE;EACnB,CAAC;EACD,CAACJ,OAAO,CAACM,iBAAiB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,IAAAC,qBAAA;QACzD,OAAO,EAAAA,qBAAA,GAAAhB,QAAQ,CAACiB,iBAAiB,cAAAD,qBAAA,uBAA1BA,qBAAA,CAA6BD,cAAc,CAAC,MAAK,IAAI;MAChE,CAAC,CAAC,cAAAN,qBAAA,cAAAA,qBAAA,GAAI,KAAK;MACf,IAAIE,oBAAoB,EAAE;QACtBV,UAAU,CAACiB,GAAG,CAACf,OAAO,EAAarB,aAAa,CAACqC,MAAM,CAAC;MAC5D,CAAC,MAAM,IAAIN,uBAAuB,EAAE;QAChCZ,UAAU,CAACiB,GAAG,CAACf,OAAO,EAAarB,aAAa,CAACsC,QAAQ,CAAC;MAC9D,CAAC,MAAM;QACHnB,UAAU,CAACiB,GAAG,CAACf,OAAO,EAAarB,aAAa,CAACuC,WAAW,CAAC;MACjE;IACJ;IACA,OAAOpB,UAAU;EACrB,CAAC;EAAA,OAAAL,uBAAA,CAAAC,KAAA,OAAAC,SAAA;AAAA","ignoreList":[]}
|
package/lib/http-api/method.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2022 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 2022 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 Method = /*#__PURE__*/function (Method) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"method.js","names":["Method"],"sources":["../../src/http-api/method.ts"],"sourcesContent":["/*\
|
|
1
|
+
{"version":3,"file":"method.js","names":["Method"],"sources":["../../src/http-api/method.ts"],"sourcesContent":["/*\nCopyright 2022 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nexport enum Method {\n Get = \"GET\",\n Put = \"PUT\",\n Post = \"POST\",\n Delete = \"DELETE\",\n Options = \"OPTIONS\",\n Head = \"HEAD\",\n Patch = \"PATCH\",\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,WAAYA,MAAM,0BAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAAA,OAANA,MAAM;AAAA","ignoreList":[]}
|
package/lib/http-api/prefix.js
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2022 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 2022 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 ClientPrefix = /*#__PURE__*/function (ClientPrefix) {
|
|
18
|
-
/**
|
|
19
|
-
* A constant representing the URI path for Client-Server API endpoints versioned at v1.
|
|
18
|
+
/**
|
|
19
|
+
* A constant representing the URI path for Client-Server API endpoints versioned at v1.
|
|
20
20
|
*/
|
|
21
21
|
ClientPrefix["V1"] = "/_matrix/client/v1";
|
|
22
|
-
/**
|
|
23
|
-
* A constant representing the URI path for Client-Server API endpoints versioned at v3.
|
|
22
|
+
/**
|
|
23
|
+
* A constant representing the URI path for Client-Server API endpoints versioned at v3.
|
|
24
24
|
*/
|
|
25
25
|
ClientPrefix["V3"] = "/_matrix/client/v3";
|
|
26
|
-
/**
|
|
27
|
-
* A constant representing the URI path for as-yet unspecified Client-Server HTTP APIs.
|
|
26
|
+
/**
|
|
27
|
+
* A constant representing the URI path for as-yet unspecified Client-Server HTTP APIs.
|
|
28
28
|
*/
|
|
29
29
|
ClientPrefix["Unstable"] = "/_matrix/client/unstable";
|
|
30
30
|
return ClientPrefix;
|
|
31
31
|
}({});
|
|
32
32
|
export var IdentityPrefix = /*#__PURE__*/function (IdentityPrefix) {
|
|
33
|
-
/**
|
|
34
|
-
* URI path for the v2 identity API
|
|
33
|
+
/**
|
|
34
|
+
* URI path for the v2 identity API
|
|
35
35
|
*/
|
|
36
36
|
IdentityPrefix["V2"] = "/_matrix/identity/v2";
|
|
37
37
|
return IdentityPrefix;
|
|
38
38
|
}({});
|
|
39
39
|
export var MediaPrefix = /*#__PURE__*/function (MediaPrefix) {
|
|
40
|
-
/**
|
|
41
|
-
* A constant representing the URI path for Client-Server API Media endpoints versioned at v1.
|
|
40
|
+
/**
|
|
41
|
+
* A constant representing the URI path for Client-Server API Media endpoints versioned at v1.
|
|
42
42
|
*/
|
|
43
43
|
MediaPrefix["V1"] = "/_matrix/media/v1";
|
|
44
|
-
/**
|
|
45
|
-
* A constant representing the URI path for Client-Server API Media endpoints versioned at v3.
|
|
44
|
+
/**
|
|
45
|
+
* A constant representing the URI path for Client-Server API Media endpoints versioned at v3.
|
|
46
46
|
*/
|
|
47
47
|
MediaPrefix["V3"] = "/_matrix/media/v3";
|
|
48
48
|
return MediaPrefix;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefix.js","names":["ClientPrefix","IdentityPrefix","MediaPrefix"],"sources":["../../src/http-api/prefix.ts"],"sourcesContent":["/*\
|
|
1
|
+
{"version":3,"file":"prefix.js","names":["ClientPrefix","IdentityPrefix","MediaPrefix"],"sources":["../../src/http-api/prefix.ts"],"sourcesContent":["/*\nCopyright 2022 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nexport enum ClientPrefix {\n /**\n * A constant representing the URI path for Client-Server API endpoints versioned at v1.\n */\n V1 = \"/_matrix/client/v1\",\n /**\n * A constant representing the URI path for Client-Server API endpoints versioned at v3.\n */\n V3 = \"/_matrix/client/v3\",\n /**\n * A constant representing the URI path for as-yet unspecified Client-Server HTTP APIs.\n */\n Unstable = \"/_matrix/client/unstable\",\n}\n\nexport enum IdentityPrefix {\n /**\n * URI path for the v2 identity API\n */\n V2 = \"/_matrix/identity/v2\",\n}\n\nexport enum MediaPrefix {\n /**\n * A constant representing the URI path for Client-Server API Media endpoints versioned at v1.\n */\n V1 = \"/_matrix/media/v1\",\n /**\n * A constant representing the URI path for Client-Server API Media endpoints versioned at v3.\n */\n V3 = \"/_matrix/media/v3\",\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,WAAYA,YAAY,0BAAZA,YAAY;EACpB;AACJ;AACA;EAHYA,YAAY;EAKpB;AACJ;AACA;EAPYA,YAAY;EASpB;AACJ;AACA;EAXYA,YAAY;EAAA,OAAZA,YAAY;AAAA;AAexB,WAAYC,cAAc,0BAAdA,cAAc;EACtB;AACJ;AACA;EAHYA,cAAc;EAAA,OAAdA,cAAc;AAAA;AAO1B,WAAYC,WAAW,0BAAXA,WAAW;EACnB;AACJ;AACA;EAHYA,WAAW;EAKnB;AACJ;AACA;EAPYA,WAAW;EAAA,OAAXA,WAAW;AAAA","ignoreList":[]}
|
package/lib/indexeddb-helpers.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2019 New Vector Ltd
|
|
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 New Vector Ltd
|
|
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
|
-
/**
|
|
18
|
-
* Check if an IndexedDB database exists. The only way to do so is to try opening it, so
|
|
19
|
-
* we do that and then delete it did not exist before.
|
|
20
|
-
*
|
|
21
|
-
* @param indexedDB - The `indexedDB` interface
|
|
22
|
-
* @param dbName - The database name to test for
|
|
23
|
-
* @returns Whether the database exists
|
|
17
|
+
/**
|
|
18
|
+
* Check if an IndexedDB database exists. The only way to do so is to try opening it, so
|
|
19
|
+
* we do that and then delete it did not exist before.
|
|
20
|
+
*
|
|
21
|
+
* @param indexedDB - The `indexedDB` interface
|
|
22
|
+
* @param dbName - The database name to test for
|
|
23
|
+
* @returns Whether the database exists
|
|
24
24
|
*/
|
|
25
25
|
export function exists(indexedDB, dbName) {
|
|
26
26
|
return new Promise((resolve, reject) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexeddb-helpers.js","names":["exists","indexedDB","dbName","Promise","resolve","reject","req","open","onupgradeneeded","onblocked","error","onsuccess","db","result","close","deleteDatabase","onerror"],"sources":["../src/indexeddb-helpers.ts"],"sourcesContent":["/*\
|
|
1
|
+
{"version":3,"file":"indexeddb-helpers.js","names":["exists","indexedDB","dbName","Promise","resolve","reject","req","open","onupgradeneeded","onblocked","error","onsuccess","db","result","close","deleteDatabase","onerror"],"sources":["../src/indexeddb-helpers.ts"],"sourcesContent":["/*\nCopyright 2019 New Vector Ltd\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\n/**\n * Check if an IndexedDB database exists. The only way to do so is to try opening it, so\n * we do that and then delete it did not exist before.\n *\n * @param indexedDB - The `indexedDB` interface\n * @param dbName - The database name to test for\n * @returns Whether the database exists\n */\nexport function exists(indexedDB: IDBFactory, dbName: string): Promise<boolean> {\n return new Promise<boolean>((resolve, reject) => {\n let exists = true;\n const req = indexedDB.open(dbName);\n req.onupgradeneeded = (): void => {\n // Since we did not provide an explicit version when opening, this event\n // should only fire if the DB did not exist before at any version.\n exists = false;\n };\n req.onblocked = (): void => reject(req.error);\n req.onsuccess = (): void => {\n const db = req.result;\n db.close();\n if (!exists) {\n // The DB did not exist before, but has been created as part of this\n // existence check. Delete it now to restore previous state. Delete can\n // actually take a while to complete in some browsers, so don't wait for\n // it. This won't block future open calls that a store might issue next to\n // properly set up the DB.\n indexedDB.deleteDatabase(dbName);\n }\n resolve(exists);\n };\n req.onerror = (): void => reject(req.error);\n });\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,MAAMA,CAACC,SAAqB,EAAEC,MAAc,EAAoB;EAC5E,OAAO,IAAIC,OAAO,CAAU,CAACC,OAAO,EAAEC,MAAM,KAAK;IAC7C,IAAIL,MAAM,GAAG,IAAI;IACjB,IAAMM,GAAG,GAAGL,SAAS,CAACM,IAAI,CAACL,MAAM,CAAC;IAClCI,GAAG,CAACE,eAAe,GAAG,MAAY;MAC9B;MACA;MACAR,MAAM,GAAG,KAAK;IAClB,CAAC;IACDM,GAAG,CAACG,SAAS,GAAG,MAAYJ,MAAM,CAACC,GAAG,CAACI,KAAK,CAAC;IAC7CJ,GAAG,CAACK,SAAS,GAAG,MAAY;MACxB,IAAMC,EAAE,GAAGN,GAAG,CAACO,MAAM;MACrBD,EAAE,CAACE,KAAK,CAAC,CAAC;MACV,IAAI,CAACd,MAAM,EAAE;QACT;QACA;QACA;QACA;QACA;QACAC,SAAS,CAACc,cAAc,CAACb,MAAM,CAAC;MACpC;MACAE,OAAO,CAACJ,MAAM,CAAC;IACnB,CAAC;IACDM,GAAG,CAACU,OAAO,GAAG,MAAYX,MAAM,CAACC,GAAG,CAACI,KAAK,CAAC;EAC/C,CAAC,CAAC;AACN","ignoreList":[]}
|
package/lib/indexeddb-worker.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2017 Vector Creations Ltd
|
|
3
|
-
Copyright 2019 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.
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2017 Vector Creations Ltd
|
|
3
|
+
Copyright 2019 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
|
-
* Separate exports file for the indexeddb web worker, which is designed
|
|
20
|
-
* to be used separately
|
|
18
|
+
/**
|
|
19
|
+
* Separate exports file for the indexeddb web worker, which is designed
|
|
20
|
+
* to be used separately
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
23
|
/** The {@link IndexedDBStoreWorker} class. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexeddb-worker.js","names":["IndexedDBStoreWorker"],"sources":["../src/indexeddb-worker.ts"],"sourcesContent":["/*\
|
|
1
|
+
{"version":3,"file":"indexeddb-worker.js","names":["IndexedDBStoreWorker"],"sources":["../src/indexeddb-worker.ts"],"sourcesContent":["/*\nCopyright 2017 Vector Creations Ltd\nCopyright 2019 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\n/**\n * Separate exports file for the indexeddb web worker, which is designed\n * to be used separately\n */\n\n/** The {@link IndexedDBStoreWorker} class. */\nexport { IndexedDBStoreWorker } from \"./store/indexeddb-store-worker.ts\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,SAASA,oBAAoB,QAAQ,mCAAmC","ignoreList":[]}
|