@openclaw/matrix 2026.7.1-beta.1 → 2026.7.1-beta.4
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/dist/{account-selection-Bv_ZuOu4.js → account-selection-5e4mHR1m.js} +1 -1
- package/dist/api.js +5 -5
- package/dist/{approval-handler.runtime-GpL8SxX2.js → approval-handler.runtime-DI5x9r8I.js} +5 -5
- package/dist/{approval-ids-DIKCZewR.js → approval-ids-ZgqbspmS.js} +1 -1
- package/dist/{approval-reaction-auth-DhBxqiQQ.js → approval-reaction-auth-D9LijQhr.js} +2 -2
- package/dist/{approval-reactions-BRGQgOu2.js → approval-reactions-BdUaUXVw.js} +24 -73
- package/dist/auth-presence.js +1 -1
- package/dist/{channel-CGc6D4tf.js → channel-jUTBsjHU.js} +21 -23
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel.runtime-CPu_uwsn.js → channel.runtime-DO1Nv9ed.js} +26 -17
- package/dist/{cli-BfwYmyEc.js → cli-CEfWwCKx.js} +10 -17
- package/dist/{cli-metadata-FO-fJqf0.js → cli-metadata-CfiEO-CE.js} +1 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/{client-CVluBRDh.js → client-FRuyCNju.js} +2 -2
- package/dist/{client-bootstrap-1cbA9aSs.js → client-bootstrap-DjFJ7e0N.js} +6 -10
- package/dist/{client-Cb5ILtpE.js → client-tgnlQJk4.js} +2 -2
- package/dist/{config-schema-DFRmUTAG.js → config-schema-DtnhNYd-.js} +1 -1
- package/dist/contract-api.js +2 -2
- package/dist/{create-client-8YNurIAr.js → create-client-CNakT7zF.js} +7 -10
- package/dist/{credentials-G8lNmiME.js → credentials-Ds9V1mn2.js} +1 -1
- package/dist/{credentials-read-TzTOQPOM.js → credentials-read-BlkvsNFg.js} +1 -1
- package/dist/{credentials-write.runtime-cZhhyGAZ.js → credentials-write.runtime-CTqqxcut.js} +2 -5
- package/dist/{crypto-runtime-hMMmqNr1.js → crypto-runtime-B74cTS6A.js} +11 -9
- package/dist/{crypto-state-store-DK2tcEyP.js → crypto-state-store-Jy3qwhdy.js} +1 -1
- package/dist/{deps-D3bkh48_.js → deps-CdjHvnmh.js} +20 -2
- package/dist/{directory-live-pjbvjDz2.js → directory-live-Ufd4qSpX.js} +2 -2
- package/dist/{doctor-BRSDNU5C.js → doctor-DfaOqFtr.js} +3 -3
- package/dist/{doctor-contract-Dq8OZWHF.js → doctor-contract-BAja_fmb.js} +1 -1
- package/dist/doctor-contract-api.js +8 -14
- package/dist/{draft-stream-Djasj65z.js → draft-stream-D4EH25gv.js} +1 -1
- package/dist/{encryption-guidance-Bg3IRYoX.js → encryption-guidance-D8walY04.js} +1 -1
- package/dist/{file-sync-store-BWLVB01Y.js → file-sync-store-DVm0ACml.js} +3 -3
- package/dist/helper-api.js +1 -1
- package/dist/{idb-persistence-BGY1CJ7J.js → idb-persistence-BHm97th-.js} +1 -1
- package/dist/index.js +3 -6
- package/dist/{legacy-crypto-inspector-D_8iylBq.js → legacy-crypto-inspector-vzXSkm18.js} +1 -1
- package/dist/{legacy-crypto-restore-B0gcIEkE.js → legacy-crypto-restore-CIBfOmLn.js} +2 -2
- package/dist/{matrix-migration.runtime-Ctlb_rZl.js → matrix-migration.runtime-BMCyrANT.js} +3 -3
- package/dist/{media-text-CUFW_BP5.js → media-text-p-LP21qs.js} +1 -1
- package/dist/{messages-C1dIZHKy.js → messages-DRKkiEY-.js} +6 -5
- package/dist/{monitor-BMGnvIbg.js → monitor-CsGOGdwu.js} +89 -119
- package/dist/plugin-entry.handlers.runtime.js +2 -5
- package/dist/probe.runtime-2MZLc6ng.js +3 -0
- package/dist/{profile-update-BaEk4COs.js → profile-update-Ucc8RrJL.js} +2 -2
- package/dist/{reaction-events-n69MjKzG.js → reaction-events-DentrVii.js} +5 -12
- package/dist/{recovery-key-store-BGk8c_gf.js → recovery-key-store-DSeLFvNx.js} +1 -1
- package/dist/{resolve-targets-DyGW9WzC.js → resolve-targets-DcV_KfgX.js} +1 -1
- package/dist/{resolver.runtime-DhZV369r.js → resolver.runtime-Hr6bO5zl.js} +1 -1
- package/dist/runtime-api.js +2 -2
- package/dist/runtime-heavy-api.js +1 -1
- package/dist/{sdk-DOxaiBRE.js → sdk-AZYVl34z.js} +12 -13
- package/dist/{send-C0NwpZ-c.js → send-D92v6Yy0.js} +22 -12
- package/dist/session-binding-contract-api.js +1 -1
- package/dist/{setup-bootstrap-DbWPVINS.js → setup-bootstrap-Da564w5f.js} +2 -2
- package/dist/{setup-core-DVkrIoax.js → setup-core-BGgbrdaJ.js} +5 -8
- package/dist/setup-plugin-api.js +3 -3
- package/dist/{setup-surface-CN7DEvpg.js → setup-surface-iJ6pd-t5.js} +6 -6
- package/dist/{shared-iLI-9tb9.js → shared-DkFfq7mH.js} +16 -32
- package/dist/{startup-verification-Bd31KqLv.js → startup-verification-BKMAXvcV.js} +2 -2
- package/dist/{storage-t5S-5c_5.js → storage-CQdyKcGg.js} +5 -5
- package/dist/subagent-hooks-api.js +2 -5
- package/dist/{thread-bindings-D73QFTXW.js → thread-bindings-BX5nmWpw.js} +3 -3
- package/dist/{tool-actions.runtime-BCCPq_aO.js → tool-actions.runtime-C1d5fxE_.js} +12 -12
- package/dist/{verification-C0KvXyHK.js → verification-BGCMiO1p.js} +2 -2
- package/node_modules/@babel/runtime/package.json +468 -1089
- package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/.cargo/config.toml +2 -0
- package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/CHANGELOG.md +12 -3
- package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/README.md +17 -0
- package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/download-lib.js +10 -2
- package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/package.json +1 -1
- package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/xtask/.idea/modules.xml +8 -0
- package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/xtask/.idea/vcs.xml +6 -0
- package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/xtask/.idea/xtask.iml +11 -0
- package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/package.json +1 -1
- package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.cjs +28 -28
- package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.js +24 -24
- package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.wasm +0 -0
- package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.wasm.d.ts +58 -58
- package/node_modules/content-type/README.md +32 -57
- package/node_modules/content-type/dist/index.d.ts +26 -0
- package/node_modules/content-type/dist/index.js +170 -0
- package/node_modules/content-type/dist/index.js.map +1 -0
- package/node_modules/content-type/package.json +35 -25
- package/node_modules/linkify-it/README.md +3 -4
- package/node_modules/linkify-it/build/index.cjs.js +44 -41
- package/node_modules/linkify-it/index.mjs +10 -11
- package/node_modules/linkify-it/lib/re.mjs +34 -30
- package/node_modules/linkify-it/package.json +10 -15
- package/node_modules/markdown-it/dist/index.cjs.js +3652 -5378
- package/node_modules/markdown-it/dist/index.cjs.js.map +1 -0
- package/node_modules/markdown-it/dist/markdown-it.js +1399 -4479
- package/node_modules/markdown-it/dist/markdown-it.js.map +1 -0
- package/node_modules/markdown-it/dist/markdown-it.min.js +3 -2
- package/node_modules/markdown-it/dist/markdown-it.min.js.map +1 -0
- package/node_modules/markdown-it/lib/common/html_re.mjs +9 -9
- package/node_modules/markdown-it/lib/common/utils.mjs +2 -11
- package/node_modules/markdown-it/lib/parser_block.mjs +9 -9
- package/node_modules/markdown-it/lib/parser_core.mjs +7 -7
- package/node_modules/markdown-it/lib/parser_inline.mjs +16 -16
- package/node_modules/markdown-it/lib/renderer.mjs +2 -2
- package/node_modules/markdown-it/lib/rules_block/blockquote.mjs +6 -6
- package/node_modules/markdown-it/lib/rules_block/code.mjs +2 -2
- package/node_modules/markdown-it/lib/rules_block/fence.mjs +4 -4
- package/node_modules/markdown-it/lib/rules_block/heading.mjs +7 -7
- package/node_modules/markdown-it/lib/rules_block/hr.mjs +2 -2
- package/node_modules/markdown-it/lib/rules_block/html_block.mjs +6 -6
- package/node_modules/markdown-it/lib/rules_block/lheading.mjs +8 -8
- package/node_modules/markdown-it/lib/rules_block/list.mjs +6 -6
- package/node_modules/markdown-it/lib/rules_block/paragraph.mjs +5 -5
- package/node_modules/markdown-it/lib/rules_block/reference.mjs +1 -1
- package/node_modules/markdown-it/lib/rules_block/state_block.mjs +6 -6
- package/node_modules/markdown-it/lib/rules_block/table.mjs +4 -4
- package/node_modules/markdown-it/lib/rules_core/block.mjs +3 -3
- package/node_modules/markdown-it/lib/rules_core/linkify.mjs +15 -15
- package/node_modules/markdown-it/lib/rules_core/normalize.mjs +2 -2
- package/node_modules/markdown-it/lib/rules_inline/autolink.mjs +17 -17
- package/node_modules/markdown-it/lib/rules_inline/balance_pairs.mjs +2 -2
- package/node_modules/markdown-it/lib/rules_inline/emphasis.mjs +8 -8
- package/node_modules/markdown-it/lib/rules_inline/entity.mjs +7 -7
- package/node_modules/markdown-it/lib/rules_inline/escape.mjs +15 -1
- package/node_modules/markdown-it/lib/rules_inline/html_inline.mjs +1 -1
- package/node_modules/markdown-it/lib/rules_inline/link.mjs +1 -1
- package/node_modules/markdown-it/lib/rules_inline/state_inline.mjs +2 -2
- package/node_modules/markdown-it/lib/rules_inline/strikethrough.mjs +10 -10
- package/node_modules/markdown-it/lib/token.mjs +12 -12
- package/node_modules/markdown-it/package.json +25 -34
- package/node_modules/matrix-js-sdk/CHANGELOG.md +24 -0
- package/node_modules/matrix-js-sdk/README.md +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/AESEncryptedSecretStoragePayload.js +3 -1
- package/node_modules/matrix-js-sdk/lib/@types/IIdentityServerProvider.js +3 -1
- package/node_modules/matrix-js-sdk/lib/@types/PushRules.js +7 -7
- package/node_modules/matrix-js-sdk/lib/@types/PushRules.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/auth.js +4 -4
- package/node_modules/matrix-js-sdk/lib/@types/auth.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/beacon.js +2 -2
- package/node_modules/matrix-js-sdk/lib/@types/beacon.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/common.js +3 -1
- package/node_modules/matrix-js-sdk/lib/@types/crypto.js +3 -1
- package/node_modules/matrix-js-sdk/lib/@types/event.d.ts +6 -1
- package/node_modules/matrix-js-sdk/lib/@types/event.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/event.js +23 -20
- package/node_modules/matrix-js-sdk/lib/@types/event.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/events.js +3 -1
- package/node_modules/matrix-js-sdk/lib/@types/extensible_events.js +6 -6
- package/node_modules/matrix-js-sdk/lib/@types/extensible_events.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/global.d.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/json.js +3 -1
- package/node_modules/matrix-js-sdk/lib/@types/local_notifications.js +3 -1
- package/node_modules/matrix-js-sdk/lib/@types/location.js +4 -4
- package/node_modules/matrix-js-sdk/lib/@types/location.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/matrix-sdk-crypto-wasm.d.js +3 -1
- package/node_modules/matrix-js-sdk/lib/@types/media.js +3 -1
- package/node_modules/matrix-js-sdk/lib/@types/membership.js +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/membership.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/partials.js +6 -6
- package/node_modules/matrix-js-sdk/lib/@types/partials.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/polls.js +5 -5
- package/node_modules/matrix-js-sdk/lib/@types/polls.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/read_receipts.js +2 -2
- package/node_modules/matrix-js-sdk/lib/@types/read_receipts.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/registration.js +3 -1
- package/node_modules/matrix-js-sdk/lib/@types/requests.js +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/requests.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/retention.d.ts +15 -0
- package/node_modules/matrix-js-sdk/lib/@types/retention.d.ts.map +1 -0
- package/node_modules/matrix-js-sdk/lib/@types/retention.js +13 -0
- package/node_modules/matrix-js-sdk/lib/@types/retention.js.map +1 -0
- package/node_modules/matrix-js-sdk/lib/@types/search.js +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/search.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/signed.js +3 -1
- package/node_modules/matrix-js-sdk/lib/@types/spaces.js +3 -1
- package/node_modules/matrix-js-sdk/lib/@types/state_events.js +3 -1
- package/node_modules/matrix-js-sdk/lib/@types/synapse.js +3 -1
- package/node_modules/matrix-js-sdk/lib/@types/sync.js +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/sync.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/threepids.js +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/threepids.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/topic.js +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/topic.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/uia.js +3 -1
- package/node_modules/matrix-js-sdk/lib/NamespacedValue.js +8 -8
- package/node_modules/matrix-js-sdk/lib/NamespacedValue.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/ReEmitter.js +8 -15
- package/node_modules/matrix-js-sdk/lib/ReEmitter.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/ToDeviceMessageQueue.js +47 -55
- package/node_modules/matrix-js-sdk/lib/ToDeviceMessageQueue.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/autodiscovery.js +233 -247
- package/node_modules/matrix-js-sdk/lib/autodiscovery.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/base64.js +1 -1
- package/node_modules/matrix-js-sdk/lib/base64.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/browser-index.d.ts +2 -2
- package/node_modules/matrix-js-sdk/lib/browser-index.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/browser-index.js +5 -5
- package/node_modules/matrix-js-sdk/lib/browser-index.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/capabilityPoller.d.ts +38 -0
- package/node_modules/matrix-js-sdk/lib/capabilityPoller.d.ts.map +1 -0
- package/node_modules/matrix-js-sdk/lib/capabilityPoller.js +93 -0
- package/node_modules/matrix-js-sdk/lib/capabilityPoller.js.map +1 -0
- package/node_modules/matrix-js-sdk/lib/client.d.ts +9 -8
- package/node_modules/matrix-js-sdk/lib/client.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/client.js +2123 -2483
- package/node_modules/matrix-js-sdk/lib/client.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/common-crypto/CryptoBackend.js +3 -1
- package/node_modules/matrix-js-sdk/lib/common-crypto/CryptoBackend.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/common-crypto/key-passphrase.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/content-helpers.js +43 -48
- package/node_modules/matrix-js-sdk/lib/content-helpers.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/content-repo.js +14 -24
- package/node_modules/matrix-js-sdk/lib/content-repo.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/crypto/store/base.js +6 -6
- package/node_modules/matrix-js-sdk/lib/crypto/store/base.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/crypto/store/indexeddb-crypto-store-backend.js +189 -237
- package/node_modules/matrix-js-sdk/lib/crypto/store/indexeddb-crypto-store-backend.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/crypto/store/indexeddb-crypto-store.js +25 -28
- package/node_modules/matrix-js-sdk/lib/crypto/store/indexeddb-crypto-store.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/crypto/store/localStorage-crypto-store.js +113 -145
- package/node_modules/matrix-js-sdk/lib/crypto/store/localStorage-crypto-store.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/crypto/store/memory-crypto-store.js +74 -105
- package/node_modules/matrix-js-sdk/lib/crypto/store/memory-crypto-store.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/crypto-api/CryptoEvent.js +1 -1
- package/node_modules/matrix-js-sdk/lib/crypto-api/CryptoEvent.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/crypto-api/CryptoEventHandlerMap.js +3 -1
- package/node_modules/matrix-js-sdk/lib/crypto-api/index.d.ts +15 -6
- package/node_modules/matrix-js-sdk/lib/crypto-api/index.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/crypto-api/index.js +76 -76
- package/node_modules/matrix-js-sdk/lib/crypto-api/index.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/crypto-api/key-passphrase.js +15 -23
- package/node_modules/matrix-js-sdk/lib/crypto-api/key-passphrase.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/crypto-api/keybackup.js +3 -1
- package/node_modules/matrix-js-sdk/lib/crypto-api/recovery-key.js +11 -12
- package/node_modules/matrix-js-sdk/lib/crypto-api/recovery-key.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/crypto-api/verification.js +3 -3
- package/node_modules/matrix-js-sdk/lib/crypto-api/verification.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/digest.js +7 -14
- package/node_modules/matrix-js-sdk/lib/digest.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/embedded.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/embedded.js +379 -500
- package/node_modules/matrix-js-sdk/lib/embedded.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/errors.js +2 -2
- package/node_modules/matrix-js-sdk/lib/errors.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/event-mapper.js +10 -12
- package/node_modules/matrix-js-sdk/lib/event-mapper.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/extensible_events_v1/ExtensibleEvent.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/extensible_events_v1/InvalidEventError.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/extensible_events_v1/MessageEvent.js +26 -28
- package/node_modules/matrix-js-sdk/lib/extensible_events_v1/MessageEvent.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/extensible_events_v1/PollEndEvent.js +11 -12
- package/node_modules/matrix-js-sdk/lib/extensible_events_v1/PollEndEvent.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/extensible_events_v1/PollResponseEvent.js +6 -6
- package/node_modules/matrix-js-sdk/lib/extensible_events_v1/PollResponseEvent.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/extensible_events_v1/PollStartEvent.js +36 -38
- package/node_modules/matrix-js-sdk/lib/extensible_events_v1/PollStartEvent.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/extensible_events_v1/utilities.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/feature.js +18 -31
- package/node_modules/matrix-js-sdk/lib/feature.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/filter-component.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/filter-component.js +20 -26
- package/node_modules/matrix-js-sdk/lib/filter-component.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/filter.js +14 -15
- package/node_modules/matrix-js-sdk/lib/filter.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/http-api/errors.js +41 -56
- package/node_modules/matrix-js-sdk/lib/http-api/errors.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/http-api/fetch.js +140 -157
- package/node_modules/matrix-js-sdk/lib/http-api/fetch.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/http-api/index.js +17 -20
- package/node_modules/matrix-js-sdk/lib/http-api/index.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/http-api/interface.js +1 -1
- package/node_modules/matrix-js-sdk/lib/http-api/interface.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/http-api/method.js +1 -1
- package/node_modules/matrix-js-sdk/lib/http-api/method.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/http-api/prefix.js +3 -3
- package/node_modules/matrix-js-sdk/lib/http-api/prefix.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/http-api/refresh.js +80 -99
- package/node_modules/matrix-js-sdk/lib/http-api/refresh.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/http-api/utils.d.ts +1 -1
- package/node_modules/matrix-js-sdk/lib/http-api/utils.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/http-api/utils.js +35 -47
- package/node_modules/matrix-js-sdk/lib/http-api/utils.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/index.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/indexeddb-helpers.js +3 -3
- package/node_modules/matrix-js-sdk/lib/indexeddb-helpers.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/indexeddb-worker.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/interactive-auth.d.ts +5 -5
- package/node_modules/matrix-js-sdk/lib/interactive-auth.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/interactive-auth.js +181 -203
- package/node_modules/matrix-js-sdk/lib/interactive-auth.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/logger.js +22 -56
- package/node_modules/matrix-js-sdk/lib/logger.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrix.d.ts +1 -0
- package/node_modules/matrix-js-sdk/lib/matrix.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrix.js +8 -11
- package/node_modules/matrix-js-sdk/lib/matrix.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/CallMembership.js +83 -76
- package/node_modules/matrix-js-sdk/lib/matrixrtc/CallMembership.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/EncryptionManager.js +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/EncryptionManager.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/IKeyTransport.js +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/IKeyTransport.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/IMembershipManager.js +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/IMembershipManager.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/LivekitTransport.d.ts +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/LivekitTransport.js +4 -4
- package/node_modules/matrix-js-sdk/lib/matrixrtc/LivekitTransport.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSession.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSession.js +144 -184
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSession.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSessionManager.js +35 -39
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSessionManager.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManager.d.ts +2 -0
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManager.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManager.js +346 -383
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManager.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManagerActionScheduler.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManagerActionScheduler.js +54 -59
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManagerActionScheduler.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/RTCEncryptionManager.js +117 -139
- package/node_modules/matrix-js-sdk/lib/matrixrtc/RTCEncryptionManager.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/ToDeviceKeyTransport.js +49 -54
- package/node_modules/matrix-js-sdk/lib/matrixrtc/ToDeviceKeyTransport.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/index.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/common.js +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/common.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/index.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/rtc.js +15 -23
- package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/rtc.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/session.js +4 -5
- package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/session.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/types.js +4 -6
- package/node_modules/matrix-js-sdk/lib/matrixrtc/types.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/utils.js +4 -11
- package/node_modules/matrix-js-sdk/lib/matrixrtc/utils.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/MSC3089Branch.js +91 -116
- package/node_modules/matrix-js-sdk/lib/models/MSC3089Branch.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/MSC3089TreeSpace.js +209 -244
- package/node_modules/matrix-js-sdk/lib/models/MSC3089TreeSpace.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/ToDeviceMessage.js +3 -1
- package/node_modules/matrix-js-sdk/lib/models/beacon.js +20 -15
- package/node_modules/matrix-js-sdk/lib/models/beacon.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/compare-event-ordering.js +13 -13
- package/node_modules/matrix-js-sdk/lib/models/compare-event-ordering.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/device.js +10 -3
- package/node_modules/matrix-js-sdk/lib/models/device.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/event-context.js +5 -7
- package/node_modules/matrix-js-sdk/lib/models/event-context.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/event-status.js +1 -1
- package/node_modules/matrix-js-sdk/lib/models/event-status.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/event-timeline-set.js +91 -91
- package/node_modules/matrix-js-sdk/lib/models/event-timeline-set.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/event-timeline.js +31 -29
- package/node_modules/matrix-js-sdk/lib/models/event-timeline.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/event.js +215 -235
- package/node_modules/matrix-js-sdk/lib/models/event.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/invites-ignorer-types.js +4 -4
- package/node_modules/matrix-js-sdk/lib/models/invites-ignorer-types.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/invites-ignorer.js +159 -179
- package/node_modules/matrix-js-sdk/lib/models/invites-ignorer.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/poll.js +72 -78
- package/node_modules/matrix-js-sdk/lib/models/poll.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/profile-keys.js +2 -2
- package/node_modules/matrix-js-sdk/lib/models/profile-keys.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/read-receipt.js +40 -56
- package/node_modules/matrix-js-sdk/lib/models/read-receipt.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/related-relations.js +2 -0
- package/node_modules/matrix-js-sdk/lib/models/related-relations.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/relations-container.js +20 -21
- package/node_modules/matrix-js-sdk/lib/models/relations-container.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/relations.js +131 -156
- package/node_modules/matrix-js-sdk/lib/models/relations.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/room-member.js +44 -27
- package/node_modules/matrix-js-sdk/lib/models/room-member.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/room-receipts.js +48 -55
- package/node_modules/matrix-js-sdk/lib/models/room-receipts.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/room-retention.d.ts +28 -0
- package/node_modules/matrix-js-sdk/lib/models/room-retention.d.ts.map +1 -0
- package/node_modules/matrix-js-sdk/lib/models/room-retention.js +192 -0
- package/node_modules/matrix-js-sdk/lib/models/room-retention.js.map +1 -0
- package/node_modules/matrix-js-sdk/lib/models/room-state.js +141 -170
- package/node_modules/matrix-js-sdk/lib/models/room-state.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/room-sticky-events.d.ts +1 -0
- package/node_modules/matrix-js-sdk/lib/models/room-sticky-events.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/room-sticky-events.js +46 -65
- package/node_modules/matrix-js-sdk/lib/models/room-sticky-events.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/room-summary.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/room.d.ts +2 -1
- package/node_modules/matrix-js-sdk/lib/models/room.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/room.js +800 -887
- package/node_modules/matrix-js-sdk/lib/models/room.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/search-result.js +5 -5
- package/node_modules/matrix-js-sdk/lib/models/search-result.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/thread.js +267 -283
- package/node_modules/matrix-js-sdk/lib/models/thread.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/typed-event-emitter.js +7 -18
- package/node_modules/matrix-js-sdk/lib/models/typed-event-emitter.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/user.js +26 -7
- package/node_modules/matrix-js-sdk/lib/models/user.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/oidc/authorize.js +208 -241
- package/node_modules/matrix-js-sdk/lib/oidc/authorize.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/oidc/discovery.js +23 -36
- package/node_modules/matrix-js-sdk/lib/oidc/discovery.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/oidc/error.js +1 -1
- package/node_modules/matrix-js-sdk/lib/oidc/error.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/oidc/index.js +1 -0
- package/node_modules/matrix-js-sdk/lib/oidc/index.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/oidc/register.js +60 -66
- package/node_modules/matrix-js-sdk/lib/oidc/register.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/oidc/tokenRefresher.js +83 -94
- package/node_modules/matrix-js-sdk/lib/oidc/tokenRefresher.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/oidc/validate.js +18 -18
- package/node_modules/matrix-js-sdk/lib/oidc/validate.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/pushprocessor.js +70 -81
- package/node_modules/matrix-js-sdk/lib/pushprocessor.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/randomstring.js +9 -9
- package/node_modules/matrix-js-sdk/lib/randomstring.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/realtime-callbacks.js +25 -28
- package/node_modules/matrix-js-sdk/lib/realtime-callbacks.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/receipt-accumulator.d.ts +2 -0
- package/node_modules/matrix-js-sdk/lib/receipt-accumulator.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/receipt-accumulator.js +14 -22
- package/node_modules/matrix-js-sdk/lib/receipt-accumulator.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rendezvous/MSC4108SignInWithQR.js +272 -298
- package/node_modules/matrix-js-sdk/lib/rendezvous/MSC4108SignInWithQR.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rendezvous/RendezvousChannel.js +3 -1
- package/node_modules/matrix-js-sdk/lib/rendezvous/RendezvousCode.js +3 -1
- package/node_modules/matrix-js-sdk/lib/rendezvous/RendezvousError.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rendezvous/RendezvousFailureReason.js +2 -2
- package/node_modules/matrix-js-sdk/lib/rendezvous/RendezvousFailureReason.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rendezvous/RendezvousIntent.js +1 -1
- package/node_modules/matrix-js-sdk/lib/rendezvous/RendezvousIntent.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rendezvous/RendezvousTransport.js +3 -1
- package/node_modules/matrix-js-sdk/lib/rendezvous/channels/MSC4108SecureChannel.js +122 -144
- package/node_modules/matrix-js-sdk/lib/rendezvous/channels/MSC4108SecureChannel.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rendezvous/index.js +44 -69
- package/node_modules/matrix-js-sdk/lib/rendezvous/index.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts +1 -1
- package/node_modules/matrix-js-sdk/lib/rendezvous/transports/MSC4108RendezvousSession.js +142 -152
- package/node_modules/matrix-js-sdk/lib/rendezvous/transports/MSC4108RendezvousSession.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/retentionPolicy.d.ts +33 -0
- package/node_modules/matrix-js-sdk/lib/retentionPolicy.d.ts.map +1 -0
- package/node_modules/matrix-js-sdk/lib/retentionPolicy.js +39 -0
- package/node_modules/matrix-js-sdk/lib/retentionPolicy.js.map +1 -0
- package/node_modules/matrix-js-sdk/lib/room-hierarchy.js +52 -56
- package/node_modules/matrix-js-sdk/lib/room-hierarchy.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/CrossSigningIdentity.js +94 -104
- package/node_modules/matrix-js-sdk/lib/rust-crypto/CrossSigningIdentity.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/DehydratedDeviceManager.js +158 -190
- package/node_modules/matrix-js-sdk/lib/rust-crypto/DehydratedDeviceManager.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/KeyClaimManager.js +17 -20
- package/node_modules/matrix-js-sdk/lib/rust-crypto/KeyClaimManager.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/OutgoingRequestProcessor.js +109 -139
- package/node_modules/matrix-js-sdk/lib/rust-crypto/OutgoingRequestProcessor.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/OutgoingRequestsManager.js +72 -86
- package/node_modules/matrix-js-sdk/lib/rust-crypto/OutgoingRequestsManager.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/PerSessionKeyBackupDownloader.js +195 -221
- package/node_modules/matrix-js-sdk/lib/rust-crypto/PerSessionKeyBackupDownloader.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/RoomEncryptor.js +121 -137
- package/node_modules/matrix-js-sdk/lib/rust-crypto/RoomEncryptor.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/backup.d.ts +7 -2
- package/node_modules/matrix-js-sdk/lib/rust-crypto/backup.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/backup.js +459 -544
- package/node_modules/matrix-js-sdk/lib/rust-crypto/backup.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/constants.js +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/constants.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/device-converter.js +15 -28
- package/node_modules/matrix-js-sdk/lib/rust-crypto/device-converter.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/index.js +103 -116
- package/node_modules/matrix-js-sdk/lib/rust-crypto/index.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/libolm_migration.js +303 -365
- package/node_modules/matrix-js-sdk/lib/rust-crypto/libolm_migration.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/rust-crypto.d.ts +5 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/rust-crypto.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/rust-crypto.js +1065 -1322
- package/node_modules/matrix-js-sdk/lib/rust-crypto/rust-crypto.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/secret-storage.js +12 -25
- package/node_modules/matrix-js-sdk/lib/rust-crypto/secret-storage.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/verification.js +134 -184
- package/node_modules/matrix-js-sdk/lib/rust-crypto/verification.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/scheduler.js +42 -17
- package/node_modules/matrix-js-sdk/lib/scheduler.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/secret-storage.js +179 -213
- package/node_modules/matrix-js-sdk/lib/secret-storage.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/serverCapabilities.d.ts +4 -23
- package/node_modules/matrix-js-sdk/lib/serverCapabilities.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/serverCapabilities.js +9 -62
- package/node_modules/matrix-js-sdk/lib/serverCapabilities.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/service-types.js +1 -1
- package/node_modules/matrix-js-sdk/lib/service-types.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/sliding-sync-sdk.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/sliding-sync-sdk.js +368 -421
- package/node_modules/matrix-js-sdk/lib/sliding-sync-sdk.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/sliding-sync.js +136 -167
- package/node_modules/matrix-js-sdk/lib/sliding-sync.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/store/index.d.ts +7 -0
- package/node_modules/matrix-js-sdk/lib/store/index.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/store/index.js +3 -1
- package/node_modules/matrix-js-sdk/lib/store/index.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/store/indexeddb-backend.js +3 -1
- package/node_modules/matrix-js-sdk/lib/store/indexeddb-local-backend.d.ts +1 -0
- package/node_modules/matrix-js-sdk/lib/store/indexeddb-local-backend.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/store/indexeddb-local-backend.js +197 -240
- package/node_modules/matrix-js-sdk/lib/store/indexeddb-local-backend.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/store/indexeddb-remote-backend.d.ts +3 -1
- package/node_modules/matrix-js-sdk/lib/store/indexeddb-remote-backend.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/store/indexeddb-remote-backend.js +51 -59
- package/node_modules/matrix-js-sdk/lib/store/indexeddb-remote-backend.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/store/indexeddb-store-worker.js +22 -22
- package/node_modules/matrix-js-sdk/lib/store/indexeddb-store-worker.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/store/indexeddb.d.ts +7 -5
- package/node_modules/matrix-js-sdk/lib/store/indexeddb.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/store/indexeddb.js +63 -79
- package/node_modules/matrix-js-sdk/lib/store/indexeddb.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/store/local-storage-events-emitter.js +2 -2
- package/node_modules/matrix-js-sdk/lib/store/local-storage-events-emitter.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/store/memory.d.ts +1 -0
- package/node_modules/matrix-js-sdk/lib/store/memory.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/store/memory.js +38 -54
- package/node_modules/matrix-js-sdk/lib/store/memory.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/store/stub.d.ts +1 -0
- package/node_modules/matrix-js-sdk/lib/store/stub.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/store/stub.js +22 -32
- package/node_modules/matrix-js-sdk/lib/store/stub.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/sync-accumulator.d.ts +1 -0
- package/node_modules/matrix-js-sdk/lib/sync-accumulator.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/sync-accumulator.js +57 -65
- package/node_modules/matrix-js-sdk/lib/sync-accumulator.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/sync.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/sync.js +914 -991
- package/node_modules/matrix-js-sdk/lib/sync.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/testing.js +63 -105
- package/node_modules/matrix-js-sdk/lib/testing.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/thread-utils.js +1 -4
- package/node_modules/matrix-js-sdk/lib/thread-utils.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/timeline-window.js +90 -99
- package/node_modules/matrix-js-sdk/lib/timeline-window.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/types.js +1 -1
- package/node_modules/matrix-js-sdk/lib/types.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/utils/decryptAESSecretStorageItem.js +14 -25
- package/node_modules/matrix-js-sdk/lib/utils/decryptAESSecretStorageItem.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/utils/encryptAESSecretStorageItem.js +27 -38
- package/node_modules/matrix-js-sdk/lib/utils/encryptAESSecretStorageItem.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/utils/internal/deriveKeys.js +25 -32
- package/node_modules/matrix-js-sdk/lib/utils/internal/deriveKeys.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/utils/roomVersion.js +1 -1
- package/node_modules/matrix-js-sdk/lib/utils/roomVersion.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/utils.js +83 -135
- package/node_modules/matrix-js-sdk/lib/utils.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/version-support.js +3 -3
- package/node_modules/matrix-js-sdk/lib/version-support.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/audioContext.js +5 -6
- package/node_modules/matrix-js-sdk/lib/webrtc/audioContext.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/call.js +1123 -1256
- package/node_modules/matrix-js-sdk/lib/webrtc/call.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/callEventHandler.js +207 -214
- package/node_modules/matrix-js-sdk/lib/webrtc/callEventHandler.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/callEventTypes.js +2 -2
- package/node_modules/matrix-js-sdk/lib/webrtc/callEventTypes.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/callFeed.js +33 -20
- package/node_modules/matrix-js-sdk/lib/webrtc/callFeed.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/groupCall.js +521 -594
- package/node_modules/matrix-js-sdk/lib/webrtc/groupCall.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/groupCallEventHandler.js +58 -61
- package/node_modules/matrix-js-sdk/lib/webrtc/groupCallEventHandler.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/mediaHandler.js +203 -233
- package/node_modules/matrix-js-sdk/lib/webrtc/mediaHandler.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/callFeedStatsReporter.js +16 -20
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/callFeedStatsReporter.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/callStatsReportGatherer.js +65 -70
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/callStatsReportGatherer.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/callStatsReportSummary.js +3 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/connectionStats.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/connectionStatsBuilder.js +2 -2
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/connectionStatsBuilder.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/connectionStatsReportBuilder.js +20 -24
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/connectionStatsReportBuilder.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/groupCallStats.js +4 -5
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/groupCallStats.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/media/mediaSsrcHandler.js +7 -8
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/media/mediaSsrcHandler.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/media/mediaTrackHandler.js +7 -9
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/media/mediaTrackHandler.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/media/mediaTrackStats.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/media/mediaTrackStatsHandler.js +6 -6
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/media/mediaTrackStatsHandler.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/statsReport.js +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/statsReport.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/statsReportEmitter.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/summaryStatsReportGatherer.js +14 -14
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/summaryStatsReportGatherer.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/trackStatsBuilder.js +32 -34
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/trackStatsBuilder.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/transportStats.js +3 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/transportStatsBuilder.js +9 -9
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/transportStatsBuilder.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/valueFormatter.js +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/valueFormatter.js.map +1 -1
- package/node_modules/matrix-js-sdk/package.json +110 -138
- package/node_modules/matrix-js-sdk/src/@types/event.ts +9 -0
- package/node_modules/matrix-js-sdk/src/@types/global.d.ts +2 -2
- package/node_modules/matrix-js-sdk/src/@types/retention.ts +16 -0
- package/node_modules/matrix-js-sdk/src/ToDeviceMessageQueue.ts +2 -2
- package/node_modules/matrix-js-sdk/src/browser-index.ts +4 -4
- package/node_modules/matrix-js-sdk/src/capabilityPoller.ts +102 -0
- package/node_modules/matrix-js-sdk/src/client.ts +37 -25
- package/node_modules/matrix-js-sdk/src/crypto-api/index.ts +17 -6
- package/node_modules/matrix-js-sdk/src/embedded.ts +4 -6
- package/node_modules/matrix-js-sdk/src/filter-component.ts +1 -0
- package/node_modules/matrix-js-sdk/src/http-api/utils.ts +5 -10
- package/node_modules/matrix-js-sdk/src/interactive-auth.ts +11 -5
- package/node_modules/matrix-js-sdk/src/matrix.ts +1 -0
- package/node_modules/matrix-js-sdk/src/matrixrtc/LivekitTransport.ts +1 -1
- package/node_modules/matrix-js-sdk/src/matrixrtc/MatrixRTCSession.ts +5 -4
- package/node_modules/matrix-js-sdk/src/matrixrtc/MembershipManager.ts +2 -0
- package/node_modules/matrix-js-sdk/src/matrixrtc/MembershipManagerActionScheduler.ts +4 -1
- package/node_modules/matrix-js-sdk/src/models/MSC3089Branch.ts +1 -1
- package/node_modules/matrix-js-sdk/src/models/room-retention.ts +230 -0
- package/node_modules/matrix-js-sdk/src/models/room-sticky-events.ts +1 -0
- package/node_modules/matrix-js-sdk/src/models/room.ts +26 -12
- package/node_modules/matrix-js-sdk/src/receipt-accumulator.ts +2 -0
- package/node_modules/matrix-js-sdk/src/rendezvous/index.ts +1 -1
- package/node_modules/matrix-js-sdk/src/rendezvous/transports/MSC4108RendezvousSession.ts +2 -2
- package/node_modules/matrix-js-sdk/src/retentionPolicy.ts +65 -0
- package/node_modules/matrix-js-sdk/src/rust-crypto/PerSessionKeyBackupDownloader.ts +1 -1
- package/node_modules/matrix-js-sdk/src/rust-crypto/backup.ts +15 -4
- package/node_modules/matrix-js-sdk/src/rust-crypto/index.ts +6 -6
- package/node_modules/matrix-js-sdk/src/rust-crypto/rust-crypto.ts +31 -7
- package/node_modules/matrix-js-sdk/src/rust-crypto/verification.ts +1 -1
- package/node_modules/matrix-js-sdk/src/serverCapabilities.ts +8 -67
- package/node_modules/matrix-js-sdk/src/sliding-sync-sdk.ts +5 -7
- package/node_modules/matrix-js-sdk/src/store/index.ts +8 -0
- package/node_modules/matrix-js-sdk/src/store/indexeddb-local-backend.ts +12 -2
- package/node_modules/matrix-js-sdk/src/store/indexeddb-remote-backend.ts +24 -5
- package/node_modules/matrix-js-sdk/src/store/indexeddb.ts +20 -8
- package/node_modules/matrix-js-sdk/src/store/memory.ts +4 -0
- package/node_modules/matrix-js-sdk/src/store/stub.ts +3 -0
- package/node_modules/matrix-js-sdk/src/sync-accumulator.ts +9 -0
- package/node_modules/matrix-js-sdk/src/sync.ts +11 -9
- package/node_modules/media-typer/README.md +19 -33
- package/node_modules/media-typer/dist/index.d.ts +29 -0
- package/node_modules/media-typer/dist/index.js +64 -0
- package/node_modules/media-typer/dist/index.js.map +1 -0
- package/node_modules/media-typer/package.json +37 -22
- package/node_modules/music-metadata/lib/id3v1/ID3v1Parser.js +2 -2
- package/node_modules/music-metadata/lib/mp4/AtomToken.js +65 -13
- package/node_modules/music-metadata/lib/wav/WaveChunk.d.ts +10 -0
- package/node_modules/music-metadata/lib/wav/WaveChunk.js +13 -3
- package/node_modules/music-metadata/lib/wav/WaveParser.d.ts +1 -0
- package/node_modules/music-metadata/lib/wav/WaveParser.js +6 -5
- package/node_modules/music-metadata/package.json +5 -5
- package/node_modules/typebox/build/compile/validator.d.mts +2 -7
- package/node_modules/typebox/build/compile/validator.mjs +6 -36
- package/node_modules/typebox/build/error/errors.d.mts +1 -7
- package/node_modules/typebox/build/format/_idna.mjs +36 -6
- package/node_modules/typebox/build/format/_puny.mjs +4 -1
- package/node_modules/typebox/build/format/uuid.d.mts +2 -2
- package/node_modules/typebox/build/format/uuid.mjs +3 -3
- package/node_modules/typebox/build/guard/emit.d.mts +0 -4
- package/node_modules/typebox/build/guard/emit.mjs +0 -8
- package/node_modules/typebox/build/guard/guard.d.mts +4 -8
- package/node_modules/typebox/build/guard/guard.mjs +5 -13
- package/node_modules/typebox/build/schema/engine/boolean.d.mts +3 -3
- package/node_modules/typebox/build/schema/engine/boolean.mjs +4 -4
- package/node_modules/typebox/build/schema/engine/index.d.mts +0 -1
- package/node_modules/typebox/build/schema/engine/index.mjs +0 -1
- package/node_modules/typebox/build/schema/engine/schema.mjs +5 -10
- package/node_modules/typebox/build/schema/engine/type.mjs +14 -18
- package/node_modules/typebox/build/schema/types/dependencies.mjs +1 -1
- package/node_modules/typebox/build/schema/types/index.d.mts +0 -1
- package/node_modules/typebox/build/schema/types/index.mjs +0 -1
- package/node_modules/typebox/build/schema/types/schema.d.mts +1 -1
- package/node_modules/typebox/build/schema/types/schema.mjs +2 -2
- package/node_modules/typebox/build/system/locale/ar_001.mjs +0 -1
- package/node_modules/typebox/build/system/locale/bn_BD.mjs +0 -1
- package/node_modules/typebox/build/system/locale/cs_CZ.mjs +0 -1
- package/node_modules/typebox/build/system/locale/de_DE.mjs +0 -1
- package/node_modules/typebox/build/system/locale/el_GR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/en_US.mjs +0 -1
- package/node_modules/typebox/build/system/locale/es_419.mjs +0 -1
- package/node_modules/typebox/build/system/locale/es_AR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/es_ES.mjs +0 -1
- package/node_modules/typebox/build/system/locale/es_MX.mjs +0 -1
- package/node_modules/typebox/build/system/locale/fa_IR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/fil_PH.mjs +0 -1
- package/node_modules/typebox/build/system/locale/fr_CA.mjs +0 -1
- package/node_modules/typebox/build/system/locale/fr_FR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ha_NG.mjs +0 -1
- package/node_modules/typebox/build/system/locale/hi_IN.mjs +0 -1
- package/node_modules/typebox/build/system/locale/hu_HU.mjs +0 -1
- package/node_modules/typebox/build/system/locale/id_ID.mjs +0 -1
- package/node_modules/typebox/build/system/locale/it_IT.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ja_JP.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ko_KR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ms_MY.mjs +0 -1
- package/node_modules/typebox/build/system/locale/nl_NL.mjs +0 -1
- package/node_modules/typebox/build/system/locale/pl_PL.mjs +0 -1
- package/node_modules/typebox/build/system/locale/pt_BR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/pt_PT.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ro_RO.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ru_RU.mjs +0 -1
- package/node_modules/typebox/build/system/locale/sv_SE.mjs +0 -1
- package/node_modules/typebox/build/system/locale/sw_TZ.mjs +0 -1
- package/node_modules/typebox/build/system/locale/th_TH.mjs +0 -1
- package/node_modules/typebox/build/system/locale/tr_TR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/uk_UA.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ur_PK.mjs +0 -1
- package/node_modules/typebox/build/system/locale/vi_VN.mjs +0 -1
- package/node_modules/typebox/build/system/locale/yo_NG.mjs +0 -1
- package/node_modules/typebox/build/system/locale/zh_Hans.mjs +0 -1
- package/node_modules/typebox/build/system/locale/zh_Hant.mjs +0 -1
- package/node_modules/typebox/build/system/memory/clone.d.mts +2 -3
- package/node_modules/typebox/build/system/memory/clone.mjs +73 -26
- package/node_modules/typebox/build/system/settings/settings.d.mts +15 -0
- package/node_modules/typebox/build/system/settings/settings.mjs +3 -1
- package/node_modules/typebox/build/type/action/_add_immutable.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_add_immutable.mjs +11 -0
- package/node_modules/typebox/build/type/action/_add_optional.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_add_optional.mjs +11 -0
- package/node_modules/typebox/build/type/action/_add_readonly.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_add_readonly.mjs +11 -0
- package/node_modules/typebox/build/type/action/_remove_immutable.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_remove_immutable.mjs +11 -0
- package/node_modules/typebox/build/type/action/_remove_optional.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_remove_optional.mjs +11 -0
- package/node_modules/typebox/build/type/action/_remove_readonly.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_remove_readonly.mjs +11 -0
- package/node_modules/typebox/build/type/action/conditional.d.mts +2 -3
- package/node_modules/typebox/build/type/action/conditional.mjs +2 -1
- package/node_modules/typebox/build/type/action/index.d.mts +7 -4
- package/node_modules/typebox/build/type/action/index.mjs +7 -4
- package/node_modules/typebox/build/type/action/mapped.d.mts +2 -3
- package/node_modules/typebox/build/type/action/mapped.mjs +2 -1
- package/node_modules/typebox/build/type/action/module.d.mts +8 -7
- package/node_modules/typebox/build/type/action/module.mjs +7 -6
- package/node_modules/typebox/build/type/action/readonly_object.d.mts +0 -5
- package/node_modules/typebox/build/type/action/readonly_object.mjs +0 -5
- package/node_modules/typebox/build/type/action/with.d.mts +11 -0
- package/node_modules/typebox/build/type/action/with.mjs +11 -0
- package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +1 -1
- package/node_modules/typebox/build/type/engine/call/instantiate.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/call/instantiate.mjs +3 -2
- package/node_modules/typebox/build/type/engine/call/resolve_arguments.mjs +2 -2
- package/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.d.mts +3 -4
- package/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.mjs +2 -1
- package/node_modules/typebox/build/type/engine/cyclic/candidates.d.mts +2 -3
- package/node_modules/typebox/build/type/engine/cyclic/candidates.mjs +3 -6
- package/node_modules/typebox/build/type/engine/cyclic/check.d.mts +6 -9
- package/node_modules/typebox/build/type/engine/cyclic/check.mjs +10 -16
- package/node_modules/typebox/build/type/engine/cyclic/dependencies.d.mts +1 -4
- package/node_modules/typebox/build/type/engine/cyclic/dependencies.mjs +9 -15
- package/node_modules/typebox/build/type/engine/cyclic/extends.d.mts +1 -4
- package/node_modules/typebox/build/type/engine/cyclic/extends.mjs +8 -14
- package/node_modules/typebox/build/type/engine/cyclic/instantiate.d.mts +2 -5
- package/node_modules/typebox/build/type/engine/cyclic/instantiate.mjs +3 -2
- package/node_modules/typebox/build/type/engine/enum/index.d.mts +0 -1
- package/node_modules/typebox/build/type/engine/enum/index.mjs +0 -1
- package/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +1 -2
- package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +2 -6
- package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +10 -6
- package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +10 -6
- package/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +2 -1
- package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +3 -3
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +17 -5
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +34 -8
- package/node_modules/typebox/build/type/engine/exclude/operation.d.mts +5 -6
- package/node_modules/typebox/build/type/engine/exclude/operation.mjs +11 -12
- package/node_modules/typebox/build/type/engine/extract/operation.d.mts +5 -6
- package/node_modules/typebox/build/type/engine/extract/operation.mjs +11 -12
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +14 -0
- package/node_modules/typebox/build/type/engine/immutable/instantiate_remove.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/immutable/instantiate_remove.mjs +14 -0
- package/node_modules/typebox/build/type/engine/index.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/index.mjs +2 -2
- package/node_modules/typebox/build/type/engine/indexable/from_dependent.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/indexable/from_dependent.mjs +8 -0
- package/node_modules/typebox/build/type/engine/indexable/from_enum.d.mts +3 -3
- package/node_modules/typebox/build/type/engine/indexable/from_enum.mjs +4 -4
- package/node_modules/typebox/build/type/engine/indexable/from_template_literal.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/indexable/from_template_literal.mjs +3 -3
- package/node_modules/typebox/build/type/engine/indexable/from_type.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/indexable/from_type.mjs +9 -6
- package/node_modules/typebox/build/type/engine/indexed/instantiate.d.mts +2 -1
- package/node_modules/typebox/build/type/engine/indexed/instantiate.mjs +5 -2
- package/node_modules/typebox/build/type/engine/instantiate.d.mts +44 -31
- package/node_modules/typebox/build/type/engine/instantiate.mjs +82 -83
- package/node_modules/typebox/build/type/engine/interface/instantiate.d.mts +3 -6
- package/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.mjs +3 -3
- package/node_modules/typebox/build/type/engine/keyof/instantiate.d.mts +2 -1
- package/node_modules/typebox/build/type/engine/keyof/instantiate.mjs +5 -1
- package/node_modules/typebox/build/type/engine/mapped/mapped_operation.d.mts +4 -4
- package/node_modules/typebox/build/type/engine/mapped/mapped_operation.mjs +3 -3
- package/node_modules/typebox/build/type/engine/mapped/mapped_variants.d.mts +5 -4
- package/node_modules/typebox/build/type/engine/mapped/mapped_variants.mjs +10 -5
- package/node_modules/typebox/build/type/engine/module/instantiate.d.mts +7 -9
- package/node_modules/typebox/build/type/engine/module/instantiate.mjs +17 -15
- package/node_modules/typebox/build/type/engine/object/from_dependent.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/object/from_dependent.mjs +8 -0
- package/node_modules/typebox/build/type/engine/object/from_type.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/object/from_type.mjs +8 -5
- package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +14 -0
- package/node_modules/typebox/build/type/engine/optional/instantiate_remove.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/optional/instantiate_remove.mjs +14 -0
- package/node_modules/typebox/build/type/engine/parameters/instantiate.d.mts +3 -4
- package/node_modules/typebox/build/type/engine/parameters/instantiate.mjs +2 -1
- package/node_modules/typebox/build/type/engine/partial/from_dependent.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/partial/from_dependent.mjs +8 -0
- package/node_modules/typebox/build/type/engine/partial/from_intersect.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/partial/from_intersect.mjs +3 -2
- package/node_modules/typebox/build/type/engine/partial/from_object.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/partial/from_object.mjs +2 -2
- package/node_modules/typebox/build/type/engine/partial/from_type.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/partial/from_type.mjs +7 -4
- package/node_modules/typebox/build/type/engine/priority/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/priority/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/priority/priority.d.mts +20 -0
- package/node_modules/typebox/build/type/engine/priority/priority.mjs +28 -0
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +14 -0
- package/node_modules/typebox/build/type/engine/readonly/instantiate_remove.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/readonly/instantiate_remove.mjs +14 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_array.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_array.mjs +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_dependent.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_dependent.mjs +8 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_intersect.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/readonly_object/from_intersect.mjs +3 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_object.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_object.mjs +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_tuple.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_tuple.mjs +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_type.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/readonly_object/from_type.mjs +8 -5
- package/node_modules/typebox/build/type/engine/record/from_key_enum.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/record/from_key_enum.mjs +2 -2
- package/node_modules/typebox/build/type/engine/record/from_key_template_literal.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/record/from_key_template_literal.mjs +2 -2
- package/node_modules/typebox/build/type/engine/ref/instantiate.d.mts +3 -3
- package/node_modules/typebox/build/type/engine/ref/instantiate.mjs +6 -6
- package/node_modules/typebox/build/type/engine/required/from_dependent.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/required/from_dependent.mjs +8 -0
- package/node_modules/typebox/build/type/engine/required/from_intersect.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/required/from_intersect.mjs +3 -2
- package/node_modules/typebox/build/type/engine/required/from_object.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/required/from_object.mjs +2 -2
- package/node_modules/typebox/build/type/engine/required/from_type.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/required/from_type.mjs +7 -4
- package/node_modules/typebox/build/type/engine/template_literal/decode.mjs +3 -3
- package/node_modules/typebox/build/type/engine/template_literal/encode.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/template_literal/encode.mjs +6 -6
- package/node_modules/typebox/build/type/engine/template_literal/is_finite.mjs +1 -1
- package/node_modules/typebox/build/type/engine/template_literal/is_pattern.mjs +1 -0
- package/node_modules/typebox/build/type/engine/this/expand_this.d.mts +1 -4
- package/node_modules/typebox/build/type/engine/this/expand_this.mjs +7 -13
- package/node_modules/typebox/build/type/engine/with/instantiate.d.mts +8 -0
- package/node_modules/typebox/build/type/engine/{options → with}/instantiate.mjs +5 -5
- package/node_modules/typebox/build/type/extends/dependent.d.mts +6 -0
- package/node_modules/typebox/build/type/extends/dependent.mjs +6 -0
- package/node_modules/typebox/build/type/extends/enum.d.mts +4 -4
- package/node_modules/typebox/build/type/extends/enum.mjs +3 -2
- package/node_modules/typebox/build/type/extends/extends_left.d.mts +5 -7
- package/node_modules/typebox/build/type/extends/extends_left.mjs +24 -27
- package/node_modules/typebox/build/type/extends/extends_right.d.mts +7 -5
- package/node_modules/typebox/build/type/extends/extends_right.mjs +20 -15
- package/node_modules/typebox/build/type/extends/inference.mjs +1 -1
- package/node_modules/typebox/build/type/extends/object.d.mts +8 -1
- package/node_modules/typebox/build/type/extends/object.mjs +25 -3
- package/node_modules/typebox/build/type/extends/parameters.mjs +2 -2
- package/node_modules/typebox/build/type/extends/record.d.mts +13 -0
- package/node_modules/typebox/build/type/extends/record.mjs +23 -0
- package/node_modules/typebox/build/type/extends/template_literal.d.mts +3 -3
- package/node_modules/typebox/build/type/extends/template_literal.mjs +3 -3
- package/node_modules/typebox/build/type/extends/tuple.d.mts +3 -6
- package/node_modules/typebox/build/type/extends/tuple.mjs +6 -5
- package/node_modules/typebox/build/type/extends/union.mjs +2 -2
- package/node_modules/typebox/build/type/script/mapping.d.mts +84 -99
- package/node_modules/typebox/build/type/script/mapping.mjs +81 -85
- package/node_modules/typebox/build/type/script/parser.d.mts +40 -40
- package/node_modules/typebox/build/type/script/parser.mjs +22 -22
- package/node_modules/typebox/build/type/script/script.d.mts +3 -4
- package/node_modules/typebox/build/type/script/script.mjs +3 -2
- package/node_modules/typebox/build/type/script/token/internal/guard.d.mts +1 -1
- package/node_modules/typebox/build/type/script/token/internal/guard.mjs +1 -1
- package/node_modules/typebox/build/type/script/token/internal/take.mjs +1 -1
- package/node_modules/typebox/build/type/script/token/until.mjs +2 -2
- package/node_modules/typebox/build/type/types/_codec.d.mts +12 -12
- package/node_modules/typebox/build/type/types/_codec.mjs +0 -1
- package/node_modules/typebox/build/type/types/_immutable.d.mts +2 -9
- package/node_modules/typebox/build/type/types/_immutable.mjs +2 -10
- package/node_modules/typebox/build/type/types/_optional.d.mts +2 -9
- package/node_modules/typebox/build/type/types/_optional.mjs +2 -11
- package/node_modules/typebox/build/type/types/_readonly.d.mts +2 -9
- package/node_modules/typebox/build/type/types/_readonly.mjs +2 -10
- package/node_modules/typebox/build/type/types/_refine.d.mts +8 -10
- package/node_modules/typebox/build/type/types/_refine.mjs +1 -2
- package/node_modules/typebox/build/type/types/call.d.mts +3 -3
- package/node_modules/typebox/build/type/types/call.mjs +3 -2
- package/node_modules/typebox/build/type/types/deferred.d.mts +1 -0
- package/node_modules/typebox/build/type/types/deferred.mjs +1 -1
- package/node_modules/typebox/build/type/types/dependent.d.mts +17 -0
- package/node_modules/typebox/build/type/types/dependent.mjs +24 -0
- package/node_modules/typebox/build/type/types/enum.d.mts +3 -1
- package/node_modules/typebox/build/type/types/enum.mjs +5 -0
- package/node_modules/typebox/build/type/types/index.d.mts +1 -4
- package/node_modules/typebox/build/type/types/index.mjs +1 -4
- package/node_modules/typebox/build/type/types/number.d.mts +1 -1
- package/node_modules/typebox/build/type/types/number.mjs +1 -1
- package/node_modules/typebox/build/type/types/record.d.mts +13 -7
- package/node_modules/typebox/build/type/types/record.mjs +15 -9
- package/node_modules/typebox/build/type/types/static.d.mts +2 -5
- package/node_modules/typebox/build/typebox.d.mts +4 -8
- package/node_modules/typebox/build/typebox.mjs +4 -8
- package/node_modules/typebox/build/value/clean/clean.mjs +4 -2
- package/node_modules/typebox/build/value/clean/from_intersect.mjs +2 -2
- package/node_modules/typebox/build/value/clean/from_type.mjs +8 -10
- package/node_modules/typebox/build/value/clean/from_union.d.mts +1 -1
- package/node_modules/typebox/build/value/clean/from_union.mjs +1 -2
- package/node_modules/typebox/build/value/clone/clone.mjs +2 -73
- package/node_modules/typebox/build/value/codec/decode.mjs +4 -2
- package/node_modules/typebox/build/value/codec/encode.mjs +4 -2
- package/node_modules/typebox/build/value/codec/from_array.mjs +1 -4
- package/node_modules/typebox/build/value/codec/from_object.mjs +1 -4
- package/node_modules/typebox/build/value/codec/from_record.mjs +2 -7
- package/node_modules/typebox/build/value/codec/from_tuple.mjs +1 -4
- package/node_modules/typebox/build/value/codec/from_union.mjs +2 -3
- package/node_modules/typebox/build/value/convert/from_enum.mjs +3 -4
- package/node_modules/typebox/build/value/convert/from_template_literal.d.mts +1 -1
- package/node_modules/typebox/build/value/convert/from_template_literal.mjs +2 -3
- package/node_modules/typebox/build/value/convert/from_type.mjs +19 -21
- package/node_modules/typebox/build/value/create/from_enum.mjs +2 -2
- package/node_modules/typebox/build/value/create/from_type.mjs +23 -31
- package/node_modules/typebox/build/value/default/from_object.mjs +1 -1
- package/node_modules/typebox/build/value/default/from_type.mjs +8 -10
- package/node_modules/typebox/build/value/index.d.mts +0 -1
- package/node_modules/typebox/build/value/index.mjs +0 -1
- package/node_modules/typebox/build/value/repair/from_enum.mjs +2 -3
- package/node_modules/typebox/build/value/repair/from_type.mjs +24 -22
- package/node_modules/typebox/build/value/shared/union_priority_sort.d.mts +6 -2
- package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +62 -26
- package/node_modules/typebox/build/value/value.d.mts +0 -1
- package/node_modules/typebox/build/value/value.mjs +0 -1
- package/node_modules/typebox/package.json +25 -25
- package/node_modules/typebox/readme.md +97 -80
- package/npm-shrinkwrap.json +59 -54
- package/package.json +10 -10
- package/dist/probe.runtime-DFt7PIoE.js +0 -3
- package/node_modules/@babel/runtime/helpers/AwaitValue.js +0 -4
- package/node_modules/@babel/runtime/helpers/applyDecs.js +0 -236
- package/node_modules/@babel/runtime/helpers/applyDecs2203.js +0 -184
- package/node_modules/@babel/runtime/helpers/applyDecs2203R.js +0 -191
- package/node_modules/@babel/runtime/helpers/applyDecs2301.js +0 -222
- package/node_modules/@babel/runtime/helpers/applyDecs2305.js +0 -133
- package/node_modules/@babel/runtime/helpers/classApplyDescriptorDestructureSet.js +0 -10
- package/node_modules/@babel/runtime/helpers/classApplyDescriptorGet.js +0 -4
- package/node_modules/@babel/runtime/helpers/classApplyDescriptorSet.js +0 -7
- package/node_modules/@babel/runtime/helpers/classCheckPrivateStaticAccess.js +0 -5
- package/node_modules/@babel/runtime/helpers/classCheckPrivateStaticFieldDescriptor.js +0 -4
- package/node_modules/@babel/runtime/helpers/classExtractFieldDescriptor.js +0 -5
- package/node_modules/@babel/runtime/helpers/classPrivateFieldDestructureSet.js +0 -7
- package/node_modules/@babel/runtime/helpers/classPrivateFieldGet.js +0 -7
- package/node_modules/@babel/runtime/helpers/classPrivateFieldSet.js +0 -7
- package/node_modules/@babel/runtime/helpers/classPrivateMethodGet.js +0 -5
- package/node_modules/@babel/runtime/helpers/classPrivateMethodSet.js +0 -4
- package/node_modules/@babel/runtime/helpers/classStaticPrivateFieldDestructureSet.js +0 -7
- package/node_modules/@babel/runtime/helpers/classStaticPrivateFieldSpecGet.js +0 -7
- package/node_modules/@babel/runtime/helpers/classStaticPrivateFieldSpecSet.js +0 -7
- package/node_modules/@babel/runtime/helpers/classStaticPrivateMethodSet.js +0 -4
- package/node_modules/@babel/runtime/helpers/decorate.js +0 -250
- package/node_modules/@babel/runtime/helpers/defineEnumerableProperties.js +0 -12
- package/node_modules/@babel/runtime/helpers/dispose.js +0 -28
- package/node_modules/@babel/runtime/helpers/esm/AwaitValue.js +0 -4
- package/node_modules/@babel/runtime/helpers/esm/applyDecs.js +0 -236
- package/node_modules/@babel/runtime/helpers/esm/applyDecs2203.js +0 -184
- package/node_modules/@babel/runtime/helpers/esm/applyDecs2203R.js +0 -191
- package/node_modules/@babel/runtime/helpers/esm/applyDecs2301.js +0 -222
- package/node_modules/@babel/runtime/helpers/esm/applyDecs2305.js +0 -133
- package/node_modules/@babel/runtime/helpers/esm/classApplyDescriptorDestructureSet.js +0 -10
- package/node_modules/@babel/runtime/helpers/esm/classApplyDescriptorGet.js +0 -4
- package/node_modules/@babel/runtime/helpers/esm/classApplyDescriptorSet.js +0 -7
- package/node_modules/@babel/runtime/helpers/esm/classCheckPrivateStaticAccess.js +0 -5
- package/node_modules/@babel/runtime/helpers/esm/classCheckPrivateStaticFieldDescriptor.js +0 -4
- package/node_modules/@babel/runtime/helpers/esm/classExtractFieldDescriptor.js +0 -5
- package/node_modules/@babel/runtime/helpers/esm/classPrivateFieldDestructureSet.js +0 -7
- package/node_modules/@babel/runtime/helpers/esm/classPrivateFieldGet.js +0 -7
- package/node_modules/@babel/runtime/helpers/esm/classPrivateFieldSet.js +0 -7
- package/node_modules/@babel/runtime/helpers/esm/classPrivateMethodGet.js +0 -5
- package/node_modules/@babel/runtime/helpers/esm/classPrivateMethodSet.js +0 -4
- package/node_modules/@babel/runtime/helpers/esm/classStaticPrivateFieldDestructureSet.js +0 -7
- package/node_modules/@babel/runtime/helpers/esm/classStaticPrivateFieldSpecGet.js +0 -7
- package/node_modules/@babel/runtime/helpers/esm/classStaticPrivateFieldSpecSet.js +0 -7
- package/node_modules/@babel/runtime/helpers/esm/classStaticPrivateMethodSet.js +0 -4
- package/node_modules/@babel/runtime/helpers/esm/decorate.js +0 -250
- package/node_modules/@babel/runtime/helpers/esm/defineEnumerableProperties.js +0 -12
- package/node_modules/@babel/runtime/helpers/esm/dispose.js +0 -28
- package/node_modules/@babel/runtime/helpers/esm/objectSpread.js +0 -14
- package/node_modules/@babel/runtime/helpers/esm/regeneratorRuntime.js +0 -77
- package/node_modules/@babel/runtime/helpers/esm/using.js +0 -12
- package/node_modules/@babel/runtime/helpers/objectSpread.js +0 -14
- package/node_modules/@babel/runtime/helpers/regeneratorRuntime.js +0 -77
- package/node_modules/@babel/runtime/helpers/using.js +0 -12
- package/node_modules/@babel/runtime/regenerator/index.js +0 -15
- package/node_modules/content-type/HISTORY.md +0 -29
- package/node_modules/content-type/index.js +0 -225
- package/node_modules/media-typer/HISTORY.md +0 -50
- package/node_modules/media-typer/index.js +0 -143
- package/node_modules/typebox/build/schema/engine/_guard.d.mts +0 -6
- package/node_modules/typebox/build/schema/engine/_guard.mjs +0 -26
- package/node_modules/typebox/build/schema/types/_guard.d.mts +0 -10
- package/node_modules/typebox/build/schema/types/_guard.mjs +0 -16
- package/node_modules/typebox/build/type/action/_optional.d.mts +0 -19
- package/node_modules/typebox/build/type/action/_optional.mjs +0 -40
- package/node_modules/typebox/build/type/action/_readonly.d.mts +0 -19
- package/node_modules/typebox/build/type/action/_readonly.mjs +0 -40
- package/node_modules/typebox/build/type/action/awaited.d.mts +0 -15
- package/node_modules/typebox/build/type/action/awaited.mjs +0 -15
- package/node_modules/typebox/build/type/action/options.d.mts +0 -11
- package/node_modules/typebox/build/type/action/options.mjs +0 -11
- package/node_modules/typebox/build/type/engine/awaited/instantiate.d.mts +0 -11
- package/node_modules/typebox/build/type/engine/awaited/instantiate.mjs +0 -20
- package/node_modules/typebox/build/type/engine/enum/enum_to_union.d.mts +0 -14
- package/node_modules/typebox/build/type/engine/enum/enum_to_union.mjs +0 -24
- package/node_modules/typebox/build/type/engine/options/index.d.mts +0 -1
- package/node_modules/typebox/build/type/engine/options/index.mjs +0 -1
- package/node_modules/typebox/build/type/engine/options/instantiate.d.mts +0 -8
- package/node_modules/typebox/build/type/extends/async_iterator.d.mts +0 -7
- package/node_modules/typebox/build/type/extends/async_iterator.mjs +0 -9
- package/node_modules/typebox/build/type/extends/iterator.d.mts +0 -7
- package/node_modules/typebox/build/type/extends/iterator.mjs +0 -9
- package/node_modules/typebox/build/type/extends/promise.d.mts +0 -7
- package/node_modules/typebox/build/type/extends/promise.mjs +0 -9
- package/node_modules/typebox/build/type/types/async_iterator.d.mts +0 -20
- package/node_modules/typebox/build/type/types/async_iterator.mjs +0 -28
- package/node_modules/typebox/build/type/types/base.d.mts +0 -50
- package/node_modules/typebox/build/type/types/base.mjs +0 -84
- package/node_modules/typebox/build/type/types/iterator.d.mts +0 -20
- package/node_modules/typebox/build/type/types/iterator.mjs +0 -28
- package/node_modules/typebox/build/type/types/promise.d.mts +0 -21
- package/node_modules/typebox/build/type/types/promise.mjs +0 -29
- package/node_modules/typebox/build/value/clean/from_base.d.mts +0 -2
- package/node_modules/typebox/build/value/clean/from_base.mjs +0 -4
- package/node_modules/typebox/build/value/convert/from_base.d.mts +0 -2
- package/node_modules/typebox/build/value/convert/from_base.mjs +0 -4
- package/node_modules/typebox/build/value/create/from_async_iterator.d.mts +0 -2
- package/node_modules/typebox/build/value/create/from_async_iterator.mjs +0 -5
- package/node_modules/typebox/build/value/create/from_base.d.mts +0 -2
- package/node_modules/typebox/build/value/create/from_base.mjs +0 -4
- package/node_modules/typebox/build/value/create/from_iterator.d.mts +0 -2
- package/node_modules/typebox/build/value/create/from_iterator.mjs +0 -5
- package/node_modules/typebox/build/value/create/from_promise.d.mts +0 -2
- package/node_modules/typebox/build/value/create/from_promise.mjs +0 -5
- package/node_modules/typebox/build/value/default/from_base.d.mts +0 -2
- package/node_modules/typebox/build/value/default/from_base.mjs +0 -5
- package/node_modules/typebox/build/value/mutate/error.d.mts +0 -3
- package/node_modules/typebox/build/value/mutate/error.mjs +0 -6
- package/node_modules/typebox/build/value/mutate/from_array.d.mts +0 -2
- package/node_modules/typebox/build/value/mutate/from_array.mjs +0 -16
- package/node_modules/typebox/build/value/mutate/from_object.d.mts +0 -2
- package/node_modules/typebox/build/value/mutate/from_object.mjs +0 -40
- package/node_modules/typebox/build/value/mutate/from_unknown.d.mts +0 -2
- package/node_modules/typebox/build/value/mutate/from_unknown.mjs +0 -7
- package/node_modules/typebox/build/value/mutate/from_value.d.mts +0 -2
- package/node_modules/typebox/build/value/mutate/from_value.mjs +0 -12
- package/node_modules/typebox/build/value/mutate/index.d.mts +0 -1
- package/node_modules/typebox/build/value/mutate/index.mjs +0 -1
- package/node_modules/typebox/build/value/mutate/mutate.d.mts +0 -11
- package/node_modules/typebox/build/value/mutate/mutate.mjs +0 -41
- package/node_modules/typebox/build/value/repair/from_base.d.mts +0 -2
- package/node_modules/typebox/build/value/repair/from_base.mjs +0 -8
- /package/node_modules/typebox/build/type/engine/{awaited → with}/index.d.mts +0 -0
- /package/node_modules/typebox/build/type/engine/{awaited → with}/index.mjs +0 -0
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
3
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
-
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; }
|
|
5
|
-
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; }
|
|
6
3
|
/*
|
|
7
4
|
Copyright 2022-2023 The Matrix.org Foundation C.I.C.
|
|
8
5
|
|
|
@@ -49,9 +46,9 @@ import { DehydratedDeviceManager } from "./DehydratedDeviceManager.js";
|
|
|
49
46
|
import { VerificationMethod } from "../types.js";
|
|
50
47
|
import { keyFromAuthData } from "../common-crypto/key-passphrase.js";
|
|
51
48
|
import { getHttpUriForMxc } from "../content-repo.js";
|
|
52
|
-
|
|
49
|
+
const ALL_VERIFICATION_METHODS = [VerificationMethod.Sas, VerificationMethod.ScanQrCode, VerificationMethod.ShowQrCode, VerificationMethod.Reciprocate];
|
|
53
50
|
/** The maximum time, in milliseconds, since we accepted an invite, that we should accept a key bundle. */
|
|
54
|
-
export
|
|
51
|
+
export const MAX_INVITE_ACCEPTANCE_MS_FOR_KEY_BUNDLE = 24 * 60 * 60 * 1000; // 24 hours
|
|
55
52
|
|
|
56
53
|
/**
|
|
57
54
|
* An implementation of {@link CryptoBackend} using the Rust matrix-sdk-crypto.
|
|
@@ -70,8 +67,8 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
70
67
|
userId, /** The local user's Device ID. */
|
|
71
68
|
_deviceId, /** Interface to server-side secret storage */
|
|
72
69
|
secretStorage, /** Crypto callbacks provided by the application */
|
|
73
|
-
cryptoCallbacks
|
|
74
|
-
|
|
70
|
+
cryptoCallbacks, /** Enable support for encrypted state events under MSC4362. */
|
|
71
|
+
enableEncryptedStateEvents = false) {
|
|
75
72
|
super();
|
|
76
73
|
/**
|
|
77
74
|
* The number of iterations to use when deriving a recovery key from a passphrase.
|
|
@@ -83,6 +80,14 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
83
80
|
_defineProperty(this, "stopped", false);
|
|
84
81
|
/** mapping of roomId → encryptor class */
|
|
85
82
|
_defineProperty(this, "roomEncryptors", {});
|
|
83
|
+
_defineProperty(this, "eventDecryptor", void 0);
|
|
84
|
+
_defineProperty(this, "keyClaimManager", void 0);
|
|
85
|
+
_defineProperty(this, "outgoingRequestProcessor", void 0);
|
|
86
|
+
_defineProperty(this, "crossSigningIdentity", void 0);
|
|
87
|
+
_defineProperty(this, "backupManager", void 0);
|
|
88
|
+
_defineProperty(this, "outgoingRequestsManager", void 0);
|
|
89
|
+
_defineProperty(this, "perSessionBackupDownloader", void 0);
|
|
90
|
+
_defineProperty(this, "dehydratedDeviceManager", void 0);
|
|
86
91
|
_defineProperty(this, "reemitter", new TypedReEmitter(this));
|
|
87
92
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
88
93
|
//
|
|
@@ -163,133 +168,115 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
163
168
|
// can then be deleted.
|
|
164
169
|
this.olmMachine.close();
|
|
165
170
|
}
|
|
166
|
-
encryptEvent(event, _room) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
// once we drop support for the libolm crypto implementation, we can stop passing to-device messages
|
|
186
|
-
// through decryptEvent and hence get rid of this case.
|
|
187
|
-
throw new Error("to-device event was not decrypted in preprocessToDeviceMessages");
|
|
188
|
-
}
|
|
189
|
-
return yield _this2.eventDecryptor.attemptEventDecryption(event, _this2.deviceIsolationMode);
|
|
190
|
-
})();
|
|
171
|
+
async encryptEvent(event, _room) {
|
|
172
|
+
const roomId = event.getRoomId();
|
|
173
|
+
const encryptor = this.roomEncryptors[roomId];
|
|
174
|
+
if (!encryptor) {
|
|
175
|
+
throw new Error(`Cannot encrypt event in unconfigured room ${roomId}`);
|
|
176
|
+
}
|
|
177
|
+
await encryptor.encryptEvent(event, this.globalBlacklistUnverifiedDevices, this.deviceIsolationMode);
|
|
178
|
+
}
|
|
179
|
+
async decryptEvent(event) {
|
|
180
|
+
const roomId = event.getRoomId();
|
|
181
|
+
if (!roomId) {
|
|
182
|
+
// presumably, a to-device message. These are normally decrypted in preprocessToDeviceMessages
|
|
183
|
+
// so the fact it has come back here suggests that decryption failed.
|
|
184
|
+
//
|
|
185
|
+
// once we drop support for the libolm crypto implementation, we can stop passing to-device messages
|
|
186
|
+
// through decryptEvent and hence get rid of this case.
|
|
187
|
+
throw new Error("to-device event was not decrypted in preprocessToDeviceMessages");
|
|
188
|
+
}
|
|
189
|
+
return await this.eventDecryptor.attemptEventDecryption(event, this.deviceIsolationMode);
|
|
191
190
|
}
|
|
192
191
|
|
|
193
192
|
/**
|
|
194
193
|
* Implementation of {@link CryptoBackend#getBackupDecryptor}.
|
|
195
194
|
*/
|
|
196
|
-
getBackupDecryptor(backupInfo, privKey) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
return _this3.backupManager.createBackupDecryptor(backupDecryptionKey);
|
|
210
|
-
})();
|
|
195
|
+
async getBackupDecryptor(backupInfo, privKey) {
|
|
196
|
+
if (!(privKey instanceof Uint8Array)) {
|
|
197
|
+
throw new Error(`getBackupDecryptor: expects Uint8Array`);
|
|
198
|
+
}
|
|
199
|
+
if (backupInfo.algorithm != "m.megolm_backup.v1.curve25519-aes-sha2") {
|
|
200
|
+
throw new Error(`getBackupDecryptor: Unsupported algorithm ${backupInfo.algorithm}`);
|
|
201
|
+
}
|
|
202
|
+
const backupDecryptionKey = RustSdkCryptoJs.BackupDecryptionKey.fromBase64(encodeBase64(privKey));
|
|
203
|
+
if (!decryptionKeyMatchesKeyBackupInfo(backupDecryptionKey, backupInfo)) {
|
|
204
|
+
throw new Error(`getBackupDecryptor: key backup on server does not match the decryption key`);
|
|
205
|
+
}
|
|
206
|
+
return this.backupManager.createBackupDecryptor(backupDecryptionKey);
|
|
211
207
|
}
|
|
212
208
|
|
|
213
209
|
/**
|
|
214
210
|
* Implementation of {@link CryptoBackend#importBackedUpRoomKeys}.
|
|
215
211
|
*/
|
|
216
|
-
importBackedUpRoomKeys(keys, backupVersion, opts) {
|
|
217
|
-
|
|
218
|
-
return _asyncToGenerator(function* () {
|
|
219
|
-
return yield _this4.backupManager.importBackedUpRoomKeys(keys, backupVersion, opts);
|
|
220
|
-
})();
|
|
212
|
+
async importBackedUpRoomKeys(keys, backupVersion, opts) {
|
|
213
|
+
return await this.backupManager.importBackedUpRoomKeys(keys, backupVersion, opts);
|
|
221
214
|
}
|
|
222
215
|
|
|
223
216
|
/**
|
|
224
217
|
* Implementation of {@link CryptoBackend.maybeAcceptKeyBundle}.
|
|
225
218
|
*/
|
|
226
|
-
maybeAcceptKeyBundle(roomId, inviter) {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
// TODO: retry this if it gets interrupted or it fails. (https://github.com/matrix-org/matrix-rust-sdk/issues/5112)
|
|
230
|
-
// TODO: do this in the background.
|
|
219
|
+
async maybeAcceptKeyBundle(roomId, inviter) {
|
|
220
|
+
// TODO: retry this if it gets interrupted or it fails. (https://github.com/matrix-org/matrix-rust-sdk/issues/5112)
|
|
221
|
+
// TODO: do this in the background.
|
|
231
222
|
|
|
232
|
-
|
|
223
|
+
const logger = new LogSpan(this.logger, `maybeAcceptKeyBundle(${roomId}, ${inviter})`);
|
|
233
224
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
})();
|
|
225
|
+
// Make sure we have an up-to-date idea of the inviter's cross-signing keys, so that we can check if the
|
|
226
|
+
// device that sent us the bundle data was correctly cross-signed.
|
|
227
|
+
//
|
|
228
|
+
// TODO: it would be nice to skip this step if we have an up-to-date copy of the inviter's cross-signing keys,
|
|
229
|
+
// but we don't have an easy way to check that. Possibly the rust side could trigger a key request and then
|
|
230
|
+
// block until it happens.
|
|
231
|
+
logger.info(`Checking inviter cross-signing keys`);
|
|
232
|
+
const request = this.olmMachine.queryKeysForUsers([new RustSdkCryptoJs.UserId(inviter)]);
|
|
233
|
+
await this.outgoingRequestProcessor.makeOutgoingRequest(request);
|
|
234
|
+
const bundleData = await this.olmMachine.getReceivedRoomKeyBundleData(new RustSdkCryptoJs.RoomId(roomId), new RustSdkCryptoJs.UserId(inviter));
|
|
235
|
+
if (!bundleData) {
|
|
236
|
+
logger.info("No key bundle found for user");
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
logger.info(`Fetching key bundle ${bundleData.url}`);
|
|
240
|
+
const url = getHttpUriForMxc(this.http.opts.baseUrl, bundleData.url, undefined, undefined, undefined, /* allowDirectLinks */false, /* allowRedirects */true, /* useAuthentication */true);
|
|
241
|
+
let encryptedBundle;
|
|
242
|
+
try {
|
|
243
|
+
const bundleUrl = new URL(url);
|
|
244
|
+
const encryptedBundleBlob = await this.http.authedRequest(Method.Get, bundleUrl.pathname + bundleUrl.search, {}, undefined, {
|
|
245
|
+
rawResponseBody: true,
|
|
246
|
+
prefix: ""
|
|
247
|
+
});
|
|
248
|
+
logger.info(`Received blob of length ${encryptedBundleBlob.size}`);
|
|
249
|
+
encryptedBundle = new Uint8Array(await encryptedBundleBlob.arrayBuffer());
|
|
250
|
+
} catch (err) {
|
|
251
|
+
logger.warn(`Error downloading encrypted bundle from ${url}:`, err);
|
|
252
|
+
throw err;
|
|
253
|
+
}
|
|
254
|
+
try {
|
|
255
|
+
await this.olmMachine.receiveRoomKeyBundle(bundleData, encryptedBundle);
|
|
256
|
+
} catch (err) {
|
|
257
|
+
logger.warn(`Error receiving encrypted bundle:`, err);
|
|
258
|
+
throw err;
|
|
259
|
+
} finally {
|
|
260
|
+
// Even if we were unable to import the bundle, we still clear the flag that indicates that we
|
|
261
|
+
// are waiting for the bundle to be received. The only reason this can happen is that the bundle was
|
|
262
|
+
// malformed somehow, so we don't want to keep retrying it.
|
|
263
|
+
await this.olmMachine.clearRoomPendingKeyBundle(new RustSdkCryptoJs.RoomId(roomId));
|
|
264
|
+
}
|
|
265
|
+
return true;
|
|
276
266
|
}
|
|
277
267
|
|
|
278
268
|
/**
|
|
279
269
|
* Implementation of {@link CryptoBackend.markRoomAsPendingKeyBundle}.
|
|
280
270
|
*/
|
|
281
|
-
markRoomAsPendingKeyBundle(roomId, inviter) {
|
|
282
|
-
|
|
283
|
-
return _asyncToGenerator(function* () {
|
|
284
|
-
yield _this6.olmMachine.storeRoomPendingKeyBundle(new RustSdkCryptoJs.RoomId(roomId), new RustSdkCryptoJs.UserId(inviter));
|
|
285
|
-
})();
|
|
271
|
+
async markRoomAsPendingKeyBundle(roomId, inviter) {
|
|
272
|
+
await this.olmMachine.storeRoomPendingKeyBundle(new RustSdkCryptoJs.RoomId(roomId), new RustSdkCryptoJs.UserId(inviter));
|
|
286
273
|
}
|
|
287
274
|
/**
|
|
288
275
|
* Implementation of {@link CryptoApi#getVersion}.
|
|
289
276
|
*/
|
|
290
277
|
getVersion() {
|
|
291
|
-
|
|
292
|
-
return
|
|
278
|
+
const versions = RustSdkCryptoJs.getVersions();
|
|
279
|
+
return `Rust SDK ${versions.matrix_sdk_crypto} (${versions.git_sha}), Vodozemac ${versions.vodozemac}`;
|
|
293
280
|
}
|
|
294
281
|
|
|
295
282
|
/**
|
|
@@ -302,122 +289,93 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
302
289
|
/**
|
|
303
290
|
* Implementation of {@link CryptoApi#isEncryptionEnabledInRoom}.
|
|
304
291
|
*/
|
|
305
|
-
isEncryptionEnabledInRoom(roomId) {
|
|
306
|
-
|
|
307
|
-
return
|
|
308
|
-
var roomSettings = yield _this7.olmMachine.getRoomSettings(new RustSdkCryptoJs.RoomId(roomId));
|
|
309
|
-
return Boolean(roomSettings === null || roomSettings === void 0 ? void 0 : roomSettings.algorithm);
|
|
310
|
-
})();
|
|
292
|
+
async isEncryptionEnabledInRoom(roomId) {
|
|
293
|
+
const roomSettings = await this.olmMachine.getRoomSettings(new RustSdkCryptoJs.RoomId(roomId));
|
|
294
|
+
return Boolean(roomSettings?.algorithm);
|
|
311
295
|
}
|
|
312
296
|
|
|
313
297
|
/**
|
|
314
298
|
* Implementation of {@link CryptoApi#isStateEncryptionEnabledInRoom}.
|
|
315
299
|
*/
|
|
316
|
-
isStateEncryptionEnabledInRoom(roomId) {
|
|
317
|
-
|
|
318
|
-
return
|
|
319
|
-
var roomSettings = yield _this8.olmMachine.getRoomSettings(new RustSdkCryptoJs.RoomId(roomId));
|
|
320
|
-
return Boolean(roomSettings === null || roomSettings === void 0 ? void 0 : roomSettings.encryptStateEvents);
|
|
321
|
-
})();
|
|
300
|
+
async isStateEncryptionEnabledInRoom(roomId) {
|
|
301
|
+
const roomSettings = await this.olmMachine.getRoomSettings(new RustSdkCryptoJs.RoomId(roomId));
|
|
302
|
+
return Boolean(roomSettings?.encryptStateEvents);
|
|
322
303
|
}
|
|
323
304
|
|
|
324
305
|
/**
|
|
325
306
|
* Implementation of {@link CryptoApi#getOwnDeviceKeys}.
|
|
326
307
|
*/
|
|
327
|
-
getOwnDeviceKeys() {
|
|
328
|
-
|
|
329
|
-
return
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
curve25519: keys.curve25519.toBase64()
|
|
334
|
-
};
|
|
335
|
-
})();
|
|
308
|
+
async getOwnDeviceKeys() {
|
|
309
|
+
const keys = this.olmMachine.identityKeys;
|
|
310
|
+
return {
|
|
311
|
+
ed25519: keys.ed25519.toBase64(),
|
|
312
|
+
curve25519: keys.curve25519.toBase64()
|
|
313
|
+
};
|
|
336
314
|
}
|
|
337
315
|
prepareToEncrypt(room) {
|
|
338
|
-
|
|
316
|
+
const encryptor = this.roomEncryptors[room.roomId];
|
|
339
317
|
if (encryptor) {
|
|
340
318
|
encryptor.prepareForEncryption(this.globalBlacklistUnverifiedDevices, this.deviceIsolationMode);
|
|
341
319
|
}
|
|
342
320
|
}
|
|
343
321
|
forceDiscardSession(roomId) {
|
|
344
|
-
|
|
345
|
-
return (_this$roomEncryptors$ = this.roomEncryptors[roomId]) === null || _this$roomEncryptors$ === void 0 ? void 0 : _this$roomEncryptors$.forceDiscardSession();
|
|
322
|
+
return this.roomEncryptors[roomId]?.forceDiscardSession();
|
|
346
323
|
}
|
|
347
|
-
exportRoomKeys() {
|
|
348
|
-
|
|
349
|
-
return
|
|
350
|
-
var raw = yield _this0.olmMachine.exportRoomKeys(() => true);
|
|
351
|
-
return JSON.parse(raw);
|
|
352
|
-
})();
|
|
324
|
+
async exportRoomKeys() {
|
|
325
|
+
const raw = await this.olmMachine.exportRoomKeys(() => true);
|
|
326
|
+
return JSON.parse(raw);
|
|
353
327
|
}
|
|
354
|
-
exportRoomKeysAsJson() {
|
|
355
|
-
|
|
356
|
-
return _asyncToGenerator(function* () {
|
|
357
|
-
return yield _this1.olmMachine.exportRoomKeys(() => true);
|
|
358
|
-
})();
|
|
328
|
+
async exportRoomKeysAsJson() {
|
|
329
|
+
return await this.olmMachine.exportRoomKeys(() => true);
|
|
359
330
|
}
|
|
360
|
-
importRoomKeys(keys, opts) {
|
|
361
|
-
|
|
362
|
-
return _asyncToGenerator(function* () {
|
|
363
|
-
return yield _this10.backupManager.importRoomKeys(keys, opts);
|
|
364
|
-
})();
|
|
331
|
+
async importRoomKeys(keys, opts) {
|
|
332
|
+
return await this.backupManager.importRoomKeys(keys, opts);
|
|
365
333
|
}
|
|
366
|
-
importRoomKeysAsJson(keys, opts) {
|
|
367
|
-
|
|
368
|
-
return _asyncToGenerator(function* () {
|
|
369
|
-
return yield _this11.backupManager.importRoomKeysAsJson(keys, opts);
|
|
370
|
-
})();
|
|
334
|
+
async importRoomKeysAsJson(keys, opts) {
|
|
335
|
+
return await this.backupManager.importRoomKeysAsJson(keys, opts);
|
|
371
336
|
}
|
|
372
337
|
|
|
373
338
|
/**
|
|
374
339
|
* Implementation of {@link CryptoApi.userHasCrossSigningKeys}.
|
|
375
340
|
*/
|
|
376
|
-
userHasCrossSigningKeys() {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
var rustTrackedUser;
|
|
385
|
-
for (var u of rustTrackedUsers) {
|
|
386
|
-
if (userId === u.toString()) {
|
|
387
|
-
rustTrackedUser = u;
|
|
388
|
-
break;
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
if (rustTrackedUser !== undefined) {
|
|
392
|
-
if (userId === _this12.userId) {
|
|
393
|
-
/* make sure we have an *up-to-date* idea of the user's cross-signing keys. This is important, because if we
|
|
394
|
-
* return "false" here, we will end up generating new cross-signing keys and replacing the existing ones.
|
|
395
|
-
*/
|
|
396
|
-
var request = _this12.olmMachine.queryKeysForUsers(
|
|
397
|
-
// clone as rust layer will take ownership and it's reused later
|
|
398
|
-
[rustTrackedUser.clone()]);
|
|
399
|
-
yield _this12.outgoingRequestProcessor.makeOutgoingRequest(request);
|
|
400
|
-
}
|
|
401
|
-
var userIdentity = yield _this12.olmMachine.getIdentity(rustTrackedUser);
|
|
402
|
-
userIdentity === null || userIdentity === void 0 || userIdentity.free();
|
|
403
|
-
return userIdentity !== undefined;
|
|
404
|
-
} else if (downloadUncached) {
|
|
405
|
-
var _keyResult$master_key;
|
|
406
|
-
// Download the cross signing keys and check if the master key is available
|
|
407
|
-
var keyResult = yield _this12.downloadDeviceList(new Set([userId]));
|
|
408
|
-
var keys = (_keyResult$master_key = keyResult.master_keys) === null || _keyResult$master_key === void 0 ? void 0 : _keyResult$master_key[userId];
|
|
409
|
-
|
|
410
|
-
// No master key
|
|
411
|
-
if (!keys) return false;
|
|
412
|
-
|
|
413
|
-
// `keys` is an object with { [`ed25519:${pubKey}`]: pubKey }
|
|
414
|
-
// We assume only a single key, and we want the bare form without type
|
|
415
|
-
// prefix, so we select the values.
|
|
416
|
-
return Boolean(Object.values(keys.keys)[0]);
|
|
417
|
-
} else {
|
|
418
|
-
return false;
|
|
341
|
+
async userHasCrossSigningKeys(userId = this.userId, downloadUncached = false) {
|
|
342
|
+
// TODO: could probably do with a more efficient way of doing this than returning the whole set and searching
|
|
343
|
+
const rustTrackedUsers = await this.olmMachine.trackedUsers();
|
|
344
|
+
let rustTrackedUser;
|
|
345
|
+
for (const u of rustTrackedUsers) {
|
|
346
|
+
if (userId === u.toString()) {
|
|
347
|
+
rustTrackedUser = u;
|
|
348
|
+
break;
|
|
419
349
|
}
|
|
420
|
-
}
|
|
350
|
+
}
|
|
351
|
+
if (rustTrackedUser !== undefined) {
|
|
352
|
+
if (userId === this.userId) {
|
|
353
|
+
/* make sure we have an *up-to-date* idea of the user's cross-signing keys. This is important, because if we
|
|
354
|
+
* return "false" here, we will end up generating new cross-signing keys and replacing the existing ones.
|
|
355
|
+
*/
|
|
356
|
+
const request = this.olmMachine.queryKeysForUsers(
|
|
357
|
+
// clone as rust layer will take ownership and it's reused later
|
|
358
|
+
[rustTrackedUser.clone()]);
|
|
359
|
+
await this.outgoingRequestProcessor.makeOutgoingRequest(request);
|
|
360
|
+
}
|
|
361
|
+
const userIdentity = await this.olmMachine.getIdentity(rustTrackedUser);
|
|
362
|
+
userIdentity?.free();
|
|
363
|
+
return userIdentity !== undefined;
|
|
364
|
+
} else if (downloadUncached) {
|
|
365
|
+
// Download the cross signing keys and check if the master key is available
|
|
366
|
+
const keyResult = await this.downloadDeviceList(new Set([userId]));
|
|
367
|
+
const keys = keyResult.master_keys?.[userId];
|
|
368
|
+
|
|
369
|
+
// No master key
|
|
370
|
+
if (!keys) return false;
|
|
371
|
+
|
|
372
|
+
// `keys` is an object with { [`ed25519:${pubKey}`]: pubKey }
|
|
373
|
+
// We assume only a single key, and we want the bare form without type
|
|
374
|
+
// prefix, so we select the values.
|
|
375
|
+
return Boolean(Object.values(keys.keys)[0]);
|
|
376
|
+
} else {
|
|
377
|
+
return false;
|
|
378
|
+
}
|
|
421
379
|
}
|
|
422
380
|
|
|
423
381
|
/**
|
|
@@ -429,98 +387,82 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
429
387
|
*
|
|
430
388
|
* @returns A map `{@link DeviceMap}`.
|
|
431
389
|
*/
|
|
432
|
-
getUserDeviceInfo(userIds) {
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
//
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
if (trackedUsers.has(_userId)) {
|
|
451
|
-
deviceMapByUserId.set(_userId, yield _this13.getUserDevices(_userId));
|
|
452
|
-
} else {
|
|
453
|
-
untrackedUsers.add(_userId);
|
|
454
|
-
}
|
|
390
|
+
async getUserDeviceInfo(userIds, downloadUncached = false) {
|
|
391
|
+
const deviceMapByUserId = new Map();
|
|
392
|
+
const rustTrackedUsers = await this.getOlmMachineOrThrow().trackedUsers();
|
|
393
|
+
|
|
394
|
+
// Convert RustSdkCryptoJs.UserId to a `Set<string>`
|
|
395
|
+
const trackedUsers = new Set();
|
|
396
|
+
rustTrackedUsers.forEach(rustUserId => trackedUsers.add(rustUserId.toString()));
|
|
397
|
+
|
|
398
|
+
// Keep untracked user to download their keys after
|
|
399
|
+
const untrackedUsers = new Set();
|
|
400
|
+
for (const userId of userIds) {
|
|
401
|
+
// if this is a tracked user, we can just fetch the device list from the rust-sdk
|
|
402
|
+
// (NB: this is probably ok even if we race with a leave event such that we stop tracking the user's
|
|
403
|
+
// devices: the rust-sdk will return the last-known device list, which will be good enough.)
|
|
404
|
+
if (trackedUsers.has(userId)) {
|
|
405
|
+
deviceMapByUserId.set(userId, await this.getUserDevices(userId));
|
|
406
|
+
} else {
|
|
407
|
+
untrackedUsers.add(userId);
|
|
455
408
|
}
|
|
409
|
+
}
|
|
456
410
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
deviceKeys = _ref2[1];
|
|
465
|
-
return deviceMapByUserId.set(userId, deviceKeysToDeviceMap(deviceKeys));
|
|
466
|
-
});
|
|
467
|
-
}
|
|
468
|
-
return deviceMapByUserId;
|
|
469
|
-
})();
|
|
411
|
+
// for any users whose device lists we are not tracking, fall back to downloading the device list
|
|
412
|
+
// over HTTP.
|
|
413
|
+
if (downloadUncached && untrackedUsers.size >= 1) {
|
|
414
|
+
const queryResult = await this.downloadDeviceList(untrackedUsers);
|
|
415
|
+
Object.entries(queryResult.device_keys).forEach(([userId, deviceKeys]) => deviceMapByUserId.set(userId, deviceKeysToDeviceMap(deviceKeys)));
|
|
416
|
+
}
|
|
417
|
+
return deviceMapByUserId;
|
|
470
418
|
}
|
|
471
419
|
|
|
472
420
|
/**
|
|
473
421
|
* Get the device list for the given user from the olm machine
|
|
474
422
|
* @param userId - Rust SDK UserId
|
|
475
423
|
*/
|
|
476
|
-
getUserDevices(userId) {
|
|
477
|
-
|
|
478
|
-
return _asyncToGenerator(function* () {
|
|
479
|
-
var rustUserId = new RustSdkCryptoJs.UserId(userId);
|
|
480
|
-
|
|
481
|
-
// For reasons I don't really understand, the Javascript FinalizationRegistry doesn't seem to run the
|
|
482
|
-
// registered callbacks when `userDevices` goes out of scope, nor when the individual devices in the array
|
|
483
|
-
// returned by `userDevices.devices` do so.
|
|
484
|
-
//
|
|
485
|
-
// This is particularly problematic, because each of those structures holds a reference to the
|
|
486
|
-
// VerificationMachine, which in turn holds a reference to the IndexeddbCryptoStore. Hence, we end up leaking
|
|
487
|
-
// open connections to the crypto store, which means the store can't be deleted on logout.
|
|
488
|
-
//
|
|
489
|
-
// To fix this, we explicitly call `.free` on each of the objects, which tells the rust code to drop the
|
|
490
|
-
// allocated memory and decrement the refcounts for the crypto store.
|
|
424
|
+
async getUserDevices(userId) {
|
|
425
|
+
const rustUserId = new RustSdkCryptoJs.UserId(userId);
|
|
491
426
|
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
427
|
+
// For reasons I don't really understand, the Javascript FinalizationRegistry doesn't seem to run the
|
|
428
|
+
// registered callbacks when `userDevices` goes out of scope, nor when the individual devices in the array
|
|
429
|
+
// returned by `userDevices.devices` do so.
|
|
430
|
+
//
|
|
431
|
+
// This is particularly problematic, because each of those structures holds a reference to the
|
|
432
|
+
// VerificationMachine, which in turn holds a reference to the IndexeddbCryptoStore. Hence, we end up leaking
|
|
433
|
+
// open connections to the crypto store, which means the store can't be deleted on logout.
|
|
434
|
+
//
|
|
435
|
+
// To fix this, we explicitly call `.free` on each of the objects, which tells the rust code to drop the
|
|
436
|
+
// allocated memory and decrement the refcounts for the crypto store.
|
|
437
|
+
|
|
438
|
+
// Wait for up to a second for any in-flight device list requests to complete.
|
|
439
|
+
// The reason for this isn't so much to avoid races (some level of raciness is
|
|
440
|
+
// inevitable for this method) but to make testing easier.
|
|
441
|
+
const userDevices = await this.olmMachine.getUserDevices(rustUserId, 1);
|
|
442
|
+
try {
|
|
443
|
+
const deviceArray = userDevices.devices();
|
|
496
444
|
try {
|
|
497
|
-
|
|
498
|
-
try {
|
|
499
|
-
return new Map(deviceArray.map(device => [device.deviceId.toString(), rustDeviceToJsDevice(device, rustUserId)]));
|
|
500
|
-
} finally {
|
|
501
|
-
deviceArray.forEach(d => d.free());
|
|
502
|
-
}
|
|
445
|
+
return new Map(deviceArray.map(device => [device.deviceId.toString(), rustDeviceToJsDevice(device, rustUserId)]));
|
|
503
446
|
} finally {
|
|
504
|
-
|
|
447
|
+
deviceArray.forEach(d => d.free());
|
|
505
448
|
}
|
|
506
|
-
}
|
|
449
|
+
} finally {
|
|
450
|
+
userDevices.free();
|
|
451
|
+
}
|
|
507
452
|
}
|
|
508
453
|
|
|
509
454
|
/**
|
|
510
455
|
* Download the given user keys by calling `/keys/query` request
|
|
511
456
|
* @param untrackedUsers - download keys of these users
|
|
512
457
|
*/
|
|
513
|
-
downloadDeviceList(untrackedUsers) {
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
prefix: ""
|
|
522
|
-
});
|
|
523
|
-
})();
|
|
458
|
+
async downloadDeviceList(untrackedUsers) {
|
|
459
|
+
const queryBody = {
|
|
460
|
+
device_keys: {}
|
|
461
|
+
};
|
|
462
|
+
untrackedUsers.forEach(user => queryBody.device_keys[user] = []);
|
|
463
|
+
return await this.http.authedRequest(Method.Post, "/_matrix/client/v3/keys/query", undefined, queryBody, {
|
|
464
|
+
prefix: ""
|
|
465
|
+
});
|
|
524
466
|
}
|
|
525
467
|
|
|
526
468
|
/**
|
|
@@ -544,21 +486,16 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
544
486
|
*
|
|
545
487
|
* Implementation of {@link CryptoApi#setDeviceVerified}.
|
|
546
488
|
*/
|
|
547
|
-
setDeviceVerified(userId, deviceId) {
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
yield device.setLocalTrust(verified ? RustSdkCryptoJs.LocalTrust.Verified : RustSdkCryptoJs.LocalTrust.Unset);
|
|
558
|
-
} finally {
|
|
559
|
-
device.free();
|
|
560
|
-
}
|
|
561
|
-
})();
|
|
489
|
+
async setDeviceVerified(userId, deviceId, verified = true) {
|
|
490
|
+
const device = await this.olmMachine.getDevice(new RustSdkCryptoJs.UserId(userId), new RustSdkCryptoJs.DeviceId(deviceId));
|
|
491
|
+
if (!device) {
|
|
492
|
+
throw new Error(`Unknown device ${userId}|${deviceId}`);
|
|
493
|
+
}
|
|
494
|
+
try {
|
|
495
|
+
await device.setLocalTrust(verified ? RustSdkCryptoJs.LocalTrust.Verified : RustSdkCryptoJs.LocalTrust.Unset);
|
|
496
|
+
} finally {
|
|
497
|
+
device.free();
|
|
498
|
+
}
|
|
562
499
|
}
|
|
563
500
|
|
|
564
501
|
/**
|
|
@@ -566,287 +503,269 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
566
503
|
*
|
|
567
504
|
* Implementation of {@link CryptoApi#crossSignDevice}.
|
|
568
505
|
*/
|
|
569
|
-
crossSignDevice(deviceId) {
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
device.free();
|
|
581
|
-
}
|
|
582
|
-
})();
|
|
506
|
+
async crossSignDevice(deviceId) {
|
|
507
|
+
const device = await this.olmMachine.getDevice(new RustSdkCryptoJs.UserId(this.userId), new RustSdkCryptoJs.DeviceId(deviceId));
|
|
508
|
+
if (!device) {
|
|
509
|
+
throw new Error(`Unknown device ${deviceId}`);
|
|
510
|
+
}
|
|
511
|
+
try {
|
|
512
|
+
const outgoingRequest = await device.verify();
|
|
513
|
+
await this.outgoingRequestProcessor.makeOutgoingRequest(outgoingRequest);
|
|
514
|
+
} finally {
|
|
515
|
+
device.free();
|
|
516
|
+
}
|
|
583
517
|
}
|
|
584
518
|
|
|
585
519
|
/**
|
|
586
520
|
* Implementation of {@link CryptoApi#getDeviceVerificationStatus}.
|
|
587
521
|
*/
|
|
588
|
-
getDeviceVerificationStatus(userId, deviceId) {
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
device.free();
|
|
602
|
-
}
|
|
603
|
-
})();
|
|
522
|
+
async getDeviceVerificationStatus(userId, deviceId) {
|
|
523
|
+
const device = await this.olmMachine.getDevice(new RustSdkCryptoJs.UserId(userId), new RustSdkCryptoJs.DeviceId(deviceId));
|
|
524
|
+
if (!device) return null;
|
|
525
|
+
try {
|
|
526
|
+
return new DeviceVerificationStatus({
|
|
527
|
+
signedByOwner: device.isCrossSignedByOwner(),
|
|
528
|
+
crossSigningVerified: device.isCrossSigningTrusted(),
|
|
529
|
+
localVerified: device.isLocallyTrusted(),
|
|
530
|
+
trustCrossSignedDevices: this._trustCrossSignedDevices
|
|
531
|
+
});
|
|
532
|
+
} finally {
|
|
533
|
+
device.free();
|
|
534
|
+
}
|
|
604
535
|
}
|
|
605
536
|
|
|
606
537
|
/**
|
|
607
538
|
* Implementation of {@link CryptoApi#getUserVerificationStatus}.
|
|
608
539
|
*/
|
|
609
|
-
getUserVerificationStatus(userId) {
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
userIdentity.free();
|
|
620
|
-
return new UserVerificationStatus(verified, wasVerified, true, needsUserApproval);
|
|
621
|
-
})();
|
|
540
|
+
async getUserVerificationStatus(userId) {
|
|
541
|
+
const userIdentity = await this.getOlmMachineOrThrow().getIdentity(new RustSdkCryptoJs.UserId(userId));
|
|
542
|
+
if (userIdentity === undefined) {
|
|
543
|
+
return new UserVerificationStatus(false, false, false);
|
|
544
|
+
}
|
|
545
|
+
const verified = userIdentity.isVerified();
|
|
546
|
+
const wasVerified = userIdentity.wasPreviouslyVerified();
|
|
547
|
+
const needsUserApproval = userIdentity instanceof RustSdkCryptoJs.OtherUserIdentity ? userIdentity.identityNeedsUserApproval() : false;
|
|
548
|
+
userIdentity.free();
|
|
549
|
+
return new UserVerificationStatus(verified, wasVerified, true, needsUserApproval);
|
|
622
550
|
}
|
|
623
551
|
|
|
624
552
|
/**
|
|
625
553
|
* Implementation of {@link CryptoApi#pinCurrentUserIdentity}.
|
|
626
554
|
*/
|
|
627
|
-
pinCurrentUserIdentity(userId) {
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
}
|
|
637
|
-
yield userIdentity.pinCurrentMasterKey();
|
|
638
|
-
})();
|
|
555
|
+
async pinCurrentUserIdentity(userId) {
|
|
556
|
+
const userIdentity = await this.getOlmMachineOrThrow().getIdentity(new RustSdkCryptoJs.UserId(userId));
|
|
557
|
+
if (userIdentity === undefined) {
|
|
558
|
+
throw new Error("Cannot pin identity of unknown user");
|
|
559
|
+
}
|
|
560
|
+
if (userIdentity instanceof RustSdkCryptoJs.OwnUserIdentity) {
|
|
561
|
+
throw new Error("Cannot pin identity of own user");
|
|
562
|
+
}
|
|
563
|
+
await userIdentity.pinCurrentMasterKey();
|
|
639
564
|
}
|
|
640
565
|
|
|
641
566
|
/**
|
|
642
567
|
* Implementation of {@link CryptoApi#withdrawVerificationRequirement}.
|
|
643
568
|
*/
|
|
644
|
-
withdrawVerificationRequirement(userId) {
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
569
|
+
async withdrawVerificationRequirement(userId) {
|
|
570
|
+
const userIdentity = await this.getOlmMachineOrThrow().getIdentity(new RustSdkCryptoJs.UserId(userId));
|
|
571
|
+
if (userIdentity === undefined) {
|
|
572
|
+
throw new Error("Cannot withdraw verification of unknown user");
|
|
573
|
+
}
|
|
574
|
+
await userIdentity.withdrawVerification();
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Implementation of {@link CryptoApi#getUserCrossSigningKeys}.
|
|
579
|
+
*/
|
|
580
|
+
async getUserCrossSigningKeys(userId) {
|
|
581
|
+
const userIdentity = await this.getOlmMachineOrThrow().getIdentity(new RustSdkCryptoJs.UserId(userId));
|
|
582
|
+
if (!userIdentity) {
|
|
583
|
+
return null;
|
|
584
|
+
}
|
|
585
|
+
const result = {
|
|
586
|
+
master_key: JSON.parse(userIdentity.masterKey),
|
|
587
|
+
self_signing_key: JSON.parse(userIdentity.selfSigningKey)
|
|
588
|
+
};
|
|
589
|
+
|
|
590
|
+
// The USK is only visible for our own identity
|
|
591
|
+
if ("userSigningKey" in userIdentity) {
|
|
592
|
+
result.user_signing_key = JSON.parse(userIdentity.userSigningKey);
|
|
593
|
+
}
|
|
594
|
+
return result;
|
|
653
595
|
}
|
|
654
596
|
|
|
655
597
|
/**
|
|
656
598
|
* Implementation of {@link CryptoApi#isCrossSigningReady}
|
|
657
599
|
*/
|
|
658
|
-
isCrossSigningReady() {
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
var identity = yield _this22.getOwnIdentity();
|
|
600
|
+
async isCrossSigningReady() {
|
|
601
|
+
const {
|
|
602
|
+
privateKeysInSecretStorage,
|
|
603
|
+
privateKeysCachedLocally
|
|
604
|
+
} = await this.getCrossSigningStatus();
|
|
605
|
+
const hasKeysInCache = Boolean(privateKeysCachedLocally.masterKey) && Boolean(privateKeysCachedLocally.selfSigningKey) && Boolean(privateKeysCachedLocally.userSigningKey);
|
|
606
|
+
const identity = await this.getOwnIdentity();
|
|
666
607
|
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
})();
|
|
608
|
+
// Cross-signing is ready if the public identity is trusted, and the private keys
|
|
609
|
+
// are either cached, or accessible via secret-storage.
|
|
610
|
+
return !!identity?.isVerified() && (hasKeysInCache || privateKeysInSecretStorage);
|
|
671
611
|
}
|
|
672
612
|
|
|
673
613
|
/**
|
|
674
614
|
* Implementation of {@link CryptoApi#getCrossSigningKeyId}
|
|
675
615
|
*/
|
|
676
|
-
getCrossSigningKeyId() {
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
616
|
+
async getCrossSigningKeyId(type = CrossSigningKey.Master) {
|
|
617
|
+
const userIdentity = await this.getOwnIdentity();
|
|
618
|
+
if (!userIdentity) {
|
|
619
|
+
// The public keys are not available on this device
|
|
620
|
+
return null;
|
|
621
|
+
}
|
|
622
|
+
try {
|
|
623
|
+
const crossSigningStatus = await this.olmMachine.crossSigningStatus();
|
|
624
|
+
const privateKeysOnDevice = crossSigningStatus.hasMaster && crossSigningStatus.hasUserSigning && crossSigningStatus.hasSelfSigning;
|
|
625
|
+
if (!privateKeysOnDevice) {
|
|
626
|
+
// The private keys are not available on this device
|
|
684
627
|
return null;
|
|
685
628
|
}
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
629
|
+
if (!userIdentity.isVerified()) {
|
|
630
|
+
// We have both public and private keys, but they don't match!
|
|
631
|
+
return null;
|
|
632
|
+
}
|
|
633
|
+
let key;
|
|
634
|
+
switch (type) {
|
|
635
|
+
case CrossSigningKey.Master:
|
|
636
|
+
key = userIdentity.masterKey;
|
|
637
|
+
break;
|
|
638
|
+
case CrossSigningKey.SelfSigning:
|
|
639
|
+
key = userIdentity.selfSigningKey;
|
|
640
|
+
break;
|
|
641
|
+
case CrossSigningKey.UserSigning:
|
|
642
|
+
key = userIdentity.userSigningKey;
|
|
643
|
+
break;
|
|
644
|
+
default:
|
|
645
|
+
// Unknown type
|
|
695
646
|
return null;
|
|
696
|
-
}
|
|
697
|
-
var key;
|
|
698
|
-
switch (type) {
|
|
699
|
-
case CrossSigningKey.Master:
|
|
700
|
-
key = userIdentity.masterKey;
|
|
701
|
-
break;
|
|
702
|
-
case CrossSigningKey.SelfSigning:
|
|
703
|
-
key = userIdentity.selfSigningKey;
|
|
704
|
-
break;
|
|
705
|
-
case CrossSigningKey.UserSigning:
|
|
706
|
-
key = userIdentity.userSigningKey;
|
|
707
|
-
break;
|
|
708
|
-
default:
|
|
709
|
-
// Unknown type
|
|
710
|
-
return null;
|
|
711
|
-
}
|
|
712
|
-
var parsedKey = JSON.parse(key);
|
|
713
|
-
// `keys` is an object with { [`ed25519:${pubKey}`]: pubKey }
|
|
714
|
-
// We assume only a single key, and we want the bare form without type
|
|
715
|
-
// prefix, so we select the values.
|
|
716
|
-
return Object.values(parsedKey.keys)[0];
|
|
717
|
-
} finally {
|
|
718
|
-
userIdentity.free();
|
|
719
647
|
}
|
|
720
|
-
|
|
648
|
+
const parsedKey = JSON.parse(key);
|
|
649
|
+
// `keys` is an object with { [`ed25519:${pubKey}`]: pubKey }
|
|
650
|
+
// We assume only a single key, and we want the bare form without type
|
|
651
|
+
// prefix, so we select the values.
|
|
652
|
+
return Object.values(parsedKey.keys)[0];
|
|
653
|
+
} finally {
|
|
654
|
+
userIdentity.free();
|
|
655
|
+
}
|
|
721
656
|
}
|
|
722
657
|
|
|
723
658
|
/**
|
|
724
659
|
* Implementation of {@link CryptoApi#bootstrapCrossSigning}
|
|
725
660
|
*/
|
|
726
|
-
bootstrapCrossSigning(opts) {
|
|
727
|
-
|
|
728
|
-
return _asyncToGenerator(function* () {
|
|
729
|
-
yield _this24.crossSigningIdentity.bootstrapCrossSigning(opts);
|
|
730
|
-
})();
|
|
661
|
+
async bootstrapCrossSigning(opts) {
|
|
662
|
+
await this.crossSigningIdentity.bootstrapCrossSigning(opts);
|
|
731
663
|
}
|
|
732
664
|
|
|
733
665
|
/**
|
|
734
666
|
* Implementation of {@link CryptoApi#isSecretStorageReady}
|
|
735
667
|
*/
|
|
736
|
-
isSecretStorageReady() {
|
|
737
|
-
|
|
738
|
-
return _asyncToGenerator(function* () {
|
|
739
|
-
return (yield _this25.getSecretStorageStatus()).ready;
|
|
740
|
-
})();
|
|
668
|
+
async isSecretStorageReady() {
|
|
669
|
+
return (await this.getSecretStorageStatus()).ready;
|
|
741
670
|
}
|
|
742
671
|
|
|
743
672
|
/**
|
|
744
673
|
* Implementation of {@link CryptoApi#getSecretStorageStatus}
|
|
745
674
|
*/
|
|
746
|
-
getSecretStorageStatus() {
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
// make sure that the cross-signing keys are stored
|
|
750
|
-
var secretsToCheck = ["m.cross_signing.master", "m.cross_signing.user_signing", "m.cross_signing.self_signing"];
|
|
675
|
+
async getSecretStorageStatus() {
|
|
676
|
+
// make sure that the cross-signing keys are stored
|
|
677
|
+
const secretsToCheck = ["m.cross_signing.master", "m.cross_signing.user_signing", "m.cross_signing.self_signing"];
|
|
751
678
|
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
})();
|
|
679
|
+
// If key backup is active, we also need to check that the backup decryption key is stored
|
|
680
|
+
const keyBackupEnabled = (await this.backupManager.getActiveBackupVersion()) != null;
|
|
681
|
+
if (keyBackupEnabled) {
|
|
682
|
+
secretsToCheck.push("m.megolm_backup.v1");
|
|
683
|
+
}
|
|
684
|
+
const defaultKeyId = await this.secretStorage.getDefaultKeyId();
|
|
685
|
+
const result = {
|
|
686
|
+
// Assume we have all secrets until proven otherwise
|
|
687
|
+
ready: true,
|
|
688
|
+
defaultKeyId,
|
|
689
|
+
secretStorageKeyValidityMap: {}
|
|
690
|
+
};
|
|
691
|
+
for (const secretName of secretsToCheck) {
|
|
692
|
+
// Check which keys this particular secret is encrypted with
|
|
693
|
+
const record = (await this.secretStorage.isStored(secretName)) || {};
|
|
694
|
+
|
|
695
|
+
// If it's encrypted with the right key, it is valid
|
|
696
|
+
const secretStored = !!defaultKeyId && defaultKeyId in record;
|
|
697
|
+
result.secretStorageKeyValidityMap[secretName] = secretStored;
|
|
698
|
+
result.ready = result.ready && secretStored;
|
|
699
|
+
}
|
|
700
|
+
return result;
|
|
775
701
|
}
|
|
776
702
|
|
|
777
703
|
/**
|
|
778
704
|
* Implementation of {@link CryptoApi#bootstrapSecretStorage}
|
|
779
705
|
*/
|
|
780
|
-
bootstrapSecretStorage(
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
yield _this27.secretStorage.store("m.cross_signing.user_signing", crossSigningPrivateKeys.userSigningKey);
|
|
813
|
-
yield _this27.secretStorage.store("m.cross_signing.self_signing", crossSigningPrivateKeys.self_signing_key);
|
|
814
|
-
}
|
|
706
|
+
async bootstrapSecretStorage({
|
|
707
|
+
createSecretStorageKey,
|
|
708
|
+
setupNewSecretStorage,
|
|
709
|
+
setupNewKeyBackup
|
|
710
|
+
} = {}) {
|
|
711
|
+
// If an AES Key is already stored in the secret storage and setupNewSecretStorage is not set
|
|
712
|
+
// we don't want to create a new key
|
|
713
|
+
const isNewSecretStorageKeyNeeded = setupNewSecretStorage || !(await this.secretStorageHasAESKey());
|
|
714
|
+
if (isNewSecretStorageKeyNeeded) {
|
|
715
|
+
if (!createSecretStorageKey) {
|
|
716
|
+
throw new Error("unable to create a new secret storage key, createSecretStorageKey is not set");
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
// Create a new storage key and add it to secret storage
|
|
720
|
+
this.logger.info("bootstrapSecretStorage: creating new secret storage key");
|
|
721
|
+
const recoveryKey = await createSecretStorageKey();
|
|
722
|
+
if (!recoveryKey) {
|
|
723
|
+
throw new Error("createSecretStorageKey() callback did not return a secret storage key");
|
|
724
|
+
}
|
|
725
|
+
await this.addSecretStorageKeyToSecretStorage(recoveryKey);
|
|
726
|
+
}
|
|
727
|
+
const crossSigningPrivateKeys = await this.olmMachine.exportCrossSigningKeys();
|
|
728
|
+
const hasPrivateKeys = crossSigningPrivateKeys && crossSigningPrivateKeys.masterKey !== undefined && crossSigningPrivateKeys.self_signing_key !== undefined && crossSigningPrivateKeys.userSigningKey !== undefined;
|
|
729
|
+
|
|
730
|
+
// If we have cross-signing private keys cached, store them in secret
|
|
731
|
+
// storage if they are not there already.
|
|
732
|
+
if (hasPrivateKeys && (isNewSecretStorageKeyNeeded || !(await secretStorageContainsCrossSigningKeys(this.secretStorage)))) {
|
|
733
|
+
this.logger.info("bootstrapSecretStorage: cross-signing keys not yet exported; doing so now.");
|
|
734
|
+
await this.secretStorage.store("m.cross_signing.master", crossSigningPrivateKeys.masterKey);
|
|
735
|
+
await this.secretStorage.store("m.cross_signing.user_signing", crossSigningPrivateKeys.userSigningKey);
|
|
736
|
+
await this.secretStorage.store("m.cross_signing.self_signing", crossSigningPrivateKeys.self_signing_key);
|
|
737
|
+
}
|
|
815
738
|
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
})();
|
|
739
|
+
// likewise with the key backup key: if we have one, store it in secret storage (if it's not already there)
|
|
740
|
+
// also don't bother storing it if we're about to set up a new backup
|
|
741
|
+
if (!setupNewKeyBackup) {
|
|
742
|
+
await this.saveBackupKeyToStorage();
|
|
743
|
+
} else {
|
|
744
|
+
await this.resetKeyBackup();
|
|
745
|
+
}
|
|
824
746
|
}
|
|
825
747
|
|
|
826
748
|
/**
|
|
827
749
|
* If we have a backup key for the current, trusted backup in cache,
|
|
828
750
|
* save it to secret storage.
|
|
829
751
|
*/
|
|
830
|
-
saveBackupKeyToStorage() {
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
var backupKeyBase64 = backupKeys.decryptionKey.toBase64();
|
|
848
|
-
yield _this28.secretStorage.store("m.megolm_backup.v1", backupKeyBase64);
|
|
849
|
-
})();
|
|
752
|
+
async saveBackupKeyToStorage() {
|
|
753
|
+
const keyBackupInfo = await this.backupManager.getServerBackupInfo();
|
|
754
|
+
if (!keyBackupInfo || !keyBackupInfo.version) {
|
|
755
|
+
this.logger.info("Not saving backup key to secret storage: no backup info");
|
|
756
|
+
return;
|
|
757
|
+
}
|
|
758
|
+
const backupKeys = await this.olmMachine.getBackupKeys();
|
|
759
|
+
if (!backupKeys.decryptionKey) {
|
|
760
|
+
this.logger.info("Not saving backup key to secret storage: no backup key");
|
|
761
|
+
return;
|
|
762
|
+
}
|
|
763
|
+
if (!decryptionKeyMatchesKeyBackupInfo(backupKeys.decryptionKey, keyBackupInfo)) {
|
|
764
|
+
this.logger.info("Not saving backup key to secret storage: decryption key does not match backup info");
|
|
765
|
+
return;
|
|
766
|
+
}
|
|
767
|
+
const backupKeyBase64 = backupKeys.decryptionKey.toBase64();
|
|
768
|
+
await this.secretStorage.store("m.megolm_backup.v1", backupKeyBase64);
|
|
850
769
|
}
|
|
851
770
|
|
|
852
771
|
/**
|
|
@@ -857,18 +776,14 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
857
776
|
*
|
|
858
777
|
* @param secretStorageKey - The secret storage key to add in the secret storage.
|
|
859
778
|
*/
|
|
860
|
-
addSecretStorageKeyToSecretStorage(secretStorageKey) {
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
});
|
|
869
|
-
yield _this29.secretStorage.setDefaultKeyId(secretStorageKeyObject.keyId);
|
|
870
|
-
(_this29$cryptoCallbac = (_this29$cryptoCallbac2 = _this29.cryptoCallbacks).cacheSecretStorageKey) === null || _this29$cryptoCallbac === void 0 || _this29$cryptoCallbac.call(_this29$cryptoCallbac2, secretStorageKeyObject.keyId, secretStorageKeyObject.keyInfo, secretStorageKey.privateKey);
|
|
871
|
-
})();
|
|
779
|
+
async addSecretStorageKeyToSecretStorage(secretStorageKey) {
|
|
780
|
+
const secretStorageKeyObject = await this.secretStorage.addKey(SECRET_STORAGE_ALGORITHM_V1_AES, {
|
|
781
|
+
passphrase: secretStorageKey.keyInfo?.passphrase,
|
|
782
|
+
name: secretStorageKey.keyInfo?.name,
|
|
783
|
+
key: secretStorageKey.privateKey
|
|
784
|
+
});
|
|
785
|
+
await this.secretStorage.setDefaultKeyId(secretStorageKeyObject.keyId);
|
|
786
|
+
this.cryptoCallbacks.cacheSecretStorageKey?.(secretStorageKeyObject.keyId, secretStorageKeyObject.keyInfo, secretStorageKey.privateKey);
|
|
872
787
|
}
|
|
873
788
|
|
|
874
789
|
/**
|
|
@@ -876,86 +791,73 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
876
791
|
*
|
|
877
792
|
* @returns True if an AES key is in the secret storage
|
|
878
793
|
*/
|
|
879
|
-
secretStorageHasAESKey() {
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
if (!secretStorageKeyTuple) return false;
|
|
885
|
-
var _secretStorageKeyTupl = _slicedToArray(secretStorageKeyTuple, 2),
|
|
886
|
-
keyInfo = _secretStorageKeyTupl[1];
|
|
794
|
+
async secretStorageHasAESKey() {
|
|
795
|
+
// See if we already have an AES secret-storage key.
|
|
796
|
+
const secretStorageKeyTuple = await this.secretStorage.getKey();
|
|
797
|
+
if (!secretStorageKeyTuple) return false;
|
|
798
|
+
const [, keyInfo] = secretStorageKeyTuple;
|
|
887
799
|
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
})();
|
|
800
|
+
// Check if the key is an AES key
|
|
801
|
+
return keyInfo.algorithm === SECRET_STORAGE_ALGORITHM_V1_AES;
|
|
891
802
|
}
|
|
892
803
|
|
|
893
804
|
/**
|
|
894
805
|
* Implementation of {@link CryptoApi#getCrossSigningStatus}
|
|
895
806
|
*/
|
|
896
|
-
getCrossSigningStatus() {
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
}
|
|
912
|
-
};
|
|
913
|
-
})();
|
|
807
|
+
async getCrossSigningStatus() {
|
|
808
|
+
const userIdentity = await this.getOwnIdentity();
|
|
809
|
+
const publicKeysOnDevice = Boolean(userIdentity?.masterKey) && Boolean(userIdentity?.selfSigningKey) && Boolean(userIdentity?.userSigningKey);
|
|
810
|
+
userIdentity?.free();
|
|
811
|
+
const privateKeysInSecretStorage = await secretStorageContainsCrossSigningKeys(this.secretStorage);
|
|
812
|
+
const crossSigningStatus = await this.getOlmMachineOrThrow().crossSigningStatus();
|
|
813
|
+
return {
|
|
814
|
+
publicKeysOnDevice,
|
|
815
|
+
privateKeysInSecretStorage,
|
|
816
|
+
privateKeysCachedLocally: {
|
|
817
|
+
masterKey: Boolean(crossSigningStatus?.hasMaster),
|
|
818
|
+
userSigningKey: Boolean(crossSigningStatus?.hasUserSigning),
|
|
819
|
+
selfSigningKey: Boolean(crossSigningStatus?.hasSelfSigning)
|
|
820
|
+
}
|
|
821
|
+
};
|
|
914
822
|
}
|
|
915
823
|
|
|
916
824
|
/**
|
|
917
825
|
* Implementation of {@link CryptoApi#createRecoveryKeyFromPassphrase}
|
|
918
826
|
*/
|
|
919
|
-
createRecoveryKeyFromPassphrase(password) {
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
};
|
|
947
|
-
}
|
|
948
|
-
})();
|
|
827
|
+
async createRecoveryKeyFromPassphrase(password) {
|
|
828
|
+
if (password) {
|
|
829
|
+
// Generate the key from the passphrase
|
|
830
|
+
// first we generate a random salt
|
|
831
|
+
const salt = secureRandomString(32);
|
|
832
|
+
// then we derive the key from the passphrase
|
|
833
|
+
const recoveryKey = await deriveRecoveryKeyFromPassphrase(password, salt, this.RECOVERY_KEY_DERIVATION_ITERATIONS);
|
|
834
|
+
return {
|
|
835
|
+
keyInfo: {
|
|
836
|
+
passphrase: {
|
|
837
|
+
algorithm: "m.pbkdf2",
|
|
838
|
+
iterations: this.RECOVERY_KEY_DERIVATION_ITERATIONS,
|
|
839
|
+
salt
|
|
840
|
+
}
|
|
841
|
+
},
|
|
842
|
+
privateKey: recoveryKey,
|
|
843
|
+
encodedPrivateKey: encodeRecoveryKey(recoveryKey)
|
|
844
|
+
};
|
|
845
|
+
} else {
|
|
846
|
+
// Using the navigator crypto API to generate the private key
|
|
847
|
+
const key = new Uint8Array(32);
|
|
848
|
+
globalThis.crypto.getRandomValues(key);
|
|
849
|
+
return {
|
|
850
|
+
privateKey: key,
|
|
851
|
+
encodedPrivateKey: encodeRecoveryKey(key)
|
|
852
|
+
};
|
|
853
|
+
}
|
|
949
854
|
}
|
|
950
855
|
|
|
951
856
|
/**
|
|
952
857
|
* Implementation of {@link CryptoApi#getEncryptionInfoForEvent}.
|
|
953
858
|
*/
|
|
954
|
-
getEncryptionInfoForEvent(event) {
|
|
955
|
-
|
|
956
|
-
return _asyncToGenerator(function* () {
|
|
957
|
-
return _this33.eventDecryptor.getEncryptionInfoForEvent(event);
|
|
958
|
-
})();
|
|
859
|
+
async getEncryptionInfoForEvent(event) {
|
|
860
|
+
return this.eventDecryptor.getEncryptionInfoForEvent(event);
|
|
959
861
|
}
|
|
960
862
|
|
|
961
863
|
/**
|
|
@@ -968,7 +870,7 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
968
870
|
* @returns the VerificationRequests that are in progress
|
|
969
871
|
*/
|
|
970
872
|
getVerificationRequestsToDeviceInProgress(userId) {
|
|
971
|
-
|
|
873
|
+
const requests = this.olmMachine.getVerificationRequests(new RustSdkCryptoJs.UserId(userId));
|
|
972
874
|
return requests.filter(request => request.roomId === undefined && !request.isCancelled()).map(request => this.makeVerificationRequest(request));
|
|
973
875
|
}
|
|
974
876
|
|
|
@@ -985,13 +887,10 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
985
887
|
*/
|
|
986
888
|
findVerificationRequestDMInProgress(roomId, userId) {
|
|
987
889
|
if (!userId) throw new Error("missing userId");
|
|
988
|
-
|
|
890
|
+
const requests = this.olmMachine.getVerificationRequests(new RustSdkCryptoJs.UserId(userId));
|
|
989
891
|
|
|
990
892
|
// Search for the verification request for the given room id
|
|
991
|
-
|
|
992
|
-
var _request$roomId;
|
|
993
|
-
return ((_request$roomId = request.roomId) === null || _request$roomId === void 0 ? void 0 : _request$roomId.toString()) === roomId && !request.isCancelled();
|
|
994
|
-
});
|
|
893
|
+
const request = requests.find(request => request.roomId?.toString() === roomId && !request.isCancelled());
|
|
995
894
|
if (request) {
|
|
996
895
|
return this.makeVerificationRequest(request);
|
|
997
896
|
}
|
|
@@ -1000,32 +899,29 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
1000
899
|
/**
|
|
1001
900
|
* Implementation of {@link CryptoApi#requestVerificationDM}
|
|
1002
901
|
*/
|
|
1003
|
-
requestVerificationDM(userId, roomId) {
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
userIdentity.free();
|
|
1027
|
-
}
|
|
1028
|
-
})();
|
|
902
|
+
async requestVerificationDM(userId, roomId) {
|
|
903
|
+
const userIdentity = await this.olmMachine.getIdentity(new RustSdkCryptoJs.UserId(userId));
|
|
904
|
+
if (!userIdentity) throw new Error(`unknown userId ${userId}`);
|
|
905
|
+
try {
|
|
906
|
+
// Transform the verification methods into rust objects
|
|
907
|
+
const methods = this._supportedVerificationMethods.map(method => verificationMethodIdentifierToMethod(method));
|
|
908
|
+
// Get the request content to send to the DM room
|
|
909
|
+
const verCont = userIdentity.verificationRequestContent(methods);
|
|
910
|
+
|
|
911
|
+
// TODO: due to https://github.com/matrix-org/matrix-rust-sdk/issues/5643, we need to fix up the verification request content to include `msgtype`.
|
|
912
|
+
const verContObj = JSON.parse(verCont);
|
|
913
|
+
verContObj["msgtype"] = "m.key.verification.request";
|
|
914
|
+
const verificationEventContent = JSON.stringify(verContObj);
|
|
915
|
+
|
|
916
|
+
// Send the request content to send to the DM room
|
|
917
|
+
const eventId = await this.sendVerificationRequestContent(roomId, verificationEventContent);
|
|
918
|
+
|
|
919
|
+
// Get a verification request
|
|
920
|
+
const request = userIdentity.requestVerification(new RustSdkCryptoJs.RoomId(roomId), new RustSdkCryptoJs.EventId(eventId), methods);
|
|
921
|
+
return this.makeVerificationRequest(request);
|
|
922
|
+
} finally {
|
|
923
|
+
userIdentity.free();
|
|
924
|
+
}
|
|
1029
925
|
}
|
|
1030
926
|
|
|
1031
927
|
/**
|
|
@@ -1039,17 +935,15 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
1039
935
|
*
|
|
1040
936
|
* @returns the event id
|
|
1041
937
|
*/
|
|
1042
|
-
sendVerificationRequestContent(roomId, verificationEventContent) {
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
return eventId;
|
|
1052
|
-
})();
|
|
938
|
+
async sendVerificationRequestContent(roomId, verificationEventContent) {
|
|
939
|
+
const txId = secureRandomString(32);
|
|
940
|
+
// Send the verification request content to the DM room
|
|
941
|
+
const {
|
|
942
|
+
event_id: eventId
|
|
943
|
+
} = await this.http.authedRequest(Method.Put, `/_matrix/client/v3/rooms/${encodeURIComponent(roomId)}/send/m.room.message/${encodeURIComponent(txId)}`, undefined, verificationEventContent, {
|
|
944
|
+
prefix: ""
|
|
945
|
+
});
|
|
946
|
+
return eventId;
|
|
1053
947
|
}
|
|
1054
948
|
/**
|
|
1055
949
|
* Set the verification methods we offer to the other side during an interactive verification.
|
|
@@ -1058,7 +952,7 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
1058
952
|
*/
|
|
1059
953
|
setSupportedVerificationMethods(methods) {
|
|
1060
954
|
// by default, the Rust SDK does not offer `m.qr_code.scan.v1`, but we do want to offer that.
|
|
1061
|
-
this._supportedVerificationMethods = methods
|
|
955
|
+
this._supportedVerificationMethods = methods ?? ALL_VERIFICATION_METHODS;
|
|
1062
956
|
}
|
|
1063
957
|
|
|
1064
958
|
/**
|
|
@@ -1070,24 +964,18 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
1070
964
|
*
|
|
1071
965
|
* @returns a VerificationRequest when the request has been sent to the other party.
|
|
1072
966
|
*/
|
|
1073
|
-
requestOwnUserVerification() {
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
yield _this36.outgoingRequestProcessor.makeOutgoingRequest(outgoingRequest);
|
|
1086
|
-
return _this36.makeVerificationRequest(request);
|
|
1087
|
-
} finally {
|
|
1088
|
-
userIdentity.free();
|
|
1089
|
-
}
|
|
1090
|
-
})();
|
|
967
|
+
async requestOwnUserVerification() {
|
|
968
|
+
const userIdentity = await this.getOwnIdentity();
|
|
969
|
+
if (userIdentity === undefined) {
|
|
970
|
+
throw new Error("cannot request verification for this device when there is no existing cross-signing key");
|
|
971
|
+
}
|
|
972
|
+
try {
|
|
973
|
+
const [request, outgoingRequest] = await userIdentity.requestVerification(this._supportedVerificationMethods.map(verificationMethodIdentifierToMethod));
|
|
974
|
+
await this.outgoingRequestProcessor.makeOutgoingRequest(outgoingRequest);
|
|
975
|
+
return this.makeVerificationRequest(request);
|
|
976
|
+
} finally {
|
|
977
|
+
userIdentity.free();
|
|
978
|
+
}
|
|
1091
979
|
}
|
|
1092
980
|
|
|
1093
981
|
/**
|
|
@@ -1102,24 +990,18 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
1102
990
|
*
|
|
1103
991
|
* @returns a VerificationRequest when the request has been sent to the other party.
|
|
1104
992
|
*/
|
|
1105
|
-
requestDeviceVerification(userId, deviceId) {
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
yield _this37.outgoingRequestProcessor.makeOutgoingRequest(outgoingRequest);
|
|
1118
|
-
return _this37.makeVerificationRequest(request);
|
|
1119
|
-
} finally {
|
|
1120
|
-
device.free();
|
|
1121
|
-
}
|
|
1122
|
-
})();
|
|
993
|
+
async requestDeviceVerification(userId, deviceId) {
|
|
994
|
+
const device = await this.olmMachine.getDevice(new RustSdkCryptoJs.UserId(userId), new RustSdkCryptoJs.DeviceId(deviceId));
|
|
995
|
+
if (!device) {
|
|
996
|
+
throw new Error("Not a known device");
|
|
997
|
+
}
|
|
998
|
+
try {
|
|
999
|
+
const [request, outgoingRequest] = device.requestVerification(this._supportedVerificationMethods.map(verificationMethodIdentifierToMethod));
|
|
1000
|
+
await this.outgoingRequestProcessor.makeOutgoingRequest(outgoingRequest);
|
|
1001
|
+
return this.makeVerificationRequest(request);
|
|
1002
|
+
} finally {
|
|
1003
|
+
device.free();
|
|
1004
|
+
}
|
|
1123
1005
|
}
|
|
1124
1006
|
|
|
1125
1007
|
/**
|
|
@@ -1129,13 +1011,10 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
1129
1011
|
*
|
|
1130
1012
|
* @returns the key, if any, or null
|
|
1131
1013
|
*/
|
|
1132
|
-
getSessionBackupPrivateKey() {
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
if (!backupKeys.decryptionKey) return null;
|
|
1137
|
-
return decodeBase64(backupKeys.decryptionKey.toBase64());
|
|
1138
|
-
})();
|
|
1014
|
+
async getSessionBackupPrivateKey() {
|
|
1015
|
+
const backupKeys = await this.olmMachine.getBackupKeys();
|
|
1016
|
+
if (!backupKeys.decryptionKey) return null;
|
|
1017
|
+
return decodeBase64(backupKeys.decryptionKey.toBase64());
|
|
1139
1018
|
}
|
|
1140
1019
|
|
|
1141
1020
|
/**
|
|
@@ -1146,37 +1025,31 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
1146
1025
|
* @param key - the backup decryption key
|
|
1147
1026
|
* @param version - the backup version for this key.
|
|
1148
1027
|
*/
|
|
1149
|
-
storeSessionBackupPrivateKey(key, version) {
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
}
|
|
1156
|
-
yield _this39.backupManager.saveBackupDecryptionKey(RustSdkCryptoJs.BackupDecryptionKey.fromBase64(base64Key), version);
|
|
1157
|
-
})();
|
|
1028
|
+
async storeSessionBackupPrivateKey(key, version) {
|
|
1029
|
+
const base64Key = encodeBase64(key);
|
|
1030
|
+
if (!version) {
|
|
1031
|
+
throw new Error("storeSessionBackupPrivateKey: version is required");
|
|
1032
|
+
}
|
|
1033
|
+
await this.backupManager.saveBackupDecryptionKey(RustSdkCryptoJs.BackupDecryptionKey.fromBase64(base64Key), version);
|
|
1158
1034
|
}
|
|
1159
1035
|
|
|
1160
1036
|
/**
|
|
1161
1037
|
* Implementation of {@link CryptoApi#loadSessionBackupPrivateKeyFromSecretStorage}.
|
|
1162
1038
|
*/
|
|
1163
|
-
loadSessionBackupPrivateKeyFromSecretStorage() {
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
}
|
|
1178
|
-
yield _this40.backupManager.saveBackupDecryptionKey(backupDecryptionKey, keyBackupInfo.version);
|
|
1179
|
-
})();
|
|
1039
|
+
async loadSessionBackupPrivateKeyFromSecretStorage() {
|
|
1040
|
+
const backupKey = await this.secretStorage.get("m.megolm_backup.v1");
|
|
1041
|
+
if (!backupKey) {
|
|
1042
|
+
throw new Error("loadSessionBackupPrivateKeyFromSecretStorage: missing decryption key in secret storage");
|
|
1043
|
+
}
|
|
1044
|
+
const keyBackupInfo = await this.backupManager.getServerBackupInfo();
|
|
1045
|
+
if (!keyBackupInfo || !keyBackupInfo.version) {
|
|
1046
|
+
throw new Error("loadSessionBackupPrivateKeyFromSecretStorage: unable to get backup version");
|
|
1047
|
+
}
|
|
1048
|
+
const backupDecryptionKey = RustSdkCryptoJs.BackupDecryptionKey.fromBase64(backupKey);
|
|
1049
|
+
if (!decryptionKeyMatchesKeyBackupInfo(backupDecryptionKey, keyBackupInfo)) {
|
|
1050
|
+
throw new DecryptionKeyDoesNotMatchError("loadSessionBackupPrivateKeyFromSecretStorage: decryption key does not match backup info");
|
|
1051
|
+
}
|
|
1052
|
+
await this.backupManager.saveBackupDecryptionKey(backupDecryptionKey, keyBackupInfo.version);
|
|
1180
1053
|
}
|
|
1181
1054
|
|
|
1182
1055
|
/**
|
|
@@ -1184,21 +1057,15 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
1184
1057
|
*
|
|
1185
1058
|
* Implementation of {@link CryptoApi#getActiveSessionBackupVersion}.
|
|
1186
1059
|
*/
|
|
1187
|
-
getActiveSessionBackupVersion() {
|
|
1188
|
-
|
|
1189
|
-
return _asyncToGenerator(function* () {
|
|
1190
|
-
return yield _this41.backupManager.getActiveBackupVersion();
|
|
1191
|
-
})();
|
|
1060
|
+
async getActiveSessionBackupVersion() {
|
|
1061
|
+
return await this.backupManager.getActiveBackupVersion();
|
|
1192
1062
|
}
|
|
1193
1063
|
|
|
1194
1064
|
/**
|
|
1195
1065
|
* Implementation of {@link CryptoApi#getKeyBackupInfo}.
|
|
1196
1066
|
*/
|
|
1197
|
-
getKeyBackupInfo() {
|
|
1198
|
-
|
|
1199
|
-
return _asyncToGenerator(function* () {
|
|
1200
|
-
return (yield _this42.backupManager.getServerBackupInfo()) || null;
|
|
1201
|
-
})();
|
|
1067
|
+
async getKeyBackupInfo() {
|
|
1068
|
+
return (await this.backupManager.getServerBackupInfo()) || null;
|
|
1202
1069
|
}
|
|
1203
1070
|
|
|
1204
1071
|
/**
|
|
@@ -1206,11 +1073,8 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
1206
1073
|
*
|
|
1207
1074
|
* Implementation of {@link CryptoApi#isKeyBackupTrusted}.
|
|
1208
1075
|
*/
|
|
1209
|
-
isKeyBackupTrusted(info) {
|
|
1210
|
-
|
|
1211
|
-
return _asyncToGenerator(function* () {
|
|
1212
|
-
return yield _this43.backupManager.isKeyBackupTrusted(info);
|
|
1213
|
-
})();
|
|
1076
|
+
async isKeyBackupTrusted(info) {
|
|
1077
|
+
return await this.backupManager.isKeyBackupTrusted(info);
|
|
1214
1078
|
}
|
|
1215
1079
|
|
|
1216
1080
|
/**
|
|
@@ -1218,61 +1082,49 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
1218
1082
|
*
|
|
1219
1083
|
* Implementation of {@link CryptoApi#checkKeyBackupAndEnable}.
|
|
1220
1084
|
*/
|
|
1221
|
-
checkKeyBackupAndEnable() {
|
|
1222
|
-
|
|
1223
|
-
return _asyncToGenerator(function* () {
|
|
1224
|
-
return yield _this44.backupManager.checkKeyBackupAndEnable(true);
|
|
1225
|
-
})();
|
|
1085
|
+
async checkKeyBackupAndEnable() {
|
|
1086
|
+
return await this.backupManager.checkKeyBackupAndEnable(true);
|
|
1226
1087
|
}
|
|
1227
1088
|
|
|
1228
1089
|
/**
|
|
1229
1090
|
* Implementation of {@link CryptoApi#deleteKeyBackupVersion}.
|
|
1230
1091
|
*/
|
|
1231
|
-
deleteKeyBackupVersion(version) {
|
|
1232
|
-
|
|
1233
|
-
return _asyncToGenerator(function* () {
|
|
1234
|
-
yield _this45.backupManager.deleteKeyBackupVersion(version);
|
|
1235
|
-
})();
|
|
1092
|
+
async deleteKeyBackupVersion(version) {
|
|
1093
|
+
await this.backupManager.deleteKeyBackupVersion(version);
|
|
1236
1094
|
}
|
|
1237
1095
|
|
|
1238
1096
|
/**
|
|
1239
1097
|
* Implementation of {@link CryptoApi#resetKeyBackup}.
|
|
1240
1098
|
*/
|
|
1241
|
-
resetKeyBackup() {
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
var backupInfo = yield _this46.backupManager.setupKeyBackup(o => _this46.signObject(o));
|
|
1245
|
-
yield _this46.pushSecretToVerifiedDevices("m.megolm_backup.v1");
|
|
1099
|
+
async resetKeyBackup() {
|
|
1100
|
+
const backupInfo = await this.backupManager.setupKeyBackup(o => this.signObject(o));
|
|
1101
|
+
await this.pushSecretToVerifiedDevices("m.megolm_backup.v1");
|
|
1246
1102
|
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1103
|
+
// we want to store the private key in 4S
|
|
1104
|
+
// need to check if 4S is set up?
|
|
1105
|
+
if (await this.secretStorageHasAESKey()) {
|
|
1106
|
+
await this.secretStorage.store("m.megolm_backup.v1", backupInfo.decryptionKey.toBase64());
|
|
1107
|
+
}
|
|
1252
1108
|
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
})();
|
|
1109
|
+
// we can check and start async
|
|
1110
|
+
void this.checkKeyBackupAndEnable();
|
|
1256
1111
|
}
|
|
1257
1112
|
|
|
1258
1113
|
/**
|
|
1259
1114
|
* Implementation of {@link CryptoApi#disableKeyStorage}.
|
|
1260
1115
|
*/
|
|
1261
|
-
disableKeyStorage() {
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
_this47.logger.error("Can't delete key backup version: no version available");
|
|
1270
|
-
}
|
|
1116
|
+
async disableKeyStorage() {
|
|
1117
|
+
// Get the key backup version we're using
|
|
1118
|
+
const info = await this.getKeyBackupInfo();
|
|
1119
|
+
if (info?.version) {
|
|
1120
|
+
await this.deleteKeyBackupVersion(info.version);
|
|
1121
|
+
} else {
|
|
1122
|
+
this.logger.error("Can't delete key backup version: no version available");
|
|
1123
|
+
}
|
|
1271
1124
|
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
})();
|
|
1125
|
+
// also turn off 4S, since this is also storing keys on the server.
|
|
1126
|
+
await this.deleteSecretStorage();
|
|
1127
|
+
await this.dehydratedDeviceManager.delete();
|
|
1276
1128
|
}
|
|
1277
1129
|
|
|
1278
1130
|
/**
|
|
@@ -1283,257 +1135,218 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
1283
1135
|
*
|
|
1284
1136
|
* @param obj - The object to sign
|
|
1285
1137
|
*/
|
|
1286
|
-
signObject(obj) {
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
if (unsigned !== undefined) obj.unsigned = unsigned;
|
|
1299
|
-
obj.signatures = Object.fromEntries(sigs.entries());
|
|
1300
|
-
})();
|
|
1138
|
+
async signObject(obj) {
|
|
1139
|
+
const sigs = new Map(Object.entries(obj.signatures || {}));
|
|
1140
|
+
const unsigned = obj.unsigned;
|
|
1141
|
+
delete obj.signatures;
|
|
1142
|
+
delete obj.unsigned;
|
|
1143
|
+
const userSignatures = sigs.get(this.userId) || {};
|
|
1144
|
+
const canonalizedJson = anotherjson.stringify(obj);
|
|
1145
|
+
const signatures = await this.olmMachine.sign(canonalizedJson);
|
|
1146
|
+
const map = JSON.parse(signatures.asJSON());
|
|
1147
|
+
sigs.set(this.userId, _objectSpread(_objectSpread({}, userSignatures), map[this.userId]));
|
|
1148
|
+
if (unsigned !== undefined) obj.unsigned = unsigned;
|
|
1149
|
+
obj.signatures = Object.fromEntries(sigs.entries());
|
|
1301
1150
|
}
|
|
1302
1151
|
|
|
1303
1152
|
/**
|
|
1304
1153
|
* Implementation of {@link CryptoApi#restoreKeyBackupWithPassphrase}.
|
|
1305
1154
|
*/
|
|
1306
|
-
restoreKeyBackupWithPassphrase(passphrase, opts) {
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
}
|
|
1313
|
-
var privateKey = yield keyFromAuthData(backupInfo.auth_data, passphrase);
|
|
1155
|
+
async restoreKeyBackupWithPassphrase(passphrase, opts) {
|
|
1156
|
+
const backupInfo = await this.backupManager.getServerBackupInfo();
|
|
1157
|
+
if (!backupInfo?.version) {
|
|
1158
|
+
throw new Error("No backup info available");
|
|
1159
|
+
}
|
|
1160
|
+
const privateKey = await keyFromAuthData(backupInfo.auth_data, passphrase);
|
|
1314
1161
|
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
})();
|
|
1162
|
+
// Cache the key
|
|
1163
|
+
await this.storeSessionBackupPrivateKey(privateKey, backupInfo.version);
|
|
1164
|
+
return this.restoreKeyBackup(opts);
|
|
1319
1165
|
}
|
|
1320
1166
|
|
|
1321
1167
|
/**
|
|
1322
1168
|
* Implementation of {@link CryptoApi#restoreKeyBackup}.
|
|
1323
1169
|
*/
|
|
1324
|
-
restoreKeyBackup(opts) {
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
}
|
|
1346
|
-
})();
|
|
1170
|
+
async restoreKeyBackup(opts) {
|
|
1171
|
+
// Get the decryption key from the crypto store
|
|
1172
|
+
const backupKeys = await this.olmMachine.getBackupKeys();
|
|
1173
|
+
const {
|
|
1174
|
+
decryptionKey,
|
|
1175
|
+
backupVersion
|
|
1176
|
+
} = backupKeys;
|
|
1177
|
+
if (!decryptionKey || !backupVersion) throw new Error("No decryption key found in crypto store");
|
|
1178
|
+
const decodedDecryptionKey = decodeBase64(decryptionKey.toBase64());
|
|
1179
|
+
const backupInfo = await this.backupManager.requestKeyBackupVersion(backupVersion);
|
|
1180
|
+
if (!backupInfo) throw new Error(`Backup version to restore ${backupVersion} not found on server`);
|
|
1181
|
+
const backupDecryptor = await this.getBackupDecryptor(backupInfo, decodedDecryptionKey);
|
|
1182
|
+
try {
|
|
1183
|
+
opts?.progressCallback?.({
|
|
1184
|
+
stage: ImportRoomKeyStage.Fetch
|
|
1185
|
+
});
|
|
1186
|
+
return await this.backupManager.restoreKeyBackup(backupVersion, backupDecryptor, opts);
|
|
1187
|
+
} finally {
|
|
1188
|
+
// Free to avoid to keep in memory the decryption key stored in it. To avoid to exposing it to an attacker.
|
|
1189
|
+
backupDecryptor.free();
|
|
1190
|
+
}
|
|
1347
1191
|
}
|
|
1348
1192
|
|
|
1349
1193
|
/**
|
|
1350
1194
|
* Implementation of {@link CryptoApi#isDehydrationSupported}.
|
|
1351
1195
|
*/
|
|
1352
|
-
isDehydrationSupported() {
|
|
1353
|
-
|
|
1354
|
-
return _asyncToGenerator(function* () {
|
|
1355
|
-
return yield _this51.dehydratedDeviceManager.isSupported();
|
|
1356
|
-
})();
|
|
1196
|
+
async isDehydrationSupported() {
|
|
1197
|
+
return await this.dehydratedDeviceManager.isSupported();
|
|
1357
1198
|
}
|
|
1358
1199
|
|
|
1359
1200
|
/**
|
|
1360
1201
|
* Implementation of {@link CryptoApi#startDehydration}.
|
|
1361
1202
|
*/
|
|
1362
|
-
startDehydration() {
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
if (!(yield _this52.isCrossSigningReady()) || !(yield _this52.isSecretStorageReady())) {
|
|
1368
|
-
throw new Error("Device dehydration requires cross-signing and secret storage to be set up");
|
|
1369
|
-
}
|
|
1370
|
-
return yield _this52.dehydratedDeviceManager.start(opts || {});
|
|
1371
|
-
})();
|
|
1203
|
+
async startDehydration(opts = {}) {
|
|
1204
|
+
if (!(await this.isCrossSigningReady()) || !(await this.isSecretStorageReady())) {
|
|
1205
|
+
throw new Error("Device dehydration requires cross-signing and secret storage to be set up");
|
|
1206
|
+
}
|
|
1207
|
+
return await this.dehydratedDeviceManager.start(opts || {});
|
|
1372
1208
|
}
|
|
1373
1209
|
|
|
1374
1210
|
/**
|
|
1375
1211
|
* Implementation of {@link CryptoApi#importSecretsBundle}.
|
|
1376
1212
|
*/
|
|
1377
|
-
importSecretsBundle(secrets) {
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
var secretsBundle = RustSdkCryptoJs.SecretsBundle.from_json(secrets);
|
|
1381
|
-
yield _this53.getOlmMachineOrThrow().importSecretsBundle(secretsBundle); // this method frees the SecretsBundle
|
|
1382
|
-
})();
|
|
1213
|
+
async importSecretsBundle(secrets) {
|
|
1214
|
+
const secretsBundle = RustSdkCryptoJs.SecretsBundle.from_json(secrets);
|
|
1215
|
+
await this.getOlmMachineOrThrow().importSecretsBundle(secretsBundle); // this method frees the SecretsBundle
|
|
1383
1216
|
}
|
|
1384
1217
|
|
|
1385
1218
|
/**
|
|
1386
1219
|
* Implementation of {@link CryptoApi#exportSecretsBundle}.
|
|
1387
1220
|
*/
|
|
1388
|
-
exportSecretsBundle() {
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
secretsBundle.free();
|
|
1394
|
-
return secrets;
|
|
1395
|
-
})();
|
|
1221
|
+
async exportSecretsBundle() {
|
|
1222
|
+
const secretsBundle = await this.getOlmMachineOrThrow().exportSecretsBundle();
|
|
1223
|
+
const secrets = secretsBundle.to_json();
|
|
1224
|
+
secretsBundle.free();
|
|
1225
|
+
return secrets;
|
|
1396
1226
|
}
|
|
1397
1227
|
|
|
1398
1228
|
/**
|
|
1399
1229
|
* Implementation of {@link CryptoApi#encryptToDeviceMessages}.
|
|
1400
1230
|
*/
|
|
1401
|
-
encryptToDeviceMessages(eventType, devices, payload) {
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
deviceId,
|
|
1427
|
-
userId,
|
|
1428
|
-
payload: encryptedPayload
|
|
1429
|
-
});
|
|
1430
|
-
} else {
|
|
1431
|
-
_this55.logger.warn("encryptToDeviceMessages: unknown device ".concat(userId, ":").concat(deviceId));
|
|
1432
|
-
}
|
|
1231
|
+
async encryptToDeviceMessages(eventType, devices, payload) {
|
|
1232
|
+
const logger = new LogSpan(this.logger, "encryptToDeviceMessages");
|
|
1233
|
+
const uniqueUsers = new Set(devices.map(({
|
|
1234
|
+
userId
|
|
1235
|
+
}) => userId));
|
|
1236
|
+
|
|
1237
|
+
// This will ensure we have Olm sessions for all of the users' devices.
|
|
1238
|
+
// However, we only care about some of the devices.
|
|
1239
|
+
// So, perhaps we can optimise this later on.
|
|
1240
|
+
await this.keyClaimManager.ensureSessionsForUsers(logger, Array.from(uniqueUsers).map(userId => new RustSdkCryptoJs.UserId(userId)));
|
|
1241
|
+
const batch = {
|
|
1242
|
+
batch: [],
|
|
1243
|
+
eventType: EventType.RoomMessageEncrypted
|
|
1244
|
+
};
|
|
1245
|
+
await Promise.all(devices.map(async ({
|
|
1246
|
+
userId,
|
|
1247
|
+
deviceId
|
|
1248
|
+
}) => {
|
|
1249
|
+
const device = await this.olmMachine.getDevice(new RustSdkCryptoJs.UserId(userId), new RustSdkCryptoJs.DeviceId(deviceId));
|
|
1250
|
+
if (device) {
|
|
1251
|
+
const encryptedPayload = JSON.parse(await device.encryptToDeviceEvent(eventType, payload));
|
|
1252
|
+
batch.batch.push({
|
|
1253
|
+
deviceId,
|
|
1254
|
+
userId,
|
|
1255
|
+
payload: encryptedPayload
|
|
1433
1256
|
});
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
})();
|
|
1257
|
+
} else {
|
|
1258
|
+
this.logger.warn(`encryptToDeviceMessages: unknown device ${userId}:${deviceId}`);
|
|
1259
|
+
}
|
|
1260
|
+
}));
|
|
1261
|
+
return batch;
|
|
1440
1262
|
}
|
|
1441
1263
|
|
|
1442
1264
|
/**
|
|
1443
1265
|
* Implementation of {@link CryptoApi#resetEncryption}.
|
|
1444
1266
|
*/
|
|
1445
|
-
resetEncryption(authUploadDeviceSigningKeys) {
|
|
1446
|
-
|
|
1447
|
-
return _asyncToGenerator(function* () {
|
|
1448
|
-
_this56.logger.debug("resetEncryption: resetting encryption");
|
|
1267
|
+
async resetEncryption(authUploadDeviceSigningKeys) {
|
|
1268
|
+
this.logger.debug("resetEncryption: resetting encryption");
|
|
1449
1269
|
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1270
|
+
// Delete the dehydrated device, since any existing one will be signed
|
|
1271
|
+
// by the wrong cross-signing key
|
|
1272
|
+
void this.dehydratedDeviceManager.delete();
|
|
1453
1273
|
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1274
|
+
// Disable backup, and delete all the backups from the server
|
|
1275
|
+
await this.backupManager.deleteAllKeyBackupVersions();
|
|
1276
|
+
await this.deleteSecretStorage();
|
|
1457
1277
|
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1278
|
+
// Reset the cross-signing keys
|
|
1279
|
+
await this.crossSigningIdentity.bootstrapCrossSigning({
|
|
1280
|
+
setupNewCrossSigning: true,
|
|
1281
|
+
authUploadDeviceSigningKeys
|
|
1282
|
+
});
|
|
1463
1283
|
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
})();
|
|
1284
|
+
// Create a new key backup
|
|
1285
|
+
await this.resetKeyBackup();
|
|
1286
|
+
this.logger.debug("resetEncryption: ended");
|
|
1468
1287
|
}
|
|
1469
1288
|
|
|
1470
1289
|
/**
|
|
1471
1290
|
* Removes the secret storage key, default key pointer and all (known) secret storage data
|
|
1472
1291
|
* from the user's account data
|
|
1473
1292
|
*/
|
|
1474
|
-
deleteSecretStorage() {
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
yield _this57.secretStorage.store("m.cross_signing.user_signing", null);
|
|
1481
|
-
yield _this57.secretStorage.store("m.megolm_backup.v1", null);
|
|
1293
|
+
async deleteSecretStorage() {
|
|
1294
|
+
// Remove the stored secrets in the secret storage
|
|
1295
|
+
await this.secretStorage.store("m.cross_signing.master", null);
|
|
1296
|
+
await this.secretStorage.store("m.cross_signing.self_signing", null);
|
|
1297
|
+
await this.secretStorage.store("m.cross_signing.user_signing", null);
|
|
1298
|
+
await this.secretStorage.store("m.megolm_backup.v1", null);
|
|
1482
1299
|
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
})();
|
|
1300
|
+
// Remove the recovery key
|
|
1301
|
+
const defaultKeyId = await this.secretStorage.getDefaultKeyId();
|
|
1302
|
+
if (defaultKeyId) await this.secretStorage.store(`m.secret_storage.key.${defaultKeyId}`, null);
|
|
1303
|
+
// Disable the recovery key and the secret storage
|
|
1304
|
+
await this.secretStorage.setDefaultKeyId(null);
|
|
1489
1305
|
}
|
|
1490
1306
|
|
|
1491
1307
|
/**
|
|
1492
1308
|
* Implementation of {@link CryptoApi#shareRoomHistoryWithUser}.
|
|
1493
1309
|
*/
|
|
1494
|
-
shareRoomHistoryWithUser(roomId, userId) {
|
|
1495
|
-
|
|
1496
|
-
return _asyncToGenerator(function* () {
|
|
1497
|
-
var logger = new LogSpan(_this58.logger, "shareRoomHistoryWithUser(".concat(roomId, ", ").concat(userId, ")"));
|
|
1310
|
+
async shareRoomHistoryWithUser(roomId, userId) {
|
|
1311
|
+
const logger = new LogSpan(this.logger, `shareRoomHistoryWithUser(${roomId}, ${userId})`);
|
|
1498
1312
|
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1313
|
+
// 0. We can only share room history if our user has set up cross-signing.
|
|
1314
|
+
const identity = await this.getOwnIdentity();
|
|
1315
|
+
if (!identity?.isVerified()) {
|
|
1316
|
+
logger.warn("Not sharing message history as the current device is not verified by our cross-signing identity");
|
|
1317
|
+
return;
|
|
1318
|
+
}
|
|
1319
|
+
logger.info("Sharing message history");
|
|
1506
1320
|
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1321
|
+
// 1. Download keys from backup.
|
|
1322
|
+
if (!(await this.getOlmMachineOrThrow().hasDownloadedAllRoomKeys(new RustSdkCryptoJs.RoomId(roomId)))) {
|
|
1323
|
+
await this.backupManager.downloadLatestRoomKeyBackup(roomId);
|
|
1324
|
+
await this.getOlmMachineOrThrow().setHasDownloadedAllRoomKeys(new RustSdkCryptoJs.RoomId(roomId));
|
|
1325
|
+
}
|
|
1512
1326
|
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1327
|
+
// 2. Construct the key bundle
|
|
1328
|
+
const bundle = await this.getOlmMachineOrThrow().buildRoomKeyBundle(new RustSdkCryptoJs.RoomId(roomId));
|
|
1329
|
+
if (!bundle) {
|
|
1330
|
+
logger.info("No keys to share");
|
|
1331
|
+
return;
|
|
1332
|
+
}
|
|
1519
1333
|
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1334
|
+
// 3. Upload the encrypted bundle to the server
|
|
1335
|
+
const uploadResponse = await this.http.uploadContent(bundle.encryptedData);
|
|
1336
|
+
logger.info(`Uploaded encrypted key blob: ${JSON.stringify(uploadResponse)}`);
|
|
1523
1337
|
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1338
|
+
// 4. We may not share a room with the user, so get a fresh list of devices for the invited user.
|
|
1339
|
+
const req = this.getOlmMachineOrThrow().queryKeysForUsers([new RustSdkCryptoJs.UserId(userId)]);
|
|
1340
|
+
await this.outgoingRequestProcessor.makeOutgoingRequest(req);
|
|
1527
1341
|
|
|
1528
|
-
|
|
1529
|
-
|
|
1342
|
+
// 5. Establish Olm sessions with all of the recipient's devices.
|
|
1343
|
+
await this.keyClaimManager.ensureSessionsForUsers(logger, [new RustSdkCryptoJs.UserId(userId)]);
|
|
1530
1344
|
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
})();
|
|
1345
|
+
// 6. Send to-device messages to the recipient to share the keys.
|
|
1346
|
+
const requests = await this.getOlmMachineOrThrow().shareRoomKeyBundleData(new RustSdkCryptoJs.UserId(userId), new RustSdkCryptoJs.RoomId(roomId), uploadResponse.content_uri, bundle.mediaEncryptionInfo, RustSdkCryptoJs.CollectStrategy.identityBasedStrategy());
|
|
1347
|
+
for (const req of requests) {
|
|
1348
|
+
await this.outgoingRequestProcessor.makeOutgoingRequest(req);
|
|
1349
|
+
}
|
|
1537
1350
|
}
|
|
1538
1351
|
|
|
1539
1352
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
@@ -1550,17 +1363,13 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
1550
1363
|
* @param devices - the received device list updates
|
|
1551
1364
|
* @returns A list of processed to-device messages.
|
|
1552
1365
|
*/
|
|
1553
|
-
receiveSyncChanges(
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
_ref7$devices = _ref7.devices,
|
|
1561
|
-
devices = _ref7$devices === void 0 ? new RustSdkCryptoJs.DeviceLists() : _ref7$devices;
|
|
1562
|
-
return yield _this59.olmMachine.receiveSyncChanges(events ? JSON.stringify(events) : "[]", devices, oneTimeKeysCounts, unusedFallbackKeys);
|
|
1563
|
-
})();
|
|
1366
|
+
async receiveSyncChanges({
|
|
1367
|
+
events,
|
|
1368
|
+
oneTimeKeysCounts = new Map(),
|
|
1369
|
+
unusedFallbackKeys,
|
|
1370
|
+
devices = new RustSdkCryptoJs.DeviceLists()
|
|
1371
|
+
}) {
|
|
1372
|
+
return await this.olmMachine.receiveSyncChanges(events ? JSON.stringify(events) : "[]", devices, oneTimeKeysCounts, unusedFallbackKeys);
|
|
1564
1373
|
}
|
|
1565
1374
|
|
|
1566
1375
|
/** called by the sync loop to preprocess incoming to-device messages
|
|
@@ -1568,87 +1377,80 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
1568
1377
|
* @param events - the received to-device messages
|
|
1569
1378
|
* @returns A list of preprocessed to-device messages.
|
|
1570
1379
|
*/
|
|
1571
|
-
preprocessToDeviceMessages(events) {
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
if (transactionId && sender) {
|
|
1588
|
-
_this60.onIncomingKeyVerificationRequest(sender, transactionId);
|
|
1589
|
-
}
|
|
1380
|
+
async preprocessToDeviceMessages(events) {
|
|
1381
|
+
// send the received to-device messages into receiveSyncChanges. We have no info on device-list changes,
|
|
1382
|
+
// one-time-keys, or fallback keys, so just pass empty data.
|
|
1383
|
+
const processed = await this.receiveSyncChanges({
|
|
1384
|
+
events
|
|
1385
|
+
});
|
|
1386
|
+
const received = [];
|
|
1387
|
+
for (const message of processed) {
|
|
1388
|
+
const parsedMessage = JSON.parse(message.rawEvent);
|
|
1389
|
+
|
|
1390
|
+
// look for interesting to-device messages
|
|
1391
|
+
if (parsedMessage.type === EventType.KeyVerificationRequest) {
|
|
1392
|
+
const sender = parsedMessage.sender;
|
|
1393
|
+
const transactionId = parsedMessage.content.transaction_id;
|
|
1394
|
+
if (transactionId && sender) {
|
|
1395
|
+
this.onIncomingKeyVerificationRequest(sender, transactionId);
|
|
1590
1396
|
}
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
}
|
|
1397
|
+
}
|
|
1398
|
+
switch (message.type) {
|
|
1399
|
+
case RustSdkCryptoJs.ProcessedToDeviceEventType.Decrypted:
|
|
1400
|
+
{
|
|
1401
|
+
const encryptionInfo = message.encryptionInfo;
|
|
1402
|
+
received.push({
|
|
1403
|
+
message: parsedMessage,
|
|
1404
|
+
encryptionInfo: {
|
|
1405
|
+
sender: encryptionInfo.sender.toString(),
|
|
1406
|
+
senderDevice: encryptionInfo.senderDevice?.toString(),
|
|
1407
|
+
senderCurve25519KeyBase64: encryptionInfo.senderCurve25519Key,
|
|
1408
|
+
senderVerified: encryptionInfo.isSenderVerified()
|
|
1409
|
+
}
|
|
1410
|
+
});
|
|
1411
|
+
|
|
1412
|
+
// If we have received a room key bundle message, and have recently joined the room in question,
|
|
1413
|
+
// tell the Rust SDK to try and accept the key bundle.
|
|
1414
|
+
//
|
|
1415
|
+
// We don't actually need to validate the contents of the bundle message, or do
|
|
1416
|
+
// anything with its contents at all. We simply want to inform the Rust SDK we have
|
|
1417
|
+
// received a new room key bundle that we might be able to download.
|
|
1418
|
+
if (isRoomKeyBundleMessage(parsedMessage)) {
|
|
1419
|
+
const roomId = parsedMessage.content.room_id;
|
|
1420
|
+
const pendingDetails = await this.olmMachine.getPendingKeyBundleDetailsForRoom(new RustSdkCryptoJs.RoomId(roomId));
|
|
1421
|
+
// Only accept the key bundle if we joined the room less than 24 hours ago.
|
|
1422
|
+
if (!pendingDetails) {
|
|
1423
|
+
this.logger.debug(`Not yet accepting key bundle for room where we are not awaiting a bundle: ${roomId}`);
|
|
1424
|
+
} else if (Date.now() - pendingDetails.inviteAcceptedAtMillis > MAX_INVITE_ACCEPTANCE_MS_FOR_KEY_BUNDLE) {
|
|
1425
|
+
this.logger.info(`Ignoring key bundle for room we joined too long ago: ${roomId}, joining time: ${new Date(pendingDetails.inviteAcceptedAtMillis).toISOString()}`);
|
|
1426
|
+
} else {
|
|
1427
|
+
this.logger.info(`Considering key bundle for recently-joined room ${roomId}`);
|
|
1428
|
+
// Don't block for the import to happen, here, as this is called from inside the `/sync` loop.
|
|
1429
|
+
this.maybeAcceptKeyBundle(roomId, pendingDetails.inviterId.toString()).catch(err => {
|
|
1430
|
+
this.logger.error(`Error attempting to download key bundle for room ${roomId}`);
|
|
1431
|
+
this.logger.error(err);
|
|
1432
|
+
});
|
|
1628
1433
|
}
|
|
1629
|
-
break;
|
|
1630
|
-
}
|
|
1631
|
-
case RustSdkCryptoJs.ProcessedToDeviceEventType.PlainText:
|
|
1632
|
-
{
|
|
1633
|
-
received.push({
|
|
1634
|
-
message: parsedMessage,
|
|
1635
|
-
encryptionInfo: null
|
|
1636
|
-
});
|
|
1637
|
-
break;
|
|
1638
1434
|
}
|
|
1639
|
-
case RustSdkCryptoJs.ProcessedToDeviceEventType.UnableToDecrypt:
|
|
1640
|
-
// ignore messages we cannot decrypt
|
|
1641
1435
|
break;
|
|
1642
|
-
|
|
1643
|
-
|
|
1436
|
+
}
|
|
1437
|
+
case RustSdkCryptoJs.ProcessedToDeviceEventType.PlainText:
|
|
1438
|
+
{
|
|
1439
|
+
received.push({
|
|
1440
|
+
message: parsedMessage,
|
|
1441
|
+
encryptionInfo: null
|
|
1442
|
+
});
|
|
1644
1443
|
break;
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1444
|
+
}
|
|
1445
|
+
case RustSdkCryptoJs.ProcessedToDeviceEventType.UnableToDecrypt:
|
|
1446
|
+
// ignore messages we cannot decrypt
|
|
1447
|
+
break;
|
|
1448
|
+
case RustSdkCryptoJs.ProcessedToDeviceEventType.Invalid:
|
|
1449
|
+
// ignore invalid messages
|
|
1450
|
+
break;
|
|
1649
1451
|
}
|
|
1650
|
-
|
|
1651
|
-
|
|
1452
|
+
}
|
|
1453
|
+
return received;
|
|
1652
1454
|
}
|
|
1653
1455
|
|
|
1654
1456
|
/** called by the sync loop to process one time key counts and unused fallback keys
|
|
@@ -1656,18 +1458,15 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
1656
1458
|
* @param oneTimeKeysCounts - the received one time key counts
|
|
1657
1459
|
* @param unusedFallbackKeys - the received unused fallback keys
|
|
1658
1460
|
*/
|
|
1659
|
-
processKeyCounts(oneTimeKeysCounts, unusedFallbackKeys) {
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
});
|
|
1669
|
-
}
|
|
1670
|
-
})();
|
|
1461
|
+
async processKeyCounts(oneTimeKeysCounts, unusedFallbackKeys) {
|
|
1462
|
+
const mapOneTimeKeysCount = oneTimeKeysCounts && new Map(Object.entries(oneTimeKeysCounts));
|
|
1463
|
+
const setUnusedFallbackKeys = unusedFallbackKeys && new Set(unusedFallbackKeys);
|
|
1464
|
+
if (mapOneTimeKeysCount !== undefined || setUnusedFallbackKeys !== undefined) {
|
|
1465
|
+
await this.receiveSyncChanges({
|
|
1466
|
+
oneTimeKeysCounts: mapOneTimeKeysCount,
|
|
1467
|
+
unusedFallbackKeys: setUnusedFallbackKeys
|
|
1468
|
+
});
|
|
1469
|
+
}
|
|
1671
1470
|
}
|
|
1672
1471
|
|
|
1673
1472
|
/** called by the sync loop to process the notification that device lists have
|
|
@@ -1675,15 +1474,11 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
1675
1474
|
*
|
|
1676
1475
|
* @param deviceLists - device_lists field from /sync
|
|
1677
1476
|
*/
|
|
1678
|
-
processDeviceLists(deviceLists) {
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
yield _this62.receiveSyncChanges({
|
|
1684
|
-
devices
|
|
1685
|
-
});
|
|
1686
|
-
})();
|
|
1477
|
+
async processDeviceLists(deviceLists) {
|
|
1478
|
+
const devices = new RustSdkCryptoJs.DeviceLists(deviceLists.changed?.map(userId => new RustSdkCryptoJs.UserId(userId)), deviceLists.left?.map(userId => new RustSdkCryptoJs.UserId(userId)));
|
|
1479
|
+
await this.receiveSyncChanges({
|
|
1480
|
+
devices
|
|
1481
|
+
});
|
|
1687
1482
|
}
|
|
1688
1483
|
|
|
1689
1484
|
/** called by the sync loop on m.room.encryption events
|
|
@@ -1691,40 +1486,37 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
1691
1486
|
* @param room - in which the event was received
|
|
1692
1487
|
* @param event - encryption event to be processed
|
|
1693
1488
|
*/
|
|
1694
|
-
onCryptoEvent(room, event) {
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
}
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
return;
|
|
1717
|
-
}
|
|
1489
|
+
async onCryptoEvent(room, event) {
|
|
1490
|
+
const config = event.getContent();
|
|
1491
|
+
const settings = new RustSdkCryptoJs.RoomSettings();
|
|
1492
|
+
if (config.algorithm === "m.megolm.v1.aes-sha2") {
|
|
1493
|
+
settings.algorithm = RustSdkCryptoJs.EncryptionAlgorithm.MegolmV1AesSha2;
|
|
1494
|
+
} else {
|
|
1495
|
+
// Among other situations, this happens if the crypto state event is redacted.
|
|
1496
|
+
this.logger.warn(`Room ${room.roomId}: ignoring crypto event with invalid algorithm ${config.algorithm}`);
|
|
1497
|
+
return;
|
|
1498
|
+
}
|
|
1499
|
+
if (config["io.element.msc4362.encrypt_state_events"] && this.enableEncryptedStateEvents) {
|
|
1500
|
+
this.logger.info("crypto Enabling state event encryption...");
|
|
1501
|
+
settings.encryptStateEvents = true;
|
|
1502
|
+
}
|
|
1503
|
+
try {
|
|
1504
|
+
settings.sessionRotationPeriodMs = config.rotation_period_ms;
|
|
1505
|
+
settings.sessionRotationPeriodMessages = config.rotation_period_msgs;
|
|
1506
|
+
await this.olmMachine.setRoomSettings(new RustSdkCryptoJs.RoomId(room.roomId), settings);
|
|
1507
|
+
} catch (e) {
|
|
1508
|
+
this.logger.warn(`Room ${room.roomId}: ignoring crypto event which caused error: ${e}`);
|
|
1509
|
+
return;
|
|
1510
|
+
}
|
|
1718
1511
|
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
})();
|
|
1512
|
+
// If we got this far, the SDK found the event acceptable.
|
|
1513
|
+
// We need to either create or update the active RoomEncryptor.
|
|
1514
|
+
const existingEncryptor = this.roomEncryptors[room.roomId];
|
|
1515
|
+
if (existingEncryptor) {
|
|
1516
|
+
existingEncryptor.onCryptoEvent(config);
|
|
1517
|
+
} else {
|
|
1518
|
+
this.roomEncryptors[room.roomId] = new RoomEncryptor(this.logger.getChild(`[${room.roomId} encryption]`), this.olmMachine, this.keyClaimManager, this.outgoingRequestsManager, room, config);
|
|
1519
|
+
}
|
|
1728
1520
|
}
|
|
1729
1521
|
|
|
1730
1522
|
/** called by the sync loop after processing each sync.
|
|
@@ -1743,11 +1535,8 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
1743
1535
|
/**
|
|
1744
1536
|
* Implementation of {@link CryptoApi#markAllTrackedUsersAsDirty}.
|
|
1745
1537
|
*/
|
|
1746
|
-
markAllTrackedUsersAsDirty() {
|
|
1747
|
-
|
|
1748
|
-
return _asyncToGenerator(function* () {
|
|
1749
|
-
yield _this64.olmMachine.markAllTrackedUsersAsDirty();
|
|
1750
|
-
})();
|
|
1538
|
+
async markAllTrackedUsersAsDirty() {
|
|
1539
|
+
await this.olmMachine.markAllTrackedUsersAsDirty();
|
|
1751
1540
|
}
|
|
1752
1541
|
|
|
1753
1542
|
/**
|
|
@@ -1758,13 +1547,13 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
1758
1547
|
* content of the message; for in-room messages it is the event ID.
|
|
1759
1548
|
*/
|
|
1760
1549
|
onIncomingKeyVerificationRequest(sender, transactionId) {
|
|
1761
|
-
|
|
1550
|
+
const request = this.olmMachine.getVerificationRequest(new RustSdkCryptoJs.UserId(sender), transactionId);
|
|
1762
1551
|
if (request) {
|
|
1763
1552
|
this.emit(CryptoEvent.VerificationRequestReceived, this.makeVerificationRequest(request));
|
|
1764
1553
|
} else {
|
|
1765
1554
|
// There are multiple reasons this can happen; probably the most likely is that the event is an
|
|
1766
1555
|
// in-room event which is too old.
|
|
1767
|
-
this.logger.info(
|
|
1556
|
+
this.logger.info(`Ignoring just-received verification request ${transactionId} which did not start a rust-side verification`);
|
|
1768
1557
|
}
|
|
1769
1558
|
}
|
|
1770
1559
|
|
|
@@ -1786,16 +1575,16 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
1786
1575
|
* @param oldMembership - The previous membership state. Null if it's a new member.
|
|
1787
1576
|
*/
|
|
1788
1577
|
onRoomMembership(event, member, oldMembership) {
|
|
1789
|
-
|
|
1578
|
+
const roomId = event.getRoomId();
|
|
1790
1579
|
|
|
1791
1580
|
// If it's our own membership, and we are no longer joined, clear any indication that we are waiting for a key
|
|
1792
1581
|
// bundle.
|
|
1793
1582
|
if (oldMembership === KnownMembership.Join && member.membership !== KnownMembership.Join && member.userId === this.olmMachine.userId.toString()) {
|
|
1794
1583
|
this.olmMachine.clearRoomPendingKeyBundle(new RustSdkCryptoJs.RoomId(roomId)).catch(e => {
|
|
1795
|
-
this.logger.error(
|
|
1584
|
+
this.logger.error(`Error clearing room pending key bundle indicator for ${roomId}: ${e}`);
|
|
1796
1585
|
});
|
|
1797
1586
|
}
|
|
1798
|
-
|
|
1587
|
+
const enc = this.roomEncryptors[roomId];
|
|
1799
1588
|
if (!enc) {
|
|
1800
1589
|
// not encrypting in this room
|
|
1801
1590
|
return;
|
|
@@ -1832,8 +1621,8 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
1832
1621
|
return;
|
|
1833
1622
|
}
|
|
1834
1623
|
if (event.getStateKey() !== this.olmMachine.userId.toString() && event.getContent().membership !== KnownMembership.Join) {
|
|
1835
|
-
this.logger.info(
|
|
1836
|
-
this.forceDiscardSession(event.getRoomId());
|
|
1624
|
+
this.logger.info(`Rotating session for room ${event.getRoomId()} due to member leaving the room`);
|
|
1625
|
+
void this.forceDiscardSession(event.getRoomId());
|
|
1837
1626
|
}
|
|
1838
1627
|
}
|
|
1839
1628
|
|
|
@@ -1845,22 +1634,18 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
1845
1634
|
*
|
|
1846
1635
|
* @param keys - details of the updated keys
|
|
1847
1636
|
*/
|
|
1848
|
-
onRoomKeysUpdated(keys) {
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
}
|
|
1854
|
-
_this65.backupManager.maybeUploadKey();
|
|
1855
|
-
})();
|
|
1637
|
+
async onRoomKeysUpdated(keys) {
|
|
1638
|
+
for (const key of keys) {
|
|
1639
|
+
this.onRoomKeyUpdated(key);
|
|
1640
|
+
}
|
|
1641
|
+
void this.backupManager.maybeUploadKey();
|
|
1856
1642
|
}
|
|
1857
1643
|
onRoomKeyUpdated(key) {
|
|
1858
|
-
var _this66 = this;
|
|
1859
1644
|
if (this.stopped) return;
|
|
1860
|
-
this.logger.debug(
|
|
1861
|
-
|
|
1645
|
+
this.logger.debug(`Got update for session ${key.sessionId} from sender ${key.senderKey.toBase64()} in ${key.roomId.toString()}`);
|
|
1646
|
+
const pendingList = this.eventDecryptor.getEventsPendingRoomKey(key.roomId.toString(), key.sessionId);
|
|
1862
1647
|
if (pendingList.length === 0) return;
|
|
1863
|
-
this.logger.debug("Retrying decryption on events:", pendingList.map(e =>
|
|
1648
|
+
this.logger.debug("Retrying decryption on events:", pendingList.map(e => `${e.getId()}`));
|
|
1864
1649
|
|
|
1865
1650
|
// Have another go at decrypting events with this key.
|
|
1866
1651
|
//
|
|
@@ -1868,15 +1653,12 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
1868
1653
|
// so we don't wait for the decryption to complete. In any case, there is no need to wait:
|
|
1869
1654
|
// MatrixEvent.attemptDecryption ensures that there is only one decryption attempt happening at once,
|
|
1870
1655
|
// and deduplicates repeated attempts for the same event.
|
|
1871
|
-
|
|
1872
|
-
ev.attemptDecryption(
|
|
1656
|
+
for (const ev of pendingList) {
|
|
1657
|
+
ev.attemptDecryption(this, {
|
|
1873
1658
|
isRetry: true
|
|
1874
1659
|
}).catch(_e => {
|
|
1875
|
-
|
|
1660
|
+
this.logger.info(`Still unable to decrypt event ${ev.getId()} after receiving key`);
|
|
1876
1661
|
});
|
|
1877
|
-
};
|
|
1878
|
-
for (var ev of pendingList) {
|
|
1879
|
-
_loop2(ev);
|
|
1880
1662
|
}
|
|
1881
1663
|
}
|
|
1882
1664
|
|
|
@@ -1888,25 +1670,22 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
1888
1670
|
*
|
|
1889
1671
|
* @param withheld - Details of the withheld sessions.
|
|
1890
1672
|
*/
|
|
1891
|
-
onRoomKeysWithheld(withheld) {
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
// It's somewhat expected that we still can't decrypt here.
|
|
1906
|
-
});
|
|
1907
|
-
}
|
|
1673
|
+
async onRoomKeysWithheld(withheld) {
|
|
1674
|
+
for (const session of withheld) {
|
|
1675
|
+
this.logger.debug(`Got withheld message for session ${session.sessionId} in ${session.roomId.toString()}`);
|
|
1676
|
+
const pendingList = this.eventDecryptor.getEventsPendingRoomKey(session.roomId.toString(), session.sessionId);
|
|
1677
|
+
if (pendingList.length === 0) return;
|
|
1678
|
+
|
|
1679
|
+
// The easiest way to update the status of the event is to have another go at decrypting it.
|
|
1680
|
+
this.logger.debug("Retrying decryption on events:", pendingList.map(e => `${e.getId()}`));
|
|
1681
|
+
for (const ev of pendingList) {
|
|
1682
|
+
ev.attemptDecryption(this, {
|
|
1683
|
+
isRetry: true
|
|
1684
|
+
}).catch(_e => {
|
|
1685
|
+
// It's somewhat expected that we still can't decrypt here.
|
|
1686
|
+
});
|
|
1908
1687
|
}
|
|
1909
|
-
}
|
|
1688
|
+
}
|
|
1910
1689
|
}
|
|
1911
1690
|
|
|
1912
1691
|
/**
|
|
@@ -1917,19 +1696,16 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
1917
1696
|
*
|
|
1918
1697
|
* @param userId - the user with the updated identity
|
|
1919
1698
|
*/
|
|
1920
|
-
onUserIdentityUpdated(userId) {
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
yield _this68.checkKeyBackupAndEnable();
|
|
1931
|
-
}
|
|
1932
|
-
})();
|
|
1699
|
+
async onUserIdentityUpdated(userId) {
|
|
1700
|
+
const newVerification = await this.getUserVerificationStatus(userId.toString());
|
|
1701
|
+
this.emit(CryptoEvent.UserTrustStatusChanged, userId.toString(), newVerification);
|
|
1702
|
+
|
|
1703
|
+
// If our own user identity has changed, we may now trust the key backup where we did not before.
|
|
1704
|
+
// So, re-check the key backup status and enable it if available.
|
|
1705
|
+
if (userId.toString() === this.userId) {
|
|
1706
|
+
this.emit(CryptoEvent.KeysChanged, {});
|
|
1707
|
+
await this.checkKeyBackupAndEnable();
|
|
1708
|
+
}
|
|
1933
1709
|
}
|
|
1934
1710
|
|
|
1935
1711
|
/**
|
|
@@ -1942,12 +1718,9 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
1942
1718
|
*
|
|
1943
1719
|
* @param userIds - an array of user IDs of users whose devices have updated.
|
|
1944
1720
|
*/
|
|
1945
|
-
onDevicesUpdated(userIds) {
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
_this69.emit(CryptoEvent.WillUpdateDevices, userIds, false);
|
|
1949
|
-
_this69.emit(CryptoEvent.DevicesUpdated, userIds, false);
|
|
1950
|
-
})();
|
|
1721
|
+
async onDevicesUpdated(userIds) {
|
|
1722
|
+
this.emit(CryptoEvent.WillUpdateDevices, userIds, false);
|
|
1723
|
+
this.emit(CryptoEvent.DevicesUpdated, userIds, false);
|
|
1951
1724
|
}
|
|
1952
1725
|
|
|
1953
1726
|
/**
|
|
@@ -1962,19 +1735,16 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
1962
1735
|
* @param name - the secret name
|
|
1963
1736
|
* @param value - the secret value
|
|
1964
1737
|
*/
|
|
1965
|
-
handleSecretReceived(name, value) {
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
}
|
|
1976
|
-
return false;
|
|
1977
|
-
})();
|
|
1738
|
+
async handleSecretReceived(name, value) {
|
|
1739
|
+
this.logger.debug(`onReceiveSecret: Received secret ${name}`);
|
|
1740
|
+
if (name === "m.megolm_backup.v1") {
|
|
1741
|
+
return await this.backupManager.handleBackupSecretReceived(value);
|
|
1742
|
+
// XXX at this point we should probably try to download the backup and import the keys,
|
|
1743
|
+
// or at least retry for the current decryption failures?
|
|
1744
|
+
// Maybe add some signaling when a new secret is received, and let clients handle it?
|
|
1745
|
+
// as it's where the restore from backup APIs are exposed.
|
|
1746
|
+
}
|
|
1747
|
+
return false;
|
|
1978
1748
|
}
|
|
1979
1749
|
|
|
1980
1750
|
/**
|
|
@@ -1984,21 +1754,18 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
1984
1754
|
*
|
|
1985
1755
|
* @param name - The name of the secret received.
|
|
1986
1756
|
*/
|
|
1987
|
-
checkSecrets(name) {
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
// It's probably the same secret shared by another device.
|
|
1995
|
-
break;
|
|
1996
|
-
}
|
|
1757
|
+
async checkSecrets(name) {
|
|
1758
|
+
const pendingValues = await this.olmMachine.getSecretsFromInbox(name);
|
|
1759
|
+
for (const value of pendingValues) {
|
|
1760
|
+
if (await this.handleSecretReceived(name, value)) {
|
|
1761
|
+
// If we have a valid secret for that name there is no point of processing the other secrets values.
|
|
1762
|
+
// It's probably the same secret shared by another device.
|
|
1763
|
+
break;
|
|
1997
1764
|
}
|
|
1765
|
+
}
|
|
1998
1766
|
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
})();
|
|
1767
|
+
// Important to call this after handling the secrets as good hygiene.
|
|
1768
|
+
await this.olmMachine.deleteSecretsFromInbox(name);
|
|
2002
1769
|
}
|
|
2003
1770
|
|
|
2004
1771
|
/**
|
|
@@ -2007,42 +1774,34 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
2007
1774
|
*
|
|
2008
1775
|
* @param event - live event
|
|
2009
1776
|
*/
|
|
2010
|
-
onLiveEventFromSync(event) {
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
// Process only verification event
|
|
2019
|
-
if (isVerificationEvent(event)) {
|
|
2020
|
-
yield _this72.onKeyVerificationEvent(evt);
|
|
2021
|
-
}
|
|
2022
|
-
});
|
|
2023
|
-
return function processEvent(_x2) {
|
|
2024
|
-
return _ref8.apply(this, arguments);
|
|
2025
|
-
};
|
|
2026
|
-
}();
|
|
2027
|
-
|
|
2028
|
-
// If the event is encrypted of in failure, we wait for decryption
|
|
2029
|
-
if (event.isDecryptionFailure() || event.isEncrypted()) {
|
|
2030
|
-
// 5 mins
|
|
2031
|
-
var TIMEOUT_DELAY = 5 * 60 * 1000;
|
|
2032
|
-
|
|
2033
|
-
// After 5mins, we are not expecting the event to be decrypted
|
|
2034
|
-
var timeoutId = setTimeout(() => event.off(MatrixEventEvent.Decrypted, onDecrypted), TIMEOUT_DELAY);
|
|
2035
|
-
var onDecrypted = (decryptedEvent, error) => {
|
|
2036
|
-
if (error) return;
|
|
2037
|
-
clearTimeout(timeoutId);
|
|
2038
|
-
event.off(MatrixEventEvent.Decrypted, onDecrypted);
|
|
2039
|
-
processEvent(decryptedEvent);
|
|
2040
|
-
};
|
|
2041
|
-
event.on(MatrixEventEvent.Decrypted, onDecrypted);
|
|
2042
|
-
} else {
|
|
2043
|
-
yield processEvent(event);
|
|
1777
|
+
async onLiveEventFromSync(event) {
|
|
1778
|
+
// Ignore state event or remote echo
|
|
1779
|
+
// transaction_id is provided in case of remote echo {@link https://spec.matrix.org/v1.7/client-server-api/#local-echo}
|
|
1780
|
+
if (event.isState() || !!event.getUnsigned().transaction_id) return;
|
|
1781
|
+
const processEvent = async evt => {
|
|
1782
|
+
// Process only verification event
|
|
1783
|
+
if (isVerificationEvent(event)) {
|
|
1784
|
+
await this.onKeyVerificationEvent(evt);
|
|
2044
1785
|
}
|
|
2045
|
-
}
|
|
1786
|
+
};
|
|
1787
|
+
|
|
1788
|
+
// If the event is encrypted of in failure, we wait for decryption
|
|
1789
|
+
if (event.isDecryptionFailure() || event.isEncrypted()) {
|
|
1790
|
+
// 5 mins
|
|
1791
|
+
const TIMEOUT_DELAY = 5 * 60 * 1000;
|
|
1792
|
+
|
|
1793
|
+
// After 5mins, we are not expecting the event to be decrypted
|
|
1794
|
+
const timeoutId = setTimeout(() => event.off(MatrixEventEvent.Decrypted, onDecrypted), TIMEOUT_DELAY);
|
|
1795
|
+
const onDecrypted = (decryptedEvent, error) => {
|
|
1796
|
+
if (error) return;
|
|
1797
|
+
clearTimeout(timeoutId);
|
|
1798
|
+
event.off(MatrixEventEvent.Decrypted, onDecrypted);
|
|
1799
|
+
void processEvent(decryptedEvent);
|
|
1800
|
+
};
|
|
1801
|
+
event.on(MatrixEventEvent.Decrypted, onDecrypted);
|
|
1802
|
+
} else {
|
|
1803
|
+
await processEvent(event);
|
|
1804
|
+
}
|
|
2046
1805
|
}
|
|
2047
1806
|
|
|
2048
1807
|
/**
|
|
@@ -2050,45 +1809,42 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
2050
1809
|
*
|
|
2051
1810
|
* @param event - a key validation request event.
|
|
2052
1811
|
*/
|
|
2053
|
-
onKeyVerificationEvent(event) {
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
_this73.onIncomingKeyVerificationRequest(senderId, event.getId());
|
|
2085
|
-
}
|
|
1812
|
+
async onKeyVerificationEvent(event) {
|
|
1813
|
+
const roomId = event.getRoomId();
|
|
1814
|
+
const senderId = event.getSender();
|
|
1815
|
+
if (!roomId) {
|
|
1816
|
+
throw new Error("missing roomId in the event");
|
|
1817
|
+
}
|
|
1818
|
+
if (!senderId) {
|
|
1819
|
+
throw new Error("missing sender in the event");
|
|
1820
|
+
}
|
|
1821
|
+
this.logger.debug(`Incoming verification event ${event.getId()} type ${event.getType()} from ${event.getSender()}`);
|
|
1822
|
+
const isRoomVerificationRequest = event.getType() === EventType.RoomMessage && event.getContent().msgtype === MsgType.KeyVerificationRequest;
|
|
1823
|
+
if (isRoomVerificationRequest) {
|
|
1824
|
+
// Before processing an in-room verification request, we need to
|
|
1825
|
+
// make sure we have the sender's device information - otherwise we
|
|
1826
|
+
// will immediately abort verification. So we explicitly fetch it
|
|
1827
|
+
// from /keys/query and wait for that request to complete before we
|
|
1828
|
+
// call receiveVerificationEvent.
|
|
1829
|
+
const req = this.getOlmMachineOrThrow().queryKeysForUsers([new RustSdkCryptoJs.UserId(senderId)]);
|
|
1830
|
+
await this.outgoingRequestProcessor.makeOutgoingRequest(req);
|
|
1831
|
+
}
|
|
1832
|
+
await this.getOlmMachineOrThrow().receiveVerificationEvent(JSON.stringify({
|
|
1833
|
+
event_id: event.getId(),
|
|
1834
|
+
type: event.getType(),
|
|
1835
|
+
sender: senderId,
|
|
1836
|
+
state_key: event.getStateKey(),
|
|
1837
|
+
content: event.getContent(),
|
|
1838
|
+
origin_server_ts: event.getTs()
|
|
1839
|
+
}), new RustSdkCryptoJs.RoomId(roomId));
|
|
1840
|
+
if (isRoomVerificationRequest) {
|
|
1841
|
+
this.onIncomingKeyVerificationRequest(senderId, event.getId());
|
|
1842
|
+
}
|
|
2086
1843
|
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
})();
|
|
1844
|
+
// that may have caused us to queue up outgoing requests, so make sure we send them.
|
|
1845
|
+
this.outgoingRequestsManager.doProcessOutgoingRequests().catch(e => {
|
|
1846
|
+
this.logger.warn("onKeyVerificationRequest: Error processing outgoing requests", e);
|
|
1847
|
+
});
|
|
2092
1848
|
}
|
|
2093
1849
|
|
|
2094
1850
|
/**
|
|
@@ -2097,27 +1853,21 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
2097
1853
|
* Not part of the public crypto-api interface.
|
|
2098
1854
|
* Used during migration from legacy js-crypto to update local trust if needed.
|
|
2099
1855
|
*/
|
|
2100
|
-
getOwnIdentity() {
|
|
2101
|
-
|
|
2102
|
-
return
|
|
2103
|
-
var identity = yield _this74.getOlmMachineOrThrow().getIdentity(new RustSdkCryptoJs.UserId(_this74.userId));
|
|
2104
|
-
return identity;
|
|
2105
|
-
})();
|
|
1856
|
+
async getOwnIdentity() {
|
|
1857
|
+
const identity = await this.getOlmMachineOrThrow().getIdentity(new RustSdkCryptoJs.UserId(this.userId));
|
|
1858
|
+
return identity;
|
|
2106
1859
|
}
|
|
2107
1860
|
|
|
2108
1861
|
/**
|
|
2109
1862
|
* Push a secret to all of the current user's verified devices.
|
|
2110
1863
|
*/
|
|
2111
|
-
pushSecretToVerifiedDevices(name) {
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
logger.warn("pushSecretToVerifiedDevices: Error processing outgoing requests", e);
|
|
2119
|
-
});
|
|
2120
|
-
})();
|
|
1864
|
+
async pushSecretToVerifiedDevices(name) {
|
|
1865
|
+
const logger = new LogSpan(this.logger, "pushSecretToVerifiedDevices");
|
|
1866
|
+
await this.keyClaimManager.ensureSessionsForUsers(logger, [new RustSdkCryptoJs.UserId(this.userId)]);
|
|
1867
|
+
await this.olmMachine.pushSecretToVerifiedDevices(name);
|
|
1868
|
+
this.outgoingRequestsManager.doProcessOutgoingRequests().catch(e => {
|
|
1869
|
+
logger.warn("pushSecretToVerifiedDevices: Error processing outgoing requests", e);
|
|
1870
|
+
});
|
|
2121
1871
|
}
|
|
2122
1872
|
}
|
|
2123
1873
|
class EventDecryptor {
|
|
@@ -2132,44 +1882,40 @@ class EventDecryptor {
|
|
|
2132
1882
|
this.olmMachine = olmMachine;
|
|
2133
1883
|
this.perSessionBackupDownloader = perSessionBackupDownloader;
|
|
2134
1884
|
}
|
|
2135
|
-
attemptEventDecryption(event, isolationMode) {
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
}
|
|
2166
|
-
|
|
2167
|
-
_this76.onMegolmDecryptionError(event, err, yield _this76.perSessionBackupDownloader.getServerBackupInfo());
|
|
2168
|
-
} else {
|
|
2169
|
-
throw new DecryptionError(DecryptionFailureCode.UNKNOWN_ERROR, "Unknown error");
|
|
2170
|
-
}
|
|
1885
|
+
async attemptEventDecryption(event, isolationMode) {
|
|
1886
|
+
// add the event to the pending list *before* attempting to decrypt.
|
|
1887
|
+
// then, if the key turns up while decryption is in progress (and
|
|
1888
|
+
// decryption fails), we will schedule a retry.
|
|
1889
|
+
// (fixes https://github.com/vector-im/element-web/issues/5001)
|
|
1890
|
+
this.addEventToPendingList(event);
|
|
1891
|
+
let trustRequirement;
|
|
1892
|
+
switch (isolationMode.kind) {
|
|
1893
|
+
case DeviceIsolationModeKind.AllDevicesIsolationMode:
|
|
1894
|
+
trustRequirement = RustSdkCryptoJs.TrustRequirement.Untrusted;
|
|
1895
|
+
break;
|
|
1896
|
+
case DeviceIsolationModeKind.OnlySignedDevicesIsolationMode:
|
|
1897
|
+
trustRequirement = RustSdkCryptoJs.TrustRequirement.CrossSignedOrLegacy;
|
|
1898
|
+
break;
|
|
1899
|
+
}
|
|
1900
|
+
try {
|
|
1901
|
+
const res = await this.olmMachine.decryptRoomEvent(stringifyEvent(event), new RustSdkCryptoJs.RoomId(event.getRoomId()), new RustSdkCryptoJs.DecryptionSettings(trustRequirement));
|
|
1902
|
+
|
|
1903
|
+
// Success. We can remove the event from the pending list, if
|
|
1904
|
+
// that hasn't already happened.
|
|
1905
|
+
this.removeEventFromPendingList(event);
|
|
1906
|
+
return {
|
|
1907
|
+
clearEvent: JSON.parse(res.event),
|
|
1908
|
+
claimedEd25519Key: res.senderClaimedEd25519Key,
|
|
1909
|
+
senderCurve25519Key: res.senderCurve25519Key,
|
|
1910
|
+
keyForwardedBy: res.forwarder?.toString()
|
|
1911
|
+
};
|
|
1912
|
+
} catch (err) {
|
|
1913
|
+
if (err instanceof RustSdkCryptoJs.MegolmDecryptionError) {
|
|
1914
|
+
this.onMegolmDecryptionError(event, err, await this.perSessionBackupDownloader.getServerBackupInfo());
|
|
1915
|
+
} else {
|
|
1916
|
+
throw new DecryptionError(DecryptionFailureCode.UNKNOWN_ERROR, "Unknown error");
|
|
2171
1917
|
}
|
|
2172
|
-
}
|
|
1918
|
+
}
|
|
2173
1919
|
}
|
|
2174
1920
|
|
|
2175
1921
|
/**
|
|
@@ -2183,8 +1929,8 @@ class EventDecryptor {
|
|
|
2183
1929
|
* `undefined` if our attempt to check failed.
|
|
2184
1930
|
*/
|
|
2185
1931
|
onMegolmDecryptionError(event, err, serverBackupInfo) {
|
|
2186
|
-
|
|
2187
|
-
|
|
1932
|
+
const content = event.getWireContent();
|
|
1933
|
+
const errorDetails = {
|
|
2188
1934
|
sender_key: content.sender_key,
|
|
2189
1935
|
session_id: content.session_id
|
|
2190
1936
|
};
|
|
@@ -2195,7 +1941,7 @@ class EventDecryptor {
|
|
|
2195
1941
|
|
|
2196
1942
|
// If the server is telling us our membership at the time the event
|
|
2197
1943
|
// was sent, and it isn't "join", we use a different error code.
|
|
2198
|
-
|
|
1944
|
+
const membership = event.getMembershipAtEvent();
|
|
2199
1945
|
if (membership && membership !== KnownMembership.Join && membership !== KnownMembership.Invite) {
|
|
2200
1946
|
throw new DecryptionError(DecryptionFailureCode.HISTORICAL_MESSAGE_USER_NOT_JOINED, "This message was sent when we were not a member of the room.", errorDetails);
|
|
2201
1947
|
}
|
|
@@ -2216,7 +1962,7 @@ class EventDecryptor {
|
|
|
2216
1962
|
if (err.maybe_withheld) {
|
|
2217
1963
|
// Unfortunately the Rust SDK API doesn't let us distinguish between different withheld cases, other than
|
|
2218
1964
|
// by string-matching.
|
|
2219
|
-
|
|
1965
|
+
const failureCode = err.maybe_withheld === "The sender has disabled encrypting to unverified devices." ? DecryptionFailureCode.MEGOLM_KEY_WITHHELD_FOR_UNVERIFIED_DEVICE : DecryptionFailureCode.MEGOLM_KEY_WITHHELD;
|
|
2220
1966
|
throw new DecryptionError(failureCode, err.maybe_withheld, errorDetails);
|
|
2221
1967
|
}
|
|
2222
1968
|
switch (err.code) {
|
|
@@ -2249,24 +1995,21 @@ class EventDecryptor {
|
|
|
2249
1995
|
throw new DecryptionError(DecryptionFailureCode.UNKNOWN_ERROR, err.description, errorDetails);
|
|
2250
1996
|
}
|
|
2251
1997
|
}
|
|
2252
|
-
getEncryptionInfoForEvent(event) {
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
return null;
|
|
2258
|
-
}
|
|
1998
|
+
async getEncryptionInfoForEvent(event) {
|
|
1999
|
+
if (!event.getClearContent() || event.isDecryptionFailure()) {
|
|
2000
|
+
// not successfully decrypted
|
|
2001
|
+
return null;
|
|
2002
|
+
}
|
|
2259
2003
|
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
})();
|
|
2004
|
+
// special-case outgoing events, which the rust crypto-sdk will barf on
|
|
2005
|
+
if (event.status !== null) {
|
|
2006
|
+
return {
|
|
2007
|
+
shieldColour: EventShieldColour.NONE,
|
|
2008
|
+
shieldReason: null
|
|
2009
|
+
};
|
|
2010
|
+
}
|
|
2011
|
+
const encryptionInfo = await this.olmMachine.getRoomEventEncryptionInfo(stringifyEvent(event), new RustSdkCryptoJs.RoomId(event.getRoomId()));
|
|
2012
|
+
return rustEncryptionInfoToJsEncryptionInfo(this.logger, encryptionInfo);
|
|
2270
2013
|
}
|
|
2271
2014
|
|
|
2272
2015
|
/**
|
|
@@ -2275,9 +2018,9 @@ class EventDecryptor {
|
|
|
2275
2018
|
* Returns a list of events which were encrypted by `session` and could not be decrypted
|
|
2276
2019
|
*/
|
|
2277
2020
|
getEventsPendingRoomKey(roomId, sessionId) {
|
|
2278
|
-
|
|
2021
|
+
const roomPendingEvents = this.eventsPendingKey.get(roomId);
|
|
2279
2022
|
if (!roomPendingEvents) return [];
|
|
2280
|
-
|
|
2023
|
+
const sessionPendingEvents = roomPendingEvents.get(sessionId);
|
|
2281
2024
|
if (!sessionPendingEvents) return [];
|
|
2282
2025
|
return [...sessionPendingEvents];
|
|
2283
2026
|
}
|
|
@@ -2286,11 +2029,11 @@ class EventDecryptor {
|
|
|
2286
2029
|
* Add an event to the list of those awaiting their session keys.
|
|
2287
2030
|
*/
|
|
2288
2031
|
addEventToPendingList(event) {
|
|
2289
|
-
|
|
2032
|
+
const roomId = event.getRoomId();
|
|
2290
2033
|
// We shouldn't have events without a room id here.
|
|
2291
2034
|
if (!roomId) return;
|
|
2292
|
-
|
|
2293
|
-
|
|
2035
|
+
const roomPendingEvents = this.eventsPendingKey.getOrCreate(roomId);
|
|
2036
|
+
const sessionPendingEvents = roomPendingEvents.getOrCreate(event.getWireContent().session_id);
|
|
2294
2037
|
sessionPendingEvents.add(event);
|
|
2295
2038
|
}
|
|
2296
2039
|
|
|
@@ -2298,11 +2041,11 @@ class EventDecryptor {
|
|
|
2298
2041
|
* Remove an event from the list of those awaiting their session keys.
|
|
2299
2042
|
*/
|
|
2300
2043
|
removeEventFromPendingList(event) {
|
|
2301
|
-
|
|
2044
|
+
const roomId = event.getRoomId();
|
|
2302
2045
|
if (!roomId) return;
|
|
2303
|
-
|
|
2046
|
+
const roomPendingEvents = this.eventsPendingKey.getOrCreate(roomId);
|
|
2304
2047
|
if (!roomPendingEvents) return;
|
|
2305
|
-
|
|
2048
|
+
const sessionPendingEvents = roomPendingEvents.get(event.getWireContent().session_id);
|
|
2306
2049
|
if (!sessionPendingEvents) return;
|
|
2307
2050
|
sessionPendingEvents.delete(event);
|
|
2308
2051
|
|
|
@@ -2332,8 +2075,8 @@ function rustEncryptionInfoToJsEncryptionInfo(logger, encryptionInfo) {
|
|
|
2332
2075
|
}
|
|
2333
2076
|
|
|
2334
2077
|
// TODO: use strict shield semantics.
|
|
2335
|
-
|
|
2336
|
-
|
|
2078
|
+
const shieldState = encryptionInfo.shieldState(false);
|
|
2079
|
+
let shieldColour;
|
|
2337
2080
|
switch (shieldState.color) {
|
|
2338
2081
|
case RustSdkCryptoJs.ShieldColor.Grey:
|
|
2339
2082
|
shieldColour = EventShieldColour.GREY;
|
|
@@ -2344,7 +2087,7 @@ function rustEncryptionInfoToJsEncryptionInfo(logger, encryptionInfo) {
|
|
|
2344
2087
|
default:
|
|
2345
2088
|
shieldColour = EventShieldColour.RED;
|
|
2346
2089
|
}
|
|
2347
|
-
|
|
2090
|
+
let shieldReason;
|
|
2348
2091
|
switch (shieldState.code) {
|
|
2349
2092
|
case undefined:
|
|
2350
2093
|
case null:
|