mindoodb 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.d.ts +3 -2
  2. package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.d.ts.map +1 -1
  3. package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.js +44 -9
  4. package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.js.map +1 -1
  5. package/dist/core/BaseMindooDB.d.ts +17 -3
  6. package/dist/core/BaseMindooDB.d.ts.map +1 -1
  7. package/dist/core/BaseMindooDB.js +29 -6
  8. package/dist/core/BaseMindooDB.js.map +1 -1
  9. package/dist/core/BaseMindooTenantDirectory.d.ts +4 -1
  10. package/dist/core/BaseMindooTenantDirectory.d.ts.map +1 -1
  11. package/dist/core/BaseMindooTenantDirectory.js +7 -3
  12. package/dist/core/BaseMindooTenantDirectory.js.map +1 -1
  13. package/dist/core/accesscontrol/evaluate.d.ts +7 -0
  14. package/dist/core/accesscontrol/evaluate.d.ts.map +1 -1
  15. package/dist/core/accesscontrol/evaluate.js +101 -0
  16. package/dist/core/accesscontrol/evaluate.js.map +1 -1
  17. package/dist/core/accesscontrol/types.d.ts +19 -3
  18. package/dist/core/accesscontrol/types.d.ts.map +1 -1
  19. package/dist/core/accesscontrol/types.js +29 -1
  20. package/dist/core/accesscontrol/types.js.map +1 -1
  21. package/dist/server/DeviceDiscoveryService.d.ts +7 -1
  22. package/dist/server/DeviceDiscoveryService.d.ts.map +1 -1
  23. package/dist/server/DeviceDiscoveryService.js +68 -24
  24. package/dist/server/DeviceDiscoveryService.js.map +1 -1
  25. package/dist/server/peer/PeerReplicator.d.ts +2 -1
  26. package/dist/server/peer/PeerReplicator.d.ts.map +1 -1
  27. package/dist/server/peer/PeerReplicator.js +2 -1
  28. package/dist/server/peer/PeerReplicator.js.map +1 -1
  29. package/package.json +1 -1
@@ -3232,6 +3232,16 @@ class BaseMindooDB {
3232
3232
  * dirty so the new visibility state survives a process restart.
3233
3233
  */
3234
3234
  async reconcileKeyVisibility() {
3235
+ await this.reconcileKeyVisibilityOf();
3236
+ }
3237
+ /**
3238
+ * {@link reconcileKeyVisibility}, limited to the documents encrypted with one
3239
+ * of `keyIds` when given. Each document of a sealed key series is checked by
3240
+ * unwrapping its recipient block (an RSA decryption on a cold session), so a
3241
+ * pass over every document of a large database costs seconds; a pass for a
3242
+ * few changed key series only touches the documents that use them.
3243
+ */
3244
+ async reconcileKeyVisibilityOf(keyIds) {
3235
3245
  if (this.isTimeTravelMode()) {
3236
3246
  return;
3237
3247
  }
@@ -3258,6 +3268,9 @@ class BaseMindooDB {
3258
3268
  if (!visibility) {
3259
3269
  continue;
3260
3270
  }
3271
+ if (keyIds && !keyIds.has(visibility.decryptionKeyId)) {
3272
+ continue;
3273
+ }
3261
3274
  const existingIndex = this.getDocIndexPosition(docId);
3262
3275
  const existing = existingIndex === undefined ? undefined : this.index[existingIndex];
3263
3276
  await this.ingestSealed(visibility.decryptionKeyId, metadataByDoc.get(docId));
@@ -3300,8 +3313,11 @@ class BaseMindooDB {
3300
3313
  // Whatever path triggered the reconcile (init, KeyBag listener,
3301
3314
  // explicit caller), record the fingerprint observed during this
3302
3315
  // pass so a subsequent warm start with identical bag composition
3303
- // can skip the scan.
3304
- this.markKeyBagFingerprintReconciled(await this.computeCurrentKeyBagFingerprint());
3316
+ // can skip the scan. A pass limited to some key series did not
3317
+ // look at the other documents, so it proves nothing about them.
3318
+ if (!keyIds) {
3319
+ this.markKeyBagFingerprintReconciled(await this.computeCurrentKeyBagFingerprint());
3320
+ }
3305
3321
  }
3306
3322
  /**
3307
3323
  * Re-materialize documents whose entries were previously skipped because the
@@ -5317,16 +5333,23 @@ class BaseMindooDB {
5317
5333
  }
5318
5334
  /**
5319
5335
  * After a pass that changed access to a key series (added to or removed from a
5320
- * group document), reveal or hide the documents that use it. Runs the full key
5321
- * visibility reconcile, which is rare enough: it only happens when this
5322
- * replica's membership in a group changed.
5336
+ * group document), reveal or hide the documents that use it.
5337
+ *
5338
+ * Only the documents of the changed key series are reconciled. A fresh session
5339
+ * starts with an empty sealed-key cache, so every sealed document in the
5340
+ * open-time delta "gains" its key here; a reconcile of every document then
5341
+ * unwrapped the recipient block of each sealed document in the database (one
5342
+ * RSA decryption each), which made opening a database with thousands of
5343
+ * per-document sealed documents (a mail store) take many seconds, again after
5344
+ * almost every sync batch.
5323
5345
  */
5324
5346
  async reconcileGroupKeyAccess() {
5325
5347
  if (this.groupKeyAccessChanged.size === 0 || this.isTimeTravelMode())
5326
5348
  return;
5349
+ const keyIds = new Set(this.groupKeyAccessChanged);
5327
5350
  this.groupKeyAccessChanged.clear();
5328
5351
  this.groupKeyMisses.clear();
5329
- await this.reconcileKeyVisibility();
5352
+ await this.reconcileKeyVisibilityOf(keyIds);
5330
5353
  this.groupKeyAccessChanged.clear();
5331
5354
  }
5332
5355
  /**