@openclaw/matrix 2026.8.1 → 2026.8.33
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/dist/{account-selection-C8nnBTxi.js → .setup/account-selection-DZMazUgX.mjs} +12 -10
- package/dist/{accounts-fC57n-Jo.js → .setup/accounts-BJ6ECCac.mjs} +3 -3
- package/dist/{approval-handler.runtime-BBjFZw1t.js → .setup/approval-handler.runtime-CdT1wQve.mjs} +6 -6
- package/dist/{approval-ids-DTIdXV-m.js → .setup/approval-ids-CU_nMQy9.mjs} +1 -1
- package/dist/{approval-reaction-auth-BDONXxnF.js → .setup/approval-reaction-auth-CpxhvOOT.mjs} +2 -2
- package/dist/{approval-reactions-tXh9KYrW.js → .setup/approval-reactions-D5eegob9.mjs} +2 -2
- package/dist/{channel-BkEcVUs_.js → .setup/channel-Q_N83Wwa.mjs} +57 -59
- package/dist/{channel.runtime-CTLSBFsP.js → .setup/channel.runtime-BFXlZFP1.mjs} +17 -13
- package/dist/{channel.setup-CSacbORr.js → .setup/channel.setup-2A6HBRbA.mjs} +22 -20
- package/dist/{cli-DRVtgrq5.js → .setup/cli-CyuDGiIr.mjs} +43 -34
- package/dist/{cli-metadata-Ddx_y4Os.js → .setup/cli-metadata-B_y2Z5Np.mjs} +1 -1
- package/dist/{client-CZ_JvrO0.js → .setup/client-CpHMD-C2.mjs} +3 -3
- package/dist/{client-kSi51NKp.js → .setup/client-DvcYcTSy.mjs} +76 -23
- package/dist/{client-bootstrap-D8irSL2i.js → .setup/client-bootstrap-Cb1tHsT4.mjs} +3 -3
- package/dist/{client-support-DLj4vDeu.js → .setup/client-support-Bn9Bk0-H.mjs} +1 -1
- package/dist/{config-update-DC0fWBxc.js → .setup/config-update-B_4qZ5bV.mjs} +49 -31
- package/dist/{credentials-BdAaWuiR.js → .setup/credentials-B2roKThT.mjs} +6 -10
- package/dist/{credentials-read-B37cQknZ.js → .setup/credentials-read-DaemdXHy.mjs} +11 -9
- package/dist/{credentials-write.runtime-nAV2-5uR.js → .setup/credentials-write.runtime-D83HEGcL.mjs} +1 -1
- package/dist/{crypto-runtime-C4WDYxlP.js → .setup/crypto-runtime-Ch4WOG1y.mjs} +8 -8
- package/dist/{deps-CcVJfvRM.js → .setup/deps-mtxF2mHI.mjs} +1 -1
- package/dist/{device-health-B4-YXtJR.js → .setup/device-health-CWOuIirq.mjs} +1 -1
- package/dist/{direct-room-RinHjtqX.js → .setup/direct-room-CKyU8upP.mjs} +1 -1
- package/dist/{directory-live-DKr0w35b.js → .setup/directory-live-DggLE-28.mjs} +10 -8
- package/dist/{doctor-EWf9CDso.js → .setup/doctor-BLCvdOFo.mjs} +1 -1
- package/dist/{doctor-contract-DEt4O4Zt.js → .setup/doctor-contract-HyWFZQVG.mjs} +5 -4
- package/dist/{draft-stream-0CEpNrBk.js → .setup/draft-stream-DfUFwKfN.mjs} +1 -1
- package/dist/{encryption-guidance-D4ZdAqzM.js → .setup/encryption-guidance-CvN_NQUJ.mjs} +4 -3
- package/dist/{http-client-D8o8b9u6.js → .setup/http-client-Bv6a2OfI.mjs} +11 -8
- package/dist/{idb-persistence-DfgW720p.js → .setup/idb-persistence-BiscLSq4.mjs} +3 -3
- package/dist/{idb-persistence-lock-DAJ49nZX.js → .setup/idb-persistence-lock-B3fZXyF_.mjs} +1 -1
- package/dist/{inbound-dedupe-RvSLqdsz.js → .setup/inbound-dedupe-BOsuMiaj.mjs} +2 -2
- package/dist/{logger-B_71hN6W.js → .setup/logger-B3tfcB-m.mjs} +1 -1
- package/dist/{logging-DRjvUOIh.js → .setup/logging-CkohOZwO.mjs} +2 -2
- package/dist/{messages-DaGRt-tu.js → .setup/messages-C3v-jkaN.mjs} +4 -4
- package/dist/{monitor-CLPbPcR9.js → .setup/monitor-CQ6pGvZh.mjs} +56 -81
- package/dist/.setup/probe.runtime-ni46ImsO.mjs +2 -0
- package/dist/{profile-D-Wubo0A.js → .setup/profile-ClrB3IgR.mjs} +2 -2
- package/dist/{profile-update-zXVCMg7y.js → .setup/profile-update-B9Q6Ox2O.mjs} +6 -5
- package/dist/{reaction-events-CjVUiqcY.js → .setup/reaction-events-Dtd3W-rj.mjs} +10 -8
- package/dist/{resolve-targets-qG6gceps.js → .setup/resolve-targets-Bke5jHKS.mjs} +3 -3
- package/dist/{resolver.runtime-zX3TR3TN.js → .setup/resolver.runtime-BtrbC025.mjs} +1 -1
- package/dist/{room-info-yheP1mod.js → .setup/room-info-B0VNxsF8.mjs} +4 -4
- package/dist/.setup/runtime-setter-api-DGMubGUq.mjs +3 -0
- package/dist/{sdk-TZYyo0XQ.js → .setup/sdk-DoObvds0.mjs} +528 -30
- package/dist/{secret-contract-CufozuyJ.js → .setup/secret-contract-JlB6VmI3.mjs} +1 -1
- package/dist/.setup/secret-contract-api-B-iJoQEv.mjs +3 -0
- package/dist/{send-BL_iH5Ox.js → .setup/send-SmBzUhD-.mjs} +19 -15
- package/dist/{setup-bootstrap-D8M7FmcO.js → .setup/setup-bootstrap-CUKhebeX.mjs} +3 -3
- package/dist/{setup-core-r6L0nno-.js → .setup/setup-core-BnqoLunq.mjs} +9 -8
- package/dist/.setup/setup-plugin-api-Dg95tydH.mjs +3 -0
- package/dist/{setup-surface-g174ElFO.js → .setup/setup-surface-sWwADrZ8.mjs} +87 -81
- package/dist/{startup-verification-Cs08ca8u.js → .setup/startup-verification-E46yu4fh.mjs} +3 -3
- package/dist/{storage-BsGuHngK.js → .setup/storage-B-nf2ReN.mjs} +7 -6
- package/dist/{subagent-hooks-CMoZaARG.js → .setup/subagent-hooks-jFgft_Mr.mjs} +6 -2
- package/dist/.setup/sync-cache-state-6Hjn1K-v.mjs +234 -0
- package/dist/{thread-binding-api-CzkeLZCU.js → .setup/thread-binding-api-DRMC62cs.mjs} +1 -1
- package/dist/{thread-bindings-ERWNousC.js → .setup/thread-bindings-_WJ8RYWJ.mjs} +4 -4
- package/dist/{tool-actions.runtime-DcBCSwY4.js → .setup/tool-actions.runtime-DLICojA3.mjs} +230 -168
- package/dist/{verification-4vsW_WSn.js → .setup/verification-DOT16noD.mjs} +4 -3
- package/dist/api.js +8 -8
- package/dist/auth-presence.js +1 -1
- 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 +9 -9
- package/dist/helper-api.js +3 -3
- package/dist/index.js +1 -1
- package/dist/plugin-entry.handlers.runtime.js +1 -1
- package/dist/runtime-api.js +6 -6
- package/dist/runtime-setter-api.js +1 -1
- package/dist/secret-contract-api.js +1 -1
- package/dist/session-binding-contract-api.js +2 -2
- package/dist/setup-entry.js +4 -3
- package/dist/setup-plugin-api.js +1 -1
- 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/markdown-it/dist/browser/markdown-it.esm.min.mjs +525 -484
- package/node_modules/markdown-it/dist/browser/markdown-it.esm.min.mjs.map +1 -1
- package/node_modules/markdown-it/dist/browser/markdown-it.umd.min.js +7 -7
- package/node_modules/markdown-it/dist/browser/markdown-it.umd.min.js.map +1 -1
- package/node_modules/markdown-it/dist/markdown-it.cjs.js +129 -121
- package/node_modules/markdown-it/dist/markdown-it.cjs.js.map +1 -1
- package/node_modules/markdown-it/dist/markdown-it.d.mts +42 -71
- package/node_modules/markdown-it/dist/markdown-it.mjs +129 -121
- package/node_modules/markdown-it/dist/markdown-it.mjs.map +1 -1
- package/node_modules/markdown-it/package.json +1 -2
- package/node_modules/matrix-js-sdk/lib/client.d.ts +2 -1
- package/node_modules/matrix-js-sdk/lib/client.js +6 -2
- package/node_modules/matrix-js-sdk/lib/sync.js +8 -8
- package/node_modules/matrix-js-sdk/src/client.ts +7 -3
- package/node_modules/matrix-js-sdk/src/sync.ts +8 -8
- package/node_modules/typebox/build/format/email.mjs +1 -1
- package/node_modules/typebox/build/format/idna/idn-hostname.mjs +19 -1
- package/node_modules/typebox/package.json +1 -1
- package/package.json +6 -6
- package/dist/file-sync-store-DjskBX2o.js +0 -436
- package/dist/probe.runtime-Bxpr1FFy.js +0 -2
- package/dist/recovery-key-store-CognuDys.js +0 -276
- /package/dist/{account-config-CRsKoMqJ.js → .setup/account-config-CRsKoMqJ.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/{credentials-state-B3cuUFwZ.js → .setup/credentials-state-B3cuUFwZ.mjs} +0 -0
- /package/dist/{crypto-node.runtime-6Aj_ltHQ.js → .setup/crypto-node.runtime-6Aj_ltHQ.mjs} +0 -0
- /package/dist/{env-vars-dGqak9dN.js → .setup/env-vars-dGqak9dN.mjs} +0 -0
- /package/dist/{errors-DKVS3_DO.js → .setup/errors-DKVS3_DO.mjs} +0 -0
- /package/dist/{event-helpers-XRfAbOIh.js → .setup/event-helpers-XRfAbOIh.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/{storage-paths-gUmSydsW.js → .setup/storage-paths-gUmSydsW.mjs} +0 -0
- /package/dist/{target-ids-Nwx7cMVE.js → .setup/target-ids-Nwx7cMVE.mjs} +0 -0
- /package/dist/{thread-bindings-shared-oNPiyMWY.js → .setup/thread-bindings-shared-oNPiyMWY.mjs} +0 -0
- /package/dist/{url-validation-GRHde6lq.js → .setup/url-validation-GRHde6lq.mjs} +0 -0
|
@@ -1,26 +1,30 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import { t as
|
|
3
|
-
import
|
|
4
|
-
import { t as
|
|
5
|
-
import { n as
|
|
6
|
-
import {
|
|
7
|
-
import { n as
|
|
8
|
-
import { n as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { n as
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
|
+
import { t as getMatrixRuntime } from "./runtime-6S3DNFNv.mjs";
|
|
3
|
+
import "./reaction-common-DkrQdBSZ.mjs";
|
|
4
|
+
import { A as writeMatrixRecoveryKeyStateForPath, E as readMatrixRecoveryKeyStateForPath, S as readLegacyMatrixRecoveryKeyFile, _ as migrateLegacyMatrixRecoveryKeyFilePathToStore, t as claimCurrentTokenStorageState } from "./storage-B-nf2ReN.mjs";
|
|
5
|
+
import { i as openMatrixSyncCacheStoreOptions, l as writeMatrixSyncCacheStateToSyncStore, n as deleteMatrixSyncCacheStateFromSyncStore, o as readPersistedStoreFromSyncStore } from "./sync-cache-state-6Hjn1K-v.mjs";
|
|
6
|
+
import { t as MATRIX_IDB_PERSIST_INTERVAL_MS } from "./idb-persistence-lock-B3fZXyF_.mjs";
|
|
7
|
+
import { n as LogService, r as noop, t as ConsoleLogger } from "./logger-B3tfcB-m.mjs";
|
|
8
|
+
import { n as isMatrixNotFoundError, t as formatMatrixErrorReason } from "./errors-DKVS3_DO.mjs";
|
|
9
|
+
import { a as throwIfMatrixStartupAborted, r as createMatrixStartupAbortError } from "./client-DvcYcTSy.mjs";
|
|
10
|
+
import { n as matrixEventToRaw, r as parseMxc } from "./event-helpers-XRfAbOIh.mjs";
|
|
11
|
+
import { n as createMatrixGuardedFetch, t as MatrixAuthedHttpClient } from "./http-client-Bv6a2OfI.mjs";
|
|
12
|
+
import { n as resolveMatrixRoomKeyBackupReadinessError } from "./backup-health-Dm_YMVFT.mjs";
|
|
13
|
+
import { t as createMatrixJsSdkClientLogger } from "./logging-CkohOZwO.mjs";
|
|
14
|
+
import { a as isMatrixAccessTokenInvalidatedError, c as resolveMatrixLocalTimeoutMs, f as isMatrixReadySyncState, i as createMatrixExplicitBootstrapOptions, l as unresolvedMatrixDeviceVerificationStatus, n as MATRIX_INITIAL_CRYPTO_BOOTSTRAP_OPTIONS, o as resolveMatrixDiagnostic, p as isMatrixTerminalSyncState, r as MATRIX_STATUS_DIAGNOSTIC_TIMEOUT_MS, s as resolveMatrixDiagnosticResult, t as MATRIX_AUTOMATIC_REPAIR_BOOTSTRAP_OPTIONS, u as unresolvedMatrixRoomKeyBackupStatus } from "./client-support-Bn9Bk0-H.mjs";
|
|
13
15
|
import { createRequire } from "node:module";
|
|
14
16
|
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
15
17
|
import { normalizeNullableString, normalizeStringEntries, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
16
18
|
import { createHash } from "node:crypto";
|
|
19
|
+
import path from "node:path";
|
|
17
20
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
18
21
|
import { KeyedAsyncQueue } from "openclaw/plugin-sdk/keyed-async-queue";
|
|
19
|
-
import { ClientEvent, EventType, Filter, MatrixError, MatrixEventEvent, MsgType, Preset, createClient } from "matrix-js-sdk/lib/matrix.js";
|
|
20
22
|
import { EventEmitter } from "node:events";
|
|
23
|
+
import { ClientEvent, EventType, Filter, MatrixError, MatrixEventEvent, MemoryStore, MsgType, Preset, SyncAccumulator, createClient } from "matrix-js-sdk/lib/matrix.js";
|
|
21
24
|
import { RoomEvent } from "matrix-js-sdk/lib/models/room.js";
|
|
22
25
|
import { VerificationMethod } from "matrix-js-sdk/lib/types.js";
|
|
23
26
|
import { SyncApi, SyncState } from "matrix-js-sdk/lib/sync.js";
|
|
27
|
+
import { decodeRecoveryKey } from "matrix-js-sdk/lib/crypto-api/recovery-key.js";
|
|
24
28
|
import { EventStatus } from "matrix-js-sdk/lib/models/event-status.js";
|
|
25
29
|
//#region extensions/matrix/src/matrix/sdk/client-device-info.ts
|
|
26
30
|
async function resolveMatrixCrossSigningPublicationStatus(params) {
|
|
@@ -135,6 +139,219 @@ function refreshMatrixDmRoomIds(direct, dmRoomIds) {
|
|
|
135
139
|
return true;
|
|
136
140
|
}
|
|
137
141
|
//#endregion
|
|
142
|
+
//#region extensions/matrix/src/matrix/async-lock.ts
|
|
143
|
+
function createAsyncLock() {
|
|
144
|
+
let lock = Promise.resolve();
|
|
145
|
+
return async function withLock(fn) {
|
|
146
|
+
const previous = lock;
|
|
147
|
+
let release;
|
|
148
|
+
lock = new Promise((resolve) => {
|
|
149
|
+
release = resolve;
|
|
150
|
+
});
|
|
151
|
+
await previous;
|
|
152
|
+
try {
|
|
153
|
+
return await fn();
|
|
154
|
+
} finally {
|
|
155
|
+
release?.();
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region extensions/matrix/src/matrix/client/file-sync-store.ts
|
|
161
|
+
const PERSIST_DEBOUNCE_MS = 250;
|
|
162
|
+
function cloneJson(value) {
|
|
163
|
+
return structuredClone(value);
|
|
164
|
+
}
|
|
165
|
+
function syncDataToSyncResponse(syncData) {
|
|
166
|
+
return {
|
|
167
|
+
next_batch: syncData.nextBatch,
|
|
168
|
+
rooms: syncData.roomsData,
|
|
169
|
+
account_data: { events: syncData.accountData }
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
var SqliteBackedMatrixSyncStore = class extends MemoryStore {
|
|
173
|
+
constructor(storageRootDir) {
|
|
174
|
+
super();
|
|
175
|
+
this.storageRootDir = storageRootDir;
|
|
176
|
+
this.persistLock = createAsyncLock();
|
|
177
|
+
this.accumulator = new SyncAccumulator();
|
|
178
|
+
this.savedSync = null;
|
|
179
|
+
this.cleanShutdown = false;
|
|
180
|
+
this.dirty = false;
|
|
181
|
+
this.frozen = false;
|
|
182
|
+
this.persistTimer = null;
|
|
183
|
+
this.persistPromise = null;
|
|
184
|
+
let restoredSavedSync = null;
|
|
185
|
+
let restoredClientOptions;
|
|
186
|
+
let restoredCleanShutdown = false;
|
|
187
|
+
let syncCacheStore = createNoopMatrixSyncCacheStore();
|
|
188
|
+
let syncCacheStoreUnavailableError;
|
|
189
|
+
try {
|
|
190
|
+
syncCacheStore = openMatrixSyncCacheStore(storageRootDir);
|
|
191
|
+
const persisted = readPersistedStoreFromSyncStore(syncCacheStore);
|
|
192
|
+
if (persisted) {
|
|
193
|
+
restoredSavedSync = persisted.savedSync;
|
|
194
|
+
restoredClientOptions = persisted.clientOptions;
|
|
195
|
+
restoredCleanShutdown = persisted.cleanShutdown === true;
|
|
196
|
+
}
|
|
197
|
+
} catch (err) {
|
|
198
|
+
syncCacheStoreUnavailableError = err;
|
|
199
|
+
LogService.warn("MatrixSyncCacheStore", "Failed to load Matrix sync cache:", err);
|
|
200
|
+
}
|
|
201
|
+
this.store = syncCacheStore;
|
|
202
|
+
this.storeUnavailableError = syncCacheStoreUnavailableError;
|
|
203
|
+
this.savedSync = restoredSavedSync;
|
|
204
|
+
this.savedClientOptions = restoredClientOptions;
|
|
205
|
+
this.hadSavedSyncOnLoad = restoredSavedSync !== null;
|
|
206
|
+
this.hadCleanShutdownOnLoad = this.hadSavedSyncOnLoad && restoredCleanShutdown;
|
|
207
|
+
this.cleanShutdown = this.hadCleanShutdownOnLoad;
|
|
208
|
+
if (this.savedSync) {
|
|
209
|
+
this.accumulator.accumulate(syncDataToSyncResponse(this.savedSync), true);
|
|
210
|
+
super.setSyncToken(this.savedSync.nextBatch);
|
|
211
|
+
}
|
|
212
|
+
if (this.savedClientOptions) super.storeClientOptions(this.savedClientOptions);
|
|
213
|
+
}
|
|
214
|
+
hasSavedSync() {
|
|
215
|
+
return this.hadSavedSyncOnLoad;
|
|
216
|
+
}
|
|
217
|
+
hasSavedSyncFromCleanShutdown() {
|
|
218
|
+
return this.hadCleanShutdownOnLoad;
|
|
219
|
+
}
|
|
220
|
+
getSavedSync() {
|
|
221
|
+
return Promise.resolve(this.savedSync ? cloneJson(this.savedSync) : null);
|
|
222
|
+
}
|
|
223
|
+
getSavedSyncToken() {
|
|
224
|
+
return Promise.resolve(this.savedSync?.nextBatch ?? null);
|
|
225
|
+
}
|
|
226
|
+
setSyncData(syncData) {
|
|
227
|
+
if (this.frozen) return Promise.resolve();
|
|
228
|
+
this.accumulator.accumulate(syncData);
|
|
229
|
+
this.savedSync = this.accumulator.getJSON();
|
|
230
|
+
this.markDirtyAndSchedulePersist();
|
|
231
|
+
return Promise.resolve();
|
|
232
|
+
}
|
|
233
|
+
getClientOptions() {
|
|
234
|
+
return Promise.resolve(this.savedClientOptions ? cloneJson(this.savedClientOptions) : void 0);
|
|
235
|
+
}
|
|
236
|
+
storeClientOptions(options) {
|
|
237
|
+
if (this.frozen) return Promise.resolve();
|
|
238
|
+
this.savedClientOptions = cloneJson(options);
|
|
239
|
+
super.storeClientOptions(options);
|
|
240
|
+
this.markDirtyAndSchedulePersist();
|
|
241
|
+
return Promise.resolve();
|
|
242
|
+
}
|
|
243
|
+
save(force = false) {
|
|
244
|
+
if (force) return this.flush();
|
|
245
|
+
return Promise.resolve();
|
|
246
|
+
}
|
|
247
|
+
wantsSave() {
|
|
248
|
+
return false;
|
|
249
|
+
}
|
|
250
|
+
async deleteAllData() {
|
|
251
|
+
this.assertStoreAvailable();
|
|
252
|
+
if (this.persistTimer) {
|
|
253
|
+
clearTimeout(this.persistTimer);
|
|
254
|
+
this.persistTimer = null;
|
|
255
|
+
}
|
|
256
|
+
this.dirty = false;
|
|
257
|
+
await this.persistPromise?.catch(() => void 0);
|
|
258
|
+
await super.deleteAllData();
|
|
259
|
+
this.savedSync = null;
|
|
260
|
+
this.savedClientOptions = void 0;
|
|
261
|
+
this.cleanShutdown = false;
|
|
262
|
+
await deleteMatrixSyncCacheStateFromSyncStore({
|
|
263
|
+
storageRootDir: this.storageRootDir,
|
|
264
|
+
store: this.store
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
markCleanShutdown() {
|
|
268
|
+
this.cleanShutdown = true;
|
|
269
|
+
this.dirty = true;
|
|
270
|
+
}
|
|
271
|
+
async freezeSyncCursorPersistence() {
|
|
272
|
+
this.frozen = true;
|
|
273
|
+
if (this.persistTimer) {
|
|
274
|
+
clearTimeout(this.persistTimer);
|
|
275
|
+
this.persistTimer = null;
|
|
276
|
+
}
|
|
277
|
+
await this.persistPromise;
|
|
278
|
+
}
|
|
279
|
+
discardPendingSyncCursorPersistence() {
|
|
280
|
+
this.frozen = true;
|
|
281
|
+
if (this.persistTimer) {
|
|
282
|
+
clearTimeout(this.persistTimer);
|
|
283
|
+
this.persistTimer = null;
|
|
284
|
+
}
|
|
285
|
+
this.cleanShutdown = false;
|
|
286
|
+
this.dirty = false;
|
|
287
|
+
}
|
|
288
|
+
async flush() {
|
|
289
|
+
if (this.persistTimer) {
|
|
290
|
+
clearTimeout(this.persistTimer);
|
|
291
|
+
this.persistTimer = null;
|
|
292
|
+
}
|
|
293
|
+
while (this.dirty || this.persistPromise) {
|
|
294
|
+
if (this.dirty && !this.persistPromise) this.persistPromise = this.persist().finally(() => {
|
|
295
|
+
this.persistPromise = null;
|
|
296
|
+
});
|
|
297
|
+
await this.persistPromise;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
markDirtyAndSchedulePersist() {
|
|
301
|
+
if (this.frozen) return;
|
|
302
|
+
this.cleanShutdown = false;
|
|
303
|
+
this.dirty = true;
|
|
304
|
+
if (this.persistTimer) return;
|
|
305
|
+
this.persistTimer = setTimeout(() => {
|
|
306
|
+
this.persistTimer = null;
|
|
307
|
+
this.flush().catch((err) => {
|
|
308
|
+
LogService.warn("MatrixSyncCacheStore", "Failed to persist Matrix sync store:", err);
|
|
309
|
+
});
|
|
310
|
+
}, PERSIST_DEBOUNCE_MS);
|
|
311
|
+
this.persistTimer.unref?.();
|
|
312
|
+
}
|
|
313
|
+
async persist() {
|
|
314
|
+
this.assertStoreAvailable();
|
|
315
|
+
this.dirty = false;
|
|
316
|
+
const payload = {
|
|
317
|
+
version: 1,
|
|
318
|
+
savedSync: this.savedSync ? cloneJson(this.savedSync) : null,
|
|
319
|
+
cleanShutdown: this.cleanShutdown,
|
|
320
|
+
...this.savedClientOptions ? { clientOptions: cloneJson(this.savedClientOptions) } : {}
|
|
321
|
+
};
|
|
322
|
+
try {
|
|
323
|
+
await this.persistLock(async () => {
|
|
324
|
+
writeMatrixSyncCacheStateToSyncStore({
|
|
325
|
+
payload,
|
|
326
|
+
store: this.store
|
|
327
|
+
});
|
|
328
|
+
claimCurrentTokenStorageState({ rootDir: this.storageRootDir });
|
|
329
|
+
});
|
|
330
|
+
} catch (err) {
|
|
331
|
+
this.dirty = true;
|
|
332
|
+
throw err;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
assertStoreAvailable() {
|
|
336
|
+
if (this.storeUnavailableError == null) return;
|
|
337
|
+
throw new Error("Matrix sync cache SQLite store is unavailable; cannot persist sync state", { cause: this.storeUnavailableError });
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
function createNoopMatrixSyncCacheStore() {
|
|
341
|
+
return {
|
|
342
|
+
register: () => {},
|
|
343
|
+
registerIfAbsent: () => false,
|
|
344
|
+
lookup: () => void 0,
|
|
345
|
+
consume: () => void 0,
|
|
346
|
+
delete: () => false,
|
|
347
|
+
entries: () => [],
|
|
348
|
+
clear: () => {}
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
function openMatrixSyncCacheStore(storageRootDir) {
|
|
352
|
+
return getMatrixRuntime().state.openSyncKeyedStore(openMatrixSyncCacheStoreOptions(storageRootDir));
|
|
353
|
+
}
|
|
354
|
+
//#endregion
|
|
138
355
|
//#region extensions/matrix/src/matrix/sdk/client-sync-quiesce.ts
|
|
139
356
|
const MATRIX_SYNC_QUIESCE_TIMEOUT_MS = 5e3;
|
|
140
357
|
const MATRIX_JS_SDK_SYNC_VERSION = "42.2.0";
|
|
@@ -204,6 +421,275 @@ async function quiesceMatrixClientSync(params) {
|
|
|
204
421
|
});
|
|
205
422
|
}
|
|
206
423
|
//#endregion
|
|
424
|
+
//#region extensions/matrix/src/matrix/sdk/recovery-key-store.ts
|
|
425
|
+
function isRepairableSecretStorageAccessError(err) {
|
|
426
|
+
const message = formatMatrixErrorReason(err);
|
|
427
|
+
if (!message) return false;
|
|
428
|
+
if (message.includes("getsecretstoragekey callback returned falsey")) return true;
|
|
429
|
+
if (message.includes("decrypting secret") && message.includes("bad mac")) return true;
|
|
430
|
+
return false;
|
|
431
|
+
}
|
|
432
|
+
var MatrixRecoveryKeyStore = class {
|
|
433
|
+
constructor(recoveryKeyPath) {
|
|
434
|
+
this.secretStorageKeyCache = /* @__PURE__ */ new Map();
|
|
435
|
+
this.stagedRecoveryKey = null;
|
|
436
|
+
this.stagedRecoveryKeyUsed = false;
|
|
437
|
+
this.stagedCacheKeyIds = /* @__PURE__ */ new Set();
|
|
438
|
+
this.recoveryKeyPath = recoveryKeyPath;
|
|
439
|
+
this.storageRootDir = recoveryKeyPath ? path.dirname(recoveryKeyPath) : void 0;
|
|
440
|
+
if (this.recoveryKeyPath) try {
|
|
441
|
+
migrateLegacyMatrixRecoveryKeyFilePathToStore(this.recoveryKeyPath);
|
|
442
|
+
} catch (err) {
|
|
443
|
+
this.legacyRecoveryKeyPathOnMigrationFailure = this.recoveryKeyPath;
|
|
444
|
+
LogService.warn("MatrixClientLite", "Failed to migrate Matrix recovery key state:", err);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
buildCryptoCallbacks() {
|
|
448
|
+
return {
|
|
449
|
+
getSecretStorageKey: async ({ keys }) => {
|
|
450
|
+
const requestedKeyIds = Object.keys(keys ?? {});
|
|
451
|
+
if (requestedKeyIds.length === 0) return null;
|
|
452
|
+
const staged = this.resolveStagedSecretStorageKey(requestedKeyIds);
|
|
453
|
+
if (staged) return staged;
|
|
454
|
+
for (const keyId of requestedKeyIds) {
|
|
455
|
+
const cached = this.secretStorageKeyCache.get(keyId);
|
|
456
|
+
if (cached) return [keyId, new Uint8Array(cached.key)];
|
|
457
|
+
}
|
|
458
|
+
const stored = this.loadStoredRecoveryKey();
|
|
459
|
+
if (!stored?.privateKeyBase64) return null;
|
|
460
|
+
const privateKey = new Uint8Array(Buffer.from(stored.privateKeyBase64, "base64"));
|
|
461
|
+
if (privateKey.length === 0) return null;
|
|
462
|
+
if (stored.keyId && requestedKeyIds.includes(stored.keyId)) {
|
|
463
|
+
this.rememberSecretStorageKey(stored.keyId, privateKey, stored.keyInfo);
|
|
464
|
+
return [stored.keyId, privateKey];
|
|
465
|
+
}
|
|
466
|
+
const firstRequestedKeyId = requestedKeyIds[0];
|
|
467
|
+
if (!firstRequestedKeyId) return null;
|
|
468
|
+
this.rememberSecretStorageKey(firstRequestedKeyId, privateKey, stored.keyInfo);
|
|
469
|
+
return [firstRequestedKeyId, privateKey];
|
|
470
|
+
},
|
|
471
|
+
cacheSecretStorageKey: (keyId, keyInfo, key) => {
|
|
472
|
+
const privateKey = new Uint8Array(key);
|
|
473
|
+
const normalizedKeyInfo = {
|
|
474
|
+
passphrase: keyInfo?.passphrase,
|
|
475
|
+
name: typeof keyInfo?.name === "string" ? keyInfo.name : void 0
|
|
476
|
+
};
|
|
477
|
+
this.rememberSecretStorageKey(keyId, privateKey, normalizedKeyInfo);
|
|
478
|
+
const stored = this.loadStoredRecoveryKey();
|
|
479
|
+
this.saveRecoveryKeyToDisk({
|
|
480
|
+
keyId,
|
|
481
|
+
keyInfo: normalizedKeyInfo,
|
|
482
|
+
privateKey,
|
|
483
|
+
encodedPrivateKey: stored?.encodedPrivateKey
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
getRecoveryKeySummary() {
|
|
489
|
+
const stored = this.loadStoredRecoveryKey();
|
|
490
|
+
if (!stored) return null;
|
|
491
|
+
return {
|
|
492
|
+
encodedPrivateKey: stored.encodedPrivateKey,
|
|
493
|
+
keyId: stored.keyId,
|
|
494
|
+
createdAt: stored.createdAt
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
getSecretStorageKeyCandidate(keyId) {
|
|
498
|
+
const normalizedKeyId = keyId.trim();
|
|
499
|
+
if (!normalizedKeyId) return null;
|
|
500
|
+
const staged = this.resolveStagedSecretStorageKey([normalizedKeyId]);
|
|
501
|
+
if (staged) return staged[1];
|
|
502
|
+
const stored = this.loadStoredRecoveryKey();
|
|
503
|
+
if (!stored?.privateKeyBase64) return null;
|
|
504
|
+
const privateKey = new Uint8Array(Buffer.from(stored.privateKeyBase64, "base64"));
|
|
505
|
+
if (privateKey.length === 0) return null;
|
|
506
|
+
this.rememberSecretStorageKey(normalizedKeyId, privateKey, stored.keyInfo);
|
|
507
|
+
return privateKey;
|
|
508
|
+
}
|
|
509
|
+
resolveEncodedRecoveryKeyInput(params) {
|
|
510
|
+
const encodedPrivateKey = params.encodedPrivateKey.trim();
|
|
511
|
+
if (!encodedPrivateKey) throw new Error("Matrix recovery key is required");
|
|
512
|
+
let privateKey;
|
|
513
|
+
try {
|
|
514
|
+
privateKey = decodeRecoveryKey(encodedPrivateKey);
|
|
515
|
+
} catch (err) {
|
|
516
|
+
throw new Error(`Invalid Matrix recovery key: ${formatErrorMessage(err)}`, { cause: err });
|
|
517
|
+
}
|
|
518
|
+
const keyId = typeof params.keyId === "string" && params.keyId.trim() ? params.keyId.trim() : null;
|
|
519
|
+
return {
|
|
520
|
+
encodedPrivateKey,
|
|
521
|
+
privateKey,
|
|
522
|
+
keyId,
|
|
523
|
+
keyInfo: params.keyInfo ?? this.loadStoredRecoveryKey()?.keyInfo
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
storeEncodedRecoveryKey(params) {
|
|
527
|
+
const prepared = this.resolveEncodedRecoveryKeyInput(params);
|
|
528
|
+
this.saveRecoveryKeyToDisk({
|
|
529
|
+
keyId: prepared.keyId,
|
|
530
|
+
keyInfo: prepared.keyInfo,
|
|
531
|
+
privateKey: prepared.privateKey,
|
|
532
|
+
encodedPrivateKey: prepared.encodedPrivateKey
|
|
533
|
+
});
|
|
534
|
+
if (prepared.keyId) this.rememberSecretStorageKey(prepared.keyId, prepared.privateKey, prepared.keyInfo);
|
|
535
|
+
return this.getRecoveryKeySummary() ?? {};
|
|
536
|
+
}
|
|
537
|
+
stageEncodedRecoveryKey(params) {
|
|
538
|
+
const prepared = this.resolveEncodedRecoveryKeyInput(params);
|
|
539
|
+
this.discardStagedRecoveryKey();
|
|
540
|
+
this.stagedRecoveryKey = {
|
|
541
|
+
version: 1,
|
|
542
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
543
|
+
keyId: prepared.keyId,
|
|
544
|
+
encodedPrivateKey: prepared.encodedPrivateKey,
|
|
545
|
+
privateKeyBase64: Buffer.from(prepared.privateKey).toString("base64"),
|
|
546
|
+
keyInfo: prepared.keyInfo
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
hasStagedRecoveryKeyBeenUsed() {
|
|
550
|
+
return this.stagedRecoveryKeyUsed;
|
|
551
|
+
}
|
|
552
|
+
commitStagedRecoveryKey(params) {
|
|
553
|
+
if (!this.stagedRecoveryKey) return this.getRecoveryKeySummary();
|
|
554
|
+
const staged = this.stagedRecoveryKey;
|
|
555
|
+
const privateKey = new Uint8Array(Buffer.from(staged.privateKeyBase64, "base64"));
|
|
556
|
+
const keyId = typeof params?.keyId === "string" && params.keyId.trim() ? params.keyId.trim() : staged.keyId;
|
|
557
|
+
this.saveRecoveryKeyToDisk({
|
|
558
|
+
keyId,
|
|
559
|
+
keyInfo: params?.keyInfo ?? staged.keyInfo,
|
|
560
|
+
privateKey,
|
|
561
|
+
encodedPrivateKey: staged.encodedPrivateKey
|
|
562
|
+
});
|
|
563
|
+
this.clearStagedRecoveryKeyTracking();
|
|
564
|
+
return this.getRecoveryKeySummary();
|
|
565
|
+
}
|
|
566
|
+
discardStagedRecoveryKey() {
|
|
567
|
+
for (const keyId of this.stagedCacheKeyIds) this.secretStorageKeyCache.delete(keyId);
|
|
568
|
+
this.clearStagedRecoveryKeyTracking();
|
|
569
|
+
}
|
|
570
|
+
async bootstrapSecretStorageWithRecoveryKey(crypto, options = {}) {
|
|
571
|
+
let status = null;
|
|
572
|
+
const getSecretStorageStatus = crypto.getSecretStorageStatus;
|
|
573
|
+
if (typeof getSecretStorageStatus === "function") try {
|
|
574
|
+
status = await getSecretStorageStatus.call(crypto);
|
|
575
|
+
} catch (err) {
|
|
576
|
+
LogService.warn("MatrixClientLite", "Failed to read secret storage status:", err);
|
|
577
|
+
}
|
|
578
|
+
const hasDefaultSecretStorageKey = Boolean(status?.defaultKeyId);
|
|
579
|
+
const hasKnownInvalidSecrets = Object.values(status?.secretStorageKeyValidityMap ?? {}).some((valid) => !valid);
|
|
580
|
+
let generatedRecoveryKey = false;
|
|
581
|
+
const storedRecovery = this.loadStoredRecoveryKey();
|
|
582
|
+
const stagedRecovery = this.stagedRecoveryKey;
|
|
583
|
+
const sourceRecovery = options.forceNewRecoveryKey === true ? null : stagedRecovery ?? storedRecovery;
|
|
584
|
+
let recoveryKey = sourceRecovery ? {
|
|
585
|
+
keyInfo: sourceRecovery.keyInfo,
|
|
586
|
+
privateKey: new Uint8Array(Buffer.from(sourceRecovery.privateKeyBase64, "base64")),
|
|
587
|
+
encodedPrivateKey: sourceRecovery.encodedPrivateKey
|
|
588
|
+
} : null;
|
|
589
|
+
if (recoveryKey && status?.defaultKeyId) {
|
|
590
|
+
const defaultKeyId = status.defaultKeyId;
|
|
591
|
+
if (!stagedRecovery) {
|
|
592
|
+
this.rememberSecretStorageKey(defaultKeyId, recoveryKey.privateKey, recoveryKey.keyInfo);
|
|
593
|
+
if (storedRecovery && storedRecovery.keyId !== defaultKeyId) this.saveRecoveryKeyToDisk({
|
|
594
|
+
keyId: defaultKeyId,
|
|
595
|
+
keyInfo: recoveryKey.keyInfo,
|
|
596
|
+
privateKey: recoveryKey.privateKey,
|
|
597
|
+
encodedPrivateKey: recoveryKey.encodedPrivateKey
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
const ensureRecoveryKey = async () => {
|
|
602
|
+
if (recoveryKey) {
|
|
603
|
+
if (stagedRecovery) this.stagedRecoveryKeyUsed = true;
|
|
604
|
+
return recoveryKey;
|
|
605
|
+
}
|
|
606
|
+
if (typeof crypto.createRecoveryKeyFromPassphrase !== "function") throw new Error("Matrix crypto backend does not support recovery key generation (createRecoveryKeyFromPassphrase missing)");
|
|
607
|
+
recoveryKey = await crypto.createRecoveryKeyFromPassphrase();
|
|
608
|
+
this.saveRecoveryKeyToDisk(recoveryKey);
|
|
609
|
+
generatedRecoveryKey = true;
|
|
610
|
+
return recoveryKey;
|
|
611
|
+
};
|
|
612
|
+
const shouldRecreateSecretStorage = options.forceNewSecretStorage === true || !hasDefaultSecretStorageKey || !recoveryKey && status?.ready === false || hasKnownInvalidSecrets;
|
|
613
|
+
if (hasKnownInvalidSecrets) recoveryKey = null;
|
|
614
|
+
const secretStorageOptions = { setupNewKeyBackup: options.setupNewKeyBackup === true };
|
|
615
|
+
if (shouldRecreateSecretStorage) {
|
|
616
|
+
secretStorageOptions.setupNewSecretStorage = true;
|
|
617
|
+
secretStorageOptions.createSecretStorageKey = ensureRecoveryKey;
|
|
618
|
+
}
|
|
619
|
+
try {
|
|
620
|
+
await crypto.bootstrapSecretStorage(secretStorageOptions);
|
|
621
|
+
} catch (err) {
|
|
622
|
+
if (!(options.allowSecretStorageRecreateWithoutRecoveryKey === true && hasDefaultSecretStorageKey && isRepairableSecretStorageAccessError(err))) throw err;
|
|
623
|
+
recoveryKey = null;
|
|
624
|
+
LogService.warn("MatrixClientLite", "Secret storage exists on the server but local recovery material cannot unlock it; recreating secret storage during explicit bootstrap.");
|
|
625
|
+
await crypto.bootstrapSecretStorage({
|
|
626
|
+
setupNewSecretStorage: true,
|
|
627
|
+
setupNewKeyBackup: options.setupNewKeyBackup === true,
|
|
628
|
+
createSecretStorageKey: ensureRecoveryKey
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
if (generatedRecoveryKey && this.storageRootDir) LogService.warn("MatrixClientLite", "Generated Matrix recovery key and saved it to Matrix SQLite state. Keep the displayed recovery key secure.");
|
|
632
|
+
}
|
|
633
|
+
clearStagedRecoveryKeyTracking() {
|
|
634
|
+
this.stagedRecoveryKey = null;
|
|
635
|
+
this.stagedRecoveryKeyUsed = false;
|
|
636
|
+
this.stagedCacheKeyIds.clear();
|
|
637
|
+
}
|
|
638
|
+
resolveStagedSecretStorageKey(requestedKeyIds) {
|
|
639
|
+
const staged = this.stagedRecoveryKey;
|
|
640
|
+
if (!staged?.privateKeyBase64) return null;
|
|
641
|
+
const privateKey = new Uint8Array(Buffer.from(staged.privateKeyBase64, "base64"));
|
|
642
|
+
if (privateKey.length === 0) return null;
|
|
643
|
+
const keyId = staged.keyId && requestedKeyIds.includes(staged.keyId) ? staged.keyId : requestedKeyIds[0];
|
|
644
|
+
if (!keyId) return null;
|
|
645
|
+
this.rememberStagedSecretStorageKey(keyId, privateKey, staged.keyInfo);
|
|
646
|
+
this.stagedCacheKeyIds.add(keyId);
|
|
647
|
+
return [keyId, privateKey];
|
|
648
|
+
}
|
|
649
|
+
rememberStagedSecretStorageKey(keyId, key, keyInfo) {
|
|
650
|
+
this.stagedRecoveryKeyUsed = true;
|
|
651
|
+
this.rememberSecretStorageKey(keyId, key, keyInfo);
|
|
652
|
+
}
|
|
653
|
+
rememberSecretStorageKey(keyId, key, keyInfo) {
|
|
654
|
+
if (!keyId.trim()) return;
|
|
655
|
+
this.secretStorageKeyCache.set(keyId, {
|
|
656
|
+
key: new Uint8Array(key),
|
|
657
|
+
keyInfo
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
loadStoredRecoveryKey() {
|
|
661
|
+
if (!this.recoveryKeyPath) return null;
|
|
662
|
+
try {
|
|
663
|
+
const stored = readMatrixRecoveryKeyStateForPath(this.recoveryKeyPath);
|
|
664
|
+
if (stored) return stored;
|
|
665
|
+
} catch {}
|
|
666
|
+
if (this.legacyRecoveryKeyPathOnMigrationFailure) return readLegacyMatrixRecoveryKeyFile(this.legacyRecoveryKeyPathOnMigrationFailure);
|
|
667
|
+
return null;
|
|
668
|
+
}
|
|
669
|
+
saveRecoveryKeyToDisk(params) {
|
|
670
|
+
if (!this.recoveryKeyPath) return;
|
|
671
|
+
try {
|
|
672
|
+
const payload = {
|
|
673
|
+
version: 1,
|
|
674
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
675
|
+
keyId: typeof params.keyId === "string" ? params.keyId : null,
|
|
676
|
+
encodedPrivateKey: params.encodedPrivateKey,
|
|
677
|
+
privateKeyBase64: Buffer.from(params.privateKey).toString("base64"),
|
|
678
|
+
keyInfo: params.keyInfo ? {
|
|
679
|
+
passphrase: params.keyInfo.passphrase,
|
|
680
|
+
name: params.keyInfo.name
|
|
681
|
+
} : void 0
|
|
682
|
+
};
|
|
683
|
+
writeMatrixRecoveryKeyStateForPath({
|
|
684
|
+
recoveryKeyPath: this.recoveryKeyPath,
|
|
685
|
+
payload
|
|
686
|
+
});
|
|
687
|
+
} catch (err) {
|
|
688
|
+
LogService.warn("MatrixClientLite", "Failed to persist recovery key:", err);
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
};
|
|
692
|
+
//#endregion
|
|
207
693
|
//#region extensions/matrix/src/matrix/sdk/client-base.ts
|
|
208
694
|
function resolveMessageWireDispatch(resource, init) {
|
|
209
695
|
if ((init?.method ?? (resource instanceof Request ? resource.method : "GET")).toUpperCase() !== "PUT") return null;
|
|
@@ -221,7 +707,7 @@ function resolveMessageWireDispatch(resource, init) {
|
|
|
221
707
|
};
|
|
222
708
|
}
|
|
223
709
|
let loadedMatrixCryptoRuntime = null;
|
|
224
|
-
const loadMatrixCryptoRuntime = createLazyRuntimeModule(() => import("./crypto-runtime-
|
|
710
|
+
const loadMatrixCryptoRuntime = createLazyRuntimeModule(() => import("./crypto-runtime-Ch4WOG1y.mjs").then((runtime) => {
|
|
225
711
|
loadedMatrixCryptoRuntime = runtime;
|
|
226
712
|
return runtime;
|
|
227
713
|
}));
|
|
@@ -552,13 +1038,15 @@ var MatrixClientBase = class {
|
|
|
552
1038
|
if (!cryptoBootstrapper) return;
|
|
553
1039
|
const initial = await cryptoBootstrapper.bootstrap(crypto, MATRIX_INITIAL_CRYPTO_BOOTSTRAP_OPTIONS);
|
|
554
1040
|
throwIfMatrixStartupAborted(abortSignal);
|
|
555
|
-
if (!initial.crossSigningPublished || initial.ownDeviceVerified === false)
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
1041
|
+
if (!initial.crossSigningPublished || initial.ownDeviceVerified === false) {
|
|
1042
|
+
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.");
|
|
1043
|
+
else try {
|
|
1044
|
+
const repaired = await cryptoBootstrapper.bootstrap(crypto, MATRIX_AUTOMATIC_REPAIR_BOOTSTRAP_OPTIONS);
|
|
1045
|
+
throwIfMatrixStartupAborted(abortSignal);
|
|
1046
|
+
if (repaired.crossSigningPublished && repaired.ownDeviceVerified !== false) LogService.info("MatrixClientLite", "Cross-signing/bootstrap recovered after forced reset");
|
|
1047
|
+
} catch (err) {
|
|
1048
|
+
LogService.warn("MatrixClientLite", "Failed to recover cross-signing/bootstrap with forced reset:", err);
|
|
1049
|
+
}
|
|
562
1050
|
}
|
|
563
1051
|
this.cryptoBootstrapped = true;
|
|
564
1052
|
}
|
|
@@ -853,6 +1341,9 @@ var MatrixClientCore = class extends MatrixClientBase {
|
|
|
853
1341
|
//#region extensions/matrix/src/matrix/sdk/client-verification.ts
|
|
854
1342
|
const normalizeNullableVerificationString = normalizeNullableString;
|
|
855
1343
|
var MatrixClientVerification = class extends MatrixClientCore {
|
|
1344
|
+
async refreshOwnDeviceKeys() {
|
|
1345
|
+
await this.client.getCrypto()?.userHasCrossSigningKeys(await this.getUserId(), true);
|
|
1346
|
+
}
|
|
856
1347
|
async getRoomKeyBackupStatus() {
|
|
857
1348
|
if (!this.encryptionEnabled) return {
|
|
858
1349
|
serverVersion: null,
|
|
@@ -881,14 +1372,16 @@ var MatrixClientVerification = class extends MatrixClientCore {
|
|
|
881
1372
|
let keyLoadAttempted = false;
|
|
882
1373
|
let keyLoadError = null;
|
|
883
1374
|
if (serverVersion && (shouldLoadBackupKey || shouldActivateBackup)) {
|
|
884
|
-
if (shouldLoadBackupKey)
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
1375
|
+
if (shouldLoadBackupKey) {
|
|
1376
|
+
if (typeof crypto.loadSessionBackupPrivateKeyFromSecretStorage === "function") {
|
|
1377
|
+
keyLoadAttempted = true;
|
|
1378
|
+
try {
|
|
1379
|
+
await crypto.loadSessionBackupPrivateKeyFromSecretStorage();
|
|
1380
|
+
} catch (err) {
|
|
1381
|
+
keyLoadError = formatErrorMessage(err);
|
|
1382
|
+
}
|
|
1383
|
+
} else keyLoadError = "Matrix crypto backend does not support loading backup keys from secret storage";
|
|
1384
|
+
}
|
|
892
1385
|
if (!keyLoadError) await this.enableTrustedRoomKeyBackupIfPossible(crypto);
|
|
893
1386
|
({activeVersion, decryptionKeyCached} = await this.resolveRoomKeyBackupLocalState(crypto));
|
|
894
1387
|
({serverVersion, trusted, matchesDecryptionKey} = await this.resolveRoomKeyBackupTrustState(crypto, serverVersion));
|
|
@@ -1056,6 +1549,11 @@ var MatrixClientVerification = class extends MatrixClientCore {
|
|
|
1056
1549
|
};
|
|
1057
1550
|
//#endregion
|
|
1058
1551
|
//#region extensions/matrix/src/matrix/sdk.ts
|
|
1552
|
+
var sdk_exports = /* @__PURE__ */ __exportAll({
|
|
1553
|
+
ConsoleLogger: () => ConsoleLogger,
|
|
1554
|
+
LogService: () => LogService,
|
|
1555
|
+
MatrixClient: () => MatrixClient
|
|
1556
|
+
});
|
|
1059
1557
|
var MatrixClient = class extends MatrixClientVerification {
|
|
1060
1558
|
async verifyWithRecoveryKey(rawRecoveryKey) {
|
|
1061
1559
|
const fail = async (error, fields = {}) => {
|
|
@@ -1424,4 +1922,4 @@ var MatrixClient = class extends MatrixClientVerification {
|
|
|
1424
1922
|
}
|
|
1425
1923
|
};
|
|
1426
1924
|
//#endregion
|
|
1427
|
-
export { ConsoleLogger, LogService, MatrixClient };
|
|
1925
|
+
export { ConsoleLogger, LogService, MatrixClient, isRepairableSecretStorageAccessError as n, sdk_exports as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as getMatrixScopedEnvVarNames } from "./env-vars-dGqak9dN.
|
|
1
|
+
import { t as getMatrixScopedEnvVarNames } from "./env-vars-dGqak9dN.mjs";
|
|
2
2
|
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
|
3
3
|
import { collectSecretInputAssignment, createChannelSecretTargetRegistryEntries, getChannelSurface, hasConfiguredSecretInputValue, hasOwnProperty, normalizeSecretStringValue } from "openclaw/plugin-sdk/channel-secret-basic-runtime";
|
|
4
4
|
//#region extensions/matrix/src/secret-contract.ts
|