keri-ts 0.11.0 → 1.0.0

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 (370) hide show
  1. package/README.md +9 -2
  2. package/esm/keri/npm/src/_dnt.polyfills.js +36 -0
  3. package/esm/keri/npm/src/acdc/observing.js +8 -34
  4. package/esm/keri/npm/src/acdc/regbasing.js +9 -20
  5. package/esm/keri/npm/src/acdc/regengine.js +17 -96
  6. package/esm/keri/npm/src/acdc/registering.js +9 -12
  7. package/esm/keri/npm/src/acdc/registraring.js +82 -46
  8. package/esm/keri/npm/src/acdc/scheming.js +12 -69
  9. package/esm/keri/npm/src/app/abortable.js +41 -4
  10. package/esm/keri/npm/src/app/agent-runtime.js +75 -169
  11. package/esm/keri/npm/src/app/authenticating.js +4 -24
  12. package/esm/keri/npm/src/app/byte-source.js +8 -16
  13. package/esm/keri/npm/src/app/cesr-egress.js +129 -143
  14. package/esm/keri/npm/src/app/cesr-http.js +10 -25
  15. package/esm/keri/npm/src/app/challenging.js +13 -8
  16. package/esm/keri/npm/src/app/cli/annotate.js +3 -8
  17. package/esm/keri/npm/src/app/cli/benchmark.js +3 -5
  18. package/esm/keri/npm/src/app/cli/challenge.js +16 -14
  19. package/esm/keri/npm/src/app/cli/common/context.js +1 -4
  20. package/esm/keri/npm/src/app/cli/common/existing.js +0 -18
  21. package/esm/keri/npm/src/app/cli/db-dump.js +3 -17
  22. package/esm/keri/npm/src/app/cli/delegate.js +37 -57
  23. package/esm/keri/npm/src/app/cli/did.js +12 -21
  24. package/esm/keri/npm/src/app/cli/ends.js +3 -5
  25. package/esm/keri/npm/src/app/cli/exchange.js +0 -2
  26. package/esm/keri/npm/src/app/cli/incept.js +5 -7
  27. package/esm/keri/npm/src/app/cli/init.js +3 -9
  28. package/esm/keri/npm/src/app/cli/ipex.js +129 -63
  29. package/esm/keri/npm/src/app/cli/loc.js +7 -10
  30. package/esm/keri/npm/src/app/cli/multisig.js +140 -54
  31. package/esm/keri/npm/src/app/cli/oobi.js +3 -5
  32. package/esm/keri/npm/src/app/cli/query.js +28 -29
  33. package/esm/keri/npm/src/app/cli/rotate.js +3 -5
  34. package/esm/keri/npm/src/app/cli/vc.js +2 -3
  35. package/esm/keri/npm/src/app/cli/verifier.js +5 -9
  36. package/esm/keri/npm/src/app/credential-workflows.js +22 -44
  37. package/esm/keri/npm/src/app/cue-runtime.js +23 -89
  38. package/esm/keri/npm/src/app/delegating.js +26 -18
  39. package/esm/keri/npm/src/app/endpoint-roleing.js +30 -26
  40. package/esm/keri/npm/src/app/essr.js +10 -75
  41. package/esm/keri/npm/src/app/exchanging.js +82 -300
  42. package/esm/keri/npm/src/app/forwarding.js +124 -534
  43. package/esm/keri/npm/src/app/grouping.js +192 -108
  44. package/esm/keri/npm/src/app/habbing.js +37 -87
  45. package/esm/keri/npm/src/app/httping.js +44 -12
  46. package/esm/keri/npm/src/app/ipex-credentialing.js +38 -35
  47. package/esm/keri/npm/src/app/ipex-graph.js +147 -37
  48. package/esm/keri/npm/src/app/ipex-grouping.js +31 -72
  49. package/esm/keri/npm/src/app/ipex-node-authentication.js +108 -0
  50. package/esm/keri/npm/src/app/ipex-v2.js +28 -132
  51. package/esm/keri/npm/src/app/ipexing.js +2 -10
  52. package/esm/keri/npm/src/app/mailbox-director.js +30 -128
  53. package/esm/keri/npm/src/app/mailbox-sse.js +10 -27
  54. package/esm/keri/npm/src/app/mailboxing.js +12 -16
  55. package/esm/keri/npm/src/app/multisig-workflows.js +142 -222
  56. package/esm/keri/npm/src/app/notifying.js +15 -36
  57. package/esm/keri/npm/src/app/oobi-replies.js +55 -138
  58. package/esm/keri/npm/src/app/oobiery.js +63 -205
  59. package/esm/keri/npm/src/app/parsering.js +48 -46
  60. package/esm/keri/npm/src/app/query-replies.js +36 -117
  61. package/esm/keri/npm/src/app/querying.js +246 -511
  62. package/esm/keri/npm/src/app/reactor.js +175 -298
  63. package/esm/keri/npm/src/app/reply-streams.js +12 -131
  64. package/esm/keri/npm/src/app/respondant.js +256 -71
  65. package/esm/keri/npm/src/app/runtime-services.js +0 -3
  66. package/esm/keri/npm/src/app/signaling.js +29 -240
  67. package/esm/keri/npm/src/app/socket-source.js +2 -3
  68. package/esm/keri/npm/src/app/stored-replies.js +13 -45
  69. package/esm/keri/npm/src/app/tcp-conversation.js +85 -0
  70. package/esm/keri/npm/src/app/tcp-egress.js +154 -237
  71. package/esm/keri/npm/src/app/verifier-agent.js +25 -43
  72. package/esm/keri/npm/src/app/verifying.js +10 -40
  73. package/esm/keri/npm/src/app/version.js +2 -2
  74. package/esm/keri/npm/src/app/witnessing.js +231 -273
  75. package/esm/keri/npm/src/core/deck.js +5 -44
  76. package/esm/keri/npm/src/core/dispatch.js +10 -2
  77. package/esm/keri/npm/src/core/errors.js +5 -10
  78. package/esm/keri/npm/src/core/eventing.js +153 -366
  79. package/esm/keri/npm/src/core/kever-decisions.js +5 -10
  80. package/esm/keri/npm/src/core/kever.js +80 -163
  81. package/esm/keri/npm/src/core/kram-pruning.js +2 -12
  82. package/esm/keri/npm/src/core/kram-staging.js +56 -118
  83. package/esm/keri/npm/src/core/kram-time.js +6 -13
  84. package/esm/keri/npm/src/core/kraming.js +28 -49
  85. package/esm/keri/npm/src/core/protocol-eventing.js +5 -0
  86. package/esm/keri/npm/src/core/protocol-exchanging.js +21 -0
  87. package/esm/keri/npm/src/core/protocol-vdr-eventing.js +10 -11
  88. package/esm/keri/npm/src/core/records.js +0 -19
  89. package/esm/keri/npm/src/core/routing.js +138 -185
  90. package/esm/keri/npm/src/db/basing.js +162 -196
  91. package/esm/keri/npm/src/db/core/keys.js +2 -2
  92. package/esm/keri/npm/src/db/core/lmdber.js +20 -85
  93. package/esm/keri/npm/src/db/core/path-manager.js +2 -4
  94. package/esm/keri/npm/src/db/escrowing.js +12 -154
  95. package/esm/keri/npm/src/db/exchange-nests.js +21 -116
  96. package/esm/keri/npm/src/db/index.js +0 -2
  97. package/esm/keri/npm/src/db/keeping.js +1 -3
  98. package/esm/keri/npm/src/db/kel-replay.js +2 -21
  99. package/esm/keri/npm/src/db/kram-factors.js +16 -49
  100. package/esm/keri/npm/src/db/mailboxing.js +2 -5
  101. package/esm/keri/npm/src/db/payload-archive.js +1 -1
  102. package/esm/keri/npm/src/db/payload-store.js +4 -14
  103. package/esm/keri/npm/src/db/reger.js +12 -42
  104. package/esm/keri/npm/src/db/subing.js +0 -8
  105. package/esm/keri/npm/src/db/tel-replay.js +4 -36
  106. package/esm/keri/npm/src/db/witness-replay.js +6 -12
  107. package/esm/keri/npm/src/did/keri/resolving.js +4 -18
  108. package/esm/keri/npm/src/did/webs/artifacts.js +13 -13
  109. package/esm/keri/npm/src/did/webs/designated-aliases.js +16 -44
  110. package/esm/keri/npm/src/did/webs/documenting.js +8 -8
  111. package/esm/keri/npm/src/did/webs/resolving.js +9 -27
  112. package/esm/keri/npm/src/runtime/index.js +70 -71
  113. package/esm/keri/npm/src/vdr/credential-tsn.js +126 -114
  114. package/esm/keri/npm/src/vdr/credentialing.js +0 -27
  115. package/esm/keri/npm/src/vdr/eventing.js +50 -56
  116. package/esm/keri/npm/src/vdr/registry-tsn.js +110 -111
  117. package/esm/keri/npm/src/vdr/tsn-query.js +15 -10
  118. package/package.json +4 -20
  119. package/types/_dnt.polyfills.d.ts +49 -0
  120. package/types/_dnt.polyfills.d.ts.map +1 -1
  121. package/types/acdc/observing.d.ts +1 -8
  122. package/types/acdc/observing.d.ts.map +1 -1
  123. package/types/acdc/regbasing.d.ts +5 -8
  124. package/types/acdc/regbasing.d.ts.map +1 -1
  125. package/types/acdc/regengine.d.ts +6 -25
  126. package/types/acdc/regengine.d.ts.map +1 -1
  127. package/types/acdc/registering.d.ts +6 -6
  128. package/types/acdc/registering.d.ts.map +1 -1
  129. package/types/acdc/registraring.d.ts +21 -21
  130. package/types/acdc/registraring.d.ts.map +1 -1
  131. package/types/acdc/scheming.d.ts +3 -2
  132. package/types/acdc/scheming.d.ts.map +1 -1
  133. package/types/app/abortable.d.ts +2 -0
  134. package/types/app/abortable.d.ts.map +1 -1
  135. package/types/app/agent-runtime.d.ts +27 -90
  136. package/types/app/agent-runtime.d.ts.map +1 -1
  137. package/types/app/authenticating.d.ts.map +1 -1
  138. package/types/app/byte-source.d.ts +4 -4
  139. package/types/app/byte-source.d.ts.map +1 -1
  140. package/types/app/cesr-egress.d.ts +18 -21
  141. package/types/app/cesr-egress.d.ts.map +1 -1
  142. package/types/app/cesr-http.d.ts +6 -7
  143. package/types/app/cesr-http.d.ts.map +1 -1
  144. package/types/app/challenging.d.ts +6 -0
  145. package/types/app/challenging.d.ts.map +1 -1
  146. package/types/app/cli/annotate.d.ts.map +1 -1
  147. package/types/app/cli/benchmark.d.ts.map +1 -1
  148. package/types/app/cli/challenge.d.ts.map +1 -1
  149. package/types/app/cli/common/context.d.ts +0 -4
  150. package/types/app/cli/common/context.d.ts.map +1 -1
  151. package/types/app/cli/common/existing.d.ts +0 -4
  152. package/types/app/cli/common/existing.d.ts.map +1 -1
  153. package/types/app/cli/db-dump.d.ts +0 -2
  154. package/types/app/cli/db-dump.d.ts.map +1 -1
  155. package/types/app/cli/delegate.d.ts +0 -22
  156. package/types/app/cli/delegate.d.ts.map +1 -1
  157. package/types/app/cli/did.d.ts.map +1 -1
  158. package/types/app/cli/ends.d.ts.map +1 -1
  159. package/types/app/cli/exchange.d.ts.map +1 -1
  160. package/types/app/cli/init.d.ts.map +1 -1
  161. package/types/app/cli/ipex.d.ts +1 -1
  162. package/types/app/cli/ipex.d.ts.map +1 -1
  163. package/types/app/cli/loc.d.ts.map +1 -1
  164. package/types/app/cli/multisig.d.ts.map +1 -1
  165. package/types/app/cli/oobi.d.ts +1 -1
  166. package/types/app/cli/oobi.d.ts.map +1 -1
  167. package/types/app/cli/query.d.ts.map +1 -1
  168. package/types/app/cli/rotate.d.ts.map +1 -1
  169. package/types/app/cli/vc.d.ts.map +1 -1
  170. package/types/app/cli/verifier.d.ts.map +1 -1
  171. package/types/app/credential-workflows.d.ts +4 -9
  172. package/types/app/credential-workflows.d.ts.map +1 -1
  173. package/types/app/cue-runtime.d.ts +3 -37
  174. package/types/app/cue-runtime.d.ts.map +1 -1
  175. package/types/app/delegating.d.ts +13 -8
  176. package/types/app/delegating.d.ts.map +1 -1
  177. package/types/app/endpoint-roleing.d.ts +7 -5
  178. package/types/app/endpoint-roleing.d.ts.map +1 -1
  179. package/types/app/essr.d.ts +5 -19
  180. package/types/app/essr.d.ts.map +1 -1
  181. package/types/app/exchanging.d.ts +17 -29
  182. package/types/app/exchanging.d.ts.map +1 -1
  183. package/types/app/forwarding.d.ts +32 -91
  184. package/types/app/forwarding.d.ts.map +1 -1
  185. package/types/app/grouping.d.ts +52 -8
  186. package/types/app/grouping.d.ts.map +1 -1
  187. package/types/app/habbing.d.ts +16 -25
  188. package/types/app/habbing.d.ts.map +1 -1
  189. package/types/app/httping.d.ts +7 -0
  190. package/types/app/httping.d.ts.map +1 -1
  191. package/types/app/ipex-credentialing.d.ts +9 -4
  192. package/types/app/ipex-credentialing.d.ts.map +1 -1
  193. package/types/app/ipex-graph.d.ts +21 -2
  194. package/types/app/ipex-graph.d.ts.map +1 -1
  195. package/types/app/ipex-grouping.d.ts +6 -14
  196. package/types/app/ipex-grouping.d.ts.map +1 -1
  197. package/types/app/ipex-node-authentication.d.ts +27 -0
  198. package/types/app/ipex-node-authentication.d.ts.map +1 -0
  199. package/types/app/ipex-v2.d.ts +2 -7
  200. package/types/app/ipex-v2.d.ts.map +1 -1
  201. package/types/app/ipexing.d.ts +2 -4
  202. package/types/app/ipexing.d.ts.map +1 -1
  203. package/types/app/mailbox-director.d.ts +12 -31
  204. package/types/app/mailbox-director.d.ts.map +1 -1
  205. package/types/app/mailbox-sse.d.ts +4 -10
  206. package/types/app/mailbox-sse.d.ts.map +1 -1
  207. package/types/app/mailboxing.d.ts +3 -6
  208. package/types/app/mailboxing.d.ts.map +1 -1
  209. package/types/app/multisig-workflows.d.ts +9 -21
  210. package/types/app/multisig-workflows.d.ts.map +1 -1
  211. package/types/app/notifying.d.ts +1 -1
  212. package/types/app/notifying.d.ts.map +1 -1
  213. package/types/app/oobi-replies.d.ts +2 -12
  214. package/types/app/oobi-replies.d.ts.map +1 -1
  215. package/types/app/oobiery.d.ts +0 -2
  216. package/types/app/oobiery.d.ts.map +1 -1
  217. package/types/app/parsering.d.ts +20 -27
  218. package/types/app/parsering.d.ts.map +1 -1
  219. package/types/app/query-replies.d.ts +16 -21
  220. package/types/app/query-replies.d.ts.map +1 -1
  221. package/types/app/querying.d.ts +59 -132
  222. package/types/app/querying.d.ts.map +1 -1
  223. package/types/app/reactor.d.ts +44 -77
  224. package/types/app/reactor.d.ts.map +1 -1
  225. package/types/app/reply-streams.d.ts +4 -35
  226. package/types/app/reply-streams.d.ts.map +1 -1
  227. package/types/app/respondant.d.ts +39 -24
  228. package/types/app/respondant.d.ts.map +1 -1
  229. package/types/app/runtime-services.d.ts +0 -3
  230. package/types/app/runtime-services.d.ts.map +1 -1
  231. package/types/app/signaling.d.ts +6 -34
  232. package/types/app/signaling.d.ts.map +1 -1
  233. package/types/app/socket-source.d.ts +2 -3
  234. package/types/app/socket-source.d.ts.map +1 -1
  235. package/types/app/stored-replies.d.ts +3 -10
  236. package/types/app/stored-replies.d.ts.map +1 -1
  237. package/types/app/tcp-conversation.d.ts +27 -0
  238. package/types/app/tcp-conversation.d.ts.map +1 -0
  239. package/types/app/tcp-egress.d.ts +27 -65
  240. package/types/app/tcp-egress.d.ts.map +1 -1
  241. package/types/app/verifier-agent.d.ts +5 -4
  242. package/types/app/verifier-agent.d.ts.map +1 -1
  243. package/types/app/verifying.d.ts +2 -3
  244. package/types/app/verifying.d.ts.map +1 -1
  245. package/types/app/version.d.ts +2 -2
  246. package/types/app/version.d.ts.map +1 -1
  247. package/types/app/witnessing.d.ts +34 -38
  248. package/types/app/witnessing.d.ts.map +1 -1
  249. package/types/core/cues.d.ts +68 -36
  250. package/types/core/cues.d.ts.map +1 -1
  251. package/types/core/deck.d.ts +2 -12
  252. package/types/core/deck.d.ts.map +1 -1
  253. package/types/core/dispatch.d.ts +7 -3
  254. package/types/core/dispatch.d.ts.map +1 -1
  255. package/types/core/errors.d.ts +4 -4
  256. package/types/core/errors.d.ts.map +1 -1
  257. package/types/core/eventing.d.ts +15 -38
  258. package/types/core/eventing.d.ts.map +1 -1
  259. package/types/core/kever-decisions.d.ts +16 -15
  260. package/types/core/kever-decisions.d.ts.map +1 -1
  261. package/types/core/kever.d.ts +11 -45
  262. package/types/core/kever.d.ts.map +1 -1
  263. package/types/core/kram-pruning.d.ts +2 -2
  264. package/types/core/kram-pruning.d.ts.map +1 -1
  265. package/types/core/kram-staging.d.ts +9 -15
  266. package/types/core/kram-staging.d.ts.map +1 -1
  267. package/types/core/kram-time.d.ts +3 -9
  268. package/types/core/kram-time.d.ts.map +1 -1
  269. package/types/core/kraming.d.ts +18 -22
  270. package/types/core/kraming.d.ts.map +1 -1
  271. package/types/core/protocol-eventing.d.ts +5 -0
  272. package/types/core/protocol-eventing.d.ts.map +1 -1
  273. package/types/core/protocol-exchanging.d.ts +8 -0
  274. package/types/core/protocol-exchanging.d.ts.map +1 -1
  275. package/types/core/protocol-vdr-eventing.d.ts +7 -5
  276. package/types/core/protocol-vdr-eventing.d.ts.map +1 -1
  277. package/types/core/records.d.ts +14 -49
  278. package/types/core/records.d.ts.map +1 -1
  279. package/types/core/routing.d.ts +52 -42
  280. package/types/core/routing.d.ts.map +1 -1
  281. package/types/db/basing.d.ts +46 -39
  282. package/types/db/basing.d.ts.map +1 -1
  283. package/types/db/core/keys.d.ts.map +1 -1
  284. package/types/db/core/lmdber.d.ts +3 -10
  285. package/types/db/core/lmdber.d.ts.map +1 -1
  286. package/types/db/core/path-manager.d.ts.map +1 -1
  287. package/types/db/escrowing.d.ts +9 -48
  288. package/types/db/escrowing.d.ts.map +1 -1
  289. package/types/db/exchange-nests.d.ts +5 -29
  290. package/types/db/exchange-nests.d.ts.map +1 -1
  291. package/types/db/exchange-records.d.ts +2 -4
  292. package/types/db/exchange-records.d.ts.map +1 -1
  293. package/types/db/index.d.ts +0 -2
  294. package/types/db/index.d.ts.map +1 -1
  295. package/types/db/keeping.d.ts.map +1 -1
  296. package/types/db/kel-replay.d.ts +1 -4
  297. package/types/db/kel-replay.d.ts.map +1 -1
  298. package/types/db/koming.d.ts +1 -1
  299. package/types/db/koming.d.ts.map +1 -1
  300. package/types/db/kram-factors.d.ts +1 -3
  301. package/types/db/kram-factors.d.ts.map +1 -1
  302. package/types/db/mailboxing.d.ts +1 -2
  303. package/types/db/mailboxing.d.ts.map +1 -1
  304. package/types/db/payload-store.d.ts +2 -2
  305. package/types/db/payload-store.d.ts.map +1 -1
  306. package/types/db/reger.d.ts +4 -7
  307. package/types/db/reger.d.ts.map +1 -1
  308. package/types/db/subing.d.ts +1 -5
  309. package/types/db/subing.d.ts.map +1 -1
  310. package/types/db/tel-replay.d.ts +2 -7
  311. package/types/db/tel-replay.d.ts.map +1 -1
  312. package/types/db/witness-replay.d.ts +1 -2
  313. package/types/db/witness-replay.d.ts.map +1 -1
  314. package/types/did/keri/resolving.d.ts +5 -10
  315. package/types/did/keri/resolving.d.ts.map +1 -1
  316. package/types/did/webs/artifacts.d.ts.map +1 -1
  317. package/types/did/webs/designated-aliases.d.ts +5 -3
  318. package/types/did/webs/designated-aliases.d.ts.map +1 -1
  319. package/types/did/webs/documenting.d.ts +6 -5
  320. package/types/did/webs/documenting.d.ts.map +1 -1
  321. package/types/did/webs/resolving.d.ts +6 -0
  322. package/types/did/webs/resolving.d.ts.map +1 -1
  323. package/types/runtime/index.d.ts +70 -72
  324. package/types/runtime/index.d.ts.map +1 -1
  325. package/types/vdr/credential-tsn.d.ts +6 -1
  326. package/types/vdr/credential-tsn.d.ts.map +1 -1
  327. package/types/vdr/credentialing.d.ts +0 -10
  328. package/types/vdr/credentialing.d.ts.map +1 -1
  329. package/types/vdr/eventing.d.ts +7 -6
  330. package/types/vdr/eventing.d.ts.map +1 -1
  331. package/types/vdr/registry-tsn.d.ts +9 -4
  332. package/types/vdr/registry-tsn.d.ts.map +1 -1
  333. package/types/vdr/tsn-query.d.ts +8 -3
  334. package/types/vdr/tsn-query.d.ts.map +1 -1
  335. package/esm/keri/npm/src/app/cesr-output.js +0 -12
  336. package/esm/keri/npm/src/app/cue-delivery.js +0 -171
  337. package/esm/keri/npm/src/app/cue-preparation.js +0 -124
  338. package/esm/keri/npm/src/app/cue-route.js +0 -64
  339. package/esm/keri/npm/src/app/direct-reply-delivery.js +0 -282
  340. package/esm/keri/npm/src/app/ipex-building.js +0 -164
  341. package/esm/keri/npm/src/app/runtime-deliveries.js +0 -510
  342. package/esm/keri/npm/src/core/cue-admission.js +0 -419
  343. package/esm/keri/npm/src/core/kram-handoff.js +0 -148
  344. package/esm/keri/npm/src/db/kram-snapshots.js +0 -216
  345. package/esm/keri/npm/src/db/mailbox-inbox.js +0 -206
  346. package/esm/keri/npm/src/db/outboxing.js +0 -371
  347. package/types/app/cesr-output.d.ts +0 -5
  348. package/types/app/cesr-output.d.ts.map +0 -1
  349. package/types/app/cue-delivery.d.ts +0 -30
  350. package/types/app/cue-delivery.d.ts.map +0 -1
  351. package/types/app/cue-preparation.d.ts +0 -25
  352. package/types/app/cue-preparation.d.ts.map +0 -1
  353. package/types/app/cue-route.d.ts +0 -19
  354. package/types/app/cue-route.d.ts.map +0 -1
  355. package/types/app/direct-reply-delivery.d.ts +0 -38
  356. package/types/app/direct-reply-delivery.d.ts.map +0 -1
  357. package/types/app/ipex-building.d.ts +0 -30
  358. package/types/app/ipex-building.d.ts.map +0 -1
  359. package/types/app/runtime-deliveries.d.ts +0 -67
  360. package/types/app/runtime-deliveries.d.ts.map +0 -1
  361. package/types/core/cue-admission.d.ts +0 -74
  362. package/types/core/cue-admission.d.ts.map +0 -1
  363. package/types/core/kram-handoff.d.ts +0 -45
  364. package/types/core/kram-handoff.d.ts.map +0 -1
  365. package/types/db/kram-snapshots.d.ts +0 -23
  366. package/types/db/kram-snapshots.d.ts.map +0 -1
  367. package/types/db/mailbox-inbox.d.ts +0 -72
  368. package/types/db/mailbox-inbox.d.ts.map +0 -1
  369. package/types/db/outboxing.d.ts +0 -182
  370. package/types/db/outboxing.d.ts.map +0 -1
