@openclaw/matrix 2026.9.1-beta.1 → 2026.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{account-config-BZWN9tGS.js → account-config-CRsKoMqJ.js} +1 -1
- package/dist/{account-selection-CWuhuFn1.js → account-selection-DA-jfx22.js} +74 -36
- package/dist/{accounts-BCzyubQt.js → accounts-DR1c4xF_.js} +4 -5
- package/dist/api.js +5 -5
- package/dist/{approval-handler.runtime-G9fLHUWe.js → approval-handler.runtime-BJCD4dLf.js} +34 -11
- package/dist/{approval-ids-C6FD3pVY.js → approval-ids-Bst7HM_o.js} +1 -1
- package/dist/{approval-reaction-auth-60xHiDtQ.js → approval-reaction-auth-DhH8QOSe.js} +2 -2
- package/dist/{approval-reactions-tXh9KYrW.js → approval-reactions-1fwEhoK9.js} +1 -1
- package/dist/{channel-CBEvelTE.js → channel-Bs8VLb6q.js} +63 -58
- package/dist/channel-plugin-api.js +1 -1
- package/dist/channel.runtime-CCJRhdH5.js +76 -0
- package/dist/{channel.setup-sWPOGyQG.js → channel.setup-DhmDXwPp.js} +32 -22
- package/dist/{cli-DrTD2a_q.js → cli-IvDUuiDH.js} +179 -135
- package/dist/{cli-metadata-DrYVwQ_r.js → cli-metadata-BGryAl2e.js} +1 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/{client-hs1ePy2O.js → client-Dj4mcf-s.js} +73 -22
- package/dist/{client-bootstrap-BxdxjCwA.js → client-bootstrap-n1Rqc8Go.js} +1 -1
- package/dist/{client-BUtHbzib.js → client-oNOlldJI.js} +2 -2
- package/dist/{config-update-Bor_Pjsv.js → config-update-BnX26jCO.js} +48 -31
- package/dist/contract-api.js +2 -2
- package/dist/{credentials-BdAaWuiR.js → credentials-DJj2xs3q.js} +4 -8
- package/dist/{credentials-read-B37cQknZ.js → credentials-read-mexhw-Ur.js} +7 -5
- package/dist/{credentials-write.runtime-nAV2-5uR.js → credentials-write.runtime-DQt-kgJq.js} +1 -1
- package/dist/{crypto-runtime-C4WDYxlP.js → crypto-runtime-m1eplj3b.js} +7 -7
- package/dist/crypto-snapshot-doctor.runtime-D0v841D_.js +91 -0
- package/dist/{deps-CcVJfvRM.js → deps-mtxF2mHI.js} +1 -1
- package/dist/{directory-live-D0KfJlby.js → directory-live-DLUgWBhA.js} +8 -6
- package/dist/{doctor-EWf9CDso.js → doctor-CJE8wO6y.js} +1 -1
- package/dist/{doctor-contract-DEt4O4Zt.js → doctor-contract-HyWFZQVG.js} +5 -4
- package/dist/doctor-contract-api.js +89 -109
- package/dist/{draft-stream-B_m79Ynb.js → draft-stream-DglwxWzJ.js} +1 -1
- package/dist/{encryption-guidance-DmLY8NiO.js → encryption-guidance-BNcZNQZI.js} +3 -2
- package/dist/helper-api.js +1 -1
- package/dist/{http-client-D8o8b9u6.js → http-client-DOmFvKvB.js} +10 -7
- package/dist/{idb-persistence-DfgW720p.js → idb-persistence-CU7CNLlX.js} +2 -2
- package/dist/{idb-persistence-lock-DAJ49nZX.js → idb-persistence-lock-B3fZXyF_.js} +1 -1
- package/dist/{inbound-dedupe-RvSLqdsz.js → inbound-dedupe-Ch33GU06.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/{messages-Dow9EOoJ.js → messages-Czn8lNEh.js} +154 -5
- package/dist/{monitor-DBB47wTy.js → monitor-DouG43FJ.js} +200 -156
- package/dist/outbound-Co_tJyE6.js +220 -0
- package/dist/plugin-entry.handlers.runtime.js +1 -1
- package/dist/probe.runtime-B1YPxG9x.js +2 -0
- package/dist/{profile-update-C61NR24_.js → profile-update-CAl8nZNG.js} +5 -4
- package/dist/{profile-D-Wubo0A.js → profile-vmjsmhh4.js} +1 -1
- package/dist/{reaction-events-BZUgLIZI.js → reaction-events-C_7G7bvI.js} +9 -7
- package/dist/{resolve-targets-DXzZwsIY.js → resolve-targets-B64O69Nd.js} +1 -1
- package/dist/{resolver.runtime-p5qJ3Kst.js → resolver.runtime-TRmePJDV.js} +1 -1
- package/dist/{room-info-BXQA7y10.js → room-info-6viLR3NH.js} +55 -1
- package/dist/runtime-api.js +2 -2
- package/dist/{sdk-CljOKEvc.js → sdk-C1yfda1L.js} +534 -26
- package/dist/{send-BKu9Ghi4.js → send-B5XChnvB.js} +31 -33
- package/dist/session-binding-contract-api.js +1 -1
- package/dist/{setup-bootstrap-CpE6C3qV.js → setup-bootstrap-S_loyUyM.js} +3 -3
- package/dist/{setup-core-CyvaCOOr.js → setup-core-XkIfQ65J.js} +8 -7
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{setup-surface-DtRvRcCT.js → setup-surface-B2yZ8KGc.js} +84 -79
- package/dist/{startup-verification-Cs08ca8u.js → startup-verification-1Ney1mmI.js} +2 -2
- package/dist/{storage-BsGuHngK.js → storage-BVf4uucD.js} +5 -4
- package/dist/{subagent-hooks-CMoZaARG.js → subagent-hooks-DeICLbU5.js} +5 -1
- package/dist/subagent-hooks-api.js +1 -1
- package/dist/sync-cache-state-d-A_OhbU.js +234 -0
- package/dist/{thread-bindings-BvyU66kE.js → thread-bindings-BkBnn4te.js} +4 -4
- package/dist/{tool-actions.runtime-DD6jUxFK.js → tool-actions.runtime-a5L5xGSP.js} +226 -215
- package/dist/{verification-BP-3-XYn.js → verification-XJtTc5DI.js} +2 -2
- package/node_modules/markdown-it/dist/browser/markdown-it.esm.min.mjs +216 -183
- 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 +98 -106
- 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 +98 -106
- 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/build/format/json_pointer.d.mts +2 -2
- package/node_modules/typebox/build/format/json_pointer.mjs +2 -2
- package/node_modules/typebox/build/format/json_pointer_uri_fragment.d.mts +2 -2
- package/node_modules/typebox/build/format/json_pointer_uri_fragment.mjs +2 -2
- package/node_modules/typebox/build/format/relative_json_pointer.d.mts +2 -2
- package/node_modules/typebox/build/format/relative_json_pointer.mjs +2 -2
- package/node_modules/typebox/build/system/memory/assign.mjs +2 -1
- package/node_modules/typebox/build/system/memory/create.mjs +3 -4
- package/node_modules/typebox/build/system/memory/discard.mjs +2 -2
- package/node_modules/typebox/build/system/memory/freeze.d.mts +4 -0
- package/node_modules/typebox/build/system/memory/freeze.mjs +6 -0
- package/node_modules/typebox/build/system/memory/update.mjs +3 -2
- package/node_modules/typebox/package.json +1 -1
- package/openclaw.plugin.json +17 -3
- package/package.json +8 -7
- package/dist/channel.runtime-CiDl9deX.js +0 -276
- package/dist/env-auth-MVS-Vv41.js +0 -64
- package/dist/file-sync-store-DjskBX2o.js +0 -436
- package/dist/media-text-OR9uoC4W.js +0 -153
- package/dist/probe.runtime-CRM7RIrB.js +0 -2
- package/dist/recovery-key-store-CognuDys.js +0 -276
|
@@ -1,25 +1,30 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
2
|
+
import { t as getMatrixRuntime } from "./runtime-6S3DNFNv.js";
|
|
1
3
|
import "./reaction-common-DkrQdBSZ.js";
|
|
2
|
-
import { t as
|
|
3
|
-
import {
|
|
4
|
-
import { t as MATRIX_IDB_PERSIST_INTERVAL_MS } from "./idb-persistence-lock-DAJ49nZX.js";
|
|
4
|
+
import { A as writeMatrixRecoveryKeyStateForPath, E as readMatrixRecoveryKeyStateForPath, S as readLegacyMatrixRecoveryKeyFile, _ as migrateLegacyMatrixRecoveryKeyFilePathToStore, t as claimCurrentTokenStorageState } from "./storage-BVf4uucD.js";
|
|
5
|
+
import { i as openMatrixSyncCacheStoreOptions, l as writeMatrixSyncCacheStateToSyncStore, n as deleteMatrixSyncCacheStateFromSyncStore, o as readPersistedStoreFromSyncStore } from "./sync-cache-state-d-A_OhbU.js";
|
|
5
6
|
import { n as isMatrixNotFoundError, t as formatMatrixErrorReason } from "./errors-DKVS3_DO.js";
|
|
6
|
-
import { a as throwIfMatrixStartupAborted, r as createMatrixStartupAbortError } from "./client-
|
|
7
|
+
import { a as throwIfMatrixStartupAborted, r as createMatrixStartupAbortError } from "./client-Dj4mcf-s.js";
|
|
8
|
+
import { n as LogService, r as noop, t as ConsoleLogger } from "./logger-B_71hN6W.js";
|
|
7
9
|
import { n as matrixEventToRaw, r as parseMxc } from "./event-helpers-XRfAbOIh.js";
|
|
8
|
-
import { n as createMatrixGuardedFetch, t as MatrixAuthedHttpClient } from "./http-client-
|
|
10
|
+
import { n as createMatrixGuardedFetch, t as MatrixAuthedHttpClient } from "./http-client-DOmFvKvB.js";
|
|
9
11
|
import { n as resolveMatrixRoomKeyBackupReadinessError } from "./backup-health-Dm_YMVFT.js";
|
|
10
12
|
import { t as createMatrixJsSdkClientLogger } from "./logging-DRjvUOIh.js";
|
|
13
|
+
import { t as MATRIX_IDB_PERSIST_INTERVAL_MS } from "./idb-persistence-lock-B3fZXyF_.js";
|
|
11
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-DLj4vDeu.js";
|
|
12
|
-
import { n as isRepairableSecretStorageAccessError, t as MatrixRecoveryKeyStore } from "./recovery-key-store-CognuDys.js";
|
|
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";
|
|
24
|
+
import { RoomEvent } from "matrix-js-sdk/lib/models/room.js";
|
|
21
25
|
import { VerificationMethod } from "matrix-js-sdk/lib/types.js";
|
|
22
26
|
import { SyncApi, SyncState } from "matrix-js-sdk/lib/sync.js";
|
|
27
|
+
import { decodeRecoveryKey } from "matrix-js-sdk/lib/crypto-api/recovery-key.js";
|
|
23
28
|
import { EventStatus } from "matrix-js-sdk/lib/models/event-status.js";
|
|
24
29
|
//#region extensions/matrix/src/matrix/sdk/client-device-info.ts
|
|
25
30
|
async function resolveMatrixCrossSigningPublicationStatus(params) {
|
|
@@ -66,6 +71,13 @@ async function listMatrixOwnDevices(client) {
|
|
|
66
71
|
//#endregion
|
|
67
72
|
//#region extensions/matrix/src/matrix/sdk/client-event-bridge.ts
|
|
68
73
|
function registerMatrixClientBridge(params) {
|
|
74
|
+
let initialSyncComplete = false;
|
|
75
|
+
const joinTransitions = /* @__PURE__ */ new WeakSet();
|
|
76
|
+
params.client.on(RoomEvent.MyMembership, (room, membership, previousMembership) => {
|
|
77
|
+
if (!initialSyncComplete || membership !== "join" || previousMembership === "join") return;
|
|
78
|
+
const event = room.currentState.getStateEvents("m.room.member", params.getSelfUserId());
|
|
79
|
+
if (event) joinTransitions.add(event);
|
|
80
|
+
});
|
|
69
81
|
params.client.on(ClientEvent.Event, (event) => {
|
|
70
82
|
const roomId = event.getRoomId();
|
|
71
83
|
if (!roomId) return;
|
|
@@ -79,12 +91,16 @@ function registerMatrixClientBridge(params) {
|
|
|
79
91
|
const membership = raw.type === "m.room.member" ? raw.content.membership : void 0;
|
|
80
92
|
if (stateKey && selfUserId && stateKey === selfUserId) {
|
|
81
93
|
if (membership === "invite") params.emitter.emit("room.invite", roomId, raw);
|
|
82
|
-
else if (membership === "join") params.emitter.emit("room.join", roomId,
|
|
94
|
+
else if (membership === "join") params.emitter.emit("room.join", roomId, {
|
|
95
|
+
...raw,
|
|
96
|
+
membershipProvenance: joinTransitions.delete(event) ? "transition" : initialSyncComplete ? "update" : "snapshot"
|
|
97
|
+
});
|
|
83
98
|
}
|
|
84
99
|
if (isEncryptedEvent) params.decryptBridge.attachEncryptedEvent(event, roomId);
|
|
85
100
|
});
|
|
86
101
|
params.client.on(ClientEvent.Room, params.emitMembershipForRoom);
|
|
87
102
|
params.client.on(ClientEvent.Sync, (state, prevState, data) => {
|
|
103
|
+
initialSyncComplete ||= state === "PREPARED" || state === "SYNCING";
|
|
88
104
|
const error = data && typeof data === "object" && "error" in data ? data.error : void 0;
|
|
89
105
|
params.setCurrentSyncState(state, error);
|
|
90
106
|
params.emitter.emit("sync.state", state, prevState, error);
|
|
@@ -104,7 +120,8 @@ function emitMatrixMembershipForRoom(params) {
|
|
|
104
120
|
state_key: params.selfUserId,
|
|
105
121
|
content: { membership },
|
|
106
122
|
origin_server_ts: Date.now(),
|
|
107
|
-
unsigned: { age: 0 }
|
|
123
|
+
unsigned: { age: 0 },
|
|
124
|
+
membershipProvenance: "snapshot"
|
|
108
125
|
};
|
|
109
126
|
if (membership === "invite") {
|
|
110
127
|
params.emitter.emit("room.invite", roomId, raw);
|
|
@@ -122,6 +139,219 @@ function refreshMatrixDmRoomIds(direct, dmRoomIds) {
|
|
|
122
139
|
return true;
|
|
123
140
|
}
|
|
124
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
|
|
125
355
|
//#region extensions/matrix/src/matrix/sdk/client-sync-quiesce.ts
|
|
126
356
|
const MATRIX_SYNC_QUIESCE_TIMEOUT_MS = 5e3;
|
|
127
357
|
const MATRIX_JS_SDK_SYNC_VERSION = "42.2.0";
|
|
@@ -191,6 +421,275 @@ async function quiesceMatrixClientSync(params) {
|
|
|
191
421
|
});
|
|
192
422
|
}
|
|
193
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
|
|
194
693
|
//#region extensions/matrix/src/matrix/sdk/client-base.ts
|
|
195
694
|
function resolveMessageWireDispatch(resource, init) {
|
|
196
695
|
if ((init?.method ?? (resource instanceof Request ? resource.method : "GET")).toUpperCase() !== "PUT") return null;
|
|
@@ -208,7 +707,7 @@ function resolveMessageWireDispatch(resource, init) {
|
|
|
208
707
|
};
|
|
209
708
|
}
|
|
210
709
|
let loadedMatrixCryptoRuntime = null;
|
|
211
|
-
const loadMatrixCryptoRuntime = createLazyRuntimeModule(() => import("./crypto-runtime-
|
|
710
|
+
const loadMatrixCryptoRuntime = createLazyRuntimeModule(() => import("./crypto-runtime-m1eplj3b.js").then((runtime) => {
|
|
212
711
|
loadedMatrixCryptoRuntime = runtime;
|
|
213
712
|
return runtime;
|
|
214
713
|
}));
|
|
@@ -539,13 +1038,15 @@ var MatrixClientBase = class {
|
|
|
539
1038
|
if (!cryptoBootstrapper) return;
|
|
540
1039
|
const initial = await cryptoBootstrapper.bootstrap(crypto, MATRIX_INITIAL_CRYPTO_BOOTSTRAP_OPTIONS);
|
|
541
1040
|
throwIfMatrixStartupAborted(abortSignal);
|
|
542
|
-
if (!initial.crossSigningPublished || initial.ownDeviceVerified === false)
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
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
|
+
}
|
|
549
1050
|
}
|
|
550
1051
|
this.cryptoBootstrapped = true;
|
|
551
1052
|
}
|
|
@@ -868,14 +1369,16 @@ var MatrixClientVerification = class extends MatrixClientCore {
|
|
|
868
1369
|
let keyLoadAttempted = false;
|
|
869
1370
|
let keyLoadError = null;
|
|
870
1371
|
if (serverVersion && (shouldLoadBackupKey || shouldActivateBackup)) {
|
|
871
|
-
if (shouldLoadBackupKey)
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
1372
|
+
if (shouldLoadBackupKey) {
|
|
1373
|
+
if (typeof crypto.loadSessionBackupPrivateKeyFromSecretStorage === "function") {
|
|
1374
|
+
keyLoadAttempted = true;
|
|
1375
|
+
try {
|
|
1376
|
+
await crypto.loadSessionBackupPrivateKeyFromSecretStorage();
|
|
1377
|
+
} catch (err) {
|
|
1378
|
+
keyLoadError = formatErrorMessage(err);
|
|
1379
|
+
}
|
|
1380
|
+
} else keyLoadError = "Matrix crypto backend does not support loading backup keys from secret storage";
|
|
1381
|
+
}
|
|
879
1382
|
if (!keyLoadError) await this.enableTrustedRoomKeyBackupIfPossible(crypto);
|
|
880
1383
|
({activeVersion, decryptionKeyCached} = await this.resolveRoomKeyBackupLocalState(crypto));
|
|
881
1384
|
({serverVersion, trusted, matchesDecryptionKey} = await this.resolveRoomKeyBackupTrustState(crypto, serverVersion));
|
|
@@ -1043,6 +1546,11 @@ var MatrixClientVerification = class extends MatrixClientCore {
|
|
|
1043
1546
|
};
|
|
1044
1547
|
//#endregion
|
|
1045
1548
|
//#region extensions/matrix/src/matrix/sdk.ts
|
|
1549
|
+
var sdk_exports = /* @__PURE__ */ __exportAll({
|
|
1550
|
+
ConsoleLogger: () => ConsoleLogger,
|
|
1551
|
+
LogService: () => LogService,
|
|
1552
|
+
MatrixClient: () => MatrixClient
|
|
1553
|
+
});
|
|
1046
1554
|
var MatrixClient = class extends MatrixClientVerification {
|
|
1047
1555
|
async verifyWithRecoveryKey(rawRecoveryKey) {
|
|
1048
1556
|
const fail = async (error, fields = {}) => {
|
|
@@ -1411,4 +1919,4 @@ var MatrixClient = class extends MatrixClientVerification {
|
|
|
1411
1919
|
}
|
|
1412
1920
|
};
|
|
1413
1921
|
//#endregion
|
|
1414
|
-
export { ConsoleLogger, LogService, MatrixClient };
|
|
1922
|
+
export { ConsoleLogger, LogService, MatrixClient, isRepairableSecretStorageAccessError as n, sdk_exports as t };
|