@openclaw/matrix 2026.7.2-beta.7 → 2026.7.34

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 (368) hide show
  1. package/README.md +1 -1
  2. package/dist/{account-selection-kqquRzCf.js → .setup/account-selection-BOQeTqax.mjs} +18 -17
  3. package/dist/{approval-handler.runtime-DSeaIsGa.js → .setup/approval-handler.runtime-CEXm9_-p.mjs} +18 -28
  4. package/dist/{approval-ids-BdJGPAJT.js → .setup/approval-ids-DdFnDB3h.mjs} +1 -1
  5. package/dist/{approval-reaction-auth-BjOpELxu.js → .setup/approval-reaction-auth-CREvd7S7.mjs} +2 -2
  6. package/dist/.setup/approval-reactions-Cltyp8nL.mjs +113 -0
  7. package/dist/.setup/async-lock-BcLS4KOc.mjs +19 -0
  8. package/dist/{channel-vj788dNZ.js → .setup/channel-an4umty1.mjs} +186 -144
  9. package/dist/{channel.runtime-CLoF2S9T.js → .setup/channel.runtime-GHcIBJ7H.mjs} +51 -45
  10. package/dist/{cli-DMqfDE-q.js → .setup/cli-B3WYmv5U.mjs} +882 -901
  11. package/dist/{cli-metadata-C7D53SND.js → .setup/cli-metadata-RUKCn0wJ.mjs} +1 -1
  12. package/dist/{client-6eRENr7k.js → .setup/client-Ct0bUHCo.mjs} +5 -5
  13. package/dist/{shared-CUMWxcMz.js → .setup/client-DFBQtzCe.mjs} +422 -179
  14. package/dist/.setup/client-bootstrap-Be8jvNle.mjs +74 -0
  15. package/dist/{config-schema-Djxw3C6b.js → .setup/config-schema-D9J_vUF6.mjs} +89 -70
  16. package/dist/.setup/credentials-BhZlA0kL.mjs +56 -0
  17. package/dist/.setup/credentials-read-CRHg6XPm.mjs +114 -0
  18. package/dist/{credentials-write.runtime-Be9zNSUw.js → .setup/credentials-write.runtime-dWuLafsk.mjs} +1 -1
  19. package/dist/{crypto-runtime-D9_6J5tZ.js → .setup/crypto-runtime-D-cZa8P0.mjs} +81 -35
  20. package/dist/.setup/crypto-state-store-B43k3z3W.mjs +352 -0
  21. package/dist/{deps-CcVJfvRM.js → .setup/deps-Dy6yreL4.mjs} +92 -25
  22. package/dist/{device-health-B4-YXtJR.js → .setup/device-health-D4LBxuPq.mjs} +1 -6
  23. package/dist/{directory-live-C8dVBiCc.js → .setup/directory-live-BTEYxMwy.mjs} +10 -9
  24. package/dist/.setup/doctor-BGnvMzOR.mjs +169 -0
  25. package/dist/.setup/doctor-contract-DNJw0fdq.mjs +246 -0
  26. package/dist/{draft-stream-CtvOXq0Z.js → .setup/draft-stream-C-_OhpE8.mjs} +1 -6
  27. package/dist/{encryption-guidance-CbEFe38F.js → .setup/encryption-guidance-CpuuwmjL.mjs} +4 -3
  28. package/dist/{env-auth-CQsYbz-p.js → .setup/env-auth-CYJL1jNl.mjs} +2 -2
  29. package/dist/{env-vars-B0NxQnPk.js → .setup/env-vars-KzaYveuy.mjs} +1 -3
  30. package/dist/{exec-approval-resolver-BCgqRtZS.js → .setup/exec-approval-resolver-f9j6staN.mjs} +1 -2
  31. package/dist/{file-sync-store-DiiFsayX.js → .setup/file-sync-store-DU0cnYAz.mjs} +30 -25
  32. package/dist/{http-client-CycYxU9-.js → .setup/http-client-C954In2D.mjs} +45 -25
  33. package/dist/{idb-persistence-B6x7dMsF.js → .setup/idb-persistence-_HKTXkVC.mjs} +76 -78
  34. package/dist/{idb-persistence-lock-DAJ49nZX.js → .setup/idb-persistence-lock-B3fZXyF_.mjs} +1 -1
  35. package/dist/.setup/legacy-crypto-inspector-Byp8LCys.mjs +42 -0
  36. package/dist/.setup/legacy-crypto-restore-YQVoK1B2.mjs +93 -0
  37. package/dist/{logger-D0GCSDQq.js → .setup/logger-DpoogOgz.mjs} +1 -1
  38. package/dist/{logging-DV-p52N0.js → .setup/logging-CgxQOJJP.mjs} +2 -9
  39. package/dist/.setup/matrix-migration.runtime-BDH5c3fN.mjs +530 -0
  40. package/dist/{media-text-BTwzADS_.js → .setup/media-text-Cib-dxkn.mjs} +1 -1
  41. package/dist/{messages-DxQJkhxs.js → .setup/messages-D4DYGHYX.mjs} +15 -67
  42. package/dist/.setup/migration-snapshot-backup-CpgYhiUp.mjs +70 -0
  43. package/dist/.setup/migration-snapshot.runtime-O8qkMVaC.mjs +2 -0
  44. package/dist/{monitor-VyWlSLwo.js → .setup/monitor-DNcW_oAN.mjs} +2525 -2361
  45. package/dist/.setup/probe.runtime-CMPh0mFk.mjs +2 -0
  46. package/dist/{profile-update-CffmyW_4.js → .setup/profile-update-DzOL3Wiw.mjs} +5 -4
  47. package/dist/{reaction-events-B00WSi98.js → .setup/reaction-events-BcvgXxHb.mjs} +14 -64
  48. package/dist/{resolve-targets-nm2L48sh.js → .setup/resolve-targets-Bq80X9Sn.mjs} +3 -3
  49. package/dist/{resolver.runtime-DS6uPaEe.js → .setup/resolver.runtime-CeBHR9-T.mjs} +1 -1
  50. package/dist/{runtime-api-D1xI_cvh.js → .setup/runtime-api-CEsWNdil.mjs} +4 -4
  51. package/dist/.setup/runtime-setter-api-DGMubGUq.mjs +3 -0
  52. package/dist/{sdk-bUytQHx7.js → .setup/sdk-He1quVAq.mjs} +592 -261
  53. package/dist/.setup/secret-contract-api-CiTJ7pd5.mjs +3 -0
  54. package/dist/{secret-contract-M3hRmGO-.js → .setup/secret-contract-phPvlNfV.mjs} +53 -28
  55. package/dist/{send-BldGYG8g.js → .setup/send-CGgl0uTn.mjs} +133 -660
  56. package/dist/{setup-bootstrap-Deleiibz.js → .setup/setup-bootstrap-DUXBC8X2.mjs} +4 -4
  57. package/dist/{setup-core-BVfBv2ai.js → .setup/setup-core-bhdcEo7v.mjs} +239 -189
  58. package/dist/.setup/setup-plugin-api-CAwZ_Bi7.mjs +43 -0
  59. package/dist/.setup/setup-plugin-api-DIFVsOs3.mjs +2 -0
  60. package/dist/{setup-surface-BBq3WeqX.js → .setup/setup-surface-05_G-MnT.mjs} +149 -92
  61. package/dist/{startup-verification-wm3_i88s.js → .setup/startup-verification-BTwIGu1J.mjs} +7 -6
  62. package/dist/.setup/storage-NGZq5zet.mjs +432 -0
  63. package/dist/{storage-paths-gUmSydsW.js → .setup/storage-paths-BWo_ZEMC.mjs} +13 -2
  64. package/dist/{subagent-hooks-dkPAF6Et.js → .setup/subagent-hooks-BSWPJEmo.mjs} +2 -2
  65. package/dist/{thread-binding-api-DRbBZlhS.js → .setup/thread-binding-api-B7UaOoKv.mjs} +1 -1
  66. package/dist/{thread-bindings-DGbl3vDW.js → .setup/thread-bindings-DqmjG2on.mjs} +8 -8
  67. package/dist/{tool-actions.runtime-uu9blSqO.js → .setup/tool-actions.runtime-CXDLk2jg.mjs} +196 -332
  68. package/dist/{verification-DYMQ1QpI.js → .setup/verification-DeWOtZJr.mjs} +4 -3
  69. package/dist/api.js +9 -9
  70. package/dist/auth-presence.js +21 -13
  71. package/dist/channel-plugin-api.js +1 -1
  72. package/dist/cli-metadata.js +1 -1
  73. package/dist/contract-api.js +2 -2
  74. package/dist/doctor-contract-api.js +99 -524
  75. package/dist/helper-api.js +4 -4
  76. package/dist/index.js +1 -1
  77. package/dist/plugin-entry.handlers.runtime.js +2 -2
  78. package/dist/runtime-api.js +8 -8
  79. package/dist/runtime-heavy-api.js +3 -0
  80. package/dist/runtime-setter-api.js +1 -1
  81. package/dist/secret-contract-api.js +1 -1
  82. package/dist/session-binding-contract-api.js +3 -3
  83. package/dist/setup-entry.js +4 -3
  84. package/dist/setup-plugin-api.js +1 -44
  85. package/dist/subagent-hooks-api.js +1 -1
  86. package/dist/thread-binding-api.js +1 -1
  87. package/dist/thread-bindings-runtime.js +1 -1
  88. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/package.json +1 -1
  89. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm.d.ts +2 -14
  90. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.cjs +384 -409
  91. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.js +224 -246
  92. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.wasm +0 -0
  93. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.wasm.d.ts +58 -59
  94. package/node_modules/markdown-it/README.md +18 -294
  95. package/node_modules/markdown-it/bin/markdown-it.mjs +2 -2
  96. package/node_modules/markdown-it/dist/browser/markdown-it.esm.min.mjs +3013 -0
  97. package/node_modules/markdown-it/dist/browser/markdown-it.esm.min.mjs.map +1 -0
  98. package/node_modules/markdown-it/dist/browser/markdown-it.umd.min.js +14 -0
  99. package/node_modules/markdown-it/dist/browser/markdown-it.umd.min.js.map +1 -0
  100. package/node_modules/markdown-it/dist/markdown-it.cjs.js +4420 -0
  101. package/node_modules/markdown-it/dist/markdown-it.cjs.js.map +1 -0
  102. package/node_modules/markdown-it/dist/markdown-it.d.cts +19 -0
  103. package/node_modules/markdown-it/dist/markdown-it.d.mts +950 -0
  104. package/node_modules/markdown-it/dist/{index.cjs.js → markdown-it.mjs} +1504 -1525
  105. package/node_modules/markdown-it/dist/markdown-it.mjs.map +1 -0
  106. package/node_modules/markdown-it/node_modules/argparse/LICENSE +1 -208
  107. package/node_modules/markdown-it/node_modules/argparse/README.md +46 -41
  108. package/node_modules/markdown-it/node_modules/argparse/lib/_colorize.js +72 -0
  109. package/node_modules/markdown-it/node_modules/argparse/lib/argparse.d.ts +292 -0
  110. package/node_modules/markdown-it/node_modules/argparse/{argparse.js → lib/argparse.js} +1142 -1029
  111. package/node_modules/markdown-it/node_modules/argparse/lib/difflib.js +190 -0
  112. package/node_modules/markdown-it/node_modules/argparse/lib/sub.js +4 -4
  113. package/node_modules/markdown-it/node_modules/argparse/lib/textwrap.js +28 -28
  114. package/node_modules/markdown-it/node_modules/argparse/package.json +18 -11
  115. package/node_modules/markdown-it/node_modules/entities/dist/decode-codepoint.d.ts +8 -0
  116. package/node_modules/markdown-it/node_modules/entities/dist/decode-codepoint.d.ts.map +1 -0
  117. package/node_modules/markdown-it/node_modules/entities/dist/decode-codepoint.js +46 -0
  118. package/node_modules/markdown-it/node_modules/entities/dist/decode-codepoint.js.map +1 -0
  119. package/node_modules/markdown-it/node_modules/entities/{lib → dist}/decode.d.ts +28 -45
  120. package/node_modules/markdown-it/node_modules/entities/dist/decode.d.ts.map +1 -0
  121. package/node_modules/markdown-it/node_modules/entities/{lib/esm → dist}/decode.js +189 -141
  122. package/node_modules/markdown-it/node_modules/entities/dist/decode.js.map +1 -0
  123. package/node_modules/markdown-it/node_modules/entities/{lib/esm → dist}/encode.d.ts +4 -2
  124. package/node_modules/markdown-it/node_modules/entities/dist/encode.d.ts.map +1 -0
  125. package/node_modules/markdown-it/node_modules/entities/dist/encode.js +90 -0
  126. package/node_modules/markdown-it/node_modules/entities/dist/encode.js.map +1 -0
  127. package/node_modules/markdown-it/node_modules/entities/{lib → dist}/escape.d.ts +15 -10
  128. package/node_modules/markdown-it/node_modules/entities/dist/escape.d.ts.map +1 -0
  129. package/node_modules/markdown-it/node_modules/entities/dist/escape.js +132 -0
  130. package/node_modules/markdown-it/node_modules/entities/dist/escape.js.map +1 -0
  131. package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-html.d.ts +3 -0
  132. package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-html.d.ts.map +1 -0
  133. package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-html.js +5 -0
  134. package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-html.js.map +1 -0
  135. package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-xml.d.ts +3 -0
  136. package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-xml.d.ts.map +1 -0
  137. package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-xml.js +5 -0
  138. package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-xml.js.map +1 -0
  139. package/node_modules/markdown-it/node_modules/entities/dist/generated/encode-html.d.ts +5 -0
  140. package/node_modules/markdown-it/node_modules/entities/dist/generated/encode-html.d.ts.map +1 -0
  141. package/node_modules/markdown-it/node_modules/entities/dist/generated/encode-html.js +12 -0
  142. package/node_modules/markdown-it/node_modules/entities/dist/generated/encode-html.js.map +1 -0
  143. package/node_modules/markdown-it/node_modules/entities/{lib/esm → dist}/index.d.ts +14 -21
  144. package/node_modules/markdown-it/node_modules/entities/dist/index.d.ts.map +1 -0
  145. package/node_modules/markdown-it/node_modules/entities/dist/index.js +91 -0
  146. package/node_modules/markdown-it/node_modules/entities/dist/index.js.map +1 -0
  147. package/node_modules/markdown-it/node_modules/entities/dist/internal/bin-trie-flags.d.ts +17 -0
  148. package/node_modules/markdown-it/node_modules/entities/dist/internal/bin-trie-flags.d.ts.map +1 -0
  149. package/node_modules/markdown-it/node_modules/entities/dist/internal/bin-trie-flags.js +18 -0
  150. package/node_modules/markdown-it/node_modules/entities/dist/internal/bin-trie-flags.js.map +1 -0
  151. package/node_modules/markdown-it/node_modules/entities/dist/internal/decode-shared.d.ts +7 -0
  152. package/node_modules/markdown-it/node_modules/entities/dist/internal/decode-shared.d.ts.map +1 -0
  153. package/node_modules/markdown-it/node_modules/entities/dist/internal/decode-shared.js +17 -0
  154. package/node_modules/markdown-it/node_modules/entities/dist/internal/decode-shared.js.map +1 -0
  155. package/node_modules/markdown-it/node_modules/entities/dist/internal/encode-shared.d.ts +33 -0
  156. package/node_modules/markdown-it/node_modules/entities/dist/internal/encode-shared.d.ts.map +1 -0
  157. package/node_modules/markdown-it/node_modules/entities/dist/internal/encode-shared.js +93 -0
  158. package/node_modules/markdown-it/node_modules/entities/dist/internal/encode-shared.js.map +1 -0
  159. package/node_modules/markdown-it/node_modules/entities/package.json +63 -70
  160. package/node_modules/markdown-it/node_modules/entities/readme.md +54 -45
  161. package/node_modules/markdown-it/node_modules/entities/src/decode-codepoint.ts +50 -0
  162. package/node_modules/markdown-it/node_modules/entities/src/decode.ts +671 -0
  163. package/node_modules/markdown-it/node_modules/entities/src/encode.ts +95 -0
  164. package/node_modules/markdown-it/node_modules/entities/src/escape.ts +160 -0
  165. package/node_modules/markdown-it/node_modules/entities/src/generated/decode-data-html.ts +7 -0
  166. package/node_modules/markdown-it/node_modules/entities/src/generated/decode-data-xml.ts +7 -0
  167. package/node_modules/markdown-it/node_modules/entities/src/generated/encode-html.ts +18 -0
  168. package/node_modules/markdown-it/node_modules/entities/src/index.ts +162 -0
  169. package/node_modules/markdown-it/node_modules/entities/src/internal/bin-trie-flags.ts +16 -0
  170. package/node_modules/markdown-it/node_modules/entities/src/internal/decode-shared.ts +18 -0
  171. package/node_modules/markdown-it/node_modules/entities/src/internal/encode-shared.ts +123 -0
  172. package/node_modules/markdown-it/node_modules/linkify-it/README.md +49 -86
  173. package/node_modules/markdown-it/node_modules/linkify-it/build/index.cjs.js +636 -825
  174. package/node_modules/markdown-it/node_modules/linkify-it/build/index.cjs.js.map +1 -0
  175. package/node_modules/markdown-it/node_modules/linkify-it/build/index.d.ts +236 -0
  176. package/node_modules/markdown-it/node_modules/linkify-it/build/index.mjs +538 -0
  177. package/node_modules/markdown-it/node_modules/linkify-it/build/index.mjs.map +1 -0
  178. package/node_modules/markdown-it/node_modules/linkify-it/package.json +23 -20
  179. package/node_modules/markdown-it/node_modules/uc.micro/README.md +18 -1
  180. package/node_modules/markdown-it/node_modules/uc.micro/build/index.cjs.js +13 -18
  181. package/node_modules/markdown-it/node_modules/uc.micro/build/index.d.ts +6 -0
  182. package/node_modules/markdown-it/node_modules/uc.micro/build/index.mjs +8 -0
  183. package/node_modules/markdown-it/node_modules/uc.micro/package.json +12 -17
  184. package/node_modules/markdown-it/package.json +47 -30
  185. package/node_modules/matrix-js-sdk/CHANGELOG.md +0 -11
  186. package/node_modules/matrix-js-sdk/package.json +1 -1
  187. package/node_modules/music-metadata/lib/common/Util.d.ts +1 -1
  188. package/node_modules/music-metadata/lib/common/Util.js +1 -7
  189. package/node_modules/music-metadata/lib/id3v2/FrameHeader.js +3 -23
  190. package/node_modules/music-metadata/lib/id3v2/FrameParser.js +2 -2
  191. package/node_modules/music-metadata/lib/id3v2/ID3v2Token.js +1 -1
  192. package/node_modules/music-metadata/lib/mp4/AtomToken.js +13 -38
  193. package/node_modules/music-metadata/lib/mpeg/MpegParser.js +1 -1
  194. package/node_modules/music-metadata/package.json +6 -6
  195. package/node_modules/typebox/build/compile/validator.d.mts +4 -1
  196. package/node_modules/typebox/build/guard/guard.d.mts +1 -1
  197. package/node_modules/typebox/build/guard/guard.mjs +2 -5
  198. package/node_modules/typebox/build/guard/string.mjs +4 -16
  199. package/node_modules/typebox/build/schema/engine/_functions.mjs +15 -34
  200. package/node_modules/typebox/build/type/action/readonly_object.d.mts +0 -5
  201. package/node_modules/typebox/build/type/action/readonly_object.mjs +0 -8
  202. package/node_modules/typebox/build/typebox.d.mts +1 -1
  203. package/node_modules/typebox/build/typebox.mjs +1 -1
  204. package/node_modules/typebox/package.json +1 -1
  205. package/node_modules/typebox/readme.md +32 -29
  206. package/openclaw.plugin.json +146 -152
  207. package/package.json +31 -114
  208. package/dist/accounts-DfngqebB.js +0 -130
  209. package/dist/active-client-DXvz2gCo.js +0 -20
  210. package/dist/approval-reactions-D-BxBK_L.js +0 -202
  211. package/dist/client-Dbso3-0V.js +0 -30
  212. package/dist/client-bootstrap-XsIkHNt0.js +0 -110
  213. package/dist/create-client-BmSU-q-D.js +0 -61
  214. package/dist/credentials-W2EmwRhu.js +0 -65
  215. package/dist/credentials-read-DVmFCm7X.js +0 -77
  216. package/dist/doctor-CM8ijNpW.js +0 -64
  217. package/dist/doctor-contract-BMSJkkAE.js +0 -167
  218. package/dist/inbound-dedupe-CaBLblef.js +0 -48
  219. package/dist/probe.runtime-BuieqmS3.js +0 -3
  220. package/dist/record-shared-CWWx6fvI.js +0 -2
  221. package/dist/recovery-key-store-BNnHvXdk.js +0 -275
  222. package/dist/room-info-CAFZ3Z9J.js +0 -87
  223. package/dist/route-DY6at4qJ.js +0 -161
  224. package/dist/storage-BvAkgzvT.js +0 -685
  225. package/node_modules/markdown-it/dist/index.cjs.js.map +0 -1
  226. package/node_modules/markdown-it/dist/markdown-it.js +0 -3975
  227. package/node_modules/markdown-it/dist/markdown-it.js.map +0 -1
  228. package/node_modules/markdown-it/dist/markdown-it.min.js +0 -3
  229. package/node_modules/markdown-it/dist/markdown-it.min.js.map +0 -1
  230. package/node_modules/markdown-it/index.mjs +0 -1
  231. package/node_modules/markdown-it/lib/common/html_blocks.mjs +0 -67
  232. package/node_modules/markdown-it/lib/common/html_re.mjs +0 -25
  233. package/node_modules/markdown-it/lib/common/utils.mjs +0 -324
  234. package/node_modules/markdown-it/lib/helpers/index.mjs +0 -11
  235. package/node_modules/markdown-it/lib/helpers/parse_link_destination.mjs +0 -77
  236. package/node_modules/markdown-it/lib/helpers/parse_link_label.mjs +0 -49
  237. package/node_modules/markdown-it/lib/helpers/parse_link_title.mjs +0 -66
  238. package/node_modules/markdown-it/lib/index.mjs +0 -565
  239. package/node_modules/markdown-it/lib/parser_block.mjs +0 -134
  240. package/node_modules/markdown-it/lib/parser_core.mjs +0 -62
  241. package/node_modules/markdown-it/lib/parser_inline.mjs +0 -197
  242. package/node_modules/markdown-it/lib/presets/commonmark.mjs +0 -88
  243. package/node_modules/markdown-it/lib/presets/default.mjs +0 -47
  244. package/node_modules/markdown-it/lib/presets/zero.mjs +0 -70
  245. package/node_modules/markdown-it/lib/renderer.mjs +0 -322
  246. package/node_modules/markdown-it/lib/ruler.mjs +0 -340
  247. package/node_modules/markdown-it/lib/rules_block/blockquote.mjs +0 -209
  248. package/node_modules/markdown-it/lib/rules_block/code.mjs +0 -30
  249. package/node_modules/markdown-it/lib/rules_block/fence.mjs +0 -94
  250. package/node_modules/markdown-it/lib/rules_block/heading.mjs +0 -51
  251. package/node_modules/markdown-it/lib/rules_block/hr.mjs +0 -40
  252. package/node_modules/markdown-it/lib/rules_block/html_block.mjs +0 -80
  253. package/node_modules/markdown-it/lib/rules_block/lheading.mjs +0 -85
  254. package/node_modules/markdown-it/lib/rules_block/list.mjs +0 -331
  255. package/node_modules/markdown-it/lib/rules_block/paragraph.mjs +0 -48
  256. package/node_modules/markdown-it/lib/rules_block/reference.mjs +0 -212
  257. package/node_modules/markdown-it/lib/rules_block/state_block.mjs +0 -220
  258. package/node_modules/markdown-it/lib/rules_block/table.mjs +0 -228
  259. package/node_modules/markdown-it/lib/rules_core/block.mjs +0 -13
  260. package/node_modules/markdown-it/lib/rules_core/inline.mjs +0 -11
  261. package/node_modules/markdown-it/lib/rules_core/linkify.mjs +0 -134
  262. package/node_modules/markdown-it/lib/rules_core/normalize.mjs +0 -17
  263. package/node_modules/markdown-it/lib/rules_core/replacements.mjs +0 -101
  264. package/node_modules/markdown-it/lib/rules_core/smartquotes.mjs +0 -209
  265. package/node_modules/markdown-it/lib/rules_core/state_core.mjs +0 -17
  266. package/node_modules/markdown-it/lib/rules_core/text_join.mjs +0 -43
  267. package/node_modules/markdown-it/lib/rules_inline/autolink.mjs +0 -72
  268. package/node_modules/markdown-it/lib/rules_inline/backticks.mjs +0 -60
  269. package/node_modules/markdown-it/lib/rules_inline/balance_pairs.mjs +0 -124
  270. package/node_modules/markdown-it/lib/rules_inline/emphasis.mjs +0 -123
  271. package/node_modules/markdown-it/lib/rules_inline/entity.mjs +0 -51
  272. package/node_modules/markdown-it/lib/rules_inline/escape.mjs +0 -83
  273. package/node_modules/markdown-it/lib/rules_inline/fragments_join.mjs +0 -38
  274. package/node_modules/markdown-it/lib/rules_inline/html_inline.mjs +0 -50
  275. package/node_modules/markdown-it/lib/rules_inline/image.mjs +0 -138
  276. package/node_modules/markdown-it/lib/rules_inline/link.mjs +0 -139
  277. package/node_modules/markdown-it/lib/rules_inline/linkify.mjs +0 -63
  278. package/node_modules/markdown-it/lib/rules_inline/newline.mjs +0 -42
  279. package/node_modules/markdown-it/lib/rules_inline/state_inline.mjs +0 -154
  280. package/node_modules/markdown-it/lib/rules_inline/strikethrough.mjs +0 -127
  281. package/node_modules/markdown-it/lib/rules_inline/text.mjs +0 -86
  282. package/node_modules/markdown-it/lib/token.mjs +0 -191
  283. package/node_modules/markdown-it/node_modules/argparse/CHANGELOG.md +0 -216
  284. package/node_modules/markdown-it/node_modules/entities/lib/decode.d.ts.map +0 -1
  285. package/node_modules/markdown-it/node_modules/entities/lib/decode.js +0 -536
  286. package/node_modules/markdown-it/node_modules/entities/lib/decode.js.map +0 -1
  287. package/node_modules/markdown-it/node_modules/entities/lib/decode_codepoint.d.ts +0 -19
  288. package/node_modules/markdown-it/node_modules/entities/lib/decode_codepoint.d.ts.map +0 -1
  289. package/node_modules/markdown-it/node_modules/entities/lib/decode_codepoint.js +0 -76
  290. package/node_modules/markdown-it/node_modules/entities/lib/decode_codepoint.js.map +0 -1
  291. package/node_modules/markdown-it/node_modules/entities/lib/encode.d.ts +0 -22
  292. package/node_modules/markdown-it/node_modules/entities/lib/encode.d.ts.map +0 -1
  293. package/node_modules/markdown-it/node_modules/entities/lib/encode.js +0 -77
  294. package/node_modules/markdown-it/node_modules/entities/lib/encode.js.map +0 -1
  295. package/node_modules/markdown-it/node_modules/entities/lib/escape.d.ts.map +0 -1
  296. package/node_modules/markdown-it/node_modules/entities/lib/escape.js +0 -122
  297. package/node_modules/markdown-it/node_modules/entities/lib/escape.js.map +0 -1
  298. package/node_modules/markdown-it/node_modules/entities/lib/esm/decode.d.ts +0 -211
  299. package/node_modules/markdown-it/node_modules/entities/lib/esm/decode.d.ts.map +0 -1
  300. package/node_modules/markdown-it/node_modules/entities/lib/esm/decode.js.map +0 -1
  301. package/node_modules/markdown-it/node_modules/entities/lib/esm/decode_codepoint.d.ts +0 -19
  302. package/node_modules/markdown-it/node_modules/entities/lib/esm/decode_codepoint.d.ts.map +0 -1
  303. package/node_modules/markdown-it/node_modules/entities/lib/esm/decode_codepoint.js +0 -71
  304. package/node_modules/markdown-it/node_modules/entities/lib/esm/decode_codepoint.js.map +0 -1
  305. package/node_modules/markdown-it/node_modules/entities/lib/esm/encode.d.ts.map +0 -1
  306. package/node_modules/markdown-it/node_modules/entities/lib/esm/encode.js +0 -69
  307. package/node_modules/markdown-it/node_modules/entities/lib/esm/encode.js.map +0 -1
  308. package/node_modules/markdown-it/node_modules/entities/lib/esm/escape.d.ts +0 -43
  309. package/node_modules/markdown-it/node_modules/entities/lib/esm/escape.d.ts.map +0 -1
  310. package/node_modules/markdown-it/node_modules/entities/lib/esm/escape.js +0 -116
  311. package/node_modules/markdown-it/node_modules/entities/lib/esm/escape.js.map +0 -1
  312. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-html.d.ts +0 -3
  313. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-html.d.ts.map +0 -1
  314. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-html.js +0 -7
  315. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-html.js.map +0 -1
  316. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-xml.d.ts +0 -3
  317. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-xml.d.ts.map +0 -1
  318. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-xml.js +0 -7
  319. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-xml.js.map +0 -1
  320. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/encode-html.d.ts +0 -8
  321. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/encode-html.d.ts.map +0 -1
  322. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/encode-html.js +0 -10
  323. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/encode-html.js.map +0 -1
  324. package/node_modules/markdown-it/node_modules/entities/lib/esm/index.d.ts.map +0 -1
  325. package/node_modules/markdown-it/node_modules/entities/lib/esm/index.js +0 -99
  326. package/node_modules/markdown-it/node_modules/entities/lib/esm/index.js.map +0 -1
  327. package/node_modules/markdown-it/node_modules/entities/lib/esm/package.json +0 -1
  328. package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-html.d.ts +0 -3
  329. package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-html.d.ts.map +0 -1
  330. package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-html.js +0 -9
  331. package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-html.js.map +0 -1
  332. package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-xml.d.ts +0 -3
  333. package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-xml.d.ts.map +0 -1
  334. package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-xml.js +0 -9
  335. package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-xml.js.map +0 -1
  336. package/node_modules/markdown-it/node_modules/entities/lib/generated/encode-html.d.ts +0 -8
  337. package/node_modules/markdown-it/node_modules/entities/lib/generated/encode-html.d.ts.map +0 -1
  338. package/node_modules/markdown-it/node_modules/entities/lib/generated/encode-html.js +0 -12
  339. package/node_modules/markdown-it/node_modules/entities/lib/generated/encode-html.js.map +0 -1
  340. package/node_modules/markdown-it/node_modules/entities/lib/index.d.ts +0 -96
  341. package/node_modules/markdown-it/node_modules/entities/lib/index.d.ts.map +0 -1
  342. package/node_modules/markdown-it/node_modules/entities/lib/index.js +0 -126
  343. package/node_modules/markdown-it/node_modules/entities/lib/index.js.map +0 -1
  344. package/node_modules/markdown-it/node_modules/linkify-it/index.mjs +0 -646
  345. package/node_modules/markdown-it/node_modules/linkify-it/lib/re.mjs +0 -193
  346. package/node_modules/markdown-it/node_modules/uc.micro/categories/Cc/regex.mjs +0 -1
  347. package/node_modules/markdown-it/node_modules/uc.micro/categories/Cf/regex.mjs +0 -1
  348. package/node_modules/markdown-it/node_modules/uc.micro/categories/P/regex.mjs +0 -1
  349. package/node_modules/markdown-it/node_modules/uc.micro/categories/S/regex.mjs +0 -1
  350. package/node_modules/markdown-it/node_modules/uc.micro/categories/Z/regex.mjs +0 -1
  351. package/node_modules/markdown-it/node_modules/uc.micro/index.mjs +0 -8
  352. package/node_modules/markdown-it/node_modules/uc.micro/properties/Any/regex.mjs +0 -1
  353. /package/dist/{account-config-BZWN9tGS.js → .setup/account-config-BZWN9tGS.mjs} +0 -0
  354. /package/dist/{backup-health-Dm_YMVFT.js → .setup/backup-health-Dm_YMVFT.mjs} +0 -0
  355. /package/dist/{config-paths-CnREYb1Y.js → .setup/config-paths-CnREYb1Y.mjs} +0 -0
  356. /package/dist/{config-secret-input.runtime-CwsP3--c.js → .setup/config-secret-input.runtime-CwsP3--c.mjs} +0 -0
  357. /package/dist/{crypto-node.runtime-6Aj_ltHQ.js → .setup/crypto-node.runtime-6Aj_ltHQ.mjs} +0 -0
  358. /package/dist/{errors-C47hvAF8.js → .setup/errors-C47hvAF8.mjs} +0 -0
  359. /package/dist/{preflight-audio.runtime-BZxxQsxY.js → .setup/preflight-audio.runtime-BZxxQsxY.mjs} +0 -0
  360. /package/dist/{reaction-common-DkrQdBSZ.js → .setup/reaction-common-DkrQdBSZ.mjs} +0 -0
  361. /package/dist/{rolldown-runtime-8H4AJuhK.js → .setup/rolldown-runtime-8H4AJuhK.mjs} +0 -0
  362. /package/dist/{runtime-6S3DNFNv.js → .setup/runtime-6S3DNFNv.mjs} +0 -0
  363. /package/dist/{runtime-BefyhPWv.js → .setup/runtime-BefyhPWv.mjs} +0 -0
  364. /package/dist/{sync-state-CWbp0QSY.js → .setup/sync-state-CWbp0QSY.mjs} +0 -0
  365. /package/dist/{target-ids-B-5aQxwn.js → .setup/target-ids-B-5aQxwn.mjs} +0 -0
  366. /package/dist/{thread-bindings-shared-CKnY4LSd.js → .setup/thread-bindings-shared-CKnY4LSd.mjs} +0 -0
  367. /package/dist/{timeout-abort-signal-DMrgRFIy.js → .setup/timeout-abort-signal-DMrgRFIy.mjs} +0 -0
  368. /package/dist/{url-validation-GRHde6lq.js → .setup/url-validation-GRHde6lq.mjs} +0 -0
