mindoodb 0.0.72 → 0.0.74
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/browser/index.mjs +2 -0
- package/dist/core/BackgroundTaskTracker.d.ts +18 -0
- package/dist/core/BackgroundTaskTracker.d.ts.map +1 -0
- package/dist/core/BackgroundTaskTracker.js +37 -0
- package/dist/core/BackgroundTaskTracker.js.map +1 -0
- package/dist/core/BaseMindooDB.d.ts +60 -7
- package/dist/core/BaseMindooDB.d.ts.map +1 -1
- package/dist/core/BaseMindooDB.js +280 -66
- package/dist/core/BaseMindooDB.js.map +1 -1
- package/dist/core/BaseMindooTenant.d.ts +46 -12
- package/dist/core/BaseMindooTenant.d.ts.map +1 -1
- package/dist/core/BaseMindooTenant.js +133 -65
- package/dist/core/BaseMindooTenant.js.map +1 -1
- package/dist/core/BaseMindooTenantDirectory.d.ts +57 -14
- package/dist/core/BaseMindooTenantDirectory.d.ts.map +1 -1
- package/dist/core/BaseMindooTenantDirectory.js +319 -164
- package/dist/core/BaseMindooTenantDirectory.js.map +1 -1
- package/dist/core/appendonlystores/InMemoryContentAddressedStore.d.ts +11 -0
- package/dist/core/appendonlystores/InMemoryContentAddressedStore.d.ts.map +1 -1
- package/dist/core/appendonlystores/InMemoryContentAddressedStore.js +44 -18
- package/dist/core/appendonlystores/InMemoryContentAddressedStore.js.map +1 -1
- package/dist/core/appendonlystores/purgeDocumentHistory.d.ts +52 -0
- package/dist/core/appendonlystores/purgeDocumentHistory.d.ts.map +1 -0
- package/dist/core/appendonlystores/purgeDocumentHistory.js +107 -0
- package/dist/core/appendonlystores/purgeDocumentHistory.js.map +1 -0
- package/dist/core/appendonlystores/purgedDocumentGuard.d.ts +33 -0
- package/dist/core/appendonlystores/purgedDocumentGuard.d.ts.map +1 -0
- package/dist/core/appendonlystores/purgedDocumentGuard.js +78 -0
- package/dist/core/appendonlystores/purgedDocumentGuard.js.map +1 -0
- package/dist/core/cache/CacheManager.d.ts +4 -1
- package/dist/core/cache/CacheManager.d.ts.map +1 -1
- package/dist/core/cache/CacheManager.js +47 -19
- package/dist/core/cache/CacheManager.js.map +1 -1
- package/dist/core/indexing/fulltext/DocumentFullTextIndex.d.ts +16 -1
- package/dist/core/indexing/fulltext/DocumentFullTextIndex.d.ts.map +1 -1
- package/dist/core/indexing/fulltext/DocumentFullTextIndex.js +86 -14
- package/dist/core/indexing/fulltext/DocumentFullTextIndex.js.map +1 -1
- package/dist/core/indexing/summary/DocumentSummaryStore.d.ts +2 -0
- package/dist/core/indexing/summary/DocumentSummaryStore.d.ts.map +1 -1
- package/dist/core/indexing/summary/DocumentSummaryStore.js +19 -5
- package/dist/core/indexing/summary/DocumentSummaryStore.js.map +1 -1
- package/dist/core/types.d.ts +57 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +22 -0
- package/dist/core/types.js.map +1 -1
- package/dist/core/utils/singleFlight.d.ts +21 -0
- package/dist/core/utils/singleFlight.d.ts.map +1 -0
- package/dist/core/utils/singleFlight.js +47 -0
- package/dist/core/utils/singleFlight.js.map +1 -0
- package/dist/core/utils/timeSource.d.ts +3 -1
- package/dist/core/utils/timeSource.d.ts.map +1 -1
- package/dist/core/utils/timeSource.js +4 -0
- package/dist/core/utils/timeSource.js.map +1 -1
- package/dist/node/appendonlystores/BasicOnDiskContentAddressedStore.d.ts +13 -0
- package/dist/node/appendonlystores/BasicOnDiskContentAddressedStore.d.ts.map +1 -1
- package/dist/node/appendonlystores/BasicOnDiskContentAddressedStore.js +26 -2
- package/dist/node/appendonlystores/BasicOnDiskContentAddressedStore.js.map +1 -1
- package/dist/node/server/MindooDBServer.d.ts.map +1 -1
- package/dist/node/server/MindooDBServer.js +2 -0
- package/dist/node/server/MindooDBServer.js.map +1 -1
- package/dist/node/server/TenantManager.d.ts +11 -0
- package/dist/node/server/TenantManager.d.ts.map +1 -1
- package/dist/node/server/TenantManager.js +40 -9
- package/dist/node/server/TenantManager.js.map +1 -1
- package/dist/node/server/peer/ClusterManager.d.ts +4 -0
- package/dist/node/server/peer/ClusterManager.d.ts.map +1 -1
- package/dist/node/server/peer/ClusterManager.js +2 -0
- package/dist/node/server/peer/ClusterManager.js.map +1 -1
- package/dist/node/server/peer/PeerReplicator.d.ts +12 -0
- package/dist/node/server/peer/PeerReplicator.d.ts.map +1 -1
- package/dist/node/server/peer/PeerReplicator.js +19 -1
- package/dist/node/server/peer/PeerReplicator.js.map +1 -1
- package/package.json +1 -1
|
@@ -50,11 +50,12 @@ export declare class BaseMindooTenant implements MindooTenant {
|
|
|
50
50
|
*/
|
|
51
51
|
private unsubscribeKeyBagChanges;
|
|
52
52
|
/**
|
|
53
|
-
* Single-flight
|
|
54
|
-
* coalesce
|
|
55
|
-
*
|
|
53
|
+
* Single-flight for {@link reconcileKeyBagChanges}. Concurrent calls
|
|
54
|
+
* coalesce so live listener firings and explicit calls cannot race; a call
|
|
55
|
+
* arriving mid-run gets one follow-up run, so a KeyBag change made while
|
|
56
|
+
* databases were being reconciled is not left unconsumed.
|
|
56
57
|
*/
|
|
57
|
-
private
|
|
58
|
+
private readonly keyBagReconcile;
|
|
58
59
|
private decryptedTenantKeyCache?;
|
|
59
60
|
private decryptedUserSigningKeyCache?;
|
|
60
61
|
private decryptedUserEncryptionKeyCache?;
|
|
@@ -74,8 +75,10 @@ export declare class BaseMindooTenant implements MindooTenant {
|
|
|
74
75
|
private readonly importedVerifyKeyCache;
|
|
75
76
|
private static readonly MAX_IMPORTED_KEY_CACHE_ENTRIES;
|
|
76
77
|
private logger;
|
|
77
|
-
private
|
|
78
|
+
private readonly keyDistributionReconcile;
|
|
78
79
|
private userKeyReconcileScheduled;
|
|
80
|
+
/** Fire-and-forget work of this tenant; see {@link whenBackgroundIdle}. */
|
|
81
|
+
private readonly backgroundTasks;
|
|
79
82
|
private readonly userKeys;
|
|
80
83
|
private readonly sealedGenerations;
|
|
81
84
|
private cacheManager;
|
|
@@ -134,6 +137,19 @@ export declare class BaseMindooTenant implements MindooTenant {
|
|
|
134
137
|
* unbounded-allocates.
|
|
135
138
|
*/
|
|
136
139
|
scheduleUserKeyReconcile(): void;
|
|
140
|
+
/**
|
|
141
|
+
* Register fire-and-forget work so {@link whenBackgroundIdle} and shutdown
|
|
142
|
+
* wait for it. The task must handle its own errors.
|
|
143
|
+
*/
|
|
144
|
+
trackBackgroundTask(task: Promise<unknown>): void;
|
|
145
|
+
/**
|
|
146
|
+
* Resolve once neither this tenant nor any of its open databases has
|
|
147
|
+
* background work left (trust/key reconciles, auto-follow catch-ups,
|
|
148
|
+
* pending change events), including work that finishing tasks start.
|
|
149
|
+
*
|
|
150
|
+
* @internal Shutdown and test hook.
|
|
151
|
+
*/
|
|
152
|
+
whenBackgroundIdle(): Promise<void>;
|
|
137
153
|
noteUserDirectoryFetched(): void;
|
|
138
154
|
noteUserDirectoryFetchFailed(error: unknown): void;
|
|
139
155
|
listPendingUserKeyDevices(): Promise<PendingUserKeyDevice[]>;
|
|
@@ -292,6 +308,22 @@ export declare class BaseMindooTenant implements MindooTenant {
|
|
|
292
308
|
* cutoffs in ascending order.
|
|
293
309
|
*/
|
|
294
310
|
listTimeTravelCacheDates(dbId: string): Promise<number[]>;
|
|
311
|
+
/**
|
|
312
|
+
* Ids of the documents an admin-signed purge request removed from `dbId`
|
|
313
|
+
* (see {@link MindooTenant.getPurgedDocumentIds}). Read from the local
|
|
314
|
+
* directory; empty for the directory itself.
|
|
315
|
+
*/
|
|
316
|
+
getPurgedDocumentIds(dbId: string): Promise<ReadonlySet<string>>;
|
|
317
|
+
/**
|
|
318
|
+
* After a document's history was purged from a live database: scrub it from
|
|
319
|
+
* every open time-travel snapshot of that database, and drop the persisted
|
|
320
|
+
* snapshot caches, which hold materialized plaintext, summaries and full-text
|
|
321
|
+
* tokens of the document as of their cutoffs. Those caches are rebuilt on the
|
|
322
|
+
* next open.
|
|
323
|
+
*
|
|
324
|
+
* @internal Called by {@link BaseMindooDB.purgeDocumentHistory}.
|
|
325
|
+
*/
|
|
326
|
+
forgetPurgedDocumentInSnapshots(dbId: string, docId: string): Promise<void>;
|
|
295
327
|
/**
|
|
296
328
|
* Remove every persisted cache record of a time-travel snapshot (see
|
|
297
329
|
* {@link MindooTenant.purgeTimeTravelCache}). Deletes all records whose id
|
|
@@ -309,12 +341,14 @@ export declare class BaseMindooTenant implements MindooTenant {
|
|
|
309
341
|
* Designed as the single barrier callers can `await` to be certain that
|
|
310
342
|
* subsequent reads observe the latest add/remove of doc keys. Behaviour:
|
|
311
343
|
*
|
|
312
|
-
* - Idempotent and concurrency-safe. Concurrent callers share
|
|
313
|
-
*
|
|
314
|
-
* call after the cursor catches up is a
|
|
344
|
+
* - Idempotent and concurrency-safe. Concurrent callers share one run;
|
|
345
|
+
* a call arriving mid-run gets one follow-up run (see
|
|
346
|
+
* {@link keyBagReconcile}), and a call after the cursor catches up is a
|
|
347
|
+
* fast no-op.
|
|
315
348
|
* - Cursor-based. Replays from the persisted cursor in
|
|
316
349
|
* {@link keyBagChangeCursor}, so missed live notifications are
|
|
317
|
-
* automatically recovered.
|
|
350
|
+
* automatically recovered. The cursor advances only after every open
|
|
351
|
+
* database was reconciled, so a failed run is retried by the next call.
|
|
318
352
|
* - Tenant-scoped. Events for other tenants in a shared KeyBag are
|
|
319
353
|
* consumed (the cursor still advances) but ignored.
|
|
320
354
|
* - Invalidates the cached tenant default key when its add/remove was
|
|
@@ -323,6 +357,7 @@ export declare class BaseMindooTenant implements MindooTenant {
|
|
|
323
357
|
* cuts and never participate in visibility reconciliation.
|
|
324
358
|
*/
|
|
325
359
|
reconcileKeyBagChanges(): Promise<void>;
|
|
360
|
+
private runKeyBagReconcile;
|
|
326
361
|
/**
|
|
327
362
|
* Author-trust reconcile across all open live databases: when the tenant
|
|
328
363
|
* directory learns about new trusted signing keys (grantaccess documents
|
|
@@ -502,9 +537,8 @@ export declare class BaseMindooTenant implements MindooTenant {
|
|
|
502
537
|
* Single-flight, best-effort wrapper around
|
|
503
538
|
* {@link reconcileKeyDistributionsForCurrentUser} for the run-always trigger
|
|
504
539
|
* (docs/accesscontrol.md §13). Fired on directory bring-up and after every
|
|
505
|
-
* directory pull. Never throws
|
|
506
|
-
*
|
|
507
|
-
* directory access from re-triggering it.
|
|
540
|
+
* directory pull. Never throws: a reconcile error is logged and swallowed.
|
|
541
|
+
* Resolves after a run that started after this call.
|
|
508
542
|
*/
|
|
509
543
|
reconcileKeyDistributionsForCurrentUserSafe(): Promise<void>;
|
|
510
544
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseMindooTenant.d.ts","sourceRoot":"","sources":["../../src/core/BaseMindooTenant.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,QAAQ,EACR,qBAAqB,EACrB,4BAA4B,EAE5B,SAAS,EACT,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,YAAY,EAGZ,yBAAyB,EACzB,sBAAsB,EAEtB,sBAAsB,EAIvB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,aAAa,EAAE,YAAY,EAAkB,MAAM,UAAU,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,MAAM,EAA2B,MAAM,eAAe,CAAC;AAIhE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EACV,oBAAoB,EACpB,uBAAuB,EACxB,MAAM,kBAAkB,CAAC;AAI1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAI9D,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAe3D,OAAO,EAAE,MAAM,EAA8C,MAAM,WAAW,CAAC;AAG/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{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,CAAC,CAAC;IAchF;;;;;;;;OAQG;IACG,wCAAwC,CAC5C,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,MAAM,EAAE,GACrB,OAAO,CAAC,MAAM,CAAC;IAiClB,oEAAoE;IACpE,OAAO,CAAC,4BAA4B;IAIpC;;;;;;OAMG;cACa,eAAe,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IA8B7E;;;;;;;;;;;;;;OAcG;IACH,SAAS,CAAC,qCAAqC,IAAI,OAAO;IAI1D;;;;;;;;;;OAUG;IACG,wBAAwB,CAC5B,OAAO,EAAE,UAAU,EACnB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,UAAU,CAAC;IAgEtB;;;;;;;OAOG;IACG,wBAAwB,CAC5B,gBAAgB,EAAE,UAAU,EAC5B,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,UAAU,CAAC;CA2DvB"}
|
|
@@ -30,6 +30,8 @@ const joinRequestUri_1 = require("./uri/joinRequestUri");
|
|
|
30
30
|
const EncryptedLocalCacheStore_1 = require("./cache/EncryptedLocalCacheStore");
|
|
31
31
|
const CacheManager_1 = require("./cache/CacheManager");
|
|
32
32
|
const databaseIdValidation_1 = require("./databaseIdValidation");
|
|
33
|
+
const BackgroundTaskTracker_1 = require("./BackgroundTaskTracker");
|
|
34
|
+
const singleFlight_1 = require("./utils/singleFlight");
|
|
33
35
|
/**
|
|
34
36
|
* BaseMindooTenant is a platform-agnostic implementation of MindooTenant
|
|
35
37
|
* that works in both browser and server environments.
|
|
@@ -73,11 +75,12 @@ class BaseMindooTenant {
|
|
|
73
75
|
*/
|
|
74
76
|
this.unsubscribeKeyBagChanges = null;
|
|
75
77
|
/**
|
|
76
|
-
* Single-flight
|
|
77
|
-
* coalesce
|
|
78
|
-
*
|
|
78
|
+
* Single-flight for {@link reconcileKeyBagChanges}. Concurrent calls
|
|
79
|
+
* coalesce so live listener firings and explicit calls cannot race; a call
|
|
80
|
+
* arriving mid-run gets one follow-up run, so a KeyBag change made while
|
|
81
|
+
* databases were being reconciled is not left unconsumed.
|
|
79
82
|
*/
|
|
80
|
-
this.
|
|
83
|
+
this.keyBagReconcile = new singleFlight_1.SingleFlight(() => this.runKeyBagReconcile());
|
|
81
84
|
/**
|
|
82
85
|
* Cache of imported AES-GCM `CryptoKey`s, keyed by usage + raw key bytes
|
|
83
86
|
* (hex). `subtle.importKey` costs a WebCrypto round trip per call, which
|
|
@@ -92,14 +95,23 @@ class BaseMindooTenant {
|
|
|
92
95
|
* documents, so the per-call SPKI import is on the hot read path.
|
|
93
96
|
*/
|
|
94
97
|
this.importedVerifyKeyCache = new Map();
|
|
95
|
-
// Single-flight
|
|
96
|
-
//
|
|
97
|
-
//
|
|
98
|
-
// run
|
|
99
|
-
//
|
|
100
|
-
//
|
|
101
|
-
this.
|
|
98
|
+
// Single-flight for the SDK-driven key-distribution reconcile (§13), fired on
|
|
99
|
+
// directory bring-up and after each directory pull. A trigger arriving
|
|
100
|
+
// mid-run (e.g. a pull that brought a new distribution) gets one follow-up
|
|
101
|
+
// run instead of being dropped. The driver's own re-trigger (directory
|
|
102
|
+
// bring-up inside getDirectoryDB) is fire-and-forget, never awaited inside
|
|
103
|
+
// the run, so it queues a follow-up rather than waiting for itself.
|
|
104
|
+
this.keyDistributionReconcile = new singleFlight_1.SingleFlight(async () => {
|
|
105
|
+
try {
|
|
106
|
+
await this.reconcileKeyDistributionsForCurrentUser();
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
this.logger.warn(`reconcileKeyDistributionsForCurrentUserSafe: ${error}`);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
102
112
|
this.userKeyReconcileScheduled = false;
|
|
113
|
+
/** Fire-and-forget work of this tenant; see {@link whenBackgroundIdle}. */
|
|
114
|
+
this.backgroundTasks = new BackgroundTaskTracker_1.BackgroundTaskTracker();
|
|
103
115
|
this.userKeys = new UserKeyManager_1.UserKeyManager(this);
|
|
104
116
|
this.sealedGenerations = new Map();
|
|
105
117
|
// Local cache support
|
|
@@ -136,7 +148,9 @@ class BaseMindooTenant {
|
|
|
136
148
|
// Fire-and-forget: errors are surfaced via the reconcile path itself.
|
|
137
149
|
// We intentionally do not await here to keep the mutation call site
|
|
138
150
|
// synchronous from the listener's perspective.
|
|
139
|
-
|
|
151
|
+
this.trackBackgroundTask(this.reconcileKeyBagChanges().catch((error) => {
|
|
152
|
+
this.logger.warn(`reconcileKeyBagChanges: ${error}`);
|
|
153
|
+
}));
|
|
140
154
|
});
|
|
141
155
|
// Pre-warm the per-user CryptoKey caches so getDecryptedSigningKey()
|
|
142
156
|
// and getDecryptedEncryptionKey() never run PBKDF2 + decryptPrivateKey
|
|
@@ -191,6 +205,9 @@ class BaseMindooTenant {
|
|
|
191
205
|
// times - the disposer is nulled out after the first call.
|
|
192
206
|
this.unsubscribeKeyBagChanges?.();
|
|
193
207
|
this.unsubscribeKeyBagChanges = null;
|
|
208
|
+
// Background catch-ups write into the cache; let them finish before the
|
|
209
|
+
// final flush instead of racing the teardown.
|
|
210
|
+
await this.whenBackgroundIdle();
|
|
194
211
|
if (this.cacheManager) {
|
|
195
212
|
await this.cacheManager.dispose();
|
|
196
213
|
this.cacheManager = null;
|
|
@@ -235,12 +252,40 @@ class BaseMindooTenant {
|
|
|
235
252
|
if (this.userKeys.isReconciling() || this.userKeyReconcileScheduled)
|
|
236
253
|
return;
|
|
237
254
|
this.userKeyReconcileScheduled = true;
|
|
238
|
-
|
|
255
|
+
this.trackBackgroundTask(Promise.resolve().then(() => {
|
|
239
256
|
this.userKeyReconcileScheduled = false;
|
|
240
257
|
if (this.userKeys.isReconciling())
|
|
241
258
|
return;
|
|
242
|
-
|
|
243
|
-
});
|
|
259
|
+
return this.reconcileUserKeysSafe();
|
|
260
|
+
}));
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Register fire-and-forget work so {@link whenBackgroundIdle} and shutdown
|
|
264
|
+
* wait for it. The task must handle its own errors.
|
|
265
|
+
*/
|
|
266
|
+
trackBackgroundTask(task) {
|
|
267
|
+
this.backgroundTasks.run(task);
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Resolve once neither this tenant nor any of its open databases has
|
|
271
|
+
* background work left (trust/key reconciles, auto-follow catch-ups,
|
|
272
|
+
* pending change events), including work that finishing tasks start.
|
|
273
|
+
*
|
|
274
|
+
* @internal Shutdown and test hook.
|
|
275
|
+
*/
|
|
276
|
+
async whenBackgroundIdle() {
|
|
277
|
+
for (;;) {
|
|
278
|
+
let waited = await this.backgroundTasks.settle();
|
|
279
|
+
for (const db of Array.from(this.databaseCache.values())) {
|
|
280
|
+
const idle = db.whenBackgroundIdle;
|
|
281
|
+
if (idle && (await idle.call(db))) {
|
|
282
|
+
waited = true;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
if (!waited) {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
244
289
|
}
|
|
245
290
|
noteUserDirectoryFetched() {
|
|
246
291
|
this.userKeys.noteUserDirectoryFetched();
|
|
@@ -1078,6 +1123,49 @@ class BaseMindooTenant {
|
|
|
1078
1123
|
}
|
|
1079
1124
|
return Array.from(cutoffs).sort((a, b) => a - b);
|
|
1080
1125
|
}
|
|
1126
|
+
/**
|
|
1127
|
+
* Ids of the documents an admin-signed purge request removed from `dbId`
|
|
1128
|
+
* (see {@link MindooTenant.getPurgedDocumentIds}). Read from the local
|
|
1129
|
+
* directory; empty for the directory itself.
|
|
1130
|
+
*/
|
|
1131
|
+
async getPurgedDocumentIds(dbId) {
|
|
1132
|
+
const purged = new Set();
|
|
1133
|
+
if (dbId === "directory") {
|
|
1134
|
+
return purged;
|
|
1135
|
+
}
|
|
1136
|
+
const directory = await this.openDirectory();
|
|
1137
|
+
for (const request of await directory.getRequestedDocHistoryPurges()) {
|
|
1138
|
+
if (request.dbId !== dbId || !Array.isArray(request.docIds)) {
|
|
1139
|
+
continue;
|
|
1140
|
+
}
|
|
1141
|
+
for (const docId of request.docIds) {
|
|
1142
|
+
if (typeof docId === "string" && docId.length > 0) {
|
|
1143
|
+
purged.add(docId);
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
return purged;
|
|
1148
|
+
}
|
|
1149
|
+
/**
|
|
1150
|
+
* After a document's history was purged from a live database: scrub it from
|
|
1151
|
+
* every open time-travel snapshot of that database, and drop the persisted
|
|
1152
|
+
* snapshot caches, which hold materialized plaintext, summaries and full-text
|
|
1153
|
+
* tokens of the document as of their cutoffs. Those caches are rebuilt on the
|
|
1154
|
+
* next open.
|
|
1155
|
+
*
|
|
1156
|
+
* @internal Called by {@link BaseMindooDB.purgeDocumentHistory}.
|
|
1157
|
+
*/
|
|
1158
|
+
async forgetPurgedDocumentInSnapshots(dbId, docId) {
|
|
1159
|
+
const snapshotKeyPrefix = `${dbId}::tt:`;
|
|
1160
|
+
for (const [key, db] of this.databaseCache) {
|
|
1161
|
+
if (key.startsWith(snapshotKeyPrefix)) {
|
|
1162
|
+
await db.forgetPurgedDocument(docId);
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
for (const cutoff of await this.listTimeTravelCacheDates(dbId)) {
|
|
1166
|
+
await this.purgeTimeTravelCache(dbId, cutoff);
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1081
1169
|
/**
|
|
1082
1170
|
* Remove every persisted cache record of a time-travel snapshot (see
|
|
1083
1171
|
* {@link MindooTenant.purgeTimeTravelCache}). Deletes all records whose id
|
|
@@ -1138,12 +1226,14 @@ class BaseMindooTenant {
|
|
|
1138
1226
|
* Designed as the single barrier callers can `await` to be certain that
|
|
1139
1227
|
* subsequent reads observe the latest add/remove of doc keys. Behaviour:
|
|
1140
1228
|
*
|
|
1141
|
-
* - Idempotent and concurrency-safe. Concurrent callers share
|
|
1142
|
-
*
|
|
1143
|
-
* call after the cursor catches up is a
|
|
1229
|
+
* - Idempotent and concurrency-safe. Concurrent callers share one run;
|
|
1230
|
+
* a call arriving mid-run gets one follow-up run (see
|
|
1231
|
+
* {@link keyBagReconcile}), and a call after the cursor catches up is a
|
|
1232
|
+
* fast no-op.
|
|
1144
1233
|
* - Cursor-based. Replays from the persisted cursor in
|
|
1145
1234
|
* {@link keyBagChangeCursor}, so missed live notifications are
|
|
1146
|
-
* automatically recovered.
|
|
1235
|
+
* automatically recovered. The cursor advances only after every open
|
|
1236
|
+
* database was reconciled, so a failed run is retried by the next call.
|
|
1147
1237
|
* - Tenant-scoped. Events for other tenants in a shared KeyBag are
|
|
1148
1238
|
* consumed (the cursor still advances) but ignored.
|
|
1149
1239
|
* - Invalidates the cached tenant default key when its add/remove was
|
|
@@ -1152,34 +1242,30 @@ class BaseMindooTenant {
|
|
|
1152
1242
|
* cuts and never participate in visibility reconciliation.
|
|
1153
1243
|
*/
|
|
1154
1244
|
async reconcileKeyBagChanges() {
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
continue;
|
|
1168
|
-
}
|
|
1169
|
-
sawTenantDocKeyChange = true;
|
|
1170
|
-
if (event.keyId === types_1.DEFAULT_TENANT_KEY_ID) {
|
|
1171
|
-
// The cached plaintext default key may now refer to a rotated
|
|
1172
|
-
// or removed version; drop it so the next access re-resolves.
|
|
1173
|
-
this.decryptedTenantKeyCache = undefined;
|
|
1174
|
-
}
|
|
1245
|
+
return this.keyBagReconcile.run();
|
|
1246
|
+
}
|
|
1247
|
+
async runKeyBagReconcile() {
|
|
1248
|
+
let sawTenantDocKeyChange = false;
|
|
1249
|
+
let latestCursor = this.keyBagChangeCursor;
|
|
1250
|
+
// Consume every pending event so the cursor advances even for
|
|
1251
|
+
// unrelated tenants sharing the same bag. We only need to react to
|
|
1252
|
+
// doc keys for our own tenant though.
|
|
1253
|
+
for await (const event of this.keyBag.iterateChangesSince(this.keyBagChangeCursor)) {
|
|
1254
|
+
latestCursor = { changeSeq: event.changeSeq };
|
|
1255
|
+
if (event.type !== "doc" || event.tenantId !== this.tenantId) {
|
|
1256
|
+
continue;
|
|
1175
1257
|
}
|
|
1176
|
-
|
|
1177
|
-
if (
|
|
1178
|
-
|
|
1258
|
+
sawTenantDocKeyChange = true;
|
|
1259
|
+
if (event.keyId === types_1.DEFAULT_TENANT_KEY_ID) {
|
|
1260
|
+
// The cached plaintext default key may now refer to a rotated
|
|
1261
|
+
// or removed version; drop it so the next access re-resolves.
|
|
1262
|
+
this.decryptedTenantKeyCache = undefined;
|
|
1179
1263
|
}
|
|
1264
|
+
}
|
|
1265
|
+
if (sawTenantDocKeyChange) {
|
|
1180
1266
|
// Notify every open live database; time-travel views are read-only
|
|
1181
1267
|
// historical snapshots and intentionally skip reconciliation.
|
|
1182
|
-
for (const db of this.databaseCache.values()) {
|
|
1268
|
+
for (const db of Array.from(this.databaseCache.values())) {
|
|
1183
1269
|
if (db.isTimeTravelMode()) {
|
|
1184
1270
|
continue;
|
|
1185
1271
|
}
|
|
@@ -1188,13 +1274,8 @@ class BaseMindooTenant {
|
|
|
1188
1274
|
await reconcile.call(db);
|
|
1189
1275
|
}
|
|
1190
1276
|
}
|
|
1191
|
-
})();
|
|
1192
|
-
try {
|
|
1193
|
-
await this.keyBagReconcilePromise;
|
|
1194
|
-
}
|
|
1195
|
-
finally {
|
|
1196
|
-
this.keyBagReconcilePromise = null;
|
|
1197
1277
|
}
|
|
1278
|
+
this.keyBagChangeCursor = latestCursor;
|
|
1198
1279
|
}
|
|
1199
1280
|
/**
|
|
1200
1281
|
* Author-trust reconcile across all open live databases: when the tenant
|
|
@@ -2024,24 +2105,11 @@ class BaseMindooTenant {
|
|
|
2024
2105
|
* Single-flight, best-effort wrapper around
|
|
2025
2106
|
* {@link reconcileKeyDistributionsForCurrentUser} for the run-always trigger
|
|
2026
2107
|
* (docs/accesscontrol.md §13). Fired on directory bring-up and after every
|
|
2027
|
-
* directory pull. Never throws
|
|
2028
|
-
*
|
|
2029
|
-
* directory access from re-triggering it.
|
|
2108
|
+
* directory pull. Never throws: a reconcile error is logged and swallowed.
|
|
2109
|
+
* Resolves after a run that started after this call.
|
|
2030
2110
|
*/
|
|
2031
2111
|
async reconcileKeyDistributionsForCurrentUserSafe() {
|
|
2032
|
-
|
|
2033
|
-
return;
|
|
2034
|
-
}
|
|
2035
|
-
this.reconcileInFlight = true;
|
|
2036
|
-
try {
|
|
2037
|
-
await this.reconcileKeyDistributionsForCurrentUser();
|
|
2038
|
-
}
|
|
2039
|
-
catch (error) {
|
|
2040
|
-
this.logger.warn(`reconcileKeyDistributionsForCurrentUserSafe: ${error}`);
|
|
2041
|
-
}
|
|
2042
|
-
finally {
|
|
2043
|
-
this.reconcileInFlight = false;
|
|
2044
|
-
}
|
|
2112
|
+
await this.keyDistributionReconcile.run();
|
|
2045
2113
|
}
|
|
2046
2114
|
/**
|
|
2047
2115
|
* Export **all** stored versions of a document key for an admin-blind key
|