mindoodb 0.0.2 → 0.0.4

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 (305) hide show
  1. package/README-server.md +1001 -0
  2. package/README.md +89 -28
  3. package/dist/__mocks__/expo-standard-web-crypto.d.ts +10 -0
  4. package/dist/__mocks__/expo-standard-web-crypto.d.ts.map +1 -0
  5. package/dist/__mocks__/expo-standard-web-crypto.js +22 -0
  6. package/dist/__mocks__/expo-standard-web-crypto.js.map +1 -0
  7. package/dist/appendonlystores/BasicOnDiskContentAddressedStoreFactory.d.ts +8 -0
  8. package/dist/appendonlystores/BasicOnDiskContentAddressedStoreFactory.d.ts.map +1 -0
  9. package/dist/appendonlystores/BasicOnDiskContentAddressedStoreFactory.js +16 -0
  10. package/dist/appendonlystores/BasicOnDiskContentAddressedStoreFactory.js.map +1 -0
  11. package/dist/appendonlystores/InMemoryContentAddressedStoreFactory.d.ts +1 -1
  12. package/dist/appendonlystores/InMemoryContentAddressedStoreFactory.d.ts.map +1 -1
  13. package/dist/appendonlystores/InMemoryContentAddressedStoreFactory.js +2 -2
  14. package/dist/appendonlystores/InMemoryContentAddressedStoreFactory.js.map +1 -1
  15. package/dist/appendonlystores/network/ClientNetworkContentAddressedStore.d.ts +30 -1
  16. package/dist/appendonlystores/network/ClientNetworkContentAddressedStore.d.ts.map +1 -1
  17. package/dist/appendonlystores/network/ClientNetworkContentAddressedStore.js +152 -5
  18. package/dist/appendonlystores/network/ClientNetworkContentAddressedStore.js.map +1 -1
  19. package/dist/appendonlystores/network/HttpTransport.d.ts +17 -2
  20. package/dist/appendonlystores/network/HttpTransport.d.ts.map +1 -1
  21. package/dist/appendonlystores/network/HttpTransport.js +129 -0
  22. package/dist/appendonlystores/network/HttpTransport.js.map +1 -1
  23. package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.d.ts +22 -2
  24. package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.d.ts.map +1 -1
  25. package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.js +110 -0
  26. package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.js.map +1 -1
  27. package/dist/appendonlystores/network/index.d.ts +1 -1
  28. package/dist/appendonlystores/network/index.d.ts.map +1 -1
  29. package/dist/appendonlystores/network/index.js.map +1 -1
  30. package/dist/browser/appendonlystores/IndexedDBContentAddressedStore.d.ts +65 -0
  31. package/dist/browser/appendonlystores/IndexedDBContentAddressedStore.d.ts.map +1 -0
  32. package/dist/browser/appendonlystores/IndexedDBContentAddressedStore.js +741 -0
  33. package/dist/browser/appendonlystores/IndexedDBContentAddressedStore.js.map +1 -0
  34. package/dist/browser/appendonlystores/IndexedDBContentAddressedStoreFactory.d.ts +25 -0
  35. package/dist/browser/appendonlystores/IndexedDBContentAddressedStoreFactory.d.ts.map +1 -0
  36. package/dist/browser/appendonlystores/IndexedDBContentAddressedStoreFactory.js +41 -0
  37. package/dist/browser/appendonlystores/IndexedDBContentAddressedStoreFactory.js.map +1 -0
  38. package/dist/browser/cache/IndexedDBLocalCacheStore.d.ts +21 -0
  39. package/dist/browser/cache/IndexedDBLocalCacheStore.d.ts.map +1 -0
  40. package/dist/browser/cache/IndexedDBLocalCacheStore.js +106 -0
  41. package/dist/browser/cache/IndexedDBLocalCacheStore.js.map +1 -0
  42. package/dist/browser/index.d.ts +8 -0
  43. package/dist/browser/index.d.ts.map +1 -1
  44. package/dist/browser/index.js +21 -1
  45. package/dist/browser/index.js.map +1 -1
  46. package/dist/core/BaseMindooDB.d.ts +115 -13
  47. package/dist/core/BaseMindooDB.d.ts.map +1 -1
  48. package/dist/core/BaseMindooDB.js +1232 -269
  49. package/dist/core/BaseMindooDB.js.map +1 -1
  50. package/dist/core/BaseMindooTenant.d.ts +69 -6
  51. package/dist/core/BaseMindooTenant.d.ts.map +1 -1
  52. package/dist/core/BaseMindooTenant.js +302 -109
  53. package/dist/core/BaseMindooTenant.js.map +1 -1
  54. package/dist/core/BaseMindooTenantDirectory.d.ts +13 -10
  55. package/dist/core/BaseMindooTenantDirectory.d.ts.map +1 -1
  56. package/dist/core/BaseMindooTenantDirectory.js +144 -27
  57. package/dist/core/BaseMindooTenantDirectory.js.map +1 -1
  58. package/dist/core/BaseMindooTenantFactory.d.ts +27 -29
  59. package/dist/core/BaseMindooTenantFactory.d.ts.map +1 -1
  60. package/dist/core/BaseMindooTenantFactory.js +185 -112
  61. package/dist/core/BaseMindooTenantFactory.js.map +1 -1
  62. package/dist/core/MindooDBServerAdmin.d.ts +238 -0
  63. package/dist/core/MindooDBServerAdmin.d.ts.map +1 -0
  64. package/dist/core/MindooDBServerAdmin.js +345 -0
  65. package/dist/core/MindooDBServerAdmin.js.map +1 -0
  66. package/dist/core/appendonlystores/BasicOnDiskContentAddressedStore.d.ts +68 -0
  67. package/dist/core/appendonlystores/BasicOnDiskContentAddressedStore.d.ts.map +1 -0
  68. package/dist/core/appendonlystores/BasicOnDiskContentAddressedStore.js +659 -0
  69. package/dist/core/appendonlystores/BasicOnDiskContentAddressedStore.js.map +1 -0
  70. package/dist/core/appendonlystores/InMemoryContentAddressedStore.d.ts +45 -3
  71. package/dist/core/appendonlystores/InMemoryContentAddressedStore.d.ts.map +1 -1
  72. package/dist/core/appendonlystores/InMemoryContentAddressedStore.js +184 -23
  73. package/dist/core/appendonlystores/InMemoryContentAddressedStore.js.map +1 -1
  74. package/dist/core/appendonlystores/MaterializationPlanner.d.ts +49 -0
  75. package/dist/core/appendonlystores/MaterializationPlanner.d.ts.map +1 -0
  76. package/dist/core/appendonlystores/MaterializationPlanner.js +325 -0
  77. package/dist/core/appendonlystores/MaterializationPlanner.js.map +1 -0
  78. package/dist/core/appendonlystores/bloom.d.ts +85 -0
  79. package/dist/core/appendonlystores/bloom.d.ts.map +1 -0
  80. package/dist/core/appendonlystores/bloom.js +228 -0
  81. package/dist/core/appendonlystores/bloom.js.map +1 -0
  82. package/dist/core/appendonlystores/network/NetworkTransport.d.ts +37 -2
  83. package/dist/core/appendonlystores/network/NetworkTransport.d.ts.map +1 -1
  84. package/dist/core/appendonlystores/network/types.d.ts +12 -0
  85. package/dist/core/appendonlystores/network/types.d.ts.map +1 -1
  86. package/dist/core/appendonlystores/network/types.js.map +1 -1
  87. package/dist/core/appendonlystores/types.d.ts +206 -0
  88. package/dist/core/appendonlystores/types.d.ts.map +1 -1
  89. package/dist/core/automerge-adapter.d.ts +15 -0
  90. package/dist/core/automerge-adapter.d.ts.map +1 -0
  91. package/dist/core/automerge-adapter.js +73 -0
  92. package/dist/core/automerge-adapter.js.map +1 -0
  93. package/dist/core/cache/CacheManager.d.ts +75 -0
  94. package/dist/core/cache/CacheManager.d.ts.map +1 -0
  95. package/dist/core/cache/CacheManager.js +101 -0
  96. package/dist/core/cache/CacheManager.js.map +1 -0
  97. package/dist/core/cache/EncryptedLocalCacheStore.d.ts +41 -0
  98. package/dist/core/cache/EncryptedLocalCacheStore.d.ts.map +1 -0
  99. package/dist/core/cache/EncryptedLocalCacheStore.js +120 -0
  100. package/dist/core/cache/EncryptedLocalCacheStore.js.map +1 -0
  101. package/dist/core/cache/LocalCacheStore.d.ts +50 -0
  102. package/dist/core/cache/LocalCacheStore.d.ts.map +1 -0
  103. package/dist/core/cache/LocalCacheStore.js +39 -0
  104. package/dist/core/cache/LocalCacheStore.js.map +1 -0
  105. package/dist/core/crypto/pbkdf2Iterations.d.ts +12 -0
  106. package/dist/core/crypto/pbkdf2Iterations.d.ts.map +1 -0
  107. package/dist/core/crypto/pbkdf2Iterations.js +55 -0
  108. package/dist/core/crypto/pbkdf2Iterations.js.map +1 -0
  109. package/dist/core/crypto/privateKeyEncryption.d.ts +5 -0
  110. package/dist/core/crypto/privateKeyEncryption.d.ts.map +1 -0
  111. package/dist/core/crypto/privateKeyEncryption.js +87 -0
  112. package/dist/core/crypto/privateKeyEncryption.js.map +1 -0
  113. package/dist/core/index.d.ts +18 -6
  114. package/dist/core/index.d.ts.map +1 -1
  115. package/dist/core/index.js +42 -1
  116. package/dist/core/index.js.map +1 -1
  117. package/dist/core/indexing/virtualviews/MindooDBVirtualViewDataProvider.d.ts +4 -1
  118. package/dist/core/indexing/virtualviews/MindooDBVirtualViewDataProvider.d.ts.map +1 -1
  119. package/dist/core/indexing/virtualviews/MindooDBVirtualViewDataProvider.js +39 -11
  120. package/dist/core/indexing/virtualviews/MindooDBVirtualViewDataProvider.js.map +1 -1
  121. package/dist/core/indexing/virtualviews/ViewEntrySortKeyComparator.d.ts +1 -0
  122. package/dist/core/indexing/virtualviews/ViewEntrySortKeyComparator.d.ts.map +1 -1
  123. package/dist/core/indexing/virtualviews/ViewEntrySortKeyComparator.js +3 -0
  124. package/dist/core/indexing/virtualviews/ViewEntrySortKeyComparator.js.map +1 -1
  125. package/dist/core/indexing/virtualviews/VirtualView.d.ts +43 -0
  126. package/dist/core/indexing/virtualviews/VirtualView.d.ts.map +1 -1
  127. package/dist/core/indexing/virtualviews/VirtualView.js +173 -0
  128. package/dist/core/indexing/virtualviews/VirtualView.js.map +1 -1
  129. package/dist/core/indexing/virtualviews/VirtualViewEntryData.d.ts +7 -0
  130. package/dist/core/indexing/virtualviews/VirtualViewEntryData.d.ts.map +1 -1
  131. package/dist/core/indexing/virtualviews/VirtualViewEntryData.js +28 -0
  132. package/dist/core/indexing/virtualviews/VirtualViewEntryData.js.map +1 -1
  133. package/dist/core/keys/KeyBag.d.ts +56 -12
  134. package/dist/core/keys/KeyBag.d.ts.map +1 -1
  135. package/dist/core/keys/KeyBag.js +156 -70
  136. package/dist/core/keys/KeyBag.js.map +1 -1
  137. package/dist/core/keys/KeyContext.d.ts +4 -0
  138. package/dist/core/keys/KeyContext.d.ts.map +1 -0
  139. package/dist/core/keys/KeyContext.js +17 -0
  140. package/dist/core/keys/KeyContext.js.map +1 -0
  141. package/dist/core/types.d.ts +512 -60
  142. package/dist/core/types.d.ts.map +1 -1
  143. package/dist/core/types.js +9 -1
  144. package/dist/core/types.js.map +1 -1
  145. package/dist/core/uri/MindooURI.d.ts +58 -0
  146. package/dist/core/uri/MindooURI.d.ts.map +1 -0
  147. package/dist/core/uri/MindooURI.js +169 -0
  148. package/dist/core/uri/MindooURI.js.map +1 -0
  149. package/dist/core/userid/index.d.ts +0 -10
  150. package/dist/core/userid/index.d.ts.map +1 -1
  151. package/dist/core/utils/idGeneration.d.ts.map +1 -1
  152. package/dist/core/utils/idGeneration.js +37 -3
  153. package/dist/core/utils/idGeneration.js.map +1 -1
  154. package/dist/node/appendonlystores/BasicOnDiskContentAddressedStore.d.ts +544 -0
  155. package/dist/node/appendonlystores/BasicOnDiskContentAddressedStore.d.ts.map +1 -0
  156. package/dist/node/appendonlystores/BasicOnDiskContentAddressedStore.js +1358 -0
  157. package/dist/node/appendonlystores/BasicOnDiskContentAddressedStore.js.map +1 -0
  158. package/dist/node/attachments/writeAttachmentToFile.d.ts +15 -0
  159. package/dist/node/attachments/writeAttachmentToFile.d.ts.map +1 -0
  160. package/dist/node/attachments/writeAttachmentToFile.js +73 -0
  161. package/dist/node/attachments/writeAttachmentToFile.js.map +1 -0
  162. package/dist/node/cache/FileSystemLocalCacheStore.d.ts +17 -0
  163. package/dist/node/cache/FileSystemLocalCacheStore.d.ts.map +1 -0
  164. package/dist/node/cache/FileSystemLocalCacheStore.js +128 -0
  165. package/dist/node/cache/FileSystemLocalCacheStore.js.map +1 -0
  166. package/dist/node/cli/change-identity-password.d.ts +7 -0
  167. package/dist/node/cli/change-identity-password.d.ts.map +1 -0
  168. package/dist/node/cli/change-identity-password.js +67 -0
  169. package/dist/node/cli/change-identity-password.js.map +1 -0
  170. package/dist/node/cli/cli-utils.d.ts +16 -0
  171. package/dist/node/cli/cli-utils.d.ts.map +1 -0
  172. package/dist/node/cli/cli-utils.js +113 -0
  173. package/dist/node/cli/cli-utils.js.map +1 -0
  174. package/dist/node/cli/identity-export-public.d.ts +4 -0
  175. package/dist/node/cli/identity-export-public.d.ts.map +1 -0
  176. package/dist/node/cli/identity-export-public.js +55 -0
  177. package/dist/node/cli/identity-export-public.js.map +1 -0
  178. package/dist/node/cli/identity-info.d.ts +4 -0
  179. package/dist/node/cli/identity-info.d.ts.map +1 -0
  180. package/dist/node/cli/identity-info.js +57 -0
  181. package/dist/node/cli/identity-info.js.map +1 -0
  182. package/dist/node/index.d.ts +2 -0
  183. package/dist/node/index.d.ts.map +1 -1
  184. package/dist/node/index.js +8 -1
  185. package/dist/node/index.js.map +1 -1
  186. package/dist/node/server/CapabilityMatcher.d.ts +45 -0
  187. package/dist/node/server/CapabilityMatcher.d.ts.map +1 -0
  188. package/dist/node/server/CapabilityMatcher.js +117 -0
  189. package/dist/node/server/CapabilityMatcher.js.map +1 -0
  190. package/dist/node/server/MindooDBServer.d.ts +87 -0
  191. package/dist/node/server/MindooDBServer.d.ts.map +1 -0
  192. package/dist/node/server/MindooDBServer.js +1040 -0
  193. package/dist/node/server/MindooDBServer.js.map +1 -0
  194. package/dist/node/server/ServerSync.d.ts +41 -0
  195. package/dist/node/server/ServerSync.d.ts.map +1 -0
  196. package/dist/node/server/ServerSync.js +187 -0
  197. package/dist/node/server/ServerSync.js.map +1 -0
  198. package/dist/node/server/StoreFactory.d.ts +45 -0
  199. package/dist/node/server/StoreFactory.d.ts.map +1 -0
  200. package/dist/node/server/StoreFactory.js +89 -0
  201. package/dist/node/server/StoreFactory.js.map +1 -0
  202. package/dist/node/server/SystemAdminAuth.d.ts +65 -0
  203. package/dist/node/server/SystemAdminAuth.d.ts.map +1 -0
  204. package/dist/node/server/SystemAdminAuth.js +200 -0
  205. package/dist/node/server/SystemAdminAuth.js.map +1 -0
  206. package/dist/node/server/SystemIpAllowlist.d.ts +21 -0
  207. package/dist/node/server/SystemIpAllowlist.d.ts.map +1 -0
  208. package/dist/node/server/SystemIpAllowlist.js +210 -0
  209. package/dist/node/server/SystemIpAllowlist.js.map +1 -0
  210. package/dist/node/server/TenantManager.d.ts +85 -0
  211. package/dist/node/server/TenantManager.d.ts.map +1 -0
  212. package/dist/node/server/TenantManager.js +493 -0
  213. package/dist/node/server/TenantManager.js.map +1 -0
  214. package/dist/node/server/add-to-network.d.ts +20 -0
  215. package/dist/node/server/add-to-network.d.ts.map +1 -0
  216. package/dist/node/server/add-to-network.js +275 -0
  217. package/dist/node/server/add-to-network.js.map +1 -0
  218. package/dist/node/server/config.d.ts +51 -0
  219. package/dist/node/server/config.d.ts.map +1 -0
  220. package/dist/node/server/config.js +218 -0
  221. package/dist/node/server/config.js.map +1 -0
  222. package/dist/node/server/resolveServerPassword.d.ts +7 -0
  223. package/dist/node/server/resolveServerPassword.d.ts.map +1 -0
  224. package/dist/node/server/resolveServerPassword.js +25 -0
  225. package/dist/node/server/resolveServerPassword.js.map +1 -0
  226. package/dist/node/server/server.d.ts +22 -0
  227. package/dist/node/server/server.d.ts.map +1 -0
  228. package/dist/node/server/server.js +225 -0
  229. package/dist/node/server/server.js.map +1 -0
  230. package/dist/node/server/serverinit.d.ts +21 -0
  231. package/dist/node/server/serverinit.d.ts.map +1 -0
  232. package/dist/node/server/serverinit.js +317 -0
  233. package/dist/node/server/serverinit.js.map +1 -0
  234. package/dist/node/server/types.d.ts +162 -0
  235. package/dist/node/server/types.d.ts.map +1 -0
  236. package/dist/node/server/types.js +24 -0
  237. package/dist/node/server/types.js.map +1 -0
  238. package/dist/node/server/validation.d.ts +47 -0
  239. package/dist/node/server/validation.d.ts.map +1 -0
  240. package/dist/node/server/validation.js +114 -0
  241. package/dist/node/server/validation.js.map +1 -0
  242. package/dist/reactnative/cache/MMKVLocalCacheStore.d.ts +48 -0
  243. package/dist/reactnative/cache/MMKVLocalCacheStore.d.ts.map +1 -0
  244. package/dist/reactnative/cache/MMKVLocalCacheStore.js +113 -0
  245. package/dist/reactnative/cache/MMKVLocalCacheStore.js.map +1 -0
  246. package/dist/reactnative/crypto/AESAdapter.d.ts +18 -0
  247. package/dist/reactnative/crypto/AESAdapter.d.ts.map +1 -0
  248. package/dist/reactnative/crypto/AESAdapter.js +112 -0
  249. package/dist/reactnative/crypto/AESAdapter.js.map +1 -0
  250. package/dist/reactnative/crypto/Ed25519Adapter.d.ts +34 -0
  251. package/dist/reactnative/crypto/Ed25519Adapter.d.ts.map +1 -0
  252. package/dist/reactnative/crypto/Ed25519Adapter.js +386 -0
  253. package/dist/reactnative/crypto/Ed25519Adapter.js.map +1 -0
  254. package/dist/reactnative/crypto/ExpoGoCryptoAdapter.d.ts +23 -0
  255. package/dist/reactnative/crypto/ExpoGoCryptoAdapter.d.ts.map +1 -0
  256. package/dist/reactnative/crypto/ExpoGoCryptoAdapter.js +51 -0
  257. package/dist/reactnative/crypto/ExpoGoCryptoAdapter.js.map +1 -0
  258. package/dist/reactnative/crypto/HMACAdapter.d.ts +13 -0
  259. package/dist/reactnative/crypto/HMACAdapter.d.ts.map +1 -0
  260. package/dist/reactnative/crypto/HMACAdapter.js +50 -0
  261. package/dist/reactnative/crypto/HMACAdapter.js.map +1 -0
  262. package/dist/reactnative/crypto/KeyFormatConverter.d.ts +21 -0
  263. package/dist/reactnative/crypto/KeyFormatConverter.d.ts.map +1 -0
  264. package/dist/reactnative/crypto/KeyFormatConverter.js +72 -0
  265. package/dist/reactnative/crypto/KeyFormatConverter.js.map +1 -0
  266. package/dist/reactnative/crypto/PBKDF2Adapter.d.ts +19 -0
  267. package/dist/reactnative/crypto/PBKDF2Adapter.d.ts.map +1 -0
  268. package/dist/reactnative/crypto/PBKDF2Adapter.js +67 -0
  269. package/dist/reactnative/crypto/PBKDF2Adapter.js.map +1 -0
  270. package/dist/reactnative/crypto/QuickCryptoAdapter.d.ts +37 -0
  271. package/dist/reactnative/crypto/QuickCryptoAdapter.d.ts.map +1 -0
  272. package/dist/reactnative/crypto/QuickCryptoAdapter.js +72 -0
  273. package/dist/reactnative/crypto/QuickCryptoAdapter.js.map +1 -0
  274. package/dist/reactnative/crypto/RSAAdapter.d.ts +38 -0
  275. package/dist/reactnative/crypto/RSAAdapter.d.ts.map +1 -0
  276. package/dist/reactnative/crypto/RSAAdapter.js +184 -0
  277. package/dist/reactnative/crypto/RSAAdapter.js.map +1 -0
  278. package/dist/reactnative/crypto/ReactNativeCryptoAdapter.d.ts +33 -0
  279. package/dist/reactnative/crypto/ReactNativeCryptoAdapter.d.ts.map +1 -0
  280. package/dist/reactnative/crypto/ReactNativeCryptoAdapter.js +61 -0
  281. package/dist/reactnative/crypto/ReactNativeCryptoAdapter.js.map +1 -0
  282. package/dist/reactnative/crypto/SHA256Adapter.d.ts +9 -0
  283. package/dist/reactnative/crypto/SHA256Adapter.d.ts.map +1 -0
  284. package/dist/reactnative/crypto/SHA256Adapter.js +29 -0
  285. package/dist/reactnative/crypto/SHA256Adapter.js.map +1 -0
  286. package/dist/reactnative/crypto/SubtleCryptoPolyfill.d.ts +63 -0
  287. package/dist/reactnative/crypto/SubtleCryptoPolyfill.d.ts.map +1 -0
  288. package/dist/reactnative/crypto/SubtleCryptoPolyfill.js +350 -0
  289. package/dist/reactnative/crypto/SubtleCryptoPolyfill.js.map +1 -0
  290. package/dist/reactnative/index.d.ts +9 -0
  291. package/dist/reactnative/index.d.ts.map +1 -0
  292. package/dist/reactnative/index.js +41 -0
  293. package/dist/reactnative/index.js.map +1 -0
  294. package/package.json +63 -7
  295. package/patches/PATCHES.md +111 -0
  296. package/patches/react-native+0.76.9.patch +34 -0
  297. package/patches/react-native-quick-crypto+1.0.7.patch +42 -0
  298. package/scripts/cli.js +21 -0
  299. package/scripts/setup-react-native.js +228 -0
  300. package/templates/reactnative/App.js +252 -0
  301. package/templates/reactnative/app.json +29 -0
  302. package/templates/reactnative/babel.config.js +6 -0
  303. package/templates/reactnative/index.js +26 -0
  304. package/templates/reactnative/metro.config.snippet.js +39 -0
  305. package/templates/reactnative/mindoodb-polyfills.js +116 -0
