@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,32 @@
1
+ import { NotImplementedError } from '@did-btcr2/common';
2
+ /**
3
+ * DIDComm Transport (stub).
4
+ *
5
+ * @class DidCommTransport
6
+ * @implements {Transport}
7
+ */
8
+ export class DidCommTransport {
9
+ name = 'didcomm';
10
+ start() {
11
+ throw new NotImplementedError('DidCommTransport not implemented. Use NostrTransport instead.');
12
+ }
13
+ registerActor(_did, _keys) {
14
+ throw new NotImplementedError('DidCommTransport not implemented.');
15
+ }
16
+ getActorPk(_did) {
17
+ throw new NotImplementedError('DidCommTransport not implemented.');
18
+ }
19
+ registerPeer(_did, _communicationPk) {
20
+ throw new NotImplementedError('DidCommTransport not implemented.');
21
+ }
22
+ getPeerPk(_did) {
23
+ throw new NotImplementedError('DidCommTransport not implemented.');
24
+ }
25
+ registerMessageHandler(_actorDid, _messageType, _handler) {
26
+ throw new NotImplementedError('DidCommTransport not implemented.');
27
+ }
28
+ async sendMessage(_message, _sender, _recipient) {
29
+ throw new NotImplementedError('DidCommTransport not implemented.');
30
+ }
31
+ }
32
+ //# sourceMappingURL=didcomm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"didcomm.js","sourceRoot":"","sources":["../../../../../src/core/aggregation/transport/didcomm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAKxD;;;;;GAKG;AACH,MAAM,OAAO,gBAAgB;IACpB,IAAI,GAAW,SAAS,CAAC;IAEzB,KAAK;QACV,MAAM,IAAI,mBAAmB,CAAC,+DAA+D,CAAC,CAAC;IACjG,CAAC;IAEM,aAAa,CAAC,IAAY,EAAE,KAAqB;QACtD,MAAM,IAAI,mBAAmB,CAAC,mCAAmC,CAAC,CAAC;IACrE,CAAC;IAEM,UAAU,CAAC,IAAY;QAC5B,MAAM,IAAI,mBAAmB,CAAC,mCAAmC,CAAC,CAAC;IACrE,CAAC;IAEM,YAAY,CAAC,IAAY,EAAE,gBAA4B;QAC5D,MAAM,IAAI,mBAAmB,CAAC,mCAAmC,CAAC,CAAC;IACrE,CAAC;IAEM,SAAS,CAAC,IAAY;QAC3B,MAAM,IAAI,mBAAmB,CAAC,mCAAmC,CAAC,CAAC;IACrE,CAAC;IAEM,sBAAsB,CAAC,SAAiB,EAAE,YAAoB,EAAE,QAAwB;QAC7F,MAAM,IAAI,mBAAmB,CAAC,mCAAmC,CAAC,CAAC;IACrE,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,QAAqB,EAAE,OAAe,EAAE,UAAmB;QAClF,MAAM,IAAI,mBAAmB,CAAC,mCAAmC,CAAC,CAAC;IACrE,CAAC;CACF"}
@@ -0,0 +1,12 @@
1
+ import { MethodError } from '@did-btcr2/common';
2
+ export class TransportError extends MethodError {
3
+ constructor(message, type = 'TransportError', data) {
4
+ super(message, type, data);
5
+ }
6
+ }
7
+ export class TransportAdapterError extends MethodError {
8
+ constructor(message, type = 'TransportAdapterError', data) {
9
+ super(message, type, data);
10
+ }
11
+ }
12
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../../../../../src/core/aggregation/transport/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,OAAO,cAAe,SAAQ,WAAW;IAC7C,YAAY,OAAe,EAAE,OAAe,gBAAgB,EAAE,IAA0B;QACtF,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF;AAED,MAAM,OAAO,qBAAsB,SAAQ,WAAW;IACpD,YAAY,OAAe,EAAE,OAAe,uBAAuB,EAAE,IAA0B;QAC7F,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF"}
@@ -0,0 +1,20 @@
1
+ import { NotImplementedError } from '@did-btcr2/common';
2
+ import { NostrTransport } from './nostr.js';
3
+ import { TransportError } from './error.js';
4
+ /**
5
+ * Factory for creating Transport instances.
6
+ * @class TransportFactory
7
+ */
8
+ export class TransportFactory {
9
+ static establish(config) {
10
+ switch (config.type) {
11
+ case 'nostr':
12
+ return new NostrTransport({ relays: config.relays });
13
+ case 'didcomm':
14
+ throw new NotImplementedError('DIDComm transport not implemented yet.');
15
+ default:
16
+ throw new TransportError(`Invalid transport type: ${config.type}`, 'INVALID_TRANSPORT_TYPE', { config });
17
+ }
18
+ }
19
+ }
20
+ //# sourceMappingURL=factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../../../src/core/aggregation/transport/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAQ5C;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IAC3B,MAAM,CAAC,SAAS,CAAC,MAAuB;QACtC,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;YACpB,KAAK,OAAO;gBACV,OAAO,IAAI,cAAc,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;YACvD,KAAK,SAAS;gBACZ,MAAM,IAAI,mBAAmB,CAAC,wCAAwC,CAAC,CAAC;YAC1E;gBACE,MAAM,IAAI,cAAc,CACtB,2BAA2B,MAAM,CAAC,IAAI,EAAE,EACxC,wBAAwB,EAAE,EAAE,MAAM,EAAE,CACrC,CAAC;QACN,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,6 @@
1
+ export * from './transport.js';
2
+ export * from './error.js';
3
+ export * from './factory.js';
4
+ export * from './nostr.js';
5
+ export * from './didcomm.js';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/aggregation/transport/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
@@ -0,0 +1,262 @@
1
+ var _a;
2
+ import { CompressedSecp256k1PublicKey } from '@did-btcr2/keypair';
3
+ import { bytesToHex, hexToBytes } from '@noble/hashes/utils';
4
+ import { finalizeEvent, nip44 } from 'nostr-tools';
5
+ import { SimplePool } from 'nostr-tools/pool';
6
+ import { COHORT_ADVERT } from '../messages/constants.js';
7
+ import { isAggregationMessageType, isKeygenMessageType, isSignMessageType, isUpdateMessageType } from '../messages/guards.js';
8
+ import { TransportAdapterError } from './error.js';
9
+ /**
10
+ * Default Nostr relay URLs.
11
+ * @constant {Array<string>} DEFAULT_NOSTR_RELAYS
12
+ */
13
+ export const DEFAULT_NOSTR_RELAYS = [
14
+ 'wss://relay.damus.io',
15
+ 'wss://nos.lol',
16
+ 'wss://relay.snort.social',
17
+ 'wss://nostr-pub.wellorder.net',
18
+ ];
19
+ /**
20
+ * Nostr Transport for did:btcr2 aggregation messages.
21
+ *
22
+ * A single NostrTransport manages one relay pool and supports multiple
23
+ * registered actors. Each actor registers its own DID and keys via
24
+ * {@link registerActor}; the transport resolves the correct identity when
25
+ * sending or receiving.
26
+ *
27
+ * Message routing:
28
+ * - Keygen messages (COHORT_ADVERT, COHORT_OPT_IN, COHORT_OPT_IN_ACCEPT, COHORT_READY) → kind 1 (plaintext)
29
+ * - Update messages (SUBMIT_UPDATE, DISTRIBUTE_AGGREGATED_DATA, VALIDATION_ACK) → kind 1059 (NIP-44 encrypted)
30
+ * - Sign messages → kind 1059 (NIP-44 encrypted)
31
+ *
32
+ * @class NostrTransport
33
+ * @implements {Transport}
34
+ */
35
+ export class NostrTransport {
36
+ name = 'nostr';
37
+ pool;
38
+ #relays;
39
+ #actors = new Map();
40
+ #peerRegistry = new Map();
41
+ #started = false;
42
+ constructor(config) {
43
+ this.#relays = config?.relays ?? DEFAULT_NOSTR_RELAYS;
44
+ }
45
+ /**
46
+ * Registers an actor (DID + keys) to send/receive messages with.
47
+ * Must be called before start() to ensure subscriptions are created for the actor.
48
+ * @param {string} did - The DID of the actor.
49
+ * @param {SchnorrKeyPair} keys - The Schnorr key pair for the actor.
50
+ * @throws {TransportAdapterError} If the actor is already registered or if the transport has already started.
51
+ * @example
52
+ * const transport = new NostrTransport();
53
+ * const keys = SchnorrKeyPair.generate();
54
+ * transport.registerActor('did:btcr2:...', keys);
55
+ * transport.start();
56
+ */
57
+ registerActor(did, keys) {
58
+ const entry = { keys, handlers: new Map() };
59
+ this.#actors.set(did, entry);
60
+ // If already started, create a directed subscription for this actor
61
+ if (this.#started && this.pool) {
62
+ this.#subscribeDirected(did, entry);
63
+ }
64
+ }
65
+ getActorPk(did) {
66
+ return this.#actors.get(did)?.keys.publicKey.compressed;
67
+ }
68
+ registerPeer(did, communicationPk) {
69
+ try {
70
+ new CompressedSecp256k1PublicKey(communicationPk);
71
+ }
72
+ catch {
73
+ throw new TransportAdapterError(`Invalid communication public key for peer ${did}: expected a 33-byte compressed secp256k1 key.`, 'INVALID_PEER_KEY', { adapter: this.name, did, keyLength: communicationPk.length });
74
+ }
75
+ this.#peerRegistry.set(did, communicationPk);
76
+ }
77
+ getPeerPk(did) {
78
+ return this.#peerRegistry.get(did);
79
+ }
80
+ registerMessageHandler(actorDid, messageType, handler) {
81
+ const actor = this.#actors.get(actorDid);
82
+ if (!actor) {
83
+ throw new TransportAdapterError(`Cannot register handler: actor ${actorDid} not registered. Call registerActor() first.`, 'UNKNOWN_ACTOR_ERROR', { adapter: this.name, did: actorDid });
84
+ }
85
+ actor.handlers.set(messageType, handler);
86
+ }
87
+ start() {
88
+ if (this.#started)
89
+ return this;
90
+ this.#started = true;
91
+ this.pool = new SimplePool();
92
+ const since = Math.floor(Date.now() / 1000);
93
+ // Broadcast subscription: kind 1 COHORT_ADVERT events (all actors receive these)
94
+ this.pool.subscribeMany(this.#relays, { kinds: [1], '#t': [COHORT_ADVERT], since }, {
95
+ onclose: (reasons) => console.debug('Nostr broadcast subscription closed', reasons),
96
+ onevent: this.#handleBroadcastEvent.bind(this),
97
+ });
98
+ // Directed subscriptions for any actors already registered
99
+ for (const [did, entry] of this.#actors) {
100
+ this.#subscribeDirected(did, entry);
101
+ }
102
+ console.info(`NostrTransport started, listening on ${this.#relays.length} relay(s)`);
103
+ return this;
104
+ }
105
+ async sendMessage(message, sender, to) {
106
+ const type = message.type;
107
+ if (!type) {
108
+ throw new TransportAdapterError('Message type is undefined', 'SEND_MESSAGE_ERROR', { adapter: this.name, type });
109
+ }
110
+ const actor = this.#actors.get(sender);
111
+ if (!actor) {
112
+ throw new TransportAdapterError(`Unknown sender: ${sender}. Call registerActor() before sending messages.`, 'UNKNOWN_ACTOR_ERROR', { adapter: this.name, did: sender });
113
+ }
114
+ const senderKeys = actor.keys;
115
+ // Sender p-tag matches the event signing key
116
+ const tags = [
117
+ ['p', bytesToHex(senderKeys.publicKey.x)],
118
+ ['t', type],
119
+ ];
120
+ if (to) {
121
+ const recipientPkBytes = this.#peerRegistry.get(to);
122
+ if (recipientPkBytes) {
123
+ const recipientPk = new CompressedSecp256k1PublicKey(recipientPkBytes);
124
+ tags.push(['p', bytesToHex(recipientPk.x)]);
125
+ }
126
+ }
127
+ // Keygen messages: plaintext, kind 1
128
+ if (isKeygenMessageType(type)) {
129
+ const event = finalizeEvent({
130
+ kind: 1,
131
+ created_at: Math.floor(Date.now() / 1000),
132
+ tags,
133
+ content: JSON.stringify(message, _a.#jsonReplacer),
134
+ }, senderKeys.secretKey.bytes);
135
+ console.debug(`Publishing kind 1 [${type}]`);
136
+ await this.#publishToRelays(event);
137
+ return;
138
+ }
139
+ // Update and sign messages: NIP-44 encrypted, kind 1059
140
+ if (isUpdateMessageType(type) || isSignMessageType(type)) {
141
+ if (!to) {
142
+ throw new TransportAdapterError(`Encrypted messages require a recipient DID, got undefined for type: ${type}`, 'SEND_MESSAGE_ERROR', { adapter: this.name });
143
+ }
144
+ const recipientPkBytes = this.#peerRegistry.get(to);
145
+ if (!recipientPkBytes) {
146
+ throw new TransportAdapterError(`Unknown peer DID: ${to}. Register peer via registerPeer() before sending encrypted messages.`, 'UNKNOWN_PEER_ERROR', { adapter: this.name, did: to });
147
+ }
148
+ const recipientPk = new CompressedSecp256k1PublicKey(recipientPkBytes);
149
+ const conversationKey = nip44.v2.utils.getConversationKey(senderKeys.secretKey.bytes, bytesToHex(recipientPk.x));
150
+ const content = nip44.v2.encrypt(JSON.stringify(message, _a.#jsonReplacer), conversationKey);
151
+ const event = finalizeEvent({
152
+ kind: 1059,
153
+ created_at: Math.floor(Date.now() / 1000),
154
+ tags,
155
+ content,
156
+ }, senderKeys.secretKey.bytes);
157
+ console.debug(`Publishing kind 1059 [${type}]`);
158
+ await this.#publishToRelays(event);
159
+ return;
160
+ }
161
+ console.warn(`Unsupported message type: ${type}`);
162
+ }
163
+ #subscribeDirected(did, entry) {
164
+ if (!this.pool)
165
+ return;
166
+ const pkHex = bytesToHex(entry.keys.publicKey.x);
167
+ const since = Math.floor(Date.now() / 1000);
168
+ this.pool.subscribeMany(this.#relays, { kinds: [1, 1059], '#p': [pkHex], since }, {
169
+ onclose: (reasons) => console.debug(`Nostr directed subscription closed for ${did}`, reasons),
170
+ onevent: this.#makeActorEventHandler(did),
171
+ });
172
+ }
173
+ #makeActorEventHandler(actorDid) {
174
+ return async (event) => {
175
+ const actor = this.#actors.get(actorDid);
176
+ if (!actor)
177
+ return;
178
+ let message;
179
+ try {
180
+ if (event.kind === 1) {
181
+ message = JSON.parse(event.content, _a.#jsonReviver);
182
+ }
183
+ else if (event.kind === 1059) {
184
+ const conversationKey = nip44.v2.utils.getConversationKey(actor.keys.secretKey.bytes, event.pubkey);
185
+ const plaintext = nip44.v2.decrypt(event.content, conversationKey);
186
+ message = JSON.parse(plaintext, _a.#jsonReviver);
187
+ }
188
+ else {
189
+ return;
190
+ }
191
+ }
192
+ catch (err) {
193
+ console.debug(`Failed to parse event ${event.id} for ${actorDid}:`, err);
194
+ return;
195
+ }
196
+ this.#dispatchMessage(message, actor);
197
+ };
198
+ }
199
+ async #handleBroadcastEvent(event) {
200
+ if (event.kind !== 1)
201
+ return;
202
+ let message;
203
+ try {
204
+ message = JSON.parse(event.content, _a.#jsonReviver);
205
+ }
206
+ catch (err) {
207
+ console.debug(`Failed to parse broadcast event ${event.id}:`, err);
208
+ return;
209
+ }
210
+ if (message.body && typeof message.body === 'object') {
211
+ message = { ...message, ...message.body };
212
+ }
213
+ const messageType = message.type;
214
+ if (!messageType || !isAggregationMessageType(messageType))
215
+ return;
216
+ // Dispatch to ALL actors that have a handler for this message type
217
+ for (const actor of this.#actors.values()) {
218
+ const handler = actor.handlers.get(messageType);
219
+ if (handler)
220
+ await handler(message);
221
+ }
222
+ }
223
+ #dispatchMessage(message, actor) {
224
+ if (message.body && typeof message.body === 'object') {
225
+ message = { ...message, ...message.body };
226
+ }
227
+ const messageType = message.type;
228
+ if (!messageType || !isAggregationMessageType(messageType))
229
+ return;
230
+ const handler = actor.handlers.get(messageType);
231
+ if (handler)
232
+ handler(message);
233
+ }
234
+ async #publishToRelays(event) {
235
+ const relayPromises = this.pool?.publish(this.#relays, event);
236
+ if (!relayPromises?.length)
237
+ return;
238
+ const results = await Promise.allSettled(relayPromises);
239
+ const accepted = results.filter(r => r.status === 'fulfilled').length;
240
+ const rejected = results.filter(r => r.status === 'rejected');
241
+ for (const r of rejected) {
242
+ console.debug(`Relay rejected event ${event.id}: ${r.reason}`);
243
+ }
244
+ if (accepted === 0) {
245
+ throw new TransportAdapterError(`All ${results.length} relay(s) rejected event ${event.id}`, 'PUBLISH_ERROR', { adapter: this.name, reasons: rejected.map(r => String(r.reason)) });
246
+ }
247
+ }
248
+ static #jsonReplacer(_key, value) {
249
+ if (value instanceof Uint8Array) {
250
+ return { __bytes: bytesToHex(value) };
251
+ }
252
+ return value;
253
+ }
254
+ static #jsonReviver(_key, value) {
255
+ if (value && typeof value === 'object' && '__bytes' in value) {
256
+ return hexToBytes(value.__bytes);
257
+ }
258
+ return value;
259
+ }
260
+ }
261
+ _a = NostrTransport;
262
+ //# sourceMappingURL=nostr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nostr.js","sourceRoot":"","sources":["../../../../../src/core/aggregation/transport/nostr.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAE7D,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC9H,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAGnD;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,sBAAsB;IACtB,eAAe;IACf,0BAA0B;IAC1B,+BAA+B;CAChC,CAAC;AAYF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,cAAc;IACzB,IAAI,GAAW,OAAO,CAAC;IAEvB,IAAI,CAAc;IAClB,OAAO,CAAW;IAClB,OAAO,GAA4B,IAAI,GAAG,EAAE,CAAC;IAC7C,aAAa,GAA4B,IAAI,GAAG,EAAE,CAAC;IACnD,QAAQ,GAAG,KAAK,CAAC;IAEjB,YAAY,MAA6B;QACvC,IAAI,CAAC,OAAO,GAAG,MAAM,EAAE,MAAM,IAAI,oBAAoB,CAAC;IACxD,CAAC;IAED;;;;;;;;;;;OAWG;IACI,aAAa,CA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EAAE,CAAC;YACzF,OAAO,UAAU,CAAE,KAA6B,CAAC,OAAO,CAAC,CAAC;QAC5D,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.js","sourceRoot":"","sources":["../../../../../src/core/aggregation/transport/transport.ts"],"names":[],"mappings":""}
@@ -1,3 +1,10 @@
1
+ import { SchnorrKeyPair } from '@did-btcr2/keypair';
2
+ import { hexToBytes } from '@noble/hashes/utils';
3
+ import { opcodes, Psbt, script } from 'bitcoinjs-lib';
4
+ import { BeaconError } from './error.js';
5
+ import { StaticFeeEstimator } from './fee-estimator.js';
6
+ /** Default fee estimator used when none is supplied. ~5 sat/vB static rate. */
7
+ const DEFAULT_FEE_ESTIMATOR = new StaticFeeEstimator(5);
1
8
  /**
2
9
  * Abstract base class for all BTCR2 Beacon types.
3
10
  * A Beacon is a service listed in a BTCR2 DID document that informs resolvers
@@ -21,5 +28,78 @@ export class Beacon {
21
28
  constructor(service) {
22
29
  this.service = service;
23
30
  }
31
+ /**
32
+ * Shared PSBT construction + signing + broadcast helper used by all beacon types.
33
+ *
34
+ * Steps:
35
+ * 1. Parse the beacon's `serviceEndpoint` (stripping `bitcoin:` prefix) into a Bitcoin address.
36
+ * 2. Query the address for unconfirmed/confirmed UTXOs.
37
+ * 3. Select the most recent confirmed UTXO.
38
+ * 4. Fetch the previous transaction hex for `nonWitnessUtxo`.
39
+ * 5. Build a PSBT: input (UTXO) → change output + OP_RETURN(signalBytes).
40
+ * 6. Compute the fee via the supplied (or default) {@link FeeEstimator} against the tx vsize.
41
+ * 7. Sign input 0 with an ECDSA signer derived from `secretKey`.
42
+ * 8. Finalize, extract, and broadcast via the REST transaction endpoint.
43
+ *
44
+ * Fee handling: the PSBT is constructed with a placeholder change amount, signed to measure
45
+ * vsize, then the change is adjusted to pay the actual fee and the input re-signed. This
46
+ * two-pass approach avoids hardcoded fee constants and produces a tx that matches the
47
+ * estimator's rate.
48
+ *
49
+ * @param signalBytes 32-byte payload to embed in OP_RETURN.
50
+ * @param secretKey Secret key used to sign the spending input.
51
+ * @param bitcoin Bitcoin network connection.
52
+ * @param options Broadcast options (fee estimator, etc.).
53
+ * @returns The txid of the broadcast transaction.
54
+ * @throws {BeaconError} if the address is unfunded or no UTXO is available.
55
+ */
56
+ async buildSignAndBroadcast(signalBytes, secretKey, bitcoin, options) {
57
+ const feeEstimator = options?.feeEstimator ?? DEFAULT_FEE_ESTIMATOR;
58
+ // Strip the 'bitcoin:' prefix from the service endpoint.
59
+ const bitcoinAddress = this.service.serviceEndpoint.replace('bitcoin:', '');
60
+ // Fetch UTXOs at the beacon address.
61
+ const utxos = await bitcoin.rest.address.getUtxos(bitcoinAddress);
62
+ if (!utxos.length) {
63
+ throw new BeaconError('No UTXOs found, please fund address!', 'UNFUNDED_BEACON_ADDRESS', { bitcoinAddress });
64
+ }
65
+ // Take the most recently confirmed UTXO.
66
+ const utxo = utxos.sort((a, b) => b.status.block_height - a.status.block_height).shift();
67
+ if (!utxo) {
68
+ throw new BeaconError('Beacon bitcoin address unfunded or utxos unconfirmed.', 'UNFUNDED_BEACON_ADDRESS', { bitcoinAddress });
69
+ }
70
+ // Get the previous tx hex for non-witness UTXO reference.
71
+ const prevTx = await bitcoin.rest.transaction.getHex(utxo.txid);
72
+ // Build the ECDSA signer from the secret key.
73
+ const keyPair = SchnorrKeyPair.fromSecret(secretKey);
74
+ const signer = {
75
+ publicKey: keyPair.publicKey.compressed,
76
+ sign: (hash) => keyPair.secretKey.sign(hash, { scheme: 'ecdsa' }),
77
+ };
78
+ // First pass: build with a placeholder fee (0 sats) so we can measure vsize.
79
+ const build = (fee) => new Psbt({ network: bitcoin.data })
80
+ .addInput({
81
+ hash: utxo.txid,
82
+ index: utxo.vout,
83
+ nonWitnessUtxo: hexToBytes(prevTx),
84
+ })
85
+ .addOutput({ address: bitcoinAddress, value: BigInt(utxo.value) - fee })
86
+ .addOutput({ script: script.compile([opcodes.OP_RETURN, signalBytes]), value: 0n });
87
+ const probeTx = build(0n)
88
+ .signInput(0, signer)
89
+ .finalizeAllInputs()
90
+ .extractTransaction();
91
+ const vsize = probeTx.virtualSize();
92
+ // Second pass: use the estimator to compute the real fee.
93
+ const fee = await feeEstimator.estimateFee(vsize);
94
+ if (BigInt(utxo.value) <= fee) {
95
+ throw new BeaconError(`UTXO value (${utxo.value}) insufficient to cover fee (${fee}).`, 'INSUFFICIENT_FUNDS', { bitcoinAddress, utxoValue: utxo.value, fee: fee.toString() });
96
+ }
97
+ const signedTxHex = build(fee)
98
+ .signInput(0, signer)
99
+ .finalizeAllInputs()
100
+ .extractTransaction()
101
+ .toHex();
102
+ return bitcoin.rest.transaction.send(signedTxHex);
103
+ }
24
104
  }
