keri-ts 0.10.4 → 0.11.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 (348) hide show
  1. package/README.md +3 -3
  2. package/esm/keri/npm/src/_dnt.shims.js +2 -2
  3. package/esm/keri/npm/src/acdc/messaging.js +5 -0
  4. package/esm/keri/npm/src/acdc/observing.js +122 -0
  5. package/esm/keri/npm/src/acdc/regbasing.js +100 -0
  6. package/esm/keri/npm/src/acdc/regengine.js +434 -0
  7. package/esm/keri/npm/src/acdc/regeventing.js +273 -0
  8. package/esm/keri/npm/src/acdc/registering.js +180 -0
  9. package/esm/keri/npm/src/acdc/registraring.js +264 -0
  10. package/esm/keri/npm/src/acdc/scheming.js +363 -0
  11. package/esm/keri/npm/src/app/abortable.js +27 -0
  12. package/esm/keri/npm/src/app/agent-runtime.js +265 -58
  13. package/esm/keri/npm/src/app/authenticating.js +27 -4
  14. package/esm/keri/npm/src/app/byte-source.js +131 -0
  15. package/esm/keri/npm/src/app/cesr-egress.js +308 -0
  16. package/esm/keri/npm/src/app/cesr-http.js +77 -75
  17. package/esm/keri/npm/src/app/cesr-output.js +12 -0
  18. package/esm/keri/npm/src/app/cli/annotate.js +18 -93
  19. package/esm/keri/npm/src/app/cli/benchmark.js +20 -196
  20. package/esm/keri/npm/src/app/cli/common/existing.js +2 -0
  21. package/esm/keri/npm/src/app/cli/delegate.js +5 -3
  22. package/esm/keri/npm/src/app/cli/did.js +3 -3
  23. package/esm/keri/npm/src/app/cli/incept.js +1 -1
  24. package/esm/keri/npm/src/app/cli/ipex.js +31 -18
  25. package/esm/keri/npm/src/app/cli/multisig.js +8 -8
  26. package/esm/keri/npm/src/app/cli/notifications.js +1 -0
  27. package/esm/keri/npm/src/app/cli/output.js +22 -0
  28. package/esm/keri/npm/src/app/cli/query.js +1 -1
  29. package/esm/keri/npm/src/app/cli/rotate.js +1 -1
  30. package/esm/keri/npm/src/app/cli/vc.js +1 -1
  31. package/esm/keri/npm/src/app/cli/verifier.js +2 -8
  32. package/esm/keri/npm/src/app/credential-workflows.js +3 -3
  33. package/esm/keri/npm/src/app/cue-delivery.js +171 -0
  34. package/esm/keri/npm/src/app/cue-preparation.js +124 -0
  35. package/esm/keri/npm/src/app/cue-route.js +64 -0
  36. package/esm/keri/npm/src/app/cue-runtime.js +66 -32
  37. package/esm/keri/npm/src/app/delegating.js +20 -10
  38. package/esm/keri/npm/src/app/direct-reply-delivery.js +282 -0
  39. package/esm/keri/npm/src/app/endpoint-roleing.js +3 -3
  40. package/esm/keri/npm/src/app/essr.js +235 -0
  41. package/esm/keri/npm/src/app/exchanging.js +870 -128
  42. package/esm/keri/npm/src/app/forwarding.js +476 -230
  43. package/esm/keri/npm/src/app/grouping.js +198 -46
  44. package/esm/keri/npm/src/app/habbing.js +103 -236
  45. package/esm/keri/npm/src/app/httping.js +70 -28
  46. package/esm/keri/npm/src/app/ipex-building.js +164 -0
  47. package/esm/keri/npm/src/app/ipex-credentialing.js +5 -5
  48. package/esm/keri/npm/src/app/ipex-graph.js +297 -0
  49. package/esm/keri/npm/src/app/ipex-grouping.js +7 -8
  50. package/esm/keri/npm/src/app/ipex-v2.js +542 -0
  51. package/esm/keri/npm/src/app/ipexing.js +4 -0
  52. package/esm/keri/npm/src/app/keeping.js +8 -0
  53. package/esm/keri/npm/src/app/mailbox-director.js +395 -175
  54. package/esm/keri/npm/src/app/mailbox-sse.js +240 -100
  55. package/esm/keri/npm/src/app/mailboxing.js +10 -8
  56. package/esm/keri/npm/src/app/multisig-workflows.js +15 -13
  57. package/esm/keri/npm/src/app/notifying.js +45 -19
  58. package/esm/keri/npm/src/app/oobi-replies.js +194 -0
  59. package/esm/keri/npm/src/app/oobiery.js +300 -137
  60. package/esm/keri/npm/src/app/parsering.js +243 -224
  61. package/esm/keri/npm/src/app/query-replies.js +181 -0
  62. package/esm/keri/npm/src/app/querying.js +406 -49
  63. package/esm/keri/npm/src/app/reactor.js +373 -59
  64. package/esm/keri/npm/src/app/reply-streams.js +304 -0
  65. package/esm/keri/npm/src/app/respondant.js +47 -6
  66. package/esm/keri/npm/src/app/runtime-deliveries.js +510 -0
  67. package/esm/keri/npm/src/app/runtime-services.js +3 -0
  68. package/esm/keri/npm/src/app/signaling.js +253 -33
  69. package/esm/keri/npm/src/app/socket-source.js +164 -0
  70. package/esm/keri/npm/src/app/stored-replies.js +85 -0
  71. package/esm/keri/npm/src/app/tcp-egress.js +334 -0
  72. package/esm/keri/npm/src/app/verifier-agent.js +89 -36
  73. package/esm/keri/npm/src/app/verifying.js +55 -28
  74. package/esm/keri/npm/src/app/version.js +2 -2
  75. package/esm/keri/npm/src/app/witnessing.js +292 -165
  76. package/esm/keri/npm/src/core/attachment-countering.js +2 -2
  77. package/esm/keri/npm/src/core/cue-admission.js +419 -0
  78. package/esm/keri/npm/src/core/deck.js +50 -11
  79. package/esm/keri/npm/src/core/dispatch.js +20 -59
  80. package/esm/keri/npm/src/core/eventing.js +245 -142
  81. package/esm/keri/npm/src/core/exchange-proofing.js +60 -0
  82. package/esm/keri/npm/src/core/kever.js +28 -24
  83. package/esm/keri/npm/src/core/kram-auth.js +32 -0
  84. package/esm/keri/npm/src/core/kram-handoff.js +148 -0
  85. package/esm/keri/npm/src/core/kram-policy.js +303 -0
  86. package/esm/keri/npm/src/core/kram-pruning.js +196 -0
  87. package/esm/keri/npm/src/core/kram-signatures.js +90 -0
  88. package/esm/keri/npm/src/core/kram-staging.js +211 -0
  89. package/esm/keri/npm/src/core/kram-time.js +98 -0
  90. package/esm/keri/npm/src/core/kraming.js +99 -0
  91. package/esm/keri/npm/src/core/protocol-exchanging.js +19 -0
  92. package/esm/keri/npm/src/core/protocol-serialization.js +63 -25
  93. package/esm/keri/npm/src/core/routing.js +138 -31
  94. package/esm/keri/npm/src/db/basing.js +585 -63
  95. package/esm/keri/npm/src/db/core/lmdber.js +60 -1
  96. package/esm/keri/npm/src/db/escrowing.js +84 -1
  97. package/esm/keri/npm/src/db/exchange-nests.js +175 -0
  98. package/esm/keri/npm/src/db/exchange-records.js +7 -0
  99. package/esm/keri/npm/src/db/index.js +4 -0
  100. package/esm/keri/npm/src/db/kel-replay.js +62 -0
  101. package/esm/keri/npm/src/db/kram-factors.js +193 -0
  102. package/esm/keri/npm/src/db/kram-snapshots.js +216 -0
  103. package/esm/keri/npm/src/db/mailboxing.js +18 -5
  104. package/esm/keri/npm/src/db/outboxing.js +77 -34
  105. package/esm/keri/npm/src/db/payload-archive.js +402 -0
  106. package/esm/keri/npm/src/db/payload-store.js +416 -0
  107. package/esm/keri/npm/src/db/payload-view.js +23 -0
  108. package/esm/keri/npm/src/db/reger.js +118 -24
  109. package/esm/keri/npm/src/db/subing.js +17 -0
  110. package/esm/keri/npm/src/db/tel-replay.js +87 -0
  111. package/esm/keri/npm/src/db/witness-replay.js +133 -0
  112. package/esm/keri/npm/src/did/webs/artifacts.js +11 -1
  113. package/esm/keri/npm/src/did/webs/resolving.js +73 -45
  114. package/esm/keri/npm/src/npm/deno-shim.js +17 -0
  115. package/esm/keri/npm/src/runtime/index.js +15 -1
  116. package/esm/keri/npm/src/time/mod.js +18 -3
  117. package/esm/keri/npm/src/vdr/credential-tsn.js +218 -0
  118. package/esm/keri/npm/src/vdr/credentialing.js +8 -5
  119. package/esm/keri/npm/src/vdr/eventing.js +100 -36
  120. package/esm/keri/npm/src/vdr/registry-tsn.js +218 -0
  121. package/esm/keri/npm/src/vdr/tsn-query.js +34 -0
  122. package/package.json +7 -8
  123. package/types/_dnt.shims.d.ts +3 -2
  124. package/types/_dnt.shims.d.ts.map +1 -1
  125. package/types/acdc/messaging.d.ts.map +1 -1
  126. package/types/acdc/observing.d.ts +38 -0
  127. package/types/acdc/observing.d.ts.map +1 -0
  128. package/types/acdc/regbasing.d.ts +38 -0
  129. package/types/acdc/regbasing.d.ts.map +1 -0
  130. package/types/acdc/regengine.d.ts +87 -0
  131. package/types/acdc/regengine.d.ts.map +1 -0
  132. package/types/acdc/regeventing.d.ts +101 -0
  133. package/types/acdc/regeventing.d.ts.map +1 -0
  134. package/types/acdc/registering.d.ts +72 -0
  135. package/types/acdc/registering.d.ts.map +1 -0
  136. package/types/acdc/registraring.d.ts +87 -0
  137. package/types/acdc/registraring.d.ts.map +1 -0
  138. package/types/acdc/scheming.d.ts +27 -0
  139. package/types/acdc/scheming.d.ts.map +1 -0
  140. package/types/app/abortable.d.ts +11 -0
  141. package/types/app/abortable.d.ts.map +1 -0
  142. package/types/app/agent-runtime.d.ts +42 -10
  143. package/types/app/agent-runtime.d.ts.map +1 -1
  144. package/types/app/authenticating.d.ts.map +1 -1
  145. package/types/app/byte-source.d.ts +16 -0
  146. package/types/app/byte-source.d.ts.map +1 -0
  147. package/types/app/cesr-egress.d.ts +48 -0
  148. package/types/app/cesr-egress.d.ts.map +1 -0
  149. package/types/app/cesr-http.d.ts +8 -12
  150. package/types/app/cesr-http.d.ts.map +1 -1
  151. package/types/app/cesr-output.d.ts +5 -0
  152. package/types/app/cesr-output.d.ts.map +1 -0
  153. package/types/app/cli/annotate.d.ts +2 -7
  154. package/types/app/cli/annotate.d.ts.map +1 -1
  155. package/types/app/cli/benchmark.d.ts +2 -9
  156. package/types/app/cli/benchmark.d.ts.map +1 -1
  157. package/types/app/cli/common/context.d.ts +3 -0
  158. package/types/app/cli/common/context.d.ts.map +1 -1
  159. package/types/app/cli/common/existing.d.ts +3 -0
  160. package/types/app/cli/common/existing.d.ts.map +1 -1
  161. package/types/app/cli/delegate.d.ts.map +1 -1
  162. package/types/app/cli/ipex.d.ts.map +1 -1
  163. package/types/app/cli/notifications.d.ts.map +1 -1
  164. package/types/app/cli/output.d.ts +2 -0
  165. package/types/app/cli/output.d.ts.map +1 -0
  166. package/types/app/credential-workflows.d.ts +1 -1
  167. package/types/app/credential-workflows.d.ts.map +1 -1
  168. package/types/app/cue-delivery.d.ts +30 -0
  169. package/types/app/cue-delivery.d.ts.map +1 -0
  170. package/types/app/cue-preparation.d.ts +25 -0
  171. package/types/app/cue-preparation.d.ts.map +1 -0
  172. package/types/app/cue-route.d.ts +19 -0
  173. package/types/app/cue-route.d.ts.map +1 -0
  174. package/types/app/cue-runtime.d.ts +19 -11
  175. package/types/app/cue-runtime.d.ts.map +1 -1
  176. package/types/app/delegating.d.ts +7 -3
  177. package/types/app/delegating.d.ts.map +1 -1
  178. package/types/app/direct-reply-delivery.d.ts +38 -0
  179. package/types/app/direct-reply-delivery.d.ts.map +1 -0
  180. package/types/app/essr.d.ts +72 -0
  181. package/types/app/essr.d.ts.map +1 -0
  182. package/types/app/exchanging.d.ts +141 -18
  183. package/types/app/exchanging.d.ts.map +1 -1
  184. package/types/app/forwarding.d.ts +91 -34
  185. package/types/app/forwarding.d.ts.map +1 -1
  186. package/types/app/grouping.d.ts +48 -9
  187. package/types/app/grouping.d.ts.map +1 -1
  188. package/types/app/habbing.d.ts +17 -33
  189. package/types/app/habbing.d.ts.map +1 -1
  190. package/types/app/httping.d.ts +3 -1
  191. package/types/app/httping.d.ts.map +1 -1
  192. package/types/app/ipex-building.d.ts +30 -0
  193. package/types/app/ipex-building.d.ts.map +1 -0
  194. package/types/app/ipex-credentialing.d.ts +2 -1
  195. package/types/app/ipex-credentialing.d.ts.map +1 -1
  196. package/types/app/ipex-graph.d.ts +30 -0
  197. package/types/app/ipex-graph.d.ts.map +1 -0
  198. package/types/app/ipex-grouping.d.ts.map +1 -1
  199. package/types/app/ipex-v2.d.ts +51 -0
  200. package/types/app/ipex-v2.d.ts.map +1 -0
  201. package/types/app/ipexing.d.ts +5 -0
  202. package/types/app/ipexing.d.ts.map +1 -1
  203. package/types/app/keeping.d.ts +2 -0
  204. package/types/app/keeping.d.ts.map +1 -1
  205. package/types/app/mailbox-director.d.ts +43 -33
  206. package/types/app/mailbox-director.d.ts.map +1 -1
  207. package/types/app/mailbox-sse.d.ts +22 -9
  208. package/types/app/mailbox-sse.d.ts.map +1 -1
  209. package/types/app/mailboxing.d.ts +1 -0
  210. package/types/app/mailboxing.d.ts.map +1 -1
  211. package/types/app/notifying.d.ts +4 -1
  212. package/types/app/notifying.d.ts.map +1 -1
  213. package/types/app/oobi-replies.d.ts +18 -0
  214. package/types/app/oobi-replies.d.ts.map +1 -0
  215. package/types/app/oobiery.d.ts +10 -2
  216. package/types/app/oobiery.d.ts.map +1 -1
  217. package/types/app/parsering.d.ts +41 -8
  218. package/types/app/parsering.d.ts.map +1 -1
  219. package/types/app/query-replies.d.ts +45 -0
  220. package/types/app/query-replies.d.ts.map +1 -0
  221. package/types/app/querying.d.ts +76 -12
  222. package/types/app/querying.d.ts.map +1 -1
  223. package/types/app/reactor.d.ts +86 -31
  224. package/types/app/reactor.d.ts.map +1 -1
  225. package/types/app/reply-streams.d.ts +51 -0
  226. package/types/app/reply-streams.d.ts.map +1 -0
  227. package/types/app/respondant.d.ts +7 -2
  228. package/types/app/respondant.d.ts.map +1 -1
  229. package/types/app/runtime-deliveries.d.ts +67 -0
  230. package/types/app/runtime-deliveries.d.ts.map +1 -0
  231. package/types/app/runtime-services.d.ts +3 -0
  232. package/types/app/runtime-services.d.ts.map +1 -1
  233. package/types/app/signaling.d.ts +39 -7
  234. package/types/app/signaling.d.ts.map +1 -1
  235. package/types/app/socket-source.d.ts +17 -0
  236. package/types/app/socket-source.d.ts.map +1 -0
  237. package/types/app/stored-replies.d.ts +18 -0
  238. package/types/app/stored-replies.d.ts.map +1 -0
  239. package/types/app/tcp-egress.d.ts +87 -0
  240. package/types/app/tcp-egress.d.ts.map +1 -0
  241. package/types/app/verifier-agent.d.ts +10 -1
  242. package/types/app/verifier-agent.d.ts.map +1 -1
  243. package/types/app/verifying.d.ts +5 -0
  244. package/types/app/verifying.d.ts.map +1 -1
  245. package/types/app/version.d.ts +2 -2
  246. package/types/app/witnessing.d.ts +66 -18
  247. package/types/app/witnessing.d.ts.map +1 -1
  248. package/types/core/attachment-countering.d.ts +3 -3
  249. package/types/core/attachment-countering.d.ts.map +1 -1
  250. package/types/core/cue-admission.d.ts +74 -0
  251. package/types/core/cue-admission.d.ts.map +1 -0
  252. package/types/core/cues.d.ts +9 -3
  253. package/types/core/cues.d.ts.map +1 -1
  254. package/types/core/deck.d.ts +12 -1
  255. package/types/core/deck.d.ts.map +1 -1
  256. package/types/core/dispatch.d.ts +16 -35
  257. package/types/core/dispatch.d.ts.map +1 -1
  258. package/types/core/eventing.d.ts +52 -23
  259. package/types/core/eventing.d.ts.map +1 -1
  260. package/types/core/exchange-proofing.d.ts +31 -0
  261. package/types/core/exchange-proofing.d.ts.map +1 -0
  262. package/types/core/kever-decisions.d.ts +2 -3
  263. package/types/core/kever-decisions.d.ts.map +1 -1
  264. package/types/core/kever.d.ts +11 -9
  265. package/types/core/kever.d.ts.map +1 -1
  266. package/types/core/kram-auth.d.ts +23 -0
  267. package/types/core/kram-auth.d.ts.map +1 -0
  268. package/types/core/kram-handoff.d.ts +45 -0
  269. package/types/core/kram-handoff.d.ts.map +1 -0
  270. package/types/core/kram-policy.d.ts +43 -0
  271. package/types/core/kram-policy.d.ts.map +1 -0
  272. package/types/core/kram-pruning.d.ts +38 -0
  273. package/types/core/kram-pruning.d.ts.map +1 -0
  274. package/types/core/kram-signatures.d.ts +29 -0
  275. package/types/core/kram-signatures.d.ts.map +1 -0
  276. package/types/core/kram-staging.d.ts +36 -0
  277. package/types/core/kram-staging.d.ts.map +1 -0
  278. package/types/core/kram-time.d.ts +53 -0
  279. package/types/core/kram-time.d.ts.map +1 -0
  280. package/types/core/kraming.d.ts +46 -0
  281. package/types/core/kraming.d.ts.map +1 -0
  282. package/types/core/protocol-exchanging.d.ts +4 -0
  283. package/types/core/protocol-exchanging.d.ts.map +1 -1
  284. package/types/core/protocol-serialization.d.ts +21 -2
  285. package/types/core/protocol-serialization.d.ts.map +1 -1
  286. package/types/core/records.d.ts +4 -2
  287. package/types/core/records.d.ts.map +1 -1
  288. package/types/core/routing.d.ts +26 -1
  289. package/types/core/routing.d.ts.map +1 -1
  290. package/types/db/basing.d.ts +83 -6
  291. package/types/db/basing.d.ts.map +1 -1
  292. package/types/db/core/lmdber.d.ts +9 -0
  293. package/types/db/core/lmdber.d.ts.map +1 -1
  294. package/types/db/escrowing.d.ts +16 -0
  295. package/types/db/escrowing.d.ts.map +1 -1
  296. package/types/db/exchange-nests.d.ts +39 -0
  297. package/types/db/exchange-nests.d.ts.map +1 -0
  298. package/types/db/exchange-records.d.ts +35 -0
  299. package/types/db/exchange-records.d.ts.map +1 -0
  300. package/types/db/index.d.ts +4 -0
  301. package/types/db/index.d.ts.map +1 -1
  302. package/types/db/kel-replay.d.ts +17 -0
  303. package/types/db/kel-replay.d.ts.map +1 -0
  304. package/types/db/kram-factors.d.ts +13 -0
  305. package/types/db/kram-factors.d.ts.map +1 -0
  306. package/types/db/kram-snapshots.d.ts +23 -0
  307. package/types/db/kram-snapshots.d.ts.map +1 -0
  308. package/types/db/mailboxing.d.ts +4 -2
  309. package/types/db/mailboxing.d.ts.map +1 -1
  310. package/types/db/outboxing.d.ts +27 -5
  311. package/types/db/outboxing.d.ts.map +1 -1
  312. package/types/db/payload-archive.d.ts +70 -0
  313. package/types/db/payload-archive.d.ts.map +1 -0
  314. package/types/db/payload-store.d.ts +40 -0
  315. package/types/db/payload-store.d.ts.map +1 -0
  316. package/types/db/payload-view.d.ts +4 -0
  317. package/types/db/payload-view.d.ts.map +1 -0
  318. package/types/db/reger.d.ts +18 -7
  319. package/types/db/reger.d.ts.map +1 -1
  320. package/types/db/subing.d.ts +9 -0
  321. package/types/db/subing.d.ts.map +1 -1
  322. package/types/db/tel-replay.d.ts +26 -0
  323. package/types/db/tel-replay.d.ts.map +1 -0
  324. package/types/db/witness-replay.d.ts +17 -0
  325. package/types/db/witness-replay.d.ts.map +1 -0
  326. package/types/did/webs/artifacts.d.ts +5 -1
  327. package/types/did/webs/artifacts.d.ts.map +1 -1
  328. package/types/did/webs/resolving.d.ts +0 -6
  329. package/types/did/webs/resolving.d.ts.map +1 -1
  330. package/types/npm/deno-shim.d.ts +3 -0
  331. package/types/npm/deno-shim.d.ts.map +1 -0
  332. package/types/runtime/index.d.ts +17 -1
  333. package/types/runtime/index.d.ts.map +1 -1
  334. package/types/time/mod.d.ts +4 -2
  335. package/types/time/mod.d.ts.map +1 -1
  336. package/types/vdr/credential-tsn.d.ts +18 -0
  337. package/types/vdr/credential-tsn.d.ts.map +1 -0
  338. package/types/vdr/credentialing.d.ts +2 -2
  339. package/types/vdr/credentialing.d.ts.map +1 -1
  340. package/types/vdr/eventing.d.ts +19 -1
  341. package/types/vdr/eventing.d.ts.map +1 -1
  342. package/types/vdr/registry-tsn.d.ts +23 -0
  343. package/types/vdr/registry-tsn.d.ts.map +1 -0
  344. package/types/vdr/tsn-query.d.ts +22 -0
  345. package/types/vdr/tsn-query.d.ts.map +1 -0
  346. package/esm/keri/npm/src/app/query-transport.js +0 -121
  347. package/types/app/query-transport.d.ts +0 -13
  348. package/types/app/query-transport.d.ts.map +0 -1
