@did-btcr2/method 0.26.0 → 0.28.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 (297) hide show
  1. package/README.md +118 -236
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/browser.js +27665 -23764
  4. package/dist/browser.mjs +27665 -23764
  5. package/dist/cjs/index.js +2661 -2239
  6. package/dist/esm/core/aggregation/cohort.js +178 -0
  7. package/dist/esm/core/aggregation/cohort.js.map +1 -0
  8. package/dist/esm/core/aggregation/errors.js +22 -0
  9. package/dist/esm/core/aggregation/errors.js.map +1 -0
  10. package/dist/esm/core/{beacon/aggregation/cohort → aggregation}/messages/base.js +0 -1
  11. package/dist/esm/core/aggregation/messages/base.js.map +1 -0
  12. package/dist/esm/core/aggregation/messages/constants.js +26 -0
  13. package/dist/esm/core/aggregation/messages/constants.js.map +1 -0
  14. package/dist/esm/core/aggregation/messages/factories.js +113 -0
  15. package/dist/esm/core/aggregation/messages/factories.js.map +1 -0
  16. package/dist/esm/core/aggregation/messages/guards.js +37 -0
  17. package/dist/esm/core/aggregation/messages/guards.js.map +1 -0
  18. package/dist/esm/core/aggregation/messages/index.js +5 -0
  19. package/dist/esm/core/aggregation/messages/index.js.map +1 -0
  20. package/dist/esm/core/aggregation/participant.js +376 -0
  21. package/dist/esm/core/aggregation/participant.js.map +1 -0
  22. package/dist/esm/core/aggregation/phases.js +39 -0
  23. package/dist/esm/core/aggregation/phases.js.map +1 -0
  24. package/dist/esm/core/aggregation/runner/events.js +2 -0
  25. package/dist/esm/core/aggregation/runner/events.js.map +1 -0
  26. package/dist/esm/core/aggregation/runner/index.js +5 -0
  27. package/dist/esm/core/aggregation/runner/index.js.map +1 -0
  28. package/dist/esm/core/aggregation/runner/participant-runner.js +286 -0
  29. package/dist/esm/core/aggregation/runner/participant-runner.js.map +1 -0
  30. package/dist/esm/core/aggregation/runner/service-runner.js +290 -0
  31. package/dist/esm/core/aggregation/runner/service-runner.js.map +1 -0
  32. package/dist/esm/core/aggregation/runner/typed-emitter.js +80 -0
  33. package/dist/esm/core/aggregation/runner/typed-emitter.js.map +1 -0
  34. package/dist/esm/core/aggregation/service.js +416 -0
  35. package/dist/esm/core/aggregation/service.js.map +1 -0
  36. package/dist/esm/core/aggregation/signing-session.js +133 -0
  37. package/dist/esm/core/aggregation/signing-session.js.map +1 -0
  38. package/dist/esm/core/aggregation/transport/didcomm.js +32 -0
  39. package/dist/esm/core/aggregation/transport/didcomm.js.map +1 -0
  40. package/dist/esm/core/aggregation/transport/error.js +12 -0
  41. package/dist/esm/core/aggregation/transport/error.js.map +1 -0
  42. package/dist/esm/core/aggregation/transport/factory.js +20 -0
  43. package/dist/esm/core/aggregation/transport/factory.js.map +1 -0
  44. package/dist/esm/core/aggregation/transport/index.js +6 -0
  45. package/dist/esm/core/aggregation/transport/index.js.map +1 -0
  46. package/dist/esm/core/aggregation/transport/nostr.js +262 -0
  47. package/dist/esm/core/aggregation/transport/nostr.js.map +1 -0
  48. package/dist/esm/core/aggregation/transport/transport.js +2 -0
  49. package/dist/esm/core/aggregation/transport/transport.js.map +1 -0
  50. package/dist/esm/core/beacon/beacon.js +80 -0
  51. package/dist/esm/core/beacon/beacon.js.map +1 -1
  52. package/dist/esm/core/beacon/cas-beacon.js +15 -56
  53. package/dist/esm/core/beacon/cas-beacon.js.map +1 -1
  54. package/dist/esm/core/beacon/error.js +0 -10
  55. package/dist/esm/core/beacon/error.js.map +1 -1
  56. package/dist/esm/core/beacon/fee-estimator.js +30 -0
  57. package/dist/esm/core/beacon/fee-estimator.js.map +1 -0
  58. package/dist/esm/core/beacon/singleton-beacon.js +10 -53
  59. package/dist/esm/core/beacon/singleton-beacon.js.map +1 -1
  60. package/dist/esm/core/beacon/smt-beacon.js +85 -9
  61. package/dist/esm/core/beacon/smt-beacon.js.map +1 -1
  62. package/dist/esm/core/identifier.js +13 -0
  63. package/dist/esm/core/identifier.js.map +1 -1
  64. package/dist/esm/core/resolver.js +9 -0
  65. package/dist/esm/core/resolver.js.map +1 -1
  66. package/dist/esm/core/updater.js +269 -0
  67. package/dist/esm/core/updater.js.map +1 -0
  68. package/dist/esm/did-btcr2.js +30 -42
  69. package/dist/esm/did-btcr2.js.map +1 -1
  70. package/dist/esm/index.js +16 -25
  71. package/dist/esm/index.js.map +1 -1
  72. package/dist/types/core/aggregation/cohort.d.ts +94 -0
  73. package/dist/types/core/aggregation/cohort.d.ts.map +1 -0
  74. package/dist/types/core/aggregation/errors.d.ts +14 -0
  75. package/dist/types/core/aggregation/errors.d.ts.map +1 -0
  76. package/dist/types/core/{beacon/aggregation/cohort → aggregation}/messages/base.d.ts +7 -1
  77. package/dist/types/core/aggregation/messages/base.d.ts.map +1 -0
  78. package/dist/types/core/aggregation/messages/constants.d.ts +23 -0
  79. package/dist/types/core/aggregation/messages/constants.d.ts.map +1 -0
  80. package/dist/types/core/aggregation/messages/factories.d.ts +177 -0
  81. package/dist/types/core/aggregation/messages/factories.d.ts.map +1 -0
  82. package/dist/types/core/aggregation/messages/guards.d.ts +11 -0
  83. package/dist/types/core/aggregation/messages/guards.d.ts.map +1 -0
  84. package/dist/types/core/aggregation/messages/index.d.ts +5 -0
  85. package/dist/types/core/aggregation/messages/index.d.ts.map +1 -0
  86. package/dist/types/core/aggregation/participant.d.ts +101 -0
  87. package/dist/types/core/aggregation/participant.d.ts.map +1 -0
  88. package/dist/types/core/aggregation/phases.d.ts +49 -0
  89. package/dist/types/core/aggregation/phases.d.ts.map +1 -0
  90. package/dist/types/core/aggregation/runner/events.d.ts +89 -0
  91. package/dist/types/core/aggregation/runner/events.d.ts.map +1 -0
  92. package/dist/types/core/aggregation/runner/index.d.ts +5 -0
  93. package/dist/types/core/aggregation/runner/index.d.ts.map +1 -0
  94. package/dist/types/core/aggregation/runner/participant-runner.d.ts +111 -0
  95. package/dist/types/core/aggregation/runner/participant-runner.d.ts.map +1 -0
  96. package/dist/types/core/aggregation/runner/service-runner.d.ts +102 -0
  97. package/dist/types/core/aggregation/runner/service-runner.d.ts.map +1 -0
  98. package/dist/types/core/aggregation/runner/typed-emitter.d.ts +41 -0
  99. package/dist/types/core/aggregation/runner/typed-emitter.d.ts.map +1 -0
  100. package/dist/types/core/aggregation/service.d.ts +112 -0
  101. package/dist/types/core/aggregation/service.d.ts.map +1 -0
  102. package/dist/types/core/aggregation/signing-session.d.ts +69 -0
  103. package/dist/types/core/aggregation/signing-session.d.ts.map +1 -0
  104. package/dist/types/core/aggregation/transport/didcomm.d.ts +20 -0
  105. package/dist/types/core/aggregation/transport/didcomm.d.ts.map +1 -0
  106. package/dist/types/core/{beacon/aggregation/communication → aggregation/transport}/error.d.ts +2 -2
  107. package/dist/types/core/aggregation/transport/error.d.ts.map +1 -0
  108. package/dist/types/core/aggregation/transport/factory.d.ts +13 -0
  109. package/dist/types/core/aggregation/transport/factory.d.ts.map +1 -0
  110. package/dist/types/core/aggregation/transport/index.d.ts +6 -0
  111. package/dist/types/core/aggregation/transport/index.d.ts.map +1 -0
  112. package/dist/types/core/aggregation/transport/nostr.d.ts +55 -0
  113. package/dist/types/core/aggregation/transport/nostr.d.ts.map +1 -0
  114. package/dist/types/core/aggregation/transport/transport.d.ts +37 -0
  115. package/dist/types/core/aggregation/transport/transport.d.ts.map +1 -0
  116. package/dist/types/core/beacon/beacon.d.ts +37 -2
  117. package/dist/types/core/beacon/beacon.d.ts.map +1 -1
  118. package/dist/types/core/beacon/cas-beacon.d.ts +19 -7
  119. package/dist/types/core/beacon/cas-beacon.d.ts.map +1 -1
  120. package/dist/types/core/beacon/error.d.ts +0 -6
  121. package/dist/types/core/beacon/error.d.ts.map +1 -1
  122. package/dist/types/core/beacon/fee-estimator.d.ts +40 -0
  123. package/dist/types/core/beacon/fee-estimator.d.ts.map +1 -0
  124. package/dist/types/core/beacon/interfaces.d.ts +8 -0
  125. package/dist/types/core/beacon/interfaces.d.ts.map +1 -1
  126. package/dist/types/core/beacon/singleton-beacon.d.ts +9 -2
  127. package/dist/types/core/beacon/singleton-beacon.d.ts.map +1 -1
  128. package/dist/types/core/beacon/smt-beacon.d.ts +27 -7
  129. package/dist/types/core/beacon/smt-beacon.d.ts.map +1 -1
  130. package/dist/types/core/identifier.d.ts +8 -0
  131. package/dist/types/core/identifier.d.ts.map +1 -1
  132. package/dist/types/core/interfaces.d.ts +2 -2
  133. package/dist/types/core/resolver.d.ts +11 -1
  134. package/dist/types/core/resolver.d.ts.map +1 -1
  135. package/dist/types/core/updater.d.ts +178 -0
  136. package/dist/types/core/updater.d.ts.map +1 -0
  137. package/dist/types/did-btcr2.d.ts +23 -23
  138. package/dist/types/did-btcr2.d.ts.map +1 -1
  139. package/dist/types/index.d.ts +11 -25
  140. package/dist/types/index.d.ts.map +1 -1
  141. package/package.json +31 -30
  142. package/src/core/aggregation/cohort.ts +247 -0
  143. package/src/core/aggregation/errors.ts +25 -0
  144. package/src/core/{beacon/aggregation/cohort → aggregation}/messages/base.ts +8 -3
  145. package/src/core/aggregation/messages/constants.ts +28 -0
  146. package/src/core/aggregation/messages/factories.ts +240 -0
  147. package/src/core/aggregation/messages/guards.ts +55 -0
  148. package/src/core/aggregation/messages/index.ts +4 -0
  149. package/src/core/aggregation/participant.ts +510 -0
  150. package/src/core/aggregation/phases.ts +82 -0
  151. package/src/core/aggregation/runner/events.ts +77 -0
  152. package/src/core/aggregation/runner/index.ts +4 -0
  153. package/src/core/aggregation/runner/participant-runner.ts +364 -0
  154. package/src/core/aggregation/runner/service-runner.ts +365 -0
  155. package/src/core/aggregation/runner/typed-emitter.ts +87 -0
  156. package/src/core/aggregation/service.ts +547 -0
  157. package/src/core/aggregation/signing-session.ts +209 -0
  158. package/src/core/aggregation/transport/didcomm.ts +42 -0
  159. package/src/core/aggregation/transport/error.ts +13 -0
  160. package/src/core/aggregation/transport/factory.ts +29 -0
  161. package/src/core/aggregation/transport/index.ts +5 -0
  162. package/src/core/aggregation/transport/nostr.ts +333 -0
  163. package/src/core/aggregation/transport/transport.ts +46 -0
  164. package/src/core/beacon/beacon.ts +122 -2
  165. package/src/core/beacon/cas-beacon.ts +28 -76
  166. package/src/core/beacon/error.ts +0 -12
  167. package/src/core/beacon/fee-estimator.ts +52 -0
  168. package/src/core/beacon/interfaces.ts +10 -1
  169. package/src/core/beacon/singleton-beacon.ts +14 -75
  170. package/src/core/beacon/smt-beacon.ts +109 -11
  171. package/src/core/identifier.ts +17 -0
  172. package/src/core/interfaces.ts +2 -2
  173. package/src/core/resolver.ts +25 -2
  174. package/src/core/updater.ts +415 -0
  175. package/src/did-btcr2.ts +36 -66
  176. package/src/index.ts +17 -30
  177. package/dist/esm/core/beacon/aggregation/cohort/index.js +0 -237
  178. package/dist/esm/core/beacon/aggregation/cohort/index.js.map +0 -1
  179. package/dist/esm/core/beacon/aggregation/cohort/messages/base.js.map +0 -1
  180. package/dist/esm/core/beacon/aggregation/cohort/messages/constants.js +0 -11
  181. package/dist/esm/core/beacon/aggregation/cohort/messages/constants.js.map +0 -1
  182. package/dist/esm/core/beacon/aggregation/cohort/messages/index.js +0 -98
  183. package/dist/esm/core/beacon/aggregation/cohort/messages/index.js.map +0 -1
  184. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js +0 -31
  185. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js.map +0 -1
  186. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js +0 -29
  187. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js.map +0 -1
  188. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js +0 -27
  189. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js.map +0 -1
  190. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in.js +0 -23
  191. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in.js.map +0 -1
  192. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/subscribe.js +0 -28
  193. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/subscribe.js.map +0 -1
  194. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js +0 -29
  195. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js.map +0 -1
  196. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/authorization-request.js +0 -30
  197. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/authorization-request.js.map +0 -1
  198. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js +0 -30
  199. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js.map +0 -1
  200. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/request-signature.js +0 -30
  201. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/request-signature.js.map +0 -1
  202. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js +0 -31
  203. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js.map +0 -1
  204. package/dist/esm/core/beacon/aggregation/cohort/status.js +0 -8
  205. package/dist/esm/core/beacon/aggregation/cohort/status.js.map +0 -1
  206. package/dist/esm/core/beacon/aggregation/communication/adapter/did-comm.js +0 -121
  207. package/dist/esm/core/beacon/aggregation/communication/adapter/did-comm.js.map +0 -1
  208. package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js +0 -245
  209. package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js.map +0 -1
  210. package/dist/esm/core/beacon/aggregation/communication/error.js +0 -12
  211. package/dist/esm/core/beacon/aggregation/communication/error.js.map +0 -1
  212. package/dist/esm/core/beacon/aggregation/communication/factory.js +0 -21
  213. package/dist/esm/core/beacon/aggregation/communication/factory.js.map +0 -1
  214. package/dist/esm/core/beacon/aggregation/communication/service.js +0 -2
  215. package/dist/esm/core/beacon/aggregation/communication/service.js.map +0 -1
  216. package/dist/esm/core/beacon/aggregation/coordinator.js +0 -343
  217. package/dist/esm/core/beacon/aggregation/coordinator.js.map +0 -1
  218. package/dist/esm/core/beacon/aggregation/participant.js +0 -435
  219. package/dist/esm/core/beacon/aggregation/participant.js.map +0 -1
  220. package/dist/esm/core/beacon/aggregation/session/index.js +0 -244
  221. package/dist/esm/core/beacon/aggregation/session/index.js.map +0 -1
  222. package/dist/esm/core/beacon/aggregation/session/status.js +0 -11
  223. package/dist/esm/core/beacon/aggregation/session/status.js.map +0 -1
  224. package/dist/esm/core/update.js +0 -112
  225. package/dist/esm/core/update.js.map +0 -1
  226. package/dist/types/core/beacon/aggregation/cohort/index.d.ts +0 -136
  227. package/dist/types/core/beacon/aggregation/cohort/index.d.ts.map +0 -1
  228. package/dist/types/core/beacon/aggregation/cohort/messages/base.d.ts.map +0 -1
  229. package/dist/types/core/beacon/aggregation/cohort/messages/constants.d.ts +0 -11
  230. package/dist/types/core/beacon/aggregation/cohort/messages/constants.d.ts.map +0 -1
  231. package/dist/types/core/beacon/aggregation/cohort/messages/index.d.ts +0 -65
  232. package/dist/types/core/beacon/aggregation/cohort/messages/index.d.ts.map +0 -1
  233. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.d.ts +0 -29
  234. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.d.ts.map +0 -1
  235. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts +0 -26
  236. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts.map +0 -1
  237. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.d.ts +0 -24
  238. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.d.ts.map +0 -1
  239. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in.d.ts +0 -20
  240. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in.d.ts.map +0 -1
  241. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/subscribe.d.ts +0 -25
  242. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/subscribe.d.ts.map +0 -1
  243. package/dist/types/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.d.ts +0 -25
  244. package/dist/types/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.d.ts.map +0 -1
  245. package/dist/types/core/beacon/aggregation/cohort/messages/sign/authorization-request.d.ts +0 -26
  246. package/dist/types/core/beacon/aggregation/cohort/messages/sign/authorization-request.d.ts.map +0 -1
  247. package/dist/types/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.d.ts +0 -26
  248. package/dist/types/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.d.ts.map +0 -1
  249. package/dist/types/core/beacon/aggregation/cohort/messages/sign/request-signature.d.ts +0 -26
  250. package/dist/types/core/beacon/aggregation/cohort/messages/sign/request-signature.d.ts.map +0 -1
  251. package/dist/types/core/beacon/aggregation/cohort/messages/sign/signature-authorization.d.ts +0 -27
  252. package/dist/types/core/beacon/aggregation/cohort/messages/sign/signature-authorization.d.ts.map +0 -1
  253. package/dist/types/core/beacon/aggregation/cohort/status.d.ts +0 -8
  254. package/dist/types/core/beacon/aggregation/cohort/status.d.ts.map +0 -1
  255. package/dist/types/core/beacon/aggregation/communication/adapter/did-comm.d.ts +0 -89
  256. package/dist/types/core/beacon/aggregation/communication/adapter/did-comm.d.ts.map +0 -1
  257. package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts +0 -103
  258. package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts.map +0 -1
  259. package/dist/types/core/beacon/aggregation/communication/error.d.ts.map +0 -1
  260. package/dist/types/core/beacon/aggregation/communication/factory.d.ts +0 -10
  261. package/dist/types/core/beacon/aggregation/communication/factory.d.ts.map +0 -1
  262. package/dist/types/core/beacon/aggregation/communication/service.d.ts +0 -36
  263. package/dist/types/core/beacon/aggregation/communication/service.d.ts.map +0 -1
  264. package/dist/types/core/beacon/aggregation/coordinator.d.ts +0 -116
  265. package/dist/types/core/beacon/aggregation/coordinator.d.ts.map +0 -1
  266. package/dist/types/core/beacon/aggregation/participant.d.ts +0 -192
  267. package/dist/types/core/beacon/aggregation/participant.d.ts.map +0 -1
  268. package/dist/types/core/beacon/aggregation/session/index.d.ts +0 -156
  269. package/dist/types/core/beacon/aggregation/session/index.d.ts.map +0 -1
  270. package/dist/types/core/beacon/aggregation/session/status.d.ts +0 -11
  271. package/dist/types/core/beacon/aggregation/session/status.d.ts.map +0 -1
  272. package/dist/types/core/update.d.ts +0 -52
  273. package/dist/types/core/update.d.ts.map +0 -1
  274. package/src/core/beacon/aggregation/cohort/index.ts +0 -305
  275. package/src/core/beacon/aggregation/cohort/messages/constants.ts +0 -12
  276. package/src/core/beacon/aggregation/cohort/messages/index.ts +0 -143
  277. package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.ts +0 -44
  278. package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.ts +0 -40
  279. package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.ts +0 -35
  280. package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in.ts +0 -34
  281. package/src/core/beacon/aggregation/cohort/messages/keygen/subscribe.ts +0 -36
  282. package/src/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.ts +0 -39
  283. package/src/core/beacon/aggregation/cohort/messages/sign/authorization-request.ts +0 -40
  284. package/src/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.ts +0 -40
  285. package/src/core/beacon/aggregation/cohort/messages/sign/request-signature.ts +0 -40
  286. package/src/core/beacon/aggregation/cohort/messages/sign/signature-authorization.ts +0 -41
  287. package/src/core/beacon/aggregation/cohort/status.ts +0 -7
  288. package/src/core/beacon/aggregation/communication/adapter/did-comm.ts +0 -148
  289. package/src/core/beacon/aggregation/communication/adapter/nostr.ts +0 -323
  290. package/src/core/beacon/aggregation/communication/error.ts +0 -13
  291. package/src/core/beacon/aggregation/communication/factory.ts +0 -25
  292. package/src/core/beacon/aggregation/communication/service.ts +0 -42
  293. package/src/core/beacon/aggregation/coordinator.ts +0 -419
  294. package/src/core/beacon/aggregation/participant.ts +0 -517
  295. package/src/core/beacon/aggregation/session/index.ts +0 -301
  296. package/src/core/beacon/aggregation/session/status.ts +0 -18
  297. package/src/core/update.ts +0 -158
