@gakr-gakr/matrix 0.1.0 → 0.1.1

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 (301) hide show
  1. package/autobot.plugin.json +891 -3
  2. package/dist/account-selection-D4xDzY_1.js +158 -0
  3. package/dist/active-client-BXz0W1fG.js +20 -0
  4. package/dist/api.js +12 -0
  5. package/dist/approval-handler.runtime-XgtgHryy.js +377 -0
  6. package/dist/approval-ids-Bj1MSuK0.js +7 -0
  7. package/dist/approval-reaction-auth-CP8yUUiI.js +27 -0
  8. package/dist/approval-reactions-C7FrzFhD.js +162 -0
  9. package/dist/async-lock-SsmtFXtt.js +19 -0
  10. package/dist/auth-presence.js +26 -0
  11. package/dist/backup-health-3BHbHxyd.js +60 -0
  12. package/dist/channel-CVtvS1kS.js +1380 -0
  13. package/dist/channel-plugin-api.js +2 -0
  14. package/dist/channel.runtime-BCl9atvS.js +250 -0
  15. package/dist/cli-D1Fxo6zb.js +1338 -0
  16. package/dist/cli-metadata-lo35g_nH.js +22 -0
  17. package/dist/cli-metadata.js +2 -0
  18. package/dist/client-4JU3adE6.js +30 -0
  19. package/dist/client-DVbkO1fr.js +25 -0
  20. package/dist/client-bootstrap-mLJmDCv8.js +114 -0
  21. package/dist/config-paths-BRIwec9o.js +114 -0
  22. package/dist/config-schema-ON2KZjSH.js +308 -0
  23. package/dist/config-secret-input.runtime-BcE98Tab.js +2 -0
  24. package/dist/contract-api.js +8 -0
  25. package/dist/create-client-nSnXsRe0.js +64 -0
  26. package/dist/credentials-CLaeORZB.js +56 -0
  27. package/dist/credentials-read-lnekFDSy.js +112 -0
  28. package/dist/credentials-write.runtime-AcuXkIly.js +17 -0
  29. package/dist/crypto-node.runtime-D9qxgRPa.js +12 -0
  30. package/dist/crypto-runtime-D577JLjP.js +1214 -0
  31. package/dist/deps-CcgU6fF9.js +208 -0
  32. package/dist/device-health-BDJoK0GP.js +16 -0
  33. package/dist/directory-live-D5osmyPM.js +150 -0
  34. package/dist/doctor-contract-CRTZe22J.js +246 -0
  35. package/dist/doctor-contract-api.js +2 -0
  36. package/dist/doctor-k53ce7TR.js +153 -0
  37. package/dist/draft-stream-B81ki3aq.js +143 -0
  38. package/dist/encryption-guidance-C4UZO9P_.js +15 -0
  39. package/dist/env-auth-ZPNhil6w.js +63 -0
  40. package/dist/env-vars-Ch51id3Y.js +63 -0
  41. package/dist/errors-D8exgH7Z.js +17 -0
  42. package/dist/exec-approval-resolver-NR6hHp1P.js +15 -0
  43. package/dist/helper-api.js +4 -0
  44. package/dist/http-client-CLvnNzJZ.js +331 -0
  45. package/dist/index.js +46 -0
  46. package/dist/legacy-crypto-inspector-BXa-K6Qb.js +41 -0
  47. package/dist/legacy-crypto-restore-DmSdbVyW.js +85 -0
  48. package/dist/logging-BWx5aV5G.js +99 -0
  49. package/dist/matrix-migration.runtime-C5EAzuSF.js +525 -0
  50. package/dist/media-text-H2gCWr7p.js +146 -0
  51. package/dist/messages-BM8v2OhM.js +140 -0
  52. package/dist/migration-snapshot-backup-B4qRjmn2.js +69 -0
  53. package/dist/migration-snapshot.runtime-CEaEL8JK.js +2 -0
  54. package/dist/monitor-9_MYVUk0.js +4331 -0
  55. package/dist/plugin-entry.handlers.runtime.js +51 -0
  56. package/dist/probe.runtime-ARO_q_Zl.js +3 -0
  57. package/dist/profile-update-DgBXphvR.js +68 -0
  58. package/dist/reaction-common-Bx8mZPc9.js +71 -0
  59. package/dist/reaction-events-B2GhGktu.js +121 -0
  60. package/{src/record-shared.ts → dist/record-shared-D-PbvaZ7.js} +1 -2
  61. package/dist/resolve-targets-CFr6_x9K.js +140 -0
  62. package/dist/resolver.runtime-fPzzTZVJ.js +5 -0
  63. package/dist/rolldown-runtime-DUslC3ob.js +14 -0
  64. package/dist/route-m49kMiHx.js +161 -0
  65. package/dist/runtime-BfjP-NST.js +8 -0
  66. package/dist/runtime-api-D7plmCoC.js +24 -0
  67. package/dist/runtime-api.js +25 -0
  68. package/dist/runtime-heavy-api.js +3 -0
  69. package/dist/runtime-lwTSy9Yt.js +6 -0
  70. package/dist/runtime-setter-api.js +2 -0
  71. package/dist/sdk-CK0ON6Js.js +1704 -0
  72. package/dist/secret-contract-BKkC-9fa.js +120 -0
  73. package/dist/secret-contract-api.js +2 -0
  74. package/dist/send-CWOxcUMq.js +1517 -0
  75. package/dist/setup-bootstrap-VShXhiBJ.js +62 -0
  76. package/dist/setup-core-CmXNGvQt.js +677 -0
  77. package/dist/setup-entry.js +19 -0
  78. package/dist/setup-plugin-api.js +43 -0
  79. package/dist/setup-surface-zTLHNBns.js +537 -0
  80. package/dist/shared-BrKJkpx_.js +642 -0
  81. package/dist/startup-abort-D79WSeUh.js +109 -0
  82. package/dist/startup-verification-Dj34oWgb.js +132 -0
  83. package/dist/storage-DxbroIe0.js +281 -0
  84. package/dist/storage-paths-BcLg30GH.js +52 -0
  85. package/dist/subagent-hooks-api-CjHBfEoY.js +170 -0
  86. package/dist/subagent-hooks-api.js +2 -0
  87. package/dist/sync-state-Bx0gPaGA.js +12 -0
  88. package/dist/target-ids-iZwjCUZa.js +77 -0
  89. package/dist/test-api.js +4 -0
  90. package/dist/thread-binding-api-BWT96Ttd.js +17 -0
  91. package/dist/thread-binding-api.js +2 -0
  92. package/dist/thread-bindings-owbheXoV.js +352 -0
  93. package/dist/thread-bindings-runtime.js +2 -0
  94. package/dist/thread-bindings-shared-4nkBBftw.js +97 -0
  95. package/dist/timeout-abort-signal-CPD0PPNy.js +2 -0
  96. package/dist/tool-actions.runtime-DDh2EP6z.js +532 -0
  97. package/dist/url-validation-fQvf_pW_.js +36 -0
  98. package/dist/verification-BhMWyuAf.js +345 -0
  99. package/package.json +16 -4
  100. package/CHANGELOG.md +0 -285
  101. package/SPEC-SUPPORT.md +0 -116
  102. package/api.ts +0 -38
  103. package/auth-presence.ts +0 -56
  104. package/channel-plugin-api.ts +0 -3
  105. package/cli-metadata.ts +0 -11
  106. package/contract-api.ts +0 -17
  107. package/doctor-contract-api.ts +0 -1
  108. package/helper-api.ts +0 -3
  109. package/index.ts +0 -55
  110. package/plugin-entry.handlers.runtime.ts +0 -1
  111. package/runtime-api.ts +0 -72
  112. package/runtime-heavy-api.ts +0 -1
  113. package/runtime-setter-api.ts +0 -3
  114. package/secret-contract-api.ts +0 -5
  115. package/setup-entry.ts +0 -17
  116. package/setup-plugin-api.ts +0 -3
  117. package/src/account-selection.ts +0 -223
  118. package/src/actions.ts +0 -346
  119. package/src/approval-auth.ts +0 -25
  120. package/src/approval-handler.runtime.ts +0 -595
  121. package/src/approval-ids.ts +0 -6
  122. package/src/approval-native.ts +0 -348
  123. package/src/approval-reaction-auth.ts +0 -45
  124. package/src/approval-reactions.ts +0 -313
  125. package/src/auth-precedence.ts +0 -61
  126. package/src/channel-account-paths.ts +0 -97
  127. package/src/channel.runtime.ts +0 -17
  128. package/src/channel.setup.ts +0 -48
  129. package/src/channel.ts +0 -667
  130. package/src/cli-metadata.ts +0 -19
  131. package/src/cli.ts +0 -2298
  132. package/src/config-adapter.ts +0 -41
  133. package/src/config-schema.ts +0 -159
  134. package/src/config-ui-hints.ts +0 -56
  135. package/src/directory-live.ts +0 -238
  136. package/src/doctor-contract.ts +0 -287
  137. package/src/doctor.ts +0 -262
  138. package/src/env-vars.ts +0 -92
  139. package/src/exec-approval-resolver.ts +0 -23
  140. package/src/exec-approvals.ts +0 -293
  141. package/src/group-mentions.ts +0 -41
  142. package/src/legacy-crypto-inspector-availability.ts +0 -60
  143. package/src/legacy-crypto.ts +0 -531
  144. package/src/legacy-state.ts +0 -156
  145. package/src/matrix/account-config.ts +0 -175
  146. package/src/matrix/accounts.ts +0 -194
  147. package/src/matrix/actions/client.ts +0 -31
  148. package/src/matrix/actions/devices.ts +0 -34
  149. package/src/matrix/actions/limits.ts +0 -6
  150. package/src/matrix/actions/messages.ts +0 -129
  151. package/src/matrix/actions/pins.ts +0 -63
  152. package/src/matrix/actions/polls.ts +0 -109
  153. package/src/matrix/actions/profile.ts +0 -37
  154. package/src/matrix/actions/reactions.ts +0 -59
  155. package/src/matrix/actions/room.ts +0 -71
  156. package/src/matrix/actions/summary.ts +0 -88
  157. package/src/matrix/actions/types.ts +0 -63
  158. package/src/matrix/actions/verification.ts +0 -589
  159. package/src/matrix/actions.ts +0 -37
  160. package/src/matrix/active-client.ts +0 -26
  161. package/src/matrix/async-lock.ts +0 -18
  162. package/src/matrix/backup-health.ts +0 -124
  163. package/src/matrix/client/config-runtime-api.ts +0 -9
  164. package/src/matrix/client/config-secret-input.runtime.ts +0 -1
  165. package/src/matrix/client/config.ts +0 -853
  166. package/src/matrix/client/create-client.ts +0 -105
  167. package/src/matrix/client/env-auth.ts +0 -95
  168. package/src/matrix/client/file-sync-store.ts +0 -289
  169. package/src/matrix/client/logging.ts +0 -140
  170. package/src/matrix/client/migration-snapshot.runtime.ts +0 -1
  171. package/src/matrix/client/private-network-host.ts +0 -1
  172. package/src/matrix/client/runtime.ts +0 -4
  173. package/src/matrix/client/shared.ts +0 -316
  174. package/src/matrix/client/storage.ts +0 -543
  175. package/src/matrix/client/types.ts +0 -50
  176. package/src/matrix/client/url-validation.ts +0 -76
  177. package/src/matrix/client-bootstrap.ts +0 -173
  178. package/src/matrix/client.ts +0 -23
  179. package/src/matrix/config-paths.ts +0 -31
  180. package/src/matrix/config-update.ts +0 -292
  181. package/src/matrix/credentials-read.ts +0 -207
  182. package/src/matrix/credentials-write.runtime.ts +0 -35
  183. package/src/matrix/credentials.ts +0 -95
  184. package/src/matrix/deps.ts +0 -309
  185. package/src/matrix/device-health.ts +0 -31
  186. package/src/matrix/direct-management.ts +0 -349
  187. package/src/matrix/direct-room.ts +0 -128
  188. package/src/matrix/draft-stream.ts +0 -225
  189. package/src/matrix/encryption-guidance.ts +0 -24
  190. package/src/matrix/errors.ts +0 -21
  191. package/src/matrix/format.ts +0 -426
  192. package/src/matrix/legacy-crypto-inspector.ts +0 -95
  193. package/src/matrix/media-errors.ts +0 -20
  194. package/src/matrix/media-text.ts +0 -162
  195. package/src/matrix/monitor/access-state.ts +0 -145
  196. package/src/matrix/monitor/ack-config.ts +0 -27
  197. package/src/matrix/monitor/allowlist.ts +0 -92
  198. package/src/matrix/monitor/auto-join.ts +0 -86
  199. package/src/matrix/monitor/config.ts +0 -569
  200. package/src/matrix/monitor/context-summary.ts +0 -43
  201. package/src/matrix/monitor/direct.ts +0 -296
  202. package/src/matrix/monitor/events.ts +0 -397
  203. package/src/matrix/monitor/handler.ts +0 -2271
  204. package/src/matrix/monitor/inbound-dedupe.ts +0 -267
  205. package/src/matrix/monitor/index.ts +0 -540
  206. package/src/matrix/monitor/legacy-crypto-restore.ts +0 -139
  207. package/src/matrix/monitor/location.ts +0 -108
  208. package/src/matrix/monitor/media.ts +0 -119
  209. package/src/matrix/monitor/mentions.ts +0 -256
  210. package/src/matrix/monitor/reaction-events.ts +0 -197
  211. package/src/matrix/monitor/recent-invite.ts +0 -30
  212. package/src/matrix/monitor/replies.ts +0 -136
  213. package/src/matrix/monitor/reply-context.ts +0 -92
  214. package/src/matrix/monitor/room-history.ts +0 -301
  215. package/src/matrix/monitor/room-info.ts +0 -126
  216. package/src/matrix/monitor/rooms.ts +0 -52
  217. package/src/matrix/monitor/route.ts +0 -179
  218. package/src/matrix/monitor/runtime-api.ts +0 -28
  219. package/src/matrix/monitor/startup-verification.ts +0 -237
  220. package/src/matrix/monitor/startup.ts +0 -218
  221. package/src/matrix/monitor/status.ts +0 -120
  222. package/src/matrix/monitor/sync-lifecycle.ts +0 -91
  223. package/src/matrix/monitor/task-runner.ts +0 -38
  224. package/src/matrix/monitor/test-events.ts +0 -21
  225. package/src/matrix/monitor/thread-context.ts +0 -108
  226. package/src/matrix/monitor/threads.ts +0 -85
  227. package/src/matrix/monitor/types.ts +0 -30
  228. package/src/matrix/monitor/verification-events.ts +0 -643
  229. package/src/matrix/monitor/verification-utils.ts +0 -46
  230. package/src/matrix/outbound-media-runtime.ts +0 -1
  231. package/src/matrix/poll-summary.ts +0 -110
  232. package/src/matrix/poll-types.ts +0 -429
  233. package/src/matrix/probe.runtime.ts +0 -4
  234. package/src/matrix/probe.ts +0 -97
  235. package/src/matrix/profile.ts +0 -184
  236. package/src/matrix/reaction-common.ts +0 -147
  237. package/src/matrix/sdk/crypto-bootstrap.ts +0 -438
  238. package/src/matrix/sdk/crypto-facade.ts +0 -242
  239. package/src/matrix/sdk/crypto-node.runtime.ts +0 -17
  240. package/src/matrix/sdk/crypto-runtime.ts +0 -14
  241. package/src/matrix/sdk/decrypt-bridge.ts +0 -410
  242. package/src/matrix/sdk/event-helpers.ts +0 -83
  243. package/src/matrix/sdk/http-client.ts +0 -87
  244. package/src/matrix/sdk/idb-persistence-lock.ts +0 -51
  245. package/src/matrix/sdk/idb-persistence.ts +0 -286
  246. package/src/matrix/sdk/logger.ts +0 -108
  247. package/src/matrix/sdk/read-response-with-limit.ts +0 -19
  248. package/src/matrix/sdk/recovery-key-store.ts +0 -453
  249. package/src/matrix/sdk/timeout-abort-signal.ts +0 -1
  250. package/src/matrix/sdk/transport-runtime-api.ts +0 -18
  251. package/src/matrix/sdk/transport.ts +0 -352
  252. package/src/matrix/sdk/types.ts +0 -245
  253. package/src/matrix/sdk/verification-manager.ts +0 -795
  254. package/src/matrix/sdk/verification-status.ts +0 -23
  255. package/src/matrix/sdk.ts +0 -2152
  256. package/src/matrix/send/client.ts +0 -93
  257. package/src/matrix/send/formatting.ts +0 -189
  258. package/src/matrix/send/media.ts +0 -244
  259. package/src/matrix/send/targets.ts +0 -104
  260. package/src/matrix/send/types.ts +0 -131
  261. package/src/matrix/send.ts +0 -660
  262. package/src/matrix/session-store-metadata.ts +0 -108
  263. package/src/matrix/startup-abort.ts +0 -44
  264. package/src/matrix/subagent-hooks.ts +0 -308
  265. package/src/matrix/sync-state.ts +0 -27
  266. package/src/matrix/target-ids.ts +0 -79
  267. package/src/matrix/thread-bindings-shared.ts +0 -206
  268. package/src/matrix/thread-bindings.ts +0 -580
  269. package/src/matrix-migration.runtime.ts +0 -9
  270. package/src/migration-config.ts +0 -243
  271. package/src/migration-snapshot-backup.ts +0 -116
  272. package/src/migration-snapshot.ts +0 -53
  273. package/src/onboarding.ts +0 -775
  274. package/src/outbound.ts +0 -248
  275. package/src/plugin-entry.runtime.js +0 -115
  276. package/src/plugin-entry.runtime.ts +0 -70
  277. package/src/profile-update.ts +0 -71
  278. package/src/resolve-targets.ts +0 -175
  279. package/src/resolver.runtime.ts +0 -5
  280. package/src/resolver.ts +0 -21
  281. package/src/runtime-api.ts +0 -106
  282. package/src/runtime.ts +0 -13
  283. package/src/secret-contract.ts +0 -174
  284. package/src/session-route.ts +0 -126
  285. package/src/setup-bootstrap.ts +0 -102
  286. package/src/setup-config.ts +0 -222
  287. package/src/setup-contract.ts +0 -90
  288. package/src/setup-core.ts +0 -146
  289. package/src/setup-dm-policy.ts +0 -15
  290. package/src/setup-surface.ts +0 -4
  291. package/src/startup-maintenance.ts +0 -114
  292. package/src/storage-paths.ts +0 -92
  293. package/src/thread-binding-api.ts +0 -23
  294. package/src/tool-actions.runtime.ts +0 -1
  295. package/src/tool-actions.ts +0 -498
  296. package/src/types.ts +0 -257
  297. package/subagent-hooks-api.ts +0 -31
  298. package/test-api.ts +0 -21
  299. package/thread-binding-api.ts +0 -4
  300. package/thread-bindings-runtime.ts +0 -4
  301. package/tsconfig.json +0 -16
