@openclaw/matrix 2026.8.1-beta.3 → 2026.8.2

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 (1022) hide show
  1. package/dist/{account-config-BZWN9tGS.js → account-config-CRsKoMqJ.js} +1 -1
  2. package/dist/{account-selection-CWuhuFn1.js → account-selection-DA-jfx22.js} +74 -36
  3. package/dist/{accounts-BCzyubQt.js → accounts-DR1c4xF_.js} +4 -5
  4. package/dist/api.js +5 -5
  5. package/dist/{approval-handler.runtime-CSvueU9P.js → approval-handler.runtime-xcVrZw9o.js} +8 -6
  6. package/dist/{approval-ids-CEcf-EiM.js → approval-ids-hmvhDNBj.js} +1 -1
  7. package/dist/{approval-reaction-auth-CziKXatm.js → approval-reaction-auth-DziFGHSk.js} +2 -2
  8. package/dist/{approval-reactions-tXh9KYrW.js → approval-reactions-1fwEhoK9.js} +1 -1
  9. package/dist/{channel-CzQw5OZN.js → channel-D6-ajB_u.js} +70 -55
  10. package/dist/channel-plugin-api.js +1 -1
  11. package/dist/{channel.runtime-I9pBRQb3.js → channel.runtime-BMA0dG2k.js} +18 -14
  12. package/dist/{channel.setup-aNaa3Uyn.js → channel.setup-OIEzCzSs.js} +28 -21
  13. package/dist/{cli-iR6QJ5U0.js → cli-B6HF7Hmn.js} +43 -33
  14. package/dist/{cli-metadata-BmUYWjuM.js → cli-metadata-Mtzu5-AY.js} +1 -1
  15. package/dist/cli-metadata.js +1 -1
  16. package/dist/{client-D8XghqmX.js → client-B0yMDho1.js} +2 -2
  17. package/dist/{client-BBQdBG7t.js → client-DFsRJEgB.js} +137 -75
  18. package/dist/{client-bootstrap-Co3RlItb.js → client-bootstrap-DjXCKEtg.js} +1 -1
  19. package/dist/{config-update-Bor_Pjsv.js → config-update-BnX26jCO.js} +48 -31
  20. package/dist/contract-api.js +2 -2
  21. package/dist/{credentials-BdAaWuiR.js → credentials-DJj2xs3q.js} +4 -8
  22. package/dist/{credentials-read-B37cQknZ.js → credentials-read-mexhw-Ur.js} +7 -5
  23. package/dist/{credentials-write.runtime-nAV2-5uR.js → credentials-write.runtime-DQt-kgJq.js} +1 -1
  24. package/dist/{crypto-runtime-Bnz3zEcS.js → crypto-runtime-QvlgyCkj.js} +6 -6
  25. package/dist/{deps-CcVJfvRM.js → deps-mtxF2mHI.js} +1 -1
  26. package/dist/{directory-live-DLQzel12.js → directory-live-Drh343TW.js} +8 -6
  27. package/dist/{doctor-EWf9CDso.js → doctor-CJE8wO6y.js} +1 -1
  28. package/dist/{doctor-contract-DEt4O4Zt.js → doctor-contract-HyWFZQVG.js} +5 -4
  29. package/dist/doctor-contract-api.js +7 -7
  30. package/dist/{draft-stream-DQ7QNC-l.js → draft-stream-DhGHVdO4.js} +1 -1
  31. package/dist/{encryption-guidance-DmLY8NiO.js → encryption-guidance-BNcZNQZI.js} +3 -2
  32. package/dist/event-helpers-XRfAbOIh.js +46 -0
  33. package/dist/helper-api.js +1 -1
  34. package/dist/{http-client-CycYxU9-.js → http-client-DOmFvKvB.js} +13 -54
  35. package/dist/{idb-persistence-BM0P27Zg.js → idb-persistence-D4NGNQxt.js} +3 -3
  36. package/dist/{idb-persistence-lock-DAJ49nZX.js → idb-persistence-lock-B3fZXyF_.js} +1 -1
  37. package/dist/{inbound-dedupe-RvSLqdsz.js → inbound-dedupe-Ch33GU06.js} +1 -1
  38. package/dist/index.js +1 -1
  39. package/dist/{messages-DEqg7HVy.js → messages-DlMQaC02.js} +161 -25
  40. package/dist/{monitor-FNrfkuWL.js → monitor-U2LcVtHt.js} +232 -203
  41. package/dist/plugin-entry.handlers.runtime.js +1 -1
  42. package/dist/probe.runtime-CNo-5_iz.js +2 -0
  43. package/dist/{profile-update-BQlE5s2J.js → profile-update-CsyKA9jI.js} +5 -4
  44. package/dist/{profile-D-Wubo0A.js → profile-vmjsmhh4.js} +1 -1
  45. package/dist/{reaction-events-BKOLlnCo.js → reaction-events-lwNc5I1X.js} +10 -8
  46. package/dist/{resolve-targets-e7AI0P75.js → resolve-targets-D3Eakgzs.js} +1 -1
  47. package/dist/{resolver.runtime-V8u0pHEb.js → resolver.runtime-DJQxR35r.js} +1 -1
  48. package/dist/{room-info-BXQA7y10.js → room-info-DIU67XLP.js} +55 -1
  49. package/dist/runtime-api.js +2 -2
  50. package/dist/{sdk-NxK3vzMa.js → sdk-Jl2CgAbJ.js} +573 -47
  51. package/dist/{send-ClHgDZLT.js → send-DfS5ciUL.js} +57 -34
  52. package/dist/session-binding-contract-api.js +1 -1
  53. package/dist/{setup-bootstrap-BGPjbA5N.js → setup-bootstrap-CWoIWudw.js} +3 -3
  54. package/dist/{setup-core-DigrLebY.js → setup-core-CZM496H-.js} +8 -7
  55. package/dist/setup-plugin-api.js +1 -1
  56. package/dist/{setup-surface-Dtn8sAWs.js → setup-surface-DSZtOsWK.js} +84 -79
  57. package/dist/{startup-verification-Cs08ca8u.js → startup-verification-1Ney1mmI.js} +2 -2
  58. package/dist/{storage-BsGuHngK.js → storage-BVf4uucD.js} +5 -4
  59. package/dist/{subagent-hooks-CMoZaARG.js → subagent-hooks-DeICLbU5.js} +5 -1
  60. package/dist/subagent-hooks-api.js +1 -1
  61. package/dist/sync-cache-state-d-A_OhbU.js +234 -0
  62. package/dist/{thread-bindings-BYEGfw3h.js → thread-bindings-2HN2AyLu.js} +4 -4
  63. package/dist/{tool-actions.runtime-ck6IJyP0.js → tool-actions.runtime-CFZZPG5g.js} +267 -213
  64. package/dist/{verification-CabtBTtB.js → verification-CD7k5vE9.js} +2 -2
  65. package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/CHANGELOG.md +29 -3
  66. package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/README.md +23 -14
  67. package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/RELEASING.md +6 -2
  68. package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/download-lib.js +33 -14
  69. package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/index.d.ts +14 -0
  70. package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/package.json +41 -42
  71. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/package.json +1 -1
  72. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm.d.ts +16 -4
  73. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.cjs +25 -9
  74. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.js +23 -7
  75. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.wasm +0 -0
  76. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.wasm.d.ts +1 -0
  77. package/node_modules/markdown-it/README.md +18 -294
  78. package/node_modules/markdown-it/bin/markdown-it.mjs +2 -2
  79. package/node_modules/markdown-it/dist/browser/markdown-it.esm.min.mjs +2972 -0
  80. package/node_modules/markdown-it/dist/browser/markdown-it.esm.min.mjs.map +1 -0
  81. package/node_modules/markdown-it/dist/browser/markdown-it.umd.min.js +14 -0
  82. package/node_modules/markdown-it/dist/browser/markdown-it.umd.min.js.map +1 -0
  83. package/node_modules/markdown-it/dist/markdown-it.cjs.js +4412 -0
  84. package/node_modules/markdown-it/dist/markdown-it.cjs.js.map +1 -0
  85. package/node_modules/markdown-it/dist/markdown-it.d.cts +19 -0
  86. package/node_modules/markdown-it/dist/markdown-it.d.mts +979 -0
  87. package/node_modules/markdown-it/dist/{index.cjs.js → markdown-it.mjs} +1437 -1466
  88. package/node_modules/markdown-it/dist/markdown-it.mjs.map +1 -0
  89. package/node_modules/markdown-it/node_modules/argparse/README.md +46 -41
  90. package/node_modules/markdown-it/node_modules/argparse/lib/_colorize.js +72 -0
  91. package/node_modules/markdown-it/node_modules/argparse/lib/argparse.d.ts +292 -0
  92. package/node_modules/markdown-it/node_modules/argparse/{argparse.js → lib/argparse.js} +1124 -1027
  93. package/node_modules/markdown-it/node_modules/argparse/lib/difflib.js +190 -0
  94. package/node_modules/markdown-it/node_modules/argparse/lib/sub.js +4 -4
  95. package/node_modules/markdown-it/node_modules/argparse/lib/textwrap.js +28 -28
  96. package/node_modules/markdown-it/node_modules/argparse/package.json +17 -10
  97. package/node_modules/markdown-it/node_modules/entities/dist/decode-codepoint.d.ts +8 -0
  98. package/node_modules/markdown-it/node_modules/entities/dist/decode-codepoint.d.ts.map +1 -0
  99. package/node_modules/markdown-it/node_modules/entities/dist/decode-codepoint.js +46 -0
  100. package/node_modules/markdown-it/node_modules/entities/dist/decode-codepoint.js.map +1 -0
  101. package/node_modules/markdown-it/node_modules/entities/{lib/esm → dist}/decode.d.ts +28 -45
  102. package/node_modules/markdown-it/node_modules/entities/dist/decode.d.ts.map +1 -0
  103. package/node_modules/markdown-it/node_modules/entities/{lib/esm → dist}/decode.js +189 -141
  104. package/node_modules/markdown-it/node_modules/entities/dist/decode.js.map +1 -0
  105. package/node_modules/markdown-it/node_modules/entities/{lib/esm → dist}/encode.d.ts +4 -2
  106. package/node_modules/markdown-it/node_modules/entities/dist/encode.d.ts.map +1 -0
  107. package/node_modules/markdown-it/node_modules/entities/dist/encode.js +90 -0
  108. package/node_modules/markdown-it/node_modules/entities/dist/encode.js.map +1 -0
  109. package/node_modules/markdown-it/node_modules/entities/{lib → dist}/escape.d.ts +15 -10
  110. package/node_modules/markdown-it/node_modules/entities/dist/escape.d.ts.map +1 -0
  111. package/node_modules/markdown-it/node_modules/entities/dist/escape.js +132 -0
  112. package/node_modules/markdown-it/node_modules/entities/dist/escape.js.map +1 -0
  113. package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-html.d.ts +3 -0
  114. package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-html.d.ts.map +1 -0
  115. package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-html.js +5 -0
  116. package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-html.js.map +1 -0
  117. package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-xml.d.ts +3 -0
  118. package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-xml.d.ts.map +1 -0
  119. package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-xml.js +5 -0
  120. package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-xml.js.map +1 -0
  121. package/node_modules/markdown-it/node_modules/entities/dist/generated/encode-html.d.ts +5 -0
  122. package/node_modules/markdown-it/node_modules/entities/dist/generated/encode-html.d.ts.map +1 -0
  123. package/node_modules/markdown-it/node_modules/entities/dist/generated/encode-html.js +12 -0
  124. package/node_modules/markdown-it/node_modules/entities/dist/generated/encode-html.js.map +1 -0
  125. package/node_modules/markdown-it/node_modules/entities/{lib → dist}/index.d.ts +14 -21
  126. package/node_modules/markdown-it/node_modules/entities/dist/index.d.ts.map +1 -0
  127. package/node_modules/markdown-it/node_modules/entities/dist/index.js +91 -0
  128. package/node_modules/markdown-it/node_modules/entities/dist/index.js.map +1 -0
  129. package/node_modules/markdown-it/node_modules/entities/dist/internal/bin-trie-flags.d.ts +17 -0
  130. package/node_modules/markdown-it/node_modules/entities/dist/internal/bin-trie-flags.d.ts.map +1 -0
  131. package/node_modules/markdown-it/node_modules/entities/dist/internal/bin-trie-flags.js +18 -0
  132. package/node_modules/markdown-it/node_modules/entities/dist/internal/bin-trie-flags.js.map +1 -0
  133. package/node_modules/markdown-it/node_modules/entities/dist/internal/decode-shared.d.ts +7 -0
  134. package/node_modules/markdown-it/node_modules/entities/dist/internal/decode-shared.d.ts.map +1 -0
  135. package/node_modules/markdown-it/node_modules/entities/dist/internal/decode-shared.js +17 -0
  136. package/node_modules/markdown-it/node_modules/entities/dist/internal/decode-shared.js.map +1 -0
  137. package/node_modules/markdown-it/node_modules/entities/dist/internal/encode-shared.d.ts +33 -0
  138. package/node_modules/markdown-it/node_modules/entities/dist/internal/encode-shared.d.ts.map +1 -0
  139. package/node_modules/markdown-it/node_modules/entities/dist/internal/encode-shared.js +93 -0
  140. package/node_modules/markdown-it/node_modules/entities/dist/internal/encode-shared.js.map +1 -0
  141. package/node_modules/markdown-it/node_modules/entities/package.json +63 -70
  142. package/node_modules/markdown-it/node_modules/entities/readme.md +54 -45
  143. package/node_modules/markdown-it/node_modules/entities/src/decode-codepoint.ts +50 -0
  144. package/node_modules/markdown-it/node_modules/entities/src/decode.ts +671 -0
  145. package/node_modules/markdown-it/node_modules/entities/src/encode.ts +95 -0
  146. package/node_modules/markdown-it/node_modules/entities/src/escape.ts +160 -0
  147. package/node_modules/markdown-it/node_modules/entities/src/generated/decode-data-html.ts +7 -0
  148. package/node_modules/markdown-it/node_modules/entities/src/generated/decode-data-xml.ts +7 -0
  149. package/node_modules/markdown-it/node_modules/entities/src/generated/encode-html.ts +18 -0
  150. package/node_modules/markdown-it/node_modules/entities/src/index.ts +162 -0
  151. package/node_modules/markdown-it/node_modules/entities/src/internal/bin-trie-flags.ts +16 -0
  152. package/node_modules/markdown-it/node_modules/entities/src/internal/decode-shared.ts +18 -0
  153. package/node_modules/markdown-it/node_modules/entities/src/internal/encode-shared.ts +123 -0
  154. package/node_modules/markdown-it/node_modules/linkify-it/README.md +49 -86
  155. package/node_modules/markdown-it/node_modules/linkify-it/build/index.cjs.js +636 -825
  156. package/node_modules/markdown-it/node_modules/linkify-it/build/index.cjs.js.map +1 -0
  157. package/node_modules/markdown-it/node_modules/linkify-it/build/index.d.ts +236 -0
  158. package/node_modules/markdown-it/node_modules/linkify-it/build/index.mjs +538 -0
  159. package/node_modules/markdown-it/node_modules/linkify-it/build/index.mjs.map +1 -0
  160. package/node_modules/markdown-it/node_modules/linkify-it/package.json +23 -20
  161. package/node_modules/markdown-it/node_modules/uc.micro/README.md +18 -1
  162. package/node_modules/markdown-it/node_modules/uc.micro/build/index.cjs.js +13 -18
  163. package/node_modules/markdown-it/node_modules/uc.micro/build/index.d.ts +6 -0
  164. package/node_modules/markdown-it/node_modules/uc.micro/build/index.mjs +8 -0
  165. package/node_modules/markdown-it/node_modules/uc.micro/package.json +12 -17
  166. package/node_modules/markdown-it/package.json +48 -30
  167. package/node_modules/matrix-js-sdk/CHANGELOG.md +33 -0
  168. package/node_modules/matrix-js-sdk/lib/@types/PushRules.d.ts.map +1 -1
  169. package/node_modules/matrix-js-sdk/lib/@types/PushRules.js +0 -5
  170. package/node_modules/matrix-js-sdk/lib/@types/PushRules.js.map +1 -1
  171. package/node_modules/matrix-js-sdk/lib/@types/auth.d.ts +0 -5
  172. package/node_modules/matrix-js-sdk/lib/@types/auth.d.ts.map +1 -1
  173. package/node_modules/matrix-js-sdk/lib/@types/auth.js +0 -11
  174. package/node_modules/matrix-js-sdk/lib/@types/auth.js.map +1 -1
  175. package/node_modules/matrix-js-sdk/lib/@types/beacon.d.ts +1 -1
  176. package/node_modules/matrix-js-sdk/lib/@types/beacon.js +1 -1
  177. package/node_modules/matrix-js-sdk/lib/@types/beacon.js.map +1 -1
  178. package/node_modules/matrix-js-sdk/lib/@types/crypto.d.ts.map +1 -1
  179. package/node_modules/matrix-js-sdk/lib/@types/crypto.js.map +1 -1
  180. package/node_modules/matrix-js-sdk/lib/@types/event.d.ts +3 -1
  181. package/node_modules/matrix-js-sdk/lib/@types/event.d.ts.map +1 -1
  182. package/node_modules/matrix-js-sdk/lib/@types/event.js +1 -0
  183. package/node_modules/matrix-js-sdk/lib/@types/event.js.map +1 -1
  184. package/node_modules/matrix-js-sdk/lib/@types/extensible_events.d.ts.map +1 -1
  185. package/node_modules/matrix-js-sdk/lib/@types/extensible_events.js.map +1 -1
  186. package/node_modules/matrix-js-sdk/lib/@types/matrix-sdk-crypto-wasm.d.js.map +1 -1
  187. package/node_modules/matrix-js-sdk/lib/@types/media.js.map +1 -1
  188. package/node_modules/matrix-js-sdk/lib/@types/partials.d.ts.map +1 -1
  189. package/node_modules/matrix-js-sdk/lib/@types/partials.js.map +1 -1
  190. package/node_modules/matrix-js-sdk/lib/@types/requests.d.ts.map +1 -1
  191. package/node_modules/matrix-js-sdk/lib/@types/requests.js +0 -5
  192. package/node_modules/matrix-js-sdk/lib/@types/requests.js.map +1 -1
  193. package/node_modules/matrix-js-sdk/lib/@types/search.d.ts.map +1 -1
  194. package/node_modules/matrix-js-sdk/lib/@types/search.js +0 -3
  195. package/node_modules/matrix-js-sdk/lib/@types/search.js.map +1 -1
  196. package/node_modules/matrix-js-sdk/lib/@types/spaces.d.ts.map +1 -1
  197. package/node_modules/matrix-js-sdk/lib/@types/spaces.js.map +1 -1
  198. package/node_modules/matrix-js-sdk/lib/@types/synapse.d.ts.map +1 -1
  199. package/node_modules/matrix-js-sdk/lib/@types/synapse.js.map +1 -1
  200. package/node_modules/matrix-js-sdk/lib/@types/threepids.js.map +1 -1
  201. package/node_modules/matrix-js-sdk/lib/@types/type-guards.d.ts +43 -0
  202. package/node_modules/matrix-js-sdk/lib/@types/type-guards.d.ts.map +1 -0
  203. package/node_modules/matrix-js-sdk/lib/@types/type-guards.js +104 -0
  204. package/node_modules/matrix-js-sdk/lib/@types/type-guards.js.map +1 -0
  205. package/node_modules/matrix-js-sdk/lib/NamespacedValue.d.ts.map +1 -1
  206. package/node_modules/matrix-js-sdk/lib/ReEmitter.d.ts.map +1 -1
  207. package/node_modules/matrix-js-sdk/lib/ToDeviceMessageQueue.d.ts.map +1 -1
  208. package/node_modules/matrix-js-sdk/lib/ToDeviceMessageQueue.js +0 -2
  209. package/node_modules/matrix-js-sdk/lib/ToDeviceMessageQueue.js.map +1 -1
  210. package/node_modules/matrix-js-sdk/lib/autodiscovery.d.ts.map +1 -1
  211. package/node_modules/matrix-js-sdk/lib/autodiscovery.js.map +1 -1
  212. package/node_modules/matrix-js-sdk/lib/browser-index.d.ts.map +1 -1
  213. package/node_modules/matrix-js-sdk/lib/browser-index.js +3 -1
  214. package/node_modules/matrix-js-sdk/lib/browser-index.js.map +1 -1
  215. package/node_modules/matrix-js-sdk/lib/capabilityPoller.d.ts.map +1 -1
  216. package/node_modules/matrix-js-sdk/lib/client.d.ts +23 -21
  217. package/node_modules/matrix-js-sdk/lib/client.d.ts.map +1 -1
  218. package/node_modules/matrix-js-sdk/lib/client.js +44 -96
  219. package/node_modules/matrix-js-sdk/lib/client.js.map +1 -1
  220. package/node_modules/matrix-js-sdk/lib/common-crypto/CryptoBackend.d.ts.map +1 -1
  221. package/node_modules/matrix-js-sdk/lib/common-crypto/key-passphrase.d.ts.map +1 -1
  222. package/node_modules/matrix-js-sdk/lib/common-crypto/key-passphrase.js +1 -4
  223. package/node_modules/matrix-js-sdk/lib/common-crypto/key-passphrase.js.map +1 -1
  224. package/node_modules/matrix-js-sdk/lib/content-helpers.d.ts.map +1 -1
  225. package/node_modules/matrix-js-sdk/lib/crypto/store/base.d.ts.map +1 -1
  226. package/node_modules/matrix-js-sdk/lib/crypto/store/base.js +0 -9
  227. package/node_modules/matrix-js-sdk/lib/crypto/store/base.js.map +1 -1
  228. package/node_modules/matrix-js-sdk/lib/crypto/store/indexeddb-crypto-store-backend.d.ts.map +1 -1
  229. package/node_modules/matrix-js-sdk/lib/crypto/store/indexeddb-crypto-store-backend.js +2 -1
  230. package/node_modules/matrix-js-sdk/lib/crypto/store/indexeddb-crypto-store-backend.js.map +1 -1
  231. package/node_modules/matrix-js-sdk/lib/crypto/store/indexeddb-crypto-store.d.ts.map +1 -1
  232. package/node_modules/matrix-js-sdk/lib/crypto/store/indexeddb-crypto-store.js +1 -1
  233. package/node_modules/matrix-js-sdk/lib/crypto/store/indexeddb-crypto-store.js.map +1 -1
  234. package/node_modules/matrix-js-sdk/lib/crypto/store/localStorage-crypto-store.d.ts.map +1 -1
  235. package/node_modules/matrix-js-sdk/lib/crypto/store/localStorage-crypto-store.js +0 -2
  236. package/node_modules/matrix-js-sdk/lib/crypto/store/localStorage-crypto-store.js.map +1 -1
  237. package/node_modules/matrix-js-sdk/lib/crypto/store/memory-crypto-store.d.ts.map +1 -1
  238. package/node_modules/matrix-js-sdk/lib/crypto/store/memory-crypto-store.js.map +1 -1
  239. package/node_modules/matrix-js-sdk/lib/crypto-api/index.d.ts +1 -1
  240. package/node_modules/matrix-js-sdk/lib/crypto-api/index.d.ts.map +1 -1
  241. package/node_modules/matrix-js-sdk/lib/crypto-api/index.js.map +1 -1
  242. package/node_modules/matrix-js-sdk/lib/crypto-api/keybackup.d.ts +13 -6
  243. package/node_modules/matrix-js-sdk/lib/crypto-api/keybackup.d.ts.map +1 -1
  244. package/node_modules/matrix-js-sdk/lib/crypto-api/keybackup.js.map +1 -1
  245. package/node_modules/matrix-js-sdk/lib/crypto-api/verification.d.ts +23 -5
  246. package/node_modules/matrix-js-sdk/lib/crypto-api/verification.d.ts.map +1 -1
  247. package/node_modules/matrix-js-sdk/lib/crypto-api/verification.js.map +1 -1
  248. package/node_modules/matrix-js-sdk/lib/embedded.d.ts +16 -0
  249. package/node_modules/matrix-js-sdk/lib/embedded.d.ts.map +1 -1
  250. package/node_modules/matrix-js-sdk/lib/embedded.js +19 -11
  251. package/node_modules/matrix-js-sdk/lib/embedded.js.map +1 -1
  252. package/node_modules/matrix-js-sdk/lib/errors.d.ts.map +1 -1
  253. package/node_modules/matrix-js-sdk/lib/extensible_events_v1/ExtensibleEvent.d.ts.map +1 -1
  254. package/node_modules/matrix-js-sdk/lib/extensible_events_v1/InvalidEventError.d.ts.map +1 -1
  255. package/node_modules/matrix-js-sdk/lib/extensible_events_v1/MessageEvent.d.ts.map +1 -1
  256. package/node_modules/matrix-js-sdk/lib/extensible_events_v1/PollEndEvent.d.ts.map +1 -1
  257. package/node_modules/matrix-js-sdk/lib/extensible_events_v1/PollResponseEvent.d.ts.map +1 -1
  258. package/node_modules/matrix-js-sdk/lib/extensible_events_v1/PollStartEvent.d.ts.map +1 -1
  259. package/node_modules/matrix-js-sdk/lib/feature.d.ts.map +1 -1
  260. package/node_modules/matrix-js-sdk/lib/feature.js +0 -3
  261. package/node_modules/matrix-js-sdk/lib/feature.js.map +1 -1
  262. package/node_modules/matrix-js-sdk/lib/filter-component.d.ts.map +1 -1
  263. package/node_modules/matrix-js-sdk/lib/filter-component.js +2 -5
  264. package/node_modules/matrix-js-sdk/lib/filter-component.js.map +1 -1
  265. package/node_modules/matrix-js-sdk/lib/filter.d.ts.map +1 -1
  266. package/node_modules/matrix-js-sdk/lib/filter.js +0 -4
  267. package/node_modules/matrix-js-sdk/lib/filter.js.map +1 -1
  268. package/node_modules/matrix-js-sdk/lib/http-api/errors.d.ts.map +1 -1
  269. package/node_modules/matrix-js-sdk/lib/http-api/fetch.d.ts +1 -1
  270. package/node_modules/matrix-js-sdk/lib/http-api/fetch.d.ts.map +1 -1
  271. package/node_modules/matrix-js-sdk/lib/http-api/fetch.js.map +1 -1
  272. package/node_modules/matrix-js-sdk/lib/http-api/index.d.ts +1 -7
  273. package/node_modules/matrix-js-sdk/lib/http-api/index.d.ts.map +1 -1
  274. package/node_modules/matrix-js-sdk/lib/http-api/index.js +0 -15
  275. package/node_modules/matrix-js-sdk/lib/http-api/index.js.map +1 -1
  276. package/node_modules/matrix-js-sdk/lib/http-api/interface.d.ts +0 -9
  277. package/node_modules/matrix-js-sdk/lib/http-api/interface.d.ts.map +1 -1
  278. package/node_modules/matrix-js-sdk/lib/http-api/interface.js +0 -2
  279. package/node_modules/matrix-js-sdk/lib/http-api/interface.js.map +1 -1
  280. package/node_modules/matrix-js-sdk/lib/http-api/refresh.d.ts.map +1 -1
  281. package/node_modules/matrix-js-sdk/lib/http-api/refresh.js +0 -3
  282. package/node_modules/matrix-js-sdk/lib/http-api/refresh.js.map +1 -1
  283. package/node_modules/matrix-js-sdk/lib/index.d.ts.map +1 -1
  284. package/node_modules/matrix-js-sdk/lib/interactive-auth.d.ts.map +1 -1
  285. package/node_modules/matrix-js-sdk/lib/interactive-auth.js +5 -6
  286. package/node_modules/matrix-js-sdk/lib/interactive-auth.js.map +1 -1
  287. package/node_modules/matrix-js-sdk/lib/logger.d.ts.map +1 -1
  288. package/node_modules/matrix-js-sdk/lib/logger.js +0 -2
  289. package/node_modules/matrix-js-sdk/lib/logger.js.map +1 -1
  290. package/node_modules/matrix-js-sdk/lib/matrix.d.ts +1 -1
  291. package/node_modules/matrix-js-sdk/lib/matrix.d.ts.map +1 -1
  292. package/node_modules/matrix-js-sdk/lib/matrix.js +1 -1
  293. package/node_modules/matrix-js-sdk/lib/matrix.js.map +1 -1
  294. package/node_modules/matrix-js-sdk/lib/matrixrtc/CallMembership.d.ts +3 -3
  295. package/node_modules/matrix-js-sdk/lib/matrixrtc/CallMembership.d.ts.map +1 -1
  296. package/node_modules/matrix-js-sdk/lib/matrixrtc/CallMembership.js +5 -5
  297. package/node_modules/matrix-js-sdk/lib/matrixrtc/CallMembership.js.map +1 -1
  298. package/node_modules/matrix-js-sdk/lib/matrixrtc/LivekitTransport.d.ts.map +1 -1
  299. package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSession.d.ts +18 -1
  300. package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSession.d.ts.map +1 -1
  301. package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSession.js +56 -4
  302. package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSession.js.map +1 -1
  303. package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSessionManager.d.ts +14 -1
  304. package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSessionManager.d.ts.map +1 -1
  305. package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSessionManager.js +20 -1
  306. package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSessionManager.js.map +1 -1
  307. package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManager.d.ts.map +1 -1
  308. package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManager.js +9 -6
  309. package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManager.js.map +1 -1
  310. package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManagerActionScheduler.d.ts.map +1 -1
  311. package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManagerActionScheduler.js.map +1 -1
  312. package/node_modules/matrix-js-sdk/lib/matrixrtc/RTCEncryptionManager.d.ts.map +1 -1
  313. package/node_modules/matrix-js-sdk/lib/matrixrtc/RTCEncryptionManager.js.map +1 -1
  314. package/node_modules/matrix-js-sdk/lib/matrixrtc/ToDeviceKeyTransport.d.ts.map +1 -1
  315. package/node_modules/matrix-js-sdk/lib/matrixrtc/ToDeviceKeyTransport.js.map +1 -1
  316. package/node_modules/matrix-js-sdk/lib/matrixrtc/index.d.ts +1 -1
  317. package/node_modules/matrix-js-sdk/lib/matrixrtc/index.d.ts.map +1 -1
  318. package/node_modules/matrix-js-sdk/lib/matrixrtc/index.js +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.d.ts.map +1 -1
  321. package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/rtc.d.ts +6 -3
  322. package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/rtc.d.ts.map +1 -1
  323. package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/rtc.js +7 -4
  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.d.ts.map +1 -1
  326. package/node_modules/matrix-js-sdk/lib/matrixrtc/types.d.ts +19 -6
  327. package/node_modules/matrix-js-sdk/lib/matrixrtc/types.d.ts.map +1 -1
  328. package/node_modules/matrix-js-sdk/lib/matrixrtc/types.js +11 -1
  329. package/node_modules/matrix-js-sdk/lib/matrixrtc/types.js.map +1 -1
  330. package/node_modules/matrix-js-sdk/lib/matrixrtc/utils.d.ts +0 -1
  331. package/node_modules/matrix-js-sdk/lib/matrixrtc/utils.d.ts.map +1 -1
  332. package/node_modules/matrix-js-sdk/lib/matrixrtc/utils.js +0 -1
  333. package/node_modules/matrix-js-sdk/lib/matrixrtc/utils.js.map +1 -1
  334. package/node_modules/matrix-js-sdk/lib/models/MSC3089Branch.d.ts.map +1 -1
  335. package/node_modules/matrix-js-sdk/lib/models/MSC3089TreeSpace.d.ts.map +1 -1
  336. package/node_modules/matrix-js-sdk/lib/models/beacon.d.ts.map +1 -1
  337. package/node_modules/matrix-js-sdk/lib/models/device.d.ts.map +1 -1
  338. package/node_modules/matrix-js-sdk/lib/models/event-context.d.ts.map +1 -1
  339. package/node_modules/matrix-js-sdk/lib/models/event-timeline-set.d.ts.map +1 -1
  340. package/node_modules/matrix-js-sdk/lib/models/event-timeline-set.js +3 -3
  341. package/node_modules/matrix-js-sdk/lib/models/event-timeline-set.js.map +1 -1
  342. package/node_modules/matrix-js-sdk/lib/models/event-timeline.d.ts.map +1 -1
  343. package/node_modules/matrix-js-sdk/lib/models/event.d.ts.map +1 -1
  344. package/node_modules/matrix-js-sdk/lib/models/event.js +0 -6
  345. package/node_modules/matrix-js-sdk/lib/models/event.js.map +1 -1
  346. package/node_modules/matrix-js-sdk/lib/models/invites-ignorer.d.ts.map +1 -1
  347. package/node_modules/matrix-js-sdk/lib/models/invites-ignorer.js.map +1 -1
  348. package/node_modules/matrix-js-sdk/lib/models/poll.d.ts.map +1 -1
  349. package/node_modules/matrix-js-sdk/lib/models/poll.js.map +1 -1
  350. package/node_modules/matrix-js-sdk/lib/models/read-receipt.d.ts.map +1 -1
  351. package/node_modules/matrix-js-sdk/lib/models/read-receipt.js.map +1 -1
  352. package/node_modules/matrix-js-sdk/lib/models/related-relations.d.ts.map +1 -1
  353. package/node_modules/matrix-js-sdk/lib/models/relations-container.d.ts +10 -0
  354. package/node_modules/matrix-js-sdk/lib/models/relations-container.d.ts.map +1 -1
  355. package/node_modules/matrix-js-sdk/lib/models/relations-container.js +39 -17
  356. package/node_modules/matrix-js-sdk/lib/models/relations-container.js.map +1 -1
  357. package/node_modules/matrix-js-sdk/lib/models/relations.d.ts.map +1 -1
  358. package/node_modules/matrix-js-sdk/lib/models/relations.js +1 -1
  359. package/node_modules/matrix-js-sdk/lib/models/relations.js.map +1 -1
  360. package/node_modules/matrix-js-sdk/lib/models/room-member.d.ts.map +1 -1
  361. package/node_modules/matrix-js-sdk/lib/models/room-receipts.d.ts.map +1 -1
  362. package/node_modules/matrix-js-sdk/lib/models/room-retention.d.ts.map +1 -1
  363. package/node_modules/matrix-js-sdk/lib/models/room-state.d.ts.map +1 -1
  364. package/node_modules/matrix-js-sdk/lib/models/room-state.js.map +1 -1
  365. package/node_modules/matrix-js-sdk/lib/models/room-sticky-events.d.ts.map +1 -1
  366. package/node_modules/matrix-js-sdk/lib/models/room-summary.d.ts.map +1 -1
  367. package/node_modules/matrix-js-sdk/lib/models/room.d.ts.map +1 -1
  368. package/node_modules/matrix-js-sdk/lib/models/room.js +9 -9
  369. package/node_modules/matrix-js-sdk/lib/models/room.js.map +1 -1
  370. package/node_modules/matrix-js-sdk/lib/models/search-result.d.ts.map +1 -1
  371. package/node_modules/matrix-js-sdk/lib/models/thread.d.ts +5 -2
  372. package/node_modules/matrix-js-sdk/lib/models/thread.d.ts.map +1 -1
  373. package/node_modules/matrix-js-sdk/lib/models/thread.js +36 -3
  374. package/node_modules/matrix-js-sdk/lib/models/thread.js.map +1 -1
  375. package/node_modules/matrix-js-sdk/lib/models/typed-event-emitter.d.ts.map +1 -1
  376. package/node_modules/matrix-js-sdk/lib/models/user.d.ts.map +1 -1
  377. package/node_modules/matrix-js-sdk/lib/oauth/authorize.d.ts +133 -0
  378. package/node_modules/matrix-js-sdk/lib/oauth/authorize.d.ts.map +1 -0
  379. package/node_modules/matrix-js-sdk/lib/oauth/authorize.js +193 -0
  380. package/node_modules/matrix-js-sdk/lib/oauth/authorize.js.map +1 -0
  381. package/node_modules/matrix-js-sdk/lib/oauth/discover.d.ts +58 -0
  382. package/node_modules/matrix-js-sdk/lib/oauth/discover.d.ts.map +1 -0
  383. package/node_modules/matrix-js-sdk/lib/oauth/discover.js +35 -0
  384. package/node_modules/matrix-js-sdk/lib/oauth/discover.js.map +1 -0
  385. package/node_modules/matrix-js-sdk/lib/oauth/error.d.ts +19 -0
  386. package/node_modules/matrix-js-sdk/lib/oauth/error.d.ts.map +1 -0
  387. package/node_modules/matrix-js-sdk/lib/oauth/error.js +36 -0
  388. package/node_modules/matrix-js-sdk/lib/oauth/error.js.map +1 -0
  389. package/node_modules/matrix-js-sdk/lib/oauth/index.d.ts +87 -0
  390. package/node_modules/matrix-js-sdk/lib/oauth/index.d.ts.map +1 -0
  391. package/node_modules/matrix-js-sdk/lib/oauth/index.js +236 -0
  392. package/node_modules/matrix-js-sdk/lib/oauth/index.js.map +1 -0
  393. package/node_modules/matrix-js-sdk/lib/oauth/register.d.ts +136 -0
  394. package/node_modules/matrix-js-sdk/lib/oauth/register.d.ts.map +1 -0
  395. package/node_modules/matrix-js-sdk/lib/oauth/register.js +73 -0
  396. package/node_modules/matrix-js-sdk/lib/oauth/register.js.map +1 -0
  397. package/node_modules/matrix-js-sdk/lib/oauth/tokenRefresher.d.ts +21 -0
  398. package/node_modules/matrix-js-sdk/lib/oauth/tokenRefresher.d.ts.map +1 -0
  399. package/node_modules/matrix-js-sdk/lib/oauth/tokenRefresher.js +68 -0
  400. package/node_modules/matrix-js-sdk/lib/oauth/tokenRefresher.js.map +1 -0
  401. package/node_modules/matrix-js-sdk/lib/pollingCachedValue.d.ts +77 -0
  402. package/node_modules/matrix-js-sdk/lib/pollingCachedValue.d.ts.map +1 -0
  403. package/node_modules/matrix-js-sdk/lib/pollingCachedValue.js +160 -0
  404. package/node_modules/matrix-js-sdk/lib/pollingCachedValue.js.map +1 -0
  405. package/node_modules/matrix-js-sdk/lib/pushprocessor.d.ts.map +1 -1
  406. package/node_modules/matrix-js-sdk/lib/pushprocessor.js.map +1 -1
  407. package/node_modules/matrix-js-sdk/lib/realtime-callbacks.js +0 -1
  408. package/node_modules/matrix-js-sdk/lib/realtime-callbacks.js.map +1 -1
  409. package/node_modules/matrix-js-sdk/lib/receipt-accumulator.d.ts.map +1 -1
  410. package/node_modules/matrix-js-sdk/lib/receipt-accumulator.js.map +1 -1
  411. package/node_modules/matrix-js-sdk/lib/rendezvous/MSC4108SignInWithQR.d.ts +7 -7
  412. package/node_modules/matrix-js-sdk/lib/rendezvous/MSC4108SignInWithQR.d.ts.map +1 -1
  413. package/node_modules/matrix-js-sdk/lib/rendezvous/MSC4108SignInWithQR.js +13 -14
  414. package/node_modules/matrix-js-sdk/lib/rendezvous/MSC4108SignInWithQR.js.map +1 -1
  415. package/node_modules/matrix-js-sdk/lib/rendezvous/RendezvousError.d.ts.map +1 -1
  416. package/node_modules/matrix-js-sdk/lib/rendezvous/channels/MSC4108SecureChannel.d.ts.map +1 -1
  417. package/node_modules/matrix-js-sdk/lib/rendezvous/index.d.ts.map +1 -1
  418. package/node_modules/matrix-js-sdk/lib/rendezvous/index.js.map +1 -1
  419. package/node_modules/matrix-js-sdk/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts.map +1 -1
  420. package/node_modules/matrix-js-sdk/lib/rendezvous/transports/MSC4108RendezvousSession.js +0 -1
  421. package/node_modules/matrix-js-sdk/lib/rendezvous/transports/MSC4108RendezvousSession.js.map +1 -1
  422. package/node_modules/matrix-js-sdk/lib/retentionPolicy.d.ts.map +1 -1
  423. package/node_modules/matrix-js-sdk/lib/room-hierarchy.d.ts.map +1 -1
  424. package/node_modules/matrix-js-sdk/lib/rtcTransportsCachedValue.d.ts +9 -0
  425. package/node_modules/matrix-js-sdk/lib/rtcTransportsCachedValue.d.ts.map +1 -0
  426. package/node_modules/matrix-js-sdk/lib/rtcTransportsCachedValue.js +38 -0
  427. package/node_modules/matrix-js-sdk/lib/rtcTransportsCachedValue.js.map +1 -0
  428. package/node_modules/matrix-js-sdk/lib/rust-crypto/CrossSigningIdentity.d.ts.map +1 -1
  429. package/node_modules/matrix-js-sdk/lib/rust-crypto/DehydratedDeviceManager.d.ts.map +1 -1
  430. package/node_modules/matrix-js-sdk/lib/rust-crypto/DehydratedDeviceManager.js +11 -13
  431. package/node_modules/matrix-js-sdk/lib/rust-crypto/DehydratedDeviceManager.js.map +1 -1
  432. package/node_modules/matrix-js-sdk/lib/rust-crypto/KeyClaimManager.d.ts.map +1 -1
  433. package/node_modules/matrix-js-sdk/lib/rust-crypto/OutgoingRequestProcessor.d.ts.map +1 -1
  434. package/node_modules/matrix-js-sdk/lib/rust-crypto/OutgoingRequestProcessor.js +0 -2
  435. package/node_modules/matrix-js-sdk/lib/rust-crypto/OutgoingRequestProcessor.js.map +1 -1
  436. package/node_modules/matrix-js-sdk/lib/rust-crypto/OutgoingRequestsManager.d.ts.map +1 -1
  437. package/node_modules/matrix-js-sdk/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts.map +1 -1
  438. package/node_modules/matrix-js-sdk/lib/rust-crypto/PerSessionKeyBackupDownloader.js.map +1 -1
  439. package/node_modules/matrix-js-sdk/lib/rust-crypto/RoomEncryptor.d.ts.map +1 -1
  440. package/node_modules/matrix-js-sdk/lib/rust-crypto/backup.d.ts +23 -4
  441. package/node_modules/matrix-js-sdk/lib/rust-crypto/backup.d.ts.map +1 -1
  442. package/node_modules/matrix-js-sdk/lib/rust-crypto/backup.js +62 -21
  443. package/node_modules/matrix-js-sdk/lib/rust-crypto/backup.js.map +1 -1
  444. package/node_modules/matrix-js-sdk/lib/rust-crypto/device-converter.d.ts.map +1 -1
  445. package/node_modules/matrix-js-sdk/lib/rust-crypto/device-converter.js +1 -0
  446. package/node_modules/matrix-js-sdk/lib/rust-crypto/device-converter.js.map +1 -1
  447. package/node_modules/matrix-js-sdk/lib/rust-crypto/index.d.ts +17 -4
  448. package/node_modules/matrix-js-sdk/lib/rust-crypto/index.d.ts.map +1 -1
  449. package/node_modules/matrix-js-sdk/lib/rust-crypto/index.js +21 -4
  450. package/node_modules/matrix-js-sdk/lib/rust-crypto/index.js.map +1 -1
  451. package/node_modules/matrix-js-sdk/lib/rust-crypto/libolm_migration.d.ts.map +1 -1
  452. package/node_modules/matrix-js-sdk/lib/rust-crypto/libolm_migration.js +0 -2
  453. package/node_modules/matrix-js-sdk/lib/rust-crypto/libolm_migration.js.map +1 -1
  454. package/node_modules/matrix-js-sdk/lib/rust-crypto/rust-crypto.d.ts.map +1 -1
  455. package/node_modules/matrix-js-sdk/lib/rust-crypto/rust-crypto.js +0 -3
  456. package/node_modules/matrix-js-sdk/lib/rust-crypto/rust-crypto.js.map +1 -1
  457. package/node_modules/matrix-js-sdk/lib/rust-crypto/verification.d.ts.map +1 -1
  458. package/node_modules/matrix-js-sdk/lib/scheduler.d.ts.map +1 -1
  459. package/node_modules/matrix-js-sdk/lib/scheduler.js +0 -3
  460. package/node_modules/matrix-js-sdk/lib/scheduler.js.map +1 -1
  461. package/node_modules/matrix-js-sdk/lib/secret-storage.d.ts.map +1 -1
  462. package/node_modules/matrix-js-sdk/lib/serverCapabilities.d.ts.map +1 -1
  463. package/node_modules/matrix-js-sdk/lib/sliding-sync-sdk.d.ts.map +1 -1
  464. package/node_modules/matrix-js-sdk/lib/sliding-sync-sdk.js +6 -0
  465. package/node_modules/matrix-js-sdk/lib/sliding-sync-sdk.js.map +1 -1
  466. package/node_modules/matrix-js-sdk/lib/sliding-sync.d.ts.map +1 -1
  467. package/node_modules/matrix-js-sdk/lib/sliding-sync.js +3 -0
  468. package/node_modules/matrix-js-sdk/lib/sliding-sync.js.map +1 -1
  469. package/node_modules/matrix-js-sdk/lib/store/indexeddb-local-backend.d.ts.map +1 -1
  470. package/node_modules/matrix-js-sdk/lib/store/indexeddb-local-backend.js +1 -1
  471. package/node_modules/matrix-js-sdk/lib/store/indexeddb-local-backend.js.map +1 -1
  472. package/node_modules/matrix-js-sdk/lib/store/indexeddb-remote-backend.d.ts.map +1 -1
  473. package/node_modules/matrix-js-sdk/lib/store/indexeddb-store-worker.d.ts.map +1 -1
  474. package/node_modules/matrix-js-sdk/lib/store/indexeddb-store-worker.js +1 -0
  475. package/node_modules/matrix-js-sdk/lib/store/indexeddb-store-worker.js.map +1 -1
  476. package/node_modules/matrix-js-sdk/lib/store/indexeddb.d.ts.map +1 -1
  477. package/node_modules/matrix-js-sdk/lib/store/indexeddb.js +0 -2
  478. package/node_modules/matrix-js-sdk/lib/store/indexeddb.js.map +1 -1
  479. package/node_modules/matrix-js-sdk/lib/store/memory.d.ts.map +1 -1
  480. package/node_modules/matrix-js-sdk/lib/store/memory.js +7 -9
  481. package/node_modules/matrix-js-sdk/lib/store/memory.js.map +1 -1
  482. package/node_modules/matrix-js-sdk/lib/store/stub.d.ts.map +1 -1
  483. package/node_modules/matrix-js-sdk/lib/sync-accumulator.d.ts.map +1 -1
  484. package/node_modules/matrix-js-sdk/lib/sync-accumulator.js +1 -5
  485. package/node_modules/matrix-js-sdk/lib/sync-accumulator.js.map +1 -1
  486. package/node_modules/matrix-js-sdk/lib/sync.d.ts.map +1 -1
  487. package/node_modules/matrix-js-sdk/lib/sync.js +9 -9
  488. package/node_modules/matrix-js-sdk/lib/sync.js.map +1 -1
  489. package/node_modules/matrix-js-sdk/lib/testing.d.ts +2 -10
  490. package/node_modules/matrix-js-sdk/lib/testing.d.ts.map +1 -1
  491. package/node_modules/matrix-js-sdk/lib/testing.js +4 -19
  492. package/node_modules/matrix-js-sdk/lib/testing.js.map +1 -1
  493. package/node_modules/matrix-js-sdk/lib/timeline-window.d.ts.map +1 -1
  494. package/node_modules/matrix-js-sdk/lib/timeline-window.js +0 -1
  495. package/node_modules/matrix-js-sdk/lib/timeline-window.js.map +1 -1
  496. package/node_modules/matrix-js-sdk/lib/utils/internal/deriveKeys.d.ts.map +1 -1
  497. package/node_modules/matrix-js-sdk/lib/utils/internal/deriveKeys.js +0 -1
  498. package/node_modules/matrix-js-sdk/lib/utils/internal/deriveKeys.js.map +1 -1
  499. package/node_modules/matrix-js-sdk/lib/utils.d.ts +1 -1
  500. package/node_modules/matrix-js-sdk/lib/utils.d.ts.map +1 -1
  501. package/node_modules/matrix-js-sdk/lib/utils.js +1 -0
  502. package/node_modules/matrix-js-sdk/lib/utils.js.map +1 -1
  503. package/node_modules/matrix-js-sdk/lib/webrtc/call.d.ts.map +1 -1
  504. package/node_modules/matrix-js-sdk/lib/webrtc/call.js.map +1 -1
  505. package/node_modules/matrix-js-sdk/lib/webrtc/callEventHandler.d.ts.map +1 -1
  506. package/node_modules/matrix-js-sdk/lib/webrtc/callEventTypes.d.ts.map +1 -1
  507. package/node_modules/matrix-js-sdk/lib/webrtc/callEventTypes.js +0 -5
  508. package/node_modules/matrix-js-sdk/lib/webrtc/callEventTypes.js.map +1 -1
  509. package/node_modules/matrix-js-sdk/lib/webrtc/callFeed.d.ts.map +1 -1
  510. package/node_modules/matrix-js-sdk/lib/webrtc/groupCall.d.ts.map +1 -1
  511. package/node_modules/matrix-js-sdk/lib/webrtc/groupCall.js.map +1 -1
  512. package/node_modules/matrix-js-sdk/lib/webrtc/groupCallEventHandler.d.ts.map +1 -1
  513. package/node_modules/matrix-js-sdk/lib/webrtc/mediaHandler.d.ts.map +1 -1
  514. package/node_modules/matrix-js-sdk/lib/webrtc/mediaHandler.js.map +1 -1
  515. package/node_modules/matrix-js-sdk/lib/webrtc/stats/callFeedStatsReporter.d.ts.map +1 -1
  516. package/node_modules/matrix-js-sdk/lib/webrtc/stats/callStatsReportGatherer.d.ts.map +1 -1
  517. package/node_modules/matrix-js-sdk/lib/webrtc/stats/callStatsReportGatherer.js.map +1 -1
  518. package/node_modules/matrix-js-sdk/lib/webrtc/stats/connectionStatsBuilder.d.ts.map +1 -1
  519. package/node_modules/matrix-js-sdk/lib/webrtc/stats/connectionStatsReportBuilder.d.ts.map +1 -1
  520. package/node_modules/matrix-js-sdk/lib/webrtc/stats/groupCallStats.d.ts.map +1 -1
  521. package/node_modules/matrix-js-sdk/lib/webrtc/stats/media/mediaSsrcHandler.d.ts.map +1 -1
  522. package/node_modules/matrix-js-sdk/lib/webrtc/stats/media/mediaTrackHandler.d.ts.map +1 -1
  523. package/node_modules/matrix-js-sdk/lib/webrtc/stats/media/mediaTrackStats.d.ts.map +1 -1
  524. package/node_modules/matrix-js-sdk/lib/webrtc/stats/media/mediaTrackStatsHandler.d.ts.map +1 -1
  525. package/node_modules/matrix-js-sdk/lib/webrtc/stats/statsReportEmitter.d.ts.map +1 -1
  526. package/node_modules/matrix-js-sdk/lib/webrtc/stats/summaryStatsReportGatherer.d.ts.map +1 -1
  527. package/node_modules/matrix-js-sdk/lib/webrtc/stats/trackStatsBuilder.d.ts.map +1 -1
  528. package/node_modules/matrix-js-sdk/lib/webrtc/stats/transportStatsBuilder.d.ts.map +1 -1
  529. package/node_modules/matrix-js-sdk/lib/webrtc/stats/transportStatsBuilder.js.map +1 -1
  530. package/node_modules/matrix-js-sdk/lib/webrtc/stats/valueFormatter.d.ts.map +1 -1
  531. package/node_modules/matrix-js-sdk/lib/wellKnownCachedValue.d.ts +8 -0
  532. package/node_modules/matrix-js-sdk/lib/wellKnownCachedValue.d.ts.map +1 -0
  533. package/node_modules/matrix-js-sdk/lib/wellKnownCachedValue.js +34 -0
  534. package/node_modules/matrix-js-sdk/lib/wellKnownCachedValue.js.map +1 -0
  535. package/node_modules/matrix-js-sdk/node_modules/content-type/README.md +2 -0
  536. package/node_modules/matrix-js-sdk/node_modules/content-type/dist/index.d.ts +20 -0
  537. package/node_modules/matrix-js-sdk/node_modules/content-type/dist/index.js +20 -14
  538. package/node_modules/matrix-js-sdk/node_modules/content-type/dist/index.js.map +1 -1
  539. package/node_modules/matrix-js-sdk/node_modules/content-type/package.json +1 -1
  540. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/dist/api.js +227 -131
  541. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/dist/api.min.js +1 -1
  542. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/ClientWidgetApi.d.ts +1 -0
  543. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/ClientWidgetApi.js +142 -97
  544. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/ClientWidgetApi.js.map +1 -1
  545. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/WidgetApi.d.ts +15 -0
  546. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/WidgetApi.js +61 -19
  547. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/WidgetApi.js.map +1 -1
  548. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/driver/WidgetDriver.d.ts +15 -11
  549. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/driver/WidgetDriver.js +19 -13
  550. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/driver/WidgetDriver.js.map +1 -1
  551. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/index.d.ts +1 -0
  552. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/index.js.map +1 -1
  553. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/interfaces/ApiVersion.d.ts +2 -1
  554. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/interfaces/ApiVersion.js +2 -1
  555. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/interfaces/ApiVersion.js.map +1 -1
  556. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/interfaces/Capabilities.d.ts +5 -1
  557. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/interfaces/Capabilities.js +1 -0
  558. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/interfaces/Capabilities.js.map +1 -1
  559. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/interfaces/RtcTransportsAction.d.ts +24 -0
  560. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/interfaces/RtcTransportsAction.js +6 -0
  561. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/interfaces/RtcTransportsAction.js.map +1 -0
  562. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/interfaces/SendEventAction.d.ts +1 -0
  563. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/interfaces/SendEventAction.js.map +1 -1
  564. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/interfaces/WidgetApiAction.d.ts +5 -1
  565. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/interfaces/WidgetApiAction.js +1 -0
  566. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/interfaces/WidgetApiAction.js.map +1 -1
  567. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/package.json +1 -1
  568. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/src/ClientWidgetApi.ts +37 -14
  569. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/src/WidgetApi.ts +69 -0
  570. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/src/driver/WidgetDriver.ts +19 -12
  571. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/src/index.ts +1 -0
  572. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/src/interfaces/ApiVersion.ts +2 -0
  573. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/src/interfaces/Capabilities.ts +4 -0
  574. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/src/interfaces/RtcTransportsAction.ts +44 -0
  575. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/src/interfaces/SendEventAction.ts +1 -0
  576. package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/src/interfaces/WidgetApiAction.ts +5 -0
  577. package/node_modules/matrix-js-sdk/package.json +10 -12
  578. package/node_modules/matrix-js-sdk/src/@types/PushRules.ts +0 -5
  579. package/node_modules/matrix-js-sdk/src/@types/auth.ts +0 -12
  580. package/node_modules/matrix-js-sdk/src/@types/beacon.ts +1 -1
  581. package/node_modules/matrix-js-sdk/src/@types/crypto.ts +2 -6
  582. package/node_modules/matrix-js-sdk/src/@types/event.ts +3 -0
  583. package/node_modules/matrix-js-sdk/src/@types/extensible_events.ts +5 -6
  584. package/node_modules/matrix-js-sdk/src/@types/matrix-sdk-crypto-wasm.d.ts +0 -1
  585. package/node_modules/matrix-js-sdk/src/@types/media.ts +1 -1
  586. package/node_modules/matrix-js-sdk/src/@types/partials.ts +0 -2
  587. package/node_modules/matrix-js-sdk/src/@types/requests.ts +0 -5
  588. package/node_modules/matrix-js-sdk/src/@types/search.ts +0 -2
  589. package/node_modules/matrix-js-sdk/src/@types/spaces.ts +0 -2
  590. package/node_modules/matrix-js-sdk/src/@types/synapse.ts +0 -2
  591. package/node_modules/matrix-js-sdk/src/@types/threepids.ts +2 -2
  592. package/node_modules/matrix-js-sdk/src/@types/type-guards.ts +126 -0
  593. package/node_modules/matrix-js-sdk/src/ToDeviceMessageQueue.ts +0 -2
  594. package/node_modules/matrix-js-sdk/src/autodiscovery.ts +2 -2
  595. package/node_modules/matrix-js-sdk/src/browser-index.ts +4 -4
  596. package/node_modules/matrix-js-sdk/src/client.ts +86 -133
  597. package/node_modules/matrix-js-sdk/src/common-crypto/key-passphrase.ts +1 -2
  598. package/node_modules/matrix-js-sdk/src/crypto/store/base.ts +1 -8
  599. package/node_modules/matrix-js-sdk/src/crypto/store/indexeddb-crypto-store-backend.ts +3 -2
  600. package/node_modules/matrix-js-sdk/src/crypto/store/indexeddb-crypto-store.ts +1 -3
  601. package/node_modules/matrix-js-sdk/src/crypto/store/localStorage-crypto-store.ts +0 -1
  602. package/node_modules/matrix-js-sdk/src/crypto/store/memory-crypto-store.ts +1 -1
  603. package/node_modules/matrix-js-sdk/src/crypto-api/index.ts +1 -1
  604. package/node_modules/matrix-js-sdk/src/crypto-api/keybackup.ts +14 -7
  605. package/node_modules/matrix-js-sdk/src/crypto-api/verification.ts +23 -5
  606. package/node_modules/matrix-js-sdk/src/embedded.ts +34 -16
  607. package/node_modules/matrix-js-sdk/src/feature.ts +0 -3
  608. package/node_modules/matrix-js-sdk/src/filter-component.ts +1 -2
  609. package/node_modules/matrix-js-sdk/src/filter.ts +0 -3
  610. package/node_modules/matrix-js-sdk/src/http-api/fetch.ts +1 -1
  611. package/node_modules/matrix-js-sdk/src/http-api/index.ts +1 -23
  612. package/node_modules/matrix-js-sdk/src/http-api/interface.ts +0 -12
  613. package/node_modules/matrix-js-sdk/src/http-api/refresh.ts +0 -1
  614. package/node_modules/matrix-js-sdk/src/interactive-auth.ts +4 -4
  615. package/node_modules/matrix-js-sdk/src/logger.ts +0 -2
  616. package/node_modules/matrix-js-sdk/src/matrix.ts +1 -1
  617. package/node_modules/matrix-js-sdk/src/matrixrtc/CallMembership.ts +5 -5
  618. package/node_modules/matrix-js-sdk/src/matrixrtc/MatrixRTCSession.ts +73 -6
  619. package/node_modules/matrix-js-sdk/src/matrixrtc/MatrixRTCSessionManager.ts +21 -2
  620. package/node_modules/matrix-js-sdk/src/matrixrtc/MembershipManager.ts +9 -6
  621. package/node_modules/matrix-js-sdk/src/matrixrtc/MembershipManagerActionScheduler.ts +1 -1
  622. package/node_modules/matrix-js-sdk/src/matrixrtc/RTCEncryptionManager.ts +2 -2
  623. package/node_modules/matrix-js-sdk/src/matrixrtc/ToDeviceKeyTransport.ts +3 -3
  624. package/node_modules/matrix-js-sdk/src/matrixrtc/index.ts +1 -1
  625. package/node_modules/matrix-js-sdk/src/matrixrtc/membershipData/rtc.ts +19 -8
  626. package/node_modules/matrix-js-sdk/src/matrixrtc/types.ts +24 -7
  627. package/node_modules/matrix-js-sdk/src/matrixrtc/utils.ts +0 -2
  628. package/node_modules/matrix-js-sdk/src/models/event-timeline-set.ts +3 -3
  629. package/node_modules/matrix-js-sdk/src/models/event.ts +7 -13
  630. package/node_modules/matrix-js-sdk/src/models/invites-ignorer.ts +1 -1
  631. package/node_modules/matrix-js-sdk/src/models/poll.ts +1 -1
  632. package/node_modules/matrix-js-sdk/src/models/read-receipt.ts +1 -1
  633. package/node_modules/matrix-js-sdk/src/models/relations-container.ts +55 -19
  634. package/node_modules/matrix-js-sdk/src/models/relations.ts +1 -1
  635. package/node_modules/matrix-js-sdk/src/models/room-state.ts +0 -3
  636. package/node_modules/matrix-js-sdk/src/models/room.ts +15 -15
  637. package/node_modules/matrix-js-sdk/src/models/thread.ts +51 -6
  638. package/node_modules/matrix-js-sdk/src/oauth/authorize.ts +274 -0
  639. package/node_modules/matrix-js-sdk/src/oauth/discover.ts +102 -0
  640. package/node_modules/matrix-js-sdk/src/{oidc → oauth}/error.ts +8 -7
  641. package/node_modules/matrix-js-sdk/src/oauth/index.ts +297 -0
  642. package/node_modules/matrix-js-sdk/src/oauth/register.ts +166 -0
  643. package/node_modules/matrix-js-sdk/src/oauth/tokenRefresher.ts +77 -0
  644. package/node_modules/matrix-js-sdk/src/pollingCachedValue.ts +184 -0
  645. package/node_modules/matrix-js-sdk/src/pushprocessor.ts +3 -3
  646. package/node_modules/matrix-js-sdk/src/realtime-callbacks.ts +0 -1
  647. package/node_modules/matrix-js-sdk/src/receipt-accumulator.ts +1 -2
  648. package/node_modules/matrix-js-sdk/src/rendezvous/MSC4108SignInWithQR.ts +14 -16
  649. package/node_modules/matrix-js-sdk/src/rendezvous/index.ts +2 -2
  650. package/node_modules/matrix-js-sdk/src/rendezvous/transports/MSC4108RendezvousSession.ts +0 -1
  651. package/node_modules/matrix-js-sdk/src/rtcTransportsCachedValue.ts +40 -0
  652. package/node_modules/matrix-js-sdk/src/rust-crypto/DehydratedDeviceManager.ts +14 -13
  653. package/node_modules/matrix-js-sdk/src/rust-crypto/OutgoingRequestProcessor.ts +0 -1
  654. package/node_modules/matrix-js-sdk/src/rust-crypto/PerSessionKeyBackupDownloader.ts +1 -1
  655. package/node_modules/matrix-js-sdk/src/rust-crypto/backup.ts +67 -33
  656. package/node_modules/matrix-js-sdk/src/rust-crypto/device-converter.ts +1 -0
  657. package/node_modules/matrix-js-sdk/src/rust-crypto/index.ts +32 -23
  658. package/node_modules/matrix-js-sdk/src/rust-crypto/libolm_migration.ts +1 -3
  659. package/node_modules/matrix-js-sdk/src/rust-crypto/rust-crypto.ts +3 -6
  660. package/node_modules/matrix-js-sdk/src/scheduler.ts +0 -3
  661. package/node_modules/matrix-js-sdk/src/sliding-sync-sdk.ts +4 -1
  662. package/node_modules/matrix-js-sdk/src/sliding-sync.ts +3 -1
  663. package/node_modules/matrix-js-sdk/src/store/indexeddb-local-backend.ts +1 -1
  664. package/node_modules/matrix-js-sdk/src/store/indexeddb-store-worker.ts +1 -0
  665. package/node_modules/matrix-js-sdk/src/store/indexeddb.ts +0 -2
  666. package/node_modules/matrix-js-sdk/src/store/memory.ts +7 -9
  667. package/node_modules/matrix-js-sdk/src/sync-accumulator.ts +1 -3
  668. package/node_modules/matrix-js-sdk/src/sync.ts +13 -14
  669. package/node_modules/matrix-js-sdk/src/testing.ts +3 -22
  670. package/node_modules/matrix-js-sdk/src/timeline-window.ts +0 -1
  671. package/node_modules/matrix-js-sdk/src/utils/internal/deriveKeys.ts +0 -1
  672. package/node_modules/matrix-js-sdk/src/utils.ts +3 -2
  673. package/node_modules/matrix-js-sdk/src/webrtc/call.ts +6 -6
  674. package/node_modules/matrix-js-sdk/src/webrtc/callEventTypes.ts +0 -5
  675. package/node_modules/matrix-js-sdk/src/webrtc/groupCall.ts +7 -7
  676. package/node_modules/matrix-js-sdk/src/webrtc/mediaHandler.ts +1 -1
  677. package/node_modules/matrix-js-sdk/src/webrtc/stats/callStatsReportGatherer.ts +2 -2
  678. package/node_modules/matrix-js-sdk/src/webrtc/stats/transportStatsBuilder.ts +1 -1
  679. package/node_modules/matrix-js-sdk/src/wellKnownCachedValue.ts +34 -0
  680. package/node_modules/music-metadata/LICENSE.txt +9 -9
  681. package/node_modules/music-metadata/README.md +878 -878
  682. package/node_modules/music-metadata/lib/ParseError.d.ts +1 -1
  683. package/node_modules/music-metadata/lib/ParseError.js +1 -1
  684. package/node_modules/music-metadata/lib/asf/AsfObject.d.ts +1 -4
  685. package/node_modules/music-metadata/lib/asf/AsfObject.js +66 -30
  686. package/node_modules/music-metadata/lib/asf/AsfParser.d.ts +5 -1
  687. package/node_modules/music-metadata/lib/asf/AsfParser.js +94 -25
  688. package/node_modules/music-metadata/lib/dsf/DsfChunk.js +2 -2
  689. package/node_modules/music-metadata/lib/dsf/DsfParser.js +38 -13
  690. package/node_modules/music-metadata/lib/mp4/AtomToken.js +2 -1
  691. package/node_modules/music-metadata/lib/mp4/MP4Parser.js +34 -7
  692. package/node_modules/music-metadata/lib/ogg/speex/SpeexStream.d.ts +7 -0
  693. package/node_modules/music-metadata/lib/ogg/speex/SpeexStream.js +13 -0
  694. package/node_modules/music-metadata/lib/riff/RiffChunk.js +1 -1
  695. package/node_modules/music-metadata/node_modules/content-type/README.md +2 -0
  696. package/node_modules/music-metadata/node_modules/content-type/dist/index.d.ts +20 -0
  697. package/node_modules/music-metadata/node_modules/content-type/dist/index.js +20 -14
  698. package/node_modules/music-metadata/node_modules/content-type/dist/index.js.map +1 -1
  699. package/node_modules/music-metadata/node_modules/content-type/package.json +1 -1
  700. package/node_modules/music-metadata/node_modules/file-type/package.json +1 -1
  701. package/node_modules/music-metadata/node_modules/file-type/readme.md +3 -0
  702. package/node_modules/music-metadata/node_modules/file-type/source/detectors/zip.js +6 -1
  703. package/node_modules/music-metadata/node_modules/file-type/source/index.d.ts +3 -0
  704. package/node_modules/music-metadata/node_modules/file-type/source/index.js +25 -13
  705. package/node_modules/music-metadata/package.json +156 -156
  706. package/node_modules/typebox/build/format/date.d.mts +1 -1
  707. package/node_modules/typebox/build/format/date.mjs +1 -1
  708. package/node_modules/typebox/build/format/date_time.d.mts +2 -2
  709. package/node_modules/typebox/build/format/date_time.mjs +3 -3
  710. package/node_modules/typebox/build/format/email.d.mts +1 -1
  711. package/node_modules/typebox/build/format/email.mjs +2 -2
  712. package/node_modules/typebox/build/format/hostname.mjs +2 -10
  713. package/node_modules/typebox/build/format/idn_email.d.mts +1 -1
  714. package/node_modules/typebox/build/format/idn_email.mjs +3 -3
  715. package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -0
  716. package/node_modules/typebox/build/format/idn_hostname.mjs +3 -11
  717. package/node_modules/typebox/build/format/idna/format/bidi.d.mts +3 -0
  718. package/node_modules/typebox/build/format/idna/format/bidi.mjs +98 -0
  719. package/node_modules/typebox/build/format/idna/format/puny.d.mts +3 -0
  720. package/node_modules/typebox/build/format/idna/format/puny.mjs +144 -0
  721. package/node_modules/typebox/build/format/idna/hostname.d.mts +1 -0
  722. package/node_modules/typebox/build/format/idna/hostname.mjs +16 -0
  723. package/node_modules/typebox/build/format/idna/idn-hostname.d.mts +1 -0
  724. package/node_modules/typebox/build/format/idna/idn-hostname.mjs +41 -0
  725. package/node_modules/typebox/build/format/idna/index.d.mts +2 -0
  726. package/node_modules/typebox/build/format/idna/index.mjs +2 -0
  727. package/node_modules/typebox/build/format/idna/label/ascii.d.mts +1 -0
  728. package/node_modules/typebox/build/format/idna/label/ascii.mjs +9 -0
  729. package/node_modules/typebox/build/format/idna/label/puny.d.mts +1 -0
  730. package/node_modules/typebox/build/format/idna/label/puny.mjs +28 -0
  731. package/node_modules/typebox/build/format/idna/label/unicode.d.mts +1 -0
  732. package/node_modules/typebox/build/format/idna/label/unicode.mjs +106 -0
  733. package/node_modules/typebox/build/format/idna/pattern/pattern.d.mts +30 -0
  734. package/node_modules/typebox/build/format/idna/pattern/pattern.mjs +70 -0
  735. package/node_modules/typebox/build/format/ipv4.d.mts +0 -1
  736. package/node_modules/typebox/build/format/ipv4.mjs +2 -32
  737. package/node_modules/typebox/build/format/ipv6.mjs +2 -61
  738. package/node_modules/typebox/build/format/iri.d.mts +2 -2
  739. package/node_modules/typebox/build/format/iri.mjs +26 -8
  740. package/node_modules/typebox/build/format/iri_reference.d.mts +2 -2
  741. package/node_modules/typebox/build/format/iri_reference.mjs +9 -55
  742. package/node_modules/typebox/build/format/regex.d.mts +1 -2
  743. package/node_modules/typebox/build/format/regex.mjs +2 -6
  744. package/node_modules/typebox/build/format/time.d.mts +2 -2
  745. package/node_modules/typebox/build/format/time.mjs +19 -14
  746. package/node_modules/typebox/build/format/uri.d.mts +1 -1
  747. package/node_modules/typebox/build/format/uri.mjs +3 -130
  748. package/node_modules/typebox/build/format/uri_reference.d.mts +1 -1
  749. package/node_modules/typebox/build/format/uri_reference.mjs +2 -3
  750. package/node_modules/typebox/build/format/uri_template.d.mts +2 -3
  751. package/node_modules/typebox/build/format/uri_template.mjs +4 -5
  752. package/node_modules/typebox/build/format/url.d.mts +3 -3
  753. package/node_modules/typebox/build/format/url.mjs +4 -5
  754. package/node_modules/typebox/build/guard/emit.d.mts +3 -1
  755. package/node_modules/typebox/build/guard/emit.mjs +12 -5
  756. package/node_modules/typebox/build/guard/guard.d.mts +8 -2
  757. package/node_modules/typebox/build/guard/guard.mjs +25 -4
  758. package/node_modules/typebox/build/guard/string.d.mts +2 -2
  759. package/node_modules/typebox/build/guard/string.mjs +7 -7
  760. package/node_modules/typebox/build/schema/engine/_context.mjs +3 -3
  761. package/node_modules/typebox/build/schema/engine/_functions.mjs +1 -2
  762. package/node_modules/typebox/build/schema/engine/_regexp.d.mts +2 -0
  763. package/node_modules/typebox/build/schema/engine/_regexp.mjs +4 -0
  764. package/node_modules/typebox/build/schema/engine/_stack.mjs +12 -13
  765. package/node_modules/typebox/build/schema/engine/additionalItems.mjs +17 -7
  766. package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +4 -3
  767. package/node_modules/typebox/build/schema/engine/contains.mjs +18 -6
  768. package/node_modules/typebox/build/schema/engine/enum.mjs +1 -1
  769. package/node_modules/typebox/build/schema/engine/items.mjs +26 -6
  770. package/node_modules/typebox/build/schema/engine/maxContains.mjs +3 -3
  771. package/node_modules/typebox/build/schema/engine/minContains.mjs +14 -4
  772. package/node_modules/typebox/build/schema/engine/not.mjs +4 -2
  773. package/node_modules/typebox/build/schema/engine/oneOf.mjs +7 -6
  774. package/node_modules/typebox/build/schema/engine/pattern.mjs +3 -2
  775. package/node_modules/typebox/build/schema/engine/patternProperties.mjs +4 -3
  776. package/node_modules/typebox/build/schema/engine/ref.mjs +1 -7
  777. package/node_modules/typebox/build/schema/engine/schema.mjs +13 -4
  778. package/node_modules/typebox/build/schema/engine/type.mjs +1 -1
  779. package/node_modules/typebox/build/schema/resolve/resolve.d.mts +4 -1
  780. package/node_modules/typebox/build/schema/resolve/resolve.mjs +202 -1
  781. package/node_modules/typebox/build/schema/static/propertyNames.d.mts +5 -0
  782. package/node_modules/typebox/build/schema/static/propertyNames.mjs +3 -0
  783. package/node_modules/typebox/build/schema/static/schema.d.mts +3 -0
  784. package/node_modules/typebox/build/schema/types/index.d.mts +0 -2
  785. package/node_modules/typebox/build/schema/types/index.mjs +0 -2
  786. package/node_modules/typebox/build/system/memory/clone.mjs +14 -11
  787. package/node_modules/typebox/build/system/memory/discard.mjs +6 -5
  788. package/node_modules/typebox/build/system/settings/settings.d.mts +9 -0
  789. package/node_modules/typebox/build/system/settings/settings.mjs +2 -0
  790. package/node_modules/typebox/build/type/engine/call/distribute_arguments.d.mts +6 -1
  791. package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +16 -3
  792. package/node_modules/typebox/build/type/engine/call/instantiate.mjs +34 -4
  793. package/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +5 -5
  794. package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +20 -26
  795. package/node_modules/typebox/build/type/engine/evaluate/compare.d.mts +6 -10
  796. package/node_modules/typebox/build/type/engine/evaluate/compare.mjs +9 -13
  797. package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +7 -4
  798. package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +12 -19
  799. package/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +4 -20
  800. package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +8 -20
  801. package/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +4 -4
  802. package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +11 -8
  803. package/node_modules/typebox/build/type/engine/evaluate/flatten.d.mts +1 -1
  804. package/node_modules/typebox/build/type/engine/evaluate/flatten.mjs +3 -4
  805. package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +17 -2
  806. package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +26 -6
  807. package/node_modules/typebox/build/type/engine/exclude/operation.mjs +3 -4
  808. package/node_modules/typebox/build/type/engine/extract/operation.d.mts +1 -1
  809. package/node_modules/typebox/build/type/engine/extract/operation.mjs +3 -4
  810. package/node_modules/typebox/build/type/engine/priority/priority.d.mts +2 -2
  811. package/node_modules/typebox/build/type/engine/priority/priority.mjs +3 -4
  812. package/node_modules/typebox/build/type/script/mapping.d.mts +32 -29
  813. package/node_modules/typebox/build/type/script/mapping.mjs +18 -25
  814. package/node_modules/typebox/build/type/script/parser.d.mts +19 -25
  815. package/node_modules/typebox/build/type/script/parser.mjs +27 -23
  816. package/node_modules/typebox/build/value/errors/errors.d.mts +2 -2
  817. package/node_modules/typebox/build/value/errors/errors.mjs +1 -1
  818. package/node_modules/typebox/package.json +27 -27
  819. package/node_modules/typebox/readme.md +79 -82
  820. package/openclaw.plugin.json +16 -1
  821. package/package.json +10 -10
  822. package/dist/env-auth-MVS-Vv41.js +0 -64
  823. package/dist/file-sync-store-DjskBX2o.js +0 -436
  824. package/dist/media-text-Dh-DpTc3.js +0 -149
  825. package/dist/probe.runtime-NIJZYqc2.js +0 -2
  826. package/dist/recovery-key-store-CognuDys.js +0 -276
  827. package/dist/runtime-api-BGO16Fu8.js +0 -21
  828. package/dist/timeout-abort-signal-DMrgRFIy.js +0 -2
  829. package/node_modules/markdown-it/dist/index.cjs.js.map +0 -1
  830. package/node_modules/markdown-it/dist/markdown-it.js +0 -3975
  831. package/node_modules/markdown-it/dist/markdown-it.js.map +0 -1
  832. package/node_modules/markdown-it/dist/markdown-it.min.js +0 -3
  833. package/node_modules/markdown-it/dist/markdown-it.min.js.map +0 -1
  834. package/node_modules/markdown-it/index.mjs +0 -1
  835. package/node_modules/markdown-it/lib/common/html_blocks.mjs +0 -67
  836. package/node_modules/markdown-it/lib/common/html_re.mjs +0 -25
  837. package/node_modules/markdown-it/lib/common/utils.mjs +0 -324
  838. package/node_modules/markdown-it/lib/helpers/index.mjs +0 -11
  839. package/node_modules/markdown-it/lib/helpers/parse_link_destination.mjs +0 -77
  840. package/node_modules/markdown-it/lib/helpers/parse_link_label.mjs +0 -49
  841. package/node_modules/markdown-it/lib/helpers/parse_link_title.mjs +0 -66
  842. package/node_modules/markdown-it/lib/index.mjs +0 -565
  843. package/node_modules/markdown-it/lib/parser_block.mjs +0 -134
  844. package/node_modules/markdown-it/lib/parser_core.mjs +0 -62
  845. package/node_modules/markdown-it/lib/parser_inline.mjs +0 -197
  846. package/node_modules/markdown-it/lib/presets/commonmark.mjs +0 -88
  847. package/node_modules/markdown-it/lib/presets/default.mjs +0 -47
  848. package/node_modules/markdown-it/lib/presets/zero.mjs +0 -70
  849. package/node_modules/markdown-it/lib/renderer.mjs +0 -322
  850. package/node_modules/markdown-it/lib/ruler.mjs +0 -340
  851. package/node_modules/markdown-it/lib/rules_block/blockquote.mjs +0 -209
  852. package/node_modules/markdown-it/lib/rules_block/code.mjs +0 -30
  853. package/node_modules/markdown-it/lib/rules_block/fence.mjs +0 -94
  854. package/node_modules/markdown-it/lib/rules_block/heading.mjs +0 -51
  855. package/node_modules/markdown-it/lib/rules_block/hr.mjs +0 -40
  856. package/node_modules/markdown-it/lib/rules_block/html_block.mjs +0 -80
  857. package/node_modules/markdown-it/lib/rules_block/lheading.mjs +0 -85
  858. package/node_modules/markdown-it/lib/rules_block/list.mjs +0 -331
  859. package/node_modules/markdown-it/lib/rules_block/paragraph.mjs +0 -48
  860. package/node_modules/markdown-it/lib/rules_block/reference.mjs +0 -212
  861. package/node_modules/markdown-it/lib/rules_block/state_block.mjs +0 -220
  862. package/node_modules/markdown-it/lib/rules_block/table.mjs +0 -228
  863. package/node_modules/markdown-it/lib/rules_core/block.mjs +0 -13
  864. package/node_modules/markdown-it/lib/rules_core/inline.mjs +0 -11
  865. package/node_modules/markdown-it/lib/rules_core/linkify.mjs +0 -134
  866. package/node_modules/markdown-it/lib/rules_core/normalize.mjs +0 -17
  867. package/node_modules/markdown-it/lib/rules_core/replacements.mjs +0 -101
  868. package/node_modules/markdown-it/lib/rules_core/smartquotes.mjs +0 -209
  869. package/node_modules/markdown-it/lib/rules_core/state_core.mjs +0 -17
  870. package/node_modules/markdown-it/lib/rules_core/text_join.mjs +0 -43
  871. package/node_modules/markdown-it/lib/rules_inline/autolink.mjs +0 -72
  872. package/node_modules/markdown-it/lib/rules_inline/backticks.mjs +0 -60
  873. package/node_modules/markdown-it/lib/rules_inline/balance_pairs.mjs +0 -124
  874. package/node_modules/markdown-it/lib/rules_inline/emphasis.mjs +0 -123
  875. package/node_modules/markdown-it/lib/rules_inline/entity.mjs +0 -51
  876. package/node_modules/markdown-it/lib/rules_inline/escape.mjs +0 -83
  877. package/node_modules/markdown-it/lib/rules_inline/fragments_join.mjs +0 -38
  878. package/node_modules/markdown-it/lib/rules_inline/html_inline.mjs +0 -50
  879. package/node_modules/markdown-it/lib/rules_inline/image.mjs +0 -138
  880. package/node_modules/markdown-it/lib/rules_inline/link.mjs +0 -139
  881. package/node_modules/markdown-it/lib/rules_inline/linkify.mjs +0 -63
  882. package/node_modules/markdown-it/lib/rules_inline/newline.mjs +0 -42
  883. package/node_modules/markdown-it/lib/rules_inline/state_inline.mjs +0 -154
  884. package/node_modules/markdown-it/lib/rules_inline/strikethrough.mjs +0 -127
  885. package/node_modules/markdown-it/lib/rules_inline/text.mjs +0 -86
  886. package/node_modules/markdown-it/lib/token.mjs +0 -191
  887. package/node_modules/markdown-it/node_modules/argparse/CHANGELOG.md +0 -216
  888. package/node_modules/markdown-it/node_modules/entities/lib/decode.d.ts +0 -211
  889. package/node_modules/markdown-it/node_modules/entities/lib/decode.d.ts.map +0 -1
  890. package/node_modules/markdown-it/node_modules/entities/lib/decode.js +0 -536
  891. package/node_modules/markdown-it/node_modules/entities/lib/decode.js.map +0 -1
  892. package/node_modules/markdown-it/node_modules/entities/lib/decode_codepoint.d.ts +0 -19
  893. package/node_modules/markdown-it/node_modules/entities/lib/decode_codepoint.d.ts.map +0 -1
  894. package/node_modules/markdown-it/node_modules/entities/lib/decode_codepoint.js +0 -76
  895. package/node_modules/markdown-it/node_modules/entities/lib/decode_codepoint.js.map +0 -1
  896. package/node_modules/markdown-it/node_modules/entities/lib/encode.d.ts +0 -22
  897. package/node_modules/markdown-it/node_modules/entities/lib/encode.d.ts.map +0 -1
  898. package/node_modules/markdown-it/node_modules/entities/lib/encode.js +0 -77
  899. package/node_modules/markdown-it/node_modules/entities/lib/encode.js.map +0 -1
  900. package/node_modules/markdown-it/node_modules/entities/lib/escape.d.ts.map +0 -1
  901. package/node_modules/markdown-it/node_modules/entities/lib/escape.js +0 -122
  902. package/node_modules/markdown-it/node_modules/entities/lib/escape.js.map +0 -1
  903. package/node_modules/markdown-it/node_modules/entities/lib/esm/decode.d.ts.map +0 -1
  904. package/node_modules/markdown-it/node_modules/entities/lib/esm/decode.js.map +0 -1
  905. package/node_modules/markdown-it/node_modules/entities/lib/esm/decode_codepoint.d.ts +0 -19
  906. package/node_modules/markdown-it/node_modules/entities/lib/esm/decode_codepoint.d.ts.map +0 -1
  907. package/node_modules/markdown-it/node_modules/entities/lib/esm/decode_codepoint.js +0 -71
  908. package/node_modules/markdown-it/node_modules/entities/lib/esm/decode_codepoint.js.map +0 -1
  909. package/node_modules/markdown-it/node_modules/entities/lib/esm/encode.d.ts.map +0 -1
  910. package/node_modules/markdown-it/node_modules/entities/lib/esm/encode.js +0 -69
  911. package/node_modules/markdown-it/node_modules/entities/lib/esm/encode.js.map +0 -1
  912. package/node_modules/markdown-it/node_modules/entities/lib/esm/escape.d.ts +0 -43
  913. package/node_modules/markdown-it/node_modules/entities/lib/esm/escape.d.ts.map +0 -1
  914. package/node_modules/markdown-it/node_modules/entities/lib/esm/escape.js +0 -116
  915. package/node_modules/markdown-it/node_modules/entities/lib/esm/escape.js.map +0 -1
  916. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-html.d.ts +0 -3
  917. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-html.d.ts.map +0 -1
  918. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-html.js +0 -7
  919. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-html.js.map +0 -1
  920. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-xml.d.ts +0 -3
  921. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-xml.d.ts.map +0 -1
  922. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-xml.js +0 -7
  923. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-xml.js.map +0 -1
  924. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/encode-html.d.ts +0 -8
  925. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/encode-html.d.ts.map +0 -1
  926. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/encode-html.js +0 -10
  927. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/encode-html.js.map +0 -1
  928. package/node_modules/markdown-it/node_modules/entities/lib/esm/index.d.ts +0 -96
  929. package/node_modules/markdown-it/node_modules/entities/lib/esm/index.d.ts.map +0 -1
  930. package/node_modules/markdown-it/node_modules/entities/lib/esm/index.js +0 -99
  931. package/node_modules/markdown-it/node_modules/entities/lib/esm/index.js.map +0 -1
  932. package/node_modules/markdown-it/node_modules/entities/lib/esm/package.json +0 -1
  933. package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-html.d.ts +0 -3
  934. package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-html.d.ts.map +0 -1
  935. package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-html.js +0 -9
  936. package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-html.js.map +0 -1
  937. package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-xml.d.ts +0 -3
  938. package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-xml.d.ts.map +0 -1
  939. package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-xml.js +0 -9
  940. package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-xml.js.map +0 -1
  941. package/node_modules/markdown-it/node_modules/entities/lib/generated/encode-html.d.ts +0 -8
  942. package/node_modules/markdown-it/node_modules/entities/lib/generated/encode-html.d.ts.map +0 -1
  943. package/node_modules/markdown-it/node_modules/entities/lib/generated/encode-html.js +0 -12
  944. package/node_modules/markdown-it/node_modules/entities/lib/generated/encode-html.js.map +0 -1
  945. package/node_modules/markdown-it/node_modules/entities/lib/index.d.ts.map +0 -1
  946. package/node_modules/markdown-it/node_modules/entities/lib/index.js +0 -126
  947. package/node_modules/markdown-it/node_modules/entities/lib/index.js.map +0 -1
  948. package/node_modules/markdown-it/node_modules/linkify-it/index.mjs +0 -646
  949. package/node_modules/markdown-it/node_modules/linkify-it/lib/re.mjs +0 -193
  950. package/node_modules/markdown-it/node_modules/uc.micro/categories/Cc/regex.mjs +0 -1
  951. package/node_modules/markdown-it/node_modules/uc.micro/categories/Cf/regex.mjs +0 -1
  952. package/node_modules/markdown-it/node_modules/uc.micro/categories/P/regex.mjs +0 -1
  953. package/node_modules/markdown-it/node_modules/uc.micro/categories/S/regex.mjs +0 -1
  954. package/node_modules/markdown-it/node_modules/uc.micro/categories/Z/regex.mjs +0 -1
  955. package/node_modules/markdown-it/node_modules/uc.micro/index.mjs +0 -8
  956. package/node_modules/markdown-it/node_modules/uc.micro/properties/Any/regex.mjs +0 -1
  957. package/node_modules/matrix-js-sdk/lib/oidc/authorize.d.ts +0 -157
  958. package/node_modules/matrix-js-sdk/lib/oidc/authorize.d.ts.map +0 -1
  959. package/node_modules/matrix-js-sdk/lib/oidc/authorize.js +0 -365
  960. package/node_modules/matrix-js-sdk/lib/oidc/authorize.js.map +0 -1
  961. package/node_modules/matrix-js-sdk/lib/oidc/discovery.d.ts +0 -22
  962. package/node_modules/matrix-js-sdk/lib/oidc/discovery.d.ts.map +0 -1
  963. package/node_modules/matrix-js-sdk/lib/oidc/discovery.js +0 -65
  964. package/node_modules/matrix-js-sdk/lib/oidc/discovery.js.map +0 -1
  965. package/node_modules/matrix-js-sdk/lib/oidc/error.d.ts +0 -18
  966. package/node_modules/matrix-js-sdk/lib/oidc/error.d.ts.map +0 -1
  967. package/node_modules/matrix-js-sdk/lib/oidc/error.js +0 -35
  968. package/node_modules/matrix-js-sdk/lib/oidc/error.js.map +0 -1
  969. package/node_modules/matrix-js-sdk/lib/oidc/index.d.ts +0 -16
  970. package/node_modules/matrix-js-sdk/lib/oidc/index.d.ts.map +0 -1
  971. package/node_modules/matrix-js-sdk/lib/oidc/index.js +0 -30
  972. package/node_modules/matrix-js-sdk/lib/oidc/index.js.map +0 -1
  973. package/node_modules/matrix-js-sdk/lib/oidc/register.d.ts +0 -70
  974. package/node_modules/matrix-js-sdk/lib/oidc/register.d.ts.map +0 -1
  975. package/node_modules/matrix-js-sdk/lib/oidc/register.js +0 -134
  976. package/node_modules/matrix-js-sdk/lib/oidc/register.js.map +0 -1
  977. package/node_modules/matrix-js-sdk/lib/oidc/tokenRefresher.d.ts +0 -91
  978. package/node_modules/matrix-js-sdk/lib/oidc/tokenRefresher.d.ts.map +0 -1
  979. package/node_modules/matrix-js-sdk/lib/oidc/tokenRefresher.js +0 -173
  980. package/node_modules/matrix-js-sdk/lib/oidc/tokenRefresher.js.map +0 -1
  981. package/node_modules/matrix-js-sdk/lib/oidc/validate.d.ts +0 -78
  982. package/node_modules/matrix-js-sdk/lib/oidc/validate.d.ts.map +0 -1
  983. package/node_modules/matrix-js-sdk/lib/oidc/validate.js +0 -181
  984. package/node_modules/matrix-js-sdk/lib/oidc/validate.js.map +0 -1
  985. package/node_modules/matrix-js-sdk/node_modules/jwt-decode/LICENSE +0 -21
  986. package/node_modules/matrix-js-sdk/node_modules/jwt-decode/README.md +0 -134
  987. package/node_modules/matrix-js-sdk/node_modules/jwt-decode/build/cjs/index.d.ts +0 -23
  988. package/node_modules/matrix-js-sdk/node_modules/jwt-decode/build/cjs/index.js +0 -62
  989. package/node_modules/matrix-js-sdk/node_modules/jwt-decode/build/cjs/package.json +0 -1
  990. package/node_modules/matrix-js-sdk/node_modules/jwt-decode/build/esm/index.d.ts +0 -23
  991. package/node_modules/matrix-js-sdk/node_modules/jwt-decode/build/esm/index.js +0 -57
  992. package/node_modules/matrix-js-sdk/node_modules/jwt-decode/package.json +0 -81
  993. package/node_modules/matrix-js-sdk/node_modules/oidc-client-ts/LICENSE +0 -202
  994. package/node_modules/matrix-js-sdk/node_modules/oidc-client-ts/README.md +0 -87
  995. package/node_modules/matrix-js-sdk/node_modules/oidc-client-ts/dist/browser/oidc-client-ts.js +0 -3751
  996. package/node_modules/matrix-js-sdk/node_modules/oidc-client-ts/dist/browser/oidc-client-ts.js.map +0 -7
  997. package/node_modules/matrix-js-sdk/node_modules/oidc-client-ts/dist/browser/oidc-client-ts.min.js +0 -2
  998. package/node_modules/matrix-js-sdk/node_modules/oidc-client-ts/dist/browser/oidc-client-ts.min.js.map +0 -7
  999. package/node_modules/matrix-js-sdk/node_modules/oidc-client-ts/dist/esm/oidc-client-ts.js +0 -3671
  1000. package/node_modules/matrix-js-sdk/node_modules/oidc-client-ts/dist/esm/oidc-client-ts.js.map +0 -7
  1001. package/node_modules/matrix-js-sdk/node_modules/oidc-client-ts/dist/esm/package.json +0 -4
  1002. package/node_modules/matrix-js-sdk/node_modules/oidc-client-ts/dist/types/oidc-client-ts.d.ts +0 -2003
  1003. package/node_modules/matrix-js-sdk/node_modules/oidc-client-ts/dist/types/tsdoc-metadata.json +0 -11
  1004. package/node_modules/matrix-js-sdk/node_modules/oidc-client-ts/dist/umd/oidc-client-ts.js +0 -3719
  1005. package/node_modules/matrix-js-sdk/node_modules/oidc-client-ts/dist/umd/oidc-client-ts.js.map +0 -7
  1006. package/node_modules/matrix-js-sdk/node_modules/oidc-client-ts/package.json +0 -75
  1007. package/node_modules/matrix-js-sdk/src/oidc/authorize.ts +0 -431
  1008. package/node_modules/matrix-js-sdk/src/oidc/discovery.ts +0 -67
  1009. package/node_modules/matrix-js-sdk/src/oidc/index.ts +0 -33
  1010. package/node_modules/matrix-js-sdk/src/oidc/register.ts +0 -168
  1011. package/node_modules/matrix-js-sdk/src/oidc/tokenRefresher.ts +0 -184
  1012. package/node_modules/matrix-js-sdk/src/oidc/validate.ts +0 -265
  1013. package/node_modules/typebox/build/format/_idna.d.mts +0 -2
  1014. package/node_modules/typebox/build/format/_idna.mjs +0 -246
  1015. package/node_modules/typebox/build/format/_puny.d.mts +0 -1
  1016. package/node_modules/typebox/build/format/_puny.mjs +0 -77
  1017. package/node_modules/typebox/build/schema/resolve/ref.d.mts +0 -3
  1018. package/node_modules/typebox/build/schema/resolve/ref.mjs +0 -146
  1019. package/node_modules/typebox/build/schema/types/contentEncoding.d.mts +0 -9
  1020. package/node_modules/typebox/build/schema/types/contentEncoding.mjs +0 -13
  1021. package/node_modules/typebox/build/schema/types/contentMediaType.d.mts +0 -9
  1022. package/node_modules/typebox/build/schema/types/contentMediaType.mjs +0 -13