25
105
  //# sourceMappingURL=beacon.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"beacon.js","sourceRoot":"","sources":["../../../../src/core/beacon/beacon.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAgB,MAAM;IAC1B;;OAEG;IACM,OAAO,CAAgB;IAEhC,YAAY,OAAsB;QAChC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CA+BF"}
1
+ {"version":3,"file":"beacon.js","sourceRoot":"","sources":["../../../../src/core/beacon/beacon.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGtD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAIxD,+EAA+E;AAC/E,MAAM,qBAAqB,GAAiB,IAAI,kBAAkB,CAAC,CAAC,CA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gC,GAAG,IAAI,EAChE,oBAAoB,EAAE,EAAE,cAAc,EAAE,SAAS,EAAE,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,QAAQ,EAAE,EAAE,CACrF,CAAC;QACJ,CAAC;QAED,MAAM,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC;aAC3B,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC;aACpB,iBAAiB,EAAE;aACnB,kBAAkB,EAAE;aACpB,KAAK,EAAE,CAAC;QAEX,OAAO,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACpD,CAAC;CACF"}
@@ -1,9 +1,5 @@
1
1
  import { canonicalHash, canonicalize, decode, encode, hash } from '@did-btcr2/common';
2
- import { SchnorrKeyPair } from '@did-btcr2/keypair';
3
- import { hexToBytes } from '@noble/hashes/utils';
4
- import { opcodes, Psbt, script } from 'bitcoinjs-lib';
5
2
  import { Beacon } from './beacon.js';
6
- import { CASBeaconError } from './error.js';
7
3
  /**
8
4
  * Implements {@link https://dcdpr.github.io/did-btcr2/terminology.html#cas-beacon | CAS Beacon}.
9
5
  *
@@ -31,7 +27,7 @@ export class CASBeacon extends Beacon {
31
27
  * For each signal, the signalBytes contain the hex-encoded hash of a CAS Announcement.
32
28
  * The CAS Announcement maps DIDs to their base64url-encoded update hashes.
33
29
  * This method looks up the CAS Announcement from the sidecar, extracts the update
34
- * hash for the DID being resolved, and retrieves the corresponding signed update.
30
+ * hash for the DID being resolved, and retrieves the corresponding signed update from sidecar.
35
31
  *
36
32
  * @param {Array<BeaconSignal>} signals The array of Beacon Signals to process.
37
33
  * @param {SidecarData} sidecar The sidecar data associated with the CAS Beacon.
@@ -83,71 +79,34 @@ export class CASBeacon extends Beacon {
83
79
  /**
84
80
  * Broadcasts a CAS Beacon signal to the Bitcoin network.
85
81
  *
86
- * Creates a CAS Announcement mapping the DID to the update hash, then broadcasts
87
- * the hash of the announcement via OP_RETURN. The CAS Announcement is distributed
88
- * to resolvers via sidecar data.
82
+ * Creates a CAS Announcement mapping the DID to the update hash, broadcasts the hash of the
83
+ * announcement via OP_RETURN, and optionally publishes the announcement off-chain via the
84
+ * supplied `casPublish` callback. UTXO selection, PSBT construction, fee estimation, signing,
85
+ * and broadcast are delegated to {@link Beacon.buildSignAndBroadcast}.
89
86
  *
90
87
  * @param {SignedBTCR2Update} signedUpdate The signed BTCR2 update to broadcast.
91
88
  * @param {KeyBytes} secretKey The secret key for signing the Bitcoin transaction.
92
89
  * @param {BitcoinConnection} bitcoin The Bitcoin network connection.
90
+ * @param {CASBroadcastOptions} [options] Optional broadcast configuration, including a
91
+ * `casPublish` callback to publish the announcement off-chain and a `feeEstimator`.
93
92
  * @returns {Promise<SignedBTCR2Update>} The signed update that was broadcast.
94
- * @throws {CASBeaconError} if the bitcoin address is invalid or unfunded.
93
+ * @throws {BeaconError} if the bitcoin address is invalid, unfunded, or UTXO cannot cover the fee.
95
94
  */
96
- async broadcastSignal(signedUpdate, secretKey, bitcoin) {
95
+ async broadcastSignal(signedUpdate, secretKey, bitcoin, options) {
97
96
  // Extract the DID from the beacon service id (strip the #fragment)
98
97
  const did = this.service.id.split('#')[0];
99
- // Hash the signed update (base64url for the CAS Announcement entry)
98
+ // Hash the signed update (base64urlnopad for the CAS Announcement entry per spec)
100
99
  const updateHash = canonicalHash(signedUpdate);
101
100
  // Create the CAS Announcement mapping this DID to its update hash
102
101
  const casAnnouncement = { [did]: updateHash };
103
- // TODO: Publish CAS Announcement to content-addressed store (e.g., IPFS via Helia)
104
102
  // Canonicalize and hash the CAS Announcement for the OP_RETURN output
105
103
  const announcementHash = hash(canonicalize(casAnnouncement));
106
- // Convert the serviceEndpoint to a bitcoin address by removing the 'bitcoin:' prefix
107
- const bitcoinAddress = this.service.serviceEndpoint.replace('bitcoin:', '');
108
- // Query the Bitcoin network for UTXOs associated with the bitcoinAddress
109
- const utxos = await bitcoin.rest.address.getUtxos(bitcoinAddress);
110
- // If no utxos are found, throw an error indicating the address is unfunded.
111
- if (!utxos.length) {
112
- throw new CASBeaconError('No UTXOs found, please fund address!', 'UNFUNDED_BEACON_ADDRESS', { bitcoinAddress });
104
+ // Delegate UTXO selection, PSBT construction, fee estimation, signing, and broadcast
105
+ await this.buildSignAndBroadcast(announcementHash, secretKey, bitcoin, options);
106
+ // Publish CAS Announcement to content-addressed store if callback provided
107
+ if (options?.casPublish) {
108
+ await options.casPublish(casAnnouncement);
113
109
  }
114
- // Sort utxos by block height and take the most recent one
115
- const utxo = utxos.sort((a, b) => b.status.block_height - a.status.block_height).shift();
116
- // If no utxos are found, throw an error.
117
- if (!utxo) {
118
- throw new CASBeaconError('Beacon bitcoin address unfunded or utxos unconfirmed.', 'UNFUNDED_BEACON_ADDRESS', { bitcoinAddress });
119
- }
120
- // Get the previous tx to the utxo being spent
121
- const prevTx = await bitcoin.rest.transaction.getHex(utxo.txid);
122
- // Construct a spend transaction
123
- const spendTx = new Psbt({ network: bitcoin.data })
124
- // Spend tx contains the utxo as its input
125
- .addInput({
126
- hash: utxo.txid,
127
- index: utxo.vout,
128
- nonWitnessUtxo: hexToBytes(prevTx)
129
- })
130
- // Add a change output minus a fee of 500 sats
131
- // TODO: calculate fee based on transaction vsize and current fee rates
132
- .addOutput({ address: bitcoinAddress, value: BigInt(utxo.value) - BigInt(500) })
133
- // Add an OP_RETURN output containing the CAS Announcement hash
134
- .addOutput({ script: script.compile([opcodes.OP_RETURN, announcementHash]), value: 0n });
135
- // Construct a key pair and PSBT signer from the secret key
136
- const keyPair = SchnorrKeyPair.fromSecret(secretKey);
137
- const signer = {
138
- publicKey: keyPair.publicKey.compressed,
139
- sign: (hash) => keyPair.secretKey.sign(hash, { scheme: 'ecdsa' }),
140
- };
141
- // Sign 0th input, finalize extract to hex in prep for broadcast
142
- const signedTx = spendTx.signInput(0, signer)
143
- .finalizeAllInputs()
144
- .extractTransaction()
145
- .toHex();
146
- // Broadcast spendTx to the Bitcoin network.
147
- const txid = await bitcoin.rest.transaction.send(signedTx);
148
- // Log the txid of the broadcasted transaction
149
- console.info(`CAS Beacon Signal Broadcasted with txid: ${txid}`);
150
- // Return the signed update
151
110
  return signedUpdate;
152
111
  }
153
112
  }
@@ -1 +1 @@
1
- {"version":3,"file":"cas-beacon.js","sourceRoot":"","sources":["../../../../src/core/beacon/cas-beacon.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEtF,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGtD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG5C;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,SAAU,SAAQ,MAAM;IACnC;;;OAGG;IACH,YAAY,OAAsB;QAChC,KAAK,CAAC,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,cAAc,CACZ,OAA4B,EAC5B,OAAoB;QAEpB,MAAM,OAAO,GAAG,IAAI,KAAK,EAAsC,CAAC;QAChE,MAAM,KAAK,GAAG,IAAI,KAAK,EAAY,CAAC;QAEpC,mEAAmE;QACnE,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAE1C,KAAI,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC5B,iEAAiE;YACjE,MAAM,gBAAgB,GAAG,MAAM,CAAC,WAAW,CAAC;YAE5C,iDAAiD;YACjD,MAAM,eAAe,GAAG,OAAO,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,CAAC;YACvB,MAAM,OAAO,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;QAC5C,CAAC;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;CACF"}
@@ -4,16 +4,6 @@ export class BeaconError extends MethodError {
4
4
  super(message, type, data);
5
5
  }
6
6
  }
7
- export class BeaconCoordinatorError extends MethodError {
8
- constructor(message, type = 'BeaconCoordinatorError', data) {
9
- super(message, type, data);
10
- }
11
- }
12
- export class BeaconParticipantError extends MethodError {
13
- constructor(message, type = 'BeaconParticipantError', data) {
14
- super(message, type, data);
15
- }
16
- }
17
7
  export class SingletonBeaconError extends MethodError {
18
8
  constructor(message, type = 'SingletonBeaconError', data) {
19
9
  super(message, type, data);
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","sourceRoot":"","sources":["../../../../src/core/beacon/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,OAAO,WAAY,SAAQ,WAAW;IAC1C,YAAY,OAAe,EAAE,OAAe,aAAa,EAAE,IAA0B;QACnF,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF;AAED,MAAM,OAAO,sBAAuB,SAAQ,WAAW;IACrD,YAAY,OAAe,EAAE,OAAe,wBAAwB,EAAE,IAA0B;QAC9F,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF;AAED,MAAM,OAAO,sBAAuB,SAAQ,WAAW;IACrD,YAAY,OAAe,EAAE,OAAe,wBAAwB,EAAE,IAA0B;QAC9F,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF;AAED,MAAM,OAAO,oBAAqB,SAAQ,WAAW;IACnD,YAAY,OAAe,EAAE,OAAe,sBAAsB,EAAE,IAA0B;QAC5F,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,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