@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.
- package/README.md +1 -1
- package/dist/{account-selection-kqquRzCf.js → .setup/account-selection-BOQeTqax.mjs} +18 -17
- package/dist/{approval-handler.runtime-DSeaIsGa.js → .setup/approval-handler.runtime-CEXm9_-p.mjs} +18 -28
- package/dist/{approval-ids-BdJGPAJT.js → .setup/approval-ids-DdFnDB3h.mjs} +1 -1
- package/dist/{approval-reaction-auth-BjOpELxu.js → .setup/approval-reaction-auth-CREvd7S7.mjs} +2 -2
- package/dist/.setup/approval-reactions-Cltyp8nL.mjs +113 -0
- package/dist/.setup/async-lock-BcLS4KOc.mjs +19 -0
- package/dist/{channel-vj788dNZ.js → .setup/channel-an4umty1.mjs} +186 -144
- package/dist/{channel.runtime-CLoF2S9T.js → .setup/channel.runtime-GHcIBJ7H.mjs} +51 -45
- package/dist/{cli-DMqfDE-q.js → .setup/cli-B3WYmv5U.mjs} +882 -901
- package/dist/{cli-metadata-C7D53SND.js → .setup/cli-metadata-RUKCn0wJ.mjs} +1 -1
- package/dist/{client-6eRENr7k.js → .setup/client-Ct0bUHCo.mjs} +5 -5
- package/dist/{shared-CUMWxcMz.js → .setup/client-DFBQtzCe.mjs} +422 -179
- package/dist/.setup/client-bootstrap-Be8jvNle.mjs +74 -0
- package/dist/{config-schema-Djxw3C6b.js → .setup/config-schema-D9J_vUF6.mjs} +89 -70
- package/dist/.setup/credentials-BhZlA0kL.mjs +56 -0
- package/dist/.setup/credentials-read-CRHg6XPm.mjs +114 -0
- package/dist/{credentials-write.runtime-Be9zNSUw.js → .setup/credentials-write.runtime-dWuLafsk.mjs} +1 -1
- package/dist/{crypto-runtime-D9_6J5tZ.js → .setup/crypto-runtime-D-cZa8P0.mjs} +81 -35
- package/dist/.setup/crypto-state-store-B43k3z3W.mjs +352 -0
- package/dist/{deps-CcVJfvRM.js → .setup/deps-Dy6yreL4.mjs} +92 -25
- package/dist/{device-health-B4-YXtJR.js → .setup/device-health-D4LBxuPq.mjs} +1 -6
- package/dist/{directory-live-C8dVBiCc.js → .setup/directory-live-BTEYxMwy.mjs} +10 -9
- package/dist/.setup/doctor-BGnvMzOR.mjs +169 -0
- package/dist/.setup/doctor-contract-DNJw0fdq.mjs +246 -0
- package/dist/{draft-stream-CtvOXq0Z.js → .setup/draft-stream-C-_OhpE8.mjs} +1 -6
- package/dist/{encryption-guidance-CbEFe38F.js → .setup/encryption-guidance-CpuuwmjL.mjs} +4 -3
- package/dist/{env-auth-CQsYbz-p.js → .setup/env-auth-CYJL1jNl.mjs} +2 -2
- package/dist/{env-vars-B0NxQnPk.js → .setup/env-vars-KzaYveuy.mjs} +1 -3
- package/dist/{exec-approval-resolver-BCgqRtZS.js → .setup/exec-approval-resolver-f9j6staN.mjs} +1 -2
- package/dist/{file-sync-store-DiiFsayX.js → .setup/file-sync-store-DU0cnYAz.mjs} +30 -25
- package/dist/{http-client-CycYxU9-.js → .setup/http-client-C954In2D.mjs} +45 -25
- package/dist/{idb-persistence-B6x7dMsF.js → .setup/idb-persistence-_HKTXkVC.mjs} +76 -78
- package/dist/{idb-persistence-lock-DAJ49nZX.js → .setup/idb-persistence-lock-B3fZXyF_.mjs} +1 -1
- package/dist/.setup/legacy-crypto-inspector-Byp8LCys.mjs +42 -0
- package/dist/.setup/legacy-crypto-restore-YQVoK1B2.mjs +93 -0
- package/dist/{logger-D0GCSDQq.js → .setup/logger-DpoogOgz.mjs} +1 -1
- package/dist/{logging-DV-p52N0.js → .setup/logging-CgxQOJJP.mjs} +2 -9
- package/dist/.setup/matrix-migration.runtime-BDH5c3fN.mjs +530 -0
- package/dist/{media-text-BTwzADS_.js → .setup/media-text-Cib-dxkn.mjs} +1 -1
- package/dist/{messages-DxQJkhxs.js → .setup/messages-D4DYGHYX.mjs} +15 -67
- package/dist/.setup/migration-snapshot-backup-CpgYhiUp.mjs +70 -0
- package/dist/.setup/migration-snapshot.runtime-O8qkMVaC.mjs +2 -0
- package/dist/{monitor-VyWlSLwo.js → .setup/monitor-DNcW_oAN.mjs} +2525 -2361
- package/dist/.setup/probe.runtime-CMPh0mFk.mjs +2 -0
- package/dist/{profile-update-CffmyW_4.js → .setup/profile-update-DzOL3Wiw.mjs} +5 -4
- package/dist/{reaction-events-B00WSi98.js → .setup/reaction-events-BcvgXxHb.mjs} +14 -64
- package/dist/{resolve-targets-nm2L48sh.js → .setup/resolve-targets-Bq80X9Sn.mjs} +3 -3
- package/dist/{resolver.runtime-DS6uPaEe.js → .setup/resolver.runtime-CeBHR9-T.mjs} +1 -1
- package/dist/{runtime-api-D1xI_cvh.js → .setup/runtime-api-CEsWNdil.mjs} +4 -4
- package/dist/.setup/runtime-setter-api-DGMubGUq.mjs +3 -0
- package/dist/{sdk-bUytQHx7.js → .setup/sdk-He1quVAq.mjs} +592 -261
- package/dist/.setup/secret-contract-api-CiTJ7pd5.mjs +3 -0
- package/dist/{secret-contract-M3hRmGO-.js → .setup/secret-contract-phPvlNfV.mjs} +53 -28
- package/dist/{send-BldGYG8g.js → .setup/send-CGgl0uTn.mjs} +133 -660
- package/dist/{setup-bootstrap-Deleiibz.js → .setup/setup-bootstrap-DUXBC8X2.mjs} +4 -4
- package/dist/{setup-core-BVfBv2ai.js → .setup/setup-core-bhdcEo7v.mjs} +239 -189
- package/dist/.setup/setup-plugin-api-CAwZ_Bi7.mjs +43 -0
- package/dist/.setup/setup-plugin-api-DIFVsOs3.mjs +2 -0
- package/dist/{setup-surface-BBq3WeqX.js → .setup/setup-surface-05_G-MnT.mjs} +149 -92
- package/dist/{startup-verification-wm3_i88s.js → .setup/startup-verification-BTwIGu1J.mjs} +7 -6
- package/dist/.setup/storage-NGZq5zet.mjs +432 -0
- package/dist/{storage-paths-gUmSydsW.js → .setup/storage-paths-BWo_ZEMC.mjs} +13 -2
- package/dist/{subagent-hooks-dkPAF6Et.js → .setup/subagent-hooks-BSWPJEmo.mjs} +2 -2
- package/dist/{thread-binding-api-DRbBZlhS.js → .setup/thread-binding-api-B7UaOoKv.mjs} +1 -1
- package/dist/{thread-bindings-DGbl3vDW.js → .setup/thread-bindings-DqmjG2on.mjs} +8 -8
- package/dist/{tool-actions.runtime-uu9blSqO.js → .setup/tool-actions.runtime-CXDLk2jg.mjs} +196 -332
- package/dist/{verification-DYMQ1QpI.js → .setup/verification-DeWOtZJr.mjs} +4 -3
- package/dist/api.js +9 -9
- package/dist/auth-presence.js +21 -13
- package/dist/channel-plugin-api.js +1 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/contract-api.js +2 -2
- package/dist/doctor-contract-api.js +99 -524
- package/dist/helper-api.js +4 -4
- package/dist/index.js +1 -1
- package/dist/plugin-entry.handlers.runtime.js +2 -2
- package/dist/runtime-api.js +8 -8
- package/dist/runtime-heavy-api.js +3 -0
- package/dist/runtime-setter-api.js +1 -1
- package/dist/secret-contract-api.js +1 -1
- package/dist/session-binding-contract-api.js +3 -3
- package/dist/setup-entry.js +4 -3
- package/dist/setup-plugin-api.js +1 -44
- package/dist/subagent-hooks-api.js +1 -1
- package/dist/thread-binding-api.js +1 -1
- package/dist/thread-bindings-runtime.js +1 -1
- package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/package.json +1 -1
- package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm.d.ts +2 -14
- package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.cjs +384 -409
- package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.js +224 -246
- package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.wasm +0 -0
- package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.wasm.d.ts +58 -59
- package/node_modules/markdown-it/README.md +18 -294
- package/node_modules/markdown-it/bin/markdown-it.mjs +2 -2
- package/node_modules/markdown-it/dist/browser/markdown-it.esm.min.mjs +3013 -0
- package/node_modules/markdown-it/dist/browser/markdown-it.esm.min.mjs.map +1 -0
- package/node_modules/markdown-it/dist/browser/markdown-it.umd.min.js +14 -0
- package/node_modules/markdown-it/dist/browser/markdown-it.umd.min.js.map +1 -0
- package/node_modules/markdown-it/dist/markdown-it.cjs.js +4420 -0
- package/node_modules/markdown-it/dist/markdown-it.cjs.js.map +1 -0
- package/node_modules/markdown-it/dist/markdown-it.d.cts +19 -0
- package/node_modules/markdown-it/dist/markdown-it.d.mts +950 -0
- package/node_modules/markdown-it/dist/{index.cjs.js → markdown-it.mjs} +1504 -1525
- package/node_modules/markdown-it/dist/markdown-it.mjs.map +1 -0
- package/node_modules/markdown-it/node_modules/argparse/LICENSE +1 -208
- package/node_modules/markdown-it/node_modules/argparse/README.md +46 -41
- package/node_modules/markdown-it/node_modules/argparse/lib/_colorize.js +72 -0
- package/node_modules/markdown-it/node_modules/argparse/lib/argparse.d.ts +292 -0
- package/node_modules/markdown-it/node_modules/argparse/{argparse.js → lib/argparse.js} +1142 -1029
- package/node_modules/markdown-it/node_modules/argparse/lib/difflib.js +190 -0
- package/node_modules/markdown-it/node_modules/argparse/lib/sub.js +4 -4
- package/node_modules/markdown-it/node_modules/argparse/lib/textwrap.js +28 -28
- package/node_modules/markdown-it/node_modules/argparse/package.json +18 -11
- package/node_modules/markdown-it/node_modules/entities/dist/decode-codepoint.d.ts +8 -0
- package/node_modules/markdown-it/node_modules/entities/dist/decode-codepoint.d.ts.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/decode-codepoint.js +46 -0
- package/node_modules/markdown-it/node_modules/entities/dist/decode-codepoint.js.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/{lib → dist}/decode.d.ts +28 -45
- package/node_modules/markdown-it/node_modules/entities/dist/decode.d.ts.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/{lib/esm → dist}/decode.js +189 -141
- package/node_modules/markdown-it/node_modules/entities/dist/decode.js.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/{lib/esm → dist}/encode.d.ts +4 -2
- package/node_modules/markdown-it/node_modules/entities/dist/encode.d.ts.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/encode.js +90 -0
- package/node_modules/markdown-it/node_modules/entities/dist/encode.js.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/{lib → dist}/escape.d.ts +15 -10
- package/node_modules/markdown-it/node_modules/entities/dist/escape.d.ts.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/escape.js +132 -0
- package/node_modules/markdown-it/node_modules/entities/dist/escape.js.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-html.d.ts +3 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-html.d.ts.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-html.js +5 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-html.js.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-xml.d.ts +3 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-xml.d.ts.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-xml.js +5 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-xml.js.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/encode-html.d.ts +5 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/encode-html.d.ts.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/encode-html.js +12 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/encode-html.js.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/{lib/esm → dist}/index.d.ts +14 -21
- package/node_modules/markdown-it/node_modules/entities/dist/index.d.ts.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/index.js +91 -0
- package/node_modules/markdown-it/node_modules/entities/dist/index.js.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/bin-trie-flags.d.ts +17 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/bin-trie-flags.d.ts.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/bin-trie-flags.js +18 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/bin-trie-flags.js.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/decode-shared.d.ts +7 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/decode-shared.d.ts.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/decode-shared.js +17 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/decode-shared.js.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/encode-shared.d.ts +33 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/encode-shared.d.ts.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/encode-shared.js +93 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/encode-shared.js.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/package.json +63 -70
- package/node_modules/markdown-it/node_modules/entities/readme.md +54 -45
- package/node_modules/markdown-it/node_modules/entities/src/decode-codepoint.ts +50 -0
- package/node_modules/markdown-it/node_modules/entities/src/decode.ts +671 -0
- package/node_modules/markdown-it/node_modules/entities/src/encode.ts +95 -0
- package/node_modules/markdown-it/node_modules/entities/src/escape.ts +160 -0
- package/node_modules/markdown-it/node_modules/entities/src/generated/decode-data-html.ts +7 -0
- package/node_modules/markdown-it/node_modules/entities/src/generated/decode-data-xml.ts +7 -0
- package/node_modules/markdown-it/node_modules/entities/src/generated/encode-html.ts +18 -0
- package/node_modules/markdown-it/node_modules/entities/src/index.ts +162 -0
- package/node_modules/markdown-it/node_modules/entities/src/internal/bin-trie-flags.ts +16 -0
- package/node_modules/markdown-it/node_modules/entities/src/internal/decode-shared.ts +18 -0
- package/node_modules/markdown-it/node_modules/entities/src/internal/encode-shared.ts +123 -0
- package/node_modules/markdown-it/node_modules/linkify-it/README.md +49 -86
- package/node_modules/markdown-it/node_modules/linkify-it/build/index.cjs.js +636 -825
- package/node_modules/markdown-it/node_modules/linkify-it/build/index.cjs.js.map +1 -0
- package/node_modules/markdown-it/node_modules/linkify-it/build/index.d.ts +236 -0
- package/node_modules/markdown-it/node_modules/linkify-it/build/index.mjs +538 -0
- package/node_modules/markdown-it/node_modules/linkify-it/build/index.mjs.map +1 -0
- package/node_modules/markdown-it/node_modules/linkify-it/package.json +23 -20
- package/node_modules/markdown-it/node_modules/uc.micro/README.md +18 -1
- package/node_modules/markdown-it/node_modules/uc.micro/build/index.cjs.js +13 -18
- package/node_modules/markdown-it/node_modules/uc.micro/build/index.d.ts +6 -0
- package/node_modules/markdown-it/node_modules/uc.micro/build/index.mjs +8 -0
- package/node_modules/markdown-it/node_modules/uc.micro/package.json +12 -17
- package/node_modules/markdown-it/package.json +47 -30
- package/node_modules/matrix-js-sdk/CHANGELOG.md +0 -11
- package/node_modules/matrix-js-sdk/package.json +1 -1
- package/node_modules/music-metadata/lib/common/Util.d.ts +1 -1
- package/node_modules/music-metadata/lib/common/Util.js +1 -7
- package/node_modules/music-metadata/lib/id3v2/FrameHeader.js +3 -23
- package/node_modules/music-metadata/lib/id3v2/FrameParser.js +2 -2
- package/node_modules/music-metadata/lib/id3v2/ID3v2Token.js +1 -1
- package/node_modules/music-metadata/lib/mp4/AtomToken.js +13 -38
- package/node_modules/music-metadata/lib/mpeg/MpegParser.js +1 -1
- package/node_modules/music-metadata/package.json +6 -6
- package/node_modules/typebox/build/compile/validator.d.mts +4 -1
- package/node_modules/typebox/build/guard/guard.d.mts +1 -1
- package/node_modules/typebox/build/guard/guard.mjs +2 -5
- package/node_modules/typebox/build/guard/string.mjs +4 -16
- package/node_modules/typebox/build/schema/engine/_functions.mjs +15 -34
- package/node_modules/typebox/build/type/action/readonly_object.d.mts +0 -5
- package/node_modules/typebox/build/type/action/readonly_object.mjs +0 -8
- package/node_modules/typebox/build/typebox.d.mts +1 -1
- package/node_modules/typebox/build/typebox.mjs +1 -1
- package/node_modules/typebox/package.json +1 -1
- package/node_modules/typebox/readme.md +32 -29
- package/openclaw.plugin.json +146 -152
- package/package.json +31 -114
- package/dist/accounts-DfngqebB.js +0 -130
- package/dist/active-client-DXvz2gCo.js +0 -20
- package/dist/approval-reactions-D-BxBK_L.js +0 -202
- package/dist/client-Dbso3-0V.js +0 -30
- package/dist/client-bootstrap-XsIkHNt0.js +0 -110
- package/dist/create-client-BmSU-q-D.js +0 -61
- package/dist/credentials-W2EmwRhu.js +0 -65
- package/dist/credentials-read-DVmFCm7X.js +0 -77
- package/dist/doctor-CM8ijNpW.js +0 -64
- package/dist/doctor-contract-BMSJkkAE.js +0 -167
- package/dist/inbound-dedupe-CaBLblef.js +0 -48
- package/dist/probe.runtime-BuieqmS3.js +0 -3
- package/dist/record-shared-CWWx6fvI.js +0 -2
- package/dist/recovery-key-store-BNnHvXdk.js +0 -275
- package/dist/room-info-CAFZ3Z9J.js +0 -87
- package/dist/route-DY6at4qJ.js +0 -161
- package/dist/storage-BvAkgzvT.js +0 -685
- package/node_modules/markdown-it/dist/index.cjs.js.map +0 -1
- package/node_modules/markdown-it/dist/markdown-it.js +0 -3975
- package/node_modules/markdown-it/dist/markdown-it.js.map +0 -1
- package/node_modules/markdown-it/dist/markdown-it.min.js +0 -3
- package/node_modules/markdown-it/dist/markdown-it.min.js.map +0 -1
- package/node_modules/markdown-it/index.mjs +0 -1
- package/node_modules/markdown-it/lib/common/html_blocks.mjs +0 -67
- package/node_modules/markdown-it/lib/common/html_re.mjs +0 -25
- package/node_modules/markdown-it/lib/common/utils.mjs +0 -324
- package/node_modules/markdown-it/lib/helpers/index.mjs +0 -11
- package/node_modules/markdown-it/lib/helpers/parse_link_destination.mjs +0 -77
- package/node_modules/markdown-it/lib/helpers/parse_link_label.mjs +0 -49
- package/node_modules/markdown-it/lib/helpers/parse_link_title.mjs +0 -66
- package/node_modules/markdown-it/lib/index.mjs +0 -565
- package/node_modules/markdown-it/lib/parser_block.mjs +0 -134
- package/node_modules/markdown-it/lib/parser_core.mjs +0 -62
- package/node_modules/markdown-it/lib/parser_inline.mjs +0 -197
- package/node_modules/markdown-it/lib/presets/commonmark.mjs +0 -88
- package/node_modules/markdown-it/lib/presets/default.mjs +0 -47
- package/node_modules/markdown-it/lib/presets/zero.mjs +0 -70
- package/node_modules/markdown-it/lib/renderer.mjs +0 -322
- package/node_modules/markdown-it/lib/ruler.mjs +0 -340
- package/node_modules/markdown-it/lib/rules_block/blockquote.mjs +0 -209
- package/node_modules/markdown-it/lib/rules_block/code.mjs +0 -30
- package/node_modules/markdown-it/lib/rules_block/fence.mjs +0 -94
- package/node_modules/markdown-it/lib/rules_block/heading.mjs +0 -51
- package/node_modules/markdown-it/lib/rules_block/hr.mjs +0 -40
- package/node_modules/markdown-it/lib/rules_block/html_block.mjs +0 -80
- package/node_modules/markdown-it/lib/rules_block/lheading.mjs +0 -85
- package/node_modules/markdown-it/lib/rules_block/list.mjs +0 -331
- package/node_modules/markdown-it/lib/rules_block/paragraph.mjs +0 -48
- package/node_modules/markdown-it/lib/rules_block/reference.mjs +0 -212
- package/node_modules/markdown-it/lib/rules_block/state_block.mjs +0 -220
- package/node_modules/markdown-it/lib/rules_block/table.mjs +0 -228
- package/node_modules/markdown-it/lib/rules_core/block.mjs +0 -13
- package/node_modules/markdown-it/lib/rules_core/inline.mjs +0 -11
- package/node_modules/markdown-it/lib/rules_core/linkify.mjs +0 -134
- package/node_modules/markdown-it/lib/rules_core/normalize.mjs +0 -17
- package/node_modules/markdown-it/lib/rules_core/replacements.mjs +0 -101
- package/node_modules/markdown-it/lib/rules_core/smartquotes.mjs +0 -209
- package/node_modules/markdown-it/lib/rules_core/state_core.mjs +0 -17
- package/node_modules/markdown-it/lib/rules_core/text_join.mjs +0 -43
- package/node_modules/markdown-it/lib/rules_inline/autolink.mjs +0 -72
- package/node_modules/markdown-it/lib/rules_inline/backticks.mjs +0 -60
- package/node_modules/markdown-it/lib/rules_inline/balance_pairs.mjs +0 -124
- package/node_modules/markdown-it/lib/rules_inline/emphasis.mjs +0 -123
- package/node_modules/markdown-it/lib/rules_inline/entity.mjs +0 -51
- package/node_modules/markdown-it/lib/rules_inline/escape.mjs +0 -83
- package/node_modules/markdown-it/lib/rules_inline/fragments_join.mjs +0 -38
- package/node_modules/markdown-it/lib/rules_inline/html_inline.mjs +0 -50
- package/node_modules/markdown-it/lib/rules_inline/image.mjs +0 -138
- package/node_modules/markdown-it/lib/rules_inline/link.mjs +0 -139
- package/node_modules/markdown-it/lib/rules_inline/linkify.mjs +0 -63
- package/node_modules/markdown-it/lib/rules_inline/newline.mjs +0 -42
- package/node_modules/markdown-it/lib/rules_inline/state_inline.mjs +0 -154
- package/node_modules/markdown-it/lib/rules_inline/strikethrough.mjs +0 -127
- package/node_modules/markdown-it/lib/rules_inline/text.mjs +0 -86
- package/node_modules/markdown-it/lib/token.mjs +0 -191
- package/node_modules/markdown-it/node_modules/argparse/CHANGELOG.md +0 -216
- package/node_modules/markdown-it/node_modules/entities/lib/decode.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/decode.js +0 -536
- package/node_modules/markdown-it/node_modules/entities/lib/decode.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/decode_codepoint.d.ts +0 -19
- package/node_modules/markdown-it/node_modules/entities/lib/decode_codepoint.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/decode_codepoint.js +0 -76
- package/node_modules/markdown-it/node_modules/entities/lib/decode_codepoint.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/encode.d.ts +0 -22
- package/node_modules/markdown-it/node_modules/entities/lib/encode.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/encode.js +0 -77
- package/node_modules/markdown-it/node_modules/entities/lib/encode.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/escape.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/escape.js +0 -122
- package/node_modules/markdown-it/node_modules/entities/lib/escape.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/decode.d.ts +0 -211
- package/node_modules/markdown-it/node_modules/entities/lib/esm/decode.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/decode.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/decode_codepoint.d.ts +0 -19
- package/node_modules/markdown-it/node_modules/entities/lib/esm/decode_codepoint.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/decode_codepoint.js +0 -71
- package/node_modules/markdown-it/node_modules/entities/lib/esm/decode_codepoint.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/encode.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/encode.js +0 -69
- package/node_modules/markdown-it/node_modules/entities/lib/esm/encode.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/escape.d.ts +0 -43
- package/node_modules/markdown-it/node_modules/entities/lib/esm/escape.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/escape.js +0 -116
- package/node_modules/markdown-it/node_modules/entities/lib/esm/escape.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-html.d.ts +0 -3
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-html.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-html.js +0 -7
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-html.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-xml.d.ts +0 -3
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-xml.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-xml.js +0 -7
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-xml.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/encode-html.d.ts +0 -8
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/encode-html.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/encode-html.js +0 -10
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/encode-html.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/index.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/index.js +0 -99
- package/node_modules/markdown-it/node_modules/entities/lib/esm/index.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/package.json +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-html.d.ts +0 -3
- package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-html.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-html.js +0 -9
- package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-html.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-xml.d.ts +0 -3
- package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-xml.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-xml.js +0 -9
- package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-xml.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/generated/encode-html.d.ts +0 -8
- package/node_modules/markdown-it/node_modules/entities/lib/generated/encode-html.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/generated/encode-html.js +0 -12
- package/node_modules/markdown-it/node_modules/entities/lib/generated/encode-html.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/index.d.ts +0 -96
- package/node_modules/markdown-it/node_modules/entities/lib/index.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/index.js +0 -126
- package/node_modules/markdown-it/node_modules/entities/lib/index.js.map +0 -1
- package/node_modules/markdown-it/node_modules/linkify-it/index.mjs +0 -646
- package/node_modules/markdown-it/node_modules/linkify-it/lib/re.mjs +0 -193
- package/node_modules/markdown-it/node_modules/uc.micro/categories/Cc/regex.mjs +0 -1
- package/node_modules/markdown-it/node_modules/uc.micro/categories/Cf/regex.mjs +0 -1
- package/node_modules/markdown-it/node_modules/uc.micro/categories/P/regex.mjs +0 -1
- package/node_modules/markdown-it/node_modules/uc.micro/categories/S/regex.mjs +0 -1
- package/node_modules/markdown-it/node_modules/uc.micro/categories/Z/regex.mjs +0 -1
- package/node_modules/markdown-it/node_modules/uc.micro/index.mjs +0 -8
- package/node_modules/markdown-it/node_modules/uc.micro/properties/Any/regex.mjs +0 -1
- /package/dist/{account-config-BZWN9tGS.js → .setup/account-config-BZWN9tGS.mjs} +0 -0
- /package/dist/{backup-health-Dm_YMVFT.js → .setup/backup-health-Dm_YMVFT.mjs} +0 -0
- /package/dist/{config-paths-CnREYb1Y.js → .setup/config-paths-CnREYb1Y.mjs} +0 -0
- /package/dist/{config-secret-input.runtime-CwsP3--c.js → .setup/config-secret-input.runtime-CwsP3--c.mjs} +0 -0
- /package/dist/{crypto-node.runtime-6Aj_ltHQ.js → .setup/crypto-node.runtime-6Aj_ltHQ.mjs} +0 -0
- /package/dist/{errors-C47hvAF8.js → .setup/errors-C47hvAF8.mjs} +0 -0
- /package/dist/{preflight-audio.runtime-BZxxQsxY.js → .setup/preflight-audio.runtime-BZxxQsxY.mjs} +0 -0
- /package/dist/{reaction-common-DkrQdBSZ.js → .setup/reaction-common-DkrQdBSZ.mjs} +0 -0
- /package/dist/{rolldown-runtime-8H4AJuhK.js → .setup/rolldown-runtime-8H4AJuhK.mjs} +0 -0
- /package/dist/{runtime-6S3DNFNv.js → .setup/runtime-6S3DNFNv.mjs} +0 -0
- /package/dist/{runtime-BefyhPWv.js → .setup/runtime-BefyhPWv.mjs} +0 -0
- /package/dist/{sync-state-CWbp0QSY.js → .setup/sync-state-CWbp0QSY.mjs} +0 -0
- /package/dist/{target-ids-B-5aQxwn.js → .setup/target-ids-B-5aQxwn.mjs} +0 -0
- /package/dist/{thread-bindings-shared-CKnY4LSd.js → .setup/thread-bindings-shared-CKnY4LSd.mjs} +0 -0
- /package/dist/{timeout-abort-signal-DMrgRFIy.js → .setup/timeout-abort-signal-DMrgRFIy.mjs} +0 -0
- /package/dist/{url-validation-GRHde6lq.js → .setup/url-validation-GRHde6lq.mjs} +0 -0
|
@@ -1,47 +1,54 @@
|
|
|
1
|
-
import { t as formatMatrixErrorMessage } from "./errors-C47hvAF8.
|
|
2
|
-
import { t as ensureMatrixCryptoRuntime } from "./deps-
|
|
3
|
-
import { n as LogService, r as noop } from "./logger-
|
|
4
|
-
import { i as restoreIdbFromDisk, n as persistIdbToDisk } from "./idb-persistence-
|
|
5
|
-
import { n as isRepairableSecretStorageAccessError } from "./
|
|
1
|
+
import { t as formatMatrixErrorMessage } from "./errors-C47hvAF8.mjs";
|
|
2
|
+
import { t as ensureMatrixCryptoRuntime } from "./deps-Dy6yreL4.mjs";
|
|
3
|
+
import { n as LogService, r as noop } from "./logger-DpoogOgz.mjs";
|
|
4
|
+
import { i as restoreIdbFromDisk, n as persistIdbToDisk } from "./idb-persistence-_HKTXkVC.mjs";
|
|
5
|
+
import { n as isRepairableSecretStorageAccessError } from "./sdk-He1quVAq.mjs";
|
|
6
6
|
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
7
7
|
import { resolveDateTimestampMs, resolveTimestampMsToIsoString } from "openclaw/plugin-sdk/number-runtime";
|
|
8
8
|
import { MatrixEventEvent } from "matrix-js-sdk/lib/matrix.js";
|
|
9
|
-
import { IDBDatabase } from "fake-indexeddb";
|
|
10
9
|
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
11
10
|
import { VerificationMethod } from "matrix-js-sdk/lib/types.js";
|
|
12
11
|
import "fake-indexeddb/auto";
|
|
13
12
|
import { CryptoEvent } from "matrix-js-sdk/lib/crypto-api/CryptoEvent.js";
|
|
14
13
|
import { DecryptionFailureCode } from "matrix-js-sdk/lib/crypto-api/index.js";
|
|
15
14
|
import { VerificationPhase, VerificationRequestEvent, VerifierEvent } from "matrix-js-sdk/lib/crypto-api/verification.js";
|
|
16
|
-
import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
|
|
17
15
|
//#region extensions/matrix/src/matrix/sdk/fake-indexeddb-prune.ts
|
|
18
16
|
const MATRIX_CRYPTO_DATABASE_SUFFIXES = ["::matrix-sdk-crypto", "::matrix-sdk-crypto-meta"];
|
|
19
17
|
const PRUNER_INSTALLED = Symbol.for("openclaw.matrix.fakeIndexedDbTransactionPruner");
|
|
18
|
+
function getRawDatabase(value) {
|
|
19
|
+
if (!value || typeof value !== "object") return;
|
|
20
|
+
const rawDatabase = value["_rawDatabase"];
|
|
21
|
+
if (!rawDatabase || typeof rawDatabase !== "object") return;
|
|
22
|
+
return rawDatabase;
|
|
23
|
+
}
|
|
20
24
|
function isMatrixCryptoDatabase(rawDatabase) {
|
|
21
|
-
|
|
25
|
+
if (!rawDatabase || !Array.isArray(rawDatabase.transactions)) return false;
|
|
26
|
+
const databaseName = rawDatabase.name;
|
|
27
|
+
return typeof databaseName === "string" && MATRIX_CRYPTO_DATABASE_SUFFIXES.some((suffix) => databaseName.endsWith(suffix));
|
|
22
28
|
}
|
|
23
29
|
function pruneFinishedFakeIndexedDbTransactions(rawDatabase) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
30
|
+
const matrixRawDatabase = rawDatabase;
|
|
31
|
+
if (!isMatrixCryptoDatabase(matrixRawDatabase)) return 0;
|
|
32
|
+
const transactions = matrixRawDatabase.transactions;
|
|
33
|
+
const activeTransactions = transactions.filter((transaction) => transaction?.["_state"] !== "finished");
|
|
27
34
|
const removed = transactions.length - activeTransactions.length;
|
|
28
35
|
if (removed > 0) transactions.splice(0, transactions.length, ...activeTransactions);
|
|
29
36
|
return removed;
|
|
30
37
|
}
|
|
31
38
|
function installFakeIndexedDbTransactionPruner() {
|
|
32
|
-
const databasePrototype = IDBDatabase
|
|
33
|
-
|
|
39
|
+
const databasePrototype = globalThis.IDBDatabase?.prototype;
|
|
40
|
+
const originalTransaction = databasePrototype?.transaction;
|
|
41
|
+
if (!databasePrototype || typeof originalTransaction !== "function" || databasePrototype[PRUNER_INSTALLED]) return;
|
|
34
42
|
Object.defineProperty(databasePrototype, PRUNER_INSTALLED, {
|
|
35
43
|
configurable: false,
|
|
36
44
|
enumerable: false,
|
|
37
45
|
value: true
|
|
38
46
|
});
|
|
39
|
-
const originalTransaction = Object.getOwnPropertyDescriptor(databasePrototype, "transaction")?.value;
|
|
40
47
|
databasePrototype.transaction = function patchedMatrixFakeIndexedDbTransaction(...args) {
|
|
41
|
-
|
|
42
|
-
pruneFinishedFakeIndexedDbTransactions(rawDatabase);
|
|
48
|
+
pruneFinishedFakeIndexedDbTransactions(getRawDatabase(this));
|
|
43
49
|
const transaction = originalTransaction.apply(this, args);
|
|
44
|
-
|
|
50
|
+
const rawDatabase = getRawDatabase(transaction?.db) ?? getRawDatabase(this);
|
|
51
|
+
if (isMatrixCryptoDatabase(rawDatabase) && typeof transaction?.addEventListener === "function") {
|
|
45
52
|
const prune = () => {
|
|
46
53
|
pruneFinishedFakeIndexedDbTransactions(rawDatabase);
|
|
47
54
|
};
|
|
@@ -331,7 +338,7 @@ var MatrixCryptoBootstrapper = class {
|
|
|
331
338
|
};
|
|
332
339
|
//#endregion
|
|
333
340
|
//#region extensions/matrix/src/matrix/sdk/crypto-facade.ts
|
|
334
|
-
const matrixCryptoNodeRuntimeLoader = createLazyRuntimeModule(() => import("./crypto-node.runtime-6Aj_ltHQ.
|
|
341
|
+
const matrixCryptoNodeRuntimeLoader = createLazyRuntimeModule(() => import("./crypto-node.runtime-6Aj_ltHQ.mjs"));
|
|
335
342
|
async function loadMatrixCryptoNodeRuntime() {
|
|
336
343
|
try {
|
|
337
344
|
return await matrixCryptoNodeRuntimeLoader();
|
|
@@ -457,21 +464,31 @@ function createMatrixCryptoFacade(deps) {
|
|
|
457
464
|
const MATRIX_DECRYPT_RETRY_BASE_DELAY_MS = 1500;
|
|
458
465
|
const MATRIX_DECRYPT_RETRY_MAX_DELAY_MS = 3e4;
|
|
459
466
|
const MATRIX_DECRYPT_RETRY_MAX_ATTEMPTS = 8;
|
|
460
|
-
const
|
|
467
|
+
const MATRIX_DECRYPT_DRAIN_TIMEOUT_MS = 5e3;
|
|
468
|
+
const MATRIX_DECRYPT_EXHAUSTED_RETRY_TTL_MS = 36e5;
|
|
461
469
|
const MATRIX_DECRYPT_EXHAUSTED_RETRY_MAX_ENTRIES = 512;
|
|
462
470
|
function resolveDecryptRetryKey(roomId, eventId) {
|
|
463
471
|
if (!roomId || !eventId) return null;
|
|
464
472
|
return `${roomId}|${eventId}`;
|
|
465
473
|
}
|
|
466
|
-
function
|
|
467
|
-
|
|
474
|
+
function isDecryptionFailure(event) {
|
|
475
|
+
return typeof event.isDecryptionFailure === "function" && event.isDecryptionFailure();
|
|
476
|
+
}
|
|
477
|
+
function getDecryptionFailureReason(event) {
|
|
468
478
|
const reason = event.decryptionFailureReason;
|
|
479
|
+
return typeof reason === "string" && reason in DecryptionFailureCode ? reason : null;
|
|
480
|
+
}
|
|
481
|
+
function shouldRetryDecryptionFailure(event) {
|
|
482
|
+
if (!isDecryptionFailure(event)) return false;
|
|
483
|
+
const reason = getDecryptionFailureReason(event);
|
|
484
|
+
if (!reason) return true;
|
|
469
485
|
return reason === DecryptionFailureCode.MEGOLM_UNKNOWN_INBOUND_SESSION_ID || reason === DecryptionFailureCode.OLM_UNKNOWN_MESSAGE_INDEX || reason === DecryptionFailureCode.UNKNOWN_ERROR;
|
|
470
486
|
}
|
|
471
487
|
var MatrixDecryptBridge = class {
|
|
472
488
|
constructor(deps) {
|
|
473
489
|
this.deps = deps;
|
|
474
490
|
this.trackedEncryptedEvents = /* @__PURE__ */ new WeakSet();
|
|
491
|
+
this.pendingSdkDecryptions = /* @__PURE__ */ new Set();
|
|
475
492
|
this.decryptedMessageDedupe = /* @__PURE__ */ new Map();
|
|
476
493
|
this.decryptRetries = /* @__PURE__ */ new Map();
|
|
477
494
|
this.failedDecryptionsNotified = /* @__PURE__ */ new Set();
|
|
@@ -479,6 +496,7 @@ var MatrixDecryptBridge = class {
|
|
|
479
496
|
this.activeRetryRuns = 0;
|
|
480
497
|
this.retryIdleResolvers = /* @__PURE__ */ new Set();
|
|
481
498
|
this.cryptoRetrySignalsBound = false;
|
|
499
|
+
this.quiescing = false;
|
|
482
500
|
this.stopped = false;
|
|
483
501
|
}
|
|
484
502
|
shouldEmitUnencryptedMessage(roomId, eventId) {
|
|
@@ -489,9 +507,17 @@ var MatrixDecryptBridge = class {
|
|
|
489
507
|
return false;
|
|
490
508
|
}
|
|
491
509
|
attachEncryptedEvent(event, roomId) {
|
|
492
|
-
if (this.stopped) return;
|
|
510
|
+
if (this.quiescing || this.stopped) return;
|
|
493
511
|
if (this.trackedEncryptedEvents.has(event)) return;
|
|
494
512
|
this.trackedEncryptedEvents.add(event);
|
|
513
|
+
const sdkDecryption = event.getDecryptionPromise();
|
|
514
|
+
if (sdkDecryption) {
|
|
515
|
+
this.pendingSdkDecryptions.add(sdkDecryption);
|
|
516
|
+
const forgetSdkDecryption = () => {
|
|
517
|
+
this.pendingSdkDecryptions.delete(sdkDecryption);
|
|
518
|
+
};
|
|
519
|
+
sdkDecryption.then(forgetSdkDecryption, forgetSdkDecryption);
|
|
520
|
+
}
|
|
495
521
|
event.on(MatrixEventEvent.Decrypted, (decryptedEvent, err) => {
|
|
496
522
|
this.handleEncryptedEventDecrypted({
|
|
497
523
|
roomId,
|
|
@@ -510,7 +536,7 @@ var MatrixDecryptBridge = class {
|
|
|
510
536
|
}
|
|
511
537
|
}
|
|
512
538
|
retryPendingNow(reason, options) {
|
|
513
|
-
if (this.stopped) return;
|
|
539
|
+
if (this.quiescing || this.stopped) return;
|
|
514
540
|
if (options?.includeExhausted) {
|
|
515
541
|
this.pruneExhaustedDecryptRetries(Date.now());
|
|
516
542
|
for (const [retryKey, state] of this.exhaustedDecryptRetries) {
|
|
@@ -556,16 +582,33 @@ var MatrixDecryptBridge = class {
|
|
|
556
582
|
});
|
|
557
583
|
}
|
|
558
584
|
stop() {
|
|
585
|
+
this.quiescing = true;
|
|
559
586
|
this.stopped = true;
|
|
560
587
|
for (const retryKey of this.decryptRetries.keys()) this.clearDecryptRetry(retryKey);
|
|
588
|
+
this.pendingSdkDecryptions.clear();
|
|
561
589
|
this.exhaustedDecryptRetries.clear();
|
|
562
590
|
}
|
|
563
|
-
async drainPendingDecryptions(
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
if (
|
|
591
|
+
async drainPendingDecryptions(_reason) {
|
|
592
|
+
this.quiescing = true;
|
|
593
|
+
const pendingSdkDecryptions = Array.from(this.pendingSdkDecryptions);
|
|
594
|
+
const pending = Array.from(this.decryptRetries.entries());
|
|
595
|
+
for (const [retryKey, state] of pending) {
|
|
596
|
+
if (state.timer) {
|
|
597
|
+
clearTimeout(state.timer);
|
|
598
|
+
state.timer = null;
|
|
599
|
+
}
|
|
600
|
+
if (!state.inFlight) this.runDecryptRetry(retryKey).catch(noop);
|
|
601
|
+
}
|
|
602
|
+
let timeout;
|
|
603
|
+
try {
|
|
604
|
+
await Promise.race([Promise.all([Promise.allSettled(pendingSdkDecryptions), this.waitForActiveRetryRunsToFinish()]), new Promise((_, reject) => {
|
|
605
|
+
timeout = setTimeout(() => {
|
|
606
|
+
reject(/* @__PURE__ */ new Error(`Matrix decryption drain did not finish within ${MATRIX_DECRYPT_DRAIN_TIMEOUT_MS}ms`));
|
|
607
|
+
}, MATRIX_DECRYPT_DRAIN_TIMEOUT_MS);
|
|
608
|
+
timeout.unref?.();
|
|
609
|
+
})]);
|
|
610
|
+
} finally {
|
|
611
|
+
if (timeout !== void 0) clearTimeout(timeout);
|
|
569
612
|
}
|
|
570
613
|
}
|
|
571
614
|
handleEncryptedEventDecrypted(params) {
|
|
@@ -584,7 +627,7 @@ var MatrixDecryptBridge = class {
|
|
|
584
627
|
else if (retryKey) this.clearDecryptRetry(retryKey);
|
|
585
628
|
return;
|
|
586
629
|
}
|
|
587
|
-
if (params.decryptedEvent
|
|
630
|
+
if (isDecryptionFailure(params.decryptedEvent)) {
|
|
588
631
|
this.emitFailedDecryptionOnce(retryKey, decryptedRoomId, decryptedRaw, /* @__PURE__ */ new Error("Matrix event failed to decrypt"));
|
|
589
632
|
if (shouldRetryDecryptionFailure(params.decryptedEvent)) this.scheduleDecryptRetry({
|
|
590
633
|
event: params.encryptedEvent,
|
|
@@ -607,7 +650,7 @@ var MatrixDecryptBridge = class {
|
|
|
607
650
|
this.deps.emitFailedDecryption(roomId, event, error);
|
|
608
651
|
}
|
|
609
652
|
scheduleDecryptRetry(params) {
|
|
610
|
-
if (this.stopped) return;
|
|
653
|
+
if (this.quiescing || this.stopped) return;
|
|
611
654
|
const retryKey = resolveDecryptRetryKey(params.roomId, params.eventId);
|
|
612
655
|
if (!retryKey) return;
|
|
613
656
|
const existing = this.decryptRetries.get(retryKey);
|
|
@@ -670,8 +713,11 @@ var MatrixDecryptBridge = class {
|
|
|
670
713
|
this.resolveRetryIdleIfNeeded();
|
|
671
714
|
}
|
|
672
715
|
if (this.decryptRetries.get(retryKey) !== state) return;
|
|
673
|
-
if (this.stopped)
|
|
674
|
-
|
|
716
|
+
if (this.stopped || this.quiescing && state.event.isDecryptionFailure()) {
|
|
717
|
+
this.clearDecryptRetry(retryKey);
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
if (isDecryptionFailure(state.event)) {
|
|
675
721
|
if (!shouldRetryDecryptionFailure(state.event)) {
|
|
676
722
|
this.clearDecryptRetry(retryKey);
|
|
677
723
|
return;
|
|
@@ -747,7 +793,7 @@ function isMatrixVerificationPhase(value) {
|
|
|
747
793
|
return typeof value === "number" && MATRIX_VERIFICATION_PHASES.has(value);
|
|
748
794
|
}
|
|
749
795
|
const MAX_TRACKED_VERIFICATION_SESSIONS = 256;
|
|
750
|
-
const TERMINAL_SESSION_RETENTION_MS =
|
|
796
|
+
const TERMINAL_SESSION_RETENTION_MS = 864e5;
|
|
751
797
|
const SAS_AUTO_CONFIRM_DELAY_MS = 3e4;
|
|
752
798
|
var MatrixVerificationManager = class {
|
|
753
799
|
constructor(opts = {}) {
|
|
@@ -867,7 +913,7 @@ var MatrixVerificationManager = class {
|
|
|
867
913
|
const transactionMatches = Array.from(this.verificationSessions.values()).filter((session) => {
|
|
868
914
|
return this.readRequestValue(session.request, () => session.request.transactionId?.trim(), "") === id;
|
|
869
915
|
});
|
|
870
|
-
if (transactionMatches.length === 1) return
|
|
916
|
+
if (transactionMatches.length === 1) return transactionMatches[0];
|
|
871
917
|
if (transactionMatches.length > 1) throw new Error(`Matrix verification request id is ambiguous for transaction ${id}; use the verification id instead`);
|
|
872
918
|
throw new Error(`Matrix verification request not found: ${id}`);
|
|
873
919
|
}
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import { o as isRecord } from "./account-selection-BOQeTqax.mjs";
|
|
2
|
+
import { t as getMatrixRuntime } from "./runtime-6S3DNFNv.mjs";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
7
|
+
//#region extensions/matrix/src/matrix/sqlite-state.ts
|
|
8
|
+
function resolveStateDirOverride(options) {
|
|
9
|
+
if (!options) return;
|
|
10
|
+
if (options.stateDir) return options.stateDir;
|
|
11
|
+
if (options.stateRootDir) return options.stateRootDir;
|
|
12
|
+
return getMatrixRuntime().state.resolveStateDir(options.env ?? process.env, os.homedir);
|
|
13
|
+
}
|
|
14
|
+
function resolveMatrixSqliteStateKey(options) {
|
|
15
|
+
return resolveStateDirOverride(options) ?? "";
|
|
16
|
+
}
|
|
17
|
+
function resolveMatrixSqliteStateEnv(options) {
|
|
18
|
+
const stateDir = resolveStateDirOverride(options);
|
|
19
|
+
if (!stateDir) return options?.env;
|
|
20
|
+
return {
|
|
21
|
+
...options?.env ?? process.env,
|
|
22
|
+
OPENCLAW_STATE_DIR: stateDir
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region extensions/matrix/src/matrix/crypto-state-store.ts
|
|
27
|
+
const STATE_KEY = "current";
|
|
28
|
+
const RECOVERY_KEY_NAMESPACE = "recovery-key";
|
|
29
|
+
const LEGACY_CRYPTO_MIGRATION_NAMESPACE = "legacy-crypto-migration";
|
|
30
|
+
const IDB_SNAPSHOT_NAMESPACE = "idb-snapshot";
|
|
31
|
+
const SMALL_STATE_MAX_ENTRIES = 10;
|
|
32
|
+
const IDB_SNAPSHOT_MAX_ENTRIES = 2e4;
|
|
33
|
+
const IDB_SNAPSHOT_MAX_CHUNKS = Math.floor(19999 / 2);
|
|
34
|
+
const IDB_SNAPSHOT_CHUNK_BYTES = 24e3;
|
|
35
|
+
const MATRIX_RECOVERY_KEY_FILENAME = "recovery-key.json";
|
|
36
|
+
const MATRIX_LEGACY_CRYPTO_MIGRATION_FILENAME = "legacy-crypto-migration.json";
|
|
37
|
+
const MATRIX_IDB_SNAPSHOT_FILENAME = "crypto-idb-snapshot.json";
|
|
38
|
+
function openMatrixRecoveryKeyStoreOptions(storageRootDir) {
|
|
39
|
+
return {
|
|
40
|
+
namespace: RECOVERY_KEY_NAMESPACE,
|
|
41
|
+
maxEntries: SMALL_STATE_MAX_ENTRIES,
|
|
42
|
+
env: resolveMatrixSqliteStateEnv({ stateDir: storageRootDir })
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function openMatrixLegacyCryptoMigrationStoreOptions(storageRootDir) {
|
|
46
|
+
return {
|
|
47
|
+
namespace: LEGACY_CRYPTO_MIGRATION_NAMESPACE,
|
|
48
|
+
maxEntries: SMALL_STATE_MAX_ENTRIES,
|
|
49
|
+
env: resolveMatrixSqliteStateEnv({ stateDir: storageRootDir })
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function openMatrixIdbSnapshotStoreOptions(storageRootDir) {
|
|
53
|
+
return {
|
|
54
|
+
namespace: IDB_SNAPSHOT_NAMESPACE,
|
|
55
|
+
maxEntries: IDB_SNAPSHOT_MAX_ENTRIES,
|
|
56
|
+
env: resolveMatrixSqliteStateEnv({ stateDir: storageRootDir })
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function readMatrixRecoveryKeyState(storageRootDir) {
|
|
60
|
+
return readMatrixRecoveryKeyStateWithKey({
|
|
61
|
+
storageRootDir,
|
|
62
|
+
stateKey: STATE_KEY
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function readMatrixRecoveryKeyStateForPath(recoveryKeyPath) {
|
|
66
|
+
return readMatrixRecoveryKeyStateWithKey({
|
|
67
|
+
storageRootDir: path.dirname(recoveryKeyPath),
|
|
68
|
+
stateKey: resolveRecoveryKeyStateKeyForPath(recoveryKeyPath)
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function readMatrixRecoveryKeyStateWithKey(params) {
|
|
72
|
+
return normalizeMatrixStoredRecoveryKey(openSyncStore(openMatrixRecoveryKeyStoreOptions(params.storageRootDir)).lookup(params.stateKey));
|
|
73
|
+
}
|
|
74
|
+
function writeMatrixRecoveryKeyState(params) {
|
|
75
|
+
writeMatrixRecoveryKeyStateWithKey({
|
|
76
|
+
storageRootDir: params.storageRootDir,
|
|
77
|
+
stateKey: STATE_KEY,
|
|
78
|
+
payload: params.payload
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
function writeMatrixRecoveryKeyStateForPath(params) {
|
|
82
|
+
writeMatrixRecoveryKeyStateWithKey({
|
|
83
|
+
storageRootDir: path.dirname(params.recoveryKeyPath),
|
|
84
|
+
stateKey: resolveRecoveryKeyStateKeyForPath(params.recoveryKeyPath),
|
|
85
|
+
payload: params.payload
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function writeMatrixRecoveryKeyStateWithKey(params) {
|
|
89
|
+
const payload = normalizeMatrixStoredRecoveryKey(params.payload);
|
|
90
|
+
if (!payload) throw new Error("Invalid Matrix recovery key state");
|
|
91
|
+
openSyncStore(openMatrixRecoveryKeyStoreOptions(params.storageRootDir)).register(params.stateKey, payload);
|
|
92
|
+
}
|
|
93
|
+
async function hasMatrixRecoveryKeyStateInStore(params) {
|
|
94
|
+
return normalizeMatrixStoredRecoveryKey(await params.store.lookup(STATE_KEY)) !== null;
|
|
95
|
+
}
|
|
96
|
+
async function writeMatrixRecoveryKeyStateToStore(params) {
|
|
97
|
+
const payload = normalizeMatrixStoredRecoveryKey(params.payload);
|
|
98
|
+
if (!payload) throw new Error("Invalid Matrix recovery key state");
|
|
99
|
+
await params.store.register(STATE_KEY, payload);
|
|
100
|
+
}
|
|
101
|
+
function readMatrixLegacyCryptoMigrationState(storageRootDir) {
|
|
102
|
+
return normalizeMatrixLegacyCryptoMigrationState(openSyncStore(openMatrixLegacyCryptoMigrationStoreOptions(storageRootDir)).lookup(STATE_KEY));
|
|
103
|
+
}
|
|
104
|
+
function writeMatrixLegacyCryptoMigrationState(params) {
|
|
105
|
+
const state = normalizeMatrixLegacyCryptoMigrationState(params.state);
|
|
106
|
+
if (!state) throw new Error("Invalid Matrix legacy crypto migration state");
|
|
107
|
+
openSyncStore(openMatrixLegacyCryptoMigrationStoreOptions(params.storageRootDir)).register(STATE_KEY, state);
|
|
108
|
+
}
|
|
109
|
+
async function hasMatrixLegacyCryptoMigrationStateInStore(params) {
|
|
110
|
+
return normalizeMatrixLegacyCryptoMigrationState(await params.store.lookup(STATE_KEY)) !== null;
|
|
111
|
+
}
|
|
112
|
+
async function writeMatrixLegacyCryptoMigrationStateToStore(params) {
|
|
113
|
+
const state = normalizeMatrixLegacyCryptoMigrationState(params.state);
|
|
114
|
+
if (!state) throw new Error("Invalid Matrix legacy crypto migration state");
|
|
115
|
+
await params.store.register(STATE_KEY, state);
|
|
116
|
+
}
|
|
117
|
+
function readMatrixIdbSnapshotJson(storageRootDir) {
|
|
118
|
+
return readIdbSnapshotJsonFromStore(openSyncStore(openMatrixIdbSnapshotStoreOptions(storageRootDir)));
|
|
119
|
+
}
|
|
120
|
+
function hasMatrixIdbSnapshotState(storageRootDir) {
|
|
121
|
+
return isIdbSnapshotMeta(openSyncStore(openMatrixIdbSnapshotStoreOptions(storageRootDir)).lookup(idbMetaKey()));
|
|
122
|
+
}
|
|
123
|
+
function writeMatrixIdbSnapshotJson(params) {
|
|
124
|
+
writeIdbSnapshotJsonToStore({
|
|
125
|
+
snapshotJson: params.snapshotJson,
|
|
126
|
+
databaseCount: params.databaseCount,
|
|
127
|
+
store: openSyncStore(openMatrixIdbSnapshotStoreOptions(params.storageRootDir))
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
async function hasMatrixIdbSnapshotStateInStore(params) {
|
|
131
|
+
return await readIdbSnapshotJsonFromAsyncStore(params.store) !== null;
|
|
132
|
+
}
|
|
133
|
+
async function writeMatrixIdbSnapshotJsonToStore(params) {
|
|
134
|
+
const rows = buildIdbSnapshotRows(params.snapshotJson, params.databaseCount);
|
|
135
|
+
for (const row of rows.chunks) await params.store.register(row.key, row.value);
|
|
136
|
+
await params.store.register(rows.meta.key, rows.meta.value);
|
|
137
|
+
for (const row of await params.store.entries()) if (row.key.startsWith(idbChunkKeyPrefix()) && !rows.nextChunkKeys.has(row.key)) await params.store.delete(row.key);
|
|
138
|
+
}
|
|
139
|
+
function migrateLegacyMatrixRecoveryKeyFileToStore(storageRootDir) {
|
|
140
|
+
return migrateLegacyMatrixRecoveryKeyFilePathToStore(path.join(storageRootDir, MATRIX_RECOVERY_KEY_FILENAME));
|
|
141
|
+
}
|
|
142
|
+
function migrateLegacyMatrixRecoveryKeyFilePathToStore(recoveryKeyPath) {
|
|
143
|
+
const existing = readMatrixRecoveryKeyStateForPath(recoveryKeyPath);
|
|
144
|
+
const legacy = readLegacyMatrixRecoveryKeyFile(recoveryKeyPath);
|
|
145
|
+
if (!existing && legacy) writeMatrixRecoveryKeyStateForPath({
|
|
146
|
+
recoveryKeyPath,
|
|
147
|
+
payload: legacy
|
|
148
|
+
});
|
|
149
|
+
return archiveLegacyStateFileIfPossible(recoveryKeyPath);
|
|
150
|
+
}
|
|
151
|
+
function migrateLegacyMatrixLegacyCryptoMigrationFileToStore(storageRootDir) {
|
|
152
|
+
const existing = readMatrixLegacyCryptoMigrationState(storageRootDir);
|
|
153
|
+
const legacy = readLegacyMatrixLegacyCryptoMigrationState(storageRootDir);
|
|
154
|
+
if (!existing && legacy) writeMatrixLegacyCryptoMigrationState({
|
|
155
|
+
storageRootDir,
|
|
156
|
+
state: legacy
|
|
157
|
+
});
|
|
158
|
+
return archiveLegacyStateFileIfPossible(path.join(storageRootDir, MATRIX_LEGACY_CRYPTO_MIGRATION_FILENAME));
|
|
159
|
+
}
|
|
160
|
+
function readLegacyMatrixRecoveryKeyState(storageRootDir) {
|
|
161
|
+
return readLegacyMatrixRecoveryKeyFile(path.join(storageRootDir, MATRIX_RECOVERY_KEY_FILENAME));
|
|
162
|
+
}
|
|
163
|
+
function readLegacyMatrixRecoveryKeyFile(filePath) {
|
|
164
|
+
return readJsonFileSync(filePath, normalizeMatrixStoredRecoveryKey);
|
|
165
|
+
}
|
|
166
|
+
function readLegacyMatrixLegacyCryptoMigrationState(storageRootDir) {
|
|
167
|
+
return readJsonFileSync(path.join(storageRootDir, MATRIX_LEGACY_CRYPTO_MIGRATION_FILENAME), normalizeMatrixLegacyCryptoMigrationState);
|
|
168
|
+
}
|
|
169
|
+
function scoreMatrixCryptoStateInStore(storageRootDir) {
|
|
170
|
+
if (!matrixCryptoStateDatabaseExists(storageRootDir)) return 0;
|
|
171
|
+
let score = 0;
|
|
172
|
+
try {
|
|
173
|
+
if (readMatrixLegacyCryptoMigrationState(storageRootDir)) score += 3;
|
|
174
|
+
} catch {}
|
|
175
|
+
try {
|
|
176
|
+
if (readMatrixRecoveryKeyState(storageRootDir)) score += 2;
|
|
177
|
+
} catch {}
|
|
178
|
+
try {
|
|
179
|
+
if (hasMatrixIdbSnapshotState(storageRootDir)) score += 2;
|
|
180
|
+
} catch {}
|
|
181
|
+
return score;
|
|
182
|
+
}
|
|
183
|
+
function matrixCryptoStateDatabaseExists(storageRootDir) {
|
|
184
|
+
return fs.existsSync(path.join(storageRootDir, "state", "openclaw.sqlite"));
|
|
185
|
+
}
|
|
186
|
+
function resolveRecoveryKeyStateKeyForPath(recoveryKeyPath) {
|
|
187
|
+
const basename = path.basename(recoveryKeyPath);
|
|
188
|
+
if (basename === "recovery-key.json") return STATE_KEY;
|
|
189
|
+
return `file:${createHash("sha256").update(basename, "utf8").digest("hex").slice(0, 32)}`;
|
|
190
|
+
}
|
|
191
|
+
function normalizeMatrixStoredRecoveryKey(value) {
|
|
192
|
+
if (!isRecord(value) || value.version !== 1 || typeof value.createdAt !== "string" || typeof value.privateKeyBase64 !== "string" || !value.privateKeyBase64.trim()) return null;
|
|
193
|
+
return {
|
|
194
|
+
version: 1,
|
|
195
|
+
createdAt: value.createdAt,
|
|
196
|
+
keyId: typeof value.keyId === "string" ? value.keyId : null,
|
|
197
|
+
...typeof value.encodedPrivateKey === "string" ? { encodedPrivateKey: value.encodedPrivateKey } : {},
|
|
198
|
+
privateKeyBase64: value.privateKeyBase64,
|
|
199
|
+
...isRecord(value.keyInfo) ? { keyInfo: {
|
|
200
|
+
...value.keyInfo.passphrase !== void 0 ? { passphrase: value.keyInfo.passphrase } : {},
|
|
201
|
+
...typeof value.keyInfo.name === "string" ? { name: value.keyInfo.name } : {}
|
|
202
|
+
} } : {}
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
function normalizeMatrixLegacyCryptoMigrationState(value) {
|
|
206
|
+
if (!isRecord(value) || value.version !== 1 || typeof value.accountId !== "string") return null;
|
|
207
|
+
if (value.restoreStatus !== "pending" && value.restoreStatus !== "completed" && value.restoreStatus !== "manual-action-required") return null;
|
|
208
|
+
const roomKeyCounts = isRecord(value.roomKeyCounts) && typeof value.roomKeyCounts.total === "number" && typeof value.roomKeyCounts.backedUp === "number" ? {
|
|
209
|
+
total: value.roomKeyCounts.total,
|
|
210
|
+
backedUp: value.roomKeyCounts.backedUp
|
|
211
|
+
} : null;
|
|
212
|
+
return {
|
|
213
|
+
version: 1,
|
|
214
|
+
...value.source === "matrix-bot-sdk-rust" ? { source: value.source } : {},
|
|
215
|
+
accountId: value.accountId,
|
|
216
|
+
...typeof value.deviceId === "string" || value.deviceId === null ? { deviceId: value.deviceId } : {},
|
|
217
|
+
roomKeyCounts,
|
|
218
|
+
...typeof value.backupVersion === "string" || value.backupVersion === null ? { backupVersion: value.backupVersion } : {},
|
|
219
|
+
...typeof value.decryptionKeyImported === "boolean" ? { decryptionKeyImported: value.decryptionKeyImported } : {},
|
|
220
|
+
restoreStatus: value.restoreStatus,
|
|
221
|
+
...typeof value.detectedAt === "string" ? { detectedAt: value.detectedAt } : {},
|
|
222
|
+
...typeof value.restoredAt === "string" ? { restoredAt: value.restoredAt } : {},
|
|
223
|
+
...typeof value.importedCount === "number" ? { importedCount: value.importedCount } : {},
|
|
224
|
+
...typeof value.totalCount === "number" ? { totalCount: value.totalCount } : {},
|
|
225
|
+
...typeof value.lastError === "string" || value.lastError === null ? { lastError: value.lastError } : {}
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
function openSyncStore(options) {
|
|
229
|
+
return getMatrixRuntime().state.openSyncKeyedStore(options);
|
|
230
|
+
}
|
|
231
|
+
function readJsonFileSync(filePath, normalize) {
|
|
232
|
+
try {
|
|
233
|
+
return normalize(JSON.parse(fs.readFileSync(filePath, "utf8")));
|
|
234
|
+
} catch {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
function archiveLegacyStateFileIfPossible(filePath) {
|
|
239
|
+
if (!fs.existsSync(filePath)) return false;
|
|
240
|
+
const archivedPath = `${filePath}.migrated`;
|
|
241
|
+
if (fs.existsSync(archivedPath)) return false;
|
|
242
|
+
fs.renameSync(filePath, archivedPath);
|
|
243
|
+
return true;
|
|
244
|
+
}
|
|
245
|
+
function readIdbSnapshotJsonFromStore(store) {
|
|
246
|
+
const meta = store.lookup(idbMetaKey());
|
|
247
|
+
if (!isIdbSnapshotMeta(meta)) return null;
|
|
248
|
+
const chunks = readIdbSnapshotChunks(meta, (key) => store.lookup(key));
|
|
249
|
+
return chunks ? chunks.join("") : null;
|
|
250
|
+
}
|
|
251
|
+
async function readIdbSnapshotJsonFromAsyncStore(store) {
|
|
252
|
+
const meta = await store.lookup(idbMetaKey());
|
|
253
|
+
if (!isIdbSnapshotMeta(meta)) return null;
|
|
254
|
+
const chunks = await readIdbSnapshotChunksAsync(meta, (key) => store.lookup(key));
|
|
255
|
+
return chunks ? chunks.join("") : null;
|
|
256
|
+
}
|
|
257
|
+
function readIdbSnapshotChunks(meta, lookup) {
|
|
258
|
+
const chunks = [];
|
|
259
|
+
for (let index = 0; index < meta.chunkCount; index += 1) {
|
|
260
|
+
const chunk = lookup(idbChunkKey(meta.generation, index));
|
|
261
|
+
if (!isIdbSnapshotChunk(chunk) || chunk.index !== index) return null;
|
|
262
|
+
chunks.push(chunk.data);
|
|
263
|
+
}
|
|
264
|
+
const snapshotJson = chunks.join("");
|
|
265
|
+
if (meta.digest !== digestText(snapshotJson)) return null;
|
|
266
|
+
return chunks;
|
|
267
|
+
}
|
|
268
|
+
async function readIdbSnapshotChunksAsync(meta, lookup) {
|
|
269
|
+
const chunks = [];
|
|
270
|
+
for (let index = 0; index < meta.chunkCount; index += 1) {
|
|
271
|
+
const chunk = await lookup(idbChunkKey(meta.generation, index));
|
|
272
|
+
if (!isIdbSnapshotChunk(chunk) || chunk.index !== index) return null;
|
|
273
|
+
chunks.push(chunk.data);
|
|
274
|
+
}
|
|
275
|
+
const snapshotJson = chunks.join("");
|
|
276
|
+
if (meta.digest !== digestText(snapshotJson)) return null;
|
|
277
|
+
return chunks;
|
|
278
|
+
}
|
|
279
|
+
function writeIdbSnapshotJsonToStore(params) {
|
|
280
|
+
const rows = buildIdbSnapshotRows(params.snapshotJson, params.databaseCount);
|
|
281
|
+
for (const row of rows.chunks) params.store.register(row.key, row.value);
|
|
282
|
+
params.store.register(rows.meta.key, rows.meta.value);
|
|
283
|
+
for (const row of params.store.entries()) if (row.key.startsWith(idbChunkKeyPrefix()) && !rows.nextChunkKeys.has(row.key)) params.store.delete(row.key);
|
|
284
|
+
}
|
|
285
|
+
function buildIdbSnapshotRows(snapshotJson, databaseCount) {
|
|
286
|
+
const generation = randomUUID().replaceAll("-", "");
|
|
287
|
+
const chunks = chunkText(snapshotJson).map((data, index) => ({
|
|
288
|
+
key: idbChunkKey(generation, index),
|
|
289
|
+
value: {
|
|
290
|
+
kind: "snapshot-chunk",
|
|
291
|
+
index,
|
|
292
|
+
data
|
|
293
|
+
}
|
|
294
|
+
}));
|
|
295
|
+
return {
|
|
296
|
+
chunks,
|
|
297
|
+
nextChunkKeys: new Set(chunks.map((chunk) => chunk.key)),
|
|
298
|
+
meta: {
|
|
299
|
+
key: idbMetaKey(),
|
|
300
|
+
value: {
|
|
301
|
+
kind: "meta",
|
|
302
|
+
version: 1,
|
|
303
|
+
generation,
|
|
304
|
+
chunkCount: chunks.length,
|
|
305
|
+
digest: digestText(snapshotJson),
|
|
306
|
+
databaseCount,
|
|
307
|
+
persistedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
function idbMetaKey() {
|
|
313
|
+
return `${STATE_KEY}:meta`;
|
|
314
|
+
}
|
|
315
|
+
function idbChunkKeyPrefix() {
|
|
316
|
+
return `${STATE_KEY}:snapshot:`;
|
|
317
|
+
}
|
|
318
|
+
function idbChunkKey(generation, index) {
|
|
319
|
+
return `${idbChunkKeyPrefix()}${generation}:${index}`;
|
|
320
|
+
}
|
|
321
|
+
function chunkText(value) {
|
|
322
|
+
const chunks = [];
|
|
323
|
+
let current = "";
|
|
324
|
+
let currentBytes = 0;
|
|
325
|
+
for (const char of value) {
|
|
326
|
+
const charBytes = Buffer.byteLength(char, "utf8");
|
|
327
|
+
if (current && currentBytes + charBytes > IDB_SNAPSHOT_CHUNK_BYTES) {
|
|
328
|
+
pushChunk(chunks, current);
|
|
329
|
+
current = "";
|
|
330
|
+
currentBytes = 0;
|
|
331
|
+
}
|
|
332
|
+
current += char;
|
|
333
|
+
currentBytes += charBytes;
|
|
334
|
+
}
|
|
335
|
+
if (current) pushChunk(chunks, current);
|
|
336
|
+
return chunks;
|
|
337
|
+
}
|
|
338
|
+
function pushChunk(chunks, chunk) {
|
|
339
|
+
if (chunks.length >= IDB_SNAPSHOT_MAX_CHUNKS) throw new Error("Matrix IndexedDB snapshot exceeds SQLite chunk limit");
|
|
340
|
+
chunks.push(chunk);
|
|
341
|
+
}
|
|
342
|
+
function digestText(value) {
|
|
343
|
+
return createHash("sha256").update(value, "utf8").digest("hex");
|
|
344
|
+
}
|
|
345
|
+
function isIdbSnapshotMeta(value) {
|
|
346
|
+
return isRecord(value) && value.kind === "meta" && value.version === 1 && typeof value.generation === "string" && value.generation.trim() !== "" && typeof value.chunkCount === "number" && Number.isSafeInteger(value.chunkCount) && value.chunkCount >= 0 && value.chunkCount <= IDB_SNAPSHOT_MAX_CHUNKS && typeof value.digest === "string" && typeof value.databaseCount === "number" && Number.isSafeInteger(value.databaseCount) && value.databaseCount >= 0 && typeof value.persistedAt === "string";
|
|
347
|
+
}
|
|
348
|
+
function isIdbSnapshotChunk(value) {
|
|
349
|
+
return isRecord(value) && value.kind === "snapshot-chunk" && typeof value.index === "number" && Number.isSafeInteger(value.index) && value.index >= 0 && typeof value.data === "string";
|
|
350
|
+
}
|
|
351
|
+
//#endregion
|
|
352
|
+
export { writeMatrixLegacyCryptoMigrationState as C, writeMatrixRecoveryKeyStateToStore as D, writeMatrixRecoveryKeyStateForPath as E, resolveMatrixSqliteStateEnv as O, writeMatrixIdbSnapshotJsonToStore as S, writeMatrixRecoveryKeyState as T, readMatrixLegacyCryptoMigrationState as _, hasMatrixLegacyCryptoMigrationStateInStore as a, scoreMatrixCryptoStateInStore as b, migrateLegacyMatrixRecoveryKeyFilePathToStore as c, openMatrixLegacyCryptoMigrationStoreOptions as d, openMatrixRecoveryKeyStoreOptions as f, readMatrixIdbSnapshotJson as g, readLegacyMatrixRecoveryKeyState as h, hasMatrixIdbSnapshotStateInStore as i, resolveMatrixSqliteStateKey as k, migrateLegacyMatrixRecoveryKeyFileToStore as l, readLegacyMatrixRecoveryKeyFile as m, MATRIX_LEGACY_CRYPTO_MIGRATION_FILENAME as n, hasMatrixRecoveryKeyStateInStore as o, readLegacyMatrixLegacyCryptoMigrationState as p, MATRIX_RECOVERY_KEY_FILENAME as r, migrateLegacyMatrixLegacyCryptoMigrationFileToStore as s, MATRIX_IDB_SNAPSHOT_FILENAME as t, openMatrixIdbSnapshotStoreOptions as u, readMatrixRecoveryKeyState as v, writeMatrixLegacyCryptoMigrationStateToStore as w, writeMatrixIdbSnapshotJson as x, readMatrixRecoveryKeyStateForPath as y };
|