@@ -1,4 +1,5 @@
1
1
  import type { KeyBag } from "./keys/KeyBag";
2
+ import type { KeyType } from "./keys/KeyContext";
2
3
  import type { PublicUserId, PrivateUserId } from "./userid";
3
4
  import type { ContentAddressedStore, OpenStoreOptions } from "./appendonlystores/types";
4
5
  import type { CryptoAdapter } from "./crypto/CryptoAdapter";
@@ -7,8 +8,27 @@ import { MindooDocSigner } from "./crypto/MindooDocSigner";
7
8
  * Well-known key ID for access control documents (grantaccess, revokeaccess, groups).
8
9
  * All servers and clients MUST have this key in their KeyBag to verify user access.
9
10
  * This enables servers to validate users without having full tenant data access.
11
+ *
12
+ * KeyBag location: type "doc", id PUBLIC_INFOS_KEY_ID.
10
13
  */
11
14
  export declare const PUBLIC_INFOS_KEY_ID = "$publicinfos";
15
+ /**
16
+ * Well-known key ID for the tenant-wide default document encryption key.
17
+ *
18
+ * KeyBag location: type "doc", id DEFAULT_TENANT_KEY_ID.
19
+ */
20
+ export declare const DEFAULT_TENANT_KEY_ID = "default";
21
+ /**
22
+ * JSON payload returned by `GET /.well-known/mindoodb-server-info`.
23
+ */
24
+ export interface MindooDBServerInfo {
25
+ /** Canonical server name, typically a Notes/Domino-style DN. */
26
+ name: string;
27
+ /** Ed25519 public key in PEM format used for signing/auth verification. */
28
+ signingPublicKey: string;
29
+ /** RSA-OAEP public key in PEM format used for encryption. */
30
+ encryptionPublicKey: string;
31
+ }
12
32
  /**
13
33
  * An EncryptedPrivateKey is a private key that is encrypted with a password.
14
34
  * Used for both asymmetric keys (RSA, Ed25519, ECDH) and symmetric keys (AES-256).
@@ -59,48 +79,169 @@ export interface EncryptionKeyPair {
59
79
  privateKey: EncryptedPrivateKey;
60
80
  }
61
81
  export type { PublicUserId, PrivateUserId };
82
+ export type { KeyType };
62
83
  /**
63
- * A TenantFactory is a factory for creating and managing tenants.
84
+ * Options for opening a tenant.
64
85
  */
