mindoodb 0.0.97 → 0.0.98

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 (125) hide show
  1. package/README.md +1 -0
  2. package/dist/appendonlystores/network/ClientNetworkContentAddressedStore.d.ts +7 -0
  3. package/dist/appendonlystores/network/ClientNetworkContentAddressedStore.d.ts.map +1 -1
  4. package/dist/appendonlystores/network/ClientNetworkContentAddressedStore.js +17 -9
  5. package/dist/appendonlystores/network/ClientNetworkContentAddressedStore.js.map +1 -1
  6. package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.d.ts +12 -0
  7. package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.d.ts.map +1 -1
  8. package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.js +19 -0
  9. package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.js.map +1 -1
  10. package/dist/browser/index.mjs +70 -0
  11. package/dist/core/BaseMindooDB.d.ts +2 -0
  12. package/dist/core/BaseMindooDB.d.ts.map +1 -1
  13. package/dist/core/BaseMindooDB.js +73 -53
  14. package/dist/core/BaseMindooDB.js.map +1 -1
  15. package/dist/core/BaseMindooTenant.d.ts +33 -1
  16. package/dist/core/BaseMindooTenant.d.ts.map +1 -1
  17. package/dist/core/BaseMindooTenant.js +141 -41
  18. package/dist/core/BaseMindooTenant.js.map +1 -1
  19. package/dist/core/BaseMindooTenantDirectory.d.ts +11 -0
  20. package/dist/core/BaseMindooTenantDirectory.d.ts.map +1 -1
  21. package/dist/core/BaseMindooTenantDirectory.js +137 -92
  22. package/dist/core/BaseMindooTenantDirectory.js.map +1 -1
  23. package/dist/core/builtinDbInvariants.d.ts +26 -1
  24. package/dist/core/builtinDbInvariants.d.ts.map +1 -1
  25. package/dist/core/builtinDbInvariants.js +52 -2
  26. package/dist/core/builtinDbInvariants.js.map +1 -1
  27. package/dist/core/index.d.ts +2 -0
  28. package/dist/core/index.d.ts.map +1 -1
  29. package/dist/core/index.js +3 -0
  30. package/dist/core/index.js.map +1 -1
  31. package/dist/core/joinrequests/crypto.d.ts +110 -0
  32. package/dist/core/joinrequests/crypto.d.ts.map +1 -0
  33. package/dist/core/joinrequests/crypto.js +340 -0
  34. package/dist/core/joinrequests/crypto.js.map +1 -0
  35. package/dist/core/joinrequests/index.d.ts +4 -0
  36. package/dist/core/joinrequests/index.d.ts.map +1 -0
  37. package/dist/core/joinrequests/index.js +29 -0
  38. package/dist/core/joinrequests/index.js.map +1 -0
  39. package/dist/core/joinrequests/invitations.d.ts +257 -0
  40. package/dist/core/joinrequests/invitations.d.ts.map +1 -0
  41. package/dist/core/joinrequests/invitations.js +703 -0
  42. package/dist/core/joinrequests/invitations.js.map +1 -0
  43. package/dist/core/joinrequests/types.d.ts +208 -0
  44. package/dist/core/joinrequests/types.d.ts.map +1 -0
  45. package/dist/core/joinrequests/types.js +43 -0
  46. package/dist/core/joinrequests/types.js.map +1 -0
  47. package/dist/core/recovery/PaperRescueDevice.d.ts +92 -0
  48. package/dist/core/recovery/PaperRescueDevice.d.ts.map +1 -0
  49. package/dist/core/recovery/PaperRescueDevice.js +182 -0
  50. package/dist/core/recovery/PaperRescueDevice.js.map +1 -0
  51. package/dist/core/recovery/RecoveryContactsDocument.d.ts +91 -0
  52. package/dist/core/recovery/RecoveryContactsDocument.d.ts.map +1 -0
  53. package/dist/core/recovery/RecoveryContactsDocument.js +92 -0
  54. package/dist/core/recovery/RecoveryContactsDocument.js.map +1 -0
  55. package/dist/core/recovery/RecoveryContactsManager.d.ts +95 -0
  56. package/dist/core/recovery/RecoveryContactsManager.d.ts.map +1 -0
  57. package/dist/core/recovery/RecoveryContactsManager.js +322 -0
  58. package/dist/core/recovery/RecoveryContactsManager.js.map +1 -0
  59. package/dist/core/recovery/index.d.ts +8 -0
  60. package/dist/core/recovery/index.d.ts.map +1 -0
  61. package/dist/core/recovery/index.js +41 -0
  62. package/dist/core/recovery/index.js.map +1 -0
  63. package/dist/core/recovery/recoverWithContacts.d.ts +36 -0
  64. package/dist/core/recovery/recoverWithContacts.d.ts.map +1 -0
  65. package/dist/core/recovery/recoverWithContacts.js +103 -0
  66. package/dist/core/recovery/recoverWithContacts.js.map +1 -0
  67. package/dist/core/recovery/recoveryPackage.d.ts +72 -0
  68. package/dist/core/recovery/recoveryPackage.d.ts.map +1 -0
  69. package/dist/core/recovery/recoveryPackage.js +181 -0
  70. package/dist/core/recovery/recoveryPackage.js.map +1 -0
  71. package/dist/core/recovery/rescueDevice.d.ts +51 -0
  72. package/dist/core/recovery/rescueDevice.d.ts.map +1 -0
  73. package/dist/core/recovery/rescueDevice.js +201 -0
  74. package/dist/core/recovery/rescueDevice.js.map +1 -0
  75. package/dist/core/recovery/shamir.d.ts +30 -0
  76. package/dist/core/recovery/shamir.d.ts.map +1 -0
  77. package/dist/core/recovery/shamir.js +133 -0
  78. package/dist/core/recovery/shamir.js.map +1 -0
  79. package/dist/core/types.d.ts +64 -1
  80. package/dist/core/types.d.ts.map +1 -1
  81. package/dist/core/types.js.map +1 -1
  82. package/dist/core/userkeys/UserKeyManager.d.ts +29 -0
  83. package/dist/core/userkeys/UserKeyManager.d.ts.map +1 -1
  84. package/dist/core/userkeys/UserKeyManager.js +76 -8
  85. package/dist/core/userkeys/UserKeyManager.js.map +1 -1
  86. package/dist/core/userkeys/generationSignature.d.ts +6 -0
  87. package/dist/core/userkeys/generationSignature.d.ts.map +1 -1
  88. package/dist/core/userkeys/generationSignature.js +1 -0
  89. package/dist/core/userkeys/generationSignature.js.map +1 -1
  90. package/dist/core/userkeys/resolveUserKeyDocument.d.ts.map +1 -1
  91. package/dist/core/userkeys/resolveUserKeyDocument.js +6 -6
  92. package/dist/core/userkeys/resolveUserKeyDocument.js.map +1 -1
  93. package/dist/core/userkeys/validateUserKeyDocument.d.ts +11 -1
  94. package/dist/core/userkeys/validateUserKeyDocument.d.ts.map +1 -1
  95. package/dist/core/userkeys/validateUserKeyDocument.js +18 -5
  96. package/dist/core/userkeys/validateUserKeyDocument.js.map +1 -1
  97. package/dist/node/server/MindooDBServer.d.ts +2 -0
  98. package/dist/node/server/MindooDBServer.d.ts.map +1 -1
  99. package/dist/node/server/MindooDBServer.js +46 -0
  100. package/dist/node/server/MindooDBServer.js.map +1 -1
  101. package/dist/node/server/StoreFactory.d.ts.map +1 -1
  102. package/dist/node/server/StoreFactory.js +4 -1
  103. package/dist/node/server/StoreFactory.js.map +1 -1
  104. package/dist/node/server/server.js +2 -0
  105. package/dist/node/server/server.js.map +1 -1
  106. package/dist/server/JoinRequestService.d.ts +108 -0
  107. package/dist/server/JoinRequestService.d.ts.map +1 -0
  108. package/dist/server/JoinRequestService.js +454 -0
  109. package/dist/server/JoinRequestService.js.map +1 -0
  110. package/dist/server/TenantManager.d.ts +50 -0
  111. package/dist/server/TenantManager.d.ts.map +1 -1
  112. package/dist/server/TenantManager.js +271 -33
  113. package/dist/server/TenantManager.js.map +1 -1
  114. package/dist/server/http/MindooDBServerCore.d.ts +18 -0
  115. package/dist/server/http/MindooDBServerCore.d.ts.map +1 -1
  116. package/dist/server/http/MindooDBServerCore.js +229 -137
  117. package/dist/server/http/MindooDBServerCore.js.map +1 -1
  118. package/dist/server/serverConfig.d.ts.map +1 -1
  119. package/dist/server/serverConfig.js +17 -0
  120. package/dist/server/serverConfig.js.map +1 -1
  121. package/dist/server/types.d.ts +15 -0
  122. package/dist/server/types.d.ts.map +1 -1
  123. package/dist/server/types.js +6 -0
  124. package/dist/server/types.js.map +1 -1
  125. package/package.json +1 -1
