@enbox/dwn-sdk-js 0.0.5 → 0.0.7

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 (363) hide show
  1. package/dist/browser.mjs +8 -8
  2. package/dist/browser.mjs.map +4 -4
  3. package/dist/esm/generated/precompiled-validators.js +1 -2
  4. package/dist/esm/generated/precompiled-validators.js.map +1 -1
  5. package/dist/esm/src/core/abstract-message.js +4 -0
  6. package/dist/esm/src/core/abstract-message.js.map +1 -1
  7. package/dist/esm/src/core/auth.js +22 -33
  8. package/dist/esm/src/core/auth.js.map +1 -1
  9. package/dist/esm/src/core/dwn-constant.js +7 -7
  10. package/dist/esm/src/core/dwn-constant.js.map +1 -1
  11. package/dist/esm/src/core/dwn-error.js +1 -0
  12. package/dist/esm/src/core/dwn-error.js.map +1 -1
  13. package/dist/esm/src/core/grant-authorization.js +37 -52
  14. package/dist/esm/src/core/grant-authorization.js.map +1 -1
  15. package/dist/esm/src/core/message.js +85 -116
  16. package/dist/esm/src/core/message.js.map +1 -1
  17. package/dist/esm/src/core/messages-grant-authorization.js +63 -78
  18. package/dist/esm/src/core/messages-grant-authorization.js.map +1 -1
  19. package/dist/esm/src/core/protocol-authorization-action.js +266 -0
  20. package/dist/esm/src/core/protocol-authorization-action.js.map +1 -0
  21. package/dist/esm/src/core/protocol-authorization-validation.js +254 -0
  22. package/dist/esm/src/core/protocol-authorization-validation.js.map +1 -0
  23. package/dist/esm/src/core/protocol-authorization.js +122 -740
  24. package/dist/esm/src/core/protocol-authorization.js.map +1 -1
  25. package/dist/esm/src/core/protocols-grant-authorization.js +24 -38
  26. package/dist/esm/src/core/protocols-grant-authorization.js.map +1 -1
  27. package/dist/esm/src/core/record-chain.js +64 -0
  28. package/dist/esm/src/core/record-chain.js.map +1 -0
  29. package/dist/esm/src/core/records-grant-authorization.js +55 -72
  30. package/dist/esm/src/core/records-grant-authorization.js.map +1 -1
  31. package/dist/esm/src/core/resumable-task-manager.js +50 -65
  32. package/dist/esm/src/core/resumable-task-manager.js.map +1 -1
  33. package/dist/esm/src/core/tenant-gate.js +2 -13
  34. package/dist/esm/src/core/tenant-gate.js.map +1 -1
  35. package/dist/esm/src/dwn.js +69 -86
  36. package/dist/esm/src/dwn.js.map +1 -1
  37. package/dist/esm/src/event-stream/event-emitter-stream.js +17 -31
  38. package/dist/esm/src/event-stream/event-emitter-stream.js.map +1 -1
  39. package/dist/esm/src/handlers/messages-read.js +67 -77
  40. package/dist/esm/src/handlers/messages-read.js.map +1 -1
  41. package/dist/esm/src/handlers/messages-subscribe.js +51 -61
  42. package/dist/esm/src/handlers/messages-subscribe.js.map +1 -1
  43. package/dist/esm/src/handlers/messages-sync.js +75 -85
  44. package/dist/esm/src/handlers/messages-sync.js.map +1 -1
  45. package/dist/esm/src/handlers/protocols-configure.js +135 -155
  46. package/dist/esm/src/handlers/protocols-configure.js.map +1 -1
  47. package/dist/esm/src/handlers/protocols-query.js +52 -51
  48. package/dist/esm/src/handlers/protocols-query.js.map +1 -1
  49. package/dist/esm/src/handlers/records-count.js +96 -82
  50. package/dist/esm/src/handlers/records-count.js.map +1 -1
  51. package/dist/esm/src/handlers/records-delete.js +78 -88
  52. package/dist/esm/src/handlers/records-delete.js.map +1 -1
  53. package/dist/esm/src/handlers/records-query.js +116 -101
  54. package/dist/esm/src/handlers/records-query.js.map +1 -1
  55. package/dist/esm/src/handlers/records-read.js +124 -131
  56. package/dist/esm/src/handlers/records-read.js.map +1 -1
  57. package/dist/esm/src/handlers/records-subscribe.js +150 -103
  58. package/dist/esm/src/handlers/records-subscribe.js.map +1 -1
  59. package/dist/esm/src/handlers/records-write.js +250 -259
  60. package/dist/esm/src/handlers/records-write.js.map +1 -1
  61. package/dist/esm/src/interfaces/messages-read.js +24 -32
  62. package/dist/esm/src/interfaces/messages-read.js.map +1 -1
  63. package/dist/esm/src/interfaces/messages-subscribe.js +27 -41
  64. package/dist/esm/src/interfaces/messages-subscribe.js.map +1 -1
  65. package/dist/esm/src/interfaces/messages-sync.js +26 -40
  66. package/dist/esm/src/interfaces/messages-sync.js.map +1 -1
  67. package/dist/esm/src/interfaces/protocols-configure.js +63 -63
  68. package/dist/esm/src/interfaces/protocols-configure.js.map +1 -1
  69. package/dist/esm/src/interfaces/protocols-query.js +55 -68
  70. package/dist/esm/src/interfaces/protocols-query.js.map +1 -1
  71. package/dist/esm/src/interfaces/records-count.js +50 -66
  72. package/dist/esm/src/interfaces/records-count.js.map +1 -1
  73. package/dist/esm/src/interfaces/records-delete.js +45 -55
  74. package/dist/esm/src/interfaces/records-delete.js.map +1 -1
  75. package/dist/esm/src/interfaces/records-query.js +60 -76
  76. package/dist/esm/src/interfaces/records-query.js.map +1 -1
  77. package/dist/esm/src/interfaces/records-read.js +51 -67
  78. package/dist/esm/src/interfaces/records-read.js.map +1 -1
  79. package/dist/esm/src/interfaces/records-subscribe.js +52 -68
  80. package/dist/esm/src/interfaces/records-subscribe.js.map +1 -1
  81. package/dist/esm/src/interfaces/records-write-query.js +102 -0
  82. package/dist/esm/src/interfaces/records-write-query.js.map +1 -0
  83. package/dist/esm/src/interfaces/records-write-signing.js +92 -0
  84. package/dist/esm/src/interfaces/records-write-signing.js.map +1 -0
  85. package/dist/esm/src/interfaces/records-write.js +407 -602
  86. package/dist/esm/src/interfaces/records-write.js.map +1 -1
  87. package/dist/esm/src/jose/algorithms/signing/ed25519.js +10 -19
  88. package/dist/esm/src/jose/algorithms/signing/ed25519.js.map +1 -1
  89. package/dist/esm/src/jose/jws/general/builder.js +23 -35
  90. package/dist/esm/src/jose/jws/general/builder.js.map +1 -1
  91. package/dist/esm/src/jose/jws/general/verifier.js +56 -69
  92. package/dist/esm/src/jose/jws/general/verifier.js.map +1 -1
  93. package/dist/esm/src/protocols/permission-grant.js +44 -15
  94. package/dist/esm/src/protocols/permission-grant.js.map +1 -1
  95. package/dist/esm/src/protocols/permission-request.js +29 -15
  96. package/dist/esm/src/protocols/permission-request.js.map +1 -1
  97. package/dist/esm/src/protocols/permissions.js +216 -226
  98. package/dist/esm/src/protocols/permissions.js.map +1 -1
  99. package/dist/esm/src/smt/smt-store-level.js +42 -64
  100. package/dist/esm/src/smt/smt-store-level.js.map +1 -1
  101. package/dist/esm/src/smt/smt-store-memory.js +19 -45
  102. package/dist/esm/src/smt/smt-store-memory.js.map +1 -1
  103. package/dist/esm/src/smt/smt-utils.js +28 -45
  104. package/dist/esm/src/smt/smt-utils.js.map +1 -1
  105. package/dist/esm/src/smt/sparse-merkle-tree.js +426 -471
  106. package/dist/esm/src/smt/sparse-merkle-tree.js.map +1 -1
  107. package/dist/esm/src/state-index/state-index-level.js +115 -150
  108. package/dist/esm/src/state-index/state-index-level.js.map +1 -1
  109. package/dist/esm/src/store/blockstore-level.js +54 -156
  110. package/dist/esm/src/store/blockstore-level.js.map +1 -1
  111. package/dist/esm/src/store/blockstore-mock.js +48 -153
  112. package/dist/esm/src/store/blockstore-mock.js.map +1 -1
  113. package/dist/esm/src/store/data-store-level.js +59 -99
  114. package/dist/esm/src/store/data-store-level.js.map +1 -1
  115. package/dist/esm/src/store/index-level-compound.js +246 -0
  116. package/dist/esm/src/store/index-level-compound.js.map +1 -0
  117. package/dist/esm/src/store/index-level.js +295 -713
  118. package/dist/esm/src/store/index-level.js.map +1 -1
  119. package/dist/esm/src/store/level-wrapper.js +143 -244
  120. package/dist/esm/src/store/level-wrapper.js.map +1 -1
  121. package/dist/esm/src/store/message-store-level.js +71 -94
  122. package/dist/esm/src/store/message-store-level.js.map +1 -1
  123. package/dist/esm/src/store/resumable-task-store-level.js +62 -101
  124. package/dist/esm/src/store/resumable-task-store-level.js.map +1 -1
  125. package/dist/esm/src/store/storage-controller.js +129 -144
  126. package/dist/esm/src/store/storage-controller.js.map +1 -1
  127. package/dist/esm/src/utils/abort.js +8 -19
  128. package/dist/esm/src/utils/abort.js.map +1 -1
  129. package/dist/esm/src/utils/array.js +15 -49
  130. package/dist/esm/src/utils/array.js.map +1 -1
  131. package/dist/esm/src/utils/cid.js +29 -77
  132. package/dist/esm/src/utils/cid.js.map +1 -1
  133. package/dist/esm/src/utils/data-stream.js +37 -65
  134. package/dist/esm/src/utils/data-stream.js.map +1 -1
  135. package/dist/esm/src/utils/encryption.js +136 -162
  136. package/dist/esm/src/utils/encryption.js.map +1 -1
  137. package/dist/esm/src/utils/filter.js +1 -12
  138. package/dist/esm/src/utils/filter.js.map +1 -1
  139. package/dist/esm/src/utils/hd-key.js +45 -63
  140. package/dist/esm/src/utils/hd-key.js.map +1 -1
  141. package/dist/esm/src/utils/jws.js +9 -20
  142. package/dist/esm/src/utils/jws.js.map +1 -1
  143. package/dist/esm/src/utils/memory-cache.js +12 -23
  144. package/dist/esm/src/utils/memory-cache.js.map +1 -1
  145. package/dist/esm/src/utils/messages.js +9 -3
  146. package/dist/esm/src/utils/messages.js.map +1 -1
  147. package/dist/esm/src/utils/private-key-signer.js +9 -17
  148. package/dist/esm/src/utils/private-key-signer.js.map +1 -1
  149. package/dist/esm/src/utils/protocols.js +62 -70
  150. package/dist/esm/src/utils/protocols.js.map +1 -1
  151. package/dist/esm/src/utils/records.js +108 -140
  152. package/dist/esm/src/utils/records.js.map +1 -1
  153. package/dist/esm/src/utils/secp256k1.js +60 -96
  154. package/dist/esm/src/utils/secp256k1.js.map +1 -1
  155. package/dist/esm/src/utils/secp256r1.js +54 -71
  156. package/dist/esm/src/utils/secp256r1.js.map +1 -1
  157. package/dist/esm/src/utils/time.js +5 -18
  158. package/dist/esm/src/utils/time.js.map +1 -1
  159. package/dist/esm/src/utils/url.js +3 -3
  160. package/dist/esm/src/utils/url.js.map +1 -1
  161. package/dist/esm/tests/core/auth.spec.js +3 -12
  162. package/dist/esm/tests/core/auth.spec.js.map +1 -1
  163. package/dist/esm/tests/core/message.spec.js +50 -59
  164. package/dist/esm/tests/core/message.spec.js.map +1 -1
  165. package/dist/esm/tests/core/protocol-authorization.spec.js +9 -18
  166. package/dist/esm/tests/core/protocol-authorization.spec.js.map +1 -1
  167. package/dist/esm/tests/dwn.spec.js +45 -58
  168. package/dist/esm/tests/dwn.spec.js.map +1 -1
  169. package/dist/esm/tests/event-stream/event-emitter-stream.spec.js +24 -33
  170. package/dist/esm/tests/event-stream/event-emitter-stream.spec.js.map +1 -1
  171. package/dist/esm/tests/event-stream/event-stream.spec.js +46 -55
  172. package/dist/esm/tests/event-stream/event-stream.spec.js.map +1 -1
  173. package/dist/esm/tests/features/author-delegated-grant.spec.js +326 -343
  174. package/dist/esm/tests/features/author-delegated-grant.spec.js.map +1 -1
  175. package/dist/esm/tests/features/owner-delegated-grant.spec.js +153 -169
  176. package/dist/esm/tests/features/owner-delegated-grant.spec.js.map +1 -1
  177. package/dist/esm/tests/features/owner-signature.spec.js +67 -78
  178. package/dist/esm/tests/features/owner-signature.spec.js.map +1 -1
  179. package/dist/esm/tests/features/permissions.spec.js +446 -181
  180. package/dist/esm/tests/features/permissions.spec.js.map +1 -1
  181. package/dist/esm/tests/features/protocol-composition.spec.js +346 -356
  182. package/dist/esm/tests/features/protocol-composition.spec.js.map +1 -1
  183. package/dist/esm/tests/features/protocol-create-action.spec.js +42 -51
  184. package/dist/esm/tests/features/protocol-create-action.spec.js.map +1 -1
  185. package/dist/esm/tests/features/protocol-delete-action.spec.js +94 -103
  186. package/dist/esm/tests/features/protocol-delete-action.spec.js.map +1 -1
  187. package/dist/esm/tests/features/protocol-update-action.spec.js +105 -114
  188. package/dist/esm/tests/features/protocol-update-action.spec.js.map +1 -1
  189. package/dist/esm/tests/features/records-prune.spec.js +175 -191
  190. package/dist/esm/tests/features/records-prune.spec.js.map +1 -1
  191. package/dist/esm/tests/features/records-tags.spec.js +441 -460
  192. package/dist/esm/tests/features/records-tags.spec.js.map +1 -1
  193. package/dist/esm/tests/features/resumable-tasks.spec.js +82 -91
  194. package/dist/esm/tests/features/resumable-tasks.spec.js.map +1 -1
  195. package/dist/esm/tests/handlers/messages-read.spec.js +206 -207
  196. package/dist/esm/tests/handlers/messages-read.spec.js.map +1 -1
  197. package/dist/esm/tests/handlers/messages-subscribe.spec.js +145 -154
  198. package/dist/esm/tests/handlers/messages-subscribe.spec.js.map +1 -1
  199. package/dist/esm/tests/handlers/messages-sync.spec.js +174 -183
  200. package/dist/esm/tests/handlers/messages-sync.spec.js.map +1 -1
  201. package/dist/esm/tests/handlers/protocols-configure.spec.js +244 -238
  202. package/dist/esm/tests/handlers/protocols-configure.spec.js.map +1 -1
  203. package/dist/esm/tests/handlers/protocols-query.spec.js +156 -169
  204. package/dist/esm/tests/handlers/protocols-query.spec.js.map +1 -1
  205. package/dist/esm/tests/handlers/records-count.spec.js +93 -102
  206. package/dist/esm/tests/handlers/records-count.spec.js.map +1 -1
  207. package/dist/esm/tests/handlers/records-delete.spec.js +252 -264
  208. package/dist/esm/tests/handlers/records-delete.spec.js.map +1 -1
  209. package/dist/esm/tests/handlers/records-query.spec.js +917 -988
  210. package/dist/esm/tests/handlers/records-query.spec.js.map +1 -1
  211. package/dist/esm/tests/handlers/records-read.spec.js +553 -568
  212. package/dist/esm/tests/handlers/records-read.spec.js.map +1 -1
  213. package/dist/esm/tests/handlers/records-subscribe.spec.js +269 -278
  214. package/dist/esm/tests/handlers/records-subscribe.spec.js.map +1 -1
  215. package/dist/esm/tests/handlers/records-write.spec.js +1057 -1082
  216. package/dist/esm/tests/handlers/records-write.spec.js.map +1 -1
  217. package/dist/esm/tests/interfaces/messages-get.spec.js +39 -48
  218. package/dist/esm/tests/interfaces/messages-get.spec.js.map +1 -1
  219. package/dist/esm/tests/interfaces/messages-subscribe.spec.js +4 -13
  220. package/dist/esm/tests/interfaces/messages-subscribe.spec.js.map +1 -1
  221. package/dist/esm/tests/interfaces/protocols-configure.spec.js +212 -88
  222. package/dist/esm/tests/interfaces/protocols-configure.spec.js.map +1 -1
  223. package/dist/esm/tests/interfaces/protocols-query.spec.js +8 -17
  224. package/dist/esm/tests/interfaces/protocols-query.spec.js.map +1 -1
  225. package/dist/esm/tests/interfaces/records-delete.spec.js +8 -17
  226. package/dist/esm/tests/interfaces/records-delete.spec.js.map +1 -1
  227. package/dist/esm/tests/interfaces/records-query.spec.js +20 -29
  228. package/dist/esm/tests/interfaces/records-query.spec.js.map +1 -1
  229. package/dist/esm/tests/interfaces/records-read.spec.js +42 -51
  230. package/dist/esm/tests/interfaces/records-read.spec.js.map +1 -1
  231. package/dist/esm/tests/interfaces/records-subscribe.spec.js +16 -25
  232. package/dist/esm/tests/interfaces/records-subscribe.spec.js.map +1 -1
  233. package/dist/esm/tests/interfaces/records-write.spec.js +152 -165
  234. package/dist/esm/tests/interfaces/records-write.spec.js.map +1 -1
  235. package/dist/esm/tests/jose/jws/general.spec.js +36 -45
  236. package/dist/esm/tests/jose/jws/general.spec.js.map +1 -1
  237. package/dist/esm/tests/protocols/permission-grant.spec.js +44 -50
  238. package/dist/esm/tests/protocols/permission-grant.spec.js.map +1 -1
  239. package/dist/esm/tests/protocols/permission-request.spec.js +23 -32
  240. package/dist/esm/tests/protocols/permission-request.spec.js.map +1 -1
  241. package/dist/esm/tests/protocols/permissions.spec.js +49 -55
  242. package/dist/esm/tests/protocols/permissions.spec.js.map +1 -1
  243. package/dist/esm/tests/scenarios/aggregator.spec.js +124 -135
  244. package/dist/esm/tests/scenarios/aggregator.spec.js.map +1 -1
  245. package/dist/esm/tests/scenarios/deleted-record.spec.js +23 -32
  246. package/dist/esm/tests/scenarios/deleted-record.spec.js.map +1 -1
  247. package/dist/esm/tests/scenarios/end-to-end-tests.spec.js +52 -61
  248. package/dist/esm/tests/scenarios/end-to-end-tests.spec.js.map +1 -1
  249. package/dist/esm/tests/scenarios/nested-roles.spec.js +63 -73
  250. package/dist/esm/tests/scenarios/nested-roles.spec.js.map +1 -1
  251. package/dist/esm/tests/scenarios/subscriptions.spec.js +377 -333
  252. package/dist/esm/tests/scenarios/subscriptions.spec.js.map +1 -1
  253. package/dist/esm/tests/smt/smt-store-level.spec.js +76 -87
  254. package/dist/esm/tests/smt/smt-store-level.spec.js.map +1 -1
  255. package/dist/esm/tests/smt/sparse-merkle-tree.spec.js +344 -353
  256. package/dist/esm/tests/smt/sparse-merkle-tree.spec.js.map +1 -1
  257. package/dist/esm/tests/state-index/state-index-level.spec.js +117 -126
  258. package/dist/esm/tests/state-index/state-index-level.spec.js.map +1 -1
  259. package/dist/esm/tests/store/blockstore-level.spec.js +44 -99
  260. package/dist/esm/tests/store/blockstore-level.spec.js.map +1 -1
  261. package/dist/esm/tests/store/blockstore-mock.spec.js +40 -120
  262. package/dist/esm/tests/store/blockstore-mock.spec.js.map +1 -1
  263. package/dist/esm/tests/store/data-store-level.spec.js +86 -95
  264. package/dist/esm/tests/store/data-store-level.spec.js.map +1 -1
  265. package/dist/esm/tests/store/index-level.spec.js +404 -414
  266. package/dist/esm/tests/store/index-level.spec.js.map +1 -1
  267. package/dist/esm/tests/store/message-store-level.spec.js +13 -22
  268. package/dist/esm/tests/store/message-store-level.spec.js.map +1 -1
  269. package/dist/esm/tests/store/message-store.spec.js +229 -238
  270. package/dist/esm/tests/store/message-store.spec.js.map +1 -1
  271. package/dist/esm/tests/test-event-stream.js +3 -3
  272. package/dist/esm/tests/test-event-stream.js.map +1 -1
  273. package/dist/esm/tests/test-stores.js +16 -13
  274. package/dist/esm/tests/test-stores.js.map +1 -1
  275. package/dist/esm/tests/test-suite.js +2 -11
  276. package/dist/esm/tests/test-suite.js.map +1 -1
  277. package/dist/esm/tests/utils/cid.spec.js +24 -33
  278. package/dist/esm/tests/utils/cid.spec.js.map +1 -1
  279. package/dist/esm/tests/utils/data-stream.spec.js +48 -57
  280. package/dist/esm/tests/utils/data-stream.spec.js.map +1 -1
  281. package/dist/esm/tests/utils/encryption-callbacks.spec.js +45 -54
  282. package/dist/esm/tests/utils/encryption-callbacks.spec.js.map +1 -1
  283. package/dist/esm/tests/utils/encryption.spec.js +291 -44
  284. package/dist/esm/tests/utils/encryption.spec.js.map +1 -1
  285. package/dist/esm/tests/utils/filters.spec.js +46 -55
  286. package/dist/esm/tests/utils/filters.spec.js.map +1 -1
  287. package/dist/esm/tests/utils/hd-key.spec.js +10 -19
  288. package/dist/esm/tests/utils/hd-key.spec.js.map +1 -1
  289. package/dist/esm/tests/utils/jws.spec.js +3 -12
  290. package/dist/esm/tests/utils/jws.spec.js.map +1 -1
  291. package/dist/esm/tests/utils/memory-cache.spec.js +9 -18
  292. package/dist/esm/tests/utils/memory-cache.spec.js.map +1 -1
  293. package/dist/esm/tests/utils/messages.spec.js +6 -15
  294. package/dist/esm/tests/utils/messages.spec.js.map +1 -1
  295. package/dist/esm/tests/utils/poller.js +22 -33
  296. package/dist/esm/tests/utils/poller.js.map +1 -1
  297. package/dist/esm/tests/utils/private-key-signer.spec.js +15 -24
  298. package/dist/esm/tests/utils/private-key-signer.spec.js.map +1 -1
  299. package/dist/esm/tests/utils/records.spec.js +10 -19
  300. package/dist/esm/tests/utils/records.spec.js.map +1 -1
  301. package/dist/esm/tests/utils/secp256k1.spec.js +16 -25
  302. package/dist/esm/tests/utils/secp256k1.spec.js.map +1 -1
  303. package/dist/esm/tests/utils/secp256r1.spec.js +18 -27
  304. package/dist/esm/tests/utils/secp256r1.spec.js.map +1 -1
  305. package/dist/esm/tests/utils/test-data-generator.js +414 -468
  306. package/dist/esm/tests/utils/test-data-generator.js.map +1 -1
  307. package/dist/esm/tests/validation/json-schemas/definitions.spec.js +2 -11
  308. package/dist/esm/tests/validation/json-schemas/definitions.spec.js.map +1 -1
  309. package/dist/esm/tests/validation/json-schemas/jwk/general-jwk.spec.js +4 -13
  310. package/dist/esm/tests/validation/json-schemas/jwk/general-jwk.spec.js.map +1 -1
  311. package/dist/esm/tests/validation/json-schemas/jwk/public-jwk.spec.js +8 -17
  312. package/dist/esm/tests/validation/json-schemas/jwk/public-jwk.spec.js.map +1 -1
  313. package/dist/esm/tests/validation/json-schemas/jwk-verification-method.spec.js +3 -12
  314. package/dist/esm/tests/validation/json-schemas/jwk-verification-method.spec.js.map +1 -1
  315. package/dist/esm/tests/validation/json-schemas/protocols/protocols-configure.spec.js +4 -13
  316. package/dist/esm/tests/validation/json-schemas/protocols/protocols-configure.spec.js.map +1 -1
  317. package/dist/esm/tests/validation/json-schemas/records/records-query.spec.js +2 -11
  318. package/dist/esm/tests/validation/json-schemas/records/records-query.spec.js.map +1 -1
  319. package/dist/esm/tests/validation/json-schemas/records/records-read.spec.js +2 -11
  320. package/dist/esm/tests/validation/json-schemas/records/records-read.spec.js.map +1 -1
  321. package/dist/esm/tests/validation/json-schemas/records/records-write.spec.js +7 -16
  322. package/dist/esm/tests/validation/json-schemas/records/records-write.spec.js.map +1 -1
  323. package/dist/types/src/core/protocol-authorization-action.d.ts +42 -0
  324. package/dist/types/src/core/protocol-authorization-action.d.ts.map +1 -0
  325. package/dist/types/src/core/protocol-authorization-validation.d.ts +60 -0
  326. package/dist/types/src/core/protocol-authorization-validation.d.ts.map +1 -0
  327. package/dist/types/src/core/protocol-authorization.d.ts +10 -100
  328. package/dist/types/src/core/protocol-authorization.d.ts.map +1 -1
  329. package/dist/types/src/core/record-chain.d.ts +24 -0
  330. package/dist/types/src/core/record-chain.d.ts.map +1 -0
  331. package/dist/types/src/handlers/records-write.d.ts +2 -1
  332. package/dist/types/src/handlers/records-write.d.ts.map +1 -1
  333. package/dist/types/src/interfaces/protocols-configure.d.ts.map +1 -1
  334. package/dist/types/src/interfaces/records-write-query.d.ts +33 -0
  335. package/dist/types/src/interfaces/records-write-query.d.ts.map +1 -0
  336. package/dist/types/src/interfaces/records-write-signing.d.ts +35 -0
  337. package/dist/types/src/interfaces/records-write-signing.d.ts.map +1 -0
  338. package/dist/types/src/interfaces/records-write.d.ts +10 -44
  339. package/dist/types/src/interfaces/records-write.d.ts.map +1 -1
  340. package/dist/types/src/store/index-level-compound.d.ts +70 -0
  341. package/dist/types/src/store/index-level-compound.d.ts.map +1 -0
  342. package/dist/types/src/store/index-level.d.ts +0 -58
  343. package/dist/types/src/store/index-level.d.ts.map +1 -1
  344. package/dist/types/src/utils/protocols.d.ts +5 -0
  345. package/dist/types/src/utils/protocols.d.ts.map +1 -1
  346. package/dist/types/src/utils/records.d.ts +3 -1
  347. package/dist/types/src/utils/records.d.ts.map +1 -1
  348. package/dist/types/tests/features/permissions.spec.d.ts.map +1 -1
  349. package/package.json +3 -3
  350. package/src/core/protocol-authorization-action.ts +377 -0
  351. package/src/core/protocol-authorization-validation.ts +391 -0
  352. package/src/core/protocol-authorization.ts +60 -849
  353. package/src/core/record-chain.ts +99 -0
  354. package/src/handlers/records-read.ts +1 -1
  355. package/src/handlers/records-write.ts +37 -21
  356. package/src/interfaces/protocols-configure.ts +33 -5
  357. package/src/interfaces/records-write-query.ts +139 -0
  358. package/src/interfaces/records-write-signing.ts +143 -0
  359. package/src/interfaces/records-write.ts +49 -221
  360. package/src/store/index-level-compound.ts +324 -0
  361. package/src/store/index-level.ts +24 -306
  362. package/src/utils/protocols.ts +8 -0
  363. package/src/utils/records.ts +9 -15