@@ -1,121 +1,368 @@
1
- import { n as formatMatrixErrorReason, r as isMatrixNotFoundError, t as formatMatrixErrorMessage } from "./errors-C47hvAF8.js";
2
- import { t as SqliteBackedMatrixSyncStore } from "./file-sync-store-DiiFsayX.js";
3
- import { n as LogService, r as noop, t as ConsoleLogger } from "./logger-D0GCSDQq.js";
4
- import { t as MATRIX_IDB_PERSIST_INTERVAL_MS } from "./idb-persistence-lock-DAJ49nZX.js";
5
- import { c as createMatrixStartupAbortError, u as throwIfMatrixStartupAborted } from "./shared-CUMWxcMz.js";
6
- import { a as matrixEventToRaw, n as createMatrixGuardedFetch, o as parseMxc, t as MatrixAuthedHttpClient } from "./http-client-CycYxU9-.js";
7
- import { n as resolveMatrixRoomKeyBackupReadinessError } from "./backup-health-Dm_YMVFT.js";
8
- import { t as createMatrixJsSdkClientLogger } from "./logging-DV-p52N0.js";
9
- import { n as isMatrixReadySyncState, r as isMatrixTerminalSyncState } from "./sync-state-CWbp0QSY.js";
10
- import { n as isRepairableSecretStorageAccessError, t as MatrixRecoveryKeyStore } from "./recovery-key-store-BNnHvXdk.js";
1
+ import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
2
+ import { n as formatMatrixErrorReason, r as isMatrixNotFoundError, t as formatMatrixErrorMessage } from "./errors-C47hvAF8.mjs";
3
+ import { E as writeMatrixRecoveryKeyStateForPath, c as migrateLegacyMatrixRecoveryKeyFilePathToStore, m as readLegacyMatrixRecoveryKeyFile, y as readMatrixRecoveryKeyStateForPath } from "./crypto-state-store-B43k3z3W.mjs";
4
+ import { n as LogService, r as noop, t as ConsoleLogger } from "./logger-DpoogOgz.mjs";
5
+ import { t as SqliteBackedMatrixSyncStore } from "./file-sync-store-DU0cnYAz.mjs";
6
+ import { t as MATRIX_IDB_PERSIST_INTERVAL_MS } from "./idb-persistence-lock-B3fZXyF_.mjs";
7
+ import { a as throwIfMatrixStartupAborted, r as createMatrixStartupAbortError } from "./client-DFBQtzCe.mjs";
8
+ import { a as matrixEventToRaw, n as createMatrixGuardedFetch, o as parseMxc, t as MatrixAuthedHttpClient } from "./http-client-C954In2D.mjs";
9
+ import { n as resolveMatrixRoomKeyBackupReadinessError } from "./backup-health-Dm_YMVFT.mjs";
10
+ import { createMatrixJsSdkClientLogger } from "./logging-CgxQOJJP.mjs";
11
+ import { n as isMatrixReadySyncState, r as isMatrixTerminalSyncState } from "./sync-state-CWbp0QSY.mjs";
12
+ import { createRequire } from "node:module";
11
13
  import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