65
- export interface MindooTenantFactory {
86
+ export interface OpenTenantOptions {
66
87
  /**
67
- * Create a new tenant with a new tenant encryption key.
88
+ * Optional map of additional trusted signing public keys.
89
+ * Keys in this map are checked BEFORE the MindooTenantDirectory when
90
+ * validating public signing keys during signature verification.
68
91
  *
69
- * The tenant encryption key is used as the default document encryption key
70
- * (so that all data within the tenant is secure by default).
92
+ * Use case: server-to-server sync where trusted server identities are
93
+ * configured out-of-band (e.g. server-env.json) rather than registered
94
+ * in the directory database.
71
95
  *
72
- * The administration public key must be created beforehand using createSigningKeyPair()
73
- * and passed to this method. The administration key is used for administrative operations
74
- * within the tenant, such as adding new users to the tenant.
75
- *
76
- * The administration encryption public key must be created using createEncryptionKeyPair()
77
- * and is used to encrypt sensitive data in the directory that only admins can decrypt
78
- * (e.g., usernames in access control documents).
79
- *
80
- * @param tenantId The ID of the tenant
81
- * @param administrationPublicKey The administration public key (Ed25519, PEM format) created using createSigningKeyPair()
82
- * @param administrationEncryptionPublicKey The administration encryption public key (RSA-OAEP, PEM format) created using createEncryptionKeyPair()
83
- * @param tenantEncryptionKeyPassword The password to be set to decrypt the tenant encryption private key
84
- * @param currentUser The current user's private user ID (required for tenant operations)
85
- * @param currentUserPassword The password to decrypt the current user's private keys
86
- * @param keyBag The KeyBag instance for storing and loading named encrypted keys
87
- * @return The new tenant
96
+ * Map key: signing public key (Ed25519, PEM format)
97
+ * Map value: true if trusted, false if explicitly revoked
88
98
  */
89
- createTenant(tenantId: string, administrationPublicKey: string, administrationEncryptionPublicKey: string, tenantEncryptionKeyPassword: string, currentUser: PrivateUserId, currentUserPassword: string, keyBag: KeyBag): Promise<MindooTenant>;
99
+ additionalTrustedKeys?: ReadonlyMap<string, boolean>;
100
+ }
101
+ interface CreateTenantPasswords {
102
+ /** Password for the admin user's private keys */
103
+ adminPassword: string;
104
+ /** Password for the regular user's private keys */
105
+ userPassword: string;
106
+ }
107
+ /**
108
+ * Options for creating a new tenant with a single convenience call.
109
+ */
110
+ export type CreateTenantOptions = ({
111
+ /** Tenant identifier (e.g. "acme") */
112
+ tenantId: string;
113
+ /** Distinguished name for the admin user (e.g. "cn=admin/o=acme") */
114
+ adminName: string;
115
+ /** Distinguished name for the regular app user (e.g. "cn=alice/o=acme") */
116
+ userName: string;
117
+ } & CreateTenantPasswords) | ({
118
+ /** Tenant identifier (e.g. "acme") */
119
+ tenantId: string;
120
+ /** Existing admin private identity */
121
+ adminUser: PrivateUserId;
122
+ /** Existing regular app user private identity */
123
+ appUser: PrivateUserId;
124
+ } & CreateTenantPasswords);
125
+ /**
126
+ * Result of creating a new tenant via createTenant().
127
+ */
128
+ export interface CreateTenantResult {
129
+ /** The opened tenant, ready to use */
130
+ tenant: MindooTenant;
131
+ /** The admin user's private identity (contains signing + encryption key pairs) */
132
+ adminUser: PrivateUserId;
133
+ /** The regular app user's private identity */
134
+ appUser: PrivateUserId;
135
+ /** The KeyBag containing the tenant key and tenant-scoped doc keys */
136
+ keyBag: KeyBag;
137
+ }
138
+ /**
139
+ * A join request is created by a new user who wants to join a tenant.
140
+ * It contains only public information and is safe to share via any channel.
141
+ *
142
+ * Can be serialized to a mdb://join-request/... URI for out-of-band exchange.
143
+ */
144
+ export interface JoinRequest {
145
+ /** Protocol version (always 1 for now) */
146
+ v: 1;
147
+ /** The username the user wants to be registered as (e.g. "cn=user2/o=acme") */
148
+ username: string;
149
+ /** Ed25519 public signing key (PEM format) */
150
+ signingPublicKey: string;
151
+ /** RSA-OAEP public encryption key (PEM format) */
152
+ encryptionPublicKey: string;
153
+ }
154
+ /**
155
+ * Options for approving a join request.
156
+ */
157
+ export interface ApproveJoinRequestOptions {
158
+ /** The admin's encrypted private signing key */
159
+ adminSigningKey: EncryptedPrivateKey;
160
+ /** The password to decrypt the admin signing key */
161
+ adminPassword: string;
162
+ /** A shared password for encrypting the exported keys. Must be communicated out-of-band (e.g. phone). */
163
+ sharePassword: string;
164
+ /** Optional server URL to include in the response so the joining user knows where to sync */
165
+ serverUrl?: string;
166
+ /** If "uri", approveJoinRequest returns a mdb://join-response/... URI string instead of an object */
167
+ format?: "object" | "uri";
168
+ }
169
+ /**
170
+ * A join response is created by the admin after approving a join request.
171
+ * It contains encrypted symmetric keys and tenant metadata needed to join.
172
+ *
173
+ * Can be serialized to a mdb://join-response/... URI for out-of-band exchange.
174
+ * The encrypted keys can only be unlocked with the sharePassword communicated separately.
175
+ */
176
+ export interface JoinResponse {
177
+ /** Protocol version (always 1 for now) */
178
+ v: 1;
179
+ /** Tenant identifier */
180
+ tenantId: string;
181
+ /** Admin's public signing key (Ed25519, PEM) — needed to open the tenant */
182
+ adminSigningPublicKey: string;
183
+ /** Admin's public encryption key (RSA-OAEP, PEM) — needed to open the tenant */
184
+ adminEncryptionPublicKey: string;
185
+ /** Optional server URL for sync */
186
+ serverUrl?: string;
187
+ /** Tenant symmetric key, encrypted with the sharePassword */
188
+ encryptedTenantKey: EncryptedPrivateKey;
189
+ /** $publicinfos symmetric key, encrypted with the sharePassword */
190
+ encryptedPublicInfosKey: EncryptedPrivateKey;
191
+ }
192
+ /**
193
+ * Options for joining a tenant with a join response.
194
+ */
195
+ export interface JoinTenantOptions {
196
+ /** The user's locally-generated private identity (keys never leave this device) */
197
+ user: PrivateUserId;
198
+ /** The password for the user's private keys */
199
+ password: string;
200
+ /** The shared password used to decrypt the keys in the join response */
201
+ sharePassword: string;
202
+ }
203
+ /**
204
+ * Result of joining a tenant via joinTenant().
205
+ */
206
+ export interface JoinTenantResult {
207
+ /** The opened tenant, ready to use */
208
+ tenant: MindooTenant;
209
+ /** The KeyBag containing the imported tenant and $publicinfos keys */
210
+ keyBag: KeyBag;
211
+ }
212
+ /**
213
+ * Options for publishing a tenant to a server.
214
+ */
215
+ export interface PublishToServerOptions {
216
+ /** System admin identity (PrivateUserId) for challenge/response auth. */
217
+ systemAdminUser?: PrivateUserId;
218
+ /** Password to decrypt systemAdminUser's private keys. */
219
+ systemAdminPassword?: string;
220
+ /** Optional admin username for bootstrap handshake on the server */
221
+ adminUsername?: string;
222
+ /** Optional users to register on the server at the same time */
223
+ registerUsers?: PublicUserId[];
224
+ }
225
+ /**
226
+ * A TenantFactory is a factory for creating and managing tenants.
227
+ */
228
+ export interface MindooTenantFactory {
90
229
  /**
91
- * Opens an existing tenant with previously created keys.
230
+ * Opens an existing tenant.
92
231
  *
93
232
  * @param tenantId The ID of the tenant
94
- * @param tenantEncryptionPrivateKey The tenant encryption key (AES-256, encrypted)
95
- * @param tenantEncryptionKeyPassword The password to decrypt the tenant encryption key
96
233
  * @param administrationPublicKey The administration public key (Ed25519, PEM format)
97
234
  * @param administrationEncryptionPublicKey The administration encryption public key (RSA-OAEP, PEM format)
98
235
  * @param currentUser The current user's private user ID (required for tenant operations)
99
236
  * @param currentUserPassword The password to decrypt the current user's private keys
100
- * @param keyBag The KeyBag instance for storing and loading named encrypted keys
237
+ * @param keyBag The KeyBag instance for storing and loading tenant/doc keys.
238
+ * Must contain:
239
+ * - $publicinfos key under type "doc", tenant id tenantId, and id PUBLIC_INFOS_KEY_ID
240
+ * Optionally (required for decrypting regular database payloads):
241
+ * - tenant key under type "tenant" and id tenantId
101
242
  * @return The tenant
102
243
  */
103
- openTenantWithKeys(tenantId: string, tenantEncryptionPrivateKey: EncryptedPrivateKey, tenantEncryptionKeyPassword: string, administrationPublicKey: string, administrationEncryptionPublicKey: string, currentUser: PrivateUserId, currentUserPassword: string, keyBag: KeyBag): Promise<MindooTenant>;
244
+ openTenant(tenantId: string, administrationPublicKey: string, administrationEncryptionPublicKey: string, currentUser: PrivateUserId, currentUserPassword: string, keyBag: KeyBag, options?: OpenTenantOptions): Promise<MindooTenant>;
104
245
  /**
105
246
  * Creates a new user with separate signing and encryption key pairs.
106
247
  *
@@ -116,6 +257,15 @@ export interface MindooTenantFactory {
116
257
  * @return The public user ID
117
258
  */
118
259
  toPublicUserId(privateUserId: PrivateUserId): PublicUserId;
260
+ /**
261
+ * Re-encrypts an identity's private keys with a new password.
262
+ *
263
+ * @param identity The private identity to update
264
+ * @param oldPassword The current password
265
+ * @param newPassword The new password to protect both private keys
266
+ * @return A new PrivateUserId with unchanged public keys and re-encrypted private keys
267
+ */
268
+ changeIdentityPassword(identity: PrivateUserId, oldPassword: string, newPassword: string): Promise<PrivateUserId>;
119
269
  /**
120
270
  * Creates a new signing key pair for the tenant.
121
271
  * Returns both the public and encrypted private key, as the public key is needed
@@ -125,18 +275,6 @@ export interface MindooTenantFactory {
125
275
  * @return The signing key pair containing both public key (PEM format) and encrypted private key (Ed25519)
126
276
  */
127
277
  createSigningKeyPair(password: string): Promise<SigningKeyPair>;
128
- /**
129
- * Creates a new encrypted symmetric key (AES-256) for document encryption.
130
- * The key is encrypted with the provided password and can be distributed to authorized users.
131
- * Use KeyBag.decryptAndImportKey() to store the returned key in the user's KeyBag.
132
- *
133
- * Symmetric keys are shared secrets - anyone with the key can both encrypt and decrypt.
134
- * For user-to-user encryption where only the recipient can decrypt, use createEncryptionKeyPair() instead.
135
- *
136
- * @param password The password to encrypt the symmetric key with (mandatory)
137
- * @return The encrypted symmetric key that can be distributed to authorized users
138
- */
139
- createSymmetricEncryptedPrivateKey(password: string): Promise<EncryptedPrivateKey>;
140
278
  /**
141
279
  * Creates a new asymmetric encryption key pair (RSA-OAEP) for user-to-user encryption.
142
280
  * Returns both the public and encrypted private key.
@@ -149,6 +287,47 @@ export interface MindooTenantFactory {
149
287
  * @return The encryption key pair containing both public key (PEM format) and encrypted private key (RSA-OAEP)
150
288
  */
151
289
  createEncryptionKeyPair(password: string): Promise<EncryptionKeyPair>;
290
+ /**
291
+ * Create a new tenant with a single call. This orchestrates:
292
+ * 1. Creating the admin user identity
293
+ * 2. Creating the regular app user identity
294
+ * 3. Creating a KeyBag with tenant key and $publicinfos key
295
+ * 4. Opening the tenant
296
+ * 5. Registering the app user in the directory
297
+ *
298
+ * @param options Tenant creation options
299
+ * @return The created tenant, admin user, app user, and KeyBag
300
+ */
301
+ createTenant(options: CreateTenantOptions): Promise<CreateTenantResult>;
302
+ /**
303
+ * Create a join request from a user's private identity.
304
+ * The join request contains only public keys and is safe to share via any channel.
305
+ *
306
+ * @param user The user's private identity (only public keys are extracted)
307
+ * @param options Optional. Set format to "uri" to get a mdb://join-request/... URI string.
308
+ * @return A JoinRequest object or a mdb://join-request/... URI string
309
+ */
310
+ createJoinRequest(user: PrivateUserId, options?: {
311
+ format?: "object";
312
+ }): JoinRequest;
313
+ createJoinRequest(user: PrivateUserId, options: {
314
+ format: "uri";
315
+ }): string;
316
+ createJoinRequest(user: PrivateUserId, options?: {
317
+ format?: "object" | "uri";
318
+ }): JoinRequest | string;
319
+ /**
320
+ * Join a tenant using a join response from an admin.
321
+ * This orchestrates:
322
+ * 1. Parsing the join response (object or mdb:// URI string)
323
+ * 2. Creating a new KeyBag and importing the encrypted keys
324
+ * 3. Opening the tenant with the admin public keys from the response
325
+ *
326
+ * @param joinResponse A JoinResponse object or a mdb://join-response/... URI string
327
+ * @param options Options including the user's identity, password, and the shared password
328
+ * @return The opened tenant and KeyBag
329
+ */
330
+ joinTenant(joinResponse: JoinResponse | string, options: JoinTenantOptions): Promise<JoinTenantResult>;
152
331
  }
153
332
  /**
154
333
  * A MindooTenant contains multiple MindooDB in an organization. One MindooDB is a mandatory part
@@ -188,15 +367,6 @@ export interface MindooTenant {
188
367
  * @return The administration encryption public key (RSA-OAEP, PEM format)
189
368
  */
190
369
  getAdministrationEncryptionPublicKey(): string;
191
- /**
192
- * Returns the encryption key used to encrypt all communication in this tenant
193
- * (e.g. the document changesets).
194
- *
195
- * Note: This is a symmetric key (AES-256) used ONLY for encryption/decryption, not for signing.
196
- *
197
- * @return The tenant encryption key (AES-256, encrypted)
198
- */
199
- getTenantEncryptionKey(): EncryptedPrivateKey;
200
370
  /**
201
371
  * Encrypt a payload using the symmetric key identified by decryptionKeyId.
202
372
  * For "default", uses the tenant encryption key.
@@ -294,8 +464,45 @@ export interface MindooTenant {
294
464
  * @return The crypto adapter
295
465
  */
296
466
  getCryptoAdapter(): CryptoAdapter;
467
+ /**
468
+ * Approve a join request and produce a join response.
469
+ * This orchestrates:
470
+ * 1. Parsing the join request (object or mdb:// URI string)
471
+ * 2. Registering the user in the tenant directory
472
+ * 3. Exporting the tenant key and $publicinfos key, encrypted with the sharePassword
473
+ * 4. Packaging everything into a JoinResponse
474
+ *
475
+ * @param joinRequest A JoinRequest object or a mdb://join-request/... URI string
476
+ * @param options Options including admin key, share password, and optional server URL
477
+ * @return A JoinResponse object, or a mdb://join-response/... URI string if format is "uri"
478
+ */
479
+ approveJoinRequest(joinRequest: JoinRequest | string, options: ApproveJoinRequestOptions & {
480
+ format: "uri";
481
+ }): Promise<string>;
482
+ approveJoinRequest(joinRequest: JoinRequest | string, options: ApproveJoinRequestOptions): Promise<JoinResponse>;
483
+ /**
484
+ * Publish (register) this tenant on a MindooDB server.
485
+ * Sends an HTTP POST to the server's /admin/register-tenant endpoint
486
+ * with the admin public keys and optional initial users.
487
+ *
488
+ * @param serverUrl The base URL of the MindooDB server (e.g. "http://localhost:3000")
489
+ * @param options Optional API key and users to register
490
+ */
491
+ publishToServer(serverUrl: string, options?: PublishToServerOptions): Promise<void>;
492
+ /**
493
+ * Create a remote store connected to a MindooDB server, ready for sync.
494
+ * This orchestrates:
495
+ * 1. Creating an HttpTransport pointed at the server
496
+ * 2. Creating a ClientNetworkContentAddressedStore with the current user's keys
497
+ * 3. Returning the store for use with pullChangesFrom/pushChangesTo
498
+ *
499
+ * @param serverUrl The base URL of the MindooDB server (e.g. "http://localhost:3000")
500
+ * @param dbId The database ID to connect to (e.g. "todos")
501
+ * @return A ContentAddressedStore connected to the remote server
502
+ */
503
+ connectToServer(serverUrl: string, dbId: string): Promise<ContentAddressedStore>;
297
504
  }