@@ -12,9 +12,10 @@ const storeEntryTime_1 = require("./storeEntryTime");
12
12
  const changeAttribution_1 = require("./changeAttribution");
13
13
  const types_1 = require("./types");
14
14
  const types_2 = require("./types");
15
- const types_3 = require("./appendonlystores/types");
15
+ const types_3 = require("./joinrequests/types");
16
+ const types_4 = require("./appendonlystores/types");
16
17
  const syncStores_1 = require("./appendonlystores/syncStores");
17
- const types_4 = require("./appendonlystores/network/types");
18
+ const types_5 = require("./appendonlystores/network/types");
18
19
  const MaterializationPlanner_1 = require("./appendonlystores/MaterializationPlanner");
19
20
  const DocumentDagAnalysis_1 = require("./DocumentDagAnalysis");
20
21
  const DocumentConflictAnalysis_1 = require("./DocumentConflictAnalysis");
@@ -37,10 +38,10 @@ const builtinDbInvariants_1 = require("./builtinDbInvariants");
37
38
  const recipients_1 = require("./userkeys/recipients");
38
39
  const sealedTypes_1 = require("./userkeys/sealedTypes");
39
40
  const DocumentSummaryStore_1 = require("./indexing/summary/DocumentSummaryStore");
40
- const types_5 = require("./indexing/summary/types");
41
+ const types_6 = require("./indexing/summary/types");
41
42
  const DocumentFullTextIndex_1 = require("./indexing/fulltext/DocumentFullTextIndex");