@@ -0,0 +1,162 @@
1
+ import { n as getOptionalMatrixRuntime } from "./runtime-BfjP-NST.js";
2
+ //#region extensions/matrix/src/approval-reactions.ts
3
+ const MATRIX_APPROVAL_REACTION_META = {
4
+ "allow-once": {
5
+ emoji: "✅",
6
+ label: "Allow once"
7
+ },
8
+ "allow-always": {
9
+ emoji: "♾️",
10
+ label: "Allow always"
11
+ },
12
+ deny: {
13
+ emoji: "❌",
14
+ label: "Deny"
15
+ }
16
+ };
17
+ const MATRIX_APPROVAL_REACTION_ORDER = [
18
+ "allow-once",
19
+ "allow-always",
20
+ "deny"
21
+ ];
22
+ const PERSISTENT_NAMESPACE = "matrix.approval-reactions";
23
+ const PERSISTENT_MAX_ENTRIES = 1e3;
24
+ const DEFAULT_REACTION_TARGET_TTL_MS = 1440 * 60 * 1e3;
25
+ const matrixApprovalReactionTargets = /* @__PURE__ */ new Map();
26
+ let persistentStore;
27
+ let persistentStoreDisabled = false;
28
+ function buildReactionTargetKey(roomId, eventId) {
29
+ const normalizedRoomId = roomId.trim();
30
+ const normalizedEventId = eventId.trim();
31
+ if (!normalizedRoomId || !normalizedEventId) return null;
32
+ return `${normalizedRoomId}:${normalizedEventId}`;
33
+ }
34
+ function reportPersistentApprovalReactionError(error) {
35
+ try {
36
+ getOptionalMatrixRuntime()?.logging.getChildLogger({
37
+ plugin: "matrix",
38
+ feature: "approval-reaction-state"
39
+ }).warn("Matrix persistent approval reaction state failed", { error: String(error) });
40
+ } catch {}
41
+ }
42
+ function disablePersistentApprovalReactionStore(error) {
43
+ persistentStoreDisabled = true;
44
+ persistentStore = void 0;
45
+ reportPersistentApprovalReactionError(error);
46
+ }
47
+ function getPersistentApprovalReactionStore() {
48
+ if (persistentStoreDisabled) return;
49
+ if (persistentStore) return persistentStore;
50
+ const runtime = getOptionalMatrixRuntime();
51
+ if (!runtime) return;
52
+ try {
53
+ persistentStore = runtime.state.openKeyedStore({
54
+ namespace: PERSISTENT_NAMESPACE,
55
+ maxEntries: PERSISTENT_MAX_ENTRIES,
56
+ defaultTtlMs: DEFAULT_REACTION_TARGET_TTL_MS
57
+ });
58
+ return persistentStore;
59
+ } catch (error) {
60
+ disablePersistentApprovalReactionStore(error);
61
+ return;
62
+ }
63
+ }
64
+ function readPersistedTarget(value) {
65
+ const persisted = value;
66
+ if (persisted?.version !== 1 || !persisted.target || typeof persisted.target.approvalId !== "string" || !Array.isArray(persisted.target.allowedDecisions)) return null;
67
+ return persisted.target;
68
+ }
69
+ function rememberPersistentApprovalReactionTarget(params) {
70
+ const ttlMs = params.ttlMs == null ? DEFAULT_REACTION_TARGET_TTL_MS : Math.max(1, params.ttlMs);
71
+ const store = getPersistentApprovalReactionStore();
72
+ if (!store) return;
73
+ store.register(params.key, {
74
+ version: 1,
75
+ target: params.target
76
+ }, { ttlMs }).catch(disablePersistentApprovalReactionStore);
77
+ }
78
+ function forgetPersistentApprovalReactionTarget(key) {
79
+ const store = getPersistentApprovalReactionStore();
80
+ if (!store) return;
81
+ store.delete(key).catch(disablePersistentApprovalReactionStore);
82
+ }
83
+ async function lookupPersistentApprovalReactionTarget(key) {
84
+ const store = getPersistentApprovalReactionStore();
85
+ if (!store) return null;
86
+ try {
87
+ return readPersistedTarget(await store.lookup(key));
88
+ } catch (error) {
89
+ disablePersistentApprovalReactionStore(error);
90
+ return null;
91
+ }
92
+ }
93
+ function listMatrixApprovalReactionBindings(allowedDecisions) {
94
+ const allowed = new Set(allowedDecisions);
95
+ return MATRIX_APPROVAL_REACTION_ORDER.filter((decision) => allowed.has(decision)).map((decision) => ({
96
+ decision,
97
+ emoji: MATRIX_APPROVAL_REACTION_META[decision].emoji,
98
+ label: MATRIX_APPROVAL_REACTION_META[decision].label
99
+ }));
100
+ }
101
+ function buildMatrixApprovalReactionHint(allowedDecisions) {
102
+ const bindings = listMatrixApprovalReactionBindings(allowedDecisions);
103
+ if (bindings.length === 0) return null;
104
+ return `React here: ${bindings.map((binding) => `${binding.emoji} ${binding.label}`).join(", ")}`;
105
+ }
106
+ function resolveMatrixApprovalReactionDecision(reactionKey, allowedDecisions) {
107
+ const normalizedReaction = reactionKey.trim();
108
+ if (!normalizedReaction) return null;
109
+ const allowed = new Set(allowedDecisions);
110
+ for (const decision of MATRIX_APPROVAL_REACTION_ORDER) {
111
+ if (!allowed.has(decision)) continue;
112
+ if (MATRIX_APPROVAL_REACTION_META[decision].emoji === normalizedReaction) return decision;
113
+ }
114
+ return null;
115
+ }
116
+ function registerMatrixApprovalReactionTarget(params) {
117
+ const key = buildReactionTargetKey(params.roomId, params.eventId);
118
+ const approvalId = params.approvalId.trim();
119
+ const allowedDecisions = Array.from(new Set(params.allowedDecisions.filter((decision) => decision === "allow-once" || decision === "allow-always" || decision === "deny")));
120
+ if (!key || !approvalId || allowedDecisions.length === 0) return;
121
+ const target = {
122
+ approvalId,
123
+ allowedDecisions
124
+ };
125
+ matrixApprovalReactionTargets.set(key, target);
126
+ rememberPersistentApprovalReactionTarget({
127
+ key,
128
+ target,
129
+ ttlMs: params.ttlMs
130
+ });
131
+ }
132
+ function unregisterMatrixApprovalReactionTarget(params) {
133
+ const key = buildReactionTargetKey(params.roomId, params.eventId);
134
+ if (!key) return;
135
+ matrixApprovalReactionTargets.delete(key);
136
+ forgetPersistentApprovalReactionTarget(key);
137
+ }
138
+ function resolveTarget(params) {
139
+ const target = params.target;
140
+ if (!target) return null;
141
+ const decision = resolveMatrixApprovalReactionDecision(params.reactionKey, target.allowedDecisions);
142
+ if (!decision) return null;
143
+ return {
144
+ approvalId: target.approvalId,
145
+ decision
146
+ };
147
+ }
148
+ async function resolveMatrixApprovalReactionTargetWithPersistence(params) {
149
+ const key = buildReactionTargetKey(params.roomId, params.eventId);
150
+ if (!key) return null;
151
+ const inMemory = resolveTarget({
152
+ target: matrixApprovalReactionTargets.get(key),
153
+ reactionKey: params.reactionKey
154
+ });
155
+ if (inMemory) return inMemory;
156
+ return resolveTarget({
157
+ target: await lookupPersistentApprovalReactionTarget(key),
158
+ reactionKey: params.reactionKey
159
+ });
160
+ }
161
+ //#endregion
162
+ export { unregisterMatrixApprovalReactionTarget as a, resolveMatrixApprovalReactionTargetWithPersistence as i, listMatrixApprovalReactionBindings as n, registerMatrixApprovalReactionTarget as r, buildMatrixApprovalReactionHint as t };
@@ -0,0 +1,19 @@
1
+ //#region extensions/matrix/src/matrix/async-lock.ts
2
+ function createAsyncLock() {
3
+ let lock = Promise.resolve();
4
+ return async function withLock(fn) {
5
+ const previous = lock;
6
+ let release;
7
+ lock = new Promise((resolve) => {
8
+ release = resolve;
9
+ });
10
+ await previous;
11
+ try {
12
+ return await fn();
13
+ } finally {
14
+ release?.();
15
+ }
16
+ };
17
+ }
18
+ //#endregion
19
+ export { createAsyncLock as t };
@@ -0,0 +1,26 @@
1
+ import { i as resolveMatrixCredentialsFilename, r as resolveMatrixCredentialsDir } from "./storage-paths-BcLg30GH.js";
2
+ import fs from "node:fs";
3
+ import os from "node:os";
4
+ import path from "node:path";
5
+ import { resolveStateDir } from "autobot/plugin-sdk/state-paths";
6
+ //#region extensions/matrix/auth-presence.ts
7
+ function listMatrixCredentialPaths(_cfg, env = process.env) {
8
+ const credentialsDir = resolveMatrixCredentialsDir(resolveStateDir(env, os.homedir));
9
+ const paths = new Set([resolveMatrixCredentialsFilename(), resolveMatrixCredentialsFilename("default")]);
10
+ try {
11
+ const entries = fs.readdirSync(credentialsDir, { withFileTypes: true });
12
+ for (const entry of entries) if (entry.isFile() && /^credentials(?:-[a-z0-9._-]+)?\.json$/i.test(entry.name)) paths.add(entry.name);
13
+ } catch {}
14
+ return [...paths].map((filename) => path.join(credentialsDir, filename));
15
+ }
16
+ function hasAnyMatrixAuth(params, env = process.env) {
17
+ return listMatrixCredentialPaths(params && typeof params === "object" && "cfg" in params ? params.cfg : params, params && typeof params === "object" && "cfg" in params ? params.env ?? env : env).some((filePath) => {
18
+ try {
19
+ return fs.existsSync(filePath);
20
+ } catch {
21
+ return false;
22
+ }
23
+ });
24
+ }
25
+ //#endregion
26
+ export { hasAnyMatrixAuth };
@@ -0,0 +1,60 @@
1
+ //#region extensions/matrix/src/matrix/backup-health.ts
2
+ function resolveMatrixRoomKeyBackupIssue(backup) {
3
+ if (!backup.serverVersion) return {
4
+ code: "missing-server-backup",
5
+ summary: "missing on server",
6
+ message: "no room-key backup exists on the homeserver"
7
+ };
8
+ if (backup.decryptionKeyCached === false) {
9
+ if (backup.keyLoadError) return {
10
+ code: "key-load-failed",
11
+ summary: "present but backup key unavailable on this device",
12
+ message: `backup decryption key could not be loaded from secret storage (${backup.keyLoadError})`
13
+ };
14
+ if (backup.keyLoadAttempted) return {
15
+ code: "key-not-loaded",
16
+ summary: "present but backup key unavailable on this device",
17
+ message: "backup decryption key is not loaded on this device (secret storage did not return a key)"
18
+ };
19
+ return {
20
+ code: "key-not-loaded",
21
+ summary: "present but backup key unavailable on this device",
22
+ message: "backup decryption key is not loaded on this device"
23
+ };
24
+ }
25
+ if (backup.matchesDecryptionKey === false) return {
26
+ code: "key-mismatch",
27
+ summary: "present but backup key mismatch on this device",
28
+ message: "backup key mismatch (this device does not have the matching backup decryption key)"
29
+ };
30
+ if (backup.trusted === false) return {
31
+ code: "untrusted-signature",
32
+ summary: "present but not trusted on this device",
33
+ message: "backup signature chain is not trusted by this device"
34
+ };
35
+ if (!backup.activeVersion) return {
36
+ code: "inactive",
37
+ summary: "present on server but inactive on this device",
38
+ message: "backup exists but is not active on this device"
39
+ };
40
+ if (backup.trusted === null || backup.matchesDecryptionKey === null || backup.decryptionKeyCached === null) return {
41
+ code: "indeterminate",
42
+ summary: "present but trust state unknown",
43
+ message: "backup trust state could not be fully determined"
44
+ };
45
+ return {
46
+ code: "ok",
47
+ summary: "active and trusted on this device",
48
+ message: null
49
+ };
50
+ }
51
+ function resolveMatrixRoomKeyBackupReadinessError(backup, opts) {
52
+ const issue = resolveMatrixRoomKeyBackupIssue(backup);
53
+ if (issue.code === "missing-server-backup") return opts.requireServerBackup ? "Matrix room key backup is missing on the homeserver." : null;
54
+ if (issue.code === "ok") return null;
55
+ if (issue.code === "untrusted-signature" && opts.allowUntrustedMatchingKey === true && backup.matchesDecryptionKey === true && backup.decryptionKeyCached === true) return null;
56
+ if (issue.message) return `Matrix room key backup is not usable: ${issue.message}.`;
57
+ return "Matrix room key backup is not usable on this device.";
58
+ }
59
+ //#endregion
60
+ export { resolveMatrixRoomKeyBackupReadinessError as n, resolveMatrixRoomKeyBackupIssue as t };