298
- export type { ContentAddressedStore, ContentAddressedStoreFactory, CreateStoreResult, OpenStoreOptions } from "./appendonlystores/types";
505
+ export type { ContentAddressedStore, ContentAddressedStoreFactory, CreateStoreResult, OpenStoreOptions, StoreCompactionStatus, StoreScanCursor, StoreScanFilters, StoreScanResult, StoreIdBloomSummary, MaterializationPlanOptions, MaterializationPlanDiagnostics, DocumentMaterializationPlan, DocumentMaterializationBatchPlan, } from "./appendonlystores/types";
299
506
  /**
300
507
  * The type of entry stored in the ContentAddressedStore.
301
508
  * Entry types are prefixed to indicate their domain:
@@ -341,6 +548,18 @@ export interface StoreEntryMetadata {
341
548
  * - For attachment_chunk: Previous chunk's entry ID (enables append-only file growth)
342
549
  */
343
550
  dependencyIds: string[];
551
+ /**
552
+ * Optional causal coverage heads for snapshot entries.
553
+ * For `doc_snapshot`, this lists the Automerge head hashes represented by the snapshot.
554
+ * For other entry types this should be undefined.
555
+ */
556
+ snapshotHeadHashes?: string[];
557
+ /**
558
+ * Optional entry IDs corresponding to the snapshot heads.
559
+ * This allows stores to plan replay using metadata only, without decrypting payloads.
560
+ * For non-snapshot entries this should be undefined.
561
+ */
562
+ snapshotHeadEntryIds?: string[];
344
563
  /**
345
564
  * The timestamp when this entry was created (milliseconds since Unix epoch).
346
565
  */