42
- const types_6 = require("./indexing/fulltext/types");
43
- const types_7 = require("./extraction/types");
43
+ const types_7 = require("./indexing/fulltext/types");
44
+ const types_8 = require("./extraction/types");
44
45
  const executeQuery_1 = require("./query/executeQuery");
45
46
  const queryView_1 = require("./query/queryView");
46
47
  const queryLive_1 = require("./query/queryLive");
@@ -121,7 +122,7 @@ function networkErrorType(error) {
121
122
  * server's `Retry-After` when it asks for a longer wait than our backoff.
122
123
  */
123
124
  function rateLimitRetryDelayMs(error, attempt) {
124
- if (networkErrorType(error) !== types_4.NetworkErrorType.RATE_LIMITED ||
125
+ if (networkErrorType(error) !== types_5.NetworkErrorType.RATE_LIMITED ||
125
126
  attempt >= PREFETCH_RATE_LIMIT_DELAYS_MS.length) {
126
127
  return null;
127
128
  }
@@ -643,11 +644,11 @@ class BaseMindooDB {
643
644
  if (store.getId() !== attachmentStore.getId()) {
644
645
  throw new Error(`[BaseMindooDB] Expected document and attachment stores to share dbId but received ${store.getId()} and ${attachmentStore.getId()}`);
645
646
  }
646
- if (store.getStoreKind() !== types_3.StoreKind.docs) {
647
- throw new Error(`[BaseMindooDB] Expected primary store kind ${types_3.StoreKind.docs} but received ${store.getStoreKind()}`);
647
+ if (store.getStoreKind() !== types_4.StoreKind.docs) {
648
+ throw new Error(`[BaseMindooDB] Expected primary store kind ${types_4.StoreKind.docs} but received ${store.getStoreKind()}`);
648
649
  }
649
- if (attachmentStore.getStoreKind() !== types_3.StoreKind.attachments) {
650
- throw new Error(`[BaseMindooDB] Expected attachment store kind ${types_3.StoreKind.attachments} but received ${attachmentStore.getStoreKind()}`);
650
+ if (attachmentStore.getStoreKind() !== types_4.StoreKind.attachments) {
651
+ throw new Error(`[BaseMindooDB] Expected attachment store kind ${types_4.StoreKind.attachments} but received ${attachmentStore.getStoreKind()}`);
651
652
  }
652
653
  this.tenant = tenant;
653
654
  this.store = store;
@@ -780,6 +781,9 @@ class BaseMindooDB {
780
781
  if (signerIsAdmin && !this.isAdminKey(signerPublicKey)) {
781
782
  this.tenant.noteLocalSigningKey(signerPublicKey);
782
783
  }
784
+ const signerIsJoinRequestServer = dbId === types_3.JOIN_REQUESTS_DB_ID
785
+ ? await this.tenant.isJoinRequestServerKey(signerPublicKey)
786
+ : false;
783
787
  const decision = (0, builtinDbInvariants_1.evaluateBuiltinWrite)({
784
788
  dbId,
785
789
  op,
@@ -790,6 +794,7 @@ class BaseMindooDB {
790
794
  signerUsernameHash,
791
795
  docId,
792
796
  creatorUsernameHash,
797
+ signerIsJoinRequestServer,
793
798
  });
794
799
  if (!decision.allowed) {
795
800
  throw new Error(decision.reason);
@@ -824,10 +829,15 @@ class BaseMindooDB {
824
829
  // lifecycle entries alive on this lenient path (the server enforced the
825
830
  // write), so the store lookup is skipped for everything else.
826
831
  const signerIsAdmin = dbId === types_1.DIRECTORY_DB_ID ||
832
+ dbId === types_3.JOIN_REQUESTS_DB_ID ||
827
833
  (dbId === types_1.USER_DIRECTORY_DB_ID && (entryType === "doc_delete" || entryType === "doc_undelete"))
828
834
  ? await this.builtinSignerIsAdmin(entry, { allowLocalUnwitnessed: true })
829
835
  : false;
836
+ const signerIsJoinRequestServer = dbId === types_3.JOIN_REQUESTS_DB_ID && !signerIsAdmin
837
+ ? await this.tenant.isJoinRequestServerKey(entry.createdByPublicKey)
838
+ : false;
830
839
  return (0, builtinDbInvariants_1.shouldSkipLoadedEntry)({
840
+ signerIsJoinRequestServer,
831
841
  dbId,
832
842
  entryType,
833
843
  signerKey: entry.createdByPublicKey,
@@ -920,6 +930,9 @@ class BaseMindooDB {
920
930
  signerUsernameHash,
921
931
  docId: entry.docId,
922
932
  creatorUsernameHash,
933
+ signerIsJoinRequestServer: dbId === types_3.JOIN_REQUESTS_DB_ID
934
+ ? await this.tenant.isJoinRequestServerKey(entry.createdByPublicKey)
935
+ : false,
923
936
  });
924
937
  return decision.allowed ? null : decision.reason;
925
938
  }
@@ -1190,8 +1203,8 @@ class BaseMindooDB {
1190
1203
  */
1191
1204
  async getSummarySetup() {
1192
1205
  try {
1193
- const doc = await this.getDocument(types_5.DB_SETUP_DOC_ID);
1194
- return (0, types_5.sanitizeSummaryConfig)(doc.getData()[types_5.SUMMARY_SETUP_FIELD]) ?? null;
1206
+ const doc = await this.getDocument(types_6.DB_SETUP_DOC_ID);
1207
+ return (0, types_6.sanitizeSummaryConfig)(doc.getData()[types_6.SUMMARY_SETUP_FIELD]) ?? null;
1195
1208
  }
1196
1209
  catch (error) {
1197
1210
  if (error instanceof errors_1.DocumentNotFoundError ||
@@ -1213,14 +1226,14 @@ class BaseMindooDB {
1213
1226
  * backfill — locally and, after sync, on every other replica.
1214
1227
  */
1215
1228
  async setSummarySetup(config) {
1216
- const doc = await this.createDocument({ id: types_5.DB_SETUP_DOC_ID });
1229
+ const doc = await this.createDocument({ id: types_6.DB_SETUP_DOC_ID });
1217
1230
  await this.changeDoc(doc, (d) => {
1218
1231
  const data = d.getData();
1219
1232
  if (config === null) {
1220
- delete data[types_5.SUMMARY_SETUP_FIELD];
1233
+ delete data[types_6.SUMMARY_SETUP_FIELD];
1221
1234
  }
1222
1235
  else {
1223
- data[types_5.SUMMARY_SETUP_FIELD] = (0, types_5.sanitizeSummaryConfig)(config) ?? {};
1236
+ data[types_6.SUMMARY_SETUP_FIELD] = (0, types_6.sanitizeSummaryConfig)(config) ?? {};
1224
1237
  }
1225
1238
  });
1226
1239
  }
@@ -1264,7 +1277,7 @@ class BaseMindooDB {
1264
1277
  this.store.getId() === types_1.USER_DIRECTORY_DB_ID) {
1265
1278
  return;
1266
1279
  }
1267
- const hasSetupChange = changes.some((change) => change.docId === types_5.DB_SETUP_DOC_ID);
1280
+ const hasSetupChange = changes.some((change) => change.docId === types_6.DB_SETUP_DOC_ID);
1268
1281
  if (!hasSetupChange && this.summarySetupProbed) {
1269
1282
  return;
1270
1283
  }
@@ -1354,8 +1367,8 @@ class BaseMindooDB {
1354
1367
  */
1355
1368
  async getFulltextSetup() {
1356
1369
  try {
1357
- const doc = await this.getDocument(types_5.DB_SETUP_DOC_ID);
1358
- return ((0, types_6.sanitizeFulltextConfig)(doc.getData()[types_6.FULLTEXT_SETUP_FIELD]) ?? null);
1370
+ const doc = await this.getDocument(types_6.DB_SETUP_DOC_ID);
1371
+ return ((0, types_7.sanitizeFulltextConfig)(doc.getData()[types_7.FULLTEXT_SETUP_FIELD]) ?? null);
1359
1372
  }
1360
1373
  catch (error) {
1361
1374
  if (error instanceof errors_1.DocumentNotFoundError ||
@@ -1379,19 +1392,19 @@ class BaseMindooDB {
1379
1392
  * resumable backfill — locally and, after sync, on every other replica.
1380
1393
  */
1381
1394
  async setFulltextSetup(config) {
1382
- const sanitized = config === null ? null : ((0, types_6.sanitizeFulltextConfig)(config) ?? {});
1395
+ const sanitized = config === null ? null : ((0, types_7.sanitizeFulltextConfig)(config) ?? {});
1383
1396
  const current = await this.getFulltextSetup();
1384
1397
  if (JSON.stringify(current) === JSON.stringify(sanitized)) {
1385
1398
  return;
1386
1399
  }
1387
- const doc = await this.createDocument({ id: types_5.DB_SETUP_DOC_ID });
1400
+ const doc = await this.createDocument({ id: types_6.DB_SETUP_DOC_ID });
1388
1401
  await this.changeDoc(doc, (d) => {
1389
1402
  const data = d.getData();
1390
1403
  if (sanitized === null) {
1391
- delete data[types_6.FULLTEXT_SETUP_FIELD];
1404
+ delete data[types_7.FULLTEXT_SETUP_FIELD];
1392
1405
  }
1393
1406
  else {
1394
- data[types_6.FULLTEXT_SETUP_FIELD] = sanitized;
1407
+ data[types_7.FULLTEXT_SETUP_FIELD] = sanitized;
1395
1408
  }
1396
1409
  });
1397
1410
  }
@@ -1405,8 +1418,8 @@ class BaseMindooDB {
1405
1418
  */
1406
1419
  async getExtractionSetup() {
1407
1420
  try {
1408
- const doc = await this.getDocument(types_5.DB_SETUP_DOC_ID);
1409
- return ((0, types_7.sanitizeExtractionConfig)(doc.getData()[types_7.EXTRACTION_SETUP_FIELD]) ?? null);
1421
+ const doc = await this.getDocument(types_6.DB_SETUP_DOC_ID);
1422
+ return ((0, types_8.sanitizeExtractionConfig)(doc.getData()[types_8.EXTRACTION_SETUP_FIELD]) ?? null);
1410
1423
  }
1411
1424
  catch (error) {
1412
1425
  if (error instanceof errors_1.DocumentNotFoundError ||
@@ -1426,19 +1439,19 @@ class BaseMindooDB {
1426
1439
  * without producing changefeed/sync churn.
1427
1440
  */
1428
1441
  async setExtractionSetup(config) {
1429
- const sanitized = config === null ? null : ((0, types_7.sanitizeExtractionConfig)(config) ?? {});
1442
+ const sanitized = config === null ? null : ((0, types_8.sanitizeExtractionConfig)(config) ?? {});
1430
1443
  const current = await this.getExtractionSetup();
1431
1444
  if (JSON.stringify(current) === JSON.stringify(sanitized)) {
1432
1445
  return;
1433
1446
  }
1434
- const doc = await this.createDocument({ id: types_5.DB_SETUP_DOC_ID });
1447
+ const doc = await this.createDocument({ id: types_6.DB_SETUP_DOC_ID });
1435
1448
  await this.changeDoc(doc, (d) => {
1436
1449
  const data = d.getData();
1437
1450
  if (sanitized === null) {
1438
- delete data[types_7.EXTRACTION_SETUP_FIELD];
1451
+ delete data[types_8.EXTRACTION_SETUP_FIELD];
1439
1452
  }
1440
1453
  else {
1441
- data[types_7.EXTRACTION_SETUP_FIELD] = sanitized;
1454
+ data[types_8.EXTRACTION_SETUP_FIELD] = sanitized;
1442
1455
  }
1443
1456
  });
1444
1457
  }
@@ -1506,7 +1519,7 @@ class BaseMindooDB {
1506
1519
  this.store.getId() === types_1.USER_DIRECTORY_DB_ID) {
1507
1520
  return;
1508
1521
  }
1509
- const hasSetupChange = changes.some((change) => change.docId === types_5.DB_SETUP_DOC_ID);
1522
+ const hasSetupChange = changes.some((change) => change.docId === types_6.DB_SETUP_DOC_ID);
1510
1523
  if (!hasSetupChange && this.fulltextSetupProbed) {
1511
1524
  return;
1512
1525
  }
@@ -2291,6 +2304,10 @@ class BaseMindooDB {
2291
2304
  * directory node covering that time, or the tenant admin key). Callers that
2292
2305
  * omit it keep the historical HEAD check via `validatePublicSigningKey`.
2293
2306
  */
2307
+ /** Entry signature check that knows this database (join-request trust, docs/invitations.md). */
2308
+ verifyEntrySignatureForDb(entry, encryptedData) {
2309
+ return this.tenant.verifyEntrySignature(entry, encryptedData, { dbId: this.store.getId() });
2310
+ }
2294
2311
  async getOrImportPublicKey(publicKey, trustedTime) {
2295
2312
  const directory = await this.tenant.openDirectory();
2296
2313
  let isTrusted = false;
@@ -2311,6 +2328,9 @@ class BaseMindooDB {
2311
2328
  else {
2312
2329
  isTrusted = await directory.validatePublicSigningKey(publicKey);
2313
2330
  }
2331
+ if (!isTrusted && this.store.getId() === types_3.JOIN_REQUESTS_DB_ID) {
2332
+ isTrusted = await this.tenant.isJoinRequestServerKey(publicKey);
2333
+ }
2314
2334
  if (!isTrusted) {
2315
2335
  this.logger.warn(`Public key not trusted: ${publicKey}`);
2316
2336
  return null;
@@ -5101,7 +5121,7 @@ class BaseMindooDB {
5101
5121
  this.logger.warn(`Admin-only DB: skipping snapshot ${snapshotData.id} not signed by admin key`);
5102
5122
  }
5103
5123
  else {
5104
- isValid = await this.tenant.verifyEntrySignature(snapshotData, snapshotData.encryptedData);
5124
+ isValid = await this.verifyEntrySignatureForDb(snapshotData, snapshotData.encryptedData);
5105
5125
  }
5106
5126
  if (!isValid) {
5107
5127
  this.logger.warn(`Invalid signature for snapshot ${snapshotData.id}, falling back to replay without snapshot`);
@@ -5148,7 +5168,7 @@ class BaseMindooDB {
5148
5168
  this.logger.warn(`Admin-only DB: skipping entry ${entryData.id} not signed by admin key`);
5149
5169
  continue;
5150
5170
  }
5151
- const isValid = await this.tenant.verifyEntrySignature(entryData, entryData.encryptedData);
5171
+ const isValid = await this.verifyEntrySignatureForDb(entryData, entryData.encryptedData);
5152
5172
  if (!isValid) {
5153
5173
  this.logger.warn(`Invalid signature for entry ${entryData.id}, skipping`);
5154
5174
  continue;
@@ -5393,7 +5413,7 @@ class BaseMindooDB {
5393
5413
  continue;
5394
5414
  }
5395
5415
  // Verify signature
5396
- const isValid = await this.tenant.verifyEntrySignature(entryData, entryData.encryptedData);
5416
+ const isValid = await this.verifyEntrySignatureForDb(entryData, entryData.encryptedData);
5397
5417
  if (!isValid) {
5398
5418
  this.logger.warn(`Invalid signature for entry ${entryData.id}, skipping`);
5399
5419
  continue;
@@ -5741,7 +5761,7 @@ class BaseMindooDB {
5741
5761
  windowEnd = i + windowMetas.length;
5742
5762
  const batch = await this.store.getEntries(windowMetas.map((r) => r.meta.id));
5743
5763
  const prepared = await Promise.all(batch.map(async (entry) => {
5744
- const isValid = await this.tenant.verifyEntrySignature(entry, entry.encryptedData);
5764
+ const isValid = await this.verifyEntrySignatureForDb(entry, entry.encryptedData);
5745
5765
  if (!isValid) {
5746
5766
  this.logger.warn(`Invalid signature for revision entry ${entry.id}, skipping`);
5747
5767
  return null;
@@ -5903,7 +5923,7 @@ class BaseMindooDB {
5903
5923
  this.logger.warn(`Admin-only DB: skipping snapshot ${snapshotData.id} not signed by admin key`);
5904
5924
  return null;
5905
5925
  }
5906
- const isValid = await this.tenant.verifyEntrySignature(snapshotData, snapshotData.encryptedData);
5926
+ const isValid = await this.verifyEntrySignatureForDb(snapshotData, snapshotData.encryptedData);
5907
5927
  if (!isValid) {
5908
5928
  this.logger.warn(`Invalid signature for snapshot ${snapshotData.id}, falling back to replay`);
5909
5929
  return null;
@@ -5943,7 +5963,7 @@ class BaseMindooDB {
5943
5963
  this.logger.warn(`Revision entry ${meta.id} not found in store, skipping`);
5944
5964
  continue;
5945
5965
  }
5946
- const isValid = await this.tenant.verifyEntrySignature(entryData, entryData.encryptedData);
5966
+ const isValid = await this.verifyEntrySignatureForDb(entryData, entryData.encryptedData);
5947
5967
  if (!isValid) {
5948
5968
  this.logger.warn(`Invalid signature for revision entry ${entryData.id}, skipping`);
5949
5969
  continue;
@@ -6006,7 +6026,7 @@ class BaseMindooDB {
6006
6026
  */
6007
6027
  async readStoreEntryAttribution(entry) {
6008
6028
  try {
6009
- if (!(await this.tenant.verifyEntrySignature(entry, entry.encryptedData))) {
6029
+ if (!(await this.verifyEntrySignatureForDb(entry, entry.encryptedData))) {
6010
6030
  return undefined;
6011
6031
  }
6012
6032
  const payload = await this.tenant.decryptPayload(entry.encryptedData, entry.decryptionKeyId);
@@ -6123,7 +6143,7 @@ class BaseMindooDB {
6123
6143
  result.set(metadata.id, null);
6124
6144
  continue;
6125
6145
  }
6126
- const isValid = await this.tenant.verifyEntrySignature(entry, entry.encryptedData);
6146
+ const isValid = await this.verifyEntrySignatureForDb(entry, entry.encryptedData);
6127
6147
  if (!isValid) {
6128
6148
  result.set(metadata.id, null);
6129
6149
  continue;
@@ -6503,7 +6523,7 @@ class BaseMindooDB {
6503
6523
  this.logger.warn(`Admin-only DB: skipping DAG details for ${entry.id} not signed by admin key`);
6504
6524
  }
6505
6525
  else {
6506
- isValid = await this.tenant.verifyEntrySignature(entry, entry.encryptedData);
6526
+ isValid = await this.verifyEntrySignatureForDb(entry, entry.encryptedData);
6507
6527
  }
6508
6528
  if (isValid) {
6509
6529
  const decryptedPayload = await this.tenant.decryptPayload(entry.encryptedData, entry.decryptionKeyId);
@@ -7216,7 +7236,7 @@ class BaseMindooDB {
7216
7236
  this.logger.warn(`Admin-only DB: skipping conflict analysis entry ${entry.id} not signed by admin key`);
7217
7237
  continue;
7218
7238
  }
7219
- const isValid = await this.tenant.verifyEntrySignature(entry, entry.encryptedData);
7239
+ const isValid = await this.verifyEntrySignatureForDb(entry, entry.encryptedData);
7220
7240
  if (!isValid) {
7221
7241
  this.logger.warn(`Invalid signature for conflict analysis entry ${entry.id}, skipping`);
7222
7242
  continue;
@@ -10163,7 +10183,7 @@ class BaseMindooDB {
10163
10183
  return await this.withRateLimitBackoff("entry prefetch", () => this.store.getEntries(ids));
10164
10184
  }
10165
10185
  catch (error) {
10166
- if (networkErrorType(error) !== types_4.NetworkErrorType.PAYLOAD_TOO_LARGE ||
10186
+ if (networkErrorType(error) !== types_5.NetworkErrorType.PAYLOAD_TOO_LARGE ||
10167
10187
  ids.length <= 1) {
10168
10188
  throw error;
10169
10189
  }
@@ -10606,7 +10626,7 @@ class BaseMindooDB {
10606
10626
  this.logger.warn(`Admin-only DB: skipping snapshot ${snapshotData.id} not signed by admin key`);
10607
10627
  }
10608
10628
  else {
10609
- isValid = await this.tenant.verifyEntrySignature(snapshotData, snapshotData.encryptedData);
10629
+ isValid = await this.verifyEntrySignatureForDb(snapshotData, snapshotData.encryptedData);
10610
10630
  }
10611
10631
  if (!isValid) {
10612
10632
  this.logger.warn(`Invalid signature for snapshot ${snapshotData.id}, falling back to replay without snapshot`);
@@ -10651,7 +10671,7 @@ class BaseMindooDB {
10651
10671
  this.logger.warn(`Admin-only DB: skipping entry ${entryData.id} not signed by admin key`);
10652
10672
  continue;
10653
10673
  }
10654
- const isValid = await this.tenant.verifyEntrySignature(entryData, entryData.encryptedData);
10674
+ const isValid = await this.verifyEntrySignatureForDb(entryData, entryData.encryptedData);
10655
10675
  if (!isValid) {
10656
10676
  this.logger.warn(`Invalid signature for entry ${entryData.id}, skipping`);
10657
10677
  continue;
@@ -12746,7 +12766,7 @@ class BaseMindooDB {
12746
12766
  // Verify signature against the encrypted snapshot (no decryption needed)
12747
12767
  // We sign the encrypted payload, so anyone can verify signatures without decryption keys
12748
12768
  const signatureStartedAt = Date.now();
12749
- isValid = await this.tenant.verifyEntrySignature(snapshotData, snapshotData.encryptedData);
12769
+ isValid = await this.verifyEntrySignatureForDb(snapshotData, snapshotData.encryptedData);
12750
12770
  signatureVerificationTime += Date.now() - signatureStartedAt;
12751
12771
  }
12752
12772
  if (!isValid) {
@@ -13256,7 +13276,7 @@ class BaseMindooDB {
13256
13276
  if (await this.shouldSkipLoadedEntryForBuiltin(chunk)) {
13257
13277
  throw new Error(`Admin-only DB: chunk ${chunk.id} not signed by admin key`);
13258
13278
  }
13259
- const isValid = await this.tenant.verifyEntrySignature(chunk, chunk.encryptedData);
13279
+ const isValid = await this.verifyEntrySignatureForDb(chunk, chunk.encryptedData);
13260
13280
  if (!isValid) {
13261
13281
  throw new Error(`Invalid signature for chunk ${chunk.id}`);
13262
13282
  }
@@ -13699,15 +13719,15 @@ class BaseMindooDB {
13699
13719
  * Resolve a sync target to a ContentAddressedStore.
13700
13720
  * Accepts either a raw store or a MindooDB instance (calls getStore()).
13701
13721
  */
13702
- getStoreForKind(storeKind = types_3.StoreKind.docs) {
13703
- return storeKind === types_3.StoreKind.attachments
13722
+ getStoreForKind(storeKind = types_4.StoreKind.docs) {
13723
+ return storeKind === types_4.StoreKind.attachments
13704
13724
  ? this.attachmentStore
13705
13725
  : this.store;
13706
13726
  }
13707
- resolveStore(remote, storeKind = types_3.StoreKind.docs) {
13727
+ resolveStore(remote, storeKind = types_4.StoreKind.docs) {
13708
13728
  if ("getStore" in remote &&
13709
13729
  typeof remote.getStore === "function") {
13710
- return storeKind === types_3.StoreKind.attachments
13730
+ return storeKind === types_4.StoreKind.attachments
13711
13731
  ? remote.getAttachmentStore()
13712
13732
  : remote.getStore();
13713
13733
  }
@@ -13955,7 +13975,7 @@ class BaseMindooDB {
13955
13975
  */
13956
13976
  async pullChangesFrom(remote, options) {
13957
13977
  this.assertWritable("pullChangesFrom");
13958
- const storeKind = options?.storeKind ?? types_3.StoreKind.docs;
13978
+ const storeKind = options?.storeKind ?? types_4.StoreKind.docs;
13959
13979
  const remoteStore = this.resolveStore(remote, storeKind);
13960
13980
  // Entries of documents purged by an admin-signed request are refused on the
13961
13981
  // way in, so a replica that has not executed the purge yet cannot hand the
@@ -13987,7 +14007,7 @@ class BaseMindooDB {
13987
14007
  // summary buffer / full-text index materialize and extract documents
13988
14008
  // while the next page is still on the wire, instead of all at once
13989
14009
  // after the transfer (see docs/adhoc-queries.md, "Cold start").
13990
- const syncResult = await this.syncEntriesFromStore(remoteStore, localStore, options, storeKind === types_3.StoreKind.docs
14010
+ const syncResult = await this.syncEntriesFromStore(remoteStore, localStore, options, storeKind === types_4.StoreKind.docs
13991
14011
  ? () => this.syncStoreChanges()
13992
14012
  : undefined);
13993
14013
  const transferredBytes = syncResult.transferredBytes ?? 0;
@@ -14003,7 +14023,7 @@ class BaseMindooDB {
14003
14023
  }
14004
14024
  if (syncResult.transferred === 0) {
14005
14025
  this.logger.debug(`No new entries to pull`);
14006
- if (storeKind === types_3.StoreKind.docs) {
14026
+ if (storeKind === types_4.StoreKind.docs) {
14007
14027
  await this.reconcileAfterDocsPull();
14008
14028
  }
14009
14029
  return {
@@ -14031,7 +14051,7 @@ class BaseMindooDB {
14031
14051
  cancelled: true,
14032
14052
  };
14033
14053
  }
14034
- if (storeKind === types_3.StoreKind.docs) {
14054
+ if (storeKind === types_4.StoreKind.docs) {
14035
14055
  await this.syncStoreChanges();
14036
14056
  await this.reconcileAfterDocsPull();
14037
14057
  }
@@ -14111,7 +14131,7 @@ class BaseMindooDB {
14111
14131
  */
14112
14132
  async pushChangesTo(remote, options) {
14113
14133
  this.assertWritable("pushChangesTo");
14114
- const storeKind = options?.storeKind ?? types_3.StoreKind.docs;
14134
+ const storeKind = options?.storeKind ?? types_4.StoreKind.docs;
14115
14135
  const localStore = this.getStoreForKind(storeKind);
14116
14136
  const remoteStore = this.resolveStore(remote, storeKind);
14117
14137
  if (localStore.getId() !== remoteStore.getId() ||