package/README.md CHANGED
@@ -15,8 +15,15 @@ npm install keri-ts
15
15
  - `keri-ts/runtime`: explicit non-browser-safe runtime surface
16
16
  - `keri-ts/db`: explicit LMDB-backed storage surface
17
17
 
18
- Only those three entrypoints are supported public surfaces. Runnable CLI/server
19
- ownership lives in the separate `tufa` package.
18
+ Those three entrypoints are the general library surfaces. `keri-ts/cli` is the
19
+ separate command-helper boundary used by Tufa. Runnable CLI/server ownership
20
+ lives in `@keri-ts/tufa`.
21
+
22
+ The runtime exports deliberate operations and data contracts. Scheduling details,
23
+ handler installation, reply-slot state and constructor helpers remain internal;
24
+ implementation-module exports do not automatically become package API. npm deep
25
+ imports such as `keri-ts/app/...` and `keri-ts/core/...` are not supported. Import
26
+ runtime operations from `keri-ts/runtime` and storage from `keri-ts/db`.
20
27
 
21
28
  ## Maintainer Docs
22
29
 
@@ -125,6 +125,42 @@ export let import_meta_ponyfill = ((...args) => {
125
125
  //@ts-ignore
126
126
  return import_meta_ponyfill(...args);
127
127
  });