@@ -263,10 +263,6 @@ export class RustBackupManager extends TypedEventEmitter {
263
263
  return null;
264
264
  }
265
265
  this.checkedForBackup = true;
266
- if (backupInfo && !backupInfo.version) {
267
- this.logger.warn("active backup lacks a useful 'version'; ignoring it");
268
- backupInfo = undefined;
269
- }
270
266
  this.serverBackupInfo = backupInfo;
271
267
  const activeVersion = await this.getActiveBackupVersion();
272
268
  if (!backupInfo) {
@@ -290,29 +286,49 @@ export class RustBackupManager extends TypedEventEmitter {
290
286
  this.logger.debug("Key backup present on server but not trusted: not enabling key backup");
291
287
  }
292
288
  } else {
293
- if (activeVersion === null) {
294
- this.logger.debug(`Found usable key backup v${backupInfo.version}: enabling key backups`);
295
- await this.enableKeyBackup(backupInfo);
296
- } else if (activeVersion !== backupInfo.version) {
297
- this.logger.debug(`On backup version ${activeVersion} but found version ${backupInfo.version}: switching.`);
298
- // This will remove any pending backup request, remove the backup key and reset the backup state of each room key we have.
299
- await this.disableKeyBackup();
300
- // Enabling will now trigger re-upload of all the keys
301
- await this.enableKeyBackup(backupInfo);
302
- } else {
303
- this.logger.debug(`Backup version ${backupInfo.version} still current`);
304
- }
289
+ await this.enableOrSwitchKeyBackup(backupInfo, activeVersion);
305
290
  }