@@ -0,0 +1,60 @@
1
+ import type { MessageStore } from '../types/message-store.js';
2
+ import type { RecordsWriteMessage } from '../types/records-types.js';
3
+ import type { ProtocolDefinition, ProtocolRuleSet, ProtocolTypes } from '../types/protocols-types.js';
4
+ import type { RecordsWrite } from '../interfaces/records-write.js';
5
+ import type { FetchProtocolDefinitionFn } from './protocol-authorization.js';
6
+ /**
7
+ * Verifies the `protocolPath` declared in the given message matches the path of actual record chain.
8
+ * For cross-protocol composition, the parent record may belong to a different protocol (resolved via `$ref` in the composing protocol).
9
+ * @throws {DwnError} if fails verification.
10
+ */
11
+ export declare function verifyProtocolPathAndContextId(tenant: string, inboundMessage: RecordsWrite, messageStore: MessageStore, fetchProtocolDefinition: FetchProtocolDefinitionFn, governingTimestamp?: string): Promise<void>;
12
+ /**
13
+ * Resolves the protocol URI that should be used when querying for the parent record.
14
+ * For standard (non-composed) records, this is the same as the child's protocol.
15
+ * For cross-protocol composition, the parent may live in a different protocol
16
+ * (resolved via `$ref` in the composing protocol's definition).
17
+ *
18
+ * Logic: Given a child at protocolPath `a/b/c`, the parent is at `a/b`.
19
+ * Walk up the composing protocol's structure from root to `a/b`.
20
+ * If any segment along the way has a `$ref`, the parent (and its ancestors up to the `$ref` boundary)
21
+ * live in the referenced protocol. Specifically, the `$ref` at the topmost ancestor tells us
22
+ * the parent's protocol URI.
23
+ */
24
+ export declare function resolveParentProtocolUri(tenant: string, childProtocolUri: string, childProtocolPath: string, messageStore: MessageStore, fetchProtocolDefinition: FetchProtocolDefinitionFn, governingTimestamp?: string): Promise<string>;
25
+ /**
26
+ * Verifies the `dataFormat` and `schema` declared in the given message matches the type in the protocol.
27
+ * For cross-protocol composition, if the type is at a `$ref` position in the structure,
28
+ * the type definition is looked up in the referenced protocol's `types` map instead.
29
+ */
30
+ export declare function verifyTypeWithComposition(tenant: string, inboundMessage: RecordsWriteMessage, protocolDefinition: ProtocolDefinition, messageStore: MessageStore, fetchProtocolDefinition: FetchProtocolDefinitionFn, governingTimestamp?: string): Promise<void>;
31
+ /**
32
+ * Resolves the `ProtocolTypes` map that contains the type definition for the given protocol path.
33
+ * For non-composed records, this is the protocol definition's own `types` map.
34
+ * For records at a `$ref` position, this is the referenced protocol's `types` map.
35
+ */
36
+ export declare function resolveProtocolTypesForPath(tenant: string, protocolPath: string, protocolDefinition: ProtocolDefinition, messageStore: MessageStore, fetchProtocolDefinition: FetchProtocolDefinitionFn, governingTimestamp?: string): Promise<ProtocolTypes>;
37
+ /**
38
+ * Verifies the `dataFormat` and `schema` declared in the given message (if it is a RecordsWrite) matches dataFormat
39
+ * and schema of the type in the given protocol.
40
+ * @throws {DwnError} if fails verification.
41
+ */
42
+ export declare function verifyType(inboundMessage: RecordsWriteMessage, protocolTypes: ProtocolTypes, typeName?: string): void;
43
+ /**
44
+ * Verifies that writes adhere to the $size constraints if provided
45
+ * @throws {Error} if size is exceeded.
46
+ */
47
+ export declare function verifySizeLimit(incomingMessage: RecordsWrite, ruleSet: ProtocolRuleSet): void;
48
+ /**
49
+ * Verifies record tags against the `$tags` schema in the rule set using JSON Schema (Ajv).
50
+ * Checks required tags, additional properties, and schema conformance.
51
+ */
52
+ export declare function verifyTagsIfNeeded(incomingMessage: RecordsWrite, ruleSet: ProtocolRuleSet): void;
53
+ /**
54
+ * If the given RecordsWrite is not a role record, this method does nothing and succeeds immediately.
55
+ *
56
+ * Else it verifies the validity of the given `RecordsWrite` as a role record, including:
57
+ * 1. The same role has not been assigned to the same entity/recipient.
58
+ */
59
+ export declare function verifyAsRoleRecordIfNeeded(tenant: string, incomingMessage: RecordsWrite, ruleSet: ProtocolRuleSet, messageStore: MessageStore): Promise<void>;
60
+ //# sourceMappingURL=protocol-authorization-validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol-authorization-validation.d.ts","sourceRoot":"","sources":["../../../../src/core/protocol-authorization-validation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAgB,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEpH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AASnE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAE7E;;;;GAIG;AACH,wBAAsB,8BAA8B,CAClD,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,YAAY,EAC5B,YAAY,EAAE,YAAY,EAC1B,uBAAuB,EAAE,yBAAyB,EAClD,kBAAkB,CAAC,EAAE,MAAM,GAC1B,OAAO,CAAC,IAAI,CAAC,CAwEf;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,MAAM,EACxB,iBAAiB,EAAE,MAAM,EACzB,YAAY,EAAE,YAAY,EAC1B,uBAAuB,EAAE,yBAAyB,EAClD,kBAAkB,CAAC,EAAE,MAAM,GAC1B,OAAO,CAAC,MAAM,CAAC,CAuCjB;AAED;;;;GAIG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,mBAAmB,EACnC,kBAAkB,EAAE,kBAAkB,EACtC,YAAY,EAAE,YAAY,EAC1B,uBAAuB,EAAE,yBAAyB,EAClD,kBAAkB,CAAC,EAAE,MAAM,GAC1B,OAAO,CAAC,IAAI,CAAC,CAWf;AAED;;;;GAIG;AACH,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,EACpB,kBAAkB,EAAE,kBAAkB,EACtC,YAAY,EAAE,YAAY,EAC1B,uBAAuB,EAAE,yBAAyB,EAClD,kBAAkB,CAAC,EAAE,MAAM,GAC1B,OAAO,CAAC,aAAa,CAAC,CAqBxB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,cAAc,EAAE,mBAAmB,EACnC,aAAa,EAAE,aAAa,EAC5B,QAAQ,CAAC,EAAE,MAAM,GAChB,IAAI,CAsCN;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,eAAe,EAAE,YAAY,EAC7B,OAAO,EAAE,eAAe,GACvB,IAAI,CAgBN;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,eAAe,EAAE,YAAY,EAC7B,OAAO,EAAE,eAAe,GACvB,IAAI,CA8BN;AAED;;;;;GAKG;AACH,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,YAAY,EAC7B,OAAO,EAAE,eAAe,EACxB,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,IAAI,CAAC,CA6Cf"}
@@ -4,7 +4,13 @@ import type { RecordsDelete } from '../interfaces/records-delete.js';
4
4
  import type { RecordsQuery } from '../interfaces/records-query.js';