128
+ function findLastIndex(self, callbackfn, that) {
129
+ const boundFunc = that === undefined ? callbackfn : callbackfn.bind(that);
130
+ let index = self.length - 1;
131
+ while (index >= 0) {
132
+ const result = boundFunc(self[index], index, self);
133
+ if (result) {
134
+ return index;
135
+ }
136
+ index--;
137
+ }
138
+ return -1;
139
+ }
140
+ function findLast(self, callbackfn, that) {
141
+ const index = self.findLastIndex(callbackfn, that);
142
+ return index === -1 ? undefined : self[index];
143
+ }
144
+ if (!Array.prototype.findLastIndex) {
145
+ Array.prototype.findLastIndex = function (callbackfn, that) {
146
+ return findLastIndex(this, callbackfn, that);
147
+ };
148
+ }
149
+ if (!Array.prototype.findLast) {
150
+ Array.prototype.findLast = function (callbackfn, that) {
151
+ return findLast(this, callbackfn, that);
152
+ };
153
+ }
154
+ if (!Uint8Array.prototype.findLastIndex) {
155
+ Uint8Array.prototype.findLastIndex = function (callbackfn, that) {
156
+ return findLastIndex(this, callbackfn, that);
157
+ };
158
+ }
159
+ if (!Uint8Array.prototype.findLast) {
160
+ Uint8Array.prototype.findLast = function (callbackfn, that) {
161
+ return findLast(this, callbackfn, that);
162
+ };
163
+ }
128
164
  // https://github.com/tc39/proposal-accessible-object-hasownproperty/blob/main/polyfill.js