@@ -441,6 +660,46 @@ export interface AttachmentConfig {
441
660
  */
442
661
  chunkSizeBytes?: number;
443
662
  }
663
+ /**
664
+ * Configuration for the in-memory document cache.
665
+ */
666
+ export interface DocumentCacheConfig {
667
+ /**
668
+ * Maximum number of fully materialized documents kept in memory at once.
669
+ * Dirty documents remain pinned until cache state has been flushed.
670
+ * Default: 128
671
+ */
672
+ maxEntries?: number;
673
+ /**
674
+ * Number of upcoming documents to prefetch during changefeed iteration.
675
+ * Set to 0 to disable eager iteration prefetch.
676
+ * Default: 0
677
+ */
678
+ iteratePrefetchWindowDocs?: number;
679
+ /**
680
+ * Maximum number of documents restored from the local cache store during
681
+ * startup. Prevents large cache checkpoints from rehydrating every
682
+ * document into memory immediately.
683
+ * Default: same as `maxEntries`
684
+ */
685
+ restoreLimit?: number;
686
+ }
687
+ /**
688
+ * Configuration for automatic snapshot creation.
689
+ */
690
+ export interface SnapshotConfig {
691
+ /**
692
+ * Minimum number of replay entries since the latest snapshot before a new
693
+ * snapshot is considered.
694
+ * Default: 100
695
+ */
696
+ minChanges?: number;
697
+ /**
698
+ * Minimum time between snapshot writes for the same document.
699
+ * Default: 10 minutes
700
+ */
701
+ cooldownMs?: number;
702
+ }
444
703
  /**
445
704
  * A MindooDoc is a document that is stored in the MindooDB.
446
705
  * It's a wrapper around the Automerge document.
@@ -579,6 +838,15 @@ export interface MindooDoc {
579
838
  export interface MindooDocPayload {
580
839
  [key: string]: unknown;
581
840
  }
841
+ export interface DirectoryUserDetails {
842
+ [key: string]: string;
843
+ }
844
+ export interface DirectoryUserLookup {
845
+ username: string;
846
+ signingPublicKey: string;
847
+ encryptionPublicKey: string;
848
+ details: DirectoryUserDetails | null;
849
+ }
582
850
  export interface MindooTenantDirectory {
583
851
  /**
584
852
  * Adds a new user to the tenant. The user is identified by its user ID.
@@ -589,7 +857,7 @@ export interface MindooTenantDirectory {
589
857
  * @param administrationPrivateKeyPassword The password to decrypt the administration private key
590
858
  * @return A promise that resolves when the user is registered
591
859
  */