5
5
  import type { RecordsRead } from '../interfaces/records-read.js';
6
6
  import type { RecordsSubscribe } from '../interfaces/records-subscribe.js';
7
- import { RecordsWrite } from '../interfaces/records-write.js';
7
+ import type { RecordsWrite } from '../interfaces/records-write.js';
8
+ import type { ProtocolDefinition } from '../types/protocols-types.js';
9
+ /**
10
+ * Function signature for fetching a protocol definition.
11
+ * Used by extracted modules to break the circular dependency on `ProtocolAuthorization`.
12
+ */
13
+ export type FetchProtocolDefinitionFn = (tenant: string, protocolUri: string, messageStore: MessageStore, messageTimestamp?: string) => Promise<ProtocolDefinition>;
8
14
  export declare class ProtocolAuthorization {
9
15
  /**
10
16
  * Performs validation on the structure of RecordsWrite messages that use a protocol.
@@ -34,111 +40,15 @@ export declare class ProtocolAuthorization {
34
40
  * point in time — i.e. the ProtocolsConfigure with the greatest `messageTimestamp` that is <= the
35
41
  * given timestamp. When not provided, returns the latest (current) protocol definition.
36
42
  */
37
- private static fetchProtocolDefinition;
38
- /**
39
- * Constructs the chain of EXISTING records in the datastore where the first record is the root initial `RecordsWrite` of the record chain
40
- * and last record is the initial `RecordsWrite` of the descendant record specified.
41
- * @param descendantRecordId The ID of the descendent record to start constructing the record chain from by repeatedly looking up the parent.
42
- * @returns the record chain where each record is represented by its initial `RecordsWrite`;
43
- * returns empty array if `descendantRecordId` is `undefined`.
44
- * @throws {DwnError} if `descendantRecordId` is defined but any initial `RecordsWrite` is not found in the chain of records.
45
- */
46
- private static constructRecordChain;
47
- /**
48
- * Fetches the initial RecordsWrite message associated with the given (tenant + recordId).
49
- */
50
- private static fetchInitialWrite;
43
+ static fetchProtocolDefinition(tenant: string, protocolUri: string, messageStore: MessageStore, messageTimestamp?: string): Promise<ProtocolDefinition>;
51
44
  /**
52
45
  * Gets the rule set corresponding to the given protocolPath.
53
46
  */
54
47
  private static getRuleSet;
55
48
  /**
56
- * Verifies the `protocolPath` declared in the given message (if it is a RecordsWrite) matches the path of actual record chain.
57
- * For cross-protocol composition, the parent record may belong to a different protocol (resolved via `$ref` in the composing protocol).
58
- * @throws {DwnError} if fails verification.
59
- */
60
- private static verifyProtocolPathAndContextId;
61
- /**
62
- * Resolves the protocol URI that should be used when querying for the parent record.
63
- * For standard (non-composed) records, this is the same as the child's protocol.
64
- * For cross-protocol composition, the parent may live in a different protocol
65
- * (resolved via `$ref` in the composing protocol's definition).
66
- *
67
- * Logic: Given a child at protocolPath `a/b/c`, the parent is at `a/b`.
68
- * Walk up the composing protocol's structure from root to `a/b`.
69
- * If any segment along the way has a `$ref`, the parent (and its ancestors up to the `$ref` boundary)
70
- * live in the referenced protocol. Specifically, the `$ref` at the topmost ancestor tells us
71
- * the parent's protocol URI.
72
- */
73
- private static resolveParentProtocolUri;
74
- /**
75
- * Verifies the `dataFormat` and `schema` declared in the given message matches the type in the protocol.
76
- * For cross-protocol composition, if the type is at a `$ref` position in the structure,
77
- * the type definition is looked up in the referenced protocol's `types` map instead.
78
- */
79
- private static verifyTypeWithComposition;
80
- /**
81
- * Resolves the `ProtocolTypes` map that contains the type definition for the given protocol path.
82
- * For non-composed records, this is the protocol definition's own `types` map.
83
- * For records at a `$ref` position, this is the referenced protocol's `types` map.
84
- */
85
- private static resolveProtocolTypesForPath;
86
- /**
87
- * Verifies the `dataFormat` and `schema` declared in the given message (if it is a RecordsWrite) matches dataFormat
88
- * and schema of the type in the given protocol.
89
- * @throws {DwnError} if fails verification.
90
- */
91
- private static verifyType;
92
- /**
93
- * Check if the incoming message is invoking a role. If so, validate the invoked role.
94
- * For cross-protocol role invocation, the role record may live in a different protocol
95
- * (resolved via the composing protocol's `uses` map).
96
- */
97
- private static verifyInvokedRole;
98
- /**
99
- * Returns all the ProtocolActions that would authorized the incoming message
100
- * (but we still need to later verify if there is a rule defined that matches one of the actions).
101
- * NOTE: the reason why there could be multiple actions is because:
102
- * - In case of an initial RecordsWrite, the RecordsWrite can be authorized by an allow `create` or `write` rule.
103
- * - In case of a non-initial RecordsWrite by the original record author, the RecordsWrite can be authorized by a `write` or `co-update` rule.
104
- *
105
- * It is important to recognize that the `write` access that allowed the original record author to create the record maybe revoked
106
- * (e.g. by role revocation) by the time a "non-initial" write by the same author is attempted.
49
+ * Returns all the ProtocolActions that would authorize the incoming message.
50
+ * Delegates to the standalone function in `protocol-authorization-action.ts`.
107
51
  */
108
52
  private static getActionsSeekingARuleMatch;
109
- /**
110
- * Verifies the given message is authorized by one of the action rules in the given protocol rule set.
111
- * @param protocolDefinition Optional protocol definition for resolving cross-protocol `of` and `role` references.
112
- * @throws {Error} if action not allowed.
113
- */
114
- private static authorizeAgainstAllowedActions;
115
- /**
116
- * Verifies that writes adhere to the $size constraints if provided
117
- * @throws {Error} if size is exceeded.
118
- */
119
- private static verifySizeLimit;
120
- private static verifyTagsIfNeeded;
121
- /**
122
- * If the given RecordsWrite is not a role record, this method does nothing and succeeds immediately.
123
- *
124
- * Else it verifies the validity of the given `RecordsWrite` as a role record, including:
125
- * 1. The same role has not been assigned to the same entity/recipient.
126
- */
127
- private static verifyAsRoleRecordIfNeeded;
128
- /**
129
- * Checks if the `who: 'author' | 'recipient'` action rule has a matching record in the record chain.
130
- * For cross-protocol `of` references (e.g., `"threads:thread"`), matches against both the protocol URI
131
- * and the protocol path of the ancestor record.
132
- * @returns `true` if the action rule is satisfied; `false` otherwise.
133
- */
134
- private static checkActor;
135
- /**
136
- * Determines the timestamp that governs which protocol definition version applies to the given RecordsWrite.
137
- * For an update, this is the initial write's `messageTimestamp` (the protocol version is locked at creation time).
138
- * For a new initial write, returns `undefined` — the latest protocol definition should be used because the
139
- * record is being created now and must conform to the current protocol rules.
140
- */
141
- private static getGoverningTimestamp;
142
- private static getTypeName;
143
53
  }