129
165
  if (!Object.hasOwn) {
130
166
  Object.defineProperty(Object, "hasOwn", {
@@ -1,6 +1,6 @@
1
1
  /** Explicit public registry intake; this TypeScript integration is beyond frozen KERIpy 927. */
2
- import { Diger, Ilks, ParserError, ResourceLimitError } from "cesr-ts";
3
- import { DatabaseNotOpenError } from "../core/errors.js";
2
+ import { Diger, Ilks, ParserError } from "cesr-ts";
3
+ import { DatabaseNotOpenError, DatabaseOperationError } from "../core/errors.js";
4
4
  import { RegistryEventer } from "./regengine.js";
5
5
  import { validateRip, validateUpdate } from "./regeventing.js";
6
6
  /**
@@ -11,7 +11,7 @@ import { validateRip, validateUpdate } from "./regeventing.js";
11
11
  * Parsed evidence stays borrowed. This installs no automatic parser or runtime route.
12
12
  */
13
13
  export class RegistryObserver {
14
- constructor(db, store, { maxEvents = 16384 } = {}) {
14
+ constructor(db, store) {
15
15
  Object.defineProperty(this, "db", {
16
16
  enumerable: true,
17
17
  configurable: true,
@@ -24,16 +24,6 @@ export class RegistryObserver {
24
24
  writable: true,
25
25
  value: store
26
26
  });
27
- Object.defineProperty(this, "maxEvents", {
28
- enumerable: true,
29
- configurable: true,
30
- writable: true,
31
- value: void 0
32
- });
33
- if (!Number.isSafeInteger(maxEvents) || maxEvents < 1) {
34
- throw new RangeError("Registry maxEvents must be positive and safe.");
35
- }
36
- this.maxEvents = maxEvents;
37
27
  }
38
28
  /** Stage parsed events before inception, otherwise delegate ordinary validation and acceptance. */
39
29
  processEvent(serder) {
@@ -47,11 +37,12 @@ export class RegistryObserver {
47
37
  return { kind: "reject", reason: "registry" };
48
38
  }
49
39
  catch (error) {
50
- if (!(error instanceof ParserError) || error instanceof ResourceLimitError)
40
+ if (!(error instanceof ParserError))
51
41
  throw error;
52
42
  return { kind: "reject", reason: "registry" };
53
43
  }
54
- this.checkOrdinal(event.sn);
44
+ if (event.sn > BigInt(Number.MAX_SAFE_INTEGER))
45
+ return { kind: "reject", reason: "ordinalRange" };
55
46
  let engine = this.engine(event.regid);
56
47
  if (engine && !(engine instanceof RegistryEventer))
57
48
  return engine;
@@ -61,12 +52,12 @@ export class RegistryObserver {
61
52
  engine ??= new RegistryEventer(this.db, event.issuer, this.store, event.regid);
62
53
  }
63
54
  if (engine) {
64
- this.checkStored(event.regid, engine);
65
55
  return engine.processEvent(serder);
66
56
  }
67
57
  // Issuer/anchor discovery is impossible until RIP arrives; the existing anchor escrow owns this body.
68
58
  const baser = this.store.baser;
69
- baser.initializeStorage();
59
+ if (baser.readonly)
60
+ throw new DatabaseOperationError("Cannot write readonly registry storage.");
70
61
  return baser.env.transactionSync(() => {
71
62
  this.store.putEvent(serder);
72
63
  this.store.escrowMissingAnchor(event.regid, Number(event.sn), event.said);
@@ -78,7 +69,6 @@ export class RegistryObserver {
78
69
  const engine = this.engine(regid);
79
70
  if (!(engine instanceof RegistryEventer))
80
71
  return;
81
- this.checkStored(regid, engine);
82
72
  engine.processEscrows();
83
73
  }
84
74
  /** Stored inception is durable issuer identity, including while its anchor is still absent. */
@@ -103,20 +93,4 @@ export class RegistryObserver {
103
93
  }
104
94
  return new RegistryEventer(this.db, result.event.issuer, this.store, regid);
105
95
  }
106
- /** Bound chain length before processing; this does not bound queued rows, scans or native allocation. */
107
- checkOrdinal(sn) {
108
- if (sn >= BigInt(this.maxEvents))
109
- throw new ResourceLimitError("Registry evidence exceeds configured event limit.");
110
- }
111
- /** A tighter observer must not advance previously staged rows beyond its own finite ceiling. */
112
- checkStored(regid, engine) {
113
- this.checkOrdinal(engine.sn);
114
- for (const escrow of [this.store.baser.maes, this.store.baser.ooes]) {
115
- for (const [, sn] of escrow?.getTopItemIter(regid) ?? []) {
116
- if (!Number.isSafeInteger(sn) || sn < 0)
117
- throw new RangeError("Unsafe observer escrow ordinal.");
118
- this.checkOrdinal(BigInt(sn));
119
- }
120
- }
121
- }
122
96
  }
@@ -1,13 +1,12 @@
1
1
  /** Public ACDC registry database layout and joined LMDB lifecycle. */
2
2
  import { b, Diger, NumberPrimitive, Saider, SerderACDC } from "cesr-ts";
3
- import { DatabaseNotOpenError, DatabaseOperationError } from "../core/errors.js";
3
+ import { DatabaseNotOpenError } from "../core/errors.js";
4
4
  import { LMDBer } from "../db/core/lmdber.js";
5
5
  import { B64OnIoSetSuber, CatCesrSuber, CesrOnSuber, CesrSuber, SerderSuber } from "../db/subing.js";
6
6
  /**
7
7
  * Own one environment for public registry TEL bodies, accepted ordinals and heads.
8
8
  * Mirrors frozen KERIpy RegBaser's typed tables; opening neither verifies
9
- * evidence nor migrates rows. Absent anchor/escrow tables stay null until an
10
- * explicit storage write initializes them, preserving readonly old layouts.
9
+ * evidence nor migrates rows. Every current store has anchor and escrow tables.
11
10
  * Construction stays closed; callers own reopen and joined close.
12
11
  */
13
12
  export class RegBaser extends LMDBer {
@@ -17,14 +16,6 @@ export class RegBaser extends LMDBer {
17
16
  throw new DatabaseNotOpenError("Registry environment is closed.");
18
17
  return this.env.getBinary(b(name)) !== undefined;
19
18
  }
20
- /** Explicit writable initialization; never called by opening or reading a store. */
21
- initializeStorage() {
22
- if (this.readonly)
23
- throw new DatabaseOperationError("Cannot initialize readonly registry storage.");
24
- this.ancs ??= new CatCesrSuber(this, { subkey: "ancs.", ctor: [NumberPrimitive, Diger] });
25
- this.maes ??= new B64OnIoSetSuber(this, { subkey: "maes." });
26
- this.ooes ??= new B64OnIoSetSuber(this, { subkey: "ooes." });
27
- }
28
19
  constructor(options = {}) {
29
20
  super(options, {
30
21
  tailDirPath: "keri/acdc/reg",
@@ -54,26 +45,26 @@ export class RegBaser extends LMDBer {
54
45
  writable: true,
55
46
  value: void 0
56
47
  });
57
- /** Event-SAID -> earliest verified KEL source couple, when this table exists. */
48
+ /** Event-SAID -> earliest verified KEL source couple, in the current store. */
58
49
  Object.defineProperty(this, "ancs", {
59
50
  enumerable: true,
60
51
  configurable: true,
61
52
  writable: true,
62
- value: null
53
+ value: void 0
63
54
  });
64
55
  /** Insertion-ordered missing-anchor event-SAID tuples by registry and ordinal. */
65
56
  Object.defineProperty(this, "maes", {
66
57
  enumerable: true,
67
58
  configurable: true,
68
59
  writable: true,
69
- value: null
60
+ value: void 0
70
61
  });
71
62
  /** Insertion-ordered out-of-order event-SAID tuples by registry and ordinal. */
72
63
  Object.defineProperty(this, "ooes", {
73
64
  enumerable: true,
74
65
  configurable: true,
75
66
  writable: true,
76
- value: null
67
+ value: void 0
77
68
  });
78
69
  }
79
70
  /** Rebind the same environment's typed tables after every joined reopen. */
@@ -85,11 +76,9 @@ export class RegBaser extends LMDBer {
85
76
  this.evts = new SerderSuber(this, { subkey: "evts.", ctor: SerderACDC });
86
77
  this.tels = new CesrOnSuber(this, { subkey: "tels.", ctor: Saider });
87
78
  this.heads = new CesrSuber(this, { subkey: "heds.", ctor: Saider });
88
- this.ancs = this.hasTable("ancs.")
89
- ? new CatCesrSuber(this, { subkey: "ancs.", ctor: [NumberPrimitive, Diger] })
90
- : null;
91
- this.maes = this.hasTable("maes.") ? new B64OnIoSetSuber(this, { subkey: "maes." }) : null;
92
- this.ooes = this.hasTable("ooes.") ? new B64OnIoSetSuber(this, { subkey: "ooes." }) : null;
79
+ this.ancs = new CatCesrSuber(this, { subkey: "ancs.", ctor: [NumberPrimitive, Diger] });
80
+ this.maes = new B64OnIoSetSuber(this, { subkey: "maes." });
81
+ this.ooes = new B64OnIoSetSuber(this, { subkey: "ooes." });
93
82
  return true;
94
83
  }
95
84
  catch (error) {
@@ -1,12 +1,10 @@
1
- /** Internal local TEL acceptance; registry facades own instance naming and scheduling. */
2
- import { Diger, Ilks, makeBlindState, makeBoundState, NumberPrimitive, SerderACDC, } from "cesr-ts";
3
- import { DatabaseNotOpenError, ValidationError } from "../core/errors.js";
4
- import { blindate } from "./messaging.js";
1
+ /** Shared TEL validation, accepted-state publication, anchoring and retry for local and foreign registries. */
2
+ import { Diger, Ilks, NumberPrimitive, } from "cesr-ts";
3
+ import { DatabaseNotOpenError, DatabaseOperationError } from "../core/errors.js";
5
4
  import { validateRip, validateUpdate, verifyRegistryAnchor, } from "./regeventing.js";
6
- import { FailedSchemaValidationError, MissingSchemaError, validateSchema } from "./scheming.js";
7
5
  /**
8
6
  * Borrow the issuer's accepted KEL and registry store; no keys or handles are acquired.
9
- * Event processing is internal until the registry facade is available.
7
+ * The local facade and foreign observer share this accepted-state engine.
10
8
  * Publication is atomic; binding this instance happens only after successful commit.
11
9
  */
12
10
  export class RegistryEventer {
@@ -36,101 +34,23 @@ export class RegistryEventer {
36
34
  value: regk
37
35
  });
38
36
  }
37
+ /** Validated accepted head metadata; local construction may inspect it without duplicating acceptance checks. */
38
+ get acceptedHeadEvent() {
39
+ return this.regk ? this.acceptedHead(this.regk) : null;
40
+ }
39
41
  /** Read the accepted head only after validating its body and ordinal marker. */
40
42
  get head() {
41
- const event = this.regk ? this.acceptedHead(this.regk) : null;
43
+ const event = this.acceptedHeadEvent;
42
44
  return event ? this.store.head(event.regid) : null;
43
45
  }
44
46
  /** Accepted TEL ordinal, retaining -1n for a staged but unaccepted inception. */
45
47
  get sn() {
46
- return this.regk ? this.acceptedHead(this.regk)?.sn ?? -1n : -1n;
48
+ return this.acceptedHeadEvent?.sn ?? -1n;
47
49
  }
48
50
  /** Return an accepted inception; a corrupt marker/body pair throws. */
49
51
  get regser() {
50
52
  return this.regk ? this.acceptedAt(this.regk, 0) : null;
51
53
  }
52
- /** Validate credential membership and issuer before deriving its next blinded registry update. */
53
- blind(acdc, state, options = {}) {
54
- if (!(acdc instanceof SerderACDC) || !acdc.verify()) {
55
- throw new ValidationError("Registry blinding requires a self-verifying ACDC.");
56
- }
57
- if (acdc.regid !== this.regk)
58
- throw new ValidationError("Credential belongs to another registry.");
59
- if (acdc.issuer !== this.issuer)
60
- throw new ValidationError("Credential belongs to another issuer.");
61
- const schema = validateSchema(acdc, this.db);
62
- if (schema.kind === "missing")
63
- throw new MissingSchemaError(schema.said);
64
- if (schema.kind === "invalid")
65
- throw new FailedSchemaValidationError(schema.reason);
66
- return this.blindTarget(acdc.said, state, options);
67
- }
68
- /** Commit a grant SAID without requiring the grant's issuer to control this presentation registry. */
69
- present(grant, state = "presented", options = {}) {
70
- const target = typeof grant === "string" ? grant : grant.said;
71
- try {
72
- new Diger({ qb64: target ?? "" });
73
- }
74
- catch (cause) {
75
- throw new ValidationError("Presentation target must be a valid grant SAID.", { cause });
76
- }
77
- return this.blindTarget(target, state, options);
78
- }
79
- /** Empty target/state disclose a vacuous step; downstream verification retains the preceding binding. */
80
- vacate(options = {}) {
81
- return this.blindTarget("", "", options);
82
- }
83
- /** Derive and stage a validated target; presentation/vacuous callers own their target checks. */
84
- blindTarget(target, state, options) {
85
- const tip = this.effectiveFrontier();
86
- if (!tip)
87
- throw new ValidationError("Registry must be anchored before updates.");
88
- if ("blinder" in options)
89
- throw new ValidationError("Caller-supplied blinder overrides are unsupported.");
90
- const sn = tip.sn + 1n;
91
- if (sn > BigInt(Number.MAX_SAFE_INTEGER))
92
- throw new RangeError("Unsafe registry update ordinal.");
93
- const { raw, salt, tier, bound, bsn, bd, ...wire } = options;
94
- const inputs = { raw, salt, tier, sn, acdc: target, state };
95
- const blinder = bound ? makeBoundState({ ...inputs, bsn, bd }) : makeBlindState(inputs);
96
- const serder = blindate(tip.regid, tip.said, blinder.d.nonce, { ...wire, sn });
97
- const decision = this.processEvent(serder);
98
- if (decision.kind === "reject")
99
- throw new ValidationError(`Registry update rejected: ${decision.reason}`);
100
- return [blinder, serder];
101
- }
102
- /** Extend an accepted head through exactly one staged successor at each ordinal, without mutation. */
103
- effectiveFrontier() {
104
- let tip = this.regk ? this.acceptedHead(this.regk) : null;
105
- while (tip) {
106
- const sn = tip.sn + 1n;
107
- if (sn > BigInt(Number.MAX_SAFE_INTEGER))
108
- return tip;
109
- const saids = new Set();
110
- for (const escrow of [this.store.baser.maes, this.store.baser.ooes]) {
111
- for (const [said] of escrow?.get(tip.regid, Number(sn)) ?? [])
112
- saids.add(said);
113
- }
114
- let successor = null;
115
- for (const said of saids) {
116
- const body = this.store.event(said);
117
- if (!body)
118
- continue;
119
- if (body.said !== said)
120
- throw new Error("Corrupt staged registry event.");
121
- const result = validateUpdate(body, tip.regid);
122
- if (result.kind !== "valid" || result.event.sn !== sn || result.event.prior !== tip.said)
123
- continue;
124
- if (successor)
125
- throw new ValidationError("Registry has conflicting staged successors.");
126
- successor = result.event;
127
- }
128
- if (!successor)
129
- return tip;
130
- tip = successor;
131
- }
132
- return null;
133
- }
134
54
  /** Retry newly visible anchors, then advance the contiguous accepted chain. */
135
55
  processEscrows() {
136
56
  this.processMissingAnchors();
@@ -185,7 +105,7 @@ export class RegistryEventer {
185
105
  const sn = head.sn + 1n;
186
106
  if (sn > BigInt(Number.MAX_SAFE_INTEGER))
187
107
  return;
188
- const candidates = this.store.baser.ooes?.get(this.regk, Number(sn)).map(([said]) => said) ?? [];
108
+ const candidates = this.store.baser.ooes.get(this.regk, Number(sn)).map(([said]) => said);
189
109
  candidates.sort((a, b) => this.compareAnchors(a, b));
190
110
  let advanced = false;
191
111
  for (const said of candidates) {
@@ -207,8 +127,8 @@ export class RegistryEventer {
207
127
  if (this.regk === null)
208
128
  return;
209
129
  const slots = new Map();
210
- // Finish the read cursor before writes. Shared scan credit belongs to the resource-policy phase.
211
- for (const [, sn, [said]] of this.store.baser.maes?.getTopItemIter(this.regk) ?? []) {
130
+ // Finish the read cursor before writes.
131
+ for (const [, sn, [said]] of this.store.baser.maes.getTopItemIter(this.regk)) {
212
132
  if (!Number.isSafeInteger(sn) || sn < 0)
213
133
  throw new RangeError("Unsafe registry escrow ordinal.");
214
134
  const candidates = slots.get(sn) ?? [];
@@ -299,7 +219,8 @@ export class RegistryEventer {
299
219
  const env = this.store.baser.env;
300
220
  if (!env)
301
221
  throw new DatabaseNotOpenError("Registry acceptance requires an open backing store.");
302
- this.store.baser.initializeStorage();
222
+ if (this.store.baser.readonly)
223
+ throw new DatabaseOperationError("Cannot write readonly registry storage.");
303
224
  return env.transactionSync(() => {
304
225
  const prior = this.acceptedAt(event.regid, Number(event.sn) - 1);
305
226
  if (prior && prior.said !== event.prior)
@@ -342,8 +263,8 @@ export class RegistryEventer {
342
263
  const env = this.store.baser.env;
343
264
  if (!env)
344
265
  throw new DatabaseNotOpenError("Registry acceptance requires an open backing store.");
345
- // Bind named tables before the rollback-capable event transaction owns their rows.
346
- this.store.baser.initializeStorage();
266
+ if (this.store.baser.readonly)
267
+ throw new DatabaseOperationError("Cannot write readonly registry storage.");
347
268
  const decision = env.transactionSync(() => {
348
269
  const previous = this.acceptedEvent(event);
349
270
  if (previous)
@@ -35,7 +35,7 @@ function registryOrdinal(sn) {
35
35
  * Wrap a supplied RegBaser without opening another environment. Reads and writes
36
36
  * are storage operations: callers authenticate events/anchors and decide acceptance.
37
37
  * Explicit close delegates to the supplied owner; construction adds no lifetime scope.
38
- * Missing old-layout facilities remain null until an explicit writable operation.
38
+ * Local aliases are optional; public observer stores need only evidence tables.
39
39
  */
40
40
  export class RegistryStore {
41
41
  constructor(baser) {
@@ -58,7 +58,7 @@ export class RegistryStore {
58
58
  value: null
59
59
  });
60
60
  }
61
- /** Alias mapper is absent for old layouts; refresh it after the owner's reopen. */
61
+ /** Local alias mapper is optional; refresh it after the owner's reopen. */
62
62
  get records() {
63
63
  if (!this.baser.env)
64
64
  throw new DatabaseNotOpenError("Registry backing store is closed.");
@@ -70,7 +70,7 @@ export class RegistryStore {
70
70
  }
71
71
  return this.aliases;
72
72
  }
73
- /** Explicit alias write creates regs. only when needed, without an opening migration. */
73
+ /** Explicit alias write creates regs. only when needed, for local registry management. */
74
74
  putRecord(name, record) {
75
75
  return this.initializeRecords().pin(name, record);
76
76
  }
@@ -100,18 +100,17 @@ export class RegistryStore {
100
100
  putEvent(serder) {
101
101
  return this.baser.evts.pin(serder.said, serder);
102
102
  }
103
- /** Read a stored source couple; missing old-layout ancs. has no anchors. */
103
+ /** Read a stored source couple. */
104
104
  anchor(said) {
105
105
  if (!this.baser.opened)
106
106
  throw new DatabaseNotOpenError("Registry backing store is closed.");
107
- return this.baser.ancs?.get(said) ?? null;
107
+ return this.baser.ancs.get(said);
108
108
  }
109
109
  /** Retain the earliest caller-verified anchor; equal/later reseals cannot reorder siblings. */
110
110
  putAnchor(said, number, diger) {
111
111
  const current = this.anchor(said);
112
112
  if (current && current[0].num <= number.num)
113
113
  return false;
114
- this.baser.initializeStorage();
115
114
  return this.baser.ancs.pin(said, [number, diger]);
116
115
  }
117
116
  /** Read the accepted-head cache without verifying the event. */
@@ -148,7 +147,7 @@ export class RegistryStore {
148
147
  yield event.raw;
149
148
  }
150
149
  }
151
- /** Eagerly collect accepted TEL bytes; callers must reserve collection credit, not infer a shared budget. */
150
+ /** Eagerly collect accepted TEL bytes in ordinal order. */
152
151
  cloneTel(regk, sn = 0) {
153
152
  const chunks = [...this.cloneTelIter(regk, sn)];
154
153
  const stream = new Uint8Array(chunks.reduce((size, raw) => size + raw.length, 0));
@@ -162,19 +161,17 @@ export class RegistryStore {
162
161
  /** Add one missing-anchor candidate in insertion order, deduplicating its SAID. */
163
162
  escrowMissingAnchor(regk, sn, said) {
164
163
  sn = registryOrdinal(sn);
165
- this.baser.initializeStorage();
166
164
  return this.baser.maes.add(regk, sn, [said]);
167
165
  }
168
166
  /** Add one out-of-order candidate in insertion order, deduplicating its SAID. */
169
167
  escrowOutOfOrder(regk, sn, said) {
170
168
  sn = registryOrdinal(sn);
171
- this.baser.initializeStorage();
172
169
  return this.baser.ooes.add(regk, sn, [said]);
173
170
  }
174
- /** Remove this candidate from both escrow families without creating absent tables. */
171
+ /** Remove this candidate from both escrow families. */
175
172
  clearEscrows(regk, sn, said) {
176
173
  sn = registryOrdinal(sn);
177
- this.baser.maes?.rem(regk, sn, [said]);
178
- this.baser.ooes?.rem(regk, sn, [said]);
174
+ this.baser.maes.rem(regk, sn, [said]);
175
+ this.baser.ooes.rem(regk, sn, [said]);
179
176
  }
180
177
  }
@@ -1,8 +1,11 @@
1
+ /** Named local v2 registry services; legacy VDR services retain their separate module and owner. */
2
+ import { Diger, makeBlindState, makeBoundState, SerderACDC, } from "cesr-ts";
1
3
  import { DatabaseNotOpenError, ValidationError } from "../core/errors.js";
2
- import { regcept } from "./messaging.js";
3
- import { RegistryEventer, } from "./regengine.js";
4
- import { validateRip } from "./regeventing.js";
4
+ import { blindate, regcept } from "./messaging.js";
5
+ import { RegistryEventer } from "./regengine.js";
6
+ import { validateRip, validateUpdate } from "./regeventing.js";
5
7
  import { openRegistry, RegistryStore } from "./registering.js";
8
+ import { FailedSchemaValidationError, MissingSchemaError, validateSchema } from "./scheming.js";
6
9
  /** Acquire a named manager, joining owned-store cleanup if opening or alias loading fails. */
7
10
  export function* createRegery({ hby, baser, ...options }) {
8
11
  const ownsBaser = baser === undefined;
@@ -90,7 +93,6 @@ export class Regery {
90
93
  const env = this.baser.env;
91
94
  if (!env)
92
95
  throw new DatabaseNotOpenError("Registry backing store is closed.");
93
- this.baser.initializeStorage();
94
96
  const records = this.store.initializeRecords();
95
97
  const registry = new Registry(hab, this.store, name);
96
98
  env.transactionSync(() => {
@@ -201,9 +203,21 @@ export class Registry {
201
203
  throw new ValidationError(`Registry inception rejected: ${result.reason}`);
202
204
  return rip;
203
205
  }
204
- /** Derive a disclosure and stage its commitment after checking credential membership. */
206
+ /** Validate credential membership and issuer before deriving its next blinded registry update. */
205
207
  blind(acdc, state, options = {}) {
206
- return this.eventer.blind(acdc, state, options);
208
+ if (!(acdc instanceof SerderACDC) || !acdc.verify()) {
209
+ throw new ValidationError("Registry blinding requires a self-verifying ACDC.");
210
+ }
211
+ if (acdc.regid !== this.regk)
212
+ throw new ValidationError("Credential belongs to another registry.");
213
+ if (acdc.issuer !== this.hab.pre)
214
+ throw new ValidationError("Credential belongs to another issuer.");
215
+ const schema = validateSchema(acdc, this.hab.db);
216
+ if (schema.kind === "missing")
217
+ throw new MissingSchemaError(schema.said);
218
+ if (schema.kind === "invalid")
219
+ throw new FailedSchemaValidationError(schema.reason);
220
+ return this.blindTarget(acdc.said, state, options);
207
221
  }
208
222
  /** Process parsed TEL evidence through the shared typed engine. */
209
223
  processEvent(serder) {
@@ -213,52 +227,74 @@ export class Registry {
213
227
  anchorMsg(said, number, diger) {
214
228
  return this.eventer.anchorMsg(said, number, diger);
215
229
  }
216
- /** Stage a grant commitment in this registry; grant authentication remains with IPEX. */
230
+ /** Commit a grant SAID without requiring the grant's issuer to control this presentation registry. */
217
231
  present(grant, state = "presented", options = {}) {
218
- return this.eventer.present(grant, state, options);
232
+ const target = typeof grant === "string" ? grant : grant.said;
233
+ try {
234
+ new Diger({ qb64: target ?? "" });
235
+ }
236
+ catch (cause) {
237
+ throw new ValidationError("Presentation target must be a valid grant SAID.", { cause });
238
+ }
239
+ return this.blindTarget(target, state, options);
219
240
  }
220
- /** Stage a vacuous disclosure that leaves the prior effective binding in force. */
241
+ /** Empty target/state disclose a vacuous step; downstream verification retains the preceding binding. */
221
242
  vacate(options = {}) {
222
- return this.eventer.vacate(options);
243
+ return this.blindTarget("", "", options);
244
+ }
245
+ /** Derive and stage a validated target; presentation/vacuous callers own their target checks. */
246
+ blindTarget(target, state, options) {
247
+ const tip = this.effectiveFrontier();
248
+ if (!tip)
249
+ throw new ValidationError("Registry must be anchored before updates.");
250
+ if ("blinder" in options)
251
+ throw new ValidationError("Caller-supplied blinder overrides are unsupported.");
252
+ const sn = tip.sn + 1n;
253
+ if (sn > BigInt(Number.MAX_SAFE_INTEGER))
254
+ throw new RangeError("Unsafe registry update ordinal.");
255
+ const { raw, salt, tier, bound, bsn, bd, ...wire } = options;
256
+ const inputs = { raw, salt, tier, sn, acdc: target, state };
257
+ const blinder = bound ? makeBoundState({ ...inputs, bsn, bd }) : makeBlindState(inputs);
258
+ const serder = blindate(tip.regid, tip.said, blinder.d.nonce, { ...wire, sn });
259
+ const decision = this.processEvent(serder);
260
+ if (decision.kind === "reject")
261
+ throw new ValidationError(`Registry update rejected: ${decision.reason}`);
262
+ return [blinder, serder];
263
+ }
264
+ /** Extend an accepted head through exactly one staged successor at each ordinal, without mutation. */
265
+ effectiveFrontier() {
266
+ let tip = this.eventer.acceptedHeadEvent;
267
+ while (tip) {
268
+ const sn = tip.sn + 1n;
269
+ if (sn > BigInt(Number.MAX_SAFE_INTEGER))
270
+ return tip;
271
+ const saids = new Set();
272
+ for (const escrow of [this.store.baser.maes, this.store.baser.ooes]) {
273
+ for (const [said] of escrow?.get(tip.regid, Number(sn)) ?? [])
274
+ saids.add(said);
275
+ }
276
+ let successor = null;
277
+ for (const said of saids) {
278
+ const body = this.store.event(said);
279
+ if (!body)
280
+ continue;
281
+ if (body.said !== said)
282
+ throw new Error("Corrupt staged registry event.");
283
+ const result = validateUpdate(body, tip.regid);
284
+ if (result.kind !== "valid" || result.event.sn !== sn || result.event.prior !== tip.said)
285
+ continue;
286
+ if (successor)
287
+ throw new ValidationError("Registry has conflicting staged successors.");
288
+ successor = result.event;
289
+ }
290
+ if (!successor)
291
+ return tip;
292
+ tip = successor;
293
+ }
294
+ return null;
223
295
  }
224
296
  /** Retry both missing-anchor and ordering prerequisites. */
225
297
  processEscrows() {
226
298
  this.eventer.processEscrows();
227
299
  }
228
300
  }
229
- /** Caller-facing v2 operations over a borrowed Regery; this facade acquires no keys, stores or runtime service. */
230
- export class Registrar {
231
- constructor(rgy) {
232
- Object.defineProperty(this, "rgy", {
233
- enumerable: true,
234
- configurable: true,
235
- writable: true,
236
- value: rgy
237
- });
238
- }
239
- /** Accept instances directly; registry keys take precedence over local aliases, as in frozen KERIpy. */
240
- registry(reference) {
241
- if (reference instanceof Registry)
242
- return reference;
243
- const registry = this.rgy.regs.get(reference) ?? this.rgy.registryByName(reference);
244
- if (!registry)
245
- throw new ValidationError(`Unknown registry: ${reference}`);
246
- return registry;
247
- }
248
- /** Create one named registry through the manager's existing atomic inception/alias workflow. */
249
- makeRegistry(name, prefix, options = {}) {
250
- return this.rgy.makeRegistry(name, prefix, options);
251
- }
252
- /** Stage a credential binding, requiring its issuer and registry to match the resolved Registry. */
253
- issue(reference, acdc, state = "issued", options = {}) {
254
- return this.registry(reference).blind(acdc, state, options);
255
- }
256
- /** Bind a grant SAID through a registry instance, key or alias. */
257
- present(reference, grant, state = "presented", options = {}) {
258
- return this.registry(reference).present(grant, state, options);
259
- }
260
- /** Append a vacuous state disclosure through the resolved registry. */
261
- vacate(reference, options = {}) {
262
- return this.registry(reference).vacate(options);
263
- }
264
- }