592
- registerUser(userId: PublicUserId, administrationPrivateKey: EncryptedPrivateKey, administrationPrivateKeyPassword: string): Promise<void>;
860
+ registerUser(userId: PublicUserId, administrationPrivateKey: EncryptedPrivateKey, administrationPrivateKeyPassword: string, userDetails?: DirectoryUserDetails): Promise<void>;
593
861
  /**
594
862
  * Revokes a user's access to the tenant by adding a revocation record to the directory.
595
863
  * This prevents the user from decrypting future changes, but they retain access to previously
@@ -620,7 +888,16 @@ export interface MindooTenantDirectory {
620
888
  getUserPublicKeys(username: string): Promise<{
621
889
  signingPublicKey: string;
622
890
  encryptionPublicKey: string;
891
+ details?: DirectoryUserDetails | null;
623
892
  } | null>;
893
+ /**
894
+ * Look up a user by their public signing key.
895
+ * This is useful for reverse-resolving historical change authors to friendly labels.
896
+ *
897
+ * @param publicKey The public signing key to look up (Ed25519, PEM format)
898
+ * @return The matching user record, or null if no registration is known
899
+ */
900
+ getUserBySigningPublicKey(publicKey: string): Promise<DirectoryUserLookup | null>;
624
901
  /**
625
902
  * Check if a user has been revoked.
626
903
  *
@@ -691,6 +968,14 @@ export interface MindooTenantDirectory {
691
968
  * @return The latest DB settings document, or null if none exists
692
969
  */