144
54
  //# sourceMappingURL=protocol-authorization.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"protocol-authorization.d.ts","sourceRoot":"","sources":["../../../../src/core/protocol-authorization.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EA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2B;IA6BhD;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,UAAU;IA4CzB;;;;OAIG;mBACkB,iBAAiB;IAuGtC;;;;;;;;;OASG;mBACkB,2BAA2B;IAkFhD;;;;OAIG;mBACkB,8BAA8B;IAgGnD;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,eAAe;IAqB9B,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAmCjC;;;;;OAKG;mBACkB,0BAA0B;IAoD/C;;;;;OAKG;mBACkB,UAAU;IAiD/B;;;;;OAKG;mBACkB,qBAAqB;IAkB1C,OAAO,CAAC,MAAM,CAAC,WAAW;CAG3B"}
1
+ {"version":3,"file":"protocol-authorization.d.ts","sourceRoot":"","sources":["../../../../src/core/protocol-authorization.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAEnE,OAAO,KAAK,EAAE,kBAAkB,EAA8C,MAAM,6BAA6B,CAAC;AAkBlH;;;GAGG;AACH,MAAM,MAAM,yBAAyB,GAAG,CACtC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,YAAY,EAC1B,gBAAgB,CAAC,EAAE,MAAM,KACtB,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAEjC,qBAAa,qBAAqB;IAEhC;;;OAGG;WACiB,4BAA4B,CAC9C,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,YAAY,EAC7B,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,IAAI,CAAC;IAkDhB;;;OAGG;WACiB,cAAc,CAChC,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,YAAY,EAC7B,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,IAAI,CAAC;IAuDhB;;;;OAIG;WACiB,aAAa,CAC/B,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,WAAW,EAC5B,kBAAkB,EAAE,YAAY,EAChC,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,IAAI,CAAC;WAmDI,yBAAyB,CAC3C,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,YAAY,GAAG,YAAY,GAAG,gBAAgB,EAC/D,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,IAAI,CAAC;IAsChB;;;OAGG;WACiB,eAAe,CACjC,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,aAAa,EAC9B,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,IAAI,CAAC;IAmDhB;;;;;OAKG;WACiB,uBAAuB,CACzC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,YAAY,EAC1B,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC,kBAAkB,CAAC;IAoC9B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,UAAU;IAYzB;;;OAGG;mBACkB,2BAA2B;CAOjD"}
@@ -0,0 +1,24 @@
1
+ import type { MessageStore } from '../types/message-store.js';
2
+ import type { RecordsWriteMessage } from '../types/records-types.js';
3
+ import { RecordsWrite } from '../interfaces/records-write.js';
4
+ /**
5
+ * Fetches the initial RecordsWrite message associated with the given (tenant + recordId).
6
+ */
7
+ export declare function fetchInitialWrite(tenant: string, recordId: string, messageStore: MessageStore): Promise<RecordsWriteMessage | undefined>;
8
+ /**
9
+ * Constructs the chain of EXISTING records in the datastore where the first record is the root initial `RecordsWrite` of the record chain
10
+ * and last record is the initial `RecordsWrite` of the descendant record specified.
11
+ * @param descendantRecordId The ID of the descendent record to start constructing the record chain from by repeatedly looking up the parent.
12
+ * @returns the record chain where each record is represented by its initial `RecordsWrite`;
13
+ * returns empty array if `descendantRecordId` is `undefined`.
14
+ * @throws {DwnError} if `descendantRecordId` is defined but any initial `RecordsWrite` is not found in the chain of records.
15
+ */
16
+ export declare function constructRecordChain(tenant: string, descendantRecordId: string | undefined, messageStore: MessageStore): Promise<RecordsWriteMessage[]>;
17
+ /**
18
+ * Determines the timestamp that governs which protocol definition version applies to the given RecordsWrite.
19
+ * For an update, this is the initial write's `messageTimestamp` (the protocol version is locked at creation time).
20
+ * For a new initial write, returns `undefined` — the latest protocol definition should be used because the
21
+ * record is being created now and must conform to the current protocol rules.
22
+ */
23
+ export declare function getGoverningTimestamp(tenant: string, incomingMessage: RecordsWrite, messageStore: MessageStore): Promise<string | undefined>;
24
+ //# sourceMappingURL=record-chain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-chain.d.ts","sourceRoot":"","sources":["../../../../src/core/record-chain.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAI9D;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAe1C;AAED;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,MAAM,EACd,kBAAkB,EAAE,MAAM,GAAG,SAAS,EACtC,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,mBAAmB,EAAE,CAAC,CA8BhC;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,YAAY,EAC7B,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAY7B"}
@@ -27,7 +27,8 @@ export declare class RecordsWriteHandler implements MethodHandler {
27
27
  private static validateSchemaForCoreRecordsWrite;
28
28
  /**
29
29
  * Performs additional necessary tasks if the RecordsWrite handled is a core DWN RecordsWrite that need additional processing.
30
- * For instance: a Permission revocation RecordsWrite.
30
+ * For instance: when a Permission revocation is written, all messages authorized by the revoked grant
31
+ * that were created after the revocation timestamp are deleted from all stores.
31
32
  */
32
33
  private postProcessingForCoreRecordsWrite;
33
34
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"records-write.d.ts","sourceRoot":"","sources":["../../../../src/handlers/records-write.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAiB7F,KAAK,WAAW,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,mBAAmB,CAAC;IAAC,UAAU,CAAC,EAAE,cAAc,CAAC,UAAU,CAAC,CAAA;CAAC,CAAC;AAE5G,qBAAa,mBAAoB,YAAW,aAAa;IAGrD,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,YAA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AO,KAAK,EACU,kBAAkB,EACtC,yBAAyB,EAC1B,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAY9D,MAAM,MAAM,yBAAyB,GAAG;IACtC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,kBAAkB,CAAC;IAC/B,MAAM,EAAE,aAAa,CAAC;IACtB;;OAEG;IACH,cAAc,CAAC,EAAE,8BAA8B,CAAC;IAChD,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,qBAAa,kBAAmB,SAAQ,eAAe,CAAC,yBAAyB,CAAC;WAC5D,KAAK,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,kBAAkB,CAAC;WAStE,MAAM,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAwB3F;;;OAGG;IACU,uBAAuB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAW/E;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,0BAA0B;IAuBzC;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,YAAY;IA+B3B,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAoBhC;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,4BAA4B;IAiC3C;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,0BAA0B;IAyOzC;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,eAAe;IAgC9B;;;;;;;OAOG;IACH,OAAO,CAAC,MAAM,CAAC,0BAA0B;IA+BzC,OAAO,CAAC,MAAM,CAAC,mBAAmB;CAmCnC"}
@@ -0,0 +1,33 @@
1
+ import type { GenericMessage } from '../types/message-types.js';
2
+ import type { MessageStore } from '../types/message-store.js';
3
+ import type { RecordsWrite } from './records-write.js';
4
+ import type { InternalRecordsWriteMessage, RecordsWriteMessage } from '../types/records-types.js';
5
+ /**
6
+ * Gets the initial write from the given list of messages.
7
+ */
8
+ export declare function getInitialWrite(messages: GenericMessage[]): Promise<RecordsWriteMessage>;
9
+ /**
10
+ * Verifies that immutable properties of the two given messages are identical.
11
+ * @throws {DwnError} if immutable properties between two RecordsWrite messages differ.
12
+ */
13
+ export declare function verifyEqualityOfImmutableProperties(existingWriteMessage: RecordsWriteMessage, newMessage: RecordsWriteMessage): boolean;
14
+ /**
15
+ * Gets the DID of the attesters of the given message.
16
+ */
17
+ export declare function getAttesters(message: InternalRecordsWriteMessage): string[];
18
+ /**
19
+ * Fetches the newest RecordsWrite for a given recordId from the message store.
20
+ * @throws {DwnError} if no write is found.
21
+ */
22
+ export declare function fetchNewestRecordsWrite(messageStore: MessageStore, tenant: string, recordId: string): Promise<RecordsWriteMessage>;
23
+ /**
24
+ * Fetches the initial RecordsWrite of a record.
25
+ * @returns The initial RecordsWrite if found; `undefined` otherwise.
26
+ */
27
+ export declare function fetchInitialRecordsWrite(messageStore: MessageStore, tenant: string, recordId: string): Promise<RecordsWrite | undefined>;
28
+ /**
29
+ * Fetches the initial RecordsWrite message of a record.
30
+ * @returns The initial RecordsWriteMessage if found; `undefined` otherwise.
31
+ */
32
+ export declare function fetchInitialRecordsWriteMessage(messageStore: MessageStore, tenant: string, recordId: string): Promise<RecordsWriteMessage | undefined>;
33
+ //# sourceMappingURL=records-write-query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"records-write-query.d.ts","sourceRoot":"","sources":["../../../../src/interfaces/records-write-query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,2BAA2B,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAkBlG;;GAEG;AACH,wBAAsB,eAAe,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAS9F;AAED;;;GAGG;AACH,wBAAgB,mCAAmC,CACjD,oBAAoB,EAAE,mBAAmB,EAAE,UAAU,EAAE,mBAAmB,GACzE,OAAO,CAyBT;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,2BAA2B,GAAG,MAAM,EAAE,CAI3E;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAC3C,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,mBAAmB,CAAC,CAe9B;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,CAC5C,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC,CASnC;AAED;;;GAGG;AACH,wBAAsB,+BAA+B,CACnD,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAS1C"}
@@ -0,0 +1,35 @@
1
+ import type { GeneralJws } from '../types/jws-types.js';
2
+ import type { MessageSigner } from '../types/signer.js';
3
+ import type { EncryptionInput, JweEncryption } from '../utils/encryption.js';
4
+ import type { RecordsWriteDescriptor, RecordsWriteMessage } from '../types/records-types.js';
5
+ /**
6
+ * Creates the JWE `encryption` property if encryption input is given. Else `undefined` is returned.
7
+ * Uses ECDH-ES+A256KW key agreement with X25519 and AEAD content encryption (A256GCM or XC20P).
8
+ * @param descriptor Descriptor of the `RecordsWrite` message which contains the information needed by key path derivation schemes.
9
+ * @param encryptionInput The encryption input containing CEK, IV, authentication tag, and recipient key encryption inputs.
10
+ */
11
+ export declare function createEncryptionProperty(descriptor: RecordsWriteDescriptor, encryptionInput: EncryptionInput | undefined): Promise<JweEncryption | undefined>;
12
+ /**
13
+ * Creates the `attestation` property of a RecordsWrite message if given signature inputs; returns `undefined` otherwise.
14
+ */
15
+ export declare function createAttestation(descriptorCid: string, signers?: MessageSigner[]): Promise<GeneralJws | undefined>;
16
+ /**
17
+ * Creates the `signature` property in the `authorization` of a `RecordsWrite` message.
18
+ */
19
+ export declare function createSignerSignature(input: {
20
+ recordId: string;
21
+ contextId: string | undefined;
22
+ descriptorCid: string;
23
+ attestation: GeneralJws | undefined;
24
+ encryption: JweEncryption | undefined;
25
+ signer: MessageSigner;
26
+ delegatedGrantId?: string;
27
+ permissionGrantId?: string;
28
+ protocolRole?: string;
29
+ }): Promise<GeneralJws>;
30
+ /**
31
+ * Validates the structural integrity of the `attestation` property.
32
+ * NOTE: Cryptographic verification of attestation signatures is performed in `authenticate()`.
33
+ */
34
+ export declare function validateAttestationIntegrity(message: RecordsWriteMessage): Promise<void>;
35
+ //# sourceMappingURL=records-write-signing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"records-write-signing.d.ts","sourceRoot":"","sources":["../../../../src/interfaces/records-write-signing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,KAAK,EAAkC,sBAAsB,EAAE,mBAAmB,EAAgC,MAAM,2BAA2B,CAAC;AAW3J;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAC5C,UAAU,EAAE,sBAAsB,EAClC,eAAe,EAAE,eAAe,GAAG,SAAS,GAC3C,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CA0BpC;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAUzH;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,KAAK,EAAE;IACjD,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,UAAU,GAAG,SAAS,CAAC;IACpC,UAAU,EAAE,aAAa,GAAG,SAAS,CAAC;IACtC,MAAM,EAAE,aAAa,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,GAAG,OAAO,CAAC,UAAU,CAAC,CAwBtB;AAED;;;GAGG;AACH,wBAAsB,4BAA4B,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiC9F"}
@@ -205,8 +205,7 @@ export declare class RecordsWrite implements MessageInterface<RecordsWriteMessag
205
205
  */
206
206
  private validateIntegrity;
207
207
  /**
208
- * Validates the structural integrity of the `attestation` property.
209
- * NOTE: Cryptographic verification of attestation signatures is performed in `authenticate()`.
208
+ * Delegate to the standalone `validateAttestationIntegrity` function for backward compatibility.
210
209
  */
211
210
  private static validateAttestationIntegrity;
212
211
  /**
@@ -236,32 +235,11 @@ export declare class RecordsWrite implements MessageInterface<RecordsWriteMessag
236
235
  * Checks if the given message is the initial entry of a record.
237
236
  */
238
237
  static isInitialWrite(message: GenericMessage): Promise<boolean>;
239
- /**
240
- * Creates the JWE `encryption` property if encryption input is given. Else `undefined` is returned.
241
- * Uses ECDH-ES+A256KW key agreement with X25519 and AEAD content encryption (A256GCM or XC20P).
242
- * @param descriptor Descriptor of the `RecordsWrite` message which contains the information needed by key path derivation schemes.
243
- */
244
- /**
245
- * Creates the JWE `encryption` property if encryption input is given. Else `undefined` is returned.
246
- * Uses ECDH-ES+A256KW key agreement with X25519 and AEAD content encryption (A256GCM or XC20P).
247
- * @param descriptor Descriptor of the `RecordsWrite` message which contains the information needed by key path derivation schemes.
248
- * @param encryptionInput The encryption input containing CEK, IV, and recipient key encryption inputs.
249
- * @param tag The authentication tag from the AEAD content encryption (stored in the JWE, separate from the ciphertext).
250
- */
251
- /**
252
- * Creates the JWE `encryption` property if encryption input is given. Else `undefined` is returned.
253
- * Uses ECDH-ES+A256KW key agreement with X25519 and AEAD content encryption (A256GCM or XC20P).
254
- * @param descriptor Descriptor of the `RecordsWrite` message which contains the information needed by key path derivation schemes.
255
- * @param encryptionInput The encryption input containing CEK, IV, authentication tag, and recipient key encryption inputs.
256
- */
238
+ /** Delegate to `createEncryptionProperty` in `records-write-signing.ts`. */
257
239
  private static createEncryptionProperty;
258
- /**
259
- * Creates the `attestation` property of a RecordsWrite message if given signature inputs; returns `undefined` otherwise.
260
- */
240
+ /** Delegate to `createAttestation` in `records-write-signing.ts`. */
261
241
  static createAttestation(descriptorCid: string, signers?: MessageSigner[]): Promise<GeneralJws | undefined>;
262
- /**
263
- * Creates the `signature` property in the `authorization` of a `RecordsWrite` message.
264
- */
242
+ /** Delegate to `createSignerSignature` in `records-write-signing.ts`. */
265
243
  static createSignerSignature(input: {
266
244
  recordId: string;
267
245
  contextId: string | undefined;
@@ -273,29 +251,17 @@ export declare class RecordsWrite implements MessageInterface<RecordsWriteMessag
273
251
  permissionGrantId?: string;
274
252
  protocolRole?: string;
275
253
  }): Promise<GeneralJws>;
276
- /**
277
- * Gets the initial write from the given list of `RecordsWrite`.
278
- */
254
+ /** Delegate to `getInitialWrite` in `records-write-query.ts`. */
279
255
  static getInitialWrite(messages: GenericMessage[]): Promise<RecordsWriteMessage>;
280
- /**
281
- * Verifies that immutable properties of the two given messages are identical.
282
- * @throws {Error} if immutable properties between two RecordsWrite message
283
- */
256
+ /** Delegate to `verifyEqualityOfImmutableProperties` in `records-write-query.ts`. */
284
257
  static verifyEqualityOfImmutableProperties(existingWriteMessage: RecordsWriteMessage, newMessage: RecordsWriteMessage): boolean;
285
- /**
286
- * Gets the DID of the attesters of the given message.
287
- */
258
+ /** Delegate to `getAttesters` in `records-write-query.ts`. */
288
259
  static getAttesters(message: InternalRecordsWriteMessage): string[];
260
+ /** Delegate to `fetchNewestRecordsWrite` in `records-write-query.ts`. */
289
261
  static fetchNewestRecordsWrite(messageStore: MessageStore, tenant: string, recordId: string): Promise<RecordsWriteMessage>;
290
- /**
291
- * Fetches the initial RecordsWrite of a record.
292
- * @returns The initial RecordsWrite if found; `undefined` otherwise.
293
- */
262
+ /** Delegate to `fetchInitialRecordsWrite` in `records-write-query.ts`. */
294
263
  static fetchInitialRecordsWrite(messageStore: MessageStore, tenant: string, recordId: string): Promise<RecordsWrite | undefined>;
295
- /**
296
- * Fetches the initial RecordsWrite message of a record.
297
- * @returns The initial RecordsWriteMessage if found; `undefined` otherwise.
298
- */
264
+ /** Delegate to `fetchInitialRecordsWriteMessage` in `records-write-query.ts`. */
299
265
  static fetchInitialRecordsWriteMessage(messageStore: MessageStore, tenant: string, recordId: string): Promise<RecordsWriteMessage | undefined>;
300
266
  }
301
267
  //# sourceMappingURL=records-write.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"records-write.d.ts","sourceRoot":"","sources":["../../../../src/interfaces/records-write.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EACV,8BAA8B,EAC9B,2BAA2B,EAE3B,sBAAsB,EACtB,mBAAmB,EACnB,4BAA4B,EAC5B,gBAAgB,EACjB,MAAM,2BAA2B,CA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,GAAG,MAAM,EAAE;IAI1E,yEAAyE;WACrD,uBAAuB,CACzC,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAC3D,OAAO,CAAC,mBAAmB,CAAC;IAI/B,0EAA0E;WACtD,wBAAwB,CAC1C,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAC3D,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;IAIpC,iFAAiF;WAC7D,+BAA+B,CACjD,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAC3D,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC;CAG5C"}
@@ -0,0 +1,70 @@
1
+ import type { Filter, KeyValues, QueryOptions } from '../types/query-types.js';
2
+ import type { IndexedItem, IndexLevelOptions } from './index-level.js';
3
+ import type { LevelWrapperBatchOperation } from './level-wrapper.js';
4
+ import type { CompoundIndexDefinition } from './index-level.js';
5
+ import type { LevelWrapper } from './level-wrapper.js';
6
+ /** Separator between compound key segments (higher than \x00 so prefix scans work correctly). */
7
+ export declare const COMPOUND_SEGMENT_SEPARATOR = "\u0001";
8
+ /**
9
+ * Gets the compound index partition for a given compound index definition.
10
+ * Compound index sublevels use the naming convention `__compound:<name>__`.
11
+ */
12
+ export declare function getCompoundIndexPartition(db: LevelWrapper<string>, tenant: string, compoundIndex: CompoundIndexDefinition): Promise<LevelWrapper<string>>;
13
+ /**
14
+ * Builds a compound index key from the given indexes and compound index definition.
15
+ *
16
+ * Key format: `<prop1>\x01<prop2>\x01...\x01<sortValue>\x00<messageCid>`
17
+ *
18
+ * @returns the compound key, or undefined if the indexes don't contain all required properties.
19
+ */
20
+ export declare function buildCompoundKey(messageCid: string, indexes: KeyValues, compoundIndex: CompoundIndexDefinition, encodeValue: (value: string | number | boolean) => string, delimiter: string): string | undefined;
21
+ /**
22
+ * Builds the prefix portion of a compound key from filter values (without the sort/messageCid suffix).
23
+ * Used for range scans: all entries with this prefix match the filter.
24
+ */
25
+ export declare function buildCompoundPrefix(filter: Filter, compoundIndex: CompoundIndexDefinition, encodeValue: (value: string | number | boolean) => string): string | undefined;
26
+ /**
27
+ * Creates a put operation for a compound index entry.
28
+ * Returns undefined if the indexes don't contain all required compound index properties.
29
+ */
30
+ export declare function createCompoundIndexPutOperation(db: LevelWrapper<string>, tenant: string, item: IndexedItem, compoundIndex: CompoundIndexDefinition, encodeValue: (value: string | number | boolean) => string, delimiter: string): Promise<LevelWrapperBatchOperation<string>> | undefined;
31
+ /**
32
+ * Creates a delete operation for a compound index entry.
33
+ * Returns undefined if the indexes don't contain all required compound index properties.
34
+ */
35
+ export declare function createCompoundIndexDeleteOperation(db: LevelWrapper<string>, tenant: string, messageCid: string, indexes: KeyValues, compoundIndex: CompoundIndexDefinition, encodeValue: (value: string | number | boolean) => string, delimiter: string): Promise<LevelWrapperBatchOperation<string>> | undefined;
36
+ /**
37
+ * Generic helper to create a batch operation for any named partition under a tenant.
38
+ */
39
+ export declare function createOperationForPartition(db: LevelWrapper<string>, tenant: string, partitionName: string, operation: LevelWrapperBatchOperation<string>): Promise<LevelWrapperBatchOperation<string>>;
40
+ /**
41
+ * Selects the best compound index that covers the given filter and sort requirements.
42
+ *
43
+ * A compound index "covers" a query when:
44
+ * 1. Every property in the compound index definition is present in the filter as an equality filter.
45
+ * 2. The compound index's sort property matches the query's sort property.
46
+ *
47
+ * Among multiple matching compound indexes, the one with the most properties is preferred
48
+ * (more specific = fewer false positives in the prefix scan).
49
+ */
50
+ export declare function selectCompoundIndex(filter: Filter, queryOptions: QueryOptions, compoundIndexes: CompoundIndexDefinition[]): CompoundIndexDefinition | undefined;
51
+ /**
52
+ * Queries using a compound index. This is the most efficient query strategy: a single LevelDB
53
+ * range scan that filters, sorts, and paginates all at once.
54
+ *
55
+ * The compound key encodes the filter properties as a prefix and the sort property as a suffix,
56
+ * so iterating over keys with the filter prefix yields results in sort order.
57
+ *
58
+ * Any remaining filter properties not covered by the compound index are verified in memory.
59
+ *
60
+ * @param queryWithIteratorPagingFallback callback to fall back to iterator paging if compound prefix fails.
61
+ */
62
+ export declare function queryWithCompoundIndex(db: LevelWrapper<string>, tenant: string, filter: Filter, queryOptions: QueryOptions, compoundIndex: CompoundIndexDefinition, encodeValue: (value: string | number | boolean) => string, delimiter: string, queryWithIteratorPagingFallback: (tenant: string, filters: Filter[], queryOptions: QueryOptions, options?: IndexLevelOptions) => Promise<IndexedItem[]>, options?: IndexLevelOptions): Promise<IndexedItem[]>;
63
+ /**
64
+ * Counts items matching a compound index prefix without loading full records.
65
+ * Iterates only keys (not values) for maximum efficiency.
66
+ *
67
+ * @param queryFallback callback to fall back to full query if compound prefix fails.
68
+ */
69
+ export declare function countWithCompoundIndex(db: LevelWrapper<string>, tenant: string, filter: Filter, compoundIndex: CompoundIndexDefinition, encodeValue: (value: string | number | boolean) => string, queryFallback: (tenant: string, filters: Filter[], queryOptions: QueryOptions, options?: IndexLevelOptions) => Promise<IndexedItem[]>, options?: IndexLevelOptions): Promise<number>;
70
+ //# sourceMappingURL=index-level-compound.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-level-compound.d.ts","sourceRoot":"","sources":["../../../../src/store/index-level-compound.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,KAAK,EAAE,0BAA0B,EAA+B,MAAM,oBAAoB,CAAC;AAElG,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAKvD,iGAAiG;AACjG,eAAO,MAAM,0BAA0B,WAAS,CAAC;AAEjD;;;GAGG;AACH,wBAAsB,yBAAyB,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AAE,OAAO,EAAE,MAAM,EAAE,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,iBAAiB,KAAK,OAAO,CAAC,WAAW,EAAE,CAAC,EACrI,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,MAAM,CAAC,CA4CjB"}
@@ -203,64 +203,6 @@ export declare class IndexLevel {
203
203
  * NOTE: we currently only use this for strings, numbers and booleans.
204
204
  */
205
205
  static encodeValue(value: string | number | boolean): string;
206
- /**
207
- * Gets the compound index partition for a given compound index definition.
208
- * Compound index sublevels use the naming convention `__compound:<name>__`.
209
- */
210
- private getCompoundIndexPartition;
211
- /**
212
- * Builds a compound index key from the given indexes and compound index definition.
213
- *
214
- * Key format: `<prop1>\x01<prop2>\x01...\x01<sortValue>\x00<messageCid>`
215
- *
216
- * @returns the compound key, or undefined if the indexes don't contain all required properties.
217
- */
218
- private static buildCompoundKey;
219
- /**
220
- * Builds the prefix portion of a compound key from filter values (without the sort/messageCid suffix).
221
- * Used for range scans: all entries with this prefix match the filter.
222
- */
223
- private static buildCompoundPrefix;
224
- /**
225
- * Creates a put operation for a compound index entry.
226
- * Returns undefined if the indexes don't contain all required compound index properties.
227
- */
228
- private createCompoundIndexPutOperation;
229
- /**
230
- * Creates a delete operation for a compound index entry.
231
- * Returns undefined if the indexes don't contain all required compound index properties.
232
- */
233
- private createCompoundIndexDeleteOperation;
234
- /**
235
- * Generic helper to create a batch operation for any named partition under a tenant.
236
- */
237
- private createOperationForPartition;
238
- /**
239
- * Selects the best compound index that covers the given filter and sort requirements.
240
- *
241
- * A compound index "covers" a query when:
242
- * 1. Every property in the compound index definition is present in the filter as an equality filter.
243
- * 2. The compound index's sort property matches the query's sort property.
244
- *
245
- * Among multiple matching compound indexes, the one with the most properties is preferred
246
- * (more specific = fewer false positives in the prefix scan).
247
- */
248
- private selectCompoundIndex;
249
- /**
250
- * Queries using a compound index. This is the most efficient query strategy: a single LevelDB
251
- * range scan that filters, sorts, and paginates all at once.
252
- *
253
- * The compound key encodes the filter properties as a prefix and the sort property as a suffix,
254
- * so iterating over keys with the filter prefix yields results in sort order.
255
- *
256
- * Any remaining filter properties not covered by the compound index are verified in memory.
257
- */
258
- private queryWithCompoundIndex;
259
- /**
260
- * Counts items matching a compound index prefix without loading full records.
261
- * Iterates only keys (not values) for maximum efficiency.
262
- */
263
- private countWithCompoundIndex;
264
206
  private static shouldQueryWithInMemoryPaging;
265
207
  static isFilterConcise(filter: Filter, queryOptions: QueryOptions): boolean;
266
208
  }