@@ -0,0 +1,434 @@
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";
5
+ import { validateRip, validateUpdate, verifyRegistryAnchor, } from "./regeventing.js";
6
+ import { FailedSchemaValidationError, MissingSchemaError, validateSchema } from "./scheming.js";
7
+ /**
8
+ * 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.
10
+ * Publication is atomic; binding this instance happens only after successful commit.
11
+ */
12
+ export class RegistryEventer {
13
+ constructor(db, issuer, store, regk = null) {
14
+ Object.defineProperty(this, "db", {
15
+ enumerable: true,
16
+ configurable: true,
17
+ writable: true,
18
+ value: db
19
+ });
20
+ Object.defineProperty(this, "issuer", {
21
+ enumerable: true,
22
+ configurable: true,
23
+ writable: true,
24
+ value: issuer
25
+ });
26
+ Object.defineProperty(this, "store", {
27
+ enumerable: true,
28
+ configurable: true,
29
+ writable: true,
30
+ value: store
31
+ });
32
+ Object.defineProperty(this, "regk", {
33
+ enumerable: true,
34
+ configurable: true,
35
+ writable: true,
36
+ value: regk
37
+ });
38
+ }
39
+ /** Read the accepted head only after validating its body and ordinal marker. */
40
+ get head() {
41
+ const event = this.regk ? this.acceptedHead(this.regk) : null;
42
+ return event ? this.store.head(event.regid) : null;
43
+ }
44
+ /** Accepted TEL ordinal, retaining -1n for a staged but unaccepted inception. */
45
+ get sn() {
46
+ return this.regk ? this.acceptedHead(this.regk)?.sn ?? -1n : -1n;
47
+ }
48
+ /** Return an accepted inception; a corrupt marker/body pair throws. */
49
+ get regser() {
50
+ return this.regk ? this.acceptedAt(this.regk, 0) : null;
51
+ }
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
+ /** Retry newly visible anchors, then advance the contiguous accepted chain. */
135
+ processEscrows() {
136
+ this.processMissingAnchors();
137
+ this.processQueued();
138
+ }
139
+ /** Authenticate a complete explicit source couple or discover one for a stored event. */
140
+ anchorMsg(said, number, diger) {
141
+ const serder = this.store.event(said);
142
+ if (!serder)
143
+ return { kind: "reject", reason: "event" };
144
+ if (serder.said !== said)
145
+ throw new Error("Corrupt escrowed registry event.");
146
+ const result = this.regk === null || serder.ilk === Ilks.rip
147
+ ? validateRip(serder, this.issuer)
148
+ : validateUpdate(serder, this.regk);
149
+ if (result.kind === "reject")
150
+ return result;
151
+ const event = result.event;
152
+ if (this.regk !== null && event.regid !== this.regk)
153
+ return { kind: "reject", reason: "registry" };
154
+ if (event.sn > BigInt(Number.MAX_SAFE_INTEGER))
155
+ return { kind: "reject", reason: "ordinalRange" };
156
+ const occupied = this.acceptedEvent(event);
157
+ if (occupied?.kind === "reject")
158
+ return occupied;
159
+ const prior = event.sn > 0n ? this.acceptedAt(event.regid, Number(event.sn) - 1) : null;
160
+ if (prior && prior.said !== event.prior)
161
+ return { kind: "reject", reason: "prior" };
162
+ if ((number === undefined) !== (diger === undefined))
163
+ return { kind: "reject", reason: "anchor" };
164
+ if (number && diger) {
165
+ if (!verifyRegistryAnchor(event, { db: this.db, issuer: this.issuer, number, diger })) {
166
+ return { kind: "reject", reason: "anchor" };
167
+ }
168
+ this.store.putAnchor(said, number, diger);
169
+ }
170
+ else {
171
+ this.discoverAnchor(event);
172
+ }
173
+ if (!this.store.anchor(said))
174
+ return { kind: "reject", reason: "anchor" };
175
+ return this.processEvent(serder);
176
+ }
177
+ /** Advance only the next ordinal, committing one verified winner per transaction. */
178
+ processQueued() {
179
+ if (this.regk === null)
180
+ return;
181
+ while (true) {
182
+ const head = this.acceptedHead(this.regk);
183
+ if (!head)
184
+ return;
185
+ const sn = head.sn + 1n;
186
+ if (sn > BigInt(Number.MAX_SAFE_INTEGER))
187
+ return;
188
+ const candidates = this.store.baser.ooes?.get(this.regk, Number(sn)).map(([said]) => said) ?? [];
189
+ candidates.sort((a, b) => this.compareAnchors(a, b));
190
+ let advanced = false;
191
+ for (const said of candidates) {
192
+ const event = this.replayCandidate(said, Number(sn));
193
+ if (!event || !this.store.anchor(said))
194
+ continue;
195
+ const decision = this.processOne(event.serder);
196
+ if (decision.kind === "accept") {
197
+ advanced = true;
198
+ break;
199
+ }
200
+ }
201
+ if (!advanced)
202
+ return;
203
+ }
204
+ }
205
+ /** Retry anchor escrow by ordinal, arbitrating siblings before entering normal acceptance. */
206
+ processMissingAnchors() {
207
+ if (this.regk === null)
208
+ return;
209
+ 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) ?? []) {
212
+ if (!Number.isSafeInteger(sn) || sn < 0)
213
+ throw new RangeError("Unsafe registry escrow ordinal.");
214
+ const candidates = slots.get(sn) ?? [];
215
+ candidates.push(said);
216
+ slots.set(sn, candidates);
217
+ }
218
+ for (const [sn, saids] of [...slots].sort(([a], [b]) => a - b)) {
219
+ const candidates = [];
220
+ for (const said of saids) {
221
+ const event = this.replayCandidate(said, sn);
222
+ if (!event)
223
+ continue;
224
+ this.discoverAnchor(event);
225
+ candidates.push(event);
226
+ }
227
+ candidates.sort((a, b) => this.compareAnchors(a.said, b.said));
228
+ for (const event of candidates) {
229
+ const result = this.processEvent(event.serder);
230
+ if (result.kind === "reject" || result.kind === "duplicate") {
231
+ this.store.clearEscrows(this.regk, sn, event.said);
232
+ }
233
+ }
234
+ }
235
+ }
236
+ /** Prune unrecoverable candidates; corrupt records and storage failures still propagate. */
237
+ replayCandidate(said, sn) {
238
+ const serder = this.store.event(said);
239
+ if (!serder) {
240
+ this.store.clearEscrows(this.regk, sn, said);
241
+ return null;
242
+ }
243
+ if (serder.said !== said)
244
+ throw new Error("Corrupt escrowed registry event.");
245
+ const result = serder.ilk === Ilks.rip
246
+ ? validateRip(serder, this.issuer)
247
+ : validateUpdate(serder, this.regk);
248
+ if (result.kind === "valid") {
249
+ const event = result.event;
250
+ if (event.regid === this.regk && event.sn === BigInt(sn)) {
251
+ const existing = this.acceptedEvent(event);
252
+ const prior = sn > 0 ? this.acceptedAt(event.regid, sn - 1) : null;
253
+ if (!existing && (!prior || prior.said === event.prior))
254
+ return event;
255
+ }
256
+ }
257
+ this.store.clearEscrows(this.regk, sn, said);
258
+ return null;
259
+ }
260
+ /** Earliest verified anchor wins; digest then event SAID break ties using code-point order. */
261
+ compareAnchors(left, right) {
262
+ const a = this.store.anchor(left), b = this.store.anchor(right);
263
+ if (a && !b)
264
+ return -1;
265
+ if (!a && b)
266
+ return 1;
267
+ if (a && b) {
268
+ if (a[0].num !== b[0].num)
269
+ return a[0].num < b[0].num ? -1 : 1;
270
+ if (a[1].qb64 !== b[1].qb64)
271
+ return a[1].qb64 < b[1].qb64 ? -1 : 1;
272
+ }
273
+ return left < right ? -1 : left > right ? 1 : 0;
274
+ }
275
+ /** Accept one parsed event, then advance ready successors without recursive replay. */
276
+ processEvent(serder) {
277
+ const decision = this.processOne(serder);
278
+ if (decision.kind === "accept")
279
+ this.processQueued();
280
+ return decision;
281
+ }
282
+ /** Decide and persist one event; callers own subsequent chain progression. */
283
+ processOne(serder) {
284
+ if (this.regk === null || serder.ilk === Ilks.rip)
285
+ return this.processInception(serder);
286
+ const result = validateUpdate(serder, this.regk);
287
+ if (result.kind === "reject")
288
+ return result;
289
+ const event = result.event;
290
+ // Preserve protocol precision until the existing ordinal storage seam can represent it.
291
+ if (event.sn > BigInt(Number.MAX_SAFE_INTEGER))
292
+ return { kind: "reject", reason: "ordinalRange" };
293
+ const prior = this.acceptedAt(event.regid, Number(event.sn) - 1);
294
+ if (prior && prior.said !== event.prior)
295
+ return { kind: "reject", reason: "prior" };
296
+ const previous = this.acceptedEvent(event);
297
+ if (previous)
298
+ return previous;
299
+ const env = this.store.baser.env;
300
+ if (!env)
301
+ throw new DatabaseNotOpenError("Registry acceptance requires an open backing store.");
302
+ this.store.baser.initializeStorage();
303
+ return env.transactionSync(() => {
304
+ const prior = this.acceptedAt(event.regid, Number(event.sn) - 1);
305
+ if (prior && prior.said !== event.prior)
306
+ return { kind: "reject", reason: "prior" };
307
+ const previous = this.acceptedEvent(event);
308
+ if (previous)
309
+ return previous;
310
+ this.store.putEvent(serder);
311
+ this.discoverAnchor(event);
312
+ if (!this.store.anchor(event.said)) {
313
+ this.store.escrowMissingAnchor(event.regid, Number(event.sn), event.said);
314
+ return { kind: "escrow", reason: "anchor", event };
315
+ }
316
+ this.store.baser.maes.rem(event.regid, Number(event.sn), [event.said]);
317
+ if (!prior) {
318
+ this.store.escrowOutOfOrder(event.regid, Number(event.sn), event.said);
319
+ return { kind: "escrow", reason: "order", event };
320
+ }
321
+ const head = this.acceptedHead(event.regid);
322
+ if (head && head.sn >= event.sn)
323
+ throw new Error("Registry update would downgrade accepted head.");
324
+ this.commit(event);
325
+ return { kind: "accept", event };
326
+ });
327
+ }
328
+ /** Validate, anchor and accept one inception, or retain its body in anchor escrow. */
329
+ processInception(serder) {
330
+ const result = validateRip(serder, this.issuer);
331
+ if (result.kind === "reject")
332
+ return result;
333
+ const event = result.event;
334
+ if (this.regk !== null && this.regk !== event.regid)
335
+ return { kind: "reject", reason: "registry" };
336
+ const previous = this.acceptedEvent(event);
337
+ if (previous) {
338
+ if (previous.kind === "duplicate")
339
+ this.regk = event.regid;
340
+ return previous;
341
+ }
342
+ const env = this.store.baser.env;
343
+ if (!env)
344
+ 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();
347
+ const decision = env.transactionSync(() => {
348
+ const previous = this.acceptedEvent(event);
349
+ if (previous)
350
+ return previous;
351
+ if (this.store.head(event.regid))
352
+ throw new Error("Registry head exists without its accepted inception.");
353
+ this.store.putEvent(serder);
354
+ this.discoverAnchor(event);
355
+ if (!this.store.anchor(event.said)) {
356
+ this.store.escrowMissingAnchor(event.regid, 0, event.said);
357
+ return { kind: "escrow", reason: "anchor", event };
358
+ }
359
+ this.commit(event);
360
+ return { kind: "accept", event };
361
+ });
362
+ if (decision.kind !== "reject")
363
+ this.regk = event.regid;
364
+ return decision;
365
+ }
366
+ /** Replay is read-only; first acceptance repeats this check under its write transaction. */
367
+ acceptedEvent(event) {
368
+ const existing = this.acceptedAt(event.regid, Number(event.sn));
369
+ if (!existing)
370
+ return null;
371
+ if (existing.said !== event.said)
372
+ return { kind: "reject", reason: "duplicity" };
373
+ return { kind: "duplicate", event };
374
+ }
375
+ /** Accepted markers require a matching body at the exact ordinal, unlike mere staged bodies. */
376
+ acceptedAt(regid, sn) {
377
+ const marker = this.store.seqSaider(regid, sn);
378
+ if (!marker)
379
+ return null;
380
+ const body = this.store.event(marker.qb64);
381
+ if (!body)
382
+ throw new Error("Corrupt accepted registry event.");
383
+ const result = body.ilk === Ilks.rip
384
+ ? validateRip(body, this.issuer)
385
+ : validateUpdate(body, regid);
386
+ if (result?.kind !== "valid" || result.event.said !== marker.qb64
387
+ || result.event.sn !== BigInt(sn) || result.event.regid !== regid) {
388
+ throw new Error("Corrupt accepted registry event.");
389
+ }
390
+ return result.event.serder;
391
+ }
392
+ /** An accepted head must identify this registry's body and its matching accepted ordinal. */
393
+ acceptedHead(regid) {
394
+ const marker = this.store.head(regid);
395
+ if (!marker)
396
+ return null;
397
+ const body = this.store.event(marker.qb64);
398
+ if (!body)
399
+ throw new Error("Corrupt registry head.");
400
+ const result = body.ilk === Ilks.rip
401
+ ? validateRip(body, this.issuer)
402
+ : validateUpdate(body, regid);
403
+ if (result?.kind !== "valid" || result.event.said !== marker.qb64 || result.event.regid !== regid
404
+ || result.event.sn > BigInt(Number.MAX_SAFE_INTEGER))
405
+ throw new Error("Corrupt registry head.");
406
+ if (this.acceptedAt(regid, Number(result.event.sn))?.said !== marker.qb64) {
407
+ throw new Error("Corrupt registry head ordinal.");
408
+ }
409
+ return result.event;
410
+ }
411
+ /** Publish one verified winner and remove all siblings from its decided slot atomically. */
412
+ commit(event) {
413
+ this.store.accept(event.regid, Number(event.sn), event.serder);
414
+ this.store.baser.maes.rem(event.regid, Number(event.sn));
415
+ this.store.baser.ooes.rem(event.regid, Number(event.sn));
416
+ }
417
+ /** Keep an already verified anchor or discover the earliest fully witnessed seal. */
418
+ discoverAnchor(event) {
419
+ if (this.store.anchor(event.said))
420
+ return;
421
+ const anchor = this.db.fetchLastSealingEventByEventSeal(this.issuer, {
422
+ i: event.regid,
423
+ s: event.serder.sad.n,
424
+ d: event.said,
425
+ });
426
+ if (!anchor)
427
+ return;
428
+ const number = NumberPrimitive.fromNum(BigInt(anchor.sn));
429
+ const diger = new Diger({ qb64: anchor.said });
430
+ if (verifyRegistryAnchor(event, { db: this.db, issuer: this.issuer, number, diger })) {
431
+ this.store.putAnchor(event.said, number, diger);
432
+ }
433
+ }
434
+ }