693
970
  getDBSettings(dbId: string): Promise<MindooDoc | null>;
971
+ /**
972
+ * Returns the database IDs currently known to the directory.
973
+ *
974
+ * This is intended for admin tooling and overview UIs. The result always includes
975
+ * `"directory"` and will also include `"main"` as the conventional default app DB.
976
+ * Additional DBs are discovered from `dbsettings` documents stored in the directory.
977
+ */
978
+ listKnownDBIds(): Promise<string[]>;
694
979
  /**
695
980
  * Create or update database-specific settings.
696
981
  * Automatically uses the cached settings document for the given dbId if it exists, or creates a new one.
@@ -717,6 +1002,11 @@ export interface MindooTenantDirectory {
717
1002
  * @param groupName The name of the group to look up (case-insensitive, converted to lowercase)
718
1003
  * @return The members of the group
719
1004
  */
1005
+ /**
1006
+ * Get the decrypted member names for a group.
1007
+ * Entries that cannot be decrypted are skipped so callers can still work with
1008
+ * the readable subset of the group.
1009
+ */
720
1010
  getGroupMembers(groupName: string): Promise<string[]>;
721
1011
  /**
722
1012
  * Deletes a group. Does nothing if the group does not exist.
@@ -766,13 +1056,20 @@ export interface MindooTenantDirectory {
766
1056
  * and prevent duplicate processing when multiple documents have the same timestamp.
767
1057
  */
768
1058
  export interface ProcessChangesCursor {
1059
+ /**
1060
+ * Monotonic changefeed sequence number assigned by BaseMindooDB.
1061
+ * This is the primary cursor field for deterministic, gap-free iteration.
1062
+ */
1063
+ changeSeq?: number;
769
1064
  /**
770
1065
  * The timestamp of the last processed change (milliseconds since Unix epoch)
1066
+ * Legacy compatibility field. New code should use `changeSeq`.
771
1067
  */
772
1068
  lastModified: number;
773
1069
  /**
774
1070
  * The document ID of the last processed change.
775
1071
  * Used to break ties when multiple documents have the same timestamp.
1072
+ * Legacy compatibility field. New code should use `changeSeq`.
776
1073
  */
777
1074
  docId: string;
778
1075
  }
@@ -790,6 +1087,28 @@ export interface ProcessChangesResult {
790
1087
  */
791
1088
  cursor: ProcessChangesCursor;
792
1089
  }
1090
+ /**
1091
+ * Result yielded by the metadata-only latest-state iterator.
1092
+ * Contains the latest known index metadata without materializing the document.
1093
+ */
1094
+ export interface ProcessChangeSummaryResult {
1095
+ /**
1096
+ * The document ID that changed.
1097
+ */
1098
+ docId: string;
1099
+ /**
1100
+ * Latest user-visible modification timestamp for the document.
1101
+ */
1102
+ lastModified: number;
1103
+ /**
1104
+ * Whether the latest known state is deleted.
1105
+ */
1106
+ isDeleted: boolean;
1107
+ /**
1108
+ * The cursor position of this document in the deterministic changefeed.
1109
+ */
1110
+ cursor: ProcessChangesCursor;
1111
+ }
793
1112
  /**
794
1113
  * Result yielded by the iterateDocumentHistory generator.
795
1114
  */
@@ -823,6 +1142,18 @@ export interface OpenDBOptions extends OpenStoreOptions {
823
1142
  * If not provided, defaults are used.
824
1143
  */
825
1144
  attachmentConfig?: AttachmentConfig;
1145
+ /**
1146
+ * Configuration for the in-memory materialized document cache.
1147
+ */
1148
+ documentCacheConfig?: DocumentCacheConfig;
1149
+ /**
1150
+ * Configuration for automatic snapshot creation.
1151
+ */
1152
+ snapshotConfig?: SnapshotConfig;
1153
+ /**
1154
+ * Optional performance callback for profiling hot paths.
1155
+ */
1156
+ performanceCallback?: PerformanceCallback;
826
1157
  }
827
1158
  /**
828
1159
  * Optional performance callback interface for tracking operation timing.
@@ -835,6 +1166,9 @@ export interface PerformanceCallback {
835
1166
  onDocumentLoad?: (metrics: {
836
1167
  docId: string;
837
1168
  cacheHit: boolean;
1169
+ metadataEntriesScanned: number;
1170
+ replayEntriesLoaded: number;
1171
+ snapshotUsed: boolean;
838
1172
  cacheCheckTime: number;
839
1173
  storeQueryTime: number;
840
1174
  entryLoadTime: number;
@@ -855,10 +1189,107 @@ export interface PerformanceCallback {
855
1189
  * Called during sync operations.
856
1190
  */
857
1191
  onSyncOperation?: (metrics: {
858
- operation: 'findNewEntries' | 'processDocument' | 'updateIndex';
1192
+ operation: 'findNewEntries' | 'processDocument' | 'updateIndex' | 'iterateChangesSince' | 'iterateChangeMetadataSince' | 'planDocumentMaterialization' | 'planDocumentMaterializationBatch' | 'bloomRebuild';
859
1193
  time: number;
860
1194
  details?: Record<string, any>;
861
1195
  }) => void;