12
14
  import { normalizeNullableString, normalizeStringEntries, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
15
+ import path from "node:path";
13
16
  import { KeyedAsyncQueue } from "openclaw/plugin-sdk/keyed-async-queue";
14
17
  import { ClientEvent, Filter, MatrixEventEvent, Preset, createClient } from "matrix-js-sdk/lib/matrix.js";
15
18
  import { EventEmitter } from "node:events";
16
19
  import { VerificationMethod } from "matrix-js-sdk/lib/types.js";
17
- //#region extensions/matrix/src/matrix/sdk/client-device-info.ts
18
- async function resolveMatrixCrossSigningPublicationStatus(params) {
19
- if (!params.userId) return {
20
- userId: null,
21
- masterKeyPublished: false,
22
- selfSigningKeyPublished: false,
23
- userSigningKeyPublished: false,
24
- published: false
25
- };
20
+ import { SyncApi, SyncState } from "matrix-js-sdk/lib/sync.js";
21
+ import { decodeRecoveryKey } from "matrix-js-sdk/lib/crypto-api/recovery-key.js";
22
+ //#region extensions/matrix/src/matrix/sdk/client-sync-quiesce.ts
23
+ const MATRIX_SYNC_QUIESCE_TIMEOUT_MS = 5e3;
24
+ const MATRIX_JS_SDK_SYNC_VERSION = "41.9.0-rc.0";
25
+ const matrixJsSdkPackage = createRequire(import.meta.url)("matrix-js-sdk/package.json");
26
+ function requireMatrixClassicSyncInternals(syncApi) {
27
+ return syncApi;
28
+ }
29
+ function assertMatrixJsSdkSyncVersion() {
30
+ const version = matrixJsSdkPackage.version;
31
+ if (version !== MATRIX_JS_SDK_SYNC_VERSION) throw new Error(`Matrix sync quiesce requires matrix-js-sdk ${MATRIX_JS_SDK_SYNC_VERSION}; found ${String(version)}`);
32
+ }
33
+ async function quiesceMatrixClientSync(params) {
34
+ await params.syncStore?.freezeSyncCursorPersistence();
26
35
  try {
27
- const response = await params.query();
28
- const masterKeyPublished = Boolean(response.master_keys?.[params.userId]);
29
- const selfSigningKeyPublished = Boolean(response.self_signing_keys?.[params.userId]);
30
- const userSigningKeyPublished = Boolean(response.user_signing_keys?.[params.userId]);
36
+ assertMatrixJsSdkSyncVersion();
37
+ } catch (error) {
38
+ params.syncStore?.discardPendingSyncCursorPersistence();
39
+ throw error;
40
+ }
41
+ const syncApi = params.client.syncApi;
42
+ if (syncApi === void 0 && !params.started) return;
43
+ if (!(syncApi instanceof SyncApi)) {
44
+ params.syncStore?.discardPendingSyncCursorPersistence();
45
+ throw new Error(syncApi === void 0 ? "Matrix sync quiesce requires the classic matrix-js-sdk SyncApi, but none is active" : "Matrix sync quiesce rejected a sliding or unknown matrix-js-sdk sync implementation");
46
+ }
47
+ const syncState = syncApi.getSyncState();
48
+ if (syncState === SyncState.Stopped) {
49
+ params.markStopped();
50
+ return;
51
+ }
52
+ const disconnectedBeforeStop = syncState === SyncState.Error || syncState === SyncState.Reconnecting;
53
+ const syncInternals = requireMatrixClassicSyncInternals(syncApi);
54
+ const keepaliveResolvers = disconnectedBeforeStop ? syncInternals.connectionReturnedResolvers : void 0;
55
+ await new Promise((resolve, reject) => {
56
+ let settled = false;
57
+ const settle = (error) => {
58
+ if (settled) return;
59
+ settled = true;
60
+ clearTimeout(timeout);
61
+ params.emitter.off("sync.state", onSyncState);
62
+ if (error) reject(error);
63
+ else {
64
+ params.markStopped();
65
+ resolve();
66
+ }
67
+ };
68
+ const onSyncState = (state) => {
69
+ if (state === "STOPPED") settle();
70
+ };
71
+ const timeout = setTimeout(() => {
72
+ params.syncStore?.discardPendingSyncCursorPersistence();
73
+ settle(/* @__PURE__ */ new Error("Matrix classic sync did not reach STOPPED within 5000ms"));
74
+ }, MATRIX_SYNC_QUIESCE_TIMEOUT_MS);
75
+ timeout.unref?.();
76
+ params.emitter.on("sync.state", onSyncState);
77
+ try {
78
+ syncApi.stop();
79
+ if (keepaliveResolvers && syncInternals.connectionReturnedResolvers === keepaliveResolvers) {
80
+ syncInternals.connectionReturnedResolvers = void 0;
81
+ keepaliveResolvers.reject("SyncApi.stop() was called");
82
+ settle();
83
+ }
84
+ } catch (error) {
85
+ params.syncStore?.discardPendingSyncCursorPersistence();
86
+ settle(error instanceof Error ? error : new Error(String(error)));
87
+ }
88
+ });
89
+ }
90
+ //#endregion
91
+ //#region extensions/matrix/src/matrix/sdk/recovery-key-store.ts
92
+ function isRepairableSecretStorageAccessError(err) {
93
+ const message = formatMatrixErrorReason(err);
94
+ if (!message) return false;
95
+ if (message.includes("getsecretstoragekey callback returned falsey")) return true;
96
+ if (message.includes("decrypting secret") && message.includes("bad mac")) return true;
97
+ return false;
98
+ }
99
+ var MatrixRecoveryKeyStore = class {
100
+ constructor(recoveryKeyPath) {
101
+ this.secretStorageKeyCache = /* @__PURE__ */ new Map();
102
+ this.stagedRecoveryKey = null;
103
+ this.stagedRecoveryKeyUsed = false;
104
+ this.stagedCacheKeyIds = /* @__PURE__ */ new Set();
105
+ this.recoveryKeyPath = recoveryKeyPath;
106
+ this.storageRootDir = recoveryKeyPath ? path.dirname(recoveryKeyPath) : void 0;
107
+ if (this.recoveryKeyPath) try {
108
+ migrateLegacyMatrixRecoveryKeyFilePathToStore(this.recoveryKeyPath);
109
+ } catch (err) {
110
+ this.legacyRecoveryKeyPathOnMigrationFailure = this.recoveryKeyPath;
111
+ LogService.warn("MatrixClientLite", "Failed to migrate Matrix recovery key state:", err);
112
+ }
113
+ }
114
+ buildCryptoCallbacks() {
31
115
  return {
32
- userId: params.userId,
33
- masterKeyPublished,
34
- selfSigningKeyPublished,
35
- userSigningKeyPublished,
36
- published: masterKeyPublished && selfSigningKeyPublished && userSigningKeyPublished
116
+ getSecretStorageKey: async ({ keys }) => {
117
+ const requestedKeyIds = Object.keys(keys ?? {});
118
+ if (requestedKeyIds.length === 0) return null;
119
+ const staged = this.resolveStagedSecretStorageKey(requestedKeyIds);
120
+ if (staged) return staged;
121
+ for (const keyId of requestedKeyIds) {
122
+ const cached = this.secretStorageKeyCache.get(keyId);
123
+ if (cached) return [keyId, new Uint8Array(cached.key)];
124
+ }
125
+ const stored = this.loadStoredRecoveryKey();
126
+ if (!stored?.privateKeyBase64) return null;
127
+ const privateKey = new Uint8Array(Buffer.from(stored.privateKeyBase64, "base64"));
128
+ if (privateKey.length === 0) return null;
129
+ if (stored.keyId && requestedKeyIds.includes(stored.keyId)) {
130
+ this.rememberSecretStorageKey(stored.keyId, privateKey, stored.keyInfo);
131
+ return [stored.keyId, privateKey];
132
+ }
133
+ const firstRequestedKeyId = requestedKeyIds[0];
134
+ if (!firstRequestedKeyId) return null;
135
+ this.rememberSecretStorageKey(firstRequestedKeyId, privateKey, stored.keyInfo);
136
+ return [firstRequestedKeyId, privateKey];
137
+ },
138
+ cacheSecretStorageKey: (keyId, keyInfo, key) => {
139
+ const privateKey = new Uint8Array(key);
140
+ const normalizedKeyInfo = {
141
+ passphrase: keyInfo?.passphrase,
142
+ name: typeof keyInfo?.name === "string" ? keyInfo.name : void 0
143
+ };
144
+ this.rememberSecretStorageKey(keyId, privateKey, normalizedKeyInfo);
145
+ const stored = this.loadStoredRecoveryKey();
146
+ this.saveRecoveryKeyToDisk({
147
+ keyId,
148
+ keyInfo: normalizedKeyInfo,
149
+ privateKey,
150
+ encodedPrivateKey: stored?.encodedPrivateKey
151
+ });
152
+ }
37
153
  };
38
- } catch {
154
+ }
155
+ getRecoveryKeySummary() {
156
+ const stored = this.loadStoredRecoveryKey();
157
+ if (!stored) return null;
39
158
  return {
40
- userId: params.userId,
41
- masterKeyPublished: false,
42
- selfSigningKeyPublished: false,
43
- userSigningKeyPublished: false,
44
- published: false
159
+ encodedPrivateKey: stored.encodedPrivateKey,
160
+ keyId: stored.keyId,
161
+ createdAt: stored.createdAt
45
162
  };
46
163
  }
47
- }
48
- async function listMatrixOwnDevices(client) {
49
- const currentDeviceId = client.getDeviceId()?.trim() || null;
50
- const devices = await client.getDevices();
51
- return (Array.isArray(devices?.devices) ? devices.devices : []).map((device) => ({
52
- deviceId: device.device_id,
53
- displayName: device.display_name?.trim() || null,
54
- lastSeenIp: device.last_seen_ip?.trim() || null,
55
- lastSeenTs: typeof device.last_seen_ts === "number" && Number.isFinite(device.last_seen_ts) ? device.last_seen_ts : null,
56
- current: currentDeviceId !== null && device.device_id === currentDeviceId
57
- }));
58
- }
59
- //#endregion
60
- //#region extensions/matrix/src/matrix/sdk/client-event-bridge.ts
61
- function registerMatrixClientBridge(params) {
62
- params.client.on(ClientEvent.Event, (event) => {
63
- const roomId = event.getRoomId();
64
- if (!roomId) return;
65
- const raw = matrixEventToRaw(event, { contentMode: "original" });
66
- const isEncryptedEvent = raw.type === "m.room.encrypted";
67
- params.emitter.emit("room.event", roomId, raw);
68
- if (isEncryptedEvent) params.emitter.emit("room.encrypted_event", roomId, raw);
69
- else if (params.decryptBridge.shouldEmitUnencryptedMessage(roomId, raw.event_id)) params.emitter.emit("room.message", roomId, raw);
70
- const stateKey = raw.state_key ?? "";
71
- const selfUserId = params.getSelfUserId();
72
- const membership = raw.type === "m.room.member" ? raw.content.membership : void 0;
73
- if (stateKey && selfUserId && stateKey === selfUserId) {
74
- if (membership === "invite") params.emitter.emit("room.invite", roomId, raw);
75
- else if (membership === "join") params.emitter.emit("room.join", roomId, raw);
164
+ getSecretStorageKeyCandidate(keyId) {
165
+ const normalizedKeyId = keyId.trim();
166
+ if (!normalizedKeyId) return null;
167
+ const staged = this.resolveStagedSecretStorageKey([normalizedKeyId]);
168
+ if (staged) return staged[1];
169
+ const stored = this.loadStoredRecoveryKey();
170
+ if (!stored?.privateKeyBase64) return null;
171
+ const privateKey = new Uint8Array(Buffer.from(stored.privateKeyBase64, "base64"));
172
+ if (privateKey.length === 0) return null;
173
+ this.rememberSecretStorageKey(normalizedKeyId, privateKey, stored.keyInfo);
174
+ return privateKey;
175
+ }
176
+ resolveEncodedRecoveryKeyInput(params) {
177
+ const encodedPrivateKey = params.encodedPrivateKey.trim();
178
+ if (!encodedPrivateKey) throw new Error("Matrix recovery key is required");
179
+ let privateKey;
180
+ try {
181
+ privateKey = decodeRecoveryKey(encodedPrivateKey);
182
+ } catch (err) {
183
+ throw new Error(`Invalid Matrix recovery key: ${formatMatrixErrorMessage(err)}`, { cause: err });
76
184
  }
77
- if (isEncryptedEvent) params.decryptBridge.attachEncryptedEvent(event, roomId);
78
- });
79
- params.client.on(ClientEvent.Room, params.emitMembershipForRoom);
80
- params.client.on(ClientEvent.Sync, (state, prevState, data) => {
81
- params.setCurrentSyncState(state);
82
- const error = data && typeof data === "object" && "error" in data ? data.error : void 0;
83
- params.emitter.emit("sync.state", state, prevState, error);
84
- });
85
- params.client.on(ClientEvent.SyncUnexpectedError, (error) => {
86
- params.emitter.emit("sync.unexpected_error", error);
87
- });
88
- }
89
- function emitMatrixMembershipForRoom(params) {
90
- const roomId = params.room.roomId.trim();
91
- if (!roomId || !params.selfUserId) return;
92
- const membership = params.room.getMyMembership();
93
- const raw = {
94
- event_id: `$membership-${roomId}-${Date.now()}`,
95
- type: "m.room.member",
96
- sender: params.selfUserId,
97
- state_key: params.selfUserId,
98
- content: { membership },
99
- origin_server_ts: Date.now(),
100
- unsigned: { age: 0 }
101
- };
102
- if (membership === "invite") {
103
- params.emitter.emit("room.invite", roomId, raw);
104
- return;
185
+ const keyId = typeof params.keyId === "string" && params.keyId.trim() ? params.keyId.trim() : null;
186
+ return {
187
+ encodedPrivateKey,
188
+ privateKey,
189
+ keyId,
190
+ keyInfo: params.keyInfo ?? this.loadStoredRecoveryKey()?.keyInfo
191
+ };
105
192
  }
106
- if (membership === "join") params.emitter.emit("room.join", roomId, raw);
107
- }
108
- function refreshMatrixDmRoomIds(direct, dmRoomIds) {
109
- dmRoomIds.clear();
110
- if (!direct || typeof direct !== "object") return false;
111
- for (const value of Object.values(direct)) {
112
- if (!Array.isArray(value)) continue;
113
- for (const roomId of value) if (typeof roomId === "string" && roomId.trim()) dmRoomIds.add(roomId);
114
- }
115
- return true;
116
- }
193
+ storeEncodedRecoveryKey(params) {
194
+ const prepared = this.resolveEncodedRecoveryKeyInput(params);
195
+ this.saveRecoveryKeyToDisk({
196
+ keyId: prepared.keyId,
197
+ keyInfo: prepared.keyInfo,
198
+ privateKey: prepared.privateKey,
199
+ encodedPrivateKey: prepared.encodedPrivateKey
200
+ });
201
+ if (prepared.keyId) this.rememberSecretStorageKey(prepared.keyId, prepared.privateKey, prepared.keyInfo);
202
+ return this.getRecoveryKeySummary() ?? {};
203
+ }
204
+ stageEncodedRecoveryKey(params) {
205
+ const prepared = this.resolveEncodedRecoveryKeyInput(params);
206
+ this.discardStagedRecoveryKey();
207
+ this.stagedRecoveryKey = {
208
+ version: 1,
209
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
210
+ keyId: prepared.keyId,
211
+ encodedPrivateKey: prepared.encodedPrivateKey,
212
+ privateKeyBase64: Buffer.from(prepared.privateKey).toString("base64"),
213
+ keyInfo: prepared.keyInfo
214
+ };
215
+ }
216
+ hasStagedRecoveryKeyBeenUsed() {
217
+ return this.stagedRecoveryKeyUsed;
218
+ }
219
+ commitStagedRecoveryKey(params) {
220
+ if (!this.stagedRecoveryKey) return this.getRecoveryKeySummary();
221
+ const staged = this.stagedRecoveryKey;
222
+ const privateKey = new Uint8Array(Buffer.from(staged.privateKeyBase64, "base64"));
223
+ const keyId = typeof params?.keyId === "string" && params.keyId.trim() ? params.keyId.trim() : staged.keyId;
224
+ this.saveRecoveryKeyToDisk({
225
+ keyId,
226
+ keyInfo: params?.keyInfo ?? staged.keyInfo,
227
+ privateKey,
228
+ encodedPrivateKey: staged.encodedPrivateKey
229
+ });
230
+ this.clearStagedRecoveryKeyTracking();
231
+ return this.getRecoveryKeySummary();
232
+ }
233
+ discardStagedRecoveryKey() {
234
+ for (const keyId of this.stagedCacheKeyIds) this.secretStorageKeyCache.delete(keyId);
235
+ this.clearStagedRecoveryKeyTracking();
236
+ }
237
+ async bootstrapSecretStorageWithRecoveryKey(crypto, options = {}) {
238
+ let status = null;
239
+ const getSecretStorageStatus = crypto.getSecretStorageStatus;
240
+ if (typeof getSecretStorageStatus === "function") try {
241
+ status = await getSecretStorageStatus.call(crypto);
242
+ } catch (err) {
243
+ LogService.warn("MatrixClientLite", "Failed to read secret storage status:", err);
244
+ }
245
+ const hasDefaultSecretStorageKey = Boolean(status?.defaultKeyId);
246
+ const hasKnownInvalidSecrets = Object.values(status?.secretStorageKeyValidityMap ?? {}).some((valid) => !valid);
247
+ let generatedRecoveryKey = false;
248
+ const storedRecovery = this.loadStoredRecoveryKey();
249
+ const stagedRecovery = this.stagedRecoveryKey;
250
+ const sourceRecovery = options.forceNewRecoveryKey === true ? null : stagedRecovery ?? storedRecovery;
251
+ let recoveryKey = sourceRecovery ? {
252
+ keyInfo: sourceRecovery.keyInfo,
253
+ privateKey: new Uint8Array(Buffer.from(sourceRecovery.privateKeyBase64, "base64")),
254
+ encodedPrivateKey: sourceRecovery.encodedPrivateKey
255
+ } : null;
256
+ if (recoveryKey && status?.defaultKeyId) {
257
+ const defaultKeyId = status.defaultKeyId;
258
+ if (!stagedRecovery) {
259
+ this.rememberSecretStorageKey(defaultKeyId, recoveryKey.privateKey, recoveryKey.keyInfo);
260
+ if (storedRecovery && storedRecovery.keyId !== defaultKeyId) this.saveRecoveryKeyToDisk({
261
+ keyId: defaultKeyId,
262
+ keyInfo: recoveryKey.keyInfo,
263
+ privateKey: recoveryKey.privateKey,
264
+ encodedPrivateKey: recoveryKey.encodedPrivateKey
265
+ });
266
+ }
267
+ }
268
+ const ensureRecoveryKey = async () => {
269
+ if (recoveryKey) {
270
+ if (stagedRecovery) this.stagedRecoveryKeyUsed = true;
271
+ return recoveryKey;
272
+ }
273
+ if (typeof crypto.createRecoveryKeyFromPassphrase !== "function") throw new Error("Matrix crypto backend does not support recovery key generation (createRecoveryKeyFromPassphrase missing)");
274
+ recoveryKey = await crypto.createRecoveryKeyFromPassphrase();
275
+ this.saveRecoveryKeyToDisk(recoveryKey);
276
+ generatedRecoveryKey = true;
277
+ return recoveryKey;
278
+ };
279
+ const shouldRecreateSecretStorage = options.forceNewSecretStorage === true || !hasDefaultSecretStorageKey || !recoveryKey && status?.ready === false || hasKnownInvalidSecrets;
280
+ if (hasKnownInvalidSecrets) recoveryKey = null;
281
+ const secretStorageOptions = { setupNewKeyBackup: options.setupNewKeyBackup === true };
282
+ if (shouldRecreateSecretStorage) {
283
+ secretStorageOptions.setupNewSecretStorage = true;
284
+ secretStorageOptions.createSecretStorageKey = ensureRecoveryKey;
285
+ }
286
+ try {
287
+ await crypto.bootstrapSecretStorage(secretStorageOptions);
288
+ } catch (err) {
289
+ if (!(options.allowSecretStorageRecreateWithoutRecoveryKey === true && hasDefaultSecretStorageKey && isRepairableSecretStorageAccessError(err))) throw err;
290
+ recoveryKey = null;
291
+ LogService.warn("MatrixClientLite", "Secret storage exists on the server but local recovery material cannot unlock it; recreating secret storage during explicit bootstrap.");
292
+ await crypto.bootstrapSecretStorage({
293
+ setupNewSecretStorage: true,
294
+ setupNewKeyBackup: options.setupNewKeyBackup === true,
295
+ createSecretStorageKey: ensureRecoveryKey
296
+ });
297
+ }
298
+ if (generatedRecoveryKey && this.storageRootDir) LogService.warn("MatrixClientLite", "Generated Matrix recovery key and saved it to Matrix SQLite state. Keep the displayed recovery key secure.");
299
+ }
300
+ clearStagedRecoveryKeyTracking() {
301
+ this.stagedRecoveryKey = null;
302
+ this.stagedRecoveryKeyUsed = false;
303
+ this.stagedCacheKeyIds.clear();
304
+ }
305
+ resolveStagedSecretStorageKey(requestedKeyIds) {
306
+ const staged = this.stagedRecoveryKey;
307
+ if (!staged?.privateKeyBase64) return null;
308
+ const privateKey = new Uint8Array(Buffer.from(staged.privateKeyBase64, "base64"));
309
+ if (privateKey.length === 0) return null;
310
+ const keyId = staged.keyId && requestedKeyIds.includes(staged.keyId) ? staged.keyId : requestedKeyIds[0];
311
+ if (!keyId) return null;
312
+ this.rememberStagedSecretStorageKey(keyId, privateKey, staged.keyInfo);
313
+ this.stagedCacheKeyIds.add(keyId);
314
+ return [keyId, privateKey];
315
+ }
316
+ rememberStagedSecretStorageKey(keyId, key, keyInfo) {
317
+ this.stagedRecoveryKeyUsed = true;
318
+ this.rememberSecretStorageKey(keyId, key, keyInfo);
319
+ }
320
+ rememberSecretStorageKey(keyId, key, keyInfo) {
321
+ if (!keyId.trim()) return;
322
+ this.secretStorageKeyCache.set(keyId, {
323
+ key: new Uint8Array(key),
324
+ keyInfo
325
+ });
326
+ }
327
+ loadStoredRecoveryKey() {
328
+ if (!this.recoveryKeyPath) return null;
329
+ try {
330
+ const stored = readMatrixRecoveryKeyStateForPath(this.recoveryKeyPath);
331
+ if (stored) return stored;
332
+ } catch {}
333
+ if (this.legacyRecoveryKeyPathOnMigrationFailure) return readLegacyMatrixRecoveryKeyFile(this.legacyRecoveryKeyPathOnMigrationFailure);
334
+ return null;
335
+ }
336
+ saveRecoveryKeyToDisk(params) {
337
+ if (!this.recoveryKeyPath) return;
338
+ try {
339
+ const payload = {
340
+ version: 1,
341
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
342
+ keyId: typeof params.keyId === "string" ? params.keyId : null,
343
+ encodedPrivateKey: params.encodedPrivateKey,
344
+ privateKeyBase64: Buffer.from(params.privateKey).toString("base64"),
345
+ keyInfo: params.keyInfo ? {
346
+ passphrase: params.keyInfo.passphrase,
347
+ name: params.keyInfo.name
348
+ } : void 0
349
+ };
350
+ writeMatrixRecoveryKeyStateForPath({
351
+ recoveryKeyPath: this.recoveryKeyPath,
352
+ payload
353
+ });
354
+ } catch (err) {
355
+ LogService.warn("MatrixClientLite", "Failed to persist recovery key:", err);
356
+ }
357
+ }
358
+ };
117
359
  //#endregion
118
- //#region extensions/matrix/src/matrix/sdk/client-support.ts
360
+ //#region extensions/matrix/src/matrix/sdk.ts
361
+ var sdk_exports = /* @__PURE__ */ __exportAll({
362
+ ConsoleLogger: () => ConsoleLogger,
363
+ LogService: () => LogService,
364
+ MatrixClient: () => MatrixClient
365
+ });
119
366
  const MATRIX_STATUS_DIAGNOSTIC_TIMEOUT_MS = 1e4;
120
367
  const DEFAULT_MATRIX_LOCAL_TIMEOUT_MS = 6e4;
121
368
  function resolveMatrixLocalTimeoutMs(raw) {
@@ -194,14 +441,19 @@ function createMatrixExplicitBootstrapOptions(params) {
194
441
  strict: params?.strict !== false
195
442
  };
196
443
  }
197
- //#endregion
198
- //#region extensions/matrix/src/matrix/sdk/client-base.ts
199
444
  let loadedMatrixCryptoRuntime = null;
200
- const loadMatrixCryptoRuntime = createLazyRuntimeModule(() => import("./crypto-runtime-D9_6J5tZ.js").then((runtime) => {
445
+ const loadMatrixCryptoRuntime = createLazyRuntimeModule(() => import("./crypto-runtime-D-cZa8P0.mjs").then((runtime) => {
201
446
  loadedMatrixCryptoRuntime = runtime;
202
447
  return runtime;
203
448
  }));
204
- var MatrixClientBase = class {
449
+ const normalizeOptionalString$1 = normalizeNullableString;
450
+ function isUnsupportedAuthenticatedMediaEndpointError(err) {
451
+ const statusCode = err?.statusCode;
452
+ if (statusCode === 404 || statusCode === 405 || statusCode === 501) return true;
453
+ const message = formatMatrixErrorReason(err);
454
+ return message.includes("m_unrecognized") || message.includes("unrecognized request") || message.includes("method not allowed") || message.includes("not implemented");
455
+ }
456
+ var MatrixClient = class {
205
457
  constructor(homeserver, accessToken, opts = {}) {
206
458
  this.emitter = new EventEmitter();
207
459
  this.bridgeRegistered = false;
@@ -210,7 +462,9 @@ var MatrixClientBase = class {
210
462
  this.dmRoomIds = /* @__PURE__ */ new Set();
211
463
  this.cryptoInitialized = false;
212
464
  this.sendQueue = new KeyedAsyncQueue();
465
+ this.syncQuiescePromise = null;
213
466
  this.stopPersistPromise = null;
467
+ this.sdkStopped = false;
214
468
  this.verificationSummaryListenerBound = false;
215
469
  this.currentSyncState = null;
216
470
  this.dms = {
@@ -230,8 +484,7 @@ var MatrixClientBase = class {
230
484
  this.initialSyncLimit = opts.initialSyncLimit;
231
485
  this.syncFilter = opts.syncFilter;
232
486
  this.encryptionEnabled = opts.encryption === true;
233
- const { password: loginPassword } = opts;
234
- this.password = loginPassword;
487
+ this.password = opts.password;
235
488
  this.syncStore = opts.storageRootDir ? new SqliteBackedMatrixSyncStore(opts.storageRootDir) : void 0;
236
489
  this.idbSnapshotPath = opts.idbSnapshotPath;
237
490
  this.cryptoDatabasePrefix = opts.cryptoDatabasePrefix;
@@ -388,6 +641,7 @@ var MatrixClientBase = class {
388
641
  }
389
642
  async startSyncSession(opts) {
390
643
  if (this.started) return;
644
+ if (this.sdkStopped) throw new Error("Matrix client has been fully stopped and cannot be restarted; acquire a new shared client generation");
391
645
  throwIfMatrixStartupAborted(opts.abortSignal);
392
646
  await this.ensureCryptoSupportInitialized();
393
647
  throwIfMatrixStartupAborted(opts.abortSignal);
@@ -425,43 +679,57 @@ var MatrixClientBase = class {
425
679
  if (this.started) return;
426
680
  await this.startSyncSession({ bootstrapCrypto: false });
427
681
  }
428
- stopSyncWithoutPersist() {
682
+ stopSdkClient() {
683
+ if (this.sdkStopped) return;
429
684
  if (this.idbPersistTimer) {
430
685
  clearInterval(this.idbPersistTimer);
431
686
  this.idbPersistTimer = null;
432
687
  }
433
688
  this.currentSyncState = null;
434
689
  this.client.stopClient();
690
+ this.sdkStopped = true;
435
691
  this.started = false;
436
692
  }
693
+ async quiesceSync() {
694
+ this.syncQuiescePromise ??= quiesceMatrixClientSync({
695
+ client: this.client,
696
+ emitter: this.emitter,
697
+ markStopped: () => {
698
+ this.started = false;
699
+ },
700
+ started: this.started,
701
+ syncStore: this.syncStore
702
+ });
703
+ await this.syncQuiescePromise;
704
+ }
437
705
  async drainPendingDecryptions(reason = "matrix client shutdown") {
438
706
  await this.decryptBridge?.drainPendingDecryptions(reason);
439
707
  }
440
708
  stop() {
441
- this.stopSyncWithoutPersist();
442
- this.decryptBridge?.stop();
443
- this.syncStore?.markCleanShutdown();
444
- if (loadedMatrixCryptoRuntime) {
445
- const { persistIdbToDisk } = loadedMatrixCryptoRuntime;
446
- this.stopPersistPromise = Promise.all([persistIdbToDisk({
447
- snapshotPath: this.idbSnapshotPath,
448
- databasePrefix: this.cryptoDatabasePrefix
449
- }).catch(noop), this.syncStore?.flush().catch(noop)]).then(() => void 0);
709
+ this.stopAndPersist().catch(() => this.stopWithoutPersist()).catch(noop);
710
+ }
711
+ async stopAndPersist() {
712
+ if (this.stopPersistPromise) {
713
+ await this.stopPersistPromise;
450
714
  return;
451
715
  }
452
- this.stopPersistPromise = loadMatrixCryptoRuntime().then(async ({ persistIdbToDisk }) => {
453
- await Promise.all([persistIdbToDisk({
716
+ this.stopPersistPromise = (async () => {
717
+ await this.quiesceSync();
718
+ this.stopSdkClient();
719
+ this.decryptBridge?.stop();
720
+ await (loadedMatrixCryptoRuntime ?? await loadMatrixCryptoRuntime()).persistIdbToDisk({
454
721
  snapshotPath: this.idbSnapshotPath,
455
- databasePrefix: this.cryptoDatabasePrefix
456
- }).catch(noop), this.syncStore?.flush().catch(noop)]);
457
- }).catch(noop).then(() => void 0);
458
- }
459
- async stopAndPersist() {
460
- this.stop();
722
+ databasePrefix: this.cryptoDatabasePrefix,
723
+ strict: true
724
+ });
725
+ this.syncStore?.markCleanShutdown();
726
+ await this.syncStore?.flush();
727
+ })();
461
728
  await this.stopPersistPromise;
462
729
  }
463
730
  stopWithoutPersist() {
464
- this.stopSyncWithoutPersist();
731
+ this.syncStore?.discardPendingSyncCursorPersistence();
732
+ this.stopSdkClient();
465
733
  this.decryptBridge?.stop();
466
734
  this.stopPersistPromise = Promise.resolve();
467
735
  }
@@ -475,13 +743,15 @@ var MatrixClientBase = class {
475
743
  if (!cryptoBootstrapper) return;
476
744
  const initial = await cryptoBootstrapper.bootstrap(crypto, MATRIX_INITIAL_CRYPTO_BOOTSTRAP_OPTIONS);
477
745
  throwIfMatrixStartupAborted(abortSignal);
478
- if (!initial.crossSigningPublished || initial.ownDeviceVerified === false) if ((await this.getOwnDeviceVerificationStatus()).signedByOwner) LogService.warn("MatrixClientLite", "Cross-signing/bootstrap is incomplete for an already owner-signed device; skipping automatic reset and preserving the current identity. Restore the recovery key or run an explicit verification bootstrap if repair is needed.");
479
- else try {
480
- const repaired = await cryptoBootstrapper.bootstrap(crypto, MATRIX_AUTOMATIC_REPAIR_BOOTSTRAP_OPTIONS);
481
- throwIfMatrixStartupAborted(abortSignal);
482
- if (repaired.crossSigningPublished && repaired.ownDeviceVerified !== false) LogService.info("MatrixClientLite", "Cross-signing/bootstrap recovered after forced reset");
483
- } catch (err) {
484
- LogService.warn("MatrixClientLite", "Failed to recover cross-signing/bootstrap with forced reset:", err);
746
+ if (!initial.crossSigningPublished || initial.ownDeviceVerified === false) {
747
+ if ((await this.getOwnDeviceVerificationStatus()).signedByOwner) LogService.warn("MatrixClientLite", "Cross-signing/bootstrap is incomplete for an already owner-signed device; skipping automatic reset and preserving the current identity. Restore the recovery key or run an explicit verification bootstrap if repair is needed.");
748
+ else try {
749
+ const repaired = await cryptoBootstrapper.bootstrap(crypto, MATRIX_AUTOMATIC_REPAIR_BOOTSTRAP_OPTIONS);
750
+ throwIfMatrixStartupAborted(abortSignal);
751
+ if (repaired.crossSigningPublished && repaired.ownDeviceVerified !== false) LogService.info("MatrixClientLite", "Cross-signing/bootstrap recovered after forced reset");
752
+ } catch (err) {
753
+ LogService.warn("MatrixClientLite", "Failed to recover cross-signing/bootstrap with forced reset:", err);
754
+ }
485
755
  }
486
756
  this.cryptoBootstrapped = true;
487
757
  }
@@ -511,16 +781,6 @@ var MatrixClientBase = class {
511
781
  LogService.warn("MatrixClientLite", "Failed to initialize rust crypto:", err);
512
782
  }
513
783
  }
514
- };
515
- //#endregion
516
- //#region extensions/matrix/src/matrix/sdk/client-core.ts
517
- function isUnsupportedAuthenticatedMediaEndpointError(err) {
518
- const statusCode = err?.statusCode;
519
- if (statusCode === 404 || statusCode === 405 || statusCode === 501) return true;
520
- const message = formatMatrixErrorReason(err);
521
- return message.includes("m_unrecognized") || message.includes("unrecognized request") || message.includes("method not allowed") || message.includes("not implemented");
522
- }
523
- var MatrixClientCore = class extends MatrixClientBase {
524
784
  async getUserId() {
525
785
  const fromClient = this.client.getUserId();
526
786
  if (fromClient) {
@@ -543,13 +803,13 @@ var MatrixClientCore = class extends MatrixClientBase {
543
803
  return Object.keys(joined);
544
804
  }
545
805
  hasSyncedJoinedRoomMember(roomId, userId) {
546
- return this.client.getRoom(roomId)?.getMember(userId)?.membership === "join";
806
+ return (this.client.getRoom?.(roomId))?.currentState?.getMember?.(userId)?.membership === "join";
547
807
  }
548
808
  async getRoomStateEvent(roomId, eventType, stateKey = "") {
549
809
  return await this.client.getStateEvent(roomId, eventType, stateKey) ?? {};
550
810
  }
551
811
  async getAccountData(eventType) {
552
- return await this.client.getAccountDataFromServer(eventType) ?? void 0;
812
+ return this.client.getAccountData(eventType)?.getContent() ?? void 0;
553
813
  }
554
814
  async setAccountData(eventType, content) {
555
815
  await this.client.setAccountData(eventType, content);
@@ -695,11 +955,6 @@ var MatrixClientCore = class extends MatrixClientBase {
695
955
  timeoutMs: this.localTimeoutMs
696
956
  });
697
957
  }
698
- };
699
- //#endregion
700
- //#region extensions/matrix/src/matrix/sdk/client-verification.ts
701
- const normalizeOptionalString$1 = normalizeNullableString;
702
- var MatrixClientVerification = class extends MatrixClientCore {
703
958
  async getRoomKeyBackupStatus() {
704
959
  if (!this.encryptionEnabled) return {
705
960
  serverVersion: null,
@@ -728,14 +983,16 @@ var MatrixClientVerification = class extends MatrixClientCore {
728
983
  let keyLoadAttempted = false;
729
984
  let keyLoadError = null;
730
985
  if (serverVersion && (shouldLoadBackupKey || shouldActivateBackup)) {
731
- if (shouldLoadBackupKey) if (typeof crypto.loadSessionBackupPrivateKeyFromSecretStorage === "function") {
732
- keyLoadAttempted = true;
733
- try {
734
- await crypto.loadSessionBackupPrivateKeyFromSecretStorage();
735
- } catch (err) {
736
- keyLoadError = formatMatrixErrorMessage(err);
737
- }
738
- } else keyLoadError = "Matrix crypto backend does not support loading backup keys from secret storage";
986
+ if (shouldLoadBackupKey) {
987
+ if (typeof crypto.loadSessionBackupPrivateKeyFromSecretStorage === "function") {
988
+ keyLoadAttempted = true;
989
+ try {
990
+ await crypto.loadSessionBackupPrivateKeyFromSecretStorage();
991
+ } catch (err) {
992
+ keyLoadError = formatMatrixErrorMessage(err);
993
+ }
994
+ } else keyLoadError = "Matrix crypto backend does not support loading backup keys from secret storage";
995
+ }
739
996
  if (!keyLoadError) await this.enableTrustedRoomKeyBackupIfPossible(crypto);
740
997
  ({activeVersion, decryptionKeyCached} = await this.resolveRoomKeyBackupLocalState(crypto));
741
998
  ({serverVersion, trusted, matchesDecryptionKey} = await this.resolveRoomKeyBackupTrustState(crypto, serverVersion));
@@ -776,6 +1033,9 @@ var MatrixClientVerification = class extends MatrixClientCore {
776
1033
  signedByOwner: deviceStatus?.signedByOwner === true
777
1034
  };
778
1035
  }
1036
+ async refreshOwnDeviceKeys() {
1037
+ await this.client.getCrypto()?.userHasCrossSigningKeys(await this.getUserId(), true);
1038
+ }
779
1039
  async getOwnDeviceVerificationStatus() {
780
1040
  const recoveryKey = this.recoveryKeyStore.getRecoveryKeySummary();
781
1041
  const userId = this.client.getUserId() ?? this.selfUserId ?? null;
@@ -827,83 +1087,6 @@ var MatrixClientVerification = class extends MatrixClientCore {
827
1087
  ownIdentity.free?.();
828
1088
  }
829
1089
  }
830
- async resolveActiveRoomKeyBackupVersion(crypto) {
831
- if (typeof crypto.getActiveSessionBackupVersion !== "function") return null;
832
- const version = await crypto.getActiveSessionBackupVersion().catch(() => null);
833
- return normalizeOptionalString$1(version);
834
- }
835
- async resolveCachedRoomKeyBackupDecryptionKey(crypto) {
836
- const read = Reflect.get(crypto, "getSessionBackupPrivateKey");
837
- if (typeof read !== "function") return null;
838
- const key = await read.call(crypto).catch(() => null);
839
- return key ? key.length > 0 : false;
840
- }
841
- async resolveRoomKeyBackupLocalState(crypto) {
842
- const [activeVersion, decryptionKeyCached] = await Promise.all([this.resolveActiveRoomKeyBackupVersion(crypto), this.resolveCachedRoomKeyBackupDecryptionKey(crypto)]);
843
- return {
844
- activeVersion,
845
- decryptionKeyCached
846
- };
847
- }
848
- async shouldForceSecretStorageRecreationForBackupReset(crypto) {
849
- if (await this.resolveCachedRoomKeyBackupDecryptionKey(crypto) !== false) return false;
850
- const loadSessionBackupPrivateKeyFromSecretStorage = crypto.loadSessionBackupPrivateKeyFromSecretStorage;
851
- if (typeof loadSessionBackupPrivateKeyFromSecretStorage !== "function") return false;
852
- try {
853
- await loadSessionBackupPrivateKeyFromSecretStorage.call(crypto);
854
- return false;
855
- } catch (err) {
856
- return isRepairableSecretStorageAccessError(err);
857
- }
858
- }
859
- async resolveRoomKeyBackupTrustState(crypto, fallbackVersion) {
860
- let serverVersion = fallbackVersion;
861
- let trusted = null;
862
- let matchesDecryptionKey = null;
863
- if (typeof crypto.getKeyBackupInfo === "function") {
864
- const info = await crypto.getKeyBackupInfo().catch(() => null);
865
- serverVersion = normalizeOptionalString$1(info?.version) ?? serverVersion;
866
- if (info && typeof crypto.isKeyBackupTrusted === "function") {
867
- const trustInfo = await crypto.isKeyBackupTrusted(info).catch(() => null);
868
- trusted = typeof trustInfo?.trusted === "boolean" ? trustInfo.trusted : null;
869
- matchesDecryptionKey = typeof trustInfo?.matchesDecryptionKey === "boolean" ? trustInfo.matchesDecryptionKey : null;
870
- }
871
- }
872
- return {
873
- serverVersion,
874
- trusted,
875
- matchesDecryptionKey
876
- };
877
- }
878
- async resolveDefaultSecretStorageKeyId(crypto) {
879
- const getSecretStorageStatus = crypto?.getSecretStorageStatus;
880
- if (typeof getSecretStorageStatus !== "function") return;
881
- return (await getSecretStorageStatus.call(crypto).catch(() => null))?.defaultKeyId;
882
- }
883
- async resolveRoomKeyBackupVersion() {
884
- try {
885
- const response = await this.doRequest("GET", "/_matrix/client/v3/room_keys/version");
886
- return normalizeOptionalString$1(response.version);
887
- } catch {
888
- return null;
889
- }
890
- }
891
- async enableTrustedRoomKeyBackupIfPossible(crypto) {
892
- if (typeof crypto.checkKeyBackupAndEnable !== "function") return;
893
- await crypto.checkKeyBackupAndEnable();
894
- }
895
- async ensureRoomKeyBackupEnabled(crypto) {
896
- if (await this.resolveRoomKeyBackupVersion()) return;
897
- LogService.info("MatrixClientLite", "No room key backup version found on server, creating one via secret storage bootstrap");
898
- await this.recoveryKeyStore.bootstrapSecretStorageWithRecoveryKey(crypto, { setupNewKeyBackup: true });
899
- const createdVersion = await this.resolveRoomKeyBackupVersion();
900
- if (!createdVersion) throw new Error("Matrix room key backup is still missing after bootstrap");
901
- LogService.info("MatrixClientLite", `Room key backup enabled (version ${createdVersion})`);
902
- }
903
- };
904
- //#endregion
905
- //#region extensions/matrix/src/matrix/sdk.ts
906
- var MatrixClient = class extends MatrixClientVerification {
907
1090
  async verifyWithRecoveryKey(rawRecoveryKey) {
908
1091
  const fail = async (error, fields = {}) => {
909
1092
  const status = await this.getOwnDeviceVerificationStatus();
@@ -1148,10 +1331,34 @@ var MatrixClient = class extends MatrixClientVerification {
1148
1331
  }
1149
1332
  async getOwnCrossSigningPublicationStatus() {
1150
1333
  const userId = this.client.getUserId() ?? this.selfUserId ?? null;
1151
- return await resolveMatrixCrossSigningPublicationStatus({
1152
- userId,
1153
- query: async () => await this.doRequest("POST", "/_matrix/client/v3/keys/query", void 0, { device_keys: userId ? { [userId]: [] } : {} })
1154
- });
1334
+ if (!userId) return {
1335
+ userId: null,
1336
+ masterKeyPublished: false,
1337
+ selfSigningKeyPublished: false,
1338
+ userSigningKeyPublished: false,
1339
+ published: false
1340
+ };
1341
+ try {
1342
+ const response = await this.doRequest("POST", "/_matrix/client/v3/keys/query", void 0, { device_keys: { [userId]: [] } });
1343
+ const masterKeyPublished = Boolean(response.master_keys?.[userId]);
1344
+ const selfSigningKeyPublished = Boolean(response.self_signing_keys?.[userId]);
1345
+ const userSigningKeyPublished = Boolean(response.user_signing_keys?.[userId]);
1346
+ return {
1347
+ userId,
1348
+ masterKeyPublished,
1349
+ selfSigningKeyPublished,
1350
+ userSigningKeyPublished,
1351
+ published: masterKeyPublished && selfSigningKeyPublished && userSigningKeyPublished
1352
+ };
1353
+ } catch {
1354
+ return {
1355
+ userId,
1356
+ masterKeyPublished: false,
1357
+ selfSigningKeyPublished: false,
1358
+ userSigningKeyPublished: false,
1359
+ published: false
1360
+ };
1361
+ }
1155
1362
  }
1156
1363
  async bootstrapOwnDeviceVerification(params) {
1157
1364
  const pendingVerifications = async () => this.crypto ? (await this.crypto.listVerifications()).length : 0;
@@ -1207,7 +1414,15 @@ var MatrixClient = class extends MatrixClientVerification {
1207
1414
  };
1208
1415
  }
1209
1416
  async listOwnDevices() {
1210
- return await listMatrixOwnDevices(this.client);
1417
+ const currentDeviceId = this.client.getDeviceId()?.trim() || null;
1418
+ const devices = await this.client.getDevices();
1419
+ return (Array.isArray(devices?.devices) ? devices.devices : []).map((device) => ({
1420
+ deviceId: device.device_id,
1421
+ displayName: device.display_name?.trim() || null,
1422
+ lastSeenIp: device.last_seen_ip?.trim() || null,
1423
+ lastSeenTs: typeof device.last_seen_ts === "number" && Number.isFinite(device.last_seen_ts) ? device.last_seen_ts : null,
1424
+ current: currentDeviceId !== null && device.device_id === currentDeviceId
1425
+ }));
1211
1426
  }
1212
1427
  async deleteOwnDevices(deviceIds) {
1213
1428
  const uniqueDeviceIds = uniqueStrings(normalizeStringEntries(deviceIds));
@@ -1239,35 +1454,151 @@ var MatrixClient = class extends MatrixClientVerification {
1239
1454
  remainingDevices: await this.listOwnDevices()
1240
1455
  };
1241
1456
  }
1457
+ async resolveActiveRoomKeyBackupVersion(crypto) {
1458
+ if (typeof crypto.getActiveSessionBackupVersion !== "function") return null;
1459
+ const version = await crypto.getActiveSessionBackupVersion().catch(() => null);
1460
+ return normalizeOptionalString$1(version);
1461
+ }
1462
+ async resolveCachedRoomKeyBackupDecryptionKey(crypto) {
1463
+ const getSessionBackupPrivateKey = crypto.getSessionBackupPrivateKey;
1464
+ if (typeof getSessionBackupPrivateKey !== "function") return null;
1465
+ const key = await getSessionBackupPrivateKey.call(crypto).catch(() => null);
1466
+ return key ? key.length > 0 : false;
1467
+ }
1468
+ async resolveRoomKeyBackupLocalState(crypto) {
1469
+ const [activeVersion, decryptionKeyCached] = await Promise.all([this.resolveActiveRoomKeyBackupVersion(crypto), this.resolveCachedRoomKeyBackupDecryptionKey(crypto)]);
1470
+ return {
1471
+ activeVersion,
1472
+ decryptionKeyCached
1473
+ };
1474
+ }
1475
+ async shouldForceSecretStorageRecreationForBackupReset(crypto) {
1476
+ if (await this.resolveCachedRoomKeyBackupDecryptionKey(crypto) !== false) return false;
1477
+ const loadSessionBackupPrivateKeyFromSecretStorage = crypto.loadSessionBackupPrivateKeyFromSecretStorage;
1478
+ if (typeof loadSessionBackupPrivateKeyFromSecretStorage !== "function") return false;
1479
+ try {
1480
+ await loadSessionBackupPrivateKeyFromSecretStorage.call(crypto);
1481
+ return false;
1482
+ } catch (err) {
1483
+ return isRepairableSecretStorageAccessError(err);
1484
+ }
1485
+ }
1486
+ async resolveRoomKeyBackupTrustState(crypto, fallbackVersion) {
1487
+ let serverVersion = fallbackVersion;
1488
+ let trusted = null;
1489
+ let matchesDecryptionKey = null;
1490
+ if (typeof crypto.getKeyBackupInfo === "function") {
1491
+ const info = await crypto.getKeyBackupInfo().catch(() => null);
1492
+ serverVersion = normalizeOptionalString$1(info?.version) ?? serverVersion;
1493
+ if (info && typeof crypto.isKeyBackupTrusted === "function") {
1494
+ const trustInfo = await crypto.isKeyBackupTrusted(info).catch(() => null);
1495
+ trusted = typeof trustInfo?.trusted === "boolean" ? trustInfo.trusted : null;
1496
+ matchesDecryptionKey = typeof trustInfo?.matchesDecryptionKey === "boolean" ? trustInfo.matchesDecryptionKey : null;
1497
+ }
1498
+ }
1499
+ return {
1500
+ serverVersion,
1501
+ trusted,
1502
+ matchesDecryptionKey
1503
+ };
1504
+ }
1505
+ async resolveDefaultSecretStorageKeyId(crypto) {
1506
+ const getSecretStorageStatus = crypto?.getSecretStorageStatus;
1507
+ if (typeof getSecretStorageStatus !== "function") return;
1508
+ return (await getSecretStorageStatus.call(crypto).catch(() => null))?.defaultKeyId;
1509
+ }
1510
+ async resolveRoomKeyBackupVersion() {
1511
+ try {
1512
+ const response = await this.doRequest("GET", "/_matrix/client/v3/room_keys/version");
1513
+ return normalizeOptionalString$1(response.version);
1514
+ } catch {
1515
+ return null;
1516
+ }
1517
+ }
1518
+ async enableTrustedRoomKeyBackupIfPossible(crypto) {
1519
+ if (typeof crypto.checkKeyBackupAndEnable !== "function") return;
1520
+ await crypto.checkKeyBackupAndEnable();
1521
+ }
1522
+ async ensureRoomKeyBackupEnabled(crypto) {
1523
+ if (await this.resolveRoomKeyBackupVersion()) return;
1524
+ LogService.info("MatrixClientLite", "No room key backup version found on server, creating one via secret storage bootstrap");
1525
+ await this.recoveryKeyStore.bootstrapSecretStorageWithRecoveryKey(crypto, { setupNewKeyBackup: true });
1526
+ const createdVersion = await this.resolveRoomKeyBackupVersion();
1527
+ if (!createdVersion) throw new Error("Matrix room key backup is still missing after bootstrap");
1528
+ LogService.info("MatrixClientLite", `Room key backup enabled (version ${createdVersion})`);
1529
+ }
1242
1530
  registerBridge() {
1243
- const decryptBridge = this.decryptBridge;
1244
- if (this.bridgeRegistered || !decryptBridge) return;
1531
+ if (this.bridgeRegistered || !this.decryptBridge) return;
1245
1532
  this.bridgeRegistered = true;
1246
- registerMatrixClientBridge({
1247
- client: this.client,
1248
- decryptBridge,
1249
- emitter: this.emitter,
1250
- emitMembershipForRoom: (room) => this.emitMembershipForRoom(room),
1251
- getSelfUserId: () => this.client.getUserId() ?? this.selfUserId ?? "",
1252
- setCurrentSyncState: (state) => {
1253
- this.currentSyncState = state;
1533
+ const decryptBridge = this.decryptBridge;
1534
+ this.client.on(ClientEvent.Event, (event) => {
1535
+ const roomId = event.getRoomId();
1536
+ if (!roomId) return;
1537
+ const raw = matrixEventToRaw(event, { contentMode: "original" });
1538
+ const isEncryptedEvent = raw.type === "m.room.encrypted";
1539
+ this.emitter.emit("room.event", roomId, raw);
1540
+ if (isEncryptedEvent) this.emitter.emit("room.encrypted_event", roomId, raw);
1541
+ else if (decryptBridge.shouldEmitUnencryptedMessage(roomId, raw.event_id)) this.emitter.emit("room.message", roomId, raw);
1542
+ const stateKey = raw.state_key ?? "";
1543
+ const selfUserId = this.client.getUserId() ?? this.selfUserId ?? "";
1544
+ const membership = raw.type === "m.room.member" ? raw.content.membership : void 0;
1545
+ if (stateKey && selfUserId && stateKey === selfUserId) {
1546
+ if (membership === "invite") this.emitter.emit("room.invite", roomId, raw);
1547
+ else if (membership === "join") this.emitter.emit("room.join", roomId, raw);
1254
1548
  }
1549
+ if (isEncryptedEvent) decryptBridge.attachEncryptedEvent(event, roomId);
1550
+ });
1551
+ this.client.on(ClientEvent.Room, (room) => {
1552
+ this.emitMembershipForRoom(room);
1553
+ });
1554
+ this.client.on(ClientEvent.Sync, (state, prevState, data) => {
1555
+ this.currentSyncState = state;
1556
+ const error = data && typeof data === "object" && "error" in data ? data.error : void 0;
1557
+ this.emitter.emit("sync.state", state, prevState, error);
1558
+ });
1559
+ this.client.on(ClientEvent.SyncUnexpectedError, (error) => {
1560
+ this.emitter.emit("sync.unexpected_error", error);
1255
1561
  });
1256
1562
  }
1257
1563
  emitMembershipForRoom(room) {
1258
- emitMatrixMembershipForRoom({
1259
- client: this.client,
1260
- emitter: this.emitter,
1261
- room,
1262
- selfUserId: this.client.getUserId() ?? this.selfUserId ?? ""
1263
- });
1564
+ const roomObj = room;
1565
+ const roomId = roomObj.roomId?.trim();
1566
+ if (!roomId) return;
1567
+ const membership = roomObj.getMyMembership?.() ?? roomObj.selfMembership ?? void 0;
1568
+ const selfUserId = this.client.getUserId() ?? this.selfUserId ?? "";
1569
+ if (!selfUserId) return;
1570
+ const raw = {
1571
+ event_id: `$membership-${roomId}-${Date.now()}`,
1572
+ type: "m.room.member",
1573
+ sender: selfUserId,
1574
+ state_key: selfUserId,
1575
+ content: { membership },
1576
+ origin_server_ts: Date.now(),
1577
+ unsigned: { age: 0 }
1578
+ };
1579
+ if (membership === "invite") {
1580
+ this.emitter.emit("room.invite", roomId, raw);
1581
+ return;
1582
+ }
1583
+ if (membership === "join") this.emitter.emit("room.join", roomId, raw);
1264
1584
  }
1265
1585
  emitOutstandingInviteEvents() {
1266
- for (const room of this.client.getRooms()) this.emitMembershipForRoom(room);
1586
+ const listRooms = this.client.getRooms;
1587
+ if (typeof listRooms !== "function") return;
1588
+ const rooms = listRooms.call(this.client);
1589
+ if (!Array.isArray(rooms)) return;
1590
+ for (const room of rooms) this.emitMembershipForRoom(room);
1267
1591
  }
1268
1592
  async refreshDmCache() {
1269
- return refreshMatrixDmRoomIds(await this.getAccountData("m.direct"), this.dmRoomIds);
1593
+ const direct = await this.getAccountData("m.direct");
1594
+ this.dmRoomIds.clear();
1595
+ if (!direct || typeof direct !== "object") return false;
1596
+ for (const value of Object.values(direct)) {
1597
+ if (!Array.isArray(value)) continue;
1598
+ for (const roomId of value) if (typeof roomId === "string" && roomId.trim()) this.dmRoomIds.add(roomId);
1599
+ }
1600
+ return true;
1270
1601
  }
1271
1602
  };
1272
1603
  //#endregion
1273
- export { ConsoleLogger, LogService, MatrixClient };
1604
+ export { ConsoleLogger, LogService, MatrixClient, isRepairableSecretStorageAccessError as n, sdk_exports as t };