@@ -0,0 +1,269 @@
1
+ var _a;
2
+ import { canonicalHash, INVALID_DID_UPDATE, JSONPatch, UpdateError } from '@did-btcr2/common';
3
+ import { SchnorrMultikey } from '@did-btcr2/cryptosuite';
4
+ import { DidDocument } from '../utils/did-document.js';
5
+ import { BeaconFactory } from './beacon/factory.js';
6
+ /**
7
+ * Internal phases of the Updater state machine.
8
+ * @internal
9
+ */
10
+ var UpdaterPhase;
11
+ (function (UpdaterPhase) {
12
+ UpdaterPhase["Construct"] = "Construct";
13
+ UpdaterPhase["Sign"] = "Sign";
14
+ UpdaterPhase["Fund"] = "Fund";
15
+ UpdaterPhase["Broadcast"] = "Broadcast";
16
+ UpdaterPhase["Complete"] = "Complete";
17
+ })(UpdaterPhase || (UpdaterPhase = {}));
18
+ /**
19
+ * Sans-I/O state machine for did:btcr2 updates — the counterpart to {@link Resolver}.
20
+ *
21
+ * Created by {@link DidBtcr2.update} (the factory). The caller drives the update by
22
+ * repeatedly calling {@link advance} and {@link provide}:
23
+ *
24
+ * ```typescript
25
+ * const updater = DidBtcr2.update({ sourceDocument, patches, ... });
26
+ * let state = updater.advance();
27
+ *
28
+ * while(state.status === 'action-required') {
29
+ * for(const need of state.needs) {
30
+ * switch(need.kind) {
31
+ * case 'NeedSigningKey':
32
+ * updater.provide(need, secretKeyBytes);
33
+ * break;
34
+ * case 'NeedFunding':
35
+ * // Check UTXOs at need.beaconAddress, fund if needed
36
+ * updater.provide(need);
37
+ * break;
38
+ * case 'NeedBroadcast':
39
+ * await Updater.announce(need.beaconService, need.signedUpdate, secretKey, bitcoin);
40
+ * updater.provide(need);
41
+ * break;
42
+ * }
43
+ * }
44
+ * state = updater.advance();
45
+ * }
46
+ *
47
+ * const { signedUpdate } = state.result;
48
+ * ```
49
+ *
50
+ * The Updater performs **zero I/O**. All external work (signing with a KMS or raw
51
+ * key, funding checks, Bitcoin transaction construction, broadcast) flows through
52
+ * the advance/provide protocol. This mirrors the {@link Resolver} pattern and makes
53
+ * the update path transport-agnostic and KMS-ready.
54
+ *
55
+ * The class also exposes static utility methods ({@link construct}, {@link sign},
56
+ * {@link announce}) for callers that need direct access to individual update steps
57
+ * outside the state machine (e.g., test vector generation scripts).
58
+ *
59
+ * @class Updater
60
+ */
61
+ export class Updater {
62
+ #phase = UpdaterPhase.Construct;
63
+ #sourceDocument;
64
+ #patches;
65
+ #sourceVersionId;
66
+ #verificationMethod;
67
+ #beaconService;
68
+ #unsignedUpdate = null;
69
+ #signedUpdate = null;
70
+ /**
71
+ * @internal — Use {@link DidBtcr2.update} to create instances.
72
+ */
73
+ constructor(params) {
74
+ this.#sourceDocument = params.sourceDocument;
75
+ this.#patches = params.patches;
76
+ this.#sourceVersionId = params.sourceVersionId;
77
+ this.#verificationMethod = params.verificationMethod;
78
+ this.#beaconService = params.beaconService;
79
+ }
80
+ // ─── Public static utility methods ─────────────────────────────────────────
81
+ // Used by generate-vector.ts and other scripts that need direct access to
82
+ // individual update steps outside the state machine flow.
83
+ /**
84
+ * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/update.html#construct-btcr2-unsigned-update | 7.3.b Construct BTCR2 Unsigned Update}.
85
+ *
86
+ * @param {Btcr2DidDocument} sourceDocument The source DID document to be updated.
87
+ * @param {PatchOperation[]} patches The JSON Patch operations to apply.
88
+ * @param {number} sourceVersionId The version ID of the source document.
89
+ * @returns {UnsignedBTCR2Update} The constructed UnsignedBTCR2Update object.
90
+ * @throws {UpdateError} If the target document fails DID Core validation.
91
+ */
92
+ static construct(sourceDocument, patches, sourceVersionId) {
93
+ const unsignedUpdate = {
94
+ '@context': [
95
+ 'https://w3id.org/security/v2',
96
+ 'https://w3id.org/zcap/v1',
97
+ 'https://w3id.org/json-ld-patch/v1',
98
+ 'https://btcr2.dev/context/v1'
99
+ ],
100
+ patch: patches,
101
+ targetHash: '',
102
+ targetVersionId: sourceVersionId + 1,
103
+ sourceHash: canonicalHash(sourceDocument),
104
+ };
105
+ const targetDocument = JSONPatch.apply(sourceDocument, patches);
106
+ try {
107
+ DidDocument.isValid(targetDocument);
108
+ }
109
+ catch (error) {
110
+ throw new UpdateError('Error validating targetDocument: ' + (error instanceof Error ? error.message : String(error)), INVALID_DID_UPDATE, targetDocument);
111
+ }
112
+ unsignedUpdate.targetHash = canonicalHash(targetDocument);
113
+ return unsignedUpdate;
114
+ }
115
+ /**
116
+ * Implements subsection {@link http://dcdpr.github.io/did-btcr2/operations/update.html#construct-btcr2-signed-update | 7.3.c Construct BTCR2 Signed Update }.
117
+ *
118
+ * @param {string} did The did-btcr2 identifier to derive the root capability from.
119
+ * @param {UnsignedBTCR2Update} unsignedUpdate The unsigned update to sign.
120
+ * @param {DidVerificationMethod} verificationMethod The verification method for signing.
121
+ * @param {KeyBytes} secretKey The secret key bytes.
122
+ * @returns {SignedBTCR2Update} The signed update with a Data Integrity proof.
123
+ */
124
+ static sign(did, unsignedUpdate, verificationMethod, secretKey) {
125
+ const controller = verificationMethod.controller;
126
+ const id = verificationMethod.id.slice(verificationMethod.id.indexOf('#'));
127
+ const multikey = SchnorrMultikey.fromSecretKey(id, controller, secretKey);
128
+ const config = {
129
+ '@context': [
130
+ 'https://w3id.org/security/v2',
131
+ 'https://w3id.org/zcap/v1',
132
+ 'https://w3id.org/json-ld-patch/v1',
133
+ 'https://btcr2.dev/context/v1'
134
+ ],
135
+ cryptosuite: 'bip340-jcs-2025',
136
+ type: 'DataIntegrityProof',
137
+ verificationMethod: verificationMethod.id,
138
+ proofPurpose: 'capabilityInvocation',
139
+ capability: `urn:zcap:root:${encodeURIComponent(did)}`,
140
+ capabilityAction: 'Write',
141
+ };
142
+ const diproof = multikey.toCryptosuite().toDataIntegrityProof();
143
+ return diproof.addProof(unsignedUpdate, config);
144
+ }
145
+ /**
146
+ * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/update.html#announce-did-update | 7.3.d Announce DID Update}.
147
+ * Announces a signed update to the Bitcoin blockchain via the specified beacon.
148
+ *
149
+ * @param {BeaconService} beaconService The beacon service to broadcast through.
150
+ * @param {SignedBTCR2Update} update The signed update to announce.
151
+ * @param {KeyBytes} secretKey The secret key for signing the Bitcoin transaction.
152
+ * @param {BitcoinConnection} bitcoin The Bitcoin network connection.
153
+ * @returns {Promise<SignedBTCR2Update>} The signed update that was broadcast.
154
+ */
155
+ static async announce(beaconService, update, secretKey, bitcoin) {
156
+ const beacon = BeaconFactory.establish(beaconService);
157
+ return beacon.broadcastSignal(update, secretKey, bitcoin);
158
+ }
159
+ // ─── Private instance wrappers ─────────────────────────────────────────────
160
+ // Delegate to the public statics with bound instance fields for cleaner
161
+ // advance/provide code.
162
+ #construct() {
163
+ return _a.construct(this.#sourceDocument, this.#patches, this.#sourceVersionId);
164
+ }
165
+ #sign(secretKey) {
166
+ return _a.sign(this.#sourceDocument.id, this.#unsignedUpdate, this.#verificationMethod, secretKey);
167
+ }
168
+ // ─── State machine ─────────────────────────────────────────────────────────
169
+ /**
170
+ * Advance the state machine. Returns either:
171
+ * - `{ status: 'action-required', needs }` — caller must provide data via {@link provide}
172
+ * - `{ status: 'complete', result }` — update is signed and broadcast
173
+ */
174
+ advance() {
175
+ while (true) {
176
+ switch (this.#phase) {
177
+ // Phase: Construct
178
+ // Build the unsigned update from source doc + patches. Pure, synchronous.
179
+ case UpdaterPhase.Construct: {
180
+ this.#unsignedUpdate = this.#construct();
181
+ this.#phase = UpdaterPhase.Sign;
182
+ continue;
183
+ }
184
+ // Phase: Sign
185
+ // Emit NeedSigningKey — the caller supplies the secret key (or a KMS signature).
186
+ case UpdaterPhase.Sign: {
187
+ return {
188
+ status: 'action-required',
189
+ needs: [{
190
+ kind: 'NeedSigningKey',
191
+ verificationMethodId: this.#verificationMethod.id,
192
+ unsignedUpdate: this.#unsignedUpdate,
193
+ }],
194
+ };
195
+ }
196
+ // Phase: Fund
197
+ // Emit NeedFunding with the beacon address. The caller checks UTXOs,
198
+ // funds the address if needed, and provides to continue.
199
+ case UpdaterPhase.Fund: {
200
+ const beaconAddress = this.#beaconService.serviceEndpoint.replace('bitcoin:', '');
201
+ return {
202
+ status: 'action-required',
203
+ needs: [{
204
+ kind: 'NeedFunding',
205
+ beaconAddress,
206
+ beaconService: this.#beaconService,
207
+ }],
208
+ };
209
+ }
210
+ // Phase: Broadcast
211
+ // Emit NeedBroadcast with the signed update + beacon service. The caller performs
212
+ // the actual on-chain announcement (or hands off to the aggregation protocol).
213
+ case UpdaterPhase.Broadcast: {
214
+ return {
215
+ status: 'action-required',
216
+ needs: [{
217
+ kind: 'NeedBroadcast',
218
+ beaconService: this.#beaconService,
219
+ signedUpdate: this.#signedUpdate,
220
+ }],
221
+ };
222
+ }
223
+ // Phase: Complete
224
+ case UpdaterPhase.Complete: {
225
+ return {
226
+ status: 'complete',
227
+ result: { signedUpdate: this.#signedUpdate },
228
+ };
229
+ }
230
+ }
231
+ }
232
+ }
233
+ provide(need, data) {
234
+ switch (need.kind) {
235
+ case 'NeedSigningKey': {
236
+ if (this.#phase !== UpdaterPhase.Sign) {
237
+ throw new UpdateError(`Cannot provide NeedSigningKey: updater phase is ${this.#phase}, expected Sign.`, INVALID_DID_UPDATE, { phase: this.#phase });
238
+ }
239
+ if (!data) {
240
+ throw new UpdateError('NeedSigningKey requires secret key bytes.', INVALID_DID_UPDATE);
241
+ }
242
+ if (!this.#unsignedUpdate) {
243
+ throw new UpdateError('Internal error: unsigned update missing in Sign phase.', INVALID_DID_UPDATE);
244
+ }
245
+ this.#signedUpdate = this.#sign(data);
246
+ this.#phase = UpdaterPhase.Fund;
247
+ break;
248
+ }
249
+ case 'NeedFunding': {
250
+ if (this.#phase !== UpdaterPhase.Fund) {
251
+ throw new UpdateError(`Cannot provide NeedFunding: updater phase is ${this.#phase}, expected Fund.`, INVALID_DID_UPDATE, { phase: this.#phase });
252
+ }
253
+ // Caller has confirmed funding (or it was already funded). Continue.
254
+ this.#phase = UpdaterPhase.Broadcast;
255
+ break;
256
+ }
257
+ case 'NeedBroadcast': {
258
+ if (this.#phase !== UpdaterPhase.Broadcast) {
259
+ throw new UpdateError(`Cannot provide NeedBroadcast: updater phase is ${this.#phase}, expected Broadcast.`, INVALID_DID_UPDATE, { phase: this.#phase });
260
+ }
261
+ // Caller has broadcast externally. Transition to Complete.
262
+ this.#phase = UpdaterPhase.Complete;
263
+ break;
264
+ }
265
+ }
266
+ }
267
+ }
268
+ _a = Updater;
269
+ //# sourceMappingURL=updater.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updater.js","sourceRoot":"","sources":["../../../src/core/updater.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC9F,OAAO,EAAE,eAAe,EAA8E,MAAM,wBAAwB,CAAC;AACrI,OAAO,EAAE,WAAW,EAAqD,MAAM,0BAA0B,CAAC;AAC1G,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAuEpD;;;GAGG;AACH,IAAK,YAMJ;AAND,WAAK,YAAY;IACf,uCAAuB,CAAA;IACvB,6BAAkB,CAAA;IAClB,6BAAkB,CAAA;IAClB,uCAAuB,CAAA;IACvB,qCAAsB,CAAA;AACxB,CAAC,EANI,YAAY,KAAZ,YAAY,QAMhB;AAcD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,MAAM,OAAO,OAAO;IAClB,MAAM,GAAiB,YAAY,CAAC,SAAS,CAAC;IACrC,eAAe,CAAmB;IAClC,QAAQ,CAAmB;IAC3B,gBAAgB,CAAS;IACzB,mBAAmB,CAAwB;IAC3C,cAAc,CAAgB;IAEvC,eAAe,GAA+B,IAAI,CAAC;IACnD,aAAa,GAA6B,IAAI,CAAC;IAE/C;;OAEG;IACH,YAAY,MAAqB;QAC/B,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,cAAc,CAAC;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AI,CAAC,MAAM,KAAK,YAAY,CAAC,IAAI,EAAE,CAAC;oBACrC,MAAM,IAAI,WAAW,CACnB,gDAAgD,IAAI,CAAC,MAAM,kBAAkB,EAC7E,kBAAkB,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,CAC3C,CAAC;gBACJ,CAAC;gBACD,qEAAqE;gBACrE,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC,SAAS,CAAC;gBACrC,MAAM;YACR,CAAC;YAED,KAAK,eAAe,CAAC,CAAC,CAAC;gBACrB,IAAG,IAAI,CAAC,MAAM,KAAK,YAAY,CAAC,SAAS,EAAE,CAAC;oBAC1C,MAAM,IAAI,WAAW,CACnB,kDAAkD,IAAI,CAAC,MAAM,uBAAuB,EACpF,kBAAkB,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,CAC3C,CAAC;gBACJ,CAAC;gBACD,2DAA2D;gBAC3D,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC,QAAQ,CAAC;gBACpC,MAAM;YACR,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
@@ -1,11 +1,10 @@
1
1
  import { IdentifierHrp, INVALID_DID_DOCUMENT, INVALID_DID_UPDATE, METHOD_NOT_SUPPORTED, MethodError, UpdateError } from '@did-btcr2/common';
2
2
  import { Did, DidError, DidErrorCode } from '@web5/dids';
3
3
  import * as ecc from '@bitcoinerlab/secp256k1';
4
- import { hexToBytes } from '@noble/hashes/utils';
5
4
  import { initEccLib } from 'bitcoinjs-lib';
6
5
  import { Identifier } from './core/identifier.js';
7
6
  import { Resolver } from './core/resolver.js';
8
- import { Update } from './core/update.js';
7
+ import { Updater } from './core/updater.js';
9
8
  import { Appendix } from './utils/appendix.js';
10
9
  /** Initialize secp256k1 ECC library */
11
10
  initEccLib(ecc);
@@ -92,34 +91,29 @@ export class DidBtcr2 {
92
91
  });
93
92
  }
94
93
  /**
95
- * Entry point for section {@link https://dcdpr.github.io/did-btcr2/#read | 7.3 Update}.
96
- * See specification for the {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#process | Resolve Process}.
97
- * See {@link Update | Update (class)} for class implementation.
94
+ * Entry point for section {@link https://dcdpr.github.io/did-btcr2/#update | 7.3 Update}.
98
95
  *
99
- * BTCR2 DID documents can be updated by anchoring BTCR2 Updates to Bitcoin transactions. These transactions MAY be
100
- * published to the Bitcoin network. Any property in the DID document may be updated except the id. Doing so would
101
- * invalidate the DID document.
102
- * @param params An object containing the parameters for the update operation.
96
+ * Factory method that validates the update parameters and returns a sans-I/O
97
+ * {@link Updater} state machine. The caller drives the updater through its
98
+ * phases (Construct Sign → Broadcast → Complete) by calling `advance()` and
99
+ * `provide()`. The method package performs **zero I/O** signing key retrieval
100
+ * (or KMS delegation) and the on-chain broadcast are the caller's responsibility.
101
+ *
102
+ * For a fully-wired version with Bitcoin broadcast and key handling, see
103
+ * `DidMethodApi.update()` in `@did-btcr2/api`.
104
+ *
105
+ * @param params Update construction parameters.
103
106
  * @param {Btcr2DidDocument} params.sourceDocument The DID document being updated.
104
- * @param {PatchOperation[]} params.patches The array of JSON Patch operations to apply to the sourceDocument.
105
- * @param {string} params.sourceVersionId The version ID before applying the update.
106
- * @param {string} params.verificationMethodId The verificationMethod ID to sign the update with.
107
- * @param {string} params.beaconId The beacon ID associated with the update.
108
- * @param {KeyBytes | HexString} [params.signingMaterial] Optional signing material (key bytes or hex string).
109
- * @param {BitcoinConnection} [params.bitcoin] Optional Bitcoin network connection for announcing the update. If not provided, a default connection will be initialized.
110
- * @return {Promise<SignedBTCR2Update>} Promise resolving to the signed BTCR2 update.
111
- * @throws {UpdateError} if no verificationMethod, verificationMethod type is not `Multikey` or the publicKeyMultibase
112
- * header is not `zQ3s`
107
+ * @param {PatchOperation[]} params.patches The JSON Patch operations to apply.
108
+ * @param {number} params.sourceVersionId The version ID before applying the update.
109
+ * @param {string} params.verificationMethodId The verification method ID to sign with.
110
+ * @param {string} params.beaconId The beacon service ID to broadcast through.
111
+ * @returns {Updater} A sans-I/O state machine for driving the update.
112
+ * @throws {UpdateError} If the verification method is not authorized, not found,
113
+ * not of type `Multikey`, or does not have a `zQ3s` publicKeyMultibase prefix.
114
+ * Also throws if the beacon service is not found.
113
115
  */
114
- static async update({ sourceDocument, patches, sourceVersionId, verificationMethodId, beaconId, signingMaterial, bitcoin, }) {
115
- // If no signingMaterial provided, throw an UpdateError with INVALID_DID_UPDATE.
116
- if (!signingMaterial) {
117
- throw new UpdateError('Missing signing material for update', INVALID_DID_UPDATE, { signingMaterial });
118
- }
119
- // Convert signingMaterial to bytes if it's a hex string
120
- const secretKey = typeof signingMaterial === 'string'
121
- ? hexToBytes(signingMaterial)
122
- : signingMaterial;
116
+ static update({ sourceDocument, patches, sourceVersionId, verificationMethodId, beaconId, }) {
123
117
  // Validate that the verificationMethodId is authorized for capabilityInvocation
124
118
  if (!sourceDocument.capabilityInvocation?.some(vr => vr === verificationMethodId)) {
125
119
  throw new UpdateError('Invalid verificationMethodId: not authorized for capabilityInvocation', INVALID_DID_DOCUMENT, sourceDocument);
@@ -138,28 +132,22 @@ export class DidBtcr2 {
138
132
  if (verificationMethod.publicKeyMultibase?.slice(0, 4) !== 'zQ3s') {
139
133
  throw new UpdateError('Invalid verificationMethodId: publicKeyMultibase prefix must start with "zQ3s"', INVALID_DID_DOCUMENT, verificationMethod);
140
134
  }
141
- // Construct an unsigned update following the BTCR2 Update construction algorithm
142
- const update = Update.construct(sourceDocument, patches, sourceVersionId);
143
- // Sign the unsigned update using the specified verification method
144
- const signed = Update.sign(sourceDocument.id, update, verificationMethod, secretKey);
145
- // Filter sourceDocument services to get beaconServices matching beaconIds
135
+ // Find the beacon service matching the given beaconId
146
136
  const beaconService = sourceDocument.service
147
137
  .filter((service) => service.id === beaconId)
148
138
  .filter((service) => !!service)
149
139
  .shift();
150
- // If no matching beacon service found, throw an UpdateError with INVALID_DID_UPDATE.
151
140
  if (!beaconService) {
152
141
  throw new UpdateError('No beacon service found for provided beaconId', INVALID_DID_UPDATE, { sourceDocument, beaconId });
153
142
  }
154
- // Require an explicit bitcoin connection no silent env-var fallback
155
- if (!bitcoin) {
156
- throw new UpdateError('Bitcoin connection required for update. Pass a configured `bitcoin` parameter '
157
- + 'or use DidBtcr2Api which injects it automatically.', INVALID_DID_UPDATE, { beaconId });
158
- }
159
- // Announce the signed update to the blockchain using the specified beacon(s)
160
- await Update.announce(beaconService, signed, secretKey, bitcoin);
161
- // Return signed update if announced successfully
162
- return signed;
143
+ // Return a sans-I/O state machine the caller will drive
144
+ return new Updater({
145
+ sourceDocument,
146
+ patches,
147
+ sourceVersionId,
148
+ verificationMethod,
149
+ beaconService,
150
+ });
163
151
  }
164
152
  /**
165
153
  * Given the W3C DID Document of a `did:btcr2` identifier, return the signing verification method that will be used
@@ -1 +1 @@
1
- {"version":3,"file":"did-btcr2.js","sourceRoot":"","sources":["../../src/did-btcr2.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,WAAW,EACX,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EACL,GAAG,EACH,QAAQ,EACR,YAAY,EACb,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,GAAG,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAY/C,uCAAuC;AACvC,UAAU,CAAC,GAAG,CAAC,CAAC;AAEhB;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,QAAQ;IACnB;;OAEG;IACH,MAAM,CA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C,CAAC,CAAC,CACpE,CAAC;QAEF,qDAAqD;QACrD,IAAI,CAAC,CAAC,kBAAkB,IAAI,kBAAkB,CAAC,kBAAkB,CAAC,EAAE,CAAC;YACnE,MAAM,IAAI,QAAQ,CAChB,YAAY,CAAC,aAAa,EAC1B,0FAA0F,CAC3F,CAAC;QACJ,CAAC;QACD,OAAO,kBAA2C,CAAC;IACrD,CAAC"}
package/dist/esm/index.js CHANGED
@@ -1,43 +1,34 @@
1
- export * from './core/beacon/aggregation/cohort/index.js';
2
- export * from './core/beacon/aggregation/cohort/status.js';
3
- export * from './core/beacon/aggregation/cohort/messages/base.js';
4
- export * from './core/beacon/aggregation/cohort/messages/constants.js';
5
- export * from './core/beacon/aggregation/cohort/messages/index.js';
6
- export * from './core/beacon/aggregation/cohort/messages/keygen//subscribe.js';
7
- export * from './core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js';
8
- export * from './core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js';
9
- export * from './core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js';
10
- export * from './core/beacon/aggregation/cohort/messages/keygen/opt-in.js';
11
- export * from './core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js';
12
- export * from './core/beacon/aggregation/cohort/messages/sign/authorization-request.js';
13
- export * from './core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js';
14
- export * from './core/beacon/aggregation/cohort/messages/sign/request-signature.js';
15
- export * from './core/beacon/aggregation/cohort/messages/sign/signature-authorization.js';
16
- export * from './core/beacon/aggregation/communication/adapter/did-comm.js';
17
- export * from './core/beacon/aggregation/communication/adapter/nostr.js';
18
- export * from './core/beacon/aggregation/communication/error.js';
19
- export * from './core/beacon/aggregation/communication/factory.js';
20
- export * from './core/beacon/aggregation/communication/service.js';
21
- export * from './core/beacon/aggregation/coordinator.js';
22
- export * from './core/beacon/aggregation/participant.js';
23
- export * from './core/beacon/aggregation/session/index.js';
24
- export * from './core/beacon/aggregation/session/status.js';
1
+ // Aggregation
2
+ export * from './core/aggregation/service.js';
3
+ export * from './core/aggregation/participant.js';
4
+ export * from './core/aggregation/cohort.js';
5
+ export * from './core/aggregation/signing-session.js';
6
+ export * from './core/aggregation/phases.js';
7
+ export * from './core/aggregation/errors.js';
8
+ export * from './core/aggregation/messages/index.js';
9
+ export * from './core/aggregation/transport/index.js';
10
+ export * from './core/aggregation/runner/index.js';
11
+ // Beacons
25
12
  export * from './core/beacon/beacon.js';
26
13
  export * from './core/beacon/cas-beacon.js';
27
14
  export * from './core/beacon/error.js';
28
15
  export * from './core/beacon/factory.js';
16
+ export * from './core/beacon/fee-estimator.js';
29
17
  export * from './core/beacon/interfaces.js';
30
18
  export * from './core/beacon/signal-discovery.js';
31
19
  export * from './core/beacon/singleton-beacon.js';
32
20
  export * from './core/beacon/smt-beacon.js';
33
21
  export * from './core/beacon/utils.js';
22
+ // Core
34
23
  export * from './core/identifier.js';
35
24
  export * from './core/interfaces.js';
36
25
  export * from './core/resolver.js';
37
26
  export * from './core/types.js';
38
- export * from './core/update.js';
27
+ export * from './core/updater.js';
28
+ // Utils
39
29
  export * from './utils/appendix.js';
40
30
  export * from './utils/did-document-builder.js';
41
31
  export * from './utils/did-document.js';
32
+ // Facade
42
33
  export * from './did-btcr2.js';
43
34
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2CAA2C,CAAC;AAC1D,cAAc,4CAA4C,CAAC;AAE3D,cAAc,mDAAmD,CAAC;AAClE,cAAc,wDAAwD,CAAC;AACvE,cAAc,oDAAoD,CAAC;AACnE,cAAc,gEAAgE,CAAC;AAC/E,cAAc,mEAAmE,CAAC;AAClF,cAAc,kEAAkE,CAAC;AACjF,cAAc,mEAAmE,CAAC;AAClF,cAAc,4DAA4D,CAAC;AAC3E,cAAc,oEAAoE,CAAC;AACnF,cAAc,yEAAyE,CAAC;AACxF,cAAc,sEAAsE,CAAC;AACrF,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,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AAEvC,OAAO;AACP,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAElC,QAAQ;AACR,cAAc,qBAAqB,CAAC;AACpC,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC;AAExC,SAAS;AACT,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,94 @@
1
+ import type { SignedBTCR2Update } from '@did-btcr2/cryptosuite';
2
+ import type { SerializedSMTProof } from '@did-btcr2/smt';
3
+ import type { CASAnnouncement } from '../types.js';
4
+ export type AggregationCohortParams = {
5
+ id?: string;
6
+ serviceDid?: string;
7
+ minParticipants?: number;
8
+ network: string;
9
+ beaconType?: string;
10
+ };
11
+ /**
12
+ * Represents an Aggregation Cohort — a set of Aggregation Participants who
13
+ * submitted cryptographic material to an Aggregation Service to coordinate
14
+ * signing of a shared n-of-n MuSig2 Bitcoin transaction.
15
+ *
16
+ * This is a pure data class — it holds cohort state and provides computation
17
+ * helpers (key aggregation, CAS Announcement building, SMT tree building).
18
+ * It performs no I/O and emits no messages. Both AggregationService and
19
+ * AggregationParticipant create their own AggregationCohort instances to
20
+ * track their respective views of the cohort state.
21
+ *
22
+ * @class AggregationCohort
23
+ */
24
+ export declare class AggregationCohort {
25
+ #private;
26
+ /** Unique identifier for the cohort. */
27
+ id: string;
28
+ /** DID of the Aggregation Service managing this cohort. */
29
+ serviceDid: string;
30
+ /** Minimum number of participants required to finalize the cohort. */
31
+ minParticipants: number;
32
+ /** Network on which the cohort operates (mainnet, mutinynet, etc.). */
33
+ network: string;
34
+ /** Type of beacon used in the cohort: 'CASBeacon' or 'SMTBeacon'. */
35
+ beaconType: string;
36
+ /** List of participant DIDs that have been accepted into the cohort. */
37
+ participants: Array<string>;
38
+ /** Taproot tweak (BIP-341 key-path-only). */
39
+ trMerkleRoot: Uint8Array;
40
+ /** The n-of-n MuSig2 Taproot beacon address. */
41
+ beaconAddress: string;
42
+ /** Pending DID updates submitted by participants, keyed by DID. */
43
+ pendingUpdates: Map<string, SignedBTCR2Update>;
44
+ /** CAS Beacon Announcement Map (DID → updateHash), set by buildCASAnnouncement(). */
45
+ casAnnouncement?: CASAnnouncement;
46
+ /** Per-participant SMT proofs, set by buildSMTTree(). */
47
+ smtProofs?: Map<string, SerializedSMTProof>;
48
+ /** Signal bytes (32 bytes) for OP_RETURN: SHA-256 of CAS announcement OR SMT root. */
49
+ signalBytes?: Uint8Array;
50
+ /** Set of participant DIDs that have approved the aggregated data. */
51
+ validationAcks: Set<string>;
52
+ /** Set of participant DIDs that have rejected the aggregated data. */
53
+ validationRejections: Set<string>;
54
+ constructor({ id, minParticipants, serviceDid, network, beaconType }: AggregationCohortParams);
55
+ /** Sorted cohort keys (sorted on assignment per BIP-327). */
56
+ get cohortKeys(): Array<Uint8Array>;
57
+ set cohortKeys(keys: Array<Uint8Array>);
58
+ /**
59
+ * Computes the n-of-n MuSig2 Taproot beacon address from cohort keys.
60
+ * Sets `trMerkleRoot` to the BIP-341 key-path-only tweak.
61
+ */
62
+ computeBeaconAddress(): string;
63
+ /**
64
+ * Validates that the participant's key is in the cohort and the beacon address
65
+ * matches the locally-computed one. Used by participants to verify cohort ready
66
+ * messages from the service.
67
+ */
68
+ validateMembership(participantPkHex: string, cohortKeysHex: Array<string>, expectedBeaconAddress: string): void;
69
+ addUpdate(participantDid: string, signedUpdate: SignedBTCR2Update): void;
70
+ hasAllUpdates(): boolean;
71
+ /**
72
+ * Builds a CAS Announcement Map from collected updates.
73
+ * Maps each participant DID → base64url canonical hash of their signed update.
74
+ * Computes signal bytes as SHA-256 of canonicalized announcement.
75
+ */
76
+ buildCASAnnouncement(): CASAnnouncement;
77
+ /**
78
+ * Builds an SMT tree from collected updates.
79
+ * Each entry uses a random 32-byte nonce + canonicalized signed update bytes.
80
+ * Stores per-participant proofs and the SMT root as signalBytes.
81
+ */
82
+ buildSMTTree(): Map<string, SerializedSMTProof>;
83
+ addValidation(participantDid: string, approved: boolean): void;
84
+ /**
85
+ * True when every participant has either approved or rejected the aggregated data.
86
+ */
87
+ hasAllValidationResponses(): boolean;
88
+ /**
89
+ * True when all participants approved. Note: differs from {@link hasAllValidationResponses} —
90
+ * this returns false if any participant rejected, even if all responses are in.
91
+ */
92
+ isFullyValidated(): boolean;
93
+ }
94
+ //# sourceMappingURL=cohort.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cohort.d.ts","sourceRoot":"","sources":["../../../../src/core/aggregation/cohort.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAa,MAAM,gBAAgB,CAAC;AAKpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGnD,MAAM,MAAM,uBAAuB,GAAG;IACpC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,qBAAa,iBAAiB;;IAC5B,wCAAwC;IACxC,EAAE,EAAE,MAAM,CAAC;IAEX,2DAA2D;IAC3D,UAAU,EAAE,MAAM,CAAC;IAEnB,sEAAsE;IACtE,eAAe,EAAE,MAAM,CAAC;IAExB,uEAAuE;IACvE,OAAO,EAAE,MAAM,CAAC;IAEhB,qEAAqE;IACrE,UAAU,EAAE,MAAM,CAAC;IAEnB,wEAAwE;IACxE,YAAY,EAAE,KAAK,CAAC,MAAM,CA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;IAI3C;;;OAGG;IACI,gBAAgB,IAAI,OAAO;CAInC"}
@@ -0,0 +1,14 @@
1
+ import { MethodError } from '@did-btcr2/common';
2
+ export declare class AggregationServiceError extends MethodError {
3
+ constructor(message: string, type?: string, data?: Record<string, any>);
4
+ }
5
+ export declare class AggregationParticipantError extends MethodError {
6
+ constructor(message: string, type?: string, data?: Record<string, any>);
7
+ }
8
+ export declare class AggregationCohortError extends MethodError {
9
+ constructor(message: string, type?: string, data?: Record<string, any>);
10
+ }
11
+ export declare class SigningSessionError extends MethodError {
12
+ constructor(message: string, type?: string, data?: Record<string, any>);
13
+ }
14
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../src/core/aggregation/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,qBAAa,uBAAwB,SAAQ,WAAW;gBAC1C,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAAkC,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAGlG;AAED,qBAAa,2BAA4B,SAAQ,WAAW;gBAC9C,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAAsC,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAGtG;AAED,qBAAa,sBAAuB,SAAQ,WAAW;gBACzC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAAiC,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAGjG;AAED,qBAAa,mBAAoB,SAAQ,WAAW;gBACtC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAA8B,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAG9F"}
@@ -1,4 +1,3 @@
1
- export declare const MESSAGE_PREFIX = "https://btcr2.tools/";
2
1
  export type BaseBody = {
3
2
  cohortId: string;
4
3
  cohortSize?: number;
@@ -11,8 +10,15 @@ export type BaseBody = {
11
10
  nonceContribution?: Uint8Array;
12
11
  partialSignature?: Uint8Array;
13
12
  pendingTx?: string;
13
+ prevOutValue?: string;
14
+ communicationPk?: Uint8Array;
14
15
  beaconType?: string;
15
16
  data?: string;
17
+ signedUpdate?: Record<string, unknown>;
18
+ casAnnouncement?: Record<string, string>;
19
+ smtProof?: Record<string, unknown>;
20
+ signalBytesHex?: string;
21
+ approved?: boolean;
16
22
  };
17
23
  export type Base = {
18
24
  type: string;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../../src/core/aggregation/messages/base.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,UAAU,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,UAAU,CAAC;IAC7B,iBAAiB,CAAC,EAAE,UAAU,CAAC;IAC/B,gBAAgB,CAAC,EAAE,UAAU,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,UAAU,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,QAAQ,CAAC,EAAE,MAAM,CA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