1196
+ /**
1197
+ * Called for bounded history/time-travel workflows.
1198
+ */
1199
+ onHistoryOperation?: (metrics: {
1200
+ operation: 'getDocumentAtTimestamp' | 'getDocumentHistoryPage';
1201
+ docId: string;
1202
+ time: number;
1203
+ scannedEntries: number;
1204
+ returnedEntries?: number;
1205
+ bounded?: boolean;
1206
+ }) => void;
1207
+ }
1208
+ /**
1209
+ * Cursor for paged history metadata access.
1210
+ */
1211
+ export interface DocumentHistoryPageCursor {
1212
+ offset: number;
1213
+ }
1214
+ /**
1215
+ * One history entry in a bounded history page.
1216
+ */
1217
+ export interface DocumentHistoryPageEntry {
1218
+ entryId: string;
1219
+ entryType: StoreEntryType;
1220
+ changeCreatedAt: number;
1221
+ changeCreatedByPublicKey: string;
1222
+ dependencyIds: string[];
1223
+ isDeleted: boolean;
1224
+ }
1225
+ /**
1226
+ * Options for bounded history metadata access.
1227
+ */
1228
+ export interface DocumentHistoryPageOptions {
1229
+ cursor?: DocumentHistoryPageCursor | null;
1230
+ limit?: number;
1231
+ }
1232
+ /**
1233
+ * Page result for bounded history metadata access.
1234
+ */
1235
+ export interface DocumentHistoryPageResult {
1236
+ entries: DocumentHistoryPageEntry[];
1237
+ nextCursor: DocumentHistoryPageCursor | null;
1238
+ hasMore: boolean;
1239
+ }
1240
+ /**
1241
+ * Progress information emitted during pull/push sync operations.
1242
+ */
1243
+ export interface SyncProgress {
1244
+ phase: 'preparing' | 'planning' | 'transferring' | 'processing' | 'complete';
1245
+ message: string;
1246
+ transferredEntries: number;
1247
+ scannedEntries: number;
1248
+ totalSourceEntries?: number;
1249
+ currentPage?: number;
1250
+ }
1251
+ /**
1252
+ * Sync mode controls how much data is transferred between stores.
1253
+ *
1254
+ * - `"full"` (default) transfers every entry the target is missing.
1255
+ * - `"dense"` uses the batch materialization planner to transfer only the
1256
+ * entries needed to reconstruct the latest state of each document (best
1257
+ * snapshot + uncovered changes + lifecycle bookkeeping). Historical
1258
+ * entries superseded by a snapshot are skipped, and attachment chunks are
1259
+ * deferred.
1260
+ */
1261
+ export type SyncMode = "full" | "dense";
1262
+ /**
1263
+ * Options for pull/push sync operations.
1264
+ */
1265
+ export interface SyncOptions {
1266
+ onProgress?: (progress: SyncProgress) => void;
1267
+ pageSize?: number;
1268
+ signal?: AbortSignal;
1269
+ /**
1270
+ * Optional network auth override for this sync call.
1271
+ *
1272
+ * Useful for bootstrap scenarios where a specific user identity (for example
1273
+ * an admin identity) must be used for the challenge/response handshake.
1274
+ */
1275
+ networkAuthOverride?: {
1276
+ user: PrivateUserId;
1277
+ password: string;
1278
+ };
1279
+ /**
1280
+ * Transfer strategy. Defaults to `"full"`.
1281
+ *
1282
+ * Use `"dense"` for bandwidth-constrained scenarios (initial mobile setup,
1283
+ * metered connections) where only the current document state is needed.
1284
+ */
1285
+ mode?: SyncMode;
1286
+ }
1287
+ /**
1288
+ * Result returned by pull/push sync operations.
1289
+ */
1290
+ export interface SyncResult {
1291
+ transferredEntries: number;
1292
+ cancelled: boolean;
862
1293
  }
863
1294
  export interface MindooDB {
864
1295
  /**
@@ -952,6 +1383,14 @@ export interface MindooDB {
952
1383
  * @return An async generator that yields DocumentHistoryResult objects containing the document state and change metadata, in chronological order from oldest to newest
953
1384
  */
954
1385
  iterateDocumentHistory(docId: string): AsyncGenerator<DocumentHistoryResult, void, unknown>;
1386
+ /**
1387
+ * Return bounded history metadata for a document without materializing every
1388
+ * historical document state.
1389
+ *
1390
+ * This is intended for scalable history UIs where the caller wants a paged
1391
+ * timeline first, and only materializes specific snapshots on demand.
1392
+ */
1393
+ getDocumentHistoryPage(docId: string, options?: DocumentHistoryPageOptions): Promise<DocumentHistoryPageResult>;
955
1394
  /**
956
1395
  * Get all document IDs in this database.
957
1396
  *
@@ -964,7 +1403,7 @@ export interface MindooDB {
964
1403
  * This method efficiently queries the content-addressed store to find
965
1404
  * documents that existed at the given point in time. A document is considered
966
1405
  * to exist at a timestamp if:
967
- * - It has a doc_create entry with createdAt < timestamp
1406
+ * - It has a doc_create entry with createdAt <= timestamp
968
1407
  * - Either it has no doc_delete entry, or its doc_delete entry has createdAt > timestamp
969
1408
  *
970
1409
  * @param timestamp The timestamp to query (milliseconds since Unix epoch)
@@ -1041,6 +1480,17 @@ export interface MindooDB {
1041
1480
  * @return An async generator that yields ProcessChangesResult objects containing the document and its cursor. Each document is yielded immediately after loading, enabling early termination.
1042
1481
  */
1043
1482
  iterateChangesSince(cursor: ProcessChangesCursor | null): AsyncGenerator<ProcessChangesResult, void, unknown>;
1483
+ /**
1484
+ * Iterate over latest-state change metadata since a given cursor without
1485
+ * loading, verifying, or decrypting the full document body.
1486
+ *
1487
+ * This is intended for external indexes, sync checkpoints, and overview UIs
1488
+ * that only need document IDs, deletion flags, and cursors.
1489
+ *
1490
+ * @param cursor The cursor to start processing changes from. Use `null` to start from the beginning.
1491
+ * @return An async generator that yields metadata-only change summaries.
1492
+ */
1493
+ iterateChangeMetadataSince(cursor: ProcessChangesCursor | null): AsyncGenerator<ProcessChangeSummaryResult, void, unknown>;
1044
1494
  /**
1045
1495
  * Sync changes from the append-only store by finding new changes and processing them.
1046
1496
  * This method can be called multiple times to incrementally sync new changes.
@@ -1055,18 +1505,20 @@ export interface MindooDB {
1055
1505
  */
1056
1506
  syncStoreChanges(): Promise<void>;
1057
1507
  /**
1058
- * Pull changes from a remote content-addressed store.
1508
+ * Pull changes from a remote content-addressed store or another MindooDB instance.
1059
1509
  *
1060
- * @param remoteStore The remote store to pull changes from
1061
- * @return A promise that resolves when the pull is complete
1510
+ * @param remote The remote store or MindooDB instance to pull changes from
1511
+ * @param options Optional sync options for progress tracking, paging, and cancellation
1512
+ * @return A promise that resolves with the sync result
1062
1513
  */
1063
- pullChangesFrom(remoteStore: ContentAddressedStore): Promise<void>;
1514
+ pullChangesFrom(remote: ContentAddressedStore | MindooDB, options?: SyncOptions): Promise<SyncResult>;
1064
1515
  /**
1065
- * Push changes to a remote content-addressed store.
1516
+ * Push changes to a remote content-addressed store or another MindooDB instance.
1066
1517
  *
1067
- * @param remoteStore The remote store to push changes to
1068
- * @return A promise that resolves when the push is complete
1518
+ * @param remote The remote store or MindooDB instance to push changes to
1519
+ * @param options Optional sync options for progress tracking, paging, and cancellation
1520
+ * @return A promise that resolves with the sync result
1069
1521
  */
1070
- pushChangesTo(remoteStore: ContentAddressedStore): Promise<void>;
1522
+ pushChangesTo(remote: ContentAddressedStore | MindooDB, options?: SyncOptions): Promise<SyncResult>;
1071
1523
  }
1072
1524
  //# sourceMappingURL=types.d.ts.map