306
291
  return {
307
292
  backupInfo,
308
293
  trustInfo
309
294
  };
310
295
  }
296
+
297
+ /**
298
+ * Enable key backup upload for the given backup version, if it is not already.
299
+ *
300
+ * If backup is currently enabled for a different version, disables it first.
301
+ *
302
+ * Also emits one or more {@link CryptoEvent.KeyBackupStatus} events if the backup status changes.
303
+ *
304
+ * @param backupInfo - the desired backup version (and the encryption key).
305
+ * @param activeVersion - the current active backup version (or `null`, if none).
306
+ */
307
+ async enableOrSwitchKeyBackup(backupInfo, activeVersion) {
308
+ if (activeVersion === null) {
309
+ this.logger.debug(`Found usable key backup v${backupInfo.version}: enabling key backups`);
310
+ await this.enableKeyBackup(backupInfo);
311
+ } else if (activeVersion !== backupInfo.version) {
312
+ this.logger.debug(`On backup version ${activeVersion} but found version ${backupInfo.version}: switching.`);
313
+ // This will remove any pending backup request, remove the backup upload key from the OlmMachine and reset
314
+ // the backup state of each room key we have.
315
+ await this.disableKeyBackup();
316
+ // Enabling will now trigger re-upload of all the keys
317
+ await this.enableKeyBackup(backupInfo);
318
+ } else {
319
+ this.logger.debug(`Backup version ${backupInfo.version} still current`);
320
+ }
321
+ }
322
+
323
+ /**
324
+ * Helper for {@link enableOrSwitchKeyBackup}.
325
+ *
326
+ * Enables key backup upload for the given backup version. Also emits
327
+ * a {@link CryptoEvent.KeyBackupStatus} event.
328
+ */
311
329
  async enableKeyBackup(backupInfo) {
312
330
  // we know for certain it must be a Curve25519 key, because we have verified it and only Curve25519
313
331
  // keys can be verified.
314
- //
315
- // we also checked it has a valid `version`.
316
332
  await this.olmMachine.enableBackupV1(backupInfo.auth_data.public_key, backupInfo.version);
317
333
  this.activeBackupVersion = backupInfo.version;
318
334
  this.emit(CryptoEvent.KeyBackupStatus, true);
@@ -474,16 +490,24 @@ export class RustBackupManager extends TypedEventEmitter {
474
490
  }
475
491
 
476
492
  /**
477
- * Creates a new key backup by generating a new random private key.
493
+ * Creates a new key backup by generating a new random private key, and then enable key backup upload and download
494
+ * using the new backup version.
478
495
  *
479
496
  * If there is an existing backup server side it will be deleted and replaced
480
497
  * by the new one.
481
498
  *
499
+ * Saves the decryption key in the Rust SDK's CryptoStore.
500
+ *
482
501
  * @param signObject - Method that should sign the backup with existing device and
483
502
  * existing identity.
484
503
  * @returns a KeyBackupCreationInfo - All information related to the backup.
485
504
  */
486
505
  async setupKeyBackup(signObject) {
506
+ // Wait for any active call to `checkKeyBackupAndEnable` to complete, to avoid racing with it
507
+ if (this.keyBackupCheckInProgress) {
508
+ await this.keyBackupCheckInProgress;
509
+ }
510
+
487
511
  // Clean up any existing backup
488
512
  await this.deleteAllKeyBackupVersions();
489
513
  const randomKey = RustSdkCryptoJs.BackupDecryptionKey.createRandomKey();
@@ -492,12 +516,29 @@ export class RustBackupManager extends TypedEventEmitter {
492
516
  public_key: pubKey.publicKeyBase64
493
517
  };
494
518
  await signObject(authData);
495
- const res = await this.http.authedRequest(Method.Post, "/room_keys/version", undefined, {
519
+ const backupData = {
496
520
  algorithm: pubKey.algorithm,
497
521
  auth_data: authData
498
- }, {
522
+ };
523
+ const res = await this.http.authedRequest(Method.Post, "/room_keys/version", undefined, backupData, {
499
524
  prefix: ClientPrefix.V3
500
525
  });
526
+
527
+ // This backup was just created and signed locally, so use the creation response to make up a full
528
+ // `KeyBackupInfo` struct representing the new backup, instead of doing another discovery/trust check.
529
+ const backupInfo = {
530
+ algorithm: pubKey.algorithm,
531
+ auth_data: authData,
532
+ version: res.version,
533
+ count: 0,
534
+ etag: "" // we never actually use the etag, so we can just make up a value
535
+ };
536
+
537
+ // saveBackupDecryptionKey emits KeyBackupDecryptionKeyCached. Cache and
538
+ // enable the created backup first so listeners observe the new version.
539
+ this.serverBackupInfo = backupInfo;
540
+ this.checkedForBackup = true;
541
+ await this.enableOrSwitchKeyBackup(backupInfo, await this.getActiveBackupVersion());
501
542
  await this.saveBackupDecryptionKey(randomKey, res.version);
502
543
  return {
503
544
  version: res.version,
@@ -1 +1 @@
1
- {"version":3,"file":"backup.js","names":[],"sources":["../../src/rust-crypto/backup.ts"],"sourcesContent":["/*\nCopyright 2023 - 2024 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { type OlmMachine, type SignatureVerification } from \"@matrix-org/matrix-sdk-crypto-wasm\";\nimport * as RustSdkCryptoJs from \"@matrix-org/matrix-sdk-crypto-wasm\";\n\nimport {\n type BackupTrustInfo,\n type Curve25519AuthData,\n type KeyBackupCheck,\n type KeyBackupInfo,\n type KeyBackupSession,\n type Curve25519SessionData,\n type KeyBackupRestoreOpts,\n type KeyBackupRestoreResult,\n type KeyBackupRoomSessions,\n} from \"../crypto-api/keybackup.ts\";\nimport { type Logger } from \"../logger.ts\";\nimport { ClientPrefix, type IHttpOpts, MatrixError, type MatrixHttpApi, Method } from \"../http-api/index.ts\";\nimport { TypedEventEmitter } from \"../models/typed-event-emitter.ts\";\nimport { encodeUri, logDuration } from \"../utils.ts\";\nimport { type OutgoingRequestProcessor } from \"./OutgoingRequestProcessor.ts\";\nimport { sleep } from \"../utils.ts\";\nimport { type BackupDecryptor } from \"../common-crypto/CryptoBackend.ts\";\nimport {\n type ImportRoomKeyProgressData,\n type ImportRoomKeysOpts,\n CryptoEvent,\n ImportRoomKeyStage,\n} from \"../crypto-api/index.ts\";\nimport { type AESEncryptedSecretStoragePayload } from \"../@types/AESEncryptedSecretStoragePayload.ts\";\nimport { type IMegolmSessionData } from \"../@types/crypto.ts\";\n\n/** Authentification of the backup info, depends on algorithm */\ntype AuthData = KeyBackupInfo[\"auth_data\"];\n\n/**\n * Holds information of a created keybackup.\n * Useful to get the generated private key material and save it securely somewhere.\n */\ninterface KeyBackupCreationInfo {\n version: string;\n algorithm: string;\n authData: AuthData;\n decryptionKey: RustSdkCryptoJs.BackupDecryptionKey;\n}\n\n/**\n * @internal\n */\nexport class RustBackupManager extends TypedEventEmitter<RustBackupCryptoEvents, RustBackupCryptoEventMap> {\n /** Have we checked if there is a backup on the server which we can use */\n private checkedForBackup = false;\n\n /**\n * The latest backup version on the server, when we last checked.\n *\n * If there was no backup on the server, `null`. If our attempt to check resulted in an error, `undefined`.\n *\n * Note that the backup was not necessarily verified.\n */\n private serverBackupInfo: KeyBackupInfo | null | undefined = undefined;\n\n private activeBackupVersion: string | null = null;\n private stopped = false;\n\n /** whether {@link backupKeysLoop} is currently running */\n private backupKeysLoopRunning = false;\n\n /** The logger to use */\n private readonly logger: Logger;\n\n public constructor(\n logger: Logger,\n private readonly olmMachine: OlmMachine,\n private readonly http: MatrixHttpApi<IHttpOpts & { onlyData: true }>,\n private readonly outgoingRequestProcessor: OutgoingRequestProcessor,\n ) {\n super();\n this.logger = logger.getChild(\"[RustBackupManager]\");\n }\n\n /**\n * Tells the RustBackupManager to stop.\n * The RustBackupManager is scheduling background uploads of keys to the backup, this\n * call allows to cancel the process when the client is stoppped.\n */\n public stop(): void {\n this.stopped = true;\n }\n\n /**\n * Get the backup version we are currently backing up to, if any\n */\n public async getActiveBackupVersion(): Promise<string | null> {\n if (!(await this.olmMachine.isBackupEnabled())) return null;\n return this.activeBackupVersion;\n }\n\n /**\n * Return the details of the latest backup on the server, when we last checked.\n *\n * This normally returns a cached value, but if we haven't yet made a request to the server, it will fire one off.\n * It will always return the details of the active backup if key backup is enabled.\n *\n * If there was no backup on the server, `null`. If our attempt to check resulted in an error, `undefined`.\n */\n public async getServerBackupInfo(): Promise<KeyBackupInfo | null | undefined> {\n // Do a validity check if we haven't already done one. The check is likely to fail if we don't yet have the\n // backup keys -- but as a side-effect, it will populate `serverBackupInfo`.\n await this.checkKeyBackupAndEnable(false);\n return this.serverBackupInfo;\n }\n\n /**\n * Determine if a key backup can be trusted.\n *\n * @param info - key backup info dict from {@link CryptoApi.getKeyBackupInfo}.\n */\n public async isKeyBackupTrusted(info: KeyBackupInfo): Promise<BackupTrustInfo> {\n const signatureVerification: SignatureVerification = await this.olmMachine.verifyBackup(info);\n\n const backupKeys: RustSdkCryptoJs.BackupKeys = await this.olmMachine.getBackupKeys();\n const decryptionKey = backupKeys?.decryptionKey;\n const backupMatchesSavedPrivateKey =\n !!decryptionKey && this.backupInfoMatchesBackupDecryptionKey(info, decryptionKey);\n return {\n matchesDecryptionKey: backupMatchesSavedPrivateKey,\n trusted: signatureVerification.trusted(),\n };\n }\n\n /**\n * Re-check the key backup and enable/disable it as appropriate.\n *\n * @param force - whether we should force a re-check even if one has already happened. If this is\n * `false`, and we have already done a check, `null` is returned rather than the actual info on the key backup.\n */\n public checkKeyBackupAndEnable(force: boolean): Promise<KeyBackupCheck | null> {\n if (!force && this.checkedForBackup) {\n return Promise.resolve(null);\n }\n\n // make sure there is only one check going on at a time\n if (!this.keyBackupCheckInProgress) {\n this.keyBackupCheckInProgress = this.doCheckKeyBackup().finally(() => {\n this.keyBackupCheckInProgress = null;\n });\n }\n return this.keyBackupCheckInProgress;\n }\n\n /**\n * Handles a backup secret received event and store it if it matches the current backup version.\n *\n * Also enables key backup upload if it was not previously enabled, and the encryption key matches the received\n * decryption key.\n *\n * @param secret - The secret as received from a `m.secret.send` or `io.element.msc4385.secret.push` event for secret `m.megolm_backup.v1`.\n * @returns true if the secret is valid and has been stored, false otherwise.\n */\n public async handleBackupSecretReceived(secret: string): Promise<boolean> {\n // Currently we only receive the decryption key without any key backup version. It is important to\n // check that the secret is valid for the current version before storing it.\n // We force a check to ensure to have the latest version.\n let latestBackupInfo: KeyBackupInfo | null;\n try {\n latestBackupInfo = await this.requestKeyBackupVersion();\n } catch (e) {\n this.logger.warn(\"handleBackupSecretReceived: Error checking for latest key backup\", e);\n return false;\n }\n\n if (!latestBackupInfo?.version) {\n // There is no server-side key backup.\n // This decryption key is useless to us.\n this.logger.warn(\n \"handleBackupSecretReceived: Received a backup decryption key, but there is no server-side key backup\",\n );\n return false;\n }\n\n let backupDecryptionKey: RustSdkCryptoJs.BackupDecryptionKey;\n try {\n backupDecryptionKey = RustSdkCryptoJs.BackupDecryptionKey.fromBase64(secret);\n } catch (e) {\n this.logger.warn(\"handleBackupSecretReceived: Invalid backup decryption key\", e);\n return false;\n }\n\n try {\n const privateKeyMatches = this.backupInfoMatchesBackupDecryptionKey(latestBackupInfo, backupDecryptionKey);\n if (!privateKeyMatches) {\n this.logger.warn(\n `handleBackupSecretReceived: Private decryption key does not match the public key of the current server-side backup version (${latestBackupInfo.version})`,\n );\n // just ignore the secret\n return false;\n }\n this.logger.info(\n `handleBackupSecretReceived: Valid decryption key for the current server-side backup version (${latestBackupInfo.version}) received`,\n );\n await this.saveBackupDecryptionKey(backupDecryptionKey, latestBackupInfo.version);\n\n // Check if backup upload should be enabled (e.g. the encryption key matches the decryption key),\n // and enable it if so.\n if (this.keyBackupCheckInProgress) {\n this.logger.debug(\"handleBackupSecretReceived: waiting for ongoing keybackup check to complete\");\n await this.keyBackupCheckInProgress;\n }\n this.logger.debug(\"handleBackupSecretReceived: checking if we can enable keybackup upload\");\n this.keyBackupCheckInProgress = this.doCheckKeyBackup(latestBackupInfo).finally(() => {\n this.keyBackupCheckInProgress = null;\n });\n await this.keyBackupCheckInProgress;\n return true;\n } catch (e) {\n this.logger.warn(\"handleBackupSecretReceived: Unable to validate backup decryption key\", e);\n }\n\n return false;\n }\n\n public async saveBackupDecryptionKey(\n backupDecryptionKey: RustSdkCryptoJs.BackupDecryptionKey,\n version: string,\n ): Promise<void> {\n await this.olmMachine.saveBackupDecryptionKey(backupDecryptionKey, version);\n // Emit an event that we have a new backup decryption key, so that the sdk can start\n // importing keys from backup if needed.\n this.emit(CryptoEvent.KeyBackupDecryptionKeyCached, version);\n }\n\n /**\n * Import a list of room keys previously exported by exportRoomKeys\n *\n * @param keys - a list of session export objects\n * @param opts - options object\n * @returns a promise which resolves once the keys have been imported\n */\n public async importRoomKeys(keys: IMegolmSessionData[], opts?: ImportRoomKeysOpts): Promise<void> {\n await this.importRoomKeysAsJson(JSON.stringify(keys), opts);\n }\n\n /**\n * Import a list of room keys previously exported by exportRoomKeysAsJson\n *\n * @param jsonKeys - a JSON string encoding a list of session export objects,\n * each of which is an IMegolmSessionData\n * @param opts - options object\n * @returns a promise which resolves once the keys have been imported\n */\n public async importRoomKeysAsJson(jsonKeys: string, opts?: ImportRoomKeysOpts): Promise<void> {\n await this.olmMachine.importExportedRoomKeys(jsonKeys, (progress: bigint, total: bigint): void => {\n const importOpt: ImportRoomKeyProgressData = {\n total: Number(total),\n successes: Number(progress),\n stage: ImportRoomKeyStage.LoadKeys,\n failures: 0,\n };\n opts?.progressCallback?.(importOpt);\n });\n }\n\n /**\n * Implementation of {@link CryptoBackend#importBackedUpRoomKeys}.\n */\n public async importBackedUpRoomKeys(\n keys: IMegolmSessionData[],\n backupVersion: string,\n opts?: ImportRoomKeysOpts,\n ): Promise<void> {\n const keysByRoom: Map<RustSdkCryptoJs.RoomId, Map<string, IMegolmSessionData>> = new Map();\n for (const key of keys) {\n const roomId = new RustSdkCryptoJs.RoomId(key.room_id);\n if (!keysByRoom.has(roomId)) {\n keysByRoom.set(roomId, new Map());\n }\n keysByRoom.get(roomId)!.set(key.session_id, key);\n }\n await this.olmMachine.importBackedUpRoomKeys(\n keysByRoom,\n (progress: bigint, total: bigint, failures: bigint): void => {\n const importOpt: ImportRoomKeyProgressData = {\n total: Number(total),\n successes: Number(progress),\n stage: ImportRoomKeyStage.LoadKeys,\n failures: Number(failures),\n };\n opts?.progressCallback?.(importOpt);\n },\n backupVersion,\n );\n }\n\n private keyBackupCheckInProgress: Promise<KeyBackupCheck | null> | null = null;\n\n /** Helper to check the key backup status, and enable/disable it as appropriate\n *\n * A KeyBackupInfo can be passed if it was fetched recently, to avoid trying to\n * re-fetch it from the server.\n */\n private async doCheckKeyBackup(backupInfo?: KeyBackupInfo | null | undefined): Promise<KeyBackupCheck | null> {\n this.logger.debug(\"Checking key backup status...\");\n try {\n if (!backupInfo) {\n backupInfo = await this.requestKeyBackupVersion();\n }\n } catch (e) {\n this.logger.warn(\"Error checking for active key backup\", e);\n this.serverBackupInfo = undefined;\n return null;\n }\n this.checkedForBackup = true;\n\n if (backupInfo && !backupInfo.version) {\n this.logger.warn(\"active backup lacks a useful 'version'; ignoring it\");\n backupInfo = undefined;\n }\n this.serverBackupInfo = backupInfo;\n\n const activeVersion = await this.getActiveBackupVersion();\n\n if (!backupInfo) {\n if (activeVersion !== null) {\n this.logger.debug(\"No key backup present on server: disabling key backup\");\n await this.disableKeyBackup();\n } else {\n this.logger.debug(\"No key backup present on server: not enabling key backup\");\n }\n return null;\n }\n\n const trustInfo = await this.isKeyBackupTrusted(backupInfo);\n\n // Per the spec, we should enable key upload if either (a) the backup is signed by a trusted key, or\n // (b) the public key matches the private decryption key that we have received from 4S.\n if (!trustInfo.matchesDecryptionKey && !trustInfo.trusted) {\n if (activeVersion !== null) {\n this.logger.debug(\"Key backup present on server but not trusted: disabling key backup\");\n await this.disableKeyBackup();\n } else {\n this.logger.debug(\"Key backup present on server but not trusted: not enabling key backup\");\n }\n } else {\n if (activeVersion === null) {\n this.logger.debug(`Found usable key backup v${backupInfo.version}: enabling key backups`);\n await this.enableKeyBackup(backupInfo);\n } else if (activeVersion !== backupInfo.version) {\n this.logger.debug(\n `On backup version ${activeVersion} but found version ${backupInfo.version}: switching.`,\n );\n // This will remove any pending backup request, remove the backup key and reset the backup state of each room key we have.\n await this.disableKeyBackup();\n // Enabling will now trigger re-upload of all the keys\n await this.enableKeyBackup(backupInfo);\n } else {\n this.logger.debug(`Backup version ${backupInfo.version} still current`);\n }\n }\n return { backupInfo, trustInfo };\n }\n\n private async enableKeyBackup(backupInfo: KeyBackupInfo): Promise<void> {\n // we know for certain it must be a Curve25519 key, because we have verified it and only Curve25519\n // keys can be verified.\n //\n // we also checked it has a valid `version`.\n await this.olmMachine.enableBackupV1(\n (backupInfo.auth_data as Curve25519AuthData).public_key,\n backupInfo.version!,\n );\n this.activeBackupVersion = backupInfo.version!;\n\n this.emit(CryptoEvent.KeyBackupStatus, true);\n\n this.backupKeysLoop();\n }\n\n /**\n * Restart the backup key loop if there is an active trusted backup.\n * Doesn't try to check the backup server side. To be called when a new\n * megolm key is known locally.\n */\n public async maybeUploadKey(): Promise<void> {\n if (this.activeBackupVersion != null) {\n this.backupKeysLoop();\n }\n }\n\n private async disableKeyBackup(): Promise<void> {\n await this.olmMachine.disableBackup();\n this.activeBackupVersion = null;\n this.emit(CryptoEvent.KeyBackupStatus, false);\n }\n\n private async backupKeysLoop(maxDelay = 10000): Promise<void> {\n if (this.backupKeysLoopRunning) {\n this.logger.debug(`Backup loop already running`);\n return;\n }\n this.backupKeysLoopRunning = true;\n\n this.logger.debug(`Backup: Starting keys upload loop for backup version:${this.activeBackupVersion}.`);\n\n // wait between 0 and `maxDelay` seconds, to avoid backup\n // requests from different clients hitting the server all at\n // the same time when a new key is sent\n const delay = Math.random() * maxDelay;\n await sleep(delay);\n\n try {\n // number of consecutive network failures for exponential backoff\n let numFailures = 0;\n // The number of keys left to back up. (Populated lazily: see more comments below.)\n let remainingToUploadCount: number | null = null;\n // To avoid computing the key when only a few keys were added (after a sync for example),\n // we compute the count only when at least two iterations are needed.\n let isFirstIteration = true;\n\n while (!this.stopped) {\n // Get a batch of room keys to upload\n let request: RustSdkCryptoJs.KeysBackupRequest | undefined = undefined;\n try {\n request = await logDuration(\n this.logger,\n \"BackupRoomKeys: Get keys to backup from rust crypto-sdk\",\n async () => {\n return await this.olmMachine.backupRoomKeys();\n },\n );\n } catch (err) {\n this.logger.error(\"Backup: Failed to get keys to backup from rust crypto-sdk\", err);\n }\n\n if (!request || this.stopped || !this.activeBackupVersion) {\n this.logger.debug(`Backup: Ending loop for version ${this.activeBackupVersion}.`);\n if (!request) {\n // nothing more to upload\n this.emit(CryptoEvent.KeyBackupSessionsRemaining, 0);\n }\n return;\n }\n\n try {\n await this.outgoingRequestProcessor.makeOutgoingRequest(request);\n numFailures = 0;\n if (this.stopped) break;\n\n // Key count performance (`olmMachine.roomKeyCounts()`) can be pretty bad on some configurations.\n // In particular, we detected on some M1 macs that when the object store reaches a threshold, the count\n // performance stops growing in O(n) and suddenly becomes very slow (40s, 60s or more).\n // For reference, the performance drop occurs around 300-400k keys on the platforms where this issue is observed.\n // Even on other configurations, the count can take several seconds.\n // This will block other operations on the database, like sending messages.\n //\n // This is a workaround to avoid calling `olmMachine.roomKeyCounts()` too often, and only when necessary.\n // We don't call it on the first loop because there could be only a few keys to upload, and we don't want to wait for the count.\n if (!isFirstIteration && remainingToUploadCount === null) {\n try {\n const keyCount = await this.olmMachine.roomKeyCounts();\n remainingToUploadCount = keyCount.total - keyCount.backedUp;\n } catch (err) {\n this.logger.error(\"Backup: Failed to get key counts from rust crypto-sdk\", err);\n }\n }\n\n if (remainingToUploadCount !== null) {\n this.emit(CryptoEvent.KeyBackupSessionsRemaining, remainingToUploadCount);\n const keysCountInBatch = this.keysCountInBatch(request);\n // `OlmMachine.roomKeyCounts` is called only once for the current backupKeysLoop. But new\n // keys could be added during the current loop (after a sync for example).\n // So the count can get out of sync with the real number of remaining keys to upload.\n // Depending on the number of new keys imported and the time to complete the loop,\n // this could result in multiple events being emitted with a remaining key count of 0.\n remainingToUploadCount = Math.max(remainingToUploadCount - keysCountInBatch, 0);\n }\n } catch (err) {\n numFailures++;\n this.logger.error(\"Backup: Error processing backup request for rust crypto-sdk\", err);\n if (err instanceof MatrixError) {\n const errCode = err.data.errcode;\n if (errCode == \"M_NOT_FOUND\" || errCode == \"M_WRONG_ROOM_KEYS_VERSION\") {\n this.logger.debug(`Backup: Failed to upload keys to current vesion: ${errCode}.`);\n try {\n await this.disableKeyBackup();\n } catch (error) {\n this.logger.error(\"Backup: An error occurred while disabling key backup:\", error);\n }\n this.emit(CryptoEvent.KeyBackupFailed, err.data.errcode!);\n // There was an active backup and we are out of sync with the server\n // force a check server side\n this.backupKeysLoopRunning = false;\n this.checkKeyBackupAndEnable(true);\n return;\n } else if (err.isRateLimitError()) {\n // wait for that and then continue?\n try {\n const waitTime = err.getRetryAfterMs();\n if (waitTime && waitTime > 0) {\n await sleep(waitTime);\n continue;\n }\n } catch (error) {\n this.logger.warn(\n \"Backup: An error occurred while retrieving a rate-limit retry delay\",\n error,\n );\n } // else go to the normal backoff\n }\n }\n\n // Some other errors (mx, network, or CORS or invalid urls?) anyhow backoff\n // exponential backoff if we have failures\n await sleep(1000 * Math.pow(2, Math.min(numFailures - 1, 4)));\n }\n isFirstIteration = false;\n }\n } finally {\n this.backupKeysLoopRunning = false;\n }\n }\n\n /**\n * Utility method to count the number of keys in a backup request, in order to update the remaining keys count.\n * This should be the chunk size of the backup request for all requests but the last, but we don't have access to it\n * (it's static in the Rust SDK).\n * @param batch - The backup request to count the keys from.\n *\n * @returns The number of keys in the backup request.\n */\n private keysCountInBatch(batch: RustSdkCryptoJs.KeysBackupRequest): number {\n const parsedBody: KeyBackup = JSON.parse(batch.body);\n return countKeysInBackup(parsedBody);\n }\n\n /**\n * Get information about a key backup from the server\n * - If version is provided, get information about that backup version.\n * - If no version is provided, get information about the latest backup.\n *\n * @param version - The version of the backup to get information about.\n * @returns Information object from API or null if there is no active backup.\n */\n public async requestKeyBackupVersion(version?: string): Promise<KeyBackupInfo | null> {\n return await requestKeyBackupVersion(this.http, version);\n }\n\n /**\n * Creates a new key backup by generating a new random private key.\n *\n * If there is an existing backup server side it will be deleted and replaced\n * by the new one.\n *\n * @param signObject - Method that should sign the backup with existing device and\n * existing identity.\n * @returns a KeyBackupCreationInfo - All information related to the backup.\n */\n public async setupKeyBackup(signObject: (authData: AuthData) => Promise<void>): Promise<KeyBackupCreationInfo> {\n // Clean up any existing backup\n await this.deleteAllKeyBackupVersions();\n\n const randomKey = RustSdkCryptoJs.BackupDecryptionKey.createRandomKey();\n const pubKey = randomKey.megolmV1PublicKey;\n\n const authData = { public_key: pubKey.publicKeyBase64 };\n\n await signObject(authData);\n\n const res = await this.http.authedRequest<{ version: string }>(\n Method.Post,\n \"/room_keys/version\",\n undefined,\n {\n algorithm: pubKey.algorithm,\n auth_data: authData,\n },\n {\n prefix: ClientPrefix.V3,\n },\n );\n\n await this.saveBackupDecryptionKey(randomKey, res.version);\n\n return {\n version: res.version,\n algorithm: pubKey.algorithm,\n authData: authData,\n decryptionKey: randomKey,\n };\n }\n\n /**\n * Deletes all key backups.\n *\n * Will call the API to delete active backup until there is no more present.\n */\n public async deleteAllKeyBackupVersions(): Promise<void> {\n // there could be several backup versions. Delete all to be safe.\n let current = (await this.requestKeyBackupVersion())?.version ?? null;\n while (current != null) {\n await this.deleteKeyBackupVersion(current);\n current = (await this.requestKeyBackupVersion())?.version ?? null;\n }\n\n // XXX: Should this also update Secret Storage and delete any existing keys?\n }\n\n /**\n * Deletes the given key backup.\n *\n * @param version - The backup version to delete.\n */\n public async deleteKeyBackupVersion(version: string): Promise<void> {\n this.logger.debug(`deleteKeyBackupVersion v:${version}`);\n const path = encodeUri(\"/room_keys/version/$version\", { $version: version });\n await this.http.authedRequest<void>(Method.Delete, path, undefined, undefined, {\n prefix: ClientPrefix.V3,\n });\n // If the backup we are deleting is the active one, we need to disable the key backup and to have the local properties reset\n if (this.activeBackupVersion === version) {\n this.serverBackupInfo = null;\n await this.disableKeyBackup();\n }\n }\n\n /**\n * Creates a new backup decryptor for the given private key.\n * @param decryptionKey - The private key to use for decryption.\n */\n public createBackupDecryptor(decryptionKey: RustSdkCryptoJs.BackupDecryptionKey): BackupDecryptor {\n return new RustBackupDecryptor(this.logger, decryptionKey);\n }\n\n /**\n * Restore a key backup.\n *\n * @param backupVersion - The version of the backup to restore.\n * @param backupDecryptor - The backup decryptor to use to decrypt the keys.\n * @param opts - Options for the restore.\n * @returns The total number of keys and the total imported.\n */\n public async restoreKeyBackup(\n backupVersion: string,\n backupDecryptor: BackupDecryptor,\n opts?: KeyBackupRestoreOpts,\n ): Promise<KeyBackupRestoreResult> {\n const keyBackup = await this.downloadKeyBackup(backupVersion);\n\n return this.importKeyBackup(keyBackup, backupVersion, backupDecryptor, opts);\n }\n\n /**\n * Download and import the keys for a given room from the current backup version.\n *\n * @param roomId - The room in question.\n */\n public async downloadLatestRoomKeyBackup(roomId: string): Promise<void> {\n const { backupVersion, decryptionKey } = await this.olmMachine.getBackupKeys();\n if (!backupVersion || !decryptionKey) {\n this.logger.warn(\n `downloadLatestRoomKeyBackup: Could not download backup (backupVersion=${backupVersion}, hasDecryptionKey=${!!decryptionKey})`,\n );\n return;\n }\n const sessions = await this.downloadRoomKeyBackup(backupVersion, roomId);\n const backupDecryptor = this.createBackupDecryptor(decryptionKey);\n this.importKeyBackup({ rooms: { [roomId]: { sessions } } }, backupVersion, backupDecryptor);\n }\n\n /**\n * Call `/room_keys/keys` to download the key backup (room keys) for the given backup version.\n * https://spec.matrix.org/v1.12/client-server-api/#get_matrixclientv3room_keyskeys\n *\n * @param backupVersion\n * @returns The key backup response.\n */\n private downloadKeyBackup(backupVersion: string): Promise<KeyBackup> {\n return this.http.authedRequest<KeyBackup>(\n Method.Get,\n \"/room_keys/keys\",\n { version: backupVersion },\n undefined,\n {\n prefix: ClientPrefix.V3,\n },\n );\n }\n\n /**\n * Call `/room/keys/keys/{roomId}` to download the key backup (room keys) for a given backup version and room ID.\n * @param backupVersion - The version to download.\n * @param roomId - The ID of the room.\n * @returns The key backup response.\n */\n private downloadRoomKeyBackup(backupVersion: string, roomId: string): Promise<KeyBackupRoomSessions> {\n const path = encodeUri(\"/room_keys/keys/$roomId\", {\n $roomId: roomId,\n });\n return this.http.authedRequest<KeyBackupRoomSessions>(Method.Get, path, { version: backupVersion }, undefined, {\n prefix: ClientPrefix.V3,\n });\n }\n\n /**\n * Import the room keys from a `/room_keys/keys` call.\n * Calls `opts.progressCallback` with the progress of the import.\n *\n * @param keyBackup - The response from the server containing the keys to import.\n * @param backupVersion - The version of the backup info.\n * @param backupDecryptor - The backup decryptor to use to decrypt the keys.\n * @param opts - Options for the import.\n *\n * @returns The total number of keys and the total imported.\n *\n * @private\n */\n private async importKeyBackup(\n keyBackup: KeyBackup,\n backupVersion: string,\n backupDecryptor: BackupDecryptor,\n opts?: KeyBackupRestoreOpts,\n ): Promise<KeyBackupRestoreResult> {\n // We have a full backup here, it can get quite big, so we need to decrypt and import it in chunks.\n\n const CHUNK_SIZE = 200;\n // Get the total count as a first pass\n const totalKeyCount = countKeysInBackup(keyBackup);\n let totalImported = 0;\n let totalFailures = 0;\n\n opts?.progressCallback?.({\n total: totalKeyCount,\n successes: totalImported,\n stage: ImportRoomKeyStage.LoadKeys,\n failures: totalFailures,\n });\n\n /**\n * This method is called when we have enough chunks to decrypt.\n * It will decrypt the chunks and try to import the room keys.\n * @param roomChunks\n */\n const handleChunkCallback = async (roomChunks: Map<string, KeyBackupRoomSessions>): Promise<void> => {\n const currentChunk: IMegolmSessionData[] = [];\n for (const roomId of roomChunks.keys()) {\n // Decrypt the sessions for the given room\n const decryptedSessions = await backupDecryptor.decryptSessions(roomChunks.get(roomId)!);\n // Add the decrypted sessions to the current chunk\n decryptedSessions.forEach((session) => {\n // We set the room_id for each session\n session.room_id = roomId;\n currentChunk.push(session);\n });\n }\n\n // We have a chunk of decrypted keys: import them\n try {\n await this.importBackedUpRoomKeys(currentChunk, backupVersion);\n totalImported += currentChunk.length;\n } catch (e) {\n totalFailures += currentChunk.length;\n // We failed to import some keys, but we should still try to import the rest?\n // Log the error and continue\n this.logger.error(\"Error importing keys from backup\", e);\n }\n\n opts?.progressCallback?.({\n total: totalKeyCount,\n successes: totalImported,\n stage: ImportRoomKeyStage.LoadKeys,\n failures: totalFailures,\n });\n };\n\n let groupChunkCount = 0;\n let chunkGroupByRoom: Map<string, KeyBackupRoomSessions> = new Map();\n\n // Iterate over the rooms and sessions to group them in chunks\n // And we call the handleChunkCallback when we have enough chunks to decrypt\n for (const [roomId, roomData] of Object.entries(keyBackup.rooms)) {\n // If there are no sessions for the room, skip it\n if (!roomData.sessions) continue;\n\n // Initialize a new chunk group for the current room\n chunkGroupByRoom.set(roomId, {});\n\n for (const [sessionId, session] of Object.entries(roomData.sessions)) {\n // We set previously the chunk group for the current room, so we can safely get it\n const sessionsForRoom = chunkGroupByRoom.get(roomId)!;\n sessionsForRoom[sessionId] = session;\n groupChunkCount += 1;\n // If we have enough chunks to decrypt, call the block callback\n if (groupChunkCount >= CHUNK_SIZE) {\n // We have enough chunks to decrypt\n await handleChunkCallback(chunkGroupByRoom);\n // Reset the chunk group\n chunkGroupByRoom = new Map();\n // There might be remaining keys for that room, so add back an entry for the current room.\n chunkGroupByRoom.set(roomId, {});\n groupChunkCount = 0;\n }\n }\n }\n\n // Handle remaining chunk if needed\n if (groupChunkCount > 0) {\n await handleChunkCallback(chunkGroupByRoom);\n }\n\n return { total: totalKeyCount, imported: totalImported };\n }\n\n /**\n * Checks if the provided backup info matches the given private key.\n *\n * @param info - The backup info to check.\n * @param backupDecryptionKey - The `BackupDecryptionKey` private key to check against.\n * @returns `true` if the private key can decrypt the backup, `false` otherwise.\n */\n private backupInfoMatchesBackupDecryptionKey(\n info: KeyBackupInfo,\n backupDecryptionKey: RustSdkCryptoJs.BackupDecryptionKey,\n ): boolean {\n if (info.algorithm !== \"m.megolm_backup.v1.curve25519-aes-sha2\") {\n this.logger.warn(\"backupMatchesPrivateKey: Unsupported backup algorithm\", info.algorithm);\n return false;\n }\n\n return (\n (info.auth_data as Curve25519AuthData)?.public_key === backupDecryptionKey.megolmV1PublicKey.publicKeyBase64\n );\n }\n}\n/**\n * Implementation of {@link BackupDecryptor} for the rust crypto backend.\n */\nexport class RustBackupDecryptor implements BackupDecryptor {\n private decryptionKey: RustSdkCryptoJs.BackupDecryptionKey;\n public sourceTrusted: boolean;\n\n public constructor(\n private readonly logger: Logger,\n decryptionKey: RustSdkCryptoJs.BackupDecryptionKey,\n ) {\n this.decryptionKey = decryptionKey;\n this.sourceTrusted = false;\n }\n\n /**\n * Implements {@link BackupDecryptor#decryptSessions}\n */\n public async decryptSessions(\n ciphertexts: Record<string, KeyBackupSession<Curve25519SessionData | AESEncryptedSecretStoragePayload>>,\n ): Promise<IMegolmSessionData[]> {\n const keys: IMegolmSessionData[] = [];\n for (const [sessionId, sessionData] of Object.entries(ciphertexts)) {\n try {\n const decrypted = JSON.parse(\n this.decryptionKey.decryptV1(\n sessionData.session_data.ephemeral,\n sessionData.session_data.mac,\n sessionData.session_data.ciphertext,\n ),\n );\n decrypted.session_id = sessionId;\n keys.push(decrypted);\n } catch (e) {\n this.logger.debug(\"Failed to decrypt megolm session from backup\", e, sessionData);\n }\n }\n return keys;\n }\n\n /**\n * Implements {@link BackupDecryptor#free}\n */\n public free(): void {\n this.decryptionKey.free();\n }\n}\n\n/**\n * Fetch a key backup info from the server.\n *\n * If `version` is provided, calls `GET /room_keys/version/$version` and gets the backup info for that version.\n * See https://spec.matrix.org/v1.12/client-server-api/#get_matrixclientv3room_keysversionversion.\n *\n * If not, calls `GET /room_keys/version` and gets the latest backup info.\n * See https://spec.matrix.org/v1.12/client-server-api/#get_matrixclientv3room_keysversion\n *\n * @param http\n * @param version - the specific version of the backup info to fetch\n * @returns The key backup info or null if there is no backup.\n */\nexport async function requestKeyBackupVersion(\n http: MatrixHttpApi<IHttpOpts & { onlyData: true }>,\n version?: string,\n): Promise<KeyBackupInfo | null> {\n try {\n const path = version ? encodeUri(\"/room_keys/version/$version\", { $version: version }) : \"/room_keys/version\";\n return await http.authedRequest<KeyBackupInfo>(Method.Get, path, undefined, undefined, {\n prefix: ClientPrefix.V3,\n });\n } catch (e) {\n if ((<MatrixError>e).errcode === \"M_NOT_FOUND\") {\n return null;\n } else {\n throw e;\n }\n }\n}\n\n/**\n * Checks if the provided decryption key matches the public key of the key backup info.\n *\n * @param decryptionKey - The decryption key to check.\n * @param keyBackupInfo - The key backup info to check against.\n * @returns `true` if the decryption key matches the key backup info, `false` otherwise.\n */\nexport function decryptionKeyMatchesKeyBackupInfo(\n decryptionKey: RustSdkCryptoJs.BackupDecryptionKey,\n keyBackupInfo: KeyBackupInfo,\n): boolean {\n const authData = <Curve25519AuthData>keyBackupInfo.auth_data;\n return authData.public_key === decryptionKey.megolmV1PublicKey.publicKeyBase64;\n}\n\n/**\n * Counts the total number of keys present in a key backup.\n * @param keyBackup - The key backup to count the keys from.\n * @returns The total number of keys in the backup.\n */\nfunction countKeysInBackup(keyBackup: KeyBackup): number {\n let count = 0;\n for (const { sessions } of Object.values(keyBackup.rooms)) {\n count += Object.keys(sessions).length;\n }\n return count;\n}\n\nexport type RustBackupCryptoEvents =\n | CryptoEvent.KeyBackupStatus\n | CryptoEvent.KeyBackupSessionsRemaining\n | CryptoEvent.KeyBackupFailed\n | CryptoEvent.KeyBackupDecryptionKeyCached;\n\nexport type RustBackupCryptoEventMap = {\n [CryptoEvent.KeyBackupStatus]: (enabled: boolean) => void;\n [CryptoEvent.KeyBackupSessionsRemaining]: (remaining: number) => void;\n [CryptoEvent.KeyBackupFailed]: (errCode: string) => void;\n [CryptoEvent.KeyBackupDecryptionKeyCached]: (version: string) => void;\n};\n\n/**\n * Response from GET `/room_keys/keys` endpoint.\n * See https://spec.matrix.org/latest/client-server-api/#get_matrixclientv3room_keyskeys\n */\nexport interface KeyBackup {\n rooms: Record<string, { sessions: KeyBackupRoomSessions }>;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAO,KAAK,eAAe,MAAM,oCAAoC;AAcrE,SAAS,YAAY,EAAkB,WAAW,EAAsB,MAAM,QAAQ,sBAAsB;AAC5G,SAAS,iBAAiB,QAAQ,kCAAkC;AACpE,SAAS,SAAS,EAAE,WAAW,QAAQ,aAAa;AAEpD,SAAS,KAAK,QAAQ,aAAa;AAEnC,SAGI,WAAW,EACX,kBAAkB,QACf,wBAAwB;;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MAAM,IAAI,GAAG,OAAO,GAAG,SAAS,CAAC,6BAA6B,EAAE;MAAE,QAAQ,EAAE;IAAQ,CAAC,CAAC,GAAG,oBAAoB;IAC7G,OAAO,MAAM,IAAI,CAAC,aAAa,CAAgB,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE;MACnF,MAAM,EAAE,YAAY,CAAC;IACzB,CAAC,CAAC;EACN,CAAC,CAAC,OAAO,CAAC,EAAE;IACR,IAAkB,CAAC,CAAE,OAAO,KAAK,aAAa,EAAE;MAC5C,OAAO,IAAI;IACf,CAAC,MAAM;MACH,MAAM,CAAC;IACX;EACJ;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS,iCAAiC,CAC7C,aAAkD,EAClD,aAA4B,EACrB;EACP,MAAM,QAAQ,GAAuB,aAAa,CAAC,SAAS;EAC5D,OAAO,QAAQ,CAAC,UAAU,KAAK,aAAa,CAAC,iBAAiB,CAAC,eAAe;AAClF;;AAEA;AACA;AACA;AACA;AACA;AACA,SAAS,iBAAiB,CAAC,SAAoB,EAAU;EACrD,IAAI,KAAK,GAAG,CAAC;EACb,KAAK,MAAM;IAAE;EAAS,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;IACvD,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM;EACzC;EACA,OAAO,KAAK;AAChB;;AAeA;AACA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"backup.js","names":[],"sources":["../../src/rust-crypto/backup.ts"],"sourcesContent":["/*\nCopyright 2023 - 2024 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { type OlmMachine, type SignatureVerification } from \"@matrix-org/matrix-sdk-crypto-wasm\";\nimport * as RustSdkCryptoJs from \"@matrix-org/matrix-sdk-crypto-wasm\";\n\nimport {\n type BackupTrustInfo,\n type Curve25519AuthData,\n type KeyBackupCheck,\n type KeyBackupInfo,\n type KeyBackupSession,\n type KeyBackupRestoreOpts,\n type KeyBackupRestoreResult,\n type KeyBackupRoomSessions,\n type NewKeyBackupInfo,\n} from \"../crypto-api/keybackup.ts\";\nimport { type Logger } from \"../logger.ts\";\nimport { ClientPrefix, type IHttpOpts, MatrixError, type MatrixHttpApi, Method } from \"../http-api/index.ts\";\nimport { TypedEventEmitter } from \"../models/typed-event-emitter.ts\";\nimport { encodeUri, logDuration } from \"../utils.ts\";\nimport { type OutgoingRequestProcessor } from \"./OutgoingRequestProcessor.ts\";\nimport { sleep } from \"../utils.ts\";\nimport { type BackupDecryptor } from \"../common-crypto/CryptoBackend.ts\";\nimport {\n type ImportRoomKeyProgressData,\n type ImportRoomKeysOpts,\n CryptoEvent,\n ImportRoomKeyStage,\n} from \"../crypto-api/index.ts\";\nimport { type IMegolmSessionData } from \"../@types/crypto.ts\";\n\n/** Authentification of the backup info, depends on algorithm */\ntype AuthData = KeyBackupInfo[\"auth_data\"];\n\n/**\n * Holds information of a created keybackup.\n * Useful to get the generated private key material and save it securely somewhere.\n */\ninterface KeyBackupCreationInfo {\n version: string;\n algorithm: string;\n authData: AuthData;\n decryptionKey: RustSdkCryptoJs.BackupDecryptionKey;\n}\n\n/**\n * @internal\n */\nexport class RustBackupManager extends TypedEventEmitter<RustBackupCryptoEvents, RustBackupCryptoEventMap> {\n /** Have we checked if there is a backup on the server which we can use */\n private checkedForBackup = false;\n\n /**\n * The latest backup version on the server, when we last checked.\n *\n * If there was no backup on the server, `null`. If our attempt to check resulted in an error, `undefined`.\n *\n * Note that the backup was not necessarily verified.\n */\n private serverBackupInfo: KeyBackupInfo | null | undefined = undefined;\n\n private activeBackupVersion: string | null = null;\n private stopped = false;\n\n /** whether {@link backupKeysLoop} is currently running */\n private backupKeysLoopRunning = false;\n\n /** The logger to use */\n private readonly logger: Logger;\n\n public constructor(\n logger: Logger,\n private readonly olmMachine: OlmMachine,\n private readonly http: MatrixHttpApi<IHttpOpts & { onlyData: true }>,\n private readonly outgoingRequestProcessor: OutgoingRequestProcessor,\n ) {\n super();\n this.logger = logger.getChild(\"[RustBackupManager]\");\n }\n\n /**\n * Tells the RustBackupManager to stop.\n * The RustBackupManager is scheduling background uploads of keys to the backup, this\n * call allows to cancel the process when the client is stoppped.\n */\n public stop(): void {\n this.stopped = true;\n }\n\n /**\n * Get the backup version we are currently backing up to, if any\n */\n public async getActiveBackupVersion(): Promise<string | null> {\n if (!(await this.olmMachine.isBackupEnabled())) return null;\n return this.activeBackupVersion;\n }\n\n /**\n * Return the details of the latest backup on the server, when we last checked.\n *\n * This normally returns a cached value, but if we haven't yet made a request to the server, it will fire one off.\n * It will always return the details of the active backup if key backup is enabled.\n *\n * If there was no backup on the server, `null`. If our attempt to check resulted in an error, `undefined`.\n */\n public async getServerBackupInfo(): Promise<KeyBackupInfo | null | undefined> {\n // Do a validity check if we haven't already done one. The check is likely to fail if we don't yet have the\n // backup keys -- but as a side-effect, it will populate `serverBackupInfo`.\n await this.checkKeyBackupAndEnable(false);\n return this.serverBackupInfo;\n }\n\n /**\n * Determine if a key backup can be trusted.\n *\n * @param info - key backup info dict from {@link CryptoApi.getKeyBackupInfo}.\n */\n public async isKeyBackupTrusted(info: KeyBackupInfo): Promise<BackupTrustInfo> {\n const signatureVerification: SignatureVerification = await this.olmMachine.verifyBackup(info);\n\n const backupKeys: RustSdkCryptoJs.BackupKeys = await this.olmMachine.getBackupKeys();\n const decryptionKey = backupKeys?.decryptionKey;\n const backupMatchesSavedPrivateKey =\n !!decryptionKey && this.backupInfoMatchesBackupDecryptionKey(info, decryptionKey);\n return {\n matchesDecryptionKey: backupMatchesSavedPrivateKey,\n trusted: signatureVerification.trusted(),\n };\n }\n\n /**\n * Re-check the key backup and enable/disable it as appropriate.\n *\n * @param force - whether we should force a re-check even if one has already happened. If this is\n * `false`, and we have already done a check, `null` is returned rather than the actual info on the key backup.\n */\n public checkKeyBackupAndEnable(force: boolean): Promise<KeyBackupCheck | null> {\n if (!force && this.checkedForBackup) {\n return Promise.resolve(null);\n }\n\n // make sure there is only one check going on at a time\n if (!this.keyBackupCheckInProgress) {\n this.keyBackupCheckInProgress = this.doCheckKeyBackup().finally(() => {\n this.keyBackupCheckInProgress = null;\n });\n }\n return this.keyBackupCheckInProgress;\n }\n\n /**\n * Handles a backup secret received event and store it if it matches the current backup version.\n *\n * Also enables key backup upload if it was not previously enabled, and the encryption key matches the received\n * decryption key.\n *\n * @param secret - The secret as received from a `m.secret.send` or `io.element.msc4385.secret.push` event for secret `m.megolm_backup.v1`.\n * @returns true if the secret is valid and has been stored, false otherwise.\n */\n public async handleBackupSecretReceived(secret: string): Promise<boolean> {\n // Currently we only receive the decryption key without any key backup version. It is important to\n // check that the secret is valid for the current version before storing it.\n // We force a check to ensure to have the latest version.\n let latestBackupInfo: KeyBackupInfo | null;\n try {\n latestBackupInfo = await this.requestKeyBackupVersion();\n } catch (e) {\n this.logger.warn(\"handleBackupSecretReceived: Error checking for latest key backup\", e);\n return false;\n }\n\n if (!latestBackupInfo?.version) {\n // There is no server-side key backup.\n // This decryption key is useless to us.\n this.logger.warn(\n \"handleBackupSecretReceived: Received a backup decryption key, but there is no server-side key backup\",\n );\n return false;\n }\n\n let backupDecryptionKey: RustSdkCryptoJs.BackupDecryptionKey;\n try {\n backupDecryptionKey = RustSdkCryptoJs.BackupDecryptionKey.fromBase64(secret);\n } catch (e) {\n this.logger.warn(\"handleBackupSecretReceived: Invalid backup decryption key\", e);\n return false;\n }\n\n try {\n const privateKeyMatches = this.backupInfoMatchesBackupDecryptionKey(latestBackupInfo, backupDecryptionKey);\n if (!privateKeyMatches) {\n this.logger.warn(\n `handleBackupSecretReceived: Private decryption key does not match the public key of the current server-side backup version (${latestBackupInfo.version})`,\n );\n // just ignore the secret\n return false;\n }\n this.logger.info(\n `handleBackupSecretReceived: Valid decryption key for the current server-side backup version (${latestBackupInfo.version}) received`,\n );\n await this.saveBackupDecryptionKey(backupDecryptionKey, latestBackupInfo.version);\n\n // Check if backup upload should be enabled (e.g. the encryption key matches the decryption key),\n // and enable it if so.\n if (this.keyBackupCheckInProgress) {\n this.logger.debug(\"handleBackupSecretReceived: waiting for ongoing keybackup check to complete\");\n await this.keyBackupCheckInProgress;\n }\n this.logger.debug(\"handleBackupSecretReceived: checking if we can enable keybackup upload\");\n this.keyBackupCheckInProgress = this.doCheckKeyBackup(latestBackupInfo).finally(() => {\n this.keyBackupCheckInProgress = null;\n });\n await this.keyBackupCheckInProgress;\n return true;\n } catch (e) {\n this.logger.warn(\"handleBackupSecretReceived: Unable to validate backup decryption key\", e);\n }\n\n return false;\n }\n\n public async saveBackupDecryptionKey(\n backupDecryptionKey: RustSdkCryptoJs.BackupDecryptionKey,\n version: string,\n ): Promise<void> {\n await this.olmMachine.saveBackupDecryptionKey(backupDecryptionKey, version);\n // Emit an event that we have a new backup decryption key, so that the sdk can start\n // importing keys from backup if needed.\n this.emit(CryptoEvent.KeyBackupDecryptionKeyCached, version);\n }\n\n /**\n * Import a list of room keys previously exported by exportRoomKeys\n *\n * @param keys - a list of session export objects\n * @param opts - options object\n * @returns a promise which resolves once the keys have been imported\n */\n public async importRoomKeys(keys: IMegolmSessionData[], opts?: ImportRoomKeysOpts): Promise<void> {\n await this.importRoomKeysAsJson(JSON.stringify(keys), opts);\n }\n\n /**\n * Import a list of room keys previously exported by exportRoomKeysAsJson\n *\n * @param jsonKeys - a JSON string encoding a list of session export objects,\n * each of which is an IMegolmSessionData\n * @param opts - options object\n * @returns a promise which resolves once the keys have been imported\n */\n public async importRoomKeysAsJson(jsonKeys: string, opts?: ImportRoomKeysOpts): Promise<void> {\n await this.olmMachine.importExportedRoomKeys(jsonKeys, (progress: bigint, total: bigint): void => {\n const importOpt: ImportRoomKeyProgressData = {\n total: Number(total),\n successes: Number(progress),\n stage: ImportRoomKeyStage.LoadKeys,\n failures: 0,\n };\n opts?.progressCallback?.(importOpt);\n });\n }\n\n /**\n * Implementation of {@link CryptoBackend#importBackedUpRoomKeys}.\n */\n public async importBackedUpRoomKeys(\n keys: IMegolmSessionData[],\n backupVersion: string,\n opts?: ImportRoomKeysOpts,\n ): Promise<void> {\n const keysByRoom: Map<RustSdkCryptoJs.RoomId, Map<string, IMegolmSessionData>> = new Map();\n for (const key of keys) {\n const roomId = new RustSdkCryptoJs.RoomId(key.room_id);\n if (!keysByRoom.has(roomId)) {\n keysByRoom.set(roomId, new Map());\n }\n keysByRoom.get(roomId)!.set(key.session_id, key);\n }\n await this.olmMachine.importBackedUpRoomKeys(\n keysByRoom,\n (progress: bigint, total: bigint, failures: bigint): void => {\n const importOpt: ImportRoomKeyProgressData = {\n total: Number(total),\n successes: Number(progress),\n stage: ImportRoomKeyStage.LoadKeys,\n failures: Number(failures),\n };\n opts?.progressCallback?.(importOpt);\n },\n backupVersion,\n );\n }\n\n private keyBackupCheckInProgress: Promise<KeyBackupCheck | null> | null = null;\n\n /** Helper to check the key backup status, and enable/disable it as appropriate\n *\n * A KeyBackupInfo can be passed if it was fetched recently, to avoid trying to\n * re-fetch it from the server.\n */\n private async doCheckKeyBackup(backupInfo?: KeyBackupInfo | null | undefined): Promise<KeyBackupCheck | null> {\n this.logger.debug(\"Checking key backup status...\");\n try {\n if (!backupInfo) {\n backupInfo = await this.requestKeyBackupVersion();\n }\n } catch (e) {\n this.logger.warn(\"Error checking for active key backup\", e);\n this.serverBackupInfo = undefined;\n return null;\n }\n this.checkedForBackup = true;\n this.serverBackupInfo = backupInfo;\n\n const activeVersion = await this.getActiveBackupVersion();\n\n if (!backupInfo) {\n if (activeVersion !== null) {\n this.logger.debug(\"No key backup present on server: disabling key backup\");\n await this.disableKeyBackup();\n } else {\n this.logger.debug(\"No key backup present on server: not enabling key backup\");\n }\n return null;\n }\n\n const trustInfo = await this.isKeyBackupTrusted(backupInfo);\n\n // Per the spec, we should enable key upload if either (a) the backup is signed by a trusted key, or\n // (b) the public key matches the private decryption key that we have received from 4S.\n if (!trustInfo.matchesDecryptionKey && !trustInfo.trusted) {\n if (activeVersion !== null) {\n this.logger.debug(\"Key backup present on server but not trusted: disabling key backup\");\n await this.disableKeyBackup();\n } else {\n this.logger.debug(\"Key backup present on server but not trusted: not enabling key backup\");\n }\n } else {\n await this.enableOrSwitchKeyBackup(backupInfo, activeVersion);\n }\n return { backupInfo, trustInfo };\n }\n\n /**\n * Enable key backup upload for the given backup version, if it is not already.\n *\n * If backup is currently enabled for a different version, disables it first.\n *\n * Also emits one or more {@link CryptoEvent.KeyBackupStatus} events if the backup status changes.\n *\n * @param backupInfo - the desired backup version (and the encryption key).\n * @param activeVersion - the current active backup version (or `null`, if none).\n */\n private async enableOrSwitchKeyBackup(backupInfo: KeyBackupInfo, activeVersion: string | null): Promise<void> {\n if (activeVersion === null) {\n this.logger.debug(`Found usable key backup v${backupInfo.version}: enabling key backups`);\n await this.enableKeyBackup(backupInfo);\n } else if (activeVersion !== backupInfo.version) {\n this.logger.debug(`On backup version ${activeVersion} but found version ${backupInfo.version}: switching.`);\n // This will remove any pending backup request, remove the backup upload key from the OlmMachine and reset\n // the backup state of each room key we have.\n await this.disableKeyBackup();\n // Enabling will now trigger re-upload of all the keys\n await this.enableKeyBackup(backupInfo);\n } else {\n this.logger.debug(`Backup version ${backupInfo.version} still current`);\n }\n }\n\n /**\n * Helper for {@link enableOrSwitchKeyBackup}.\n *\n * Enables key backup upload for the given backup version. Also emits\n * a {@link CryptoEvent.KeyBackupStatus} event.\n */\n private async enableKeyBackup(backupInfo: KeyBackupInfo): Promise<void> {\n // we know for certain it must be a Curve25519 key, because we have verified it and only Curve25519\n // keys can be verified.\n await this.olmMachine.enableBackupV1(\n (backupInfo.auth_data as Curve25519AuthData).public_key,\n backupInfo.version,\n );\n this.activeBackupVersion = backupInfo.version;\n\n this.emit(CryptoEvent.KeyBackupStatus, true);\n\n this.backupKeysLoop();\n }\n\n /**\n * Restart the backup key loop if there is an active trusted backup.\n * Doesn't try to check the backup server side. To be called when a new\n * megolm key is known locally.\n */\n public async maybeUploadKey(): Promise<void> {\n if (this.activeBackupVersion != null) {\n this.backupKeysLoop();\n }\n }\n\n private async disableKeyBackup(): Promise<void> {\n await this.olmMachine.disableBackup();\n this.activeBackupVersion = null;\n this.emit(CryptoEvent.KeyBackupStatus, false);\n }\n\n private async backupKeysLoop(maxDelay = 10000): Promise<void> {\n if (this.backupKeysLoopRunning) {\n this.logger.debug(`Backup loop already running`);\n return;\n }\n this.backupKeysLoopRunning = true;\n\n this.logger.debug(`Backup: Starting keys upload loop for backup version:${this.activeBackupVersion}.`);\n\n // wait between 0 and `maxDelay` seconds, to avoid backup\n // requests from different clients hitting the server all at\n // the same time when a new key is sent\n const delay = Math.random() * maxDelay;\n await sleep(delay);\n\n try {\n // number of consecutive network failures for exponential backoff\n let numFailures = 0;\n // The number of keys left to back up. (Populated lazily: see more comments below.)\n let remainingToUploadCount: number | null = null;\n // To avoid computing the key when only a few keys were added (after a sync for example),\n // we compute the count only when at least two iterations are needed.\n let isFirstIteration = true;\n\n while (!this.stopped) {\n // Get a batch of room keys to upload\n let request: RustSdkCryptoJs.KeysBackupRequest | undefined = undefined;\n try {\n request = await logDuration(\n this.logger,\n \"BackupRoomKeys: Get keys to backup from rust crypto-sdk\",\n async () => {\n return await this.olmMachine.backupRoomKeys();\n },\n );\n } catch (err) {\n this.logger.error(\"Backup: Failed to get keys to backup from rust crypto-sdk\", err);\n }\n\n if (!request || this.stopped || !this.activeBackupVersion) {\n this.logger.debug(`Backup: Ending loop for version ${this.activeBackupVersion}.`);\n if (!request) {\n // nothing more to upload\n this.emit(CryptoEvent.KeyBackupSessionsRemaining, 0);\n }\n return;\n }\n\n try {\n await this.outgoingRequestProcessor.makeOutgoingRequest(request);\n numFailures = 0;\n if (this.stopped) break;\n\n // Key count performance (`olmMachine.roomKeyCounts()`) can be pretty bad on some configurations.\n // In particular, we detected on some M1 macs that when the object store reaches a threshold, the count\n // performance stops growing in O(n) and suddenly becomes very slow (40s, 60s or more).\n // For reference, the performance drop occurs around 300-400k keys on the platforms where this issue is observed.\n // Even on other configurations, the count can take several seconds.\n // This will block other operations on the database, like sending messages.\n //\n // This is a workaround to avoid calling `olmMachine.roomKeyCounts()` too often, and only when necessary.\n // We don't call it on the first loop because there could be only a few keys to upload, and we don't want to wait for the count.\n if (!isFirstIteration && remainingToUploadCount === null) {\n try {\n const keyCount = await this.olmMachine.roomKeyCounts();\n remainingToUploadCount = keyCount.total - keyCount.backedUp;\n } catch (err) {\n this.logger.error(\"Backup: Failed to get key counts from rust crypto-sdk\", err);\n }\n }\n\n if (remainingToUploadCount !== null) {\n this.emit(CryptoEvent.KeyBackupSessionsRemaining, remainingToUploadCount);\n const keysCountInBatch = this.keysCountInBatch(request);\n // `OlmMachine.roomKeyCounts` is called only once for the current backupKeysLoop. But new\n // keys could be added during the current loop (after a sync for example).\n // So the count can get out of sync with the real number of remaining keys to upload.\n // Depending on the number of new keys imported and the time to complete the loop,\n // this could result in multiple events being emitted with a remaining key count of 0.\n remainingToUploadCount = Math.max(remainingToUploadCount - keysCountInBatch, 0);\n }\n } catch (err) {\n numFailures++;\n this.logger.error(\"Backup: Error processing backup request for rust crypto-sdk\", err);\n if (err instanceof MatrixError) {\n const errCode = err.data.errcode;\n if (errCode == \"M_NOT_FOUND\" || errCode == \"M_WRONG_ROOM_KEYS_VERSION\") {\n this.logger.debug(`Backup: Failed to upload keys to current vesion: ${errCode}.`);\n try {\n await this.disableKeyBackup();\n } catch (error) {\n this.logger.error(\"Backup: An error occurred while disabling key backup:\", error);\n }\n this.emit(CryptoEvent.KeyBackupFailed, err.data.errcode!);\n // There was an active backup and we are out of sync with the server\n // force a check server side\n this.backupKeysLoopRunning = false;\n this.checkKeyBackupAndEnable(true);\n return;\n } else if (err.isRateLimitError()) {\n // wait for that and then continue?\n try {\n const waitTime = err.getRetryAfterMs();\n if (waitTime && waitTime > 0) {\n await sleep(waitTime);\n continue;\n }\n } catch (error) {\n this.logger.warn(\n \"Backup: An error occurred while retrieving a rate-limit retry delay\",\n error,\n );\n } // else go to the normal backoff\n }\n }\n\n // Some other errors (mx, network, or CORS or invalid urls?) anyhow backoff\n // exponential backoff if we have failures\n await sleep(1000 * Math.pow(2, Math.min(numFailures - 1, 4)));\n }\n isFirstIteration = false;\n }\n } finally {\n this.backupKeysLoopRunning = false;\n }\n }\n\n /**\n * Utility method to count the number of keys in a backup request, in order to update the remaining keys count.\n * This should be the chunk size of the backup request for all requests but the last, but we don't have access to it\n * (it's static in the Rust SDK).\n * @param batch - The backup request to count the keys from.\n *\n * @returns The number of keys in the backup request.\n */\n private keysCountInBatch(batch: RustSdkCryptoJs.KeysBackupRequest): number {\n const parsedBody: KeyBackup = JSON.parse(batch.body);\n return countKeysInBackup(parsedBody);\n }\n\n /**\n * Get information about a key backup from the server\n * - If version is provided, get information about that backup version.\n * - If no version is provided, get information about the latest backup.\n *\n * @param version - The version of the backup to get information about.\n * @returns Information object from API or null if there is no active backup.\n */\n public async requestKeyBackupVersion(version?: string): Promise<KeyBackupInfo | null> {\n return await requestKeyBackupVersion(this.http, version);\n }\n\n /**\n * Creates a new key backup by generating a new random private key, and then enable key backup upload and download\n * using the new backup version.\n *\n * If there is an existing backup server side it will be deleted and replaced\n * by the new one.\n *\n * Saves the decryption key in the Rust SDK's CryptoStore.\n *\n * @param signObject - Method that should sign the backup with existing device and\n * existing identity.\n * @returns a KeyBackupCreationInfo - All information related to the backup.\n */\n public async setupKeyBackup(signObject: (authData: AuthData) => Promise<void>): Promise<KeyBackupCreationInfo> {\n // Wait for any active call to `checkKeyBackupAndEnable` to complete, to avoid racing with it\n if (this.keyBackupCheckInProgress) {\n await this.keyBackupCheckInProgress;\n }\n\n // Clean up any existing backup\n await this.deleteAllKeyBackupVersions();\n\n const randomKey = RustSdkCryptoJs.BackupDecryptionKey.createRandomKey();\n const pubKey = randomKey.megolmV1PublicKey;\n\n const authData = { public_key: pubKey.publicKeyBase64 };\n\n await signObject(authData);\n\n const backupData: NewKeyBackupInfo = {\n algorithm: pubKey.algorithm,\n auth_data: authData,\n };\n\n const res = await this.http.authedRequest<{ version: string }>(\n Method.Post,\n \"/room_keys/version\",\n undefined,\n backupData,\n {\n prefix: ClientPrefix.V3,\n },\n );\n\n // This backup was just created and signed locally, so use the creation response to make up a full\n // `KeyBackupInfo` struct representing the new backup, instead of doing another discovery/trust check.\n const backupInfo: KeyBackupInfo = {\n algorithm: pubKey.algorithm,\n auth_data: authData,\n version: res.version,\n count: 0,\n etag: \"\", // we never actually use the etag, so we can just make up a value\n };\n\n // saveBackupDecryptionKey emits KeyBackupDecryptionKeyCached. Cache and\n // enable the created backup first so listeners observe the new version.\n this.serverBackupInfo = backupInfo;\n this.checkedForBackup = true;\n await this.enableOrSwitchKeyBackup(backupInfo, await this.getActiveBackupVersion());\n await this.saveBackupDecryptionKey(randomKey, res.version);\n\n return {\n version: res.version,\n algorithm: pubKey.algorithm,\n authData: authData,\n decryptionKey: randomKey,\n };\n }\n\n /**\n * Deletes all key backups.\n *\n * Will call the API to delete active backup until there is no more present.\n */\n public async deleteAllKeyBackupVersions(): Promise<void> {\n // there could be several backup versions. Delete all to be safe.\n let current = (await this.requestKeyBackupVersion())?.version ?? null;\n while (current != null) {\n await this.deleteKeyBackupVersion(current);\n current = (await this.requestKeyBackupVersion())?.version ?? null;\n }\n\n // XXX: Should this also update Secret Storage and delete any existing keys?\n }\n\n /**\n * Deletes the given key backup.\n *\n * @param version - The backup version to delete.\n */\n public async deleteKeyBackupVersion(version: string): Promise<void> {\n this.logger.debug(`deleteKeyBackupVersion v:${version}`);\n const path = encodeUri(\"/room_keys/version/$version\", { $version: version });\n await this.http.authedRequest<void>(Method.Delete, path, undefined, undefined, {\n prefix: ClientPrefix.V3,\n });\n // If the backup we are deleting is the active one, we need to disable the key backup and to have the local properties reset\n if (this.activeBackupVersion === version) {\n this.serverBackupInfo = null;\n await this.disableKeyBackup();\n }\n }\n\n /**\n * Creates a new backup decryptor for the given private key.\n * @param decryptionKey - The private key to use for decryption.\n */\n public createBackupDecryptor(decryptionKey: RustSdkCryptoJs.BackupDecryptionKey): BackupDecryptor {\n return new RustBackupDecryptor(this.logger, decryptionKey);\n }\n\n /**\n * Restore a key backup.\n *\n * @param backupVersion - The version of the backup to restore.\n * @param backupDecryptor - The backup decryptor to use to decrypt the keys.\n * @param opts - Options for the restore.\n * @returns The total number of keys and the total imported.\n */\n public async restoreKeyBackup(\n backupVersion: string,\n backupDecryptor: BackupDecryptor,\n opts?: KeyBackupRestoreOpts,\n ): Promise<KeyBackupRestoreResult> {\n const keyBackup = await this.downloadKeyBackup(backupVersion);\n\n return this.importKeyBackup(keyBackup, backupVersion, backupDecryptor, opts);\n }\n\n /**\n * Download and import the keys for a given room from the current backup version.\n *\n * @param roomId - The room in question.\n */\n public async downloadLatestRoomKeyBackup(roomId: string): Promise<void> {\n const { backupVersion, decryptionKey } = await this.olmMachine.getBackupKeys();\n if (!backupVersion || !decryptionKey) {\n this.logger.warn(\n `downloadLatestRoomKeyBackup: Could not download backup (backupVersion=${backupVersion}, hasDecryptionKey=${!!decryptionKey})`,\n );\n return;\n }\n const sessions = await this.downloadRoomKeyBackup(backupVersion, roomId);\n const backupDecryptor = this.createBackupDecryptor(decryptionKey);\n this.importKeyBackup({ rooms: { [roomId]: { sessions } } }, backupVersion, backupDecryptor);\n }\n\n /**\n * Call `/room_keys/keys` to download the key backup (room keys) for the given backup version.\n * https://spec.matrix.org/v1.12/client-server-api/#get_matrixclientv3room_keyskeys\n *\n * @param backupVersion\n * @returns The key backup response.\n */\n private downloadKeyBackup(backupVersion: string): Promise<KeyBackup> {\n return this.http.authedRequest<KeyBackup>(\n Method.Get,\n \"/room_keys/keys\",\n { version: backupVersion },\n undefined,\n {\n prefix: ClientPrefix.V3,\n },\n );\n }\n\n /**\n * Call `/room/keys/keys/{roomId}` to download the key backup (room keys) for a given backup version and room ID.\n * @param backupVersion - The version to download.\n * @param roomId - The ID of the room.\n * @returns The key backup response.\n */\n private downloadRoomKeyBackup(backupVersion: string, roomId: string): Promise<KeyBackupRoomSessions> {\n const path = encodeUri(\"/room_keys/keys/$roomId\", {\n $roomId: roomId,\n });\n return this.http.authedRequest<KeyBackupRoomSessions>(Method.Get, path, { version: backupVersion }, undefined, {\n prefix: ClientPrefix.V3,\n });\n }\n\n /**\n * Import the room keys from a `/room_keys/keys` call.\n * Calls `opts.progressCallback` with the progress of the import.\n *\n * @param keyBackup - The response from the server containing the keys to import.\n * @param backupVersion - The version of the backup info.\n * @param backupDecryptor - The backup decryptor to use to decrypt the keys.\n * @param opts - Options for the import.\n *\n * @returns The total number of keys and the total imported.\n *\n * @private\n */\n private async importKeyBackup(\n keyBackup: KeyBackup,\n backupVersion: string,\n backupDecryptor: BackupDecryptor,\n opts?: KeyBackupRestoreOpts,\n ): Promise<KeyBackupRestoreResult> {\n // We have a full backup here, it can get quite big, so we need to decrypt and import it in chunks.\n\n const CHUNK_SIZE = 200;\n // Get the total count as a first pass\n const totalKeyCount = countKeysInBackup(keyBackup);\n let totalImported = 0;\n let totalFailures = 0;\n\n opts?.progressCallback?.({\n total: totalKeyCount,\n successes: totalImported,\n stage: ImportRoomKeyStage.LoadKeys,\n failures: totalFailures,\n });\n\n /**\n * This method is called when we have enough chunks to decrypt.\n * It will decrypt the chunks and try to import the room keys.\n * @param roomChunks\n */\n const handleChunkCallback = async (roomChunks: Map<string, KeyBackupRoomSessions>): Promise<void> => {\n const currentChunk: IMegolmSessionData[] = [];\n for (const roomId of roomChunks.keys()) {\n // Decrypt the sessions for the given room\n const decryptedSessions = await backupDecryptor.decryptSessions(roomChunks.get(roomId)!);\n // Add the decrypted sessions to the current chunk\n decryptedSessions.forEach((session) => {\n // We set the room_id for each session\n session.room_id = roomId;\n currentChunk.push(session);\n });\n }\n\n // We have a chunk of decrypted keys: import them\n try {\n await this.importBackedUpRoomKeys(currentChunk, backupVersion);\n totalImported += currentChunk.length;\n } catch (e) {\n totalFailures += currentChunk.length;\n // We failed to import some keys, but we should still try to import the rest?\n // Log the error and continue\n this.logger.error(\"Error importing keys from backup\", e);\n }\n\n opts?.progressCallback?.({\n total: totalKeyCount,\n successes: totalImported,\n stage: ImportRoomKeyStage.LoadKeys,\n failures: totalFailures,\n });\n };\n\n let groupChunkCount = 0;\n let chunkGroupByRoom: Map<string, KeyBackupRoomSessions> = new Map();\n\n // Iterate over the rooms and sessions to group them in chunks\n // And we call the handleChunkCallback when we have enough chunks to decrypt\n for (const [roomId, roomData] of Object.entries(keyBackup.rooms)) {\n // If there are no sessions for the room, skip it\n if (!roomData.sessions) continue;\n\n // Initialize a new chunk group for the current room\n chunkGroupByRoom.set(roomId, {});\n\n for (const [sessionId, session] of Object.entries(roomData.sessions)) {\n // We set previously the chunk group for the current room, so we can safely get it\n const sessionsForRoom = chunkGroupByRoom.get(roomId)!;\n sessionsForRoom[sessionId] = session;\n groupChunkCount += 1;\n // If we have enough chunks to decrypt, call the block callback\n if (groupChunkCount >= CHUNK_SIZE) {\n // We have enough chunks to decrypt\n await handleChunkCallback(chunkGroupByRoom);\n // Reset the chunk group\n chunkGroupByRoom = new Map();\n // There might be remaining keys for that room, so add back an entry for the current room.\n chunkGroupByRoom.set(roomId, {});\n groupChunkCount = 0;\n }\n }\n }\n\n // Handle remaining chunk if needed\n if (groupChunkCount > 0) {\n await handleChunkCallback(chunkGroupByRoom);\n }\n\n return { total: totalKeyCount, imported: totalImported };\n }\n\n /**\n * Checks if the provided backup info matches the given private key.\n *\n * @param info - The backup info to check.\n * @param backupDecryptionKey - The `BackupDecryptionKey` private key to check against.\n * @returns `true` if the private key can decrypt the backup, `false` otherwise.\n */\n private backupInfoMatchesBackupDecryptionKey(\n info: KeyBackupInfo,\n backupDecryptionKey: RustSdkCryptoJs.BackupDecryptionKey,\n ): boolean {\n if (info.algorithm !== \"m.megolm_backup.v1.curve25519-aes-sha2\") {\n this.logger.warn(\"backupMatchesPrivateKey: Unsupported backup algorithm\", info.algorithm);\n return false;\n }\n\n return (\n (info.auth_data as Curve25519AuthData)?.public_key === backupDecryptionKey.megolmV1PublicKey.publicKeyBase64\n );\n }\n}\n/**\n * Implementation of {@link BackupDecryptor} for the rust crypto backend.\n */\nexport class RustBackupDecryptor implements BackupDecryptor {\n private decryptionKey: RustSdkCryptoJs.BackupDecryptionKey;\n public sourceTrusted: boolean;\n\n public constructor(\n private readonly logger: Logger,\n decryptionKey: RustSdkCryptoJs.BackupDecryptionKey,\n ) {\n this.decryptionKey = decryptionKey;\n this.sourceTrusted = false;\n }\n\n /**\n * Implements {@link BackupDecryptor#decryptSessions}\n */\n public async decryptSessions(ciphertexts: Record<string, KeyBackupSession>): Promise<IMegolmSessionData[]> {\n const keys: IMegolmSessionData[] = [];\n for (const [sessionId, sessionData] of Object.entries(ciphertexts)) {\n try {\n const decrypted = JSON.parse(\n this.decryptionKey.decryptV1(\n sessionData.session_data.ephemeral,\n sessionData.session_data.mac,\n sessionData.session_data.ciphertext,\n ),\n );\n decrypted.session_id = sessionId;\n keys.push(decrypted);\n } catch (e) {\n this.logger.debug(\"Failed to decrypt megolm session from backup\", e, sessionData);\n }\n }\n return keys;\n }\n\n /**\n * Implements {@link BackupDecryptor#free}\n */\n public free(): void {\n this.decryptionKey.free();\n }\n}\n\n/**\n * Fetch a key backup info from the server.\n *\n * If `version` is provided, calls `GET /room_keys/version/$version` and gets the backup info for that version.\n * See https://spec.matrix.org/v1.12/client-server-api/#get_matrixclientv3room_keysversionversion.\n *\n * If not, calls `GET /room_keys/version` and gets the latest backup info.\n * See https://spec.matrix.org/v1.12/client-server-api/#get_matrixclientv3room_keysversion\n *\n * @param http\n * @param version - the specific version of the backup info to fetch\n * @returns The key backup info or null if there is no backup.\n */\nexport async function requestKeyBackupVersion(\n http: MatrixHttpApi<IHttpOpts & { onlyData: true }>,\n version?: string,\n): Promise<KeyBackupInfo | null> {\n try {\n const path = version ? encodeUri(\"/room_keys/version/$version\", { $version: version }) : \"/room_keys/version\";\n return await http.authedRequest<KeyBackupInfo>(Method.Get, path, undefined, undefined, {\n prefix: ClientPrefix.V3,\n });\n } catch (e) {\n if ((<MatrixError>e).errcode === \"M_NOT_FOUND\") {\n return null;\n } else {\n throw e;\n }\n }\n}\n\n/**\n * Checks if the provided decryption key matches the public key of the key backup info.\n *\n * @param decryptionKey - The decryption key to check.\n * @param keyBackupInfo - The key backup info to check against.\n * @returns `true` if the decryption key matches the key backup info, `false` otherwise.\n */\nexport function decryptionKeyMatchesKeyBackupInfo(\n decryptionKey: RustSdkCryptoJs.BackupDecryptionKey,\n keyBackupInfo: KeyBackupInfo,\n): boolean {\n const authData = <Curve25519AuthData>keyBackupInfo.auth_data;\n return authData.public_key === decryptionKey.megolmV1PublicKey.publicKeyBase64;\n}\n\n/**\n * Counts the total number of keys present in a key backup.\n * @param keyBackup - The key backup to count the keys from.\n * @returns The total number of keys in the backup.\n */\nfunction countKeysInBackup(keyBackup: KeyBackup): number {\n let count = 0;\n for (const { sessions } of Object.values(keyBackup.rooms)) {\n count += Object.keys(sessions).length;\n }\n return count;\n}\n\nexport type RustBackupCryptoEvents =\n | CryptoEvent.KeyBackupStatus\n | CryptoEvent.KeyBackupSessionsRemaining\n | CryptoEvent.KeyBackupFailed\n | CryptoEvent.KeyBackupDecryptionKeyCached;\n\nexport type RustBackupCryptoEventMap = {\n [CryptoEvent.KeyBackupStatus]: (enabled: boolean) => void;\n [CryptoEvent.KeyBackupSessionsRemaining]: (remaining: number) => void;\n [CryptoEvent.KeyBackupFailed]: (errCode: string) => void;\n [CryptoEvent.KeyBackupDecryptionKeyCached]: (version: string) => void;\n};\n\n/**\n * Response from GET `/room_keys/keys` endpoint.\n * See https://spec.matrix.org/latest/client-server-api/#get_matrixclientv3room_keyskeys\n */\nexport interface KeyBackup {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,CAAC,OAAO,CAAC,EAAE;IACR,IAAkB,CAAC,CAAE,OAAO,KAAK,aAAa,EAAE;MAC5C,OAAO,IAAI;IACf,CAAC,MAAM;MACH,MAAM,CAAC;IACX;EACJ;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS,iCAAiC,CAC7C,aAAkD,EAClD,aAA4B,EACrB;EACP,MAAM,QAAQ,GAAuB,aAAa,CAAC,SAAS;EAC5D,OAAO,QAAQ,CAAC,UAAU,KAAK,aAAa,CAAC,iBAAiB,CAAC,eAAe;AAClF;;AAEA;AACA;AACA;AACA;AACA;AACA,SAAS,iBAAiB,CAAC,SAAoB,EAAU;EACrD,IAAI,KAAK,GAAG,CAAC;EACb,KAAK,MAAM;IAAE;EAAS,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;IACvD,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM;EACzC;EACA,OAAO,KAAK;AAChB;;AAeA;AACA;AACA;AACA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"device-converter.d.ts","sourceRoot":"","sources":["../../src/rust-crypto/device-converter.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,eAAe,MAAM,oCAAoC,CAAC;AAEtE,OAAO,EAAE,MAAM,EAAsB,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,CAAC,MAAM,GAAG,MAAM,CAwD3G;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,UAAU,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAIjF;AAGD,KAAK,WAAW,GAAG,UAAU,CAAC,MAAM,UAAU,CAAC,CAAC;AAEhD;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAoBpE"}
1
+ {"version":3,"file":"device-converter.d.ts","sourceRoot":"","sources":["../../src/rust-crypto/device-converter.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,eAAe,MAAM,oCAAoC,CAAC;AAEtE,OAAO,EAAE,MAAM,EAAsB,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,CAAC,MAAM,GAAG,MAAM,CAwD3G;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,UAAU,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAIjF;AAGD,KAAK,WAAW,GAAG,UAAU,CAAC,MAAM,UAAU,CAAC,CAAC;AAEhD;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAqBpE"}
@@ -102,6 +102,7 @@ export function downloadDeviceToJsDevice(device) {
102
102
  const displayName = device.unsigned?.device_display_name;
103
103
  const signatures = new Map();
104
104
  if (device.signatures) {
105
+ // oxlint-disable-next-line guard-for-in
105
106
  for (const userId in device.signatures) {
106
107
  signatures.set(userId, new Map(Object.entries(device.signatures[userId])));
107
108
  }
@@ -1 +1 @@
1
- {"version":3,"file":"device-converter.js","names":[],"sources":["../../src/rust-crypto/device-converter.ts"],"sourcesContent":["/*\nCopyright 2023 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport * as RustSdkCryptoJs from \"@matrix-org/matrix-sdk-crypto-wasm\";\n\nimport { Device, DeviceVerification } from \"../models/device.ts\";\nimport { type DeviceKeys } from \"../client.ts\";\n\n/**\n * Convert a {@link RustSdkCryptoJs.Device} to a {@link Device}\n * @param device - Rust Sdk device\n * @param userId - owner of the device\n *\n * @internal\n */\nexport function rustDeviceToJsDevice(device: RustSdkCryptoJs.Device, userId: RustSdkCryptoJs.UserId): Device {\n // Copy rust device keys to Device.keys\n const keys = new Map<string, string>();\n for (const [keyId, key] of device.keys.entries()) {\n keys.set(keyId.toString(), key.toBase64());\n }\n\n // Compute verified from device state\n let verified: DeviceVerification = DeviceVerification.Unverified;\n if (device.isBlacklisted()) {\n verified = DeviceVerification.Blocked;\n } else if (device.isVerified()) {\n verified = DeviceVerification.Verified;\n }\n\n // Convert rust signatures to Device.signatures\n const signatures = new Map<string, Map<string, string>>();\n const mayBeSignatureMap: Map<string, RustSdkCryptoJs.MaybeSignature> | undefined = device.signatures.get(userId);\n if (mayBeSignatureMap) {\n const convertedSignatures = new Map<string, string>();\n // Convert maybeSignatures map to a Map<string, string>\n for (const [key, value] of mayBeSignatureMap.entries()) {\n if (value.isValid() && value.signature) {\n convertedSignatures.set(key, value.signature.toBase64());\n }\n }\n\n signatures.set(userId.toString(), convertedSignatures);\n }\n\n // Convert rust algorithms to algorithms\n const rustAlgorithms: RustSdkCryptoJs.EncryptionAlgorithm[] = device.algorithms;\n // Use set to ensure that algorithms are not duplicated\n const algorithms = new Set<string>();\n rustAlgorithms.forEach((algorithm) => {\n switch (algorithm) {\n case RustSdkCryptoJs.EncryptionAlgorithm.MegolmV1AesSha2:\n algorithms.add(\"m.megolm.v1.aes-sha2\");\n break;\n case RustSdkCryptoJs.EncryptionAlgorithm.OlmV1Curve25519AesSha2:\n default:\n algorithms.add(\"m.olm.v1.curve25519-aes-sha2\");\n break;\n }\n });\n\n return new Device({\n deviceId: device.deviceId.toString(),\n userId: userId.toString(),\n keys,\n algorithms: Array.from(algorithms),\n verified,\n signatures,\n displayName: device.displayName,\n dehydrated: device.isDehydrated,\n });\n}\n\n/**\n * Convert {@link DeviceKeys} from `/keys/query` request to a `Map<string, Device>`\n * @param deviceKeys - Device keys object to convert\n *\n * @internal\n */\nexport function deviceKeysToDeviceMap(deviceKeys: DeviceKeys): Map<string, Device> {\n return new Map(\n Object.entries(deviceKeys).map(([deviceId, device]) => [deviceId, downloadDeviceToJsDevice(device)]),\n );\n}\n\n// Device from `/keys/query` request\ntype QueryDevice = DeviceKeys[keyof DeviceKeys];\n\n/**\n * Convert `/keys/query` {@link QueryDevice} device to {@link Device}\n * @param device - Device from `/keys/query` request\n *\n * @internal\n */\nexport function downloadDeviceToJsDevice(device: QueryDevice): Device {\n const keys = new Map(Object.entries(device.keys));\n const displayName = device.unsigned?.device_display_name;\n\n const signatures = new Map<string, Map<string, string>>();\n if (device.signatures) {\n for (const userId in device.signatures) {\n signatures.set(userId, new Map(Object.entries(device.signatures[userId])));\n }\n }\n\n return new Device({\n deviceId: device.device_id,\n userId: device.user_id,\n keys,\n algorithms: device.algorithms,\n verified: DeviceVerification.Unverified,\n signatures,\n displayName,\n });\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAK,eAAe,MAAM,oCAAoC;AAErE,SAAS,MAAM,EAAE,kBAAkB,QAAQ,qBAAqB;AAGhE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS,oBAAoB,CAAC,MAA8B,EAAE,MAA8B,EAAU;EACzG;EACA,MAAM,IAAI,GAAG,IAAI,GAAG,CAAiB,CAAC;EACtC,KAAK,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE;IAC9C,IAAI,CAAC,GAA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EAAE,MAAM,CAAC,SAAS;IAC1B,MAAM,EAAE,MAAM,CAAC,OAAO;IACtB,IAAI;IACJ,UAAU,EAAE,MAAM,CAAC,UAAU;IAC7B,QAAQ,EAAE,kBAAkB,CAAC,UAAU;IACvC,UAAU;IACV;EACJ,CAAC,CAAC;AACN","ignoreList":[]}
1
+ {"version":3,"file":"device-converter.js","names":[],"sources":["../../src/rust-crypto/device-converter.ts"],"sourcesContent":["/*\nCopyright 2023 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport * as RustSdkCryptoJs from \"@matrix-org/matrix-sdk-crypto-wasm\";\n\nimport { Device, DeviceVerification } from \"../models/device.ts\";\nimport { type DeviceKeys } from \"../client.ts\";\n\n/**\n * Convert a {@link RustSdkCryptoJs.Device} to a {@link Device}\n * @param device - Rust Sdk device\n * @param userId - owner of the device\n *\n * @internal\n */\nexport function rustDeviceToJsDevice(device: RustSdkCryptoJs.Device, userId: RustSdkCryptoJs.UserId): Device {\n // Copy rust device keys to Device.keys\n const keys = new Map<string, string>();\n for (const [keyId, key] of device.keys.entries()) {\n keys.set(keyId.toString(), key.toBase64());\n }\n\n // Compute verified from device state\n let verified: DeviceVerification = DeviceVerification.Unverified;\n if (device.isBlacklisted()) {\n verified = DeviceVerification.Blocked;\n } else if (device.isVerified()) {\n verified = DeviceVerification.Verified;\n }\n\n // Convert rust signatures to Device.signatures\n const signatures = new Map<string, Map<string, string>>();\n const mayBeSignatureMap: Map<string, RustSdkCryptoJs.MaybeSignature> | undefined = device.signatures.get(userId);\n if (mayBeSignatureMap) {\n const convertedSignatures = new Map<string, string>();\n // Convert maybeSignatures map to a Map<string, string>\n for (const [key, value] of mayBeSignatureMap.entries()) {\n if (value.isValid() && value.signature) {\n convertedSignatures.set(key, value.signature.toBase64());\n }\n }\n\n signatures.set(userId.toString(), convertedSignatures);\n }\n\n // Convert rust algorithms to algorithms\n const rustAlgorithms: RustSdkCryptoJs.EncryptionAlgorithm[] = device.algorithms;\n // Use set to ensure that algorithms are not duplicated\n const algorithms = new Set<string>();\n rustAlgorithms.forEach((algorithm) => {\n switch (algorithm) {\n case RustSdkCryptoJs.EncryptionAlgorithm.MegolmV1AesSha2:\n algorithms.add(\"m.megolm.v1.aes-sha2\");\n break;\n case RustSdkCryptoJs.EncryptionAlgorithm.OlmV1Curve25519AesSha2:\n default:\n algorithms.add(\"m.olm.v1.curve25519-aes-sha2\");\n break;\n }\n });\n\n return new Device({\n deviceId: device.deviceId.toString(),\n userId: userId.toString(),\n keys,\n algorithms: Array.from(algorithms),\n verified,\n signatures,\n displayName: device.displayName,\n dehydrated: device.isDehydrated,\n });\n}\n\n/**\n * Convert {@link DeviceKeys} from `/keys/query` request to a `Map<string, Device>`\n * @param deviceKeys - Device keys object to convert\n *\n * @internal\n */\nexport function deviceKeysToDeviceMap(deviceKeys: DeviceKeys): Map<string, Device> {\n return new Map(\n Object.entries(deviceKeys).map(([deviceId, device]) => [deviceId, downloadDeviceToJsDevice(device)]),\n );\n}\n\n// Device from `/keys/query` request\ntype QueryDevice = DeviceKeys[keyof DeviceKeys];\n\n/**\n * Convert `/keys/query` {@link QueryDevice} device to {@link Device}\n * @param device - Device from `/keys/query` request\n *\n * @internal\n */\nexport function downloadDeviceToJsDevice(device: QueryDevice): Device {\n const keys = new Map(Object.entries(device.keys));\n const displayName = device.unsigned?.device_display_name;\n\n const signatures = new Map<string, Map<string, string>>();\n if (device.signatures) {\n // oxlint-disable-next-line guard-for-in\n for (const userId in device.signatures) {\n signatures.set(userId, new Map(Object.entries(device.signatures[userId])));\n }\n }\n\n return new Device({\n deviceId: device.device_id,\n userId: device.user_id,\n keys,\n algorithms: device.algorithms,\n verified: DeviceVerification.Unverified,\n signatures,\n displayName,\n });\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAK,eAAe,MAAM,oCAAoC;AAErE,SAAS,MAAM,EAAE,kBAAkB,QAAQ,qBAAqB;AAGhE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS,oBAAoB,CAAC,MAA8B,EAAE,MAA8B,EAAU;EACzG;EACA,MAAM,IAAI,GAAG,IAAI,GAAG,CAAiB,CAAC;EACtC,KAAK,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE;IAC9C,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;EAC9C;;EAEA;EACA,IAAI,QAA4B,GAAG,kBAAkB,CAAC,UAAU;EAChE,IAAI,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE;IACxB,QAAQ,GAAG,kBAAkB,CAAC,OAAO;EACzC,CAAC,MAAM,IAAI,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE;IAC5B,QAAQ,GAAG,kBAAkB,CAAC,QAAQ;EAC1C;;EAEA;EACA,MAAM,UAAU,GAAG,IAAI,GAAG,CAA8B,CAAC;EACzD,MAAM,iBAA0E,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC;EAChH,IAAI,iBAAiB,EAAE;IACnB,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAiB,CAAC;IACrD;IACA,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAC,EAAE;MACpD,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,KAAK,CAAC,SAA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O,SAAS,wBAAwB,CAAC,MAAmB,EAAU;EAClE,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;EACjD,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,EAAE,mBAAmB;EAExD,MAAM,UAAU,GAAG,IAAI,GAAG,CAA8B,CAAC;EACzD,IAAI,MAAM,CAAC,UAAU,EAAE;IACnB;IACA,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,UAAU,EAAE;MACpC,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC9E;EACJ;EAEA,OAAO,IAAI,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC,SAAS;IAC1B,MAAM,EAAE,MAAM,CAAC,OAAO;IACtB,IAAI;IACJ,UAAU,EAAE,MAAM,CAAC,UAAU;IAC7B,QAAQ,EAAE,kBAAkB,CAAC,UAAU;IACvC,UAAU;IACV;EACJ,CAAC,CAAC;AACN","ignoreList":[]}
@@ -5,12 +5,11 @@ import { type Logger } from "../logger.ts";
5
5
  import { type CryptoStore } from "../crypto/store/base.ts";
6
6
  import { type CryptoCallbacks } from "../crypto-api/index.ts";
7
7
  /**
8
- * Create a new `RustCrypto` implementation
8
+ * The arguments used to initialise RustCrypto, passed in to initRustCrypto.
9
9
  *
10
- * @param args - Parameter object
11
10
  * @internal
12
11
  */
13
- export declare function initRustCrypto(args: {
12
+ export interface InitRustCryptoArgs {
14
13
  /** A `Logger` instance that will be used for debug output. */
15
14
  logger: Logger;
16
15
  /**
@@ -61,5 +60,19 @@ export declare function initRustCrypto(args: {
61
60
  * Whether to enable support for encrypting state events.
62
61
  */
63
62
  enableEncryptedStateEvents?: boolean;
64
- }): Promise<RustCrypto>;
63
+ /**
64
+ * Optional PEM-formatted string that provides CA certificates. These will
65
+ * be used to check X.509 signatures on user identities. Any user identity
66
+ * that has a valid signature according to the supplied CAs will be
67
+ * considered verified, without any manual verification taking place.
68
+ */
69
+ caCertsPem?: string;
70
+ }
71
+ /**
72
+ * Create a new `RustCrypto` implementation
73
+ *
74
+ * @param args - InitRustCryptoArgs
75
+ * @internal
76
+ */
77
+ export declare function initRustCrypto(args: InitRustCryptoArgs): Promise<RustCrypto>;
65
78
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rust-crypto/index.ts"],"names":[],"mappings":"AAmBA,OAAO,EAA2C,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACvF,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,KAAK,WAAW,EAAkB,MAAM,yBAAyB,CAAC;AAM3E,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACvC,8DAA8D;IAC9D,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,IAAI,EAAE,aAAa,CAAC,SAAS,GAAG;QAAE,QAAQ,EAAE,IAAI,CAAA;KAAE,CAAC,CAAC;IAEpD,gCAAgC;IAChC,MAAM,EAAE,MAAM,CAAC;IAEf,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAC;IAEjB,+CAA+C;IAC/C,aAAa,EAAE,uBAAuB,CAAC;IAEvC,oDAAoD;IACpD,eAAe,EAAE,eAAe,CAAC;IAEjC;;;OAGG;IACH,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAE3B;;;;;OAKG;IACH,eAAe,CAAC,EAAE,MAAM,C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,IAAI,CAAC;IAE3B;;;;;OAKG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,UAAU,CAAC;IAEtB,+FAA+F;IAC/F,iBAAiB,CAAC,EAAE,WAAW,CAAC;IAEhC,6CAA6C;IAC7C,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;OAIG;IACH,+BAA+B,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAE5E;;OAEG;IACH,0BAA0B,CAAC,EAAE,OAAO,CAAC;IAErC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,UAAU,CAAC,CAkClF"}
@@ -20,10 +20,17 @@ import { StoreHandle } from "@matrix-org/matrix-sdk-crypto-wasm";
20
20
  import { MAX_INVITE_ACCEPTANCE_MS_FOR_KEY_BUNDLE, RustCrypto } from "./rust-crypto.js";
21
21
  import { MigrationState } from "../crypto/store/base.js";
22
22
  import { migrateFromLegacyCrypto, migrateLegacyLocalTrustIfNeeded, migrateRoomSettingsFromLegacyCrypto } from "./libolm_migration.js";
23
+
24
+ /**
25
+ * The arguments used to initialise RustCrypto, passed in to initRustCrypto.
26
+ *
27
+ * @internal
28
+ */
29
+
23
30
  /**
24
31
  * Create a new `RustCrypto` implementation
25
32
  *
26
- * @param args - Parameter object
33
+ * @param args - InitRustCryptoArgs
27
34
  * @internal
28
35
  */
29
36
  export async function initRustCrypto(args) {
@@ -52,14 +59,24 @@ export async function initRustCrypto(args) {
52
59
  storeHandle
53
60
  }, args));
54
61
  }
55
- const rustCrypto = await initOlmMachine(logger, args.http, args.userId, args.deviceId, args.secretStorage, args.cryptoCallbacks, storeHandle, args.legacyCryptoStore, args.enableEncryptedStateEvents);
62
+ const rustCrypto = await initOlmMachine(args, storeHandle);
56
63
  storeHandle.free();
57
64
  logger.debug("Completed rust crypto-sdk setup");
58
65
  return rustCrypto;
59
66
  }
60
- async function initOlmMachine(logger, http, userId, deviceId, secretStorage, cryptoCallbacks, storeHandle, legacyCryptoStore, enableEncryptedStateEvents) {
67
+ async function initOlmMachine({
68
+ logger,
69
+ http,
70
+ userId,
71
+ deviceId,
72
+ secretStorage,
73
+ cryptoCallbacks,
74
+ legacyCryptoStore,
75
+ enableEncryptedStateEvents,
76
+ caCertsPem
77
+ }, storeHandle) {
61
78
  logger.debug("Init OlmMachine");
62
- const olmMachine = await RustSdkCryptoJs.OlmMachine.initFromStore(new RustSdkCryptoJs.UserId(userId), new RustSdkCryptoJs.DeviceId(deviceId), storeHandle, logger);
79
+ const olmMachine = await RustSdkCryptoJs.OlmMachine.initFromStore(new RustSdkCryptoJs.UserId(userId), new RustSdkCryptoJs.DeviceId(deviceId), storeHandle, logger, caCertsPem);
63
80
 
64
81
  // A final migration step, now that we have an OlmMachine.
65
82
  if (legacyCryptoStore) {