@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,102 @@
1
+ import type { SchnorrKeyPair } from '@did-btcr2/keypair';
2
+ import type { AggregationResult, CohortConfig, PendingOptIn, SigningTxData } from '../service.js';
3
+ import { AggregationService } from '../service.js';
4
+ import type { Transport } from '../transport/transport.js';
5
+ import type { AggregationServiceEvents } from './events.js';
6
+ import { TypedEventEmitter } from './typed-emitter.js';
7
+ /** Decision callback: accept or reject a participant's opt-in. */
8
+ export type OnOptInReceived = (optIn: PendingOptIn) => Promise<{
9
+ accepted: boolean;
10
+ }>;
11
+ /** Decision callback: finalize keygen now, or wait for more participants. */
12
+ export type OnReadyToFinalize = (info: {
13
+ acceptedCount: number;
14
+ minRequired: number;
15
+ }) => Promise<{
16
+ finalize: boolean;
17
+ }>;
18
+ /** Data callback: provide the Bitcoin transaction data to sign. */
19
+ export type OnProvideTxData = (info: {
20
+ cohortId: string;
21
+ beaconAddress: string;
22
+ signalBytes: Uint8Array;
23
+ }) => Promise<SigningTxData>;
24
+ export interface AggregationServiceRunnerOptions {
25
+ /** Underlying transport (NostrTransport, MockTransport, etc.). */
26
+ transport: Transport;
27
+ /** This service's identity. */
28
+ did: string;
29
+ keys: SchnorrKeyPair;
30
+ /** Cohort configuration. */
31
+ config: CohortConfig;
32
+ /**
33
+ * Decide whether to accept a participant's opt-in.
34
+ * Default: auto-accept all opt-ins.
35
+ */
36
+ onOptInReceived?: OnOptInReceived;
37
+ /**
38
+ * Decide whether to finalize keygen now or wait for more participants.
39
+ * Called after each accepted opt-in once minParticipants is reached.
40
+ * Default: finalize as soon as minParticipants is reached.
41
+ */
42
+ onReadyToFinalize?: OnReadyToFinalize;
43
+ /**
44
+ * Provide the Bitcoin transaction data to sign.
45
+ * REQUIRED — no sensible default.
46
+ */
47
+ onProvideTxData: OnProvideTxData;
48
+ }
49
+ /**
50
+ * High-level facade for running an Aggregation Service over a Transport.
51
+ *
52
+ * Wires the {@link AggregationService} state machine to a {@link Transport},
53
+ * encapsulating message handler registration, outgoing message dispatch,
54
+ * and decision callback orchestration.
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * const transport = new NostrTransport({ relays: [RELAY] });
59
+ * transport.registerActor(serviceDid, serviceKeys);
60
+ *
61
+ * const runner = new AggregationServiceRunner({
62
+ * transport,
63
+ * did: serviceDid,
64
+ * keys: serviceKeys,
65
+ * config: { minParticipants: 2, network: 'mutinynet', beaconType: 'CASBeacon' },
66
+ * onProvideTxData: async ({ beaconAddress, signalBytes }) => {
67
+ * return await buildBeaconTransaction(beaconAddress, signalBytes, bitcoin);
68
+ * },
69
+ * });
70
+ *
71
+ * runner.on('keygen-complete', ({ beaconAddress }) => console.log(beaconAddress));
72
+ * runner.on('signing-complete', ({ signature }) => console.log('done'));
73
+ *
74
+ * const result = await runner.run();
75
+ * ```
76
+ *
77
+ * For full manual control, drop down to the underlying state machine via
78
+ * `runner.session`. The state machine has no transport coupling and exposes
79
+ * every protocol decision as an explicit method.
80
+ *
81
+ * @class AggregationServiceRunner
82
+ */
83
+ export declare class AggregationServiceRunner extends TypedEventEmitter<AggregationServiceEvents> {
84
+ #private;
85
+ /** Direct access to the underlying state machine for advanced use. */
86
+ readonly session: AggregationService;
87
+ constructor(options: AggregationServiceRunnerOptions);
88
+ /**
89
+ * Run the protocol to completion. Resolves with the final aggregation result
90
+ * (signature + signed transaction) once signing is complete.
91
+ *
92
+ * @returns {Promise<AggregationResult>} The final result with signature and signed tx.
93
+ */
94
+ run(): Promise<AggregationResult>;
95
+ /**
96
+ * Stop the runner early. Cleans up internal state.
97
+ * Note: does not unregister transport handlers (the transport interface
98
+ * does not currently expose unregister).
99
+ */
100
+ stop(): void;
101
+ }
102
+ //# sourceMappingURL=service-runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-runner.d.ts","sourceRoot":"","sources":["../../../../../src/core/aggregation/runner/service-runner.ts"],"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,eAAe,EAAE,eAAe,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBAAa,wBAAyB,SAAQ,iBAAiB,CAAC,wBAAwB,CAAC;;IACvF,sEAAsE;IACtE,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;gBAezB,OAAO,EAAE,+BAA+B;IAcpD;;;;;OAKG;IACH,GAAG,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAkBjC;;;;OAIG;IACH,IAAI,IAAI,IAAI;CAyMb"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Tiny strongly-typed event emitter.
3
+ *
4
+ * Browser-compatible (no Node.js `events` module). Uses a generic event map
5
+ * to give compile-time safety on event names and listener signatures.
6
+ *
7
+ * @example
8
+ * type MyEvents = {
9
+ * 'connected': [{ host: string }];
10
+ * 'data': [Uint8Array];
11
+ * 'error': [Error];
12
+ * };
13
+ *
14
+ * class MyClient extends TypedEventEmitter<MyEvents> {
15
+ * doStuff() {
16
+ * this.emit('connected', { host: 'example.com' }); // ✓ typed
17
+ * this.emit('data', new Uint8Array([1, 2])); // ✓ typed
18
+ * }
19
+ * }
20
+ *
21
+ * const client = new MyClient();
22
+ * client.on('connected', ({ host }) => console.log(host)); // ✓ typed
23
+ */
24
+ export type EventMap = Record<string, ReadonlyArray<unknown>>;
25
+ export type Listener<Args extends ReadonlyArray<unknown>> = (...args: Args) => void;
26
+ export declare class TypedEventEmitter<Events extends EventMap> {
27
+ #private;
28
+ /** Subscribe to an event. */
29
+ on<K extends keyof Events>(event: K, listener: Listener<Events[K]>): this;
30
+ /** Subscribe to an event, automatically unsubscribing after the first call. */
31
+ once<K extends keyof Events>(event: K, listener: Listener<Events[K]>): this;
32
+ /** Unsubscribe a specific listener. */
33
+ off<K extends keyof Events>(event: K, listener: Listener<Events[K]>): this;
34
+ /** Emit an event to all subscribed listeners. */
35
+ emit<K extends keyof Events>(event: K, ...args: Events[K]): boolean;
36
+ /** Remove all listeners (optionally for a specific event). */
37
+ removeAllListeners<K extends keyof Events>(event?: K): this;
38
+ /** Number of listeners for an event. */
39
+ listenerCount<K extends keyof Events>(event: K): number;
40
+ }
41
+ //# sourceMappingURL=typed-emitter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typed-emitter.d.ts","sourceRoot":"","sources":["../../../../../src/core/aggregation/runner/typed-emitter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;AAE9D,MAAM,MAAM,QAAQ,CAAC,IAAI,SAAS,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;AAEpF,qBAAa,iBAAiB,CAAC,MAAM,SAAS,QAAQ;;IAGpD,6BAA6B;IAC7B,EAAE,CAAC,CAAC,SAAS,MAAM,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;IAUzE,+EAA+E;IAC/E,IAAI,CAAC,CAAC,SAAS,MAAM,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;IAQ3E,uCAAuC;IACvC,GAAG,CAAC,CAAC,SAAS,MAAM,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;IAK1E,iDAAiD;IACjD,IAAI,CAAC,CAAC,SAAS,MAAM,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO;IAcnE,8DAA8D;IAC9D,kBAAkB,CAAC,CAAC,SAAS,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI;IAS3D,wCAAwC;IACxC,aAAa,CAAC,CAAC,SAAS,MAAM,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM;CAGxD"}
@@ -0,0 +1,112 @@
1
+ import type { SignedBTCR2Update } from '@did-btcr2/cryptosuite';
2
+ import type { SchnorrKeyPair } from '@did-btcr2/keypair';
3
+ import type { Transaction } from 'bitcoinjs-lib';
4
+ import { AggregationCohort } from './cohort.js';
5
+ import type { BaseMessage } from './messages/base.js';
6
+ import type { ServiceCohortPhaseType } from './phases.js';
7
+ /** Cohort configuration set by the service operator. */
8
+ export interface CohortConfig {
9
+ minParticipants: number;
10
+ network: string;
11
+ beaconType: string;
12
+ }
13
+ /** Pending opt-in awaiting service operator approval. */
14
+ export interface PendingOptIn {
15
+ cohortId: string;
16
+ participantDid: string;
17
+ participantPk: Uint8Array;
18
+ communicationPk: Uint8Array;
19
+ }
20
+ /** Validation tracking progress. */
21
+ export interface ValidationProgress {
22
+ approved: ReadonlySet<string>;
23
+ rejected: ReadonlySet<string>;
24
+ pending: ReadonlySet<string>;
25
+ total: number;
26
+ }
27
+ /** Final aggregation result for a cohort. */
28
+ export interface AggregationResult {
29
+ cohortId: string;
30
+ signature: Uint8Array;
31
+ signedTx: Transaction;
32
+ }
33
+ /** Transaction data needed to start a signing session. */
34
+ export interface SigningTxData {
35
+ tx: Transaction;
36
+ prevOutScripts: Uint8Array[];
37
+ prevOutValues: bigint[];
38
+ }
39
+ export interface AggregationServiceParams {
40
+ did: string;
41
+ keys: SchnorrKeyPair;
42
+ }
43
+ /**
44
+ * Sans-I/O state machine for an Aggregation Service.
45
+ *
46
+ * Manages multiple cohorts simultaneously. The service operator drives the
47
+ * state machine via `receive()` (for incoming messages) and explicit action
48
+ * methods (advertising, accepting opt-ins, finalizing keygen, building
49
+ * aggregated data, starting signing). All outgoing messages are returned for
50
+ * the caller to send via whatever transport.
51
+ *
52
+ * @class AggregationService
53
+ */
54
+ export declare class AggregationService {
55
+ #private;
56
+ readonly did: string;
57
+ readonly keys: SchnorrKeyPair;
58
+ constructor({ did, keys }: AggregationServiceParams);
59
+ receive(message: BaseMessage): void;
60
+ /**
61
+ * Create a new cohort with the given config. Returns the cohort ID.
62
+ * Cohort starts in `Created` phase — call `advertise()` to broadcast.
63
+ */
64
+ createCohort(config: CohortConfig): string;
65
+ /**
66
+ * Advertise a cohort to discover participants.
67
+ * Returns the advert message to broadcast.
68
+ */
69
+ advertise(cohortId: string): BaseMessage[];
70
+ /** Pending opt-ins awaiting operator approval. */
71
+ pendingOptIns(cohortId: string): ReadonlyMap<string, PendingOptIn>;
72
+ /**
73
+ * Service operator accepts a participant's opt-in.
74
+ * Returns the accept message to send.
75
+ */
76
+ acceptParticipant(cohortId: string, participantDid: string): BaseMessage[];
77
+ /**
78
+ * Finalize cohort keygen: compute MuSig2 Taproot beacon address and send
79
+ * COHORT_READY messages to all accepted participants.
80
+ */
81
+ finalizeKeygen(cohortId: string): BaseMessage[];
82
+ /** Updates collected so far for a cohort. */
83
+ collectedUpdates(cohortId: string): ReadonlyMap<string, SignedBTCR2Update>;
84
+ /**
85
+ * Build the aggregated data structure (CAS Announcement or SMT tree) and
86
+ * return distribute messages to send to all participants for validation.
87
+ */
88
+ buildAndDistribute(cohortId: string): BaseMessage[];
89
+ validationProgress(cohortId: string): ValidationProgress;
90
+ /**
91
+ * Start a signing session by creating auth requests for all participants.
92
+ * The caller provides the transaction data — typically built via
93
+ * `buildBeaconTransaction()` against a Bitcoin connection.
94
+ */
95
+ startSigning(cohortId: string, txData: SigningTxData): BaseMessage[];
96
+ /**
97
+ * Generate the aggregated nonce and return messages to send to participants.
98
+ * Call after `validationProgress(cohortId).approved.size === total`.
99
+ */
100
+ sendAggregatedNonce(cohortId: string): BaseMessage[];
101
+ getResult(cohortId: string): AggregationResult | undefined;
102
+ getCohortPhase(cohortId: string): ServiceCohortPhaseType | undefined;
103
+ getCohort(cohortId: string): AggregationCohort | undefined;
104
+ /**
105
+ * Get the signing session ID for a cohort, if a signing session has been started.
106
+ * @param {string} cohortId - The cohort ID.
107
+ * @returns {string | undefined} The session ID, or undefined if no session is active.
108
+ */
109
+ getSigningSessionId(cohortId: string): string | undefined;
110
+ get cohorts(): ReadonlyArray<AggregationCohort>;
111
+ }
112
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../../src/core/aggregation/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAgBtD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAI1D,wDAAwD;AACxD,MAAM,WAAW,YAAY;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,yDAAyD;AACzD,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,UAAU,CAAC;IAC1B,eAAe,EAAE,UAAU,CAAC;CAC7B;AAED,oCAAoC;AACpC,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC9B,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC9B,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;CACf;AAED,6CAA6C;AAC7C,MAAM,WAAW,iBAAiB;I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CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,WAAW,EAAE;IAuDpE;;;OAGG;IACH,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,EAAE;IA4DpD,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS;IAI1D,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,sBAAsB,GAAG,SAAS;IAIpE,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS;IAI1D;;;;OAIG;IACH,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIzD,IAAI,OAAO,IAAI,aAAa,CAAC,iBAAiB,CAAC,CAE9C;CACF"}
@@ -0,0 +1,69 @@
1
+ import { Transaction } from 'bitcoinjs-lib';
2
+ import type { AggregationCohort } from './cohort.js';
3
+ import type { SigningSessionPhaseType } from './phases.js';
4
+ type PublicKeyHex = string;
5
+ type Nonce = Uint8Array;
6
+ export interface SigningSessionParams {
7
+ id?: string;
8
+ cohort: AggregationCohort;
9
+ pendingTx: Transaction;
10
+ prevOutScripts?: Uint8Array[];
11
+ prevOutValues?: bigint[];
12
+ }
13
+ /**
14
+ * MuSig2 signing session for a beacon transaction.
15
+ *
16
+ * Implements the BIP-327 signing protocol over a Taproot key-path-only
17
+ * transaction. The session is used by both AggregationService (collecting
18
+ * nonces and partial signatures, computing the final signature) and
19
+ * AggregationParticipant (generating their nonce and partial signature).
20
+ *
21
+ * @class BeaconSigningSession
22
+ */
23
+ export declare class BeaconSigningSession {
24
+ /** Unique identifier for this signing session. */
25
+ id: string;
26
+ /** The cohort this session signs for. */
27
+ cohort: AggregationCohort;
28
+ /** The Bitcoin transaction being signed. */
29
+ pendingTx: Transaction;
30
+ /** Previous output scripts for Taproot sighash computation (BIP-341). */
31
+ prevOutScripts: Uint8Array[];
32
+ /** Previous output values for Taproot sighash computation. */
33
+ prevOutValues: bigint[];
34
+ /** Map of participant publicKey-hex → public nonce contribution. */
35
+ nonceContributions: Map<PublicKeyHex, Nonce>;
36
+ /** Aggregated MuSig2 nonce (66 bytes). */
37
+ aggregatedNonce?: Uint8Array;
38
+ /** Map of participant DID → partial signature. */
39
+ partialSignatures: Map<string, Uint8Array>;
40
+ /** Final 64-byte Schnorr signature. */
41
+ signature?: Uint8Array;
42
+ /** Current signing session phase. */
43
+ phase: SigningSessionPhaseType;
44
+ /** Participant's secret nonce (held only by the participant during signing). */
45
+ secretNonce?: Uint8Array;
46
+ constructor({ id, cohort, pendingTx, prevOutScripts, prevOutValues }: SigningSessionParams);
47
+ /**
48
+ * Computes the Taproot sighash (BIP-341) for the first input.
49
+ */
50
+ get sigHash(): Uint8Array;
51
+ addNonceContribution(participantDid: string, nonceContribution: Uint8Array): void;
52
+ generateAggregatedNonce(): Uint8Array;
53
+ addPartialSignature(participantDid: string, partialSig: Uint8Array): void;
54
+ generateFinalSignature(): Uint8Array;
55
+ /**
56
+ * Generates a fresh MuSig2 nonce contribution for the participant.
57
+ * Stores the secret nonce internally for use in `generatePartialSignature()`.
58
+ */
59
+ generateNonceContribution(participantPublicKey: Uint8Array, participantSecretKey: Uint8Array): Uint8Array;
60
+ /**
61
+ * Generates a partial signature using the participant's secret key + secret nonce.
62
+ * Requires the aggregated nonce to have been set first (via the service).
63
+ */
64
+ generatePartialSignature(participantSecretKey: Uint8Array): Uint8Array;
65
+ isComplete(): boolean;
66
+ isFailed(): boolean;
67
+ }
68
+ export {};
69
+ //# sourceMappingURL=signing-session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signing-session.d.ts","sourceRoot":"","sources":["../../../../src/core/aggregation/signing-session.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AA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U,EAAE,UAAU,GAAG,IAAI;IAoBzE,sBAAsB,IAAI,UAAU;IAsB3C;;;OAGG;IACI,yBAAyB,CAAC,oBAAoB,EAAE,UAAU,EAAE,oBAAoB,EAAE,UAAU,GAAG,UAAU;IAOhH;;;OAGG;IACI,wBAAwB,CAAC,oBAAoB,EAAE,UAAU,GAAG,UAAU;IAiBtE,UAAU,IAAI,OAAO;IAIrB,QAAQ,IAAI,OAAO;CAG3B"}
@@ -0,0 +1,20 @@
1
+ import type { SchnorrKeyPair } from '@did-btcr2/keypair';
2
+ import type { BaseMessage } from '../messages/base.js';
3
+ import type { MessageHandler, Transport } from './transport.js';
4
+ /**
5
+ * DIDComm Transport (stub).
6
+ *
7
+ * @class DidCommTransport
8
+ * @implements {Transport}
9
+ */
10
+ export declare class DidCommTransport implements Transport {
11
+ name: string;
12
+ start(): void;
13
+ registerActor(_did: string, _keys: SchnorrKeyPair): void;
14
+ getActorPk(_did: string): Uint8Array | undefined;
15
+ registerPeer(_did: string, _communicationPk: Uint8Array): void;
16
+ getPeerPk(_did: string): Uint8Array | undefined;
17
+ registerMessageHandler(_actorDid: string, _messageType: string, _handler: MessageHandler): void;
18
+ sendMessage(_message: BaseMessage, _sender: string, _recipient?: string): Promise<void>;
19
+ }
20
+ //# sourceMappingURL=didcomm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"didcomm.d.ts","sourceRoot":"","sources":["../../../../../src/core/aggregation/transport/didcomm.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhE;;;;;GAKG;AACH,qBAAa,gBAAiB,YAAW,SAAS;IACzC,IAAI,EAAE,MAAM,CAAa;IAEzB,KAAK,IAAI,IAAI;IAIb,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,GAAG,IAAI;IAIxD,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAIhD,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,gBAAgB,EAAE,UAAU,GAAG,IAAI;IAI9D,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAI/C,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,GAAG,IAAI;IAIzF,WAAW,CAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGrG"}
@@ -1,8 +1,8 @@
1
1
  import { MethodError } from '@did-btcr2/common';
2
- export declare class CommunicationServiceError extends MethodError {
2
+ export declare class TransportError extends MethodError {
3
3
  constructor(message: string, type?: string, data?: Record<string, any>);
4
4
  }
5
- export declare class CommunicationAdapterError extends MethodError {
5
+ export declare class TransportAdapterError extends MethodError {
6
6
  constructor(message: string, type?: string, data?: Record<string, any>);
7
7
  }
8
8
  //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../../../src/core/aggregation/transport/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,qBAAa,cAAe,SAAQ,WAAW;gBACjC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAAyB,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAGzF;AAED,qBAAa,qBAAsB,SAAQ,WAAW;gBACxC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAAgC,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAGhG"}
@@ -0,0 +1,13 @@
1
+ import type { Transport, TransportType } from './transport.js';
2
+ export interface TransportConfig {
3
+ type: TransportType;
4
+ relays?: string[];
5
+ }
6
+ /**
7
+ * Factory for creating Transport instances.
8
+ * @class TransportFactory
9
+ */
10
+ export declare class TransportFactory {
11
+ static establish(config: TransportConfig): Transport;
12
+ }
13
+ //# sourceMappingURL=factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../../../src/core/aggregation/transport/factory.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/D,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;;GAGG;AACH,qBAAa,gBAAgB;IAC3B,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS;CAarD"}
@@ -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.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","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,55 @@
1
+ import type { Did } from '@did-btcr2/common';
2
+ import type { SchnorrKeyPair } from '@did-btcr2/keypair';
3
+ import { SimplePool } from 'nostr-tools/pool';
4
+ import type { BaseMessage } from '../messages/base.js';
5
+ import type { MessageHandler, Transport } from './transport.js';
6
+ /**
7
+ * Default Nostr relay URLs.
8
+ * @constant {Array<string>} DEFAULT_NOSTR_RELAYS
9
+ */
10
+ export declare const DEFAULT_NOSTR_RELAYS: string[];
11
+ export interface NostrTransportConfig {
12
+ relays?: string[];
13
+ }
14
+ /**
15
+ * Nostr Transport for did:btcr2 aggregation messages.
16
+ *
17
+ * A single NostrTransport manages one relay pool and supports multiple
18
+ * registered actors. Each actor registers its own DID and keys via
19
+ * {@link registerActor}; the transport resolves the correct identity when
20
+ * sending or receiving.
21
+ *
22
+ * Message routing:
23
+ * - Keygen messages (COHORT_ADVERT, COHORT_OPT_IN, COHORT_OPT_IN_ACCEPT, COHORT_READY) → kind 1 (plaintext)
24
+ * - Update messages (SUBMIT_UPDATE, DISTRIBUTE_AGGREGATED_DATA, VALIDATION_ACK) → kind 1059 (NIP-44 encrypted)
25
+ * - Sign messages → kind 1059 (NIP-44 encrypted)
26
+ *
27
+ * @class NostrTransport
28
+ * @implements {Transport}
29
+ */
30
+ export declare class NostrTransport implements Transport {
31
+ #private;
32
+ name: string;
33
+ pool?: SimplePool;
34
+ constructor(config?: NostrTransportConfig);
35
+ /**
36
+ * Registers an actor (DID + keys) to send/receive messages with.
37
+ * Must be called before start() to ensure subscriptions are created for the actor.
38
+ * @param {string} did - The DID of the actor.
39
+ * @param {SchnorrKeyPair} keys - The Schnorr key pair for the actor.
40
+ * @throws {TransportAdapterError} If the actor is already registered or if the transport has already started.
41
+ * @example
42
+ * const transport = new NostrTransport();
43
+ * const keys = SchnorrKeyPair.generate();
44
+ * transport.registerActor('did:btcr2:...', keys);
45
+ * transport.start();
46
+ */
47
+ registerActor(did: string, keys: SchnorrKeyPair): void;
48
+ getActorPk(did: string): Uint8Array | undefined;
49
+ registerPeer(did: string, communicationPk: Uint8Array): void;
50
+ getPeerPk(did: string): Uint8Array | undefined;
51
+ registerMessageHandler(actorDid: string, messageType: string, handler: MessageHandler): void;
52
+ start(): NostrTransport;
53
+ sendMessage(message: BaseMessage, sender: Did, to?: Did): Promise<void>;
54
+ }
55
+ //# sourceMappingURL=nostr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nost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SchnorrKeyPair } from '@did-btcr2/keypair';
2
+ import type { BaseMessage } from '../messages/base.js';
3
+ export type SyncMessageHandler = (msg: any) => void;
4
+ export type AsyncMessageHandler = (msg: any) => Promise<void>;
5
+ export type MessageHandler = SyncMessageHandler | AsyncMessageHandler;
6
+ export type TransportType = 'nostr' | 'didcomm';
7
+ /**
8
+ * Multi-actor message transport.
9
+ *
10
+ * A single transport instance manages one connection (relay pool, channel, etc.)
11
+ * shared by all registered actors. Each actor registers its own DID and keys;
12
+ * the transport resolves the correct identity when sending or receiving messages.
13
+ *
14
+ * The transport is a pure passthrough — it knows nothing about the aggregation
15
+ * protocol. It only signs/encrypts outgoing messages with the sender's keys and
16
+ * dispatches incoming messages to the correct actor's registered handler.
17
+ *
18
+ * @interface Transport
19
+ */
20
+ export interface Transport {
21
+ name: string;
22
+ /** Start the underlying transport (idempotent — only starts once). */
23
+ start(): void;
24
+ /** Register an actor (service or participant) with this transport. */
25
+ registerActor(did: string, keys: SchnorrKeyPair): void;
26
+ /** Return a registered actor's compressed communication public key. */
27
+ getActorPk(did: string): Uint8Array | undefined;
28
+ /** Store a remote peer's communication public key for encrypted routing. */
29
+ registerPeer(did: string, communicationPk: Uint8Array): void;
30
+ /** Retrieve a remote peer's communication public key. */
31
+ getPeerPk(did: string): Uint8Array | undefined;
32
+ /** Register a message handler scoped to a specific actor. */
33
+ registerMessageHandler(actorDid: string, messageType: string, handler: MessageHandler): void;
34
+ /** Send a message. The transport looks up sender to resolve signing keys. */
35
+ sendMessage(message: BaseMessage, sender: string, recipient?: string): Promise<void>;
36
+ }
37
+ //# sourceMappingURL=transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../../../src/core/aggregation/transport/transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,MAAM,MAAM,kBAAkB,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC;AACpD,MAAM,MAAM,mBAAmB,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAC9D,MAAM,MAAM,cAAc,GAAG,kBAAkB,GAAG,mBAAmB,CAAC;AAEtE,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,SAAS,CAAC;AAEhD;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IAEb,sEAAsE;IACtE,KAAK,IAAI,IAAI,CAAC;IAEd,sEAAsE;IACtE,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,IAAI,CAAC;IAEvD,uEAAuE;IACvE,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;IAEhD,4EAA4E;IAC5E,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,eAAe,EAAE,UAAU,GAAG,IAAI,CAAC;IAE7D,yDAAyD;IACzD,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;IAE/C,6DAA6D;IAC7D,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IAE7F,6EAA6E;IAC7E,WAAW,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACtF"}
@@ -1,9 +1,17 @@
1
- import type { KeyBytes } from '@did-btcr2/common';
2
1
  import type { BitcoinConnection } from '@did-btcr2/bitcoin';
2
+ import type { KeyBytes } from '@did-btcr2/common';
3
3
  import type { SignedBTCR2Update } from '@did-btcr2/cryptosuite';
4
4
  import type { BeaconProcessResult } from '../resolver.js';
5
5
  import type { SidecarData } from '../types.js';
6
+ import type { FeeEstimator } from './fee-estimator.js';
6
7
  import type { BeaconService, BeaconSignal } from './interfaces.js';
8
+ /**
9
+ * Options accepted by {@link Beacon.buildSignAndBroadcast}.
10
+ */
11
+ export interface BroadcastOptions {
12
+ /** Fee estimator for computing the transaction fee. Defaults to {@link DEFAULT_FEE_ESTIMATOR}. */
13
+ feeEstimator?: FeeEstimator;
14
+ }
7
15
  /**
8
16
  * Abstract base class for all BTCR2 Beacon types.
9
17
  * A Beacon is a service listed in a BTCR2 DID document that informs resolvers
@@ -43,8 +51,35 @@ export declare abstract class Beacon {
43
51
  * @param {SignedBTCR2Update} signedUpdate The signed BTCR2 update to broadcast.
44
52
  * @param {KeyBytes} secretKey The secret key for signing the Bitcoin transaction.
45
53
  * @param {BitcoinConnection} bitcoin The Bitcoin network connection.
54
+ * @param {BroadcastOptions} [options] Optional broadcast configuration (e.g. fee estimator).
46
55
  * @returns {Promise<SignedBTCR2Update>} The signed update that was broadcast.
47
56
  */
48
- abstract broadcastSignal(signedUpdate: SignedBTCR2Update, secretKey: KeyBytes, bitcoin: BitcoinConnection): Promise<SignedBTCR2Update>;
57
+ abstract broadcastSignal(signedUpdate: SignedBTCR2Update, secretKey: KeyBytes, bitcoin: BitcoinConnection, options?: BroadcastOptions): Promise<SignedBTCR2Update>;
58
+ /**
59
+ * Shared PSBT construction + signing + broadcast helper used by all beacon types.
60
+ *
61
+ * Steps:
62
+ * 1. Parse the beacon's `serviceEndpoint` (stripping `bitcoin:` prefix) into a Bitcoin address.
63
+ * 2. Query the address for unconfirmed/confirmed UTXOs.
64
+ * 3. Select the most recent confirmed UTXO.
65
+ * 4. Fetch the previous transaction hex for `nonWitnessUtxo`.
66
+ * 5. Build a PSBT: input (UTXO) → change output + OP_RETURN(signalBytes).
67
+ * 6. Compute the fee via the supplied (or default) {@link FeeEstimator} against the tx vsize.
68
+ * 7. Sign input 0 with an ECDSA signer derived from `secretKey`.
69
+ * 8. Finalize, extract, and broadcast via the REST transaction endpoint.
70
+ *
71
+ * Fee handling: the PSBT is constructed with a placeholder change amount, signed to measure
72
+ * vsize, then the change is adjusted to pay the actual fee and the input re-signed. This
73
+ * two-pass approach avoids hardcoded fee constants and produces a tx that matches the
74
+ * estimator's rate.
75
+ *
76
+ * @param signalBytes 32-byte payload to embed in OP_RETURN.
77
+ * @param secretKey Secret key used to sign the spending input.
78
+ * @param bitcoin Bitcoin network connection.
79
+ * @param options Broadcast options (fee estimator, etc.).
80
+ * @returns The txid of the broadcast transaction.
81
+ * @throws {BeaconError} if the address is unfunded or no UTXO is available.
82
+ */
83
+ protected buildSignAndBroadcast(signalBytes: Uint8Array, secretKey: KeyBytes, bitcoin: BitcoinConnection, options?: BroadcastOptions): Promise<string>;
49
84
  }
50
85
  //# sourceMappingURL=beacon.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"beacon.d.ts","sourceRoot":"","sources":["../../../../src/core/beacon/beacon.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEnE;;;;;;;;;;;;;;GAcG;AACH,8BAAsB,MAAM;IAC1B;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;gBAEpB,OAAO,EAAE,aAAa;IAIlC;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,cAAc,CACrB,OAAO,EAAE,KAAK,CAAC,YAAY,CAAC,EAC5B,OAAO,EAAE,WAAW,GACnB,mBAAmB;IAE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;;;;;;;;;;OAwBG;cACa,qBAAqB,CACnC,WAAW,EAAE,UAAU,EACvB,SAAS,EAAE,QAAQ,EACnB,OAAO,EAAE,iBAAiB,EAC1B,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,MAAM,CAAC;CAsEnB"}
@@ -3,8 +3,17 @@ import type { KeyBytes } from '@did-btcr2/common';
3
3
  import type { SignedBTCR2Update } from '@did-btcr2/cryptosuite';
4
4
  import type { BeaconProcessResult } from '../resolver.js';
5
5
  import type { SidecarData } from '../types.js';
6
+ import type { BroadcastOptions } from './beacon.js';
6
7
  import { Beacon } from './beacon.js';
7
- import type { BeaconService, BeaconSignal } from './interfaces.js';
8
+ import type { BeaconService, BeaconSignal, CasPublishFn } from './interfaces.js';
9
+ /**
10
+ * CAS-specific broadcast options — extends {@link BroadcastOptions} with an optional
11
+ * `casPublish` callback used to publish the CAS Announcement off-chain after the
12
+ * OP_RETURN signal is broadcast.
13
+ */
14
+ export interface CASBroadcastOptions extends BroadcastOptions {
15
+ casPublish?: CasPublishFn;
16
+ }
8
17
  /**
9
18
  * Implements {@link https://dcdpr.github.io/did-btcr2/terminology.html#cas-beacon | CAS Beacon}.
10
19
  *
@@ -30,7 +39,7 @@ export declare class CASBeacon extends Beacon {
30
39
  * For each signal, the signalBytes contain the hex-encoded hash of a CAS Announcement.
31
40
  * The CAS Announcement maps DIDs to their base64url-encoded update hashes.
32
41
  * This method looks up the CAS Announcement from the sidecar, extracts the update
33
- * hash for the DID being resolved, and retrieves the corresponding signed update.
42
+ * hash for the DID being resolved, and retrieves the corresponding signed update from sidecar.
34
43
  *
35
44
  * @param {Array<BeaconSignal>} signals The array of Beacon Signals to process.
36
45
  * @param {SidecarData} sidecar The sidecar data associated with the CAS Beacon.
@@ -41,16 +50,19 @@ export declare class CASBeacon extends Beacon {
41
50
  /**
42
51
  * Broadcasts a CAS Beacon signal to the Bitcoin network.
43
52
  *
44
- * Creates a CAS Announcement mapping the DID to the update hash, then broadcasts
45
- * the hash of the announcement via OP_RETURN. The CAS Announcement is distributed
46
- * to resolvers via sidecar data.
53
+ * Creates a CAS Announcement mapping the DID to the update hash, broadcasts the hash of the
54
+ * announcement via OP_RETURN, and optionally publishes the announcement off-chain via the
55
+ * supplied `casPublish` callback. UTXO selection, PSBT construction, fee estimation, signing,
56
+ * and broadcast are delegated to {@link Beacon.buildSignAndBroadcast}.
47
57
  *
48
58
  * @param {SignedBTCR2Update} signedUpdate The signed BTCR2 update to broadcast.
49
59
  * @param {KeyBytes} secretKey The secret key for signing the Bitcoin transaction.
50
60
  * @param {BitcoinConnection} bitcoin The Bitcoin network connection.
61
+ * @param {CASBroadcastOptions} [options] Optional broadcast configuration, including a
62
+ * `casPublish` callback to publish the announcement off-chain and a `feeEstimator`.
51
63
  * @returns {Promise<SignedBTCR2Update>} The signed update that was broadcast.
52
- * @throws {CASBeaconError} if the bitcoin address is invalid or unfunded.
64
+ * @throws {BeaconError} if the bitcoin address is invalid, unfunded, or UTXO cannot cover the fee.
53
65
  */
54
- broadcastSignal(signedUpdate: SignedBTCR2Update, secretKey: KeyBytes, bitcoin: BitcoinConnection): Promise<SignedBTCR2Update>;
66
+ broadcastSignal(signedUpdate: SignedBTCR2Update, secretKey: KeyBytes, bitcoin: BitcoinConnection, options?: CASBroadcastOptions): Promise<SignedBTCR2Update>;
55
67
  }
56
68
  //# sourceMappingURL=cas-beacon.d.ts.map