@openclaw/matrix 2026.7.1-beta.2 → 2026.7.1-beta.5

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.
Files changed (1070) hide show
  1. package/dist/{account-selection-Bv_ZuOu4.js → account-selection-5e4mHR1m.js} +1 -1
  2. package/dist/api.js +5 -5
  3. package/dist/{approval-handler.runtime-DzpLXVdc.js → approval-handler.runtime-DI5x9r8I.js} +5 -5
  4. package/dist/{approval-ids-R834n6m3.js → approval-ids-ZgqbspmS.js} +1 -1
  5. package/dist/{approval-reaction-auth-eAqCXUFG.js → approval-reaction-auth-D9LijQhr.js} +2 -2
  6. package/dist/{approval-reactions-BRGQgOu2.js → approval-reactions-BdUaUXVw.js} +24 -73
  7. package/dist/auth-presence.js +1 -1
  8. package/dist/{channel-KcNo9qtl.js → channel-jUTBsjHU.js} +20 -18
  9. package/dist/channel-plugin-api.js +1 -1
  10. package/dist/{channel.runtime-DtsGVgZj.js → channel.runtime-DO1Nv9ed.js} +25 -13
  11. package/dist/{cli-Clvpw_8I.js → cli-CEfWwCKx.js} +9 -9
  12. package/dist/{cli-metadata-D3N0Avnt.js → cli-metadata-CfiEO-CE.js} +1 -1
  13. package/dist/cli-metadata.js +1 -1
  14. package/dist/{client-BQz5GcYr.js → client-FRuyCNju.js} +2 -2
  15. package/dist/{client-bootstrap-CBJciU5u.js → client-bootstrap-DjFJ7e0N.js} +1 -2
  16. package/dist/{client-D-5GVz_D.js → client-tgnlQJk4.js} +2 -2
  17. package/dist/{config-schema-Dn-fHID8.js → config-schema-DtnhNYd-.js} +1 -1
  18. package/dist/contract-api.js +2 -2
  19. package/dist/{create-client-DhGid8FE.js → create-client-CNakT7zF.js} +3 -3
  20. package/dist/{credentials-G8lNmiME.js → credentials-Ds9V1mn2.js} +1 -1
  21. package/dist/{credentials-read-TzTOQPOM.js → credentials-read-BlkvsNFg.js} +1 -1
  22. package/dist/{credentials-write.runtime-5PDPPG9f.js → credentials-write.runtime-CTqqxcut.js} +1 -1
  23. package/dist/{crypto-runtime-B7kyrTL0.js → crypto-runtime-B74cTS6A.js} +4 -4
  24. package/dist/{crypto-state-store-DK2tcEyP.js → crypto-state-store-Jy3qwhdy.js} +1 -1
  25. package/dist/{deps-D3bkh48_.js → deps-CdjHvnmh.js} +20 -2
  26. package/dist/{directory-live-Ctu4whZK.js → directory-live-Ufd4qSpX.js} +2 -2
  27. package/dist/{doctor-BRSDNU5C.js → doctor-DfaOqFtr.js} +3 -3
  28. package/dist/{doctor-contract-Dq8OZWHF.js → doctor-contract-BAja_fmb.js} +1 -1
  29. package/dist/doctor-contract-api.js +8 -14
  30. package/dist/{draft-stream-j71tSUu-.js → draft-stream-D4EH25gv.js} +1 -1
  31. package/dist/{encryption-guidance-Bg3IRYoX.js → encryption-guidance-D8walY04.js} +1 -1
  32. package/dist/{file-sync-store-BWLVB01Y.js → file-sync-store-DVm0ACml.js} +3 -3
  33. package/dist/helper-api.js +1 -1
  34. package/dist/{idb-persistence-BGY1CJ7J.js → idb-persistence-BHm97th-.js} +1 -1
  35. package/dist/index.js +1 -1
  36. package/dist/{legacy-crypto-inspector-D_8iylBq.js → legacy-crypto-inspector-vzXSkm18.js} +1 -1
  37. package/dist/{legacy-crypto-restore-B0gcIEkE.js → legacy-crypto-restore-CIBfOmLn.js} +2 -2
  38. package/dist/{matrix-migration.runtime-Ctlb_rZl.js → matrix-migration.runtime-BMCyrANT.js} +3 -3
  39. package/dist/{media-text-XO4VaezT.js → media-text-p-LP21qs.js} +1 -1
  40. package/dist/{messages-nQLGGa1r.js → messages-DRKkiEY-.js} +6 -5
  41. package/dist/{monitor-k3Sko8qt.js → monitor-CsGOGdwu.js} +71 -71
  42. package/dist/plugin-entry.handlers.runtime.js +1 -1
  43. package/dist/probe.runtime-2MZLc6ng.js +3 -0
  44. package/dist/{profile-update-DIOAhezh.js → profile-update-Ucc8RrJL.js} +2 -2
  45. package/dist/{reaction-events-BDsbR82F.js → reaction-events-DentrVii.js} +3 -3
  46. package/dist/{recovery-key-store-BGk8c_gf.js → recovery-key-store-DSeLFvNx.js} +1 -1
  47. package/dist/{resolve-targets-BbrinjHd.js → resolve-targets-DcV_KfgX.js} +1 -1
  48. package/dist/{resolver.runtime-B3N7k_6-.js → resolver.runtime-Hr6bO5zl.js} +1 -1
  49. package/dist/runtime-api.js +2 -2
  50. package/dist/runtime-heavy-api.js +1 -1
  51. package/dist/{sdk-eyqOqjmn.js → sdk-AZYVl34z.js} +8 -6
  52. package/dist/{send-D0hpevF-.js → send-D92v6Yy0.js} +21 -8
  53. package/dist/session-binding-contract-api.js +1 -1
  54. package/dist/{setup-bootstrap-Ihb_DM2a.js → setup-bootstrap-Da564w5f.js} +2 -2
  55. package/dist/{setup-core-D2BQs8w1.js → setup-core-BGgbrdaJ.js} +5 -8
  56. package/dist/setup-plugin-api.js +3 -3
  57. package/dist/{setup-surface-1qf1LZIP.js → setup-surface-iJ6pd-t5.js} +6 -6
  58. package/dist/{shared-BGcaBMK3.js → shared-DkFfq7mH.js} +6 -6
  59. package/dist/{startup-verification-Bd31KqLv.js → startup-verification-BKMAXvcV.js} +2 -2
  60. package/dist/{storage-t5S-5c_5.js → storage-CQdyKcGg.js} +5 -5
  61. package/dist/{thread-bindings-BnuBS0VH.js → thread-bindings-BX5nmWpw.js} +3 -3
  62. package/dist/{tool-actions.runtime-BeUveYxV.js → tool-actions.runtime-C1d5fxE_.js} +12 -12
  63. package/dist/{verification-CNw2K4uT.js → verification-BGCMiO1p.js} +2 -2
  64. package/node_modules/@babel/runtime/package.json +468 -1089
  65. package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/.cargo/config.toml +2 -0
  66. package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/CHANGELOG.md +12 -3
  67. package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/README.md +17 -0
  68. package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/download-lib.js +10 -2
  69. package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/package.json +1 -1
  70. package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/xtask/.idea/modules.xml +8 -0
  71. package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/xtask/.idea/vcs.xml +6 -0
  72. package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/xtask/.idea/xtask.iml +11 -0
  73. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/package.json +1 -1
  74. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.cjs +28 -28
  75. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.js +24 -24
  76. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.wasm +0 -0
  77. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.wasm.d.ts +58 -58
  78. package/node_modules/content-type/README.md +32 -57
  79. package/node_modules/content-type/dist/index.d.ts +26 -0
  80. package/node_modules/content-type/dist/index.js +170 -0
  81. package/node_modules/content-type/dist/index.js.map +1 -0
  82. package/node_modules/content-type/package.json +35 -25
  83. package/node_modules/linkify-it/README.md +3 -4
  84. package/node_modules/linkify-it/build/index.cjs.js +44 -41
  85. package/node_modules/linkify-it/index.mjs +10 -11
  86. package/node_modules/linkify-it/lib/re.mjs +34 -30
  87. package/node_modules/linkify-it/package.json +10 -15
  88. package/node_modules/markdown-it/dist/index.cjs.js +3652 -5378
  89. package/node_modules/markdown-it/dist/index.cjs.js.map +1 -0
  90. package/node_modules/markdown-it/dist/markdown-it.js +1399 -4479
  91. package/node_modules/markdown-it/dist/markdown-it.js.map +1 -0
  92. package/node_modules/markdown-it/dist/markdown-it.min.js +3 -2
  93. package/node_modules/markdown-it/dist/markdown-it.min.js.map +1 -0
  94. package/node_modules/markdown-it/lib/common/html_re.mjs +9 -9
  95. package/node_modules/markdown-it/lib/common/utils.mjs +2 -11
  96. package/node_modules/markdown-it/lib/parser_block.mjs +9 -9
  97. package/node_modules/markdown-it/lib/parser_core.mjs +7 -7
  98. package/node_modules/markdown-it/lib/parser_inline.mjs +16 -16
  99. package/node_modules/markdown-it/lib/renderer.mjs +2 -2
  100. package/node_modules/markdown-it/lib/rules_block/blockquote.mjs +6 -6
  101. package/node_modules/markdown-it/lib/rules_block/code.mjs +2 -2
  102. package/node_modules/markdown-it/lib/rules_block/fence.mjs +4 -4
  103. package/node_modules/markdown-it/lib/rules_block/heading.mjs +7 -7
  104. package/node_modules/markdown-it/lib/rules_block/hr.mjs +2 -2
  105. package/node_modules/markdown-it/lib/rules_block/html_block.mjs +6 -6
  106. package/node_modules/markdown-it/lib/rules_block/lheading.mjs +8 -8
  107. package/node_modules/markdown-it/lib/rules_block/list.mjs +6 -6
  108. package/node_modules/markdown-it/lib/rules_block/paragraph.mjs +5 -5
  109. package/node_modules/markdown-it/lib/rules_block/reference.mjs +1 -1
  110. package/node_modules/markdown-it/lib/rules_block/state_block.mjs +6 -6
  111. package/node_modules/markdown-it/lib/rules_block/table.mjs +4 -4
  112. package/node_modules/markdown-it/lib/rules_core/block.mjs +3 -3
  113. package/node_modules/markdown-it/lib/rules_core/linkify.mjs +15 -15
  114. package/node_modules/markdown-it/lib/rules_core/normalize.mjs +2 -2
  115. package/node_modules/markdown-it/lib/rules_inline/autolink.mjs +17 -17
  116. package/node_modules/markdown-it/lib/rules_inline/balance_pairs.mjs +2 -2
  117. package/node_modules/markdown-it/lib/rules_inline/emphasis.mjs +8 -8
  118. package/node_modules/markdown-it/lib/rules_inline/entity.mjs +7 -7
  119. package/node_modules/markdown-it/lib/rules_inline/escape.mjs +15 -1
  120. package/node_modules/markdown-it/lib/rules_inline/html_inline.mjs +1 -1
  121. package/node_modules/markdown-it/lib/rules_inline/link.mjs +1 -1
  122. package/node_modules/markdown-it/lib/rules_inline/state_inline.mjs +2 -2
  123. package/node_modules/markdown-it/lib/rules_inline/strikethrough.mjs +10 -10
  124. package/node_modules/markdown-it/lib/token.mjs +12 -12
  125. package/node_modules/markdown-it/package.json +25 -34
  126. package/node_modules/matrix-js-sdk/CHANGELOG.md +24 -0
  127. package/node_modules/matrix-js-sdk/README.md +1 -1
  128. package/node_modules/matrix-js-sdk/lib/@types/AESEncryptedSecretStoragePayload.js +3 -1
  129. package/node_modules/matrix-js-sdk/lib/@types/IIdentityServerProvider.js +3 -1
  130. package/node_modules/matrix-js-sdk/lib/@types/PushRules.js +7 -7
  131. package/node_modules/matrix-js-sdk/lib/@types/PushRules.js.map +1 -1
  132. package/node_modules/matrix-js-sdk/lib/@types/auth.js +4 -4
  133. package/node_modules/matrix-js-sdk/lib/@types/auth.js.map +1 -1
  134. package/node_modules/matrix-js-sdk/lib/@types/beacon.js +2 -2
  135. package/node_modules/matrix-js-sdk/lib/@types/beacon.js.map +1 -1
  136. package/node_modules/matrix-js-sdk/lib/@types/common.js +3 -1
  137. package/node_modules/matrix-js-sdk/lib/@types/crypto.js +3 -1
  138. package/node_modules/matrix-js-sdk/lib/@types/event.d.ts +6 -1
  139. package/node_modules/matrix-js-sdk/lib/@types/event.d.ts.map +1 -1
  140. package/node_modules/matrix-js-sdk/lib/@types/event.js +23 -20
  141. package/node_modules/matrix-js-sdk/lib/@types/event.js.map +1 -1
  142. package/node_modules/matrix-js-sdk/lib/@types/events.js +3 -1
  143. package/node_modules/matrix-js-sdk/lib/@types/extensible_events.js +6 -6
  144. package/node_modules/matrix-js-sdk/lib/@types/extensible_events.js.map +1 -1
  145. package/node_modules/matrix-js-sdk/lib/@types/global.d.js.map +1 -1
  146. package/node_modules/matrix-js-sdk/lib/@types/json.js +3 -1
  147. package/node_modules/matrix-js-sdk/lib/@types/local_notifications.js +3 -1
  148. package/node_modules/matrix-js-sdk/lib/@types/location.js +4 -4
  149. package/node_modules/matrix-js-sdk/lib/@types/location.js.map +1 -1
  150. package/node_modules/matrix-js-sdk/lib/@types/matrix-sdk-crypto-wasm.d.js +3 -1
  151. package/node_modules/matrix-js-sdk/lib/@types/media.js +3 -1
  152. package/node_modules/matrix-js-sdk/lib/@types/membership.js +1 -1
  153. package/node_modules/matrix-js-sdk/lib/@types/membership.js.map +1 -1
  154. package/node_modules/matrix-js-sdk/lib/@types/partials.js +6 -6
  155. package/node_modules/matrix-js-sdk/lib/@types/partials.js.map +1 -1
  156. package/node_modules/matrix-js-sdk/lib/@types/polls.js +5 -5
  157. package/node_modules/matrix-js-sdk/lib/@types/polls.js.map +1 -1
  158. package/node_modules/matrix-js-sdk/lib/@types/read_receipts.js +2 -2
  159. package/node_modules/matrix-js-sdk/lib/@types/read_receipts.js.map +1 -1
  160. package/node_modules/matrix-js-sdk/lib/@types/registration.js +3 -1
  161. package/node_modules/matrix-js-sdk/lib/@types/requests.js +1 -1
  162. package/node_modules/matrix-js-sdk/lib/@types/requests.js.map +1 -1
  163. package/node_modules/matrix-js-sdk/lib/@types/retention.d.ts +15 -0
  164. package/node_modules/matrix-js-sdk/lib/@types/retention.d.ts.map +1 -0
  165. package/node_modules/matrix-js-sdk/lib/@types/retention.js +13 -0
  166. package/node_modules/matrix-js-sdk/lib/@types/retention.js.map +1 -0
  167. package/node_modules/matrix-js-sdk/lib/@types/search.js +1 -1
  168. package/node_modules/matrix-js-sdk/lib/@types/search.js.map +1 -1
  169. package/node_modules/matrix-js-sdk/lib/@types/signed.js +3 -1
  170. package/node_modules/matrix-js-sdk/lib/@types/spaces.js +3 -1
  171. package/node_modules/matrix-js-sdk/lib/@types/state_events.js +3 -1
  172. package/node_modules/matrix-js-sdk/lib/@types/synapse.js +3 -1
  173. package/node_modules/matrix-js-sdk/lib/@types/sync.js +1 -1
  174. package/node_modules/matrix-js-sdk/lib/@types/sync.js.map +1 -1
  175. package/node_modules/matrix-js-sdk/lib/@types/threepids.js +1 -1
  176. package/node_modules/matrix-js-sdk/lib/@types/threepids.js.map +1 -1
  177. package/node_modules/matrix-js-sdk/lib/@types/topic.js +1 -1
  178. package/node_modules/matrix-js-sdk/lib/@types/topic.js.map +1 -1
  179. package/node_modules/matrix-js-sdk/lib/@types/uia.js +3 -1
  180. package/node_modules/matrix-js-sdk/lib/NamespacedValue.js +8 -8
  181. package/node_modules/matrix-js-sdk/lib/NamespacedValue.js.map +1 -1
  182. package/node_modules/matrix-js-sdk/lib/ReEmitter.js +8 -15
  183. package/node_modules/matrix-js-sdk/lib/ReEmitter.js.map +1 -1
  184. package/node_modules/matrix-js-sdk/lib/ToDeviceMessageQueue.js +47 -55
  185. package/node_modules/matrix-js-sdk/lib/ToDeviceMessageQueue.js.map +1 -1
  186. package/node_modules/matrix-js-sdk/lib/autodiscovery.js +233 -247
  187. package/node_modules/matrix-js-sdk/lib/autodiscovery.js.map +1 -1
  188. package/node_modules/matrix-js-sdk/lib/base64.js +1 -1
  189. package/node_modules/matrix-js-sdk/lib/base64.js.map +1 -1
  190. package/node_modules/matrix-js-sdk/lib/browser-index.d.ts +2 -2
  191. package/node_modules/matrix-js-sdk/lib/browser-index.d.ts.map +1 -1
  192. package/node_modules/matrix-js-sdk/lib/browser-index.js +5 -5
  193. package/node_modules/matrix-js-sdk/lib/browser-index.js.map +1 -1
  194. package/node_modules/matrix-js-sdk/lib/capabilityPoller.d.ts +38 -0
  195. package/node_modules/matrix-js-sdk/lib/capabilityPoller.d.ts.map +1 -0
  196. package/node_modules/matrix-js-sdk/lib/capabilityPoller.js +93 -0
  197. package/node_modules/matrix-js-sdk/lib/capabilityPoller.js.map +1 -0
  198. package/node_modules/matrix-js-sdk/lib/client.d.ts +9 -8
  199. package/node_modules/matrix-js-sdk/lib/client.d.ts.map +1 -1
  200. package/node_modules/matrix-js-sdk/lib/client.js +2123 -2483
  201. package/node_modules/matrix-js-sdk/lib/client.js.map +1 -1
  202. package/node_modules/matrix-js-sdk/lib/common-crypto/CryptoBackend.js +3 -1
  203. package/node_modules/matrix-js-sdk/lib/common-crypto/CryptoBackend.js.map +1 -1
  204. package/node_modules/matrix-js-sdk/lib/common-crypto/key-passphrase.js.map +1 -1
  205. package/node_modules/matrix-js-sdk/lib/content-helpers.js +43 -48
  206. package/node_modules/matrix-js-sdk/lib/content-helpers.js.map +1 -1
  207. package/node_modules/matrix-js-sdk/lib/content-repo.js +14 -24
  208. package/node_modules/matrix-js-sdk/lib/content-repo.js.map +1 -1
  209. package/node_modules/matrix-js-sdk/lib/crypto/store/base.js +6 -6
  210. package/node_modules/matrix-js-sdk/lib/crypto/store/base.js.map +1 -1
  211. package/node_modules/matrix-js-sdk/lib/crypto/store/indexeddb-crypto-store-backend.js +189 -237
  212. package/node_modules/matrix-js-sdk/lib/crypto/store/indexeddb-crypto-store-backend.js.map +1 -1
  213. package/node_modules/matrix-js-sdk/lib/crypto/store/indexeddb-crypto-store.js +25 -28
  214. package/node_modules/matrix-js-sdk/lib/crypto/store/indexeddb-crypto-store.js.map +1 -1
  215. package/node_modules/matrix-js-sdk/lib/crypto/store/localStorage-crypto-store.js +113 -145
  216. package/node_modules/matrix-js-sdk/lib/crypto/store/localStorage-crypto-store.js.map +1 -1
  217. package/node_modules/matrix-js-sdk/lib/crypto/store/memory-crypto-store.js +74 -105
  218. package/node_modules/matrix-js-sdk/lib/crypto/store/memory-crypto-store.js.map +1 -1
  219. package/node_modules/matrix-js-sdk/lib/crypto-api/CryptoEvent.js +1 -1
  220. package/node_modules/matrix-js-sdk/lib/crypto-api/CryptoEvent.js.map +1 -1
  221. package/node_modules/matrix-js-sdk/lib/crypto-api/CryptoEventHandlerMap.js +3 -1
  222. package/node_modules/matrix-js-sdk/lib/crypto-api/index.d.ts +15 -6
  223. package/node_modules/matrix-js-sdk/lib/crypto-api/index.d.ts.map +1 -1
  224. package/node_modules/matrix-js-sdk/lib/crypto-api/index.js +76 -76
  225. package/node_modules/matrix-js-sdk/lib/crypto-api/index.js.map +1 -1
  226. package/node_modules/matrix-js-sdk/lib/crypto-api/key-passphrase.js +15 -23
  227. package/node_modules/matrix-js-sdk/lib/crypto-api/key-passphrase.js.map +1 -1
  228. package/node_modules/matrix-js-sdk/lib/crypto-api/keybackup.js +3 -1
  229. package/node_modules/matrix-js-sdk/lib/crypto-api/recovery-key.js +11 -12
  230. package/node_modules/matrix-js-sdk/lib/crypto-api/recovery-key.js.map +1 -1
  231. package/node_modules/matrix-js-sdk/lib/crypto-api/verification.js +3 -3
  232. package/node_modules/matrix-js-sdk/lib/crypto-api/verification.js.map +1 -1
  233. package/node_modules/matrix-js-sdk/lib/digest.js +7 -14
  234. package/node_modules/matrix-js-sdk/lib/digest.js.map +1 -1
  235. package/node_modules/matrix-js-sdk/lib/embedded.d.ts.map +1 -1
  236. package/node_modules/matrix-js-sdk/lib/embedded.js +379 -500
  237. package/node_modules/matrix-js-sdk/lib/embedded.js.map +1 -1
  238. package/node_modules/matrix-js-sdk/lib/errors.js +2 -2
  239. package/node_modules/matrix-js-sdk/lib/errors.js.map +1 -1
  240. package/node_modules/matrix-js-sdk/lib/event-mapper.js +10 -12
  241. package/node_modules/matrix-js-sdk/lib/event-mapper.js.map +1 -1
  242. package/node_modules/matrix-js-sdk/lib/extensible_events_v1/ExtensibleEvent.js.map +1 -1
  243. package/node_modules/matrix-js-sdk/lib/extensible_events_v1/InvalidEventError.js.map +1 -1
  244. package/node_modules/matrix-js-sdk/lib/extensible_events_v1/MessageEvent.js +26 -28
  245. package/node_modules/matrix-js-sdk/lib/extensible_events_v1/MessageEvent.js.map +1 -1
  246. package/node_modules/matrix-js-sdk/lib/extensible_events_v1/PollEndEvent.js +11 -12
  247. package/node_modules/matrix-js-sdk/lib/extensible_events_v1/PollEndEvent.js.map +1 -1
  248. package/node_modules/matrix-js-sdk/lib/extensible_events_v1/PollResponseEvent.js +6 -6
  249. package/node_modules/matrix-js-sdk/lib/extensible_events_v1/PollResponseEvent.js.map +1 -1
  250. package/node_modules/matrix-js-sdk/lib/extensible_events_v1/PollStartEvent.js +36 -38
  251. package/node_modules/matrix-js-sdk/lib/extensible_events_v1/PollStartEvent.js.map +1 -1
  252. package/node_modules/matrix-js-sdk/lib/extensible_events_v1/utilities.js.map +1 -1
  253. package/node_modules/matrix-js-sdk/lib/feature.js +18 -31
  254. package/node_modules/matrix-js-sdk/lib/feature.js.map +1 -1
  255. package/node_modules/matrix-js-sdk/lib/filter-component.d.ts.map +1 -1
  256. package/node_modules/matrix-js-sdk/lib/filter-component.js +20 -26
  257. package/node_modules/matrix-js-sdk/lib/filter-component.js.map +1 -1
  258. package/node_modules/matrix-js-sdk/lib/filter.js +14 -15
  259. package/node_modules/matrix-js-sdk/lib/filter.js.map +1 -1
  260. package/node_modules/matrix-js-sdk/lib/http-api/errors.js +41 -56
  261. package/node_modules/matrix-js-sdk/lib/http-api/errors.js.map +1 -1
  262. package/node_modules/matrix-js-sdk/lib/http-api/fetch.js +140 -157
  263. package/node_modules/matrix-js-sdk/lib/http-api/fetch.js.map +1 -1
  264. package/node_modules/matrix-js-sdk/lib/http-api/index.js +17 -20
  265. package/node_modules/matrix-js-sdk/lib/http-api/index.js.map +1 -1
  266. package/node_modules/matrix-js-sdk/lib/http-api/interface.js +1 -1
  267. package/node_modules/matrix-js-sdk/lib/http-api/interface.js.map +1 -1
  268. package/node_modules/matrix-js-sdk/lib/http-api/method.js +1 -1
  269. package/node_modules/matrix-js-sdk/lib/http-api/method.js.map +1 -1
  270. package/node_modules/matrix-js-sdk/lib/http-api/prefix.js +3 -3
  271. package/node_modules/matrix-js-sdk/lib/http-api/prefix.js.map +1 -1
  272. package/node_modules/matrix-js-sdk/lib/http-api/refresh.js +80 -99
  273. package/node_modules/matrix-js-sdk/lib/http-api/refresh.js.map +1 -1
  274. package/node_modules/matrix-js-sdk/lib/http-api/utils.d.ts +1 -1
  275. package/node_modules/matrix-js-sdk/lib/http-api/utils.d.ts.map +1 -1
  276. package/node_modules/matrix-js-sdk/lib/http-api/utils.js +35 -47
  277. package/node_modules/matrix-js-sdk/lib/http-api/utils.js.map +1 -1
  278. package/node_modules/matrix-js-sdk/lib/index.js.map +1 -1
  279. package/node_modules/matrix-js-sdk/lib/indexeddb-helpers.js +3 -3
  280. package/node_modules/matrix-js-sdk/lib/indexeddb-helpers.js.map +1 -1
  281. package/node_modules/matrix-js-sdk/lib/indexeddb-worker.js.map +1 -1
  282. package/node_modules/matrix-js-sdk/lib/interactive-auth.d.ts +5 -5
  283. package/node_modules/matrix-js-sdk/lib/interactive-auth.d.ts.map +1 -1
  284. package/node_modules/matrix-js-sdk/lib/interactive-auth.js +181 -203
  285. package/node_modules/matrix-js-sdk/lib/interactive-auth.js.map +1 -1
  286. package/node_modules/matrix-js-sdk/lib/logger.js +22 -56
  287. package/node_modules/matrix-js-sdk/lib/logger.js.map +1 -1
  288. package/node_modules/matrix-js-sdk/lib/matrix.d.ts +1 -0
  289. package/node_modules/matrix-js-sdk/lib/matrix.d.ts.map +1 -1
  290. package/node_modules/matrix-js-sdk/lib/matrix.js +8 -11
  291. package/node_modules/matrix-js-sdk/lib/matrix.js.map +1 -1
  292. package/node_modules/matrix-js-sdk/lib/matrixrtc/CallMembership.js +83 -76
  293. package/node_modules/matrix-js-sdk/lib/matrixrtc/CallMembership.js.map +1 -1
  294. package/node_modules/matrix-js-sdk/lib/matrixrtc/EncryptionManager.js +1 -1
  295. package/node_modules/matrix-js-sdk/lib/matrixrtc/EncryptionManager.js.map +1 -1
  296. package/node_modules/matrix-js-sdk/lib/matrixrtc/IKeyTransport.js +1 -1
  297. package/node_modules/matrix-js-sdk/lib/matrixrtc/IKeyTransport.js.map +1 -1
  298. package/node_modules/matrix-js-sdk/lib/matrixrtc/IMembershipManager.js +1 -1
  299. package/node_modules/matrix-js-sdk/lib/matrixrtc/IMembershipManager.js.map +1 -1
  300. package/node_modules/matrix-js-sdk/lib/matrixrtc/LivekitTransport.d.ts +1 -1
  301. package/node_modules/matrix-js-sdk/lib/matrixrtc/LivekitTransport.js +4 -4
  302. package/node_modules/matrix-js-sdk/lib/matrixrtc/LivekitTransport.js.map +1 -1
  303. package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSession.d.ts.map +1 -1
  304. package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSession.js +144 -184
  305. package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSession.js.map +1 -1
  306. package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSessionManager.js +35 -39
  307. package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSessionManager.js.map +1 -1
  308. package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManager.d.ts +2 -0
  309. package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManager.d.ts.map +1 -1
  310. package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManager.js +346 -383
  311. package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManager.js.map +1 -1
  312. package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManagerActionScheduler.d.ts.map +1 -1
  313. package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManagerActionScheduler.js +54 -59
  314. package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManagerActionScheduler.js.map +1 -1
  315. package/node_modules/matrix-js-sdk/lib/matrixrtc/RTCEncryptionManager.js +117 -139
  316. package/node_modules/matrix-js-sdk/lib/matrixrtc/RTCEncryptionManager.js.map +1 -1
  317. package/node_modules/matrix-js-sdk/lib/matrixrtc/ToDeviceKeyTransport.js +49 -54
  318. package/node_modules/matrix-js-sdk/lib/matrixrtc/ToDeviceKeyTransport.js.map +1 -1
  319. package/node_modules/matrix-js-sdk/lib/matrixrtc/index.js.map +1 -1
  320. package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/common.js +1 -1
  321. package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/common.js.map +1 -1
  322. package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/index.js.map +1 -1
  323. package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/rtc.js +15 -23
  324. package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/rtc.js.map +1 -1
  325. package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/session.js +4 -5
  326. package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/session.js.map +1 -1
  327. package/node_modules/matrix-js-sdk/lib/matrixrtc/types.js +4 -6
  328. package/node_modules/matrix-js-sdk/lib/matrixrtc/types.js.map +1 -1
  329. package/node_modules/matrix-js-sdk/lib/matrixrtc/utils.js +4 -11
  330. package/node_modules/matrix-js-sdk/lib/matrixrtc/utils.js.map +1 -1
  331. package/node_modules/matrix-js-sdk/lib/models/MSC3089Branch.js +91 -116
  332. package/node_modules/matrix-js-sdk/lib/models/MSC3089Branch.js.map +1 -1
  333. package/node_modules/matrix-js-sdk/lib/models/MSC3089TreeSpace.js +209 -244
  334. package/node_modules/matrix-js-sdk/lib/models/MSC3089TreeSpace.js.map +1 -1
  335. package/node_modules/matrix-js-sdk/lib/models/ToDeviceMessage.js +3 -1
  336. package/node_modules/matrix-js-sdk/lib/models/beacon.js +20 -15
  337. package/node_modules/matrix-js-sdk/lib/models/beacon.js.map +1 -1
  338. package/node_modules/matrix-js-sdk/lib/models/compare-event-ordering.js +13 -13
  339. package/node_modules/matrix-js-sdk/lib/models/compare-event-ordering.js.map +1 -1
  340. package/node_modules/matrix-js-sdk/lib/models/device.js +10 -3
  341. package/node_modules/matrix-js-sdk/lib/models/device.js.map +1 -1
  342. package/node_modules/matrix-js-sdk/lib/models/event-context.js +5 -7
  343. package/node_modules/matrix-js-sdk/lib/models/event-context.js.map +1 -1
  344. package/node_modules/matrix-js-sdk/lib/models/event-status.js +1 -1
  345. package/node_modules/matrix-js-sdk/lib/models/event-status.js.map +1 -1
  346. package/node_modules/matrix-js-sdk/lib/models/event-timeline-set.js +91 -91
  347. package/node_modules/matrix-js-sdk/lib/models/event-timeline-set.js.map +1 -1
  348. package/node_modules/matrix-js-sdk/lib/models/event-timeline.js +31 -29
  349. package/node_modules/matrix-js-sdk/lib/models/event-timeline.js.map +1 -1
  350. package/node_modules/matrix-js-sdk/lib/models/event.js +215 -235
  351. package/node_modules/matrix-js-sdk/lib/models/event.js.map +1 -1
  352. package/node_modules/matrix-js-sdk/lib/models/invites-ignorer-types.js +4 -4
  353. package/node_modules/matrix-js-sdk/lib/models/invites-ignorer-types.js.map +1 -1
  354. package/node_modules/matrix-js-sdk/lib/models/invites-ignorer.js +159 -179
  355. package/node_modules/matrix-js-sdk/lib/models/invites-ignorer.js.map +1 -1
  356. package/node_modules/matrix-js-sdk/lib/models/poll.js +72 -78
  357. package/node_modules/matrix-js-sdk/lib/models/poll.js.map +1 -1
  358. package/node_modules/matrix-js-sdk/lib/models/profile-keys.js +2 -2
  359. package/node_modules/matrix-js-sdk/lib/models/profile-keys.js.map +1 -1
  360. package/node_modules/matrix-js-sdk/lib/models/read-receipt.js +40 -56
  361. package/node_modules/matrix-js-sdk/lib/models/read-receipt.js.map +1 -1
  362. package/node_modules/matrix-js-sdk/lib/models/related-relations.js +2 -0
  363. package/node_modules/matrix-js-sdk/lib/models/related-relations.js.map +1 -1
  364. package/node_modules/matrix-js-sdk/lib/models/relations-container.js +20 -21
  365. package/node_modules/matrix-js-sdk/lib/models/relations-container.js.map +1 -1
  366. package/node_modules/matrix-js-sdk/lib/models/relations.js +131 -156
  367. package/node_modules/matrix-js-sdk/lib/models/relations.js.map +1 -1
  368. package/node_modules/matrix-js-sdk/lib/models/room-member.js +44 -27
  369. package/node_modules/matrix-js-sdk/lib/models/room-member.js.map +1 -1
  370. package/node_modules/matrix-js-sdk/lib/models/room-receipts.js +48 -55
  371. package/node_modules/matrix-js-sdk/lib/models/room-receipts.js.map +1 -1
  372. package/node_modules/matrix-js-sdk/lib/models/room-retention.d.ts +28 -0
  373. package/node_modules/matrix-js-sdk/lib/models/room-retention.d.ts.map +1 -0
  374. package/node_modules/matrix-js-sdk/lib/models/room-retention.js +192 -0
  375. package/node_modules/matrix-js-sdk/lib/models/room-retention.js.map +1 -0
  376. package/node_modules/matrix-js-sdk/lib/models/room-state.js +141 -170
  377. package/node_modules/matrix-js-sdk/lib/models/room-state.js.map +1 -1
  378. package/node_modules/matrix-js-sdk/lib/models/room-sticky-events.d.ts +1 -0
  379. package/node_modules/matrix-js-sdk/lib/models/room-sticky-events.d.ts.map +1 -1
  380. package/node_modules/matrix-js-sdk/lib/models/room-sticky-events.js +46 -65
  381. package/node_modules/matrix-js-sdk/lib/models/room-sticky-events.js.map +1 -1
  382. package/node_modules/matrix-js-sdk/lib/models/room-summary.js.map +1 -1
  383. package/node_modules/matrix-js-sdk/lib/models/room.d.ts +2 -1
  384. package/node_modules/matrix-js-sdk/lib/models/room.d.ts.map +1 -1
  385. package/node_modules/matrix-js-sdk/lib/models/room.js +800 -887
  386. package/node_modules/matrix-js-sdk/lib/models/room.js.map +1 -1
  387. package/node_modules/matrix-js-sdk/lib/models/search-result.js +5 -5
  388. package/node_modules/matrix-js-sdk/lib/models/search-result.js.map +1 -1
  389. package/node_modules/matrix-js-sdk/lib/models/thread.js +267 -283
  390. package/node_modules/matrix-js-sdk/lib/models/thread.js.map +1 -1
  391. package/node_modules/matrix-js-sdk/lib/models/typed-event-emitter.js +7 -18
  392. package/node_modules/matrix-js-sdk/lib/models/typed-event-emitter.js.map +1 -1
  393. package/node_modules/matrix-js-sdk/lib/models/user.js +26 -7
  394. package/node_modules/matrix-js-sdk/lib/models/user.js.map +1 -1
  395. package/node_modules/matrix-js-sdk/lib/oidc/authorize.js +208 -241
  396. package/node_modules/matrix-js-sdk/lib/oidc/authorize.js.map +1 -1
  397. package/node_modules/matrix-js-sdk/lib/oidc/discovery.js +23 -36
  398. package/node_modules/matrix-js-sdk/lib/oidc/discovery.js.map +1 -1
  399. package/node_modules/matrix-js-sdk/lib/oidc/error.js +1 -1
  400. package/node_modules/matrix-js-sdk/lib/oidc/error.js.map +1 -1
  401. package/node_modules/matrix-js-sdk/lib/oidc/index.js +1 -0
  402. package/node_modules/matrix-js-sdk/lib/oidc/index.js.map +1 -1
  403. package/node_modules/matrix-js-sdk/lib/oidc/register.js +60 -66
  404. package/node_modules/matrix-js-sdk/lib/oidc/register.js.map +1 -1
  405. package/node_modules/matrix-js-sdk/lib/oidc/tokenRefresher.js +83 -94
  406. package/node_modules/matrix-js-sdk/lib/oidc/tokenRefresher.js.map +1 -1
  407. package/node_modules/matrix-js-sdk/lib/oidc/validate.js +18 -18
  408. package/node_modules/matrix-js-sdk/lib/oidc/validate.js.map +1 -1
  409. package/node_modules/matrix-js-sdk/lib/pushprocessor.js +70 -81
  410. package/node_modules/matrix-js-sdk/lib/pushprocessor.js.map +1 -1
  411. package/node_modules/matrix-js-sdk/lib/randomstring.js +9 -9
  412. package/node_modules/matrix-js-sdk/lib/randomstring.js.map +1 -1
  413. package/node_modules/matrix-js-sdk/lib/realtime-callbacks.js +25 -28
  414. package/node_modules/matrix-js-sdk/lib/realtime-callbacks.js.map +1 -1
  415. package/node_modules/matrix-js-sdk/lib/receipt-accumulator.d.ts +2 -0
  416. package/node_modules/matrix-js-sdk/lib/receipt-accumulator.d.ts.map +1 -1
  417. package/node_modules/matrix-js-sdk/lib/receipt-accumulator.js +14 -22
  418. package/node_modules/matrix-js-sdk/lib/receipt-accumulator.js.map +1 -1
  419. package/node_modules/matrix-js-sdk/lib/rendezvous/MSC4108SignInWithQR.js +272 -298
  420. package/node_modules/matrix-js-sdk/lib/rendezvous/MSC4108SignInWithQR.js.map +1 -1
  421. package/node_modules/matrix-js-sdk/lib/rendezvous/RendezvousChannel.js +3 -1
  422. package/node_modules/matrix-js-sdk/lib/rendezvous/RendezvousCode.js +3 -1
  423. package/node_modules/matrix-js-sdk/lib/rendezvous/RendezvousError.js.map +1 -1
  424. package/node_modules/matrix-js-sdk/lib/rendezvous/RendezvousFailureReason.js +2 -2
  425. package/node_modules/matrix-js-sdk/lib/rendezvous/RendezvousFailureReason.js.map +1 -1
  426. package/node_modules/matrix-js-sdk/lib/rendezvous/RendezvousIntent.js +1 -1
  427. package/node_modules/matrix-js-sdk/lib/rendezvous/RendezvousIntent.js.map +1 -1
  428. package/node_modules/matrix-js-sdk/lib/rendezvous/RendezvousTransport.js +3 -1
  429. package/node_modules/matrix-js-sdk/lib/rendezvous/channels/MSC4108SecureChannel.js +122 -144
  430. package/node_modules/matrix-js-sdk/lib/rendezvous/channels/MSC4108SecureChannel.js.map +1 -1
  431. package/node_modules/matrix-js-sdk/lib/rendezvous/index.js +44 -69
  432. package/node_modules/matrix-js-sdk/lib/rendezvous/index.js.map +1 -1
  433. package/node_modules/matrix-js-sdk/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts +1 -1
  434. package/node_modules/matrix-js-sdk/lib/rendezvous/transports/MSC4108RendezvousSession.js +142 -152
  435. package/node_modules/matrix-js-sdk/lib/rendezvous/transports/MSC4108RendezvousSession.js.map +1 -1
  436. package/node_modules/matrix-js-sdk/lib/retentionPolicy.d.ts +33 -0
  437. package/node_modules/matrix-js-sdk/lib/retentionPolicy.d.ts.map +1 -0
  438. package/node_modules/matrix-js-sdk/lib/retentionPolicy.js +39 -0
  439. package/node_modules/matrix-js-sdk/lib/retentionPolicy.js.map +1 -0
  440. package/node_modules/matrix-js-sdk/lib/room-hierarchy.js +52 -56
  441. package/node_modules/matrix-js-sdk/lib/room-hierarchy.js.map +1 -1
  442. package/node_modules/matrix-js-sdk/lib/rust-crypto/CrossSigningIdentity.js +94 -104
  443. package/node_modules/matrix-js-sdk/lib/rust-crypto/CrossSigningIdentity.js.map +1 -1
  444. package/node_modules/matrix-js-sdk/lib/rust-crypto/DehydratedDeviceManager.js +158 -190
  445. package/node_modules/matrix-js-sdk/lib/rust-crypto/DehydratedDeviceManager.js.map +1 -1
  446. package/node_modules/matrix-js-sdk/lib/rust-crypto/KeyClaimManager.js +17 -20
  447. package/node_modules/matrix-js-sdk/lib/rust-crypto/KeyClaimManager.js.map +1 -1
  448. package/node_modules/matrix-js-sdk/lib/rust-crypto/OutgoingRequestProcessor.js +109 -139
  449. package/node_modules/matrix-js-sdk/lib/rust-crypto/OutgoingRequestProcessor.js.map +1 -1
  450. package/node_modules/matrix-js-sdk/lib/rust-crypto/OutgoingRequestsManager.js +72 -86
  451. package/node_modules/matrix-js-sdk/lib/rust-crypto/OutgoingRequestsManager.js.map +1 -1
  452. package/node_modules/matrix-js-sdk/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts +1 -1
  453. package/node_modules/matrix-js-sdk/lib/rust-crypto/PerSessionKeyBackupDownloader.js +195 -221
  454. package/node_modules/matrix-js-sdk/lib/rust-crypto/PerSessionKeyBackupDownloader.js.map +1 -1
  455. package/node_modules/matrix-js-sdk/lib/rust-crypto/RoomEncryptor.js +121 -137
  456. package/node_modules/matrix-js-sdk/lib/rust-crypto/RoomEncryptor.js.map +1 -1
  457. package/node_modules/matrix-js-sdk/lib/rust-crypto/backup.d.ts +7 -2
  458. package/node_modules/matrix-js-sdk/lib/rust-crypto/backup.d.ts.map +1 -1
  459. package/node_modules/matrix-js-sdk/lib/rust-crypto/backup.js +459 -544
  460. package/node_modules/matrix-js-sdk/lib/rust-crypto/backup.js.map +1 -1
  461. package/node_modules/matrix-js-sdk/lib/rust-crypto/constants.js +1 -1
  462. package/node_modules/matrix-js-sdk/lib/rust-crypto/constants.js.map +1 -1
  463. package/node_modules/matrix-js-sdk/lib/rust-crypto/device-converter.js +15 -28
  464. package/node_modules/matrix-js-sdk/lib/rust-crypto/device-converter.js.map +1 -1
  465. package/node_modules/matrix-js-sdk/lib/rust-crypto/index.js +103 -116
  466. package/node_modules/matrix-js-sdk/lib/rust-crypto/index.js.map +1 -1
  467. package/node_modules/matrix-js-sdk/lib/rust-crypto/libolm_migration.js +303 -365
  468. package/node_modules/matrix-js-sdk/lib/rust-crypto/libolm_migration.js.map +1 -1
  469. package/node_modules/matrix-js-sdk/lib/rust-crypto/rust-crypto.d.ts +5 -1
  470. package/node_modules/matrix-js-sdk/lib/rust-crypto/rust-crypto.d.ts.map +1 -1
  471. package/node_modules/matrix-js-sdk/lib/rust-crypto/rust-crypto.js +1065 -1322
  472. package/node_modules/matrix-js-sdk/lib/rust-crypto/rust-crypto.js.map +1 -1
  473. package/node_modules/matrix-js-sdk/lib/rust-crypto/secret-storage.js +12 -25
  474. package/node_modules/matrix-js-sdk/lib/rust-crypto/secret-storage.js.map +1 -1
  475. package/node_modules/matrix-js-sdk/lib/rust-crypto/verification.js +134 -184
  476. package/node_modules/matrix-js-sdk/lib/rust-crypto/verification.js.map +1 -1
  477. package/node_modules/matrix-js-sdk/lib/scheduler.js +42 -17
  478. package/node_modules/matrix-js-sdk/lib/scheduler.js.map +1 -1
  479. package/node_modules/matrix-js-sdk/lib/secret-storage.js +179 -213
  480. package/node_modules/matrix-js-sdk/lib/secret-storage.js.map +1 -1
  481. package/node_modules/matrix-js-sdk/lib/serverCapabilities.d.ts +4 -23
  482. package/node_modules/matrix-js-sdk/lib/serverCapabilities.d.ts.map +1 -1
  483. package/node_modules/matrix-js-sdk/lib/serverCapabilities.js +9 -62
  484. package/node_modules/matrix-js-sdk/lib/serverCapabilities.js.map +1 -1
  485. package/node_modules/matrix-js-sdk/lib/service-types.js +1 -1
  486. package/node_modules/matrix-js-sdk/lib/service-types.js.map +1 -1
  487. package/node_modules/matrix-js-sdk/lib/sliding-sync-sdk.d.ts.map +1 -1
  488. package/node_modules/matrix-js-sdk/lib/sliding-sync-sdk.js +368 -421
  489. package/node_modules/matrix-js-sdk/lib/sliding-sync-sdk.js.map +1 -1
  490. package/node_modules/matrix-js-sdk/lib/sliding-sync.js +136 -167
  491. package/node_modules/matrix-js-sdk/lib/sliding-sync.js.map +1 -1
  492. package/node_modules/matrix-js-sdk/lib/store/index.d.ts +7 -0
  493. package/node_modules/matrix-js-sdk/lib/store/index.d.ts.map +1 -1
  494. package/node_modules/matrix-js-sdk/lib/store/index.js +3 -1
  495. package/node_modules/matrix-js-sdk/lib/store/index.js.map +1 -1
  496. package/node_modules/matrix-js-sdk/lib/store/indexeddb-backend.js +3 -1
  497. package/node_modules/matrix-js-sdk/lib/store/indexeddb-local-backend.d.ts +1 -0
  498. package/node_modules/matrix-js-sdk/lib/store/indexeddb-local-backend.d.ts.map +1 -1
  499. package/node_modules/matrix-js-sdk/lib/store/indexeddb-local-backend.js +197 -240
  500. package/node_modules/matrix-js-sdk/lib/store/indexeddb-local-backend.js.map +1 -1
  501. package/node_modules/matrix-js-sdk/lib/store/indexeddb-remote-backend.d.ts +3 -1
  502. package/node_modules/matrix-js-sdk/lib/store/indexeddb-remote-backend.d.ts.map +1 -1
  503. package/node_modules/matrix-js-sdk/lib/store/indexeddb-remote-backend.js +51 -59
  504. package/node_modules/matrix-js-sdk/lib/store/indexeddb-remote-backend.js.map +1 -1
  505. package/node_modules/matrix-js-sdk/lib/store/indexeddb-store-worker.js +22 -22
  506. package/node_modules/matrix-js-sdk/lib/store/indexeddb-store-worker.js.map +1 -1
  507. package/node_modules/matrix-js-sdk/lib/store/indexeddb.d.ts +7 -5
  508. package/node_modules/matrix-js-sdk/lib/store/indexeddb.d.ts.map +1 -1
  509. package/node_modules/matrix-js-sdk/lib/store/indexeddb.js +63 -79
  510. package/node_modules/matrix-js-sdk/lib/store/indexeddb.js.map +1 -1
  511. package/node_modules/matrix-js-sdk/lib/store/local-storage-events-emitter.js +2 -2
  512. package/node_modules/matrix-js-sdk/lib/store/local-storage-events-emitter.js.map +1 -1
  513. package/node_modules/matrix-js-sdk/lib/store/memory.d.ts +1 -0
  514. package/node_modules/matrix-js-sdk/lib/store/memory.d.ts.map +1 -1
  515. package/node_modules/matrix-js-sdk/lib/store/memory.js +38 -54
  516. package/node_modules/matrix-js-sdk/lib/store/memory.js.map +1 -1
  517. package/node_modules/matrix-js-sdk/lib/store/stub.d.ts +1 -0
  518. package/node_modules/matrix-js-sdk/lib/store/stub.d.ts.map +1 -1
  519. package/node_modules/matrix-js-sdk/lib/store/stub.js +22 -32
  520. package/node_modules/matrix-js-sdk/lib/store/stub.js.map +1 -1
  521. package/node_modules/matrix-js-sdk/lib/sync-accumulator.d.ts +1 -0
  522. package/node_modules/matrix-js-sdk/lib/sync-accumulator.d.ts.map +1 -1
  523. package/node_modules/matrix-js-sdk/lib/sync-accumulator.js +57 -65
  524. package/node_modules/matrix-js-sdk/lib/sync-accumulator.js.map +1 -1
  525. package/node_modules/matrix-js-sdk/lib/sync.d.ts.map +1 -1
  526. package/node_modules/matrix-js-sdk/lib/sync.js +914 -991
  527. package/node_modules/matrix-js-sdk/lib/sync.js.map +1 -1
  528. package/node_modules/matrix-js-sdk/lib/testing.js +63 -105
  529. package/node_modules/matrix-js-sdk/lib/testing.js.map +1 -1
  530. package/node_modules/matrix-js-sdk/lib/thread-utils.js +1 -4
  531. package/node_modules/matrix-js-sdk/lib/thread-utils.js.map +1 -1
  532. package/node_modules/matrix-js-sdk/lib/timeline-window.js +90 -99
  533. package/node_modules/matrix-js-sdk/lib/timeline-window.js.map +1 -1
  534. package/node_modules/matrix-js-sdk/lib/types.js +1 -1
  535. package/node_modules/matrix-js-sdk/lib/types.js.map +1 -1
  536. package/node_modules/matrix-js-sdk/lib/utils/decryptAESSecretStorageItem.js +14 -25
  537. package/node_modules/matrix-js-sdk/lib/utils/decryptAESSecretStorageItem.js.map +1 -1
  538. package/node_modules/matrix-js-sdk/lib/utils/encryptAESSecretStorageItem.js +27 -38
  539. package/node_modules/matrix-js-sdk/lib/utils/encryptAESSecretStorageItem.js.map +1 -1
  540. package/node_modules/matrix-js-sdk/lib/utils/internal/deriveKeys.js +25 -32
  541. package/node_modules/matrix-js-sdk/lib/utils/internal/deriveKeys.js.map +1 -1
  542. package/node_modules/matrix-js-sdk/lib/utils/roomVersion.js +1 -1
  543. package/node_modules/matrix-js-sdk/lib/utils/roomVersion.js.map +1 -1
  544. package/node_modules/matrix-js-sdk/lib/utils.js +83 -135
  545. package/node_modules/matrix-js-sdk/lib/utils.js.map +1 -1
  546. package/node_modules/matrix-js-sdk/lib/version-support.js +3 -3
  547. package/node_modules/matrix-js-sdk/lib/version-support.js.map +1 -1
  548. package/node_modules/matrix-js-sdk/lib/webrtc/audioContext.js +5 -6
  549. package/node_modules/matrix-js-sdk/lib/webrtc/audioContext.js.map +1 -1
  550. package/node_modules/matrix-js-sdk/lib/webrtc/call.js +1123 -1256
  551. package/node_modules/matrix-js-sdk/lib/webrtc/call.js.map +1 -1
  552. package/node_modules/matrix-js-sdk/lib/webrtc/callEventHandler.js +207 -214
  553. package/node_modules/matrix-js-sdk/lib/webrtc/callEventHandler.js.map +1 -1
  554. package/node_modules/matrix-js-sdk/lib/webrtc/callEventTypes.js +2 -2
  555. package/node_modules/matrix-js-sdk/lib/webrtc/callEventTypes.js.map +1 -1
  556. package/node_modules/matrix-js-sdk/lib/webrtc/callFeed.js +33 -20
  557. package/node_modules/matrix-js-sdk/lib/webrtc/callFeed.js.map +1 -1
  558. package/node_modules/matrix-js-sdk/lib/webrtc/groupCall.js +521 -594
  559. package/node_modules/matrix-js-sdk/lib/webrtc/groupCall.js.map +1 -1
  560. package/node_modules/matrix-js-sdk/lib/webrtc/groupCallEventHandler.js +58 -61
  561. package/node_modules/matrix-js-sdk/lib/webrtc/groupCallEventHandler.js.map +1 -1
  562. package/node_modules/matrix-js-sdk/lib/webrtc/mediaHandler.js +203 -233
  563. package/node_modules/matrix-js-sdk/lib/webrtc/mediaHandler.js.map +1 -1
  564. package/node_modules/matrix-js-sdk/lib/webrtc/stats/callFeedStatsReporter.js +16 -20
  565. package/node_modules/matrix-js-sdk/lib/webrtc/stats/callFeedStatsReporter.js.map +1 -1
  566. package/node_modules/matrix-js-sdk/lib/webrtc/stats/callStatsReportGatherer.js +65 -70
  567. package/node_modules/matrix-js-sdk/lib/webrtc/stats/callStatsReportGatherer.js.map +1 -1
  568. package/node_modules/matrix-js-sdk/lib/webrtc/stats/callStatsReportSummary.js +3 -1
  569. package/node_modules/matrix-js-sdk/lib/webrtc/stats/connectionStats.js.map +1 -1
  570. package/node_modules/matrix-js-sdk/lib/webrtc/stats/connectionStatsBuilder.js +2 -2
  571. package/node_modules/matrix-js-sdk/lib/webrtc/stats/connectionStatsBuilder.js.map +1 -1
  572. package/node_modules/matrix-js-sdk/lib/webrtc/stats/connectionStatsReportBuilder.js +20 -24
  573. package/node_modules/matrix-js-sdk/lib/webrtc/stats/connectionStatsReportBuilder.js.map +1 -1
  574. package/node_modules/matrix-js-sdk/lib/webrtc/stats/groupCallStats.js +4 -5
  575. package/node_modules/matrix-js-sdk/lib/webrtc/stats/groupCallStats.js.map +1 -1
  576. package/node_modules/matrix-js-sdk/lib/webrtc/stats/media/mediaSsrcHandler.js +7 -8
  577. package/node_modules/matrix-js-sdk/lib/webrtc/stats/media/mediaSsrcHandler.js.map +1 -1
  578. package/node_modules/matrix-js-sdk/lib/webrtc/stats/media/mediaTrackHandler.js +7 -9
  579. package/node_modules/matrix-js-sdk/lib/webrtc/stats/media/mediaTrackHandler.js.map +1 -1
  580. package/node_modules/matrix-js-sdk/lib/webrtc/stats/media/mediaTrackStats.js.map +1 -1
  581. package/node_modules/matrix-js-sdk/lib/webrtc/stats/media/mediaTrackStatsHandler.js +6 -6
  582. package/node_modules/matrix-js-sdk/lib/webrtc/stats/media/mediaTrackStatsHandler.js.map +1 -1
  583. package/node_modules/matrix-js-sdk/lib/webrtc/stats/statsReport.js +1 -1
  584. package/node_modules/matrix-js-sdk/lib/webrtc/stats/statsReport.js.map +1 -1
  585. package/node_modules/matrix-js-sdk/lib/webrtc/stats/statsReportEmitter.js.map +1 -1
  586. package/node_modules/matrix-js-sdk/lib/webrtc/stats/summaryStatsReportGatherer.js +14 -14
  587. package/node_modules/matrix-js-sdk/lib/webrtc/stats/summaryStatsReportGatherer.js.map +1 -1
  588. package/node_modules/matrix-js-sdk/lib/webrtc/stats/trackStatsBuilder.js +32 -34
  589. package/node_modules/matrix-js-sdk/lib/webrtc/stats/trackStatsBuilder.js.map +1 -1
  590. package/node_modules/matrix-js-sdk/lib/webrtc/stats/transportStats.js +3 -1
  591. package/node_modules/matrix-js-sdk/lib/webrtc/stats/transportStatsBuilder.js +9 -9
  592. package/node_modules/matrix-js-sdk/lib/webrtc/stats/transportStatsBuilder.js.map +1 -1
  593. package/node_modules/matrix-js-sdk/lib/webrtc/stats/valueFormatter.js +1 -1
  594. package/node_modules/matrix-js-sdk/lib/webrtc/stats/valueFormatter.js.map +1 -1
  595. package/node_modules/matrix-js-sdk/package.json +110 -138
  596. package/node_modules/matrix-js-sdk/src/@types/event.ts +9 -0
  597. package/node_modules/matrix-js-sdk/src/@types/global.d.ts +2 -2
  598. package/node_modules/matrix-js-sdk/src/@types/retention.ts +16 -0
  599. package/node_modules/matrix-js-sdk/src/ToDeviceMessageQueue.ts +2 -2
  600. package/node_modules/matrix-js-sdk/src/browser-index.ts +4 -4
  601. package/node_modules/matrix-js-sdk/src/capabilityPoller.ts +102 -0
  602. package/node_modules/matrix-js-sdk/src/client.ts +37 -25
  603. package/node_modules/matrix-js-sdk/src/crypto-api/index.ts +17 -6
  604. package/node_modules/matrix-js-sdk/src/embedded.ts +4 -6
  605. package/node_modules/matrix-js-sdk/src/filter-component.ts +1 -0
  606. package/node_modules/matrix-js-sdk/src/http-api/utils.ts +5 -10
  607. package/node_modules/matrix-js-sdk/src/interactive-auth.ts +11 -5
  608. package/node_modules/matrix-js-sdk/src/matrix.ts +1 -0
  609. package/node_modules/matrix-js-sdk/src/matrixrtc/LivekitTransport.ts +1 -1
  610. package/node_modules/matrix-js-sdk/src/matrixrtc/MatrixRTCSession.ts +5 -4
  611. package/node_modules/matrix-js-sdk/src/matrixrtc/MembershipManager.ts +2 -0
  612. package/node_modules/matrix-js-sdk/src/matrixrtc/MembershipManagerActionScheduler.ts +4 -1
  613. package/node_modules/matrix-js-sdk/src/models/MSC3089Branch.ts +1 -1
  614. package/node_modules/matrix-js-sdk/src/models/room-retention.ts +230 -0
  615. package/node_modules/matrix-js-sdk/src/models/room-sticky-events.ts +1 -0
  616. package/node_modules/matrix-js-sdk/src/models/room.ts +26 -12
  617. package/node_modules/matrix-js-sdk/src/receipt-accumulator.ts +2 -0
  618. package/node_modules/matrix-js-sdk/src/rendezvous/index.ts +1 -1
  619. package/node_modules/matrix-js-sdk/src/rendezvous/transports/MSC4108RendezvousSession.ts +2 -2
  620. package/node_modules/matrix-js-sdk/src/retentionPolicy.ts +65 -0
  621. package/node_modules/matrix-js-sdk/src/rust-crypto/PerSessionKeyBackupDownloader.ts +1 -1
  622. package/node_modules/matrix-js-sdk/src/rust-crypto/backup.ts +15 -4
  623. package/node_modules/matrix-js-sdk/src/rust-crypto/index.ts +6 -6
  624. package/node_modules/matrix-js-sdk/src/rust-crypto/rust-crypto.ts +31 -7
  625. package/node_modules/matrix-js-sdk/src/rust-crypto/verification.ts +1 -1
  626. package/node_modules/matrix-js-sdk/src/serverCapabilities.ts +8 -67
  627. package/node_modules/matrix-js-sdk/src/sliding-sync-sdk.ts +5 -7
  628. package/node_modules/matrix-js-sdk/src/store/index.ts +8 -0
  629. package/node_modules/matrix-js-sdk/src/store/indexeddb-local-backend.ts +12 -2
  630. package/node_modules/matrix-js-sdk/src/store/indexeddb-remote-backend.ts +24 -5
  631. package/node_modules/matrix-js-sdk/src/store/indexeddb.ts +20 -8
  632. package/node_modules/matrix-js-sdk/src/store/memory.ts +4 -0
  633. package/node_modules/matrix-js-sdk/src/store/stub.ts +3 -0
  634. package/node_modules/matrix-js-sdk/src/sync-accumulator.ts +9 -0
  635. package/node_modules/matrix-js-sdk/src/sync.ts +11 -9
  636. package/node_modules/media-typer/README.md +19 -33
  637. package/node_modules/media-typer/dist/index.d.ts +29 -0
  638. package/node_modules/media-typer/dist/index.js +64 -0
  639. package/node_modules/media-typer/dist/index.js.map +1 -0
  640. package/node_modules/media-typer/package.json +37 -22
  641. package/node_modules/music-metadata/lib/id3v1/ID3v1Parser.js +2 -2
  642. package/node_modules/music-metadata/lib/mp4/AtomToken.js +65 -13
  643. package/node_modules/music-metadata/lib/wav/WaveChunk.d.ts +10 -0
  644. package/node_modules/music-metadata/lib/wav/WaveChunk.js +13 -3
  645. package/node_modules/music-metadata/lib/wav/WaveParser.d.ts +1 -0
  646. package/node_modules/music-metadata/lib/wav/WaveParser.js +6 -5
  647. package/node_modules/music-metadata/package.json +5 -5
  648. package/node_modules/typebox/build/compile/validator.d.mts +2 -7
  649. package/node_modules/typebox/build/compile/validator.mjs +6 -36
  650. package/node_modules/typebox/build/error/errors.d.mts +1 -7
  651. package/node_modules/typebox/build/format/_idna.mjs +36 -6
  652. package/node_modules/typebox/build/format/_puny.mjs +4 -1
  653. package/node_modules/typebox/build/format/uuid.d.mts +2 -2
  654. package/node_modules/typebox/build/format/uuid.mjs +3 -3
  655. package/node_modules/typebox/build/guard/emit.d.mts +0 -4
  656. package/node_modules/typebox/build/guard/emit.mjs +0 -8
  657. package/node_modules/typebox/build/guard/guard.d.mts +4 -8
  658. package/node_modules/typebox/build/guard/guard.mjs +5 -13
  659. package/node_modules/typebox/build/schema/engine/boolean.d.mts +3 -3
  660. package/node_modules/typebox/build/schema/engine/boolean.mjs +4 -4
  661. package/node_modules/typebox/build/schema/engine/index.d.mts +0 -1
  662. package/node_modules/typebox/build/schema/engine/index.mjs +0 -1
  663. package/node_modules/typebox/build/schema/engine/schema.mjs +5 -10
  664. package/node_modules/typebox/build/schema/engine/type.mjs +14 -18
  665. package/node_modules/typebox/build/schema/types/dependencies.mjs +1 -1
  666. package/node_modules/typebox/build/schema/types/index.d.mts +0 -1
  667. package/node_modules/typebox/build/schema/types/index.mjs +0 -1
  668. package/node_modules/typebox/build/schema/types/schema.d.mts +1 -1
  669. package/node_modules/typebox/build/schema/types/schema.mjs +2 -2
  670. package/node_modules/typebox/build/system/locale/ar_001.mjs +0 -1
  671. package/node_modules/typebox/build/system/locale/bn_BD.mjs +0 -1
  672. package/node_modules/typebox/build/system/locale/cs_CZ.mjs +0 -1
  673. package/node_modules/typebox/build/system/locale/de_DE.mjs +0 -1
  674. package/node_modules/typebox/build/system/locale/el_GR.mjs +0 -1
  675. package/node_modules/typebox/build/system/locale/en_US.mjs +0 -1
  676. package/node_modules/typebox/build/system/locale/es_419.mjs +0 -1
  677. package/node_modules/typebox/build/system/locale/es_AR.mjs +0 -1
  678. package/node_modules/typebox/build/system/locale/es_ES.mjs +0 -1
  679. package/node_modules/typebox/build/system/locale/es_MX.mjs +0 -1
  680. package/node_modules/typebox/build/system/locale/fa_IR.mjs +0 -1
  681. package/node_modules/typebox/build/system/locale/fil_PH.mjs +0 -1
  682. package/node_modules/typebox/build/system/locale/fr_CA.mjs +0 -1
  683. package/node_modules/typebox/build/system/locale/fr_FR.mjs +0 -1
  684. package/node_modules/typebox/build/system/locale/ha_NG.mjs +0 -1
  685. package/node_modules/typebox/build/system/locale/hi_IN.mjs +0 -1
  686. package/node_modules/typebox/build/system/locale/hu_HU.mjs +0 -1
  687. package/node_modules/typebox/build/system/locale/id_ID.mjs +0 -1
  688. package/node_modules/typebox/build/system/locale/it_IT.mjs +0 -1
  689. package/node_modules/typebox/build/system/locale/ja_JP.mjs +0 -1
  690. package/node_modules/typebox/build/system/locale/ko_KR.mjs +0 -1
  691. package/node_modules/typebox/build/system/locale/ms_MY.mjs +0 -1
  692. package/node_modules/typebox/build/system/locale/nl_NL.mjs +0 -1
  693. package/node_modules/typebox/build/system/locale/pl_PL.mjs +0 -1
  694. package/node_modules/typebox/build/system/locale/pt_BR.mjs +0 -1
  695. package/node_modules/typebox/build/system/locale/pt_PT.mjs +0 -1
  696. package/node_modules/typebox/build/system/locale/ro_RO.mjs +0 -1
  697. package/node_modules/typebox/build/system/locale/ru_RU.mjs +0 -1
  698. package/node_modules/typebox/build/system/locale/sv_SE.mjs +0 -1
  699. package/node_modules/typebox/build/system/locale/sw_TZ.mjs +0 -1
  700. package/node_modules/typebox/build/system/locale/th_TH.mjs +0 -1
  701. package/node_modules/typebox/build/system/locale/tr_TR.mjs +0 -1
  702. package/node_modules/typebox/build/system/locale/uk_UA.mjs +0 -1
  703. package/node_modules/typebox/build/system/locale/ur_PK.mjs +0 -1
  704. package/node_modules/typebox/build/system/locale/vi_VN.mjs +0 -1
  705. package/node_modules/typebox/build/system/locale/yo_NG.mjs +0 -1
  706. package/node_modules/typebox/build/system/locale/zh_Hans.mjs +0 -1
  707. package/node_modules/typebox/build/system/locale/zh_Hant.mjs +0 -1
  708. package/node_modules/typebox/build/system/memory/clone.d.mts +2 -3
  709. package/node_modules/typebox/build/system/memory/clone.mjs +73 -26
  710. package/node_modules/typebox/build/system/settings/settings.d.mts +15 -0
  711. package/node_modules/typebox/build/system/settings/settings.mjs +3 -1
  712. package/node_modules/typebox/build/type/action/_add_immutable.d.mts +11 -0
  713. package/node_modules/typebox/build/type/action/_add_immutable.mjs +11 -0
  714. package/node_modules/typebox/build/type/action/_add_optional.d.mts +11 -0
  715. package/node_modules/typebox/build/type/action/_add_optional.mjs +11 -0
  716. package/node_modules/typebox/build/type/action/_add_readonly.d.mts +11 -0
  717. package/node_modules/typebox/build/type/action/_add_readonly.mjs +11 -0
  718. package/node_modules/typebox/build/type/action/_remove_immutable.d.mts +11 -0
  719. package/node_modules/typebox/build/type/action/_remove_immutable.mjs +11 -0
  720. package/node_modules/typebox/build/type/action/_remove_optional.d.mts +11 -0
  721. package/node_modules/typebox/build/type/action/_remove_optional.mjs +11 -0
  722. package/node_modules/typebox/build/type/action/_remove_readonly.d.mts +11 -0
  723. package/node_modules/typebox/build/type/action/_remove_readonly.mjs +11 -0
  724. package/node_modules/typebox/build/type/action/conditional.d.mts +2 -3
  725. package/node_modules/typebox/build/type/action/conditional.mjs +2 -1
  726. package/node_modules/typebox/build/type/action/index.d.mts +7 -4
  727. package/node_modules/typebox/build/type/action/index.mjs +7 -4
  728. package/node_modules/typebox/build/type/action/mapped.d.mts +2 -3
  729. package/node_modules/typebox/build/type/action/mapped.mjs +2 -1
  730. package/node_modules/typebox/build/type/action/module.d.mts +8 -7
  731. package/node_modules/typebox/build/type/action/module.mjs +7 -6
  732. package/node_modules/typebox/build/type/action/readonly_object.d.mts +0 -5
  733. package/node_modules/typebox/build/type/action/readonly_object.mjs +0 -5
  734. package/node_modules/typebox/build/type/action/with.d.mts +11 -0
  735. package/node_modules/typebox/build/type/action/with.mjs +11 -0
  736. package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +1 -1
  737. package/node_modules/typebox/build/type/engine/call/instantiate.d.mts +1 -3
  738. package/node_modules/typebox/build/type/engine/call/instantiate.mjs +3 -2
  739. package/node_modules/typebox/build/type/engine/call/resolve_arguments.mjs +2 -2
  740. package/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.d.mts +3 -4
  741. package/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.mjs +2 -1
  742. package/node_modules/typebox/build/type/engine/cyclic/candidates.d.mts +2 -3
  743. package/node_modules/typebox/build/type/engine/cyclic/candidates.mjs +3 -6
  744. package/node_modules/typebox/build/type/engine/cyclic/check.d.mts +6 -9
  745. package/node_modules/typebox/build/type/engine/cyclic/check.mjs +10 -16
  746. package/node_modules/typebox/build/type/engine/cyclic/dependencies.d.mts +1 -4
  747. package/node_modules/typebox/build/type/engine/cyclic/dependencies.mjs +9 -15
  748. package/node_modules/typebox/build/type/engine/cyclic/extends.d.mts +1 -4
  749. package/node_modules/typebox/build/type/engine/cyclic/extends.mjs +8 -14
  750. package/node_modules/typebox/build/type/engine/cyclic/instantiate.d.mts +2 -5
  751. package/node_modules/typebox/build/type/engine/cyclic/instantiate.mjs +3 -2
  752. package/node_modules/typebox/build/type/engine/enum/index.d.mts +0 -1
  753. package/node_modules/typebox/build/type/engine/enum/index.mjs +0 -1
  754. package/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +1 -2
  755. package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +2 -6
  756. package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +10 -6
  757. package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +10 -6
  758. package/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +2 -1
  759. package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +3 -3
  760. package/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +17 -5
  761. package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +34 -8
  762. package/node_modules/typebox/build/type/engine/exclude/operation.d.mts +5 -6
  763. package/node_modules/typebox/build/type/engine/exclude/operation.mjs +11 -12
  764. package/node_modules/typebox/build/type/engine/extract/operation.d.mts +5 -6
  765. package/node_modules/typebox/build/type/engine/extract/operation.mjs +11 -12
  766. package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +10 -0
  767. package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +14 -0
  768. package/node_modules/typebox/build/type/engine/immutable/instantiate_remove.d.mts +10 -0
  769. package/node_modules/typebox/build/type/engine/immutable/instantiate_remove.mjs +14 -0
  770. package/node_modules/typebox/build/type/engine/index.d.mts +2 -2
  771. package/node_modules/typebox/build/type/engine/index.mjs +2 -2
  772. package/node_modules/typebox/build/type/engine/indexable/from_dependent.d.mts +5 -0
  773. package/node_modules/typebox/build/type/engine/indexable/from_dependent.mjs +8 -0
  774. package/node_modules/typebox/build/type/engine/indexable/from_enum.d.mts +3 -3
  775. package/node_modules/typebox/build/type/engine/indexable/from_enum.mjs +4 -4
  776. package/node_modules/typebox/build/type/engine/indexable/from_template_literal.d.mts +2 -2
  777. package/node_modules/typebox/build/type/engine/indexable/from_template_literal.mjs +3 -3
  778. package/node_modules/typebox/build/type/engine/indexable/from_type.d.mts +3 -1
  779. package/node_modules/typebox/build/type/engine/indexable/from_type.mjs +9 -6
  780. package/node_modules/typebox/build/type/engine/indexed/instantiate.d.mts +2 -1
  781. package/node_modules/typebox/build/type/engine/indexed/instantiate.mjs +5 -2
  782. package/node_modules/typebox/build/type/engine/instantiate.d.mts +44 -31
  783. package/node_modules/typebox/build/type/engine/instantiate.mjs +82 -83
  784. package/node_modules/typebox/build/type/engine/interface/instantiate.d.mts +3 -6
  785. package/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.d.mts +2 -2
  786. package/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.mjs +3 -3
  787. package/node_modules/typebox/build/type/engine/keyof/instantiate.d.mts +2 -1
  788. package/node_modules/typebox/build/type/engine/keyof/instantiate.mjs +5 -1
  789. package/node_modules/typebox/build/type/engine/mapped/mapped_operation.d.mts +4 -4
  790. package/node_modules/typebox/build/type/engine/mapped/mapped_operation.mjs +3 -3
  791. package/node_modules/typebox/build/type/engine/mapped/mapped_variants.d.mts +5 -4
  792. package/node_modules/typebox/build/type/engine/mapped/mapped_variants.mjs +10 -5
  793. package/node_modules/typebox/build/type/engine/module/instantiate.d.mts +7 -9
  794. package/node_modules/typebox/build/type/engine/module/instantiate.mjs +17 -15
  795. package/node_modules/typebox/build/type/engine/object/from_dependent.d.mts +5 -0
  796. package/node_modules/typebox/build/type/engine/object/from_dependent.mjs +8 -0
  797. package/node_modules/typebox/build/type/engine/object/from_type.d.mts +3 -1
  798. package/node_modules/typebox/build/type/engine/object/from_type.mjs +8 -5
  799. package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
  800. package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +10 -0
  801. package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +14 -0
  802. package/node_modules/typebox/build/type/engine/optional/instantiate_remove.d.mts +10 -0
  803. package/node_modules/typebox/build/type/engine/optional/instantiate_remove.mjs +14 -0
  804. package/node_modules/typebox/build/type/engine/parameters/instantiate.d.mts +3 -4
  805. package/node_modules/typebox/build/type/engine/parameters/instantiate.mjs +2 -1
  806. package/node_modules/typebox/build/type/engine/partial/from_dependent.d.mts +5 -0
  807. package/node_modules/typebox/build/type/engine/partial/from_dependent.mjs +8 -0
  808. package/node_modules/typebox/build/type/engine/partial/from_intersect.d.mts +1 -1
  809. package/node_modules/typebox/build/type/engine/partial/from_intersect.mjs +3 -2
  810. package/node_modules/typebox/build/type/engine/partial/from_object.d.mts +2 -2
  811. package/node_modules/typebox/build/type/engine/partial/from_object.mjs +2 -2
  812. package/node_modules/typebox/build/type/engine/partial/from_type.d.mts +3 -1
  813. package/node_modules/typebox/build/type/engine/partial/from_type.mjs +7 -4
  814. package/node_modules/typebox/build/type/engine/priority/index.d.mts +1 -0
  815. package/node_modules/typebox/build/type/engine/priority/index.mjs +1 -0
  816. package/node_modules/typebox/build/type/engine/priority/priority.d.mts +20 -0
  817. package/node_modules/typebox/build/type/engine/priority/priority.mjs +28 -0
  818. package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +10 -0
  819. package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +14 -0
  820. package/node_modules/typebox/build/type/engine/readonly/instantiate_remove.d.mts +10 -0
  821. package/node_modules/typebox/build/type/engine/readonly/instantiate_remove.mjs +14 -0
  822. package/node_modules/typebox/build/type/engine/readonly_object/from_array.d.mts +2 -2
  823. package/node_modules/typebox/build/type/engine/readonly_object/from_array.mjs +2 -2
  824. package/node_modules/typebox/build/type/engine/readonly_object/from_dependent.d.mts +5 -0
  825. package/node_modules/typebox/build/type/engine/readonly_object/from_dependent.mjs +8 -0
  826. package/node_modules/typebox/build/type/engine/readonly_object/from_intersect.d.mts +1 -1
  827. package/node_modules/typebox/build/type/engine/readonly_object/from_intersect.mjs +3 -2
  828. package/node_modules/typebox/build/type/engine/readonly_object/from_object.d.mts +2 -2
  829. package/node_modules/typebox/build/type/engine/readonly_object/from_object.mjs +2 -2
  830. package/node_modules/typebox/build/type/engine/readonly_object/from_tuple.d.mts +2 -2
  831. package/node_modules/typebox/build/type/engine/readonly_object/from_tuple.mjs +2 -2
  832. package/node_modules/typebox/build/type/engine/readonly_object/from_type.d.mts +3 -1
  833. package/node_modules/typebox/build/type/engine/readonly_object/from_type.mjs +8 -5
  834. package/node_modules/typebox/build/type/engine/record/from_key_enum.d.mts +2 -2
  835. package/node_modules/typebox/build/type/engine/record/from_key_enum.mjs +2 -2
  836. package/node_modules/typebox/build/type/engine/record/from_key_template_literal.d.mts +2 -2
  837. package/node_modules/typebox/build/type/engine/record/from_key_template_literal.mjs +2 -2
  838. package/node_modules/typebox/build/type/engine/ref/instantiate.d.mts +3 -3
  839. package/node_modules/typebox/build/type/engine/ref/instantiate.mjs +6 -6
  840. package/node_modules/typebox/build/type/engine/required/from_dependent.d.mts +5 -0
  841. package/node_modules/typebox/build/type/engine/required/from_dependent.mjs +8 -0
  842. package/node_modules/typebox/build/type/engine/required/from_intersect.d.mts +1 -1
  843. package/node_modules/typebox/build/type/engine/required/from_intersect.mjs +3 -2
  844. package/node_modules/typebox/build/type/engine/required/from_object.d.mts +2 -2
  845. package/node_modules/typebox/build/type/engine/required/from_object.mjs +2 -2
  846. package/node_modules/typebox/build/type/engine/required/from_type.d.mts +3 -1
  847. package/node_modules/typebox/build/type/engine/required/from_type.mjs +7 -4
  848. package/node_modules/typebox/build/type/engine/template_literal/decode.mjs +3 -3
  849. package/node_modules/typebox/build/type/engine/template_literal/encode.d.mts +2 -2
  850. package/node_modules/typebox/build/type/engine/template_literal/encode.mjs +6 -6
  851. package/node_modules/typebox/build/type/engine/template_literal/is_finite.mjs +1 -1
  852. package/node_modules/typebox/build/type/engine/template_literal/is_pattern.mjs +1 -0
  853. package/node_modules/typebox/build/type/engine/this/expand_this.d.mts +1 -4
  854. package/node_modules/typebox/build/type/engine/this/expand_this.mjs +7 -13
  855. package/node_modules/typebox/build/type/engine/with/instantiate.d.mts +8 -0
  856. package/node_modules/typebox/build/type/engine/{options → with}/instantiate.mjs +5 -5
  857. package/node_modules/typebox/build/type/extends/dependent.d.mts +6 -0
  858. package/node_modules/typebox/build/type/extends/dependent.mjs +6 -0
  859. package/node_modules/typebox/build/type/extends/enum.d.mts +4 -4
  860. package/node_modules/typebox/build/type/extends/enum.mjs +3 -2
  861. package/node_modules/typebox/build/type/extends/extends_left.d.mts +5 -7
  862. package/node_modules/typebox/build/type/extends/extends_left.mjs +24 -27
  863. package/node_modules/typebox/build/type/extends/extends_right.d.mts +7 -5
  864. package/node_modules/typebox/build/type/extends/extends_right.mjs +20 -15
  865. package/node_modules/typebox/build/type/extends/inference.mjs +1 -1
  866. package/node_modules/typebox/build/type/extends/object.d.mts +8 -1
  867. package/node_modules/typebox/build/type/extends/object.mjs +25 -3
  868. package/node_modules/typebox/build/type/extends/parameters.mjs +2 -2
  869. package/node_modules/typebox/build/type/extends/record.d.mts +13 -0
  870. package/node_modules/typebox/build/type/extends/record.mjs +23 -0
  871. package/node_modules/typebox/build/type/extends/template_literal.d.mts +3 -3
  872. package/node_modules/typebox/build/type/extends/template_literal.mjs +3 -3
  873. package/node_modules/typebox/build/type/extends/tuple.d.mts +3 -6
  874. package/node_modules/typebox/build/type/extends/tuple.mjs +6 -5
  875. package/node_modules/typebox/build/type/extends/union.mjs +2 -2
  876. package/node_modules/typebox/build/type/script/mapping.d.mts +84 -99
  877. package/node_modules/typebox/build/type/script/mapping.mjs +81 -85
  878. package/node_modules/typebox/build/type/script/parser.d.mts +40 -40
  879. package/node_modules/typebox/build/type/script/parser.mjs +22 -22
  880. package/node_modules/typebox/build/type/script/script.d.mts +3 -4
  881. package/node_modules/typebox/build/type/script/script.mjs +3 -2
  882. package/node_modules/typebox/build/type/script/token/internal/guard.d.mts +1 -1
  883. package/node_modules/typebox/build/type/script/token/internal/guard.mjs +1 -1
  884. package/node_modules/typebox/build/type/script/token/internal/take.mjs +1 -1
  885. package/node_modules/typebox/build/type/script/token/until.mjs +2 -2
  886. package/node_modules/typebox/build/type/types/_codec.d.mts +12 -12
  887. package/node_modules/typebox/build/type/types/_codec.mjs +0 -1
  888. package/node_modules/typebox/build/type/types/_immutable.d.mts +2 -9
  889. package/node_modules/typebox/build/type/types/_immutable.mjs +2 -10
  890. package/node_modules/typebox/build/type/types/_optional.d.mts +2 -9
  891. package/node_modules/typebox/build/type/types/_optional.mjs +2 -11
  892. package/node_modules/typebox/build/type/types/_readonly.d.mts +2 -9
  893. package/node_modules/typebox/build/type/types/_readonly.mjs +2 -10
  894. package/node_modules/typebox/build/type/types/_refine.d.mts +8 -10
  895. package/node_modules/typebox/build/type/types/_refine.mjs +1 -2
  896. package/node_modules/typebox/build/type/types/call.d.mts +3 -3
  897. package/node_modules/typebox/build/type/types/call.mjs +3 -2
  898. package/node_modules/typebox/build/type/types/deferred.d.mts +1 -0
  899. package/node_modules/typebox/build/type/types/deferred.mjs +1 -1
  900. package/node_modules/typebox/build/type/types/dependent.d.mts +17 -0
  901. package/node_modules/typebox/build/type/types/dependent.mjs +24 -0
  902. package/node_modules/typebox/build/type/types/enum.d.mts +3 -1
  903. package/node_modules/typebox/build/type/types/enum.mjs +5 -0
  904. package/node_modules/typebox/build/type/types/index.d.mts +1 -4
  905. package/node_modules/typebox/build/type/types/index.mjs +1 -4
  906. package/node_modules/typebox/build/type/types/number.d.mts +1 -1
  907. package/node_modules/typebox/build/type/types/number.mjs +1 -1
  908. package/node_modules/typebox/build/type/types/record.d.mts +13 -7
  909. package/node_modules/typebox/build/type/types/record.mjs +15 -9
  910. package/node_modules/typebox/build/type/types/static.d.mts +2 -5
  911. package/node_modules/typebox/build/typebox.d.mts +4 -8
  912. package/node_modules/typebox/build/typebox.mjs +4 -8
  913. package/node_modules/typebox/build/value/clean/clean.mjs +4 -2
  914. package/node_modules/typebox/build/value/clean/from_intersect.mjs +2 -2
  915. package/node_modules/typebox/build/value/clean/from_type.mjs +8 -10
  916. package/node_modules/typebox/build/value/clean/from_union.d.mts +1 -1
  917. package/node_modules/typebox/build/value/clean/from_union.mjs +1 -2
  918. package/node_modules/typebox/build/value/clone/clone.mjs +2 -73
  919. package/node_modules/typebox/build/value/codec/decode.mjs +4 -2
  920. package/node_modules/typebox/build/value/codec/encode.mjs +4 -2
  921. package/node_modules/typebox/build/value/codec/from_array.mjs +1 -4
  922. package/node_modules/typebox/build/value/codec/from_object.mjs +1 -4
  923. package/node_modules/typebox/build/value/codec/from_record.mjs +2 -7
  924. package/node_modules/typebox/build/value/codec/from_tuple.mjs +1 -4
  925. package/node_modules/typebox/build/value/codec/from_union.mjs +2 -3
  926. package/node_modules/typebox/build/value/convert/from_enum.mjs +3 -4
  927. package/node_modules/typebox/build/value/convert/from_template_literal.d.mts +1 -1
  928. package/node_modules/typebox/build/value/convert/from_template_literal.mjs +2 -3
  929. package/node_modules/typebox/build/value/convert/from_type.mjs +19 -21
  930. package/node_modules/typebox/build/value/create/from_enum.mjs +2 -2
  931. package/node_modules/typebox/build/value/create/from_type.mjs +23 -31
  932. package/node_modules/typebox/build/value/default/from_object.mjs +1 -1
  933. package/node_modules/typebox/build/value/default/from_type.mjs +8 -10
  934. package/node_modules/typebox/build/value/index.d.mts +0 -1
  935. package/node_modules/typebox/build/value/index.mjs +0 -1
  936. package/node_modules/typebox/build/value/repair/from_enum.mjs +2 -3
  937. package/node_modules/typebox/build/value/repair/from_type.mjs +24 -22
  938. package/node_modules/typebox/build/value/shared/union_priority_sort.d.mts +6 -2
  939. package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +62 -26
  940. package/node_modules/typebox/build/value/value.d.mts +0 -1
  941. package/node_modules/typebox/build/value/value.mjs +0 -1
  942. package/node_modules/typebox/package.json +25 -25
  943. package/node_modules/typebox/readme.md +97 -80
  944. package/npm-shrinkwrap.json +59 -54
  945. package/package.json +10 -10
  946. package/dist/probe.runtime-BED7DXis.js +0 -3
  947. package/node_modules/@babel/runtime/helpers/AwaitValue.js +0 -4
  948. package/node_modules/@babel/runtime/helpers/applyDecs.js +0 -236
  949. package/node_modules/@babel/runtime/helpers/applyDecs2203.js +0 -184
  950. package/node_modules/@babel/runtime/helpers/applyDecs2203R.js +0 -191
  951. package/node_modules/@babel/runtime/helpers/applyDecs2301.js +0 -222
  952. package/node_modules/@babel/runtime/helpers/applyDecs2305.js +0 -133
  953. package/node_modules/@babel/runtime/helpers/classApplyDescriptorDestructureSet.js +0 -10
  954. package/node_modules/@babel/runtime/helpers/classApplyDescriptorGet.js +0 -4
  955. package/node_modules/@babel/runtime/helpers/classApplyDescriptorSet.js +0 -7
  956. package/node_modules/@babel/runtime/helpers/classCheckPrivateStaticAccess.js +0 -5
  957. package/node_modules/@babel/runtime/helpers/classCheckPrivateStaticFieldDescriptor.js +0 -4
  958. package/node_modules/@babel/runtime/helpers/classExtractFieldDescriptor.js +0 -5
  959. package/node_modules/@babel/runtime/helpers/classPrivateFieldDestructureSet.js +0 -7
  960. package/node_modules/@babel/runtime/helpers/classPrivateFieldGet.js +0 -7
  961. package/node_modules/@babel/runtime/helpers/classPrivateFieldSet.js +0 -7
  962. package/node_modules/@babel/runtime/helpers/classPrivateMethodGet.js +0 -5
  963. package/node_modules/@babel/runtime/helpers/classPrivateMethodSet.js +0 -4
  964. package/node_modules/@babel/runtime/helpers/classStaticPrivateFieldDestructureSet.js +0 -7
  965. package/node_modules/@babel/runtime/helpers/classStaticPrivateFieldSpecGet.js +0 -7
  966. package/node_modules/@babel/runtime/helpers/classStaticPrivateFieldSpecSet.js +0 -7
  967. package/node_modules/@babel/runtime/helpers/classStaticPrivateMethodSet.js +0 -4
  968. package/node_modules/@babel/runtime/helpers/decorate.js +0 -250
  969. package/node_modules/@babel/runtime/helpers/defineEnumerableProperties.js +0 -12
  970. package/node_modules/@babel/runtime/helpers/dispose.js +0 -28
  971. package/node_modules/@babel/runtime/helpers/esm/AwaitValue.js +0 -4
  972. package/node_modules/@babel/runtime/helpers/esm/applyDecs.js +0 -236
  973. package/node_modules/@babel/runtime/helpers/esm/applyDecs2203.js +0 -184
  974. package/node_modules/@babel/runtime/helpers/esm/applyDecs2203R.js +0 -191
  975. package/node_modules/@babel/runtime/helpers/esm/applyDecs2301.js +0 -222
  976. package/node_modules/@babel/runtime/helpers/esm/applyDecs2305.js +0 -133
  977. package/node_modules/@babel/runtime/helpers/esm/classApplyDescriptorDestructureSet.js +0 -10
  978. package/node_modules/@babel/runtime/helpers/esm/classApplyDescriptorGet.js +0 -4
  979. package/node_modules/@babel/runtime/helpers/esm/classApplyDescriptorSet.js +0 -7
  980. package/node_modules/@babel/runtime/helpers/esm/classCheckPrivateStaticAccess.js +0 -5
  981. package/node_modules/@babel/runtime/helpers/esm/classCheckPrivateStaticFieldDescriptor.js +0 -4
  982. package/node_modules/@babel/runtime/helpers/esm/classExtractFieldDescriptor.js +0 -5
  983. package/node_modules/@babel/runtime/helpers/esm/classPrivateFieldDestructureSet.js +0 -7
  984. package/node_modules/@babel/runtime/helpers/esm/classPrivateFieldGet.js +0 -7
  985. package/node_modules/@babel/runtime/helpers/esm/classPrivateFieldSet.js +0 -7
  986. package/node_modules/@babel/runtime/helpers/esm/classPrivateMethodGet.js +0 -5
  987. package/node_modules/@babel/runtime/helpers/esm/classPrivateMethodSet.js +0 -4
  988. package/node_modules/@babel/runtime/helpers/esm/classStaticPrivateFieldDestructureSet.js +0 -7
  989. package/node_modules/@babel/runtime/helpers/esm/classStaticPrivateFieldSpecGet.js +0 -7
  990. package/node_modules/@babel/runtime/helpers/esm/classStaticPrivateFieldSpecSet.js +0 -7
  991. package/node_modules/@babel/runtime/helpers/esm/classStaticPrivateMethodSet.js +0 -4
  992. package/node_modules/@babel/runtime/helpers/esm/decorate.js +0 -250
  993. package/node_modules/@babel/runtime/helpers/esm/defineEnumerableProperties.js +0 -12
  994. package/node_modules/@babel/runtime/helpers/esm/dispose.js +0 -28
  995. package/node_modules/@babel/runtime/helpers/esm/objectSpread.js +0 -14
  996. package/node_modules/@babel/runtime/helpers/esm/regeneratorRuntime.js +0 -77
  997. package/node_modules/@babel/runtime/helpers/esm/using.js +0 -12
  998. package/node_modules/@babel/runtime/helpers/objectSpread.js +0 -14
  999. package/node_modules/@babel/runtime/helpers/regeneratorRuntime.js +0 -77
  1000. package/node_modules/@babel/runtime/helpers/using.js +0 -12
  1001. package/node_modules/@babel/runtime/regenerator/index.js +0 -15
  1002. package/node_modules/content-type/HISTORY.md +0 -29
  1003. package/node_modules/content-type/index.js +0 -225
  1004. package/node_modules/media-typer/HISTORY.md +0 -50
  1005. package/node_modules/media-typer/index.js +0 -143
  1006. package/node_modules/typebox/build/schema/engine/_guard.d.mts +0 -6
  1007. package/node_modules/typebox/build/schema/engine/_guard.mjs +0 -26
  1008. package/node_modules/typebox/build/schema/types/_guard.d.mts +0 -10
  1009. package/node_modules/typebox/build/schema/types/_guard.mjs +0 -16
  1010. package/node_modules/typebox/build/type/action/_optional.d.mts +0 -19
  1011. package/node_modules/typebox/build/type/action/_optional.mjs +0 -40
  1012. package/node_modules/typebox/build/type/action/_readonly.d.mts +0 -19
  1013. package/node_modules/typebox/build/type/action/_readonly.mjs +0 -40
  1014. package/node_modules/typebox/build/type/action/awaited.d.mts +0 -15
  1015. package/node_modules/typebox/build/type/action/awaited.mjs +0 -15
  1016. package/node_modules/typebox/build/type/action/options.d.mts +0 -11
  1017. package/node_modules/typebox/build/type/action/options.mjs +0 -11
  1018. package/node_modules/typebox/build/type/engine/awaited/instantiate.d.mts +0 -11
  1019. package/node_modules/typebox/build/type/engine/awaited/instantiate.mjs +0 -20
  1020. package/node_modules/typebox/build/type/engine/enum/enum_to_union.d.mts +0 -14
  1021. package/node_modules/typebox/build/type/engine/enum/enum_to_union.mjs +0 -24
  1022. package/node_modules/typebox/build/type/engine/options/index.d.mts +0 -1
  1023. package/node_modules/typebox/build/type/engine/options/index.mjs +0 -1
  1024. package/node_modules/typebox/build/type/engine/options/instantiate.d.mts +0 -8
  1025. package/node_modules/typebox/build/type/extends/async_iterator.d.mts +0 -7
  1026. package/node_modules/typebox/build/type/extends/async_iterator.mjs +0 -9
  1027. package/node_modules/typebox/build/type/extends/iterator.d.mts +0 -7
  1028. package/node_modules/typebox/build/type/extends/iterator.mjs +0 -9
  1029. package/node_modules/typebox/build/type/extends/promise.d.mts +0 -7
  1030. package/node_modules/typebox/build/type/extends/promise.mjs +0 -9
  1031. package/node_modules/typebox/build/type/types/async_iterator.d.mts +0 -20
  1032. package/node_modules/typebox/build/type/types/async_iterator.mjs +0 -28
  1033. package/node_modules/typebox/build/type/types/base.d.mts +0 -50
  1034. package/node_modules/typebox/build/type/types/base.mjs +0 -84
  1035. package/node_modules/typebox/build/type/types/iterator.d.mts +0 -20
  1036. package/node_modules/typebox/build/type/types/iterator.mjs +0 -28
  1037. package/node_modules/typebox/build/type/types/promise.d.mts +0 -21
  1038. package/node_modules/typebox/build/type/types/promise.mjs +0 -29
  1039. package/node_modules/typebox/build/value/clean/from_base.d.mts +0 -2
  1040. package/node_modules/typebox/build/value/clean/from_base.mjs +0 -4
  1041. package/node_modules/typebox/build/value/convert/from_base.d.mts +0 -2
  1042. package/node_modules/typebox/build/value/convert/from_base.mjs +0 -4
  1043. package/node_modules/typebox/build/value/create/from_async_iterator.d.mts +0 -2
  1044. package/node_modules/typebox/build/value/create/from_async_iterator.mjs +0 -5
  1045. package/node_modules/typebox/build/value/create/from_base.d.mts +0 -2
  1046. package/node_modules/typebox/build/value/create/from_base.mjs +0 -4
  1047. package/node_modules/typebox/build/value/create/from_iterator.d.mts +0 -2
  1048. package/node_modules/typebox/build/value/create/from_iterator.mjs +0 -5
  1049. package/node_modules/typebox/build/value/create/from_promise.d.mts +0 -2
  1050. package/node_modules/typebox/build/value/create/from_promise.mjs +0 -5
  1051. package/node_modules/typebox/build/value/default/from_base.d.mts +0 -2
  1052. package/node_modules/typebox/build/value/default/from_base.mjs +0 -5
  1053. package/node_modules/typebox/build/value/mutate/error.d.mts +0 -3
  1054. package/node_modules/typebox/build/value/mutate/error.mjs +0 -6
  1055. package/node_modules/typebox/build/value/mutate/from_array.d.mts +0 -2
  1056. package/node_modules/typebox/build/value/mutate/from_array.mjs +0 -16
  1057. package/node_modules/typebox/build/value/mutate/from_object.d.mts +0 -2
  1058. package/node_modules/typebox/build/value/mutate/from_object.mjs +0 -40
  1059. package/node_modules/typebox/build/value/mutate/from_unknown.d.mts +0 -2
  1060. package/node_modules/typebox/build/value/mutate/from_unknown.mjs +0 -7
  1061. package/node_modules/typebox/build/value/mutate/from_value.d.mts +0 -2
  1062. package/node_modules/typebox/build/value/mutate/from_value.mjs +0 -12
  1063. package/node_modules/typebox/build/value/mutate/index.d.mts +0 -1
  1064. package/node_modules/typebox/build/value/mutate/index.mjs +0 -1
  1065. package/node_modules/typebox/build/value/mutate/mutate.d.mts +0 -11
  1066. package/node_modules/typebox/build/value/mutate/mutate.mjs +0 -41
  1067. package/node_modules/typebox/build/value/repair/from_base.d.mts +0 -2
  1068. package/node_modules/typebox/build/value/repair/from_base.mjs +0 -8
  1069. /package/node_modules/typebox/build/type/engine/{awaited → with}/index.d.mts +0 -0
  1070. /package/node_modules/typebox/build/type/engine/{awaited → with}/index.mjs +0 -0
@@ -1,8 +1,5 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
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
- var ALL_VERIFICATION_METHODS = [VerificationMethod.Sas, VerificationMethod.ScanQrCode, VerificationMethod.ShowQrCode, VerificationMethod.Reciprocate];
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 var MAX_INVITE_ACCEPTANCE_MS_FOR_KEY_BUNDLE = 24 * 60 * 60 * 1000; // 24 hours
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
- var enableEncryptedStateEvents = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
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
- var _this = this;
168
- return _asyncToGenerator(function* () {
169
- var roomId = event.getRoomId();
170
- var encryptor = _this.roomEncryptors[roomId];
171
- if (!encryptor) {
172
- throw new Error("Cannot encrypt event in unconfigured room ".concat(roomId));
173
- }
174
- yield encryptor.encryptEvent(event, _this.globalBlacklistUnverifiedDevices, _this.deviceIsolationMode);
175
- })();
176
- }
177
- decryptEvent(event) {
178
- var _this2 = this;
179
- return _asyncToGenerator(function* () {
180
- var 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 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
- var _this3 = this;
198
- return _asyncToGenerator(function* () {
199
- if (!(privKey instanceof Uint8Array)) {
200
- throw new Error("getBackupDecryptor: expects Uint8Array");
201
- }
202
- if (backupInfo.algorithm != "m.megolm_backup.v1.curve25519-aes-sha2") {
203
- throw new Error("getBackupDecryptor: Unsupported algorithm ".concat(backupInfo.algorithm));
204
- }
205
- var backupDecryptionKey = RustSdkCryptoJs.BackupDecryptionKey.fromBase64(encodeBase64(privKey));
206
- if (!decryptionKeyMatchesKeyBackupInfo(backupDecryptionKey, backupInfo)) {
207
- throw new Error("getBackupDecryptor: key backup on server does not match the decryption key");
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
- var _this4 = this;
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
- var _this5 = this;
228
- return _asyncToGenerator(function* () {
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
- var logger = new LogSpan(_this5.logger, "maybeAcceptKeyBundle(".concat(roomId, ", ").concat(inviter, ")"));
223
+ const logger = new LogSpan(this.logger, `maybeAcceptKeyBundle(${roomId}, ${inviter})`);
233
224
 
234
- // Make sure we have an up-to-date idea of the inviter's cross-signing keys, so that we can check if the
235
- // device that sent us the bundle data was correctly cross-signed.
236
- //
237
- // TODO: it would be nice to skip this step if we have an up-to-date copy of the inviter's cross-signing keys,
238
- // but we don't have an easy way to check that. Possibly the rust side could trigger a key request and then
239
- // block until it happens.
240
- logger.info("Checking inviter cross-signing keys");
241
- var request = _this5.olmMachine.queryKeysForUsers([new RustSdkCryptoJs.UserId(inviter)]);
242
- yield _this5.outgoingRequestProcessor.makeOutgoingRequest(request);
243
- var bundleData = yield _this5.olmMachine.getReceivedRoomKeyBundleData(new RustSdkCryptoJs.RoomId(roomId), new RustSdkCryptoJs.UserId(inviter));
244
- if (!bundleData) {
245
- logger.info("No key bundle found for user");
246
- return false;
247
- }
248
- logger.info("Fetching key bundle ".concat(bundleData.url));
249
- var url = getHttpUriForMxc(_this5.http.opts.baseUrl, bundleData.url, undefined, undefined, undefined, /* allowDirectLinks */false, /* allowRedirects */true, /* useAuthentication */true);
250
- var encryptedBundle;
251
- try {
252
- var bundleUrl = new URL(url);
253
- var encryptedBundleBlob = yield _this5.http.authedRequest(Method.Get, bundleUrl.pathname + bundleUrl.search, {}, undefined, {
254
- rawResponseBody: true,
255
- prefix: ""
256
- });
257
- logger.info("Received blob of length ".concat(encryptedBundleBlob.size));
258
- encryptedBundle = new Uint8Array(yield encryptedBundleBlob.arrayBuffer());
259
- } catch (err) {
260
- logger.warn("Error downloading encrypted bundle from ".concat(url, ":"), err);
261
- throw err;
262
- }
263
- try {
264
- yield _this5.olmMachine.receiveRoomKeyBundle(bundleData, encryptedBundle);
265
- } catch (err) {
266
- logger.warn("Error receiving encrypted bundle:", err);
267
- throw err;
268
- } finally {
269
- // Even if we were unable to import the bundle, we still clear the flag that indicates that we
270
- // are waiting for the bundle to be received. The only reason this can happen is that the bundle was
271
- // malformed somehow, so we don't want to keep retrying it.
272
- yield _this5.olmMachine.clearRoomPendingKeyBundle(new RustSdkCryptoJs.RoomId(roomId));
273
- }
274
- return true;
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
- var _this6 = this;
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
- var versions = RustSdkCryptoJs.getVersions();
292
- return "Rust SDK ".concat(versions.matrix_sdk_crypto, " (").concat(versions.git_sha, "), Vodozemac ").concat(versions.vodozemac);
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
- var _this7 = this;
307
- return _asyncToGenerator(function* () {
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
- var _this8 = this;
318
- return _asyncToGenerator(function* () {
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
- var _this9 = this;
329
- return _asyncToGenerator(function* () {
330
- var keys = _this9.olmMachine.identityKeys;
331
- return {
332
- ed25519: keys.ed25519.toBase64(),
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
- var encryptor = this.roomEncryptors[room.roomId];
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
- var _this$roomEncryptors$;
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
- var _this0 = this;
349
- return _asyncToGenerator(function* () {
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
- var _this1 = this;
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
- var _this10 = this;
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
- var _this11 = this;
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
- var _arguments = arguments,
378
- _this12 = this;
379
- return _asyncToGenerator(function* () {
380
- var userId = _arguments.length > 0 && _arguments[0] !== undefined ? _arguments[0] : _this12.userId;
381
- var downloadUncached = _arguments.length > 1 && _arguments[1] !== undefined ? _arguments[1] : false;
382
- // TODO: could probably do with a more efficient way of doing this than returning the whole set and searching
383
- var rustTrackedUsers = yield _this12.olmMachine.trackedUsers();
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
- var _arguments2 = arguments,
434
- _this13 = this;
435
- return _asyncToGenerator(function* () {
436
- var downloadUncached = _arguments2.length > 1 && _arguments2[1] !== undefined ? _arguments2[1] : false;
437
- var deviceMapByUserId = new Map();
438
- var rustTrackedUsers = yield _this13.getOlmMachineOrThrow().trackedUsers();
439
-
440
- // Convert RustSdkCryptoJs.UserId to a `Set<string>`
441
- var trackedUsers = new Set();
442
- rustTrackedUsers.forEach(rustUserId => trackedUsers.add(rustUserId.toString()));
443
-
444
- // Keep untracked user to download their keys after
445
- var untrackedUsers = new Set();
446
- for (var _userId of userIds) {
447
- // if this is a tracked user, we can just fetch the device list from the rust-sdk
448
- // (NB: this is probably ok even if we race with a leave event such that we stop tracking the user's
449
- // devices: the rust-sdk will return the last-known device list, which will be good enough.)
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
- // for any users whose device lists we are not tracking, fall back to downloading the device list
458
- // over HTTP.
459
- if (downloadUncached && untrackedUsers.size >= 1) {
460
- var queryResult = yield _this13.downloadDeviceList(untrackedUsers);
461
- Object.entries(queryResult.device_keys).forEach(_ref => {
462
- var _ref2 = _slicedToArray(_ref, 2),
463
- userId = _ref2[0],
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
- var _this14 = this;
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
- // Wait for up to a second for any in-flight device list requests to complete.
493
- // The reason for this isn't so much to avoid races (some level of raciness is
494
- // inevitable for this method) but to make testing easier.
495
- var userDevices = yield _this14.olmMachine.getUserDevices(rustUserId, 1);
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
- var deviceArray = userDevices.devices();
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
- userDevices.free();
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
- var _this15 = this;
515
- return _asyncToGenerator(function* () {
516
- var queryBody = {
517
- device_keys: {}
518
- };
519
- untrackedUsers.forEach(user => queryBody.device_keys[user] = []);
520
- return yield _this15.http.authedRequest(Method.Post, "/_matrix/client/v3/keys/query", undefined, queryBody, {
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
- var _arguments3 = arguments,
549
- _this16 = this;
550
- return _asyncToGenerator(function* () {
551
- var verified = _arguments3.length > 2 && _arguments3[2] !== undefined ? _arguments3[2] : true;
552
- var device = yield _this16.olmMachine.getDevice(new RustSdkCryptoJs.UserId(userId), new RustSdkCryptoJs.DeviceId(deviceId));
553
- if (!device) {
554
- throw new Error("Unknown device ".concat(userId, "|").concat(deviceId));
555
- }
556
- try {
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
- var _this17 = this;
571
- return _asyncToGenerator(function* () {
572
- var device = yield _this17.olmMachine.getDevice(new RustSdkCryptoJs.UserId(_this17.userId), new RustSdkCryptoJs.DeviceId(deviceId));
573
- if (!device) {
574
- throw new Error("Unknown device ".concat(deviceId));
575
- }
576
- try {
577
- var outgoingRequest = yield device.verify();
578
- yield _this17.outgoingRequestProcessor.makeOutgoingRequest(outgoingRequest);
579
- } finally {
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
- var _this18 = this;
590
- return _asyncToGenerator(function* () {
591
- var device = yield _this18.olmMachine.getDevice(new RustSdkCryptoJs.UserId(userId), new RustSdkCryptoJs.DeviceId(deviceId));
592
- if (!device) return null;
593
- try {
594
- return new DeviceVerificationStatus({
595
- signedByOwner: device.isCrossSignedByOwner(),
596
- crossSigningVerified: device.isCrossSigningTrusted(),
597
- localVerified: device.isLocallyTrusted(),
598
- trustCrossSignedDevices: _this18._trustCrossSignedDevices
599
- });
600
- } finally {
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
- var _this19 = this;
611
- return _asyncToGenerator(function* () {
612
- var userIdentity = yield _this19.getOlmMachineOrThrow().getIdentity(new RustSdkCryptoJs.UserId(userId));
613
- if (userIdentity === undefined) {
614
- return new UserVerificationStatus(false, false, false);
615
- }
616
- var verified = userIdentity.isVerified();
617
- var wasVerified = userIdentity.wasPreviouslyVerified();
618
- var needsUserApproval = userIdentity instanceof RustSdkCryptoJs.OtherUserIdentity ? userIdentity.identityNeedsUserApproval() : false;
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
- var _this20 = this;
629
- return _asyncToGenerator(function* () {
630
- var userIdentity = yield _this20.getOlmMachineOrThrow().getIdentity(new RustSdkCryptoJs.UserId(userId));
631
- if (userIdentity === undefined) {
632
- throw new Error("Cannot pin identity of unknown user");
633
- }
634
- if (userIdentity instanceof RustSdkCryptoJs.OwnUserIdentity) {
635
- throw new Error("Cannot pin identity of own user");
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
- var _this21 = this;
646
- return _asyncToGenerator(function* () {
647
- var userIdentity = yield _this21.getOlmMachineOrThrow().getIdentity(new RustSdkCryptoJs.UserId(userId));
648
- if (userIdentity === undefined) {
649
- throw new Error("Cannot withdraw verification of unknown user");
650
- }
651
- yield userIdentity.withdrawVerification();
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
- var _this22 = this;
660
- return _asyncToGenerator(function* () {
661
- var _yield$_this22$getCro = yield _this22.getCrossSigningStatus(),
662
- privateKeysInSecretStorage = _yield$_this22$getCro.privateKeysInSecretStorage,
663
- privateKeysCachedLocally = _yield$_this22$getCro.privateKeysCachedLocally;
664
- var hasKeysInCache = Boolean(privateKeysCachedLocally.masterKey) && Boolean(privateKeysCachedLocally.selfSigningKey) && Boolean(privateKeysCachedLocally.userSigningKey);
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
- // Cross-signing is ready if the public identity is trusted, and the private keys
668
- // are either cached, or accessible via secret-storage.
669
- return !!(identity !== null && identity !== void 0 && identity.isVerified()) && (hasKeysInCache || privateKeysInSecretStorage);
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
- var _arguments4 = arguments,
678
- _this23 = this;
679
- return _asyncToGenerator(function* () {
680
- var type = _arguments4.length > 0 && _arguments4[0] !== undefined ? _arguments4[0] : CrossSigningKey.Master;
681
- var userIdentity = yield _this23.getOwnIdentity();
682
- if (!userIdentity) {
683
- // The public keys are not available on this device
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
- try {
687
- var crossSigningStatus = yield _this23.olmMachine.crossSigningStatus();
688
- var privateKeysOnDevice = crossSigningStatus.hasMaster && crossSigningStatus.hasUserSigning && crossSigningStatus.hasSelfSigning;
689
- if (!privateKeysOnDevice) {
690
- // The private keys are not available on this device
691
- return null;
692
- }
693
- if (!userIdentity.isVerified()) {
694
- // We have both public and private keys, but they don't match!
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
- var _this24 = this;
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
- var _this25 = this;
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
- var _this26 = this;
748
- return _asyncToGenerator(function* () {
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
- // If key backup is active, we also need to check that the backup decryption key is stored
753
- var keyBackupEnabled = (yield _this26.backupManager.getActiveBackupVersion()) != null;
754
- if (keyBackupEnabled) {
755
- secretsToCheck.push("m.megolm_backup.v1");
756
- }
757
- var defaultKeyId = yield _this26.secretStorage.getDefaultKeyId();
758
- var result = {
759
- // Assume we have all secrets until proven otherwise
760
- ready: true,
761
- defaultKeyId,
762
- secretStorageKeyValidityMap: {}
763
- };
764
- for (var secretName of secretsToCheck) {
765
- // Check which keys this particular secret is encrypted with
766
- var record = (yield _this26.secretStorage.isStored(secretName)) || {};
767
-
768
- // If it's encrypted with the right key, it is valid
769
- var secretStored = !!defaultKeyId && defaultKeyId in record;
770
- result.secretStorageKeyValidityMap[secretName] = secretStored;
771
- result.ready = result.ready && secretStored;
772
- }
773
- return result;
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
- var _arguments5 = arguments,
782
- _this27 = this;
783
- return _asyncToGenerator(function* () {
784
- var _ref3 = _arguments5.length > 0 && _arguments5[0] !== undefined ? _arguments5[0] : {},
785
- createSecretStorageKey = _ref3.createSecretStorageKey,
786
- setupNewSecretStorage = _ref3.setupNewSecretStorage,
787
- setupNewKeyBackup = _ref3.setupNewKeyBackup;
788
- // If an AES Key is already stored in the secret storage and setupNewSecretStorage is not set
789
- // we don't want to create a new key
790
- var isNewSecretStorageKeyNeeded = setupNewSecretStorage || !(yield _this27.secretStorageHasAESKey());
791
- if (isNewSecretStorageKeyNeeded) {
792
- if (!createSecretStorageKey) {
793
- throw new Error("unable to create a new secret storage key, createSecretStorageKey is not set");
794
- }
795
-
796
- // Create a new storage key and add it to secret storage
797
- _this27.logger.info("bootstrapSecretStorage: creating new secret storage key");
798
- var recoveryKey = yield createSecretStorageKey();
799
- if (!recoveryKey) {
800
- throw new Error("createSecretStorageKey() callback did not return a secret storage key");
801
- }
802
- yield _this27.addSecretStorageKeyToSecretStorage(recoveryKey);
803
- }
804
- var crossSigningPrivateKeys = yield _this27.olmMachine.exportCrossSigningKeys();
805
- var hasPrivateKeys = crossSigningPrivateKeys && crossSigningPrivateKeys.masterKey !== undefined && crossSigningPrivateKeys.self_signing_key !== undefined && crossSigningPrivateKeys.userSigningKey !== undefined;
806
-
807
- // If we have cross-signing private keys cached, store them in secret
808
- // storage if they are not there already.
809
- if (hasPrivateKeys && (isNewSecretStorageKeyNeeded || !(yield secretStorageContainsCrossSigningKeys(_this27.secretStorage)))) {
810
- _this27.logger.info("bootstrapSecretStorage: cross-signing keys not yet exported; doing so now.");
811
- yield _this27.secretStorage.store("m.cross_signing.master", crossSigningPrivateKeys.masterKey);
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
- // likewise with the key backup key: if we have one, store it in secret storage (if it's not already there)
817
- // also don't bother storing it if we're about to set up a new backup
818
- if (!setupNewKeyBackup) {
819
- yield _this27.saveBackupKeyToStorage();
820
- } else {
821
- yield _this27.resetKeyBackup();
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
- var _this28 = this;
832
- return _asyncToGenerator(function* () {
833
- var keyBackupInfo = yield _this28.backupManager.getServerBackupInfo();
834
- if (!keyBackupInfo || !keyBackupInfo.version) {
835
- _this28.logger.info("Not saving backup key to secret storage: no backup info");
836
- return;
837
- }
838
- var backupKeys = yield _this28.olmMachine.getBackupKeys();
839
- if (!backupKeys.decryptionKey) {
840
- _this28.logger.info("Not saving backup key to secret storage: no backup key");
841
- return;
842
- }
843
- if (!decryptionKeyMatchesKeyBackupInfo(backupKeys.decryptionKey, keyBackupInfo)) {
844
- _this28.logger.info("Not saving backup key to secret storage: decryption key does not match backup info");
845
- return;
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
- var _this29 = this;
862
- return _asyncToGenerator(function* () {
863
- var _secretStorageKey$key, _secretStorageKey$key2, _this29$cryptoCallbac, _this29$cryptoCallbac2;
864
- var secretStorageKeyObject = yield _this29.secretStorage.addKey(SECRET_STORAGE_ALGORITHM_V1_AES, {
865
- passphrase: (_secretStorageKey$key = secretStorageKey.keyInfo) === null || _secretStorageKey$key === void 0 ? void 0 : _secretStorageKey$key.passphrase,
866
- name: (_secretStorageKey$key2 = secretStorageKey.keyInfo) === null || _secretStorageKey$key2 === void 0 ? void 0 : _secretStorageKey$key2.name,
867
- key: secretStorageKey.privateKey
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
- var _this30 = this;
881
- return _asyncToGenerator(function* () {
882
- // See if we already have an AES secret-storage key.
883
- var secretStorageKeyTuple = yield _this30.secretStorage.getKey();
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
- // Check if the key is an AES key
889
- return keyInfo.algorithm === SECRET_STORAGE_ALGORITHM_V1_AES;
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
- var _this31 = this;
898
- return _asyncToGenerator(function* () {
899
- var userIdentity = yield _this31.getOwnIdentity();
900
- var publicKeysOnDevice = Boolean(userIdentity === null || userIdentity === void 0 ? void 0 : userIdentity.masterKey) && Boolean(userIdentity === null || userIdentity === void 0 ? void 0 : userIdentity.selfSigningKey) && Boolean(userIdentity === null || userIdentity === void 0 ? void 0 : userIdentity.userSigningKey);
901
- userIdentity === null || userIdentity === void 0 || userIdentity.free();
902
- var privateKeysInSecretStorage = yield secretStorageContainsCrossSigningKeys(_this31.secretStorage);
903
- var crossSigningStatus = yield _this31.getOlmMachineOrThrow().crossSigningStatus();
904
- return {
905
- publicKeysOnDevice,
906
- privateKeysInSecretStorage,
907
- privateKeysCachedLocally: {
908
- masterKey: Boolean(crossSigningStatus === null || crossSigningStatus === void 0 ? void 0 : crossSigningStatus.hasMaster),
909
- userSigningKey: Boolean(crossSigningStatus === null || crossSigningStatus === void 0 ? void 0 : crossSigningStatus.hasUserSigning),
910
- selfSigningKey: Boolean(crossSigningStatus === null || crossSigningStatus === void 0 ? void 0 : crossSigningStatus.hasSelfSigning)
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
- var _this32 = this;
921
- return _asyncToGenerator(function* () {
922
- if (password) {
923
- // Generate the key from the passphrase
924
- // first we generate a random salt
925
- var salt = secureRandomString(32);
926
- // then we derive the key from the passphrase
927
- var recoveryKey = yield deriveRecoveryKeyFromPassphrase(password, salt, _this32.RECOVERY_KEY_DERIVATION_ITERATIONS);
928
- return {
929
- keyInfo: {
930
- passphrase: {
931
- algorithm: "m.pbkdf2",
932
- iterations: _this32.RECOVERY_KEY_DERIVATION_ITERATIONS,
933
- salt
934
- }
935
- },
936
- privateKey: recoveryKey,
937
- encodedPrivateKey: encodeRecoveryKey(recoveryKey)
938
- };
939
- } else {
940
- // Using the navigator crypto API to generate the private key
941
- var key = new Uint8Array(32);
942
- globalThis.crypto.getRandomValues(key);
943
- return {
944
- privateKey: key,
945
- encodedPrivateKey: encodeRecoveryKey(key)
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
- var _this33 = this;
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
- var requests = this.olmMachine.getVerificationRequests(new RustSdkCryptoJs.UserId(userId));
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
- var requests = this.olmMachine.getVerificationRequests(new RustSdkCryptoJs.UserId(userId));
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
- var request = requests.find(request => {
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
- var _this34 = this;
1005
- return _asyncToGenerator(function* () {
1006
- var userIdentity = yield _this34.olmMachine.getIdentity(new RustSdkCryptoJs.UserId(userId));
1007
- if (!userIdentity) throw new Error("unknown userId ".concat(userId));
1008
- try {
1009
- // Transform the verification methods into rust objects
1010
- var methods = _this34._supportedVerificationMethods.map(method => verificationMethodIdentifierToMethod(method));
1011
- // Get the request content to send to the DM room
1012
- var verCont = yield userIdentity.verificationRequestContent(methods);
1013
-
1014
- // 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`.
1015
- var verContObj = JSON.parse(verCont);
1016
- verContObj["msgtype"] = "m.key.verification.request";
1017
- var verificationEventContent = JSON.stringify(verContObj);
1018
-
1019
- // Send the request content to send to the DM room
1020
- var eventId = yield _this34.sendVerificationRequestContent(roomId, verificationEventContent);
1021
-
1022
- // Get a verification request
1023
- var request = yield userIdentity.requestVerification(new RustSdkCryptoJs.RoomId(roomId), new RustSdkCryptoJs.EventId(eventId), methods);
1024
- return _this34.makeVerificationRequest(request);
1025
- } finally {
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
- var _this35 = this;
1044
- return _asyncToGenerator(function* () {
1045
- var txId = secureRandomString(32);
1046
- // Send the verification request content to the DM room
1047
- var _yield$_this35$http$a = yield _this35.http.authedRequest(Method.Put, "/_matrix/client/v3/rooms/".concat(encodeURIComponent(roomId), "/send/m.room.message/").concat(encodeURIComponent(txId)), undefined, verificationEventContent, {
1048
- prefix: ""
1049
- }),
1050
- eventId = _yield$_this35$http$a.event_id;
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 !== null && methods !== void 0 ? methods : ALL_VERIFICATION_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
- var _this36 = this;
1075
- return _asyncToGenerator(function* () {
1076
- var userIdentity = yield _this36.getOwnIdentity();
1077
- if (userIdentity === undefined) {
1078
- throw new Error("cannot request verification for this device when there is no existing cross-signing key");
1079
- }
1080
- try {
1081
- var _yield$userIdentity$r = yield userIdentity.requestVerification(_this36._supportedVerificationMethods.map(verificationMethodIdentifierToMethod)),
1082
- _yield$userIdentity$r2 = _slicedToArray(_yield$userIdentity$r, 2),
1083
- request = _yield$userIdentity$r2[0],
1084
- outgoingRequest = _yield$userIdentity$r2[1];
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
- var _this37 = this;
1107
- return _asyncToGenerator(function* () {
1108
- var device = yield _this37.olmMachine.getDevice(new RustSdkCryptoJs.UserId(userId), new RustSdkCryptoJs.DeviceId(deviceId));
1109
- if (!device) {
1110
- throw new Error("Not a known device");
1111
- }
1112
- try {
1113
- var _device$requestVerifi = device.requestVerification(_this37._supportedVerificationMethods.map(verificationMethodIdentifierToMethod)),
1114
- _device$requestVerifi2 = _slicedToArray(_device$requestVerifi, 2),
1115
- request = _device$requestVerifi2[0],
1116
- outgoingRequest = _device$requestVerifi2[1];
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
- var _this38 = this;
1134
- return _asyncToGenerator(function* () {
1135
- var backupKeys = yield _this38.olmMachine.getBackupKeys();
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
- var _this39 = this;
1151
- return _asyncToGenerator(function* () {
1152
- var base64Key = encodeBase64(key);
1153
- if (!version) {
1154
- throw new Error("storeSessionBackupPrivateKey: version is required");
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
- var _this40 = this;
1165
- return _asyncToGenerator(function* () {
1166
- var backupKey = yield _this40.secretStorage.get("m.megolm_backup.v1");
1167
- if (!backupKey) {
1168
- throw new Error("loadSessionBackupPrivateKeyFromSecretStorage: missing decryption key in secret storage");
1169
- }
1170
- var keyBackupInfo = yield _this40.backupManager.getServerBackupInfo();
1171
- if (!keyBackupInfo || !keyBackupInfo.version) {
1172
- throw new Error("loadSessionBackupPrivateKeyFromSecretStorage: unable to get backup version");
1173
- }
1174
- var backupDecryptionKey = RustSdkCryptoJs.BackupDecryptionKey.fromBase64(backupKey);
1175
- if (!decryptionKeyMatchesKeyBackupInfo(backupDecryptionKey, keyBackupInfo)) {
1176
- throw new DecryptionKeyDoesNotMatchError("loadSessionBackupPrivateKeyFromSecretStorage: decryption key does not match backup info");
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
- var _this41 = this;
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
- var _this42 = this;
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
- var _this43 = this;
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
- var _this44 = this;
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
- var _this45 = this;
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
- var _this46 = this;
1243
- return _asyncToGenerator(function* () {
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
- // we want to store the private key in 4S
1248
- // need to check if 4S is set up?
1249
- if (yield _this46.secretStorageHasAESKey()) {
1250
- yield _this46.secretStorage.store("m.megolm_backup.v1", backupInfo.decryptionKey.toBase64());
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
- // we can check and start async
1254
- _this46.checkKeyBackupAndEnable();
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
- var _this47 = this;
1263
- return _asyncToGenerator(function* () {
1264
- // Get the key backup version we're using
1265
- var info = yield _this47.getKeyBackupInfo();
1266
- if (info !== null && info !== void 0 && info.version) {
1267
- yield _this47.deleteKeyBackupVersion(info.version);
1268
- } else {
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
- // also turn off 4S, since this is also storing keys on the server.
1273
- yield _this47.deleteSecretStorage();
1274
- yield _this47.dehydratedDeviceManager.delete();
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
- var _this48 = this;
1288
- return _asyncToGenerator(function* () {
1289
- var sigs = new Map(Object.entries(obj.signatures || {}));
1290
- var unsigned = obj.unsigned;
1291
- delete obj.signatures;
1292
- delete obj.unsigned;
1293
- var userSignatures = sigs.get(_this48.userId) || {};
1294
- var canonalizedJson = anotherjson.stringify(obj);
1295
- var signatures = yield _this48.olmMachine.sign(canonalizedJson);
1296
- var map = JSON.parse(signatures.asJSON());
1297
- sigs.set(_this48.userId, _objectSpread(_objectSpread({}, userSignatures), map[_this48.userId]));
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
- var _this49 = this;
1308
- return _asyncToGenerator(function* () {
1309
- var backupInfo = yield _this49.backupManager.getServerBackupInfo();
1310
- if (!(backupInfo !== null && backupInfo !== void 0 && backupInfo.version)) {
1311
- throw new Error("No backup info available");
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
- // Cache the key
1316
- yield _this49.storeSessionBackupPrivateKey(privateKey, backupInfo.version);
1317
- return _this49.restoreKeyBackup(opts);
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
- var _this50 = this;
1326
- return _asyncToGenerator(function* () {
1327
- // Get the decryption key from the crypto store
1328
- var backupKeys = yield _this50.olmMachine.getBackupKeys();
1329
- var decryptionKey = backupKeys.decryptionKey,
1330
- backupVersion = backupKeys.backupVersion;
1331
- if (!decryptionKey || !backupVersion) throw new Error("No decryption key found in crypto store");
1332
- var decodedDecryptionKey = decodeBase64(decryptionKey.toBase64());
1333
- var backupInfo = yield _this50.backupManager.requestKeyBackupVersion(backupVersion);
1334
- if (!backupInfo) throw new Error("Backup version to restore ".concat(backupVersion, " not found on server"));
1335
- var backupDecryptor = yield _this50.getBackupDecryptor(backupInfo, decodedDecryptionKey);
1336
- try {
1337
- var _opts$progressCallbac;
1338
- opts === null || opts === void 0 || (_opts$progressCallbac = opts.progressCallback) === null || _opts$progressCallbac === void 0 || _opts$progressCallbac.call(opts, {
1339
- stage: ImportRoomKeyStage.Fetch
1340
- });
1341
- return yield _this50.backupManager.restoreKeyBackup(backupVersion, backupDecryptor, opts);
1342
- } finally {
1343
- // Free to avoid to keep in memory the decryption key stored in it. To avoid to exposing it to an attacker.
1344
- backupDecryptor.free();
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
- var _this51 = this;
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
- var _arguments6 = arguments,
1364
- _this52 = this;
1365
- return _asyncToGenerator(function* () {
1366
- var opts = _arguments6.length > 0 && _arguments6[0] !== undefined ? _arguments6[0] : {};
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
- var _this53 = this;
1379
- return _asyncToGenerator(function* () {
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
- var _this54 = this;
1390
- return _asyncToGenerator(function* () {
1391
- var secretsBundle = yield _this54.getOlmMachineOrThrow().exportSecretsBundle();
1392
- var secrets = secretsBundle.to_json();
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
- var _this55 = this;
1403
- return _asyncToGenerator(function* () {
1404
- var logger = new LogSpan(_this55.logger, "encryptToDeviceMessages");
1405
- var uniqueUsers = new Set(devices.map(_ref4 => {
1406
- var userId = _ref4.userId;
1407
- return userId;
1408
- }));
1409
-
1410
- // This will ensure we have Olm sessions for all of the users' devices.
1411
- // However, we only care about some of the devices.
1412
- // So, perhaps we can optimise this later on.
1413
- yield _this55.keyClaimManager.ensureSessionsForUsers(logger, Array.from(uniqueUsers).map(userId => new RustSdkCryptoJs.UserId(userId)));
1414
- var batch = {
1415
- batch: [],
1416
- eventType: EventType.RoomMessageEncrypted
1417
- };
1418
- yield Promise.all(devices.map(/*#__PURE__*/function () {
1419
- var _ref6 = _asyncToGenerator(function* (_ref5) {
1420
- var userId = _ref5.userId,
1421
- deviceId = _ref5.deviceId;
1422
- var device = yield _this55.olmMachine.getDevice(new RustSdkCryptoJs.UserId(userId), new RustSdkCryptoJs.DeviceId(deviceId));
1423
- if (device) {
1424
- var encryptedPayload = JSON.parse(yield device.encryptToDeviceEvent(eventType, payload));
1425
- batch.batch.push({
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
- return function (_x) {
1435
- return _ref6.apply(this, arguments);
1436
- };
1437
- }()));
1438
- return batch;
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
- var _this56 = this;
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
- // Delete the dehydrated device, since any existing one will be signed
1451
- // by the wrong cross-signing key
1452
- _this56.dehydratedDeviceManager.delete();
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
- // Disable backup, and delete all the backups from the server
1455
- yield _this56.backupManager.deleteAllKeyBackupVersions();
1456
- yield _this56.deleteSecretStorage();
1274
+ // Disable backup, and delete all the backups from the server
1275
+ await this.backupManager.deleteAllKeyBackupVersions();
1276
+ await this.deleteSecretStorage();
1457
1277
 
1458
- // Reset the cross-signing keys
1459
- yield _this56.crossSigningIdentity.bootstrapCrossSigning({
1460
- setupNewCrossSigning: true,
1461
- authUploadDeviceSigningKeys
1462
- });
1278
+ // Reset the cross-signing keys
1279
+ await this.crossSigningIdentity.bootstrapCrossSigning({
1280
+ setupNewCrossSigning: true,
1281
+ authUploadDeviceSigningKeys
1282
+ });
1463
1283
 
1464
- // Create a new key backup
1465
- yield _this56.resetKeyBackup();
1466
- _this56.logger.debug("resetEncryption: ended");
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
- var _this57 = this;
1476
- return _asyncToGenerator(function* () {
1477
- // Remove the stored secrets in the secret storage
1478
- yield _this57.secretStorage.store("m.cross_signing.master", null);
1479
- yield _this57.secretStorage.store("m.cross_signing.self_signing", null);
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
- // Remove the recovery key
1484
- var defaultKeyId = yield _this57.secretStorage.getDefaultKeyId();
1485
- if (defaultKeyId) yield _this57.secretStorage.store("m.secret_storage.key.".concat(defaultKeyId), null);
1486
- // Disable the recovery key and the secret storage
1487
- yield _this57.secretStorage.setDefaultKeyId(null);
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
- var _this58 = this;
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
- // 0. We can only share room history if our user has set up cross-signing.
1500
- var identity = yield _this58.getOwnIdentity();
1501
- if (!(identity !== null && identity !== void 0 && identity.isVerified())) {
1502
- logger.warn("Not sharing message history as the current device is not verified by our cross-signing identity");
1503
- return;
1504
- }
1505
- logger.info("Sharing message history");
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
- // 1. Download keys from backup.
1508
- if (!(yield _this58.getOlmMachineOrThrow().hasDownloadedAllRoomKeys(new RustSdkCryptoJs.RoomId(roomId)))) {
1509
- yield _this58.backupManager.downloadLatestRoomKeyBackup(roomId);
1510
- yield _this58.getOlmMachineOrThrow().setHasDownloadedAllRoomKeys(new RustSdkCryptoJs.RoomId(roomId));
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
- // 2. Construct the key bundle
1514
- var bundle = yield _this58.getOlmMachineOrThrow().buildRoomKeyBundle(new RustSdkCryptoJs.RoomId(roomId));
1515
- if (!bundle) {
1516
- logger.info("No keys to share");
1517
- return;
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
- // 3. Upload the encrypted bundle to the server
1521
- var uploadResponse = yield _this58.http.uploadContent(bundle.encryptedData);
1522
- logger.info("Uploaded encrypted key blob: ".concat(JSON.stringify(uploadResponse)));
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
- // 4. We may not share a room with the user, so get a fresh list of devices for the invited user.
1525
- var req = _this58.getOlmMachineOrThrow().queryKeysForUsers([new RustSdkCryptoJs.UserId(userId)]);
1526
- yield _this58.outgoingRequestProcessor.makeOutgoingRequest(req);
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
- // 5. Establish Olm sessions with all of the recipient's devices.
1529
- yield _this58.keyClaimManager.ensureSessionsForUsers(logger, [new RustSdkCryptoJs.UserId(userId)]);
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
- // 6. Send to-device messages to the recipient to share the keys.
1532
- var requests = yield _this58.getOlmMachineOrThrow().shareRoomKeyBundleData(new RustSdkCryptoJs.UserId(userId), new RustSdkCryptoJs.RoomId(roomId), uploadResponse.content_uri, bundle.mediaEncryptionInfo, RustSdkCryptoJs.CollectStrategy.identityBasedStrategy());
1533
- for (var _req of requests) {
1534
- yield _this58.outgoingRequestProcessor.makeOutgoingRequest(_req);
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(_ref7) {
1554
- var _this59 = this;
1555
- return _asyncToGenerator(function* () {
1556
- var events = _ref7.events,
1557
- _ref7$oneTimeKeysCoun = _ref7.oneTimeKeysCounts,
1558
- oneTimeKeysCounts = _ref7$oneTimeKeysCoun === void 0 ? new Map() : _ref7$oneTimeKeysCoun,
1559
- unusedFallbackKeys = _ref7.unusedFallbackKeys,
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
- var _this60 = this;
1573
- return _asyncToGenerator(function* () {
1574
- // send the received to-device messages into receiveSyncChanges. We have no info on device-list changes,
1575
- // one-time-keys, or fallback keys, so just pass empty data.
1576
- var processed = yield _this60.receiveSyncChanges({
1577
- events
1578
- });
1579
- var received = [];
1580
- var _loop = function* _loop() {
1581
- var parsedMessage = JSON.parse(message.rawEvent);
1582
-
1583
- // look for interesting to-device messages
1584
- if (parsedMessage.type === EventType.KeyVerificationRequest) {
1585
- var sender = parsedMessage.sender;
1586
- var transactionId = parsedMessage.content.transaction_id;
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
- switch (message.type) {
1592
- case RustSdkCryptoJs.ProcessedToDeviceEventType.Decrypted:
1593
- {
1594
- var _encryptionInfo$sende;
1595
- var encryptionInfo = message.encryptionInfo;
1596
- received.push({
1597
- message: parsedMessage,
1598
- encryptionInfo: {
1599
- sender: encryptionInfo.sender.toString(),
1600
- senderDevice: (_encryptionInfo$sende = encryptionInfo.senderDevice) === null || _encryptionInfo$sende === void 0 ? void 0 : _encryptionInfo$sende.toString(),
1601
- senderCurve25519KeyBase64: encryptionInfo.senderCurve25519Key,
1602
- senderVerified: encryptionInfo.isSenderVerified()
1603
- }
1604
- });
1605
-
1606
- // If we have received a room key bundle message, and have recently joined the room in question,
1607
- // tell the Rust SDK to try and accept the key bundle.
1608
- //
1609
- // We don't actually need to validate the contents of the bundle message, or do
1610
- // anything with its contents at all. We simply want to inform the Rust SDK we have
1611
- // received a new room key bundle that we might be able to download.
1612
- if (isRoomKeyBundleMessage(parsedMessage)) {
1613
- var roomId = parsedMessage.content.room_id;
1614
- var pendingDetails = yield _this60.olmMachine.getPendingKeyBundleDetailsForRoom(new RustSdkCryptoJs.RoomId(roomId));
1615
- // Only accept the key bundle if we joined the room less than 24 hours ago.
1616
- if (!pendingDetails) {
1617
- _this60.logger.debug("Not yet accepting key bundle for room where we are not awaiting a bundle: ".concat(roomId));
1618
- } else if (Date.now() - pendingDetails.inviteAcceptedAtMillis > MAX_INVITE_ACCEPTANCE_MS_FOR_KEY_BUNDLE) {
1619
- _this60.logger.info("Ignoring key bundle for room we joined too long ago: ".concat(roomId, ", joining time: ").concat(new Date(pendingDetails.inviteAcceptedAtMillis).toISOString()));
1620
- } else {
1621
- _this60.logger.info("Considering key bundle for recently-joined room ".concat(roomId));
1622
- // Don't block for the import to happen, here, as this is called from inside the `/sync` loop.
1623
- _this60.maybeAcceptKeyBundle(roomId, pendingDetails.inviterId.toString()).catch(err => {
1624
- _this60.logger.error("Error attempting to download key bundle for room ".concat(roomId));
1625
- _this60.logger.error(err);
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
- case RustSdkCryptoJs.ProcessedToDeviceEventType.Invalid:
1643
- // ignore invalid messages
1436
+ }
1437
+ case RustSdkCryptoJs.ProcessedToDeviceEventType.PlainText:
1438
+ {
1439
+ received.push({
1440
+ message: parsedMessage,
1441
+ encryptionInfo: null
1442
+ });
1644
1443
  break;
1645
- }
1646
- };
1647
- for (var message of processed) {
1648
- yield* _loop();
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
- return received;
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
- var _this61 = this;
1661
- return _asyncToGenerator(function* () {
1662
- var mapOneTimeKeysCount = oneTimeKeysCounts && new Map(Object.entries(oneTimeKeysCounts));
1663
- var setUnusedFallbackKeys = unusedFallbackKeys && new Set(unusedFallbackKeys);
1664
- if (mapOneTimeKeysCount !== undefined || setUnusedFallbackKeys !== undefined) {
1665
- yield _this61.receiveSyncChanges({
1666
- oneTimeKeysCounts: mapOneTimeKeysCount,
1667
- unusedFallbackKeys: setUnusedFallbackKeys
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
- var _this62 = this;
1680
- return _asyncToGenerator(function* () {
1681
- var _deviceLists$changed, _deviceLists$left;
1682
- var devices = new RustSdkCryptoJs.DeviceLists((_deviceLists$changed = deviceLists.changed) === null || _deviceLists$changed === void 0 ? void 0 : _deviceLists$changed.map(userId => new RustSdkCryptoJs.UserId(userId)), (_deviceLists$left = deviceLists.left) === null || _deviceLists$left === void 0 ? void 0 : _deviceLists$left.map(userId => new RustSdkCryptoJs.UserId(userId)));
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
- var _this63 = this;
1696
- return _asyncToGenerator(function* () {
1697
- var config = event.getContent();
1698
- var settings = new RustSdkCryptoJs.RoomSettings();
1699
- if (config.algorithm === "m.megolm.v1.aes-sha2") {
1700
- settings.algorithm = RustSdkCryptoJs.EncryptionAlgorithm.MegolmV1AesSha2;
1701
- } else {
1702
- // Among other situations, this happens if the crypto state event is redacted.
1703
- _this63.logger.warn("Room ".concat(room.roomId, ": ignoring crypto event with invalid algorithm ").concat(config.algorithm));
1704
- return;
1705
- }
1706
- if (config["io.element.msc4362.encrypt_state_events"] && _this63.enableEncryptedStateEvents) {
1707
- _this63.logger.info("crypto Enabling state event encryption...");
1708
- settings.encryptStateEvents = true;
1709
- }
1710
- try {
1711
- settings.sessionRotationPeriodMs = config.rotation_period_ms;
1712
- settings.sessionRotationPeriodMessages = config.rotation_period_msgs;
1713
- yield _this63.olmMachine.setRoomSettings(new RustSdkCryptoJs.RoomId(room.roomId), settings);
1714
- } catch (e) {
1715
- _this63.logger.warn("Room ".concat(room.roomId, ": ignoring crypto event which caused error: ").concat(e));
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
- // If we got this far, the SDK found the event acceptable.
1720
- // We need to either create or update the active RoomEncryptor.
1721
- var existingEncryptor = _this63.roomEncryptors[room.roomId];
1722
- if (existingEncryptor) {
1723
- existingEncryptor.onCryptoEvent(config);
1724
- } else {
1725
- _this63.roomEncryptors[room.roomId] = new RoomEncryptor(_this63.logger.getChild("[".concat(room.roomId, " encryption]")), _this63.olmMachine, _this63.keyClaimManager, _this63.outgoingRequestsManager, room, config);
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
- var _this64 = this;
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
- var request = this.olmMachine.getVerificationRequest(new RustSdkCryptoJs.UserId(sender), transactionId);
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("Ignoring just-received verification request ".concat(transactionId, " which did not start a rust-side verification"));
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
- var roomId = event.getRoomId();
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("Error clearing room pending key bundle indicator for ".concat(roomId, ": ").concat(e));
1584
+ this.logger.error(`Error clearing room pending key bundle indicator for ${roomId}: ${e}`);
1796
1585
  });
1797
1586
  }
1798
- var enc = this.roomEncryptors[roomId];
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("Rotating session for room ".concat(event.getRoomId(), " due to member leaving the room"));
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
- var _this65 = this;
1850
- return _asyncToGenerator(function* () {
1851
- for (var key of keys) {
1852
- _this65.onRoomKeyUpdated(key);
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("Got update for session ".concat(key.sessionId, " from sender ").concat(key.senderKey.toBase64(), " in ").concat(key.roomId.toString()));
1861
- var pendingList = this.eventDecryptor.getEventsPendingRoomKey(key.roomId.toString(), key.sessionId);
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 => "".concat(e.getId())));
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
- var _loop2 = function _loop2(ev) {
1872
- ev.attemptDecryption(_this66, {
1656
+ for (const ev of pendingList) {
1657
+ ev.attemptDecryption(this, {
1873
1658
  isRetry: true
1874
1659
  }).catch(_e => {
1875
- _this66.logger.info("Still unable to decrypt event ".concat(ev.getId(), " after receiving key"));
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
- var _this67 = this;
1893
- return _asyncToGenerator(function* () {
1894
- for (var session of withheld) {
1895
- _this67.logger.debug("Got withheld message for session ".concat(session.sessionId, " in ").concat(session.roomId.toString()));
1896
- var pendingList = _this67.eventDecryptor.getEventsPendingRoomKey(session.roomId.toString(), session.sessionId);
1897
- if (pendingList.length === 0) return;
1898
-
1899
- // The easiest way to update the status of the event is to have another go at decrypting it.
1900
- _this67.logger.debug("Retrying decryption on events:", pendingList.map(e => "".concat(e.getId())));
1901
- for (var ev of pendingList) {
1902
- ev.attemptDecryption(_this67, {
1903
- isRetry: true
1904
- }).catch(_e => {
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
- var _this68 = this;
1922
- return _asyncToGenerator(function* () {
1923
- var newVerification = yield _this68.getUserVerificationStatus(userId.toString());
1924
- _this68.emit(CryptoEvent.UserTrustStatusChanged, userId.toString(), newVerification);
1925
-
1926
- // If our own user identity has changed, we may now trust the key backup where we did not before.
1927
- // So, re-check the key backup status and enable it if available.
1928
- if (userId.toString() === _this68.userId) {
1929
- _this68.emit(CryptoEvent.KeysChanged, {});
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
- var _this69 = this;
1947
- return _asyncToGenerator(function* () {
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
- var _this70 = this;
1967
- return _asyncToGenerator(function* () {
1968
- _this70.logger.debug("onReceiveSecret: Received secret ".concat(name));
1969
- if (name === "m.megolm_backup.v1") {
1970
- return yield _this70.backupManager.handleBackupSecretReceived(value);
1971
- // XXX at this point we should probably try to download the backup and import the keys,
1972
- // or at least retry for the current decryption failures?
1973
- // Maybe add some signaling when a new secret is received, and let clients handle it?
1974
- // as it's where the restore from backup APIs are exposed.
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
- var _this71 = this;
1989
- return _asyncToGenerator(function* () {
1990
- var pendingValues = yield _this71.olmMachine.getSecretsFromInbox(name);
1991
- for (var value of pendingValues) {
1992
- if (yield _this71.handleSecretReceived(name, value)) {
1993
- // If we have a valid secret for that name there is no point of processing the other secrets values.
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
- // Important to call this after handling the secrets as good hygiene.
2000
- yield _this71.olmMachine.deleteSecretsFromInbox(name);
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
- var _this72 = this;
2012
- return _asyncToGenerator(function* () {
2013
- // Ignore state event or remote echo
2014
- // transaction_id is provided in case of remote echo {@link https://spec.matrix.org/v1.7/client-server-api/#local-echo}
2015
- if (event.isState() || !!event.getUnsigned().transaction_id) return;
2016
- var processEvent = /*#__PURE__*/function () {
2017
- var _ref8 = _asyncToGenerator(function* (evt) {
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
- var _this73 = this;
2055
- return _asyncToGenerator(function* () {
2056
- var roomId = event.getRoomId();
2057
- var senderId = event.getSender();
2058
- if (!roomId) {
2059
- throw new Error("missing roomId in the event");
2060
- }
2061
- if (!senderId) {
2062
- throw new Error("missing sender in the event");
2063
- }
2064
- _this73.logger.debug("Incoming verification event ".concat(event.getId(), " type ").concat(event.getType(), " from ").concat(event.getSender()));
2065
- var isRoomVerificationRequest = event.getType() === EventType.RoomMessage && event.getContent().msgtype === MsgType.KeyVerificationRequest;
2066
- if (isRoomVerificationRequest) {
2067
- // Before processing an in-room verification request, we need to
2068
- // make sure we have the sender's device information - otherwise we
2069
- // will immediately abort verification. So we explicitly fetch it
2070
- // from /keys/query and wait for that request to complete before we
2071
- // call receiveVerificationEvent.
2072
- var req = _this73.getOlmMachineOrThrow().queryKeysForUsers([new RustSdkCryptoJs.UserId(senderId)]);
2073
- yield _this73.outgoingRequestProcessor.makeOutgoingRequest(req);
2074
- }
2075
- yield _this73.getOlmMachineOrThrow().receiveVerificationEvent(JSON.stringify({
2076
- event_id: event.getId(),
2077
- type: event.getType(),
2078
- sender: senderId,
2079
- state_key: event.getStateKey(),
2080
- content: event.getContent(),
2081
- origin_server_ts: event.getTs()
2082
- }), new RustSdkCryptoJs.RoomId(roomId));
2083
- if (isRoomVerificationRequest) {
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
- // that may have caused us to queue up outgoing requests, so make sure we send them.
2088
- _this73.outgoingRequestsManager.doProcessOutgoingRequests().catch(e => {
2089
- _this73.logger.warn("onKeyVerificationRequest: Error processing outgoing requests", e);
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
- var _this74 = this;
2102
- return _asyncToGenerator(function* () {
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
- var _this75 = this;
2113
- return _asyncToGenerator(function* () {
2114
- var logger = new LogSpan(_this75.logger, "pushSecretToVerifiedDevices");
2115
- yield _this75.keyClaimManager.ensureSessionsForUsers(logger, [new RustSdkCryptoJs.UserId(_this75.userId)]);
2116
- yield _this75.olmMachine.pushSecretToVerifiedDevices(name);
2117
- _this75.outgoingRequestsManager.doProcessOutgoingRequests().catch(e => {
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
- var _this76 = this;
2137
- return _asyncToGenerator(function* () {
2138
- // add the event to the pending list *before* attempting to decrypt.
2139
- // then, if the key turns up while decryption is in progress (and
2140
- // decryption fails), we will schedule a retry.
2141
- // (fixes https://github.com/vector-im/element-web/issues/5001)
2142
- _this76.addEventToPendingList(event);
2143
- var trustRequirement;
2144
- switch (isolationMode.kind) {
2145
- case DeviceIsolationModeKind.AllDevicesIsolationMode:
2146
- trustRequirement = RustSdkCryptoJs.TrustRequirement.Untrusted;
2147
- break;
2148
- case DeviceIsolationModeKind.OnlySignedDevicesIsolationMode:
2149
- trustRequirement = RustSdkCryptoJs.TrustRequirement.CrossSignedOrLegacy;
2150
- break;
2151
- }
2152
- try {
2153
- var _res$forwarder;
2154
- var res = yield _this76.olmMachine.decryptRoomEvent(stringifyEvent(event), new RustSdkCryptoJs.RoomId(event.getRoomId()), new RustSdkCryptoJs.DecryptionSettings(trustRequirement));
2155
-
2156
- // Success. We can remove the event from the pending list, if
2157
- // that hasn't already happened.
2158
- _this76.removeEventFromPendingList(event);
2159
- return {
2160
- clearEvent: JSON.parse(res.event),
2161
- claimedEd25519Key: res.senderClaimedEd25519Key,
2162
- senderCurve25519Key: res.senderCurve25519Key,
2163
- keyForwardedBy: (_res$forwarder = res.forwarder) === null || _res$forwarder === void 0 ? void 0 : _res$forwarder.toString()
2164
- };
2165
- } catch (err) {
2166
- if (err instanceof RustSdkCryptoJs.MegolmDecryptionError) {
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
- var content = event.getWireContent();
2187
- var errorDetails = {
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
- var membership = event.getMembershipAtEvent();
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
- var failureCode = err.maybe_withheld === "The sender has disabled encrypting to unverified devices." ? DecryptionFailureCode.MEGOLM_KEY_WITHHELD_FOR_UNVERIFIED_DEVICE : DecryptionFailureCode.MEGOLM_KEY_WITHHELD;
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
- var _this77 = this;
2254
- return _asyncToGenerator(function* () {
2255
- if (!event.getClearContent() || event.isDecryptionFailure()) {
2256
- // not successfully decrypted
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
- // special-case outgoing events, which the rust crypto-sdk will barf on
2261
- if (event.status !== null) {
2262
- return {
2263
- shieldColour: EventShieldColour.NONE,
2264
- shieldReason: null
2265
- };
2266
- }
2267
- var encryptionInfo = yield _this77.olmMachine.getRoomEventEncryptionInfo(stringifyEvent(event), new RustSdkCryptoJs.RoomId(event.getRoomId()));
2268
- return rustEncryptionInfoToJsEncryptionInfo(_this77.logger, encryptionInfo);
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
- var roomPendingEvents = this.eventsPendingKey.get(roomId);
2021
+ const roomPendingEvents = this.eventsPendingKey.get(roomId);
2279
2022
  if (!roomPendingEvents) return [];
2280
- var sessionPendingEvents = roomPendingEvents.get(sessionId);
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
- var roomId = event.getRoomId();
2032
+ const roomId = event.getRoomId();
2290
2033
  // We shouldn't have events without a room id here.
2291
2034
  if (!roomId) return;
2292
- var roomPendingEvents = this.eventsPendingKey.getOrCreate(roomId);
2293
- var sessionPendingEvents = roomPendingEvents.getOrCreate(event.getWireContent().session_id);
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
- var roomId = event.getRoomId();
2044
+ const roomId = event.getRoomId();
2302
2045
  if (!roomId) return;
2303
- var roomPendingEvents = this.eventsPendingKey.getOrCreate(roomId);
2046
+ const roomPendingEvents = this.eventsPendingKey.getOrCreate(roomId);
2304
2047
  if (!roomPendingEvents) return;
2305
- var sessionPendingEvents = roomPendingEvents.get(event.getWireContent().session_id);
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
- var shieldState = encryptionInfo.shieldState(false);
2336
- var shieldColour;
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
- var shieldReason;
2090
+ let shieldReason;
2348
2091
  switch (shieldState.code) {
2349
2092
  case undefined:
2350
2093
  case null: