@did-btcr2/method 0.25.3 → 0.27.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 (406) hide show
  1. package/README.md +86 -233
  2. package/dist/.tsbuildinfo +1 -0
  3. package/dist/browser.js +129207 -122358
  4. package/dist/browser.mjs +129235 -122386
  5. package/dist/cjs/index.js +5332 -43
  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 +282 -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 +21 -60
  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/signal-discovery.js +1 -1
  59. package/dist/esm/core/beacon/signal-discovery.js.map +1 -1
  60. package/dist/esm/core/beacon/singleton-beacon.js +13 -56
  61. package/dist/esm/core/beacon/singleton-beacon.js.map +1 -1
  62. package/dist/esm/core/beacon/smt-beacon.js +85 -9
  63. package/dist/esm/core/beacon/smt-beacon.js.map +1 -1
  64. package/dist/esm/core/beacon/utils.js.map +1 -1
  65. package/dist/esm/core/identifier.js +13 -0
  66. package/dist/esm/core/identifier.js.map +1 -1
  67. package/dist/esm/core/resolver.js +50 -35
  68. package/dist/esm/core/resolver.js.map +1 -1
  69. package/dist/esm/core/update.js.map +1 -1
  70. package/dist/esm/did-btcr2.js +1 -1
  71. package/dist/esm/did-btcr2.js.map +1 -1
  72. package/dist/esm/index.js +14 -24
  73. package/dist/esm/index.js.map +1 -1
  74. package/dist/esm/utils/appendix.js +7 -6
  75. package/dist/esm/utils/appendix.js.map +1 -1
  76. package/dist/esm/utils/did-document-builder.js.map +1 -1
  77. package/dist/esm/utils/did-document.js +2 -2
  78. package/dist/esm/utils/did-document.js.map +1 -1
  79. package/dist/types/core/aggregation/cohort.d.ts +94 -0
  80. package/dist/types/core/aggregation/cohort.d.ts.map +1 -0
  81. package/dist/types/core/aggregation/errors.d.ts +14 -0
  82. package/dist/types/core/aggregation/errors.d.ts.map +1 -0
  83. package/dist/types/core/{beacon/aggregation/cohort → aggregation}/messages/base.d.ts +7 -1
  84. package/dist/types/core/aggregation/messages/base.d.ts.map +1 -0
  85. package/dist/types/core/aggregation/messages/constants.d.ts +23 -0
  86. package/dist/types/core/aggregation/messages/constants.d.ts.map +1 -0
  87. package/dist/types/core/aggregation/messages/factories.d.ts +177 -0
  88. package/dist/types/core/aggregation/messages/factories.d.ts.map +1 -0
  89. package/dist/types/core/aggregation/messages/guards.d.ts +11 -0
  90. package/dist/types/core/aggregation/messages/guards.d.ts.map +1 -0
  91. package/dist/types/core/aggregation/messages/index.d.ts +5 -0
  92. package/dist/types/core/aggregation/messages/index.d.ts.map +1 -0
  93. package/dist/types/core/aggregation/participant.d.ts +101 -0
  94. package/dist/types/core/aggregation/participant.d.ts.map +1 -0
  95. package/dist/types/core/aggregation/phases.d.ts +49 -0
  96. package/dist/types/core/aggregation/phases.d.ts.map +1 -0
  97. package/dist/types/core/aggregation/runner/events.d.ts +89 -0
  98. package/dist/types/core/aggregation/runner/events.d.ts.map +1 -0
  99. package/dist/types/core/aggregation/runner/index.d.ts +5 -0
  100. package/dist/types/core/aggregation/runner/index.d.ts.map +1 -0
  101. package/dist/types/core/aggregation/runner/participant-runner.d.ts +107 -0
  102. package/dist/types/core/aggregation/runner/participant-runner.d.ts.map +1 -0
  103. package/dist/types/core/aggregation/runner/service-runner.d.ts +102 -0
  104. package/dist/types/core/aggregation/runner/service-runner.d.ts.map +1 -0
  105. package/dist/types/core/aggregation/runner/typed-emitter.d.ts +41 -0
  106. package/dist/types/core/aggregation/runner/typed-emitter.d.ts.map +1 -0
  107. package/dist/types/core/aggregation/service.d.ts +112 -0
  108. package/dist/types/core/aggregation/service.d.ts.map +1 -0
  109. package/dist/types/core/aggregation/signing-session.d.ts +69 -0
  110. package/dist/types/core/aggregation/signing-session.d.ts.map +1 -0
  111. package/dist/types/core/aggregation/transport/didcomm.d.ts +20 -0
  112. package/dist/types/core/aggregation/transport/didcomm.d.ts.map +1 -0
  113. package/dist/types/core/{beacon/aggregation/communication → aggregation/transport}/error.d.ts +2 -2
  114. package/dist/types/core/aggregation/transport/error.d.ts.map +1 -0
  115. package/dist/types/core/aggregation/transport/factory.d.ts +13 -0
  116. package/dist/types/core/aggregation/transport/factory.d.ts.map +1 -0
  117. package/dist/types/core/aggregation/transport/index.d.ts +6 -0
  118. package/dist/types/core/aggregation/transport/index.d.ts.map +1 -0
  119. package/dist/types/core/aggregation/transport/nostr.d.ts +55 -0
  120. package/dist/types/core/aggregation/transport/nostr.d.ts.map +1 -0
  121. package/dist/types/core/aggregation/transport/transport.d.ts +37 -0
  122. package/dist/types/core/aggregation/transport/transport.d.ts.map +1 -0
  123. package/dist/types/core/beacon/beacon.d.ts +41 -6
  124. package/dist/types/core/beacon/beacon.d.ts.map +1 -1
  125. package/dist/types/core/beacon/cas-beacon.d.ts +23 -11
  126. package/dist/types/core/beacon/cas-beacon.d.ts.map +1 -1
  127. package/dist/types/core/beacon/error.d.ts +0 -6
  128. package/dist/types/core/beacon/error.d.ts.map +1 -1
  129. package/dist/types/core/beacon/factory.d.ts +2 -2
  130. package/dist/types/core/beacon/factory.d.ts.map +1 -1
  131. package/dist/types/core/beacon/fee-estimator.d.ts +40 -0
  132. package/dist/types/core/beacon/fee-estimator.d.ts.map +1 -0
  133. package/dist/types/core/beacon/interfaces.d.ts +11 -3
  134. package/dist/types/core/beacon/interfaces.d.ts.map +1 -1
  135. package/dist/types/core/beacon/signal-discovery.d.ts +3 -3
  136. package/dist/types/core/beacon/signal-discovery.d.ts.map +1 -1
  137. package/dist/types/core/beacon/singleton-beacon.d.ts +14 -7
  138. package/dist/types/core/beacon/singleton-beacon.d.ts.map +1 -1
  139. package/dist/types/core/beacon/smt-beacon.d.ts +32 -12
  140. package/dist/types/core/beacon/smt-beacon.d.ts.map +1 -1
  141. package/dist/types/core/beacon/utils.d.ts +4 -4
  142. package/dist/types/core/beacon/utils.d.ts.map +1 -1
  143. package/dist/types/core/identifier.d.ts +10 -2
  144. package/dist/types/core/identifier.d.ts.map +1 -1
  145. package/dist/types/core/interfaces.d.ts +4 -4
  146. package/dist/types/core/interfaces.d.ts.map +1 -1
  147. package/dist/types/core/resolver.d.ts +19 -9
  148. package/dist/types/core/resolver.d.ts.map +1 -1
  149. package/dist/types/core/types.d.ts +6 -5
  150. package/dist/types/core/types.d.ts.map +1 -1
  151. package/dist/types/core/update.d.ts +5 -5
  152. package/dist/types/core/update.d.ts.map +1 -1
  153. package/dist/types/did-btcr2.d.ts +6 -6
  154. package/dist/types/did-btcr2.d.ts.map +1 -1
  155. package/dist/types/index.d.ts +9 -24
  156. package/dist/types/index.d.ts.map +1 -1
  157. package/dist/types/utils/appendix.d.ts +7 -7
  158. package/dist/types/utils/appendix.d.ts.map +1 -1
  159. package/dist/types/utils/did-document-builder.d.ts +3 -2
  160. package/dist/types/utils/did-document-builder.d.ts.map +1 -1
  161. package/dist/types/utils/did-document.d.ts +3 -3
  162. package/dist/types/utils/did-document.d.ts.map +1 -1
  163. package/package.json +35 -33
  164. package/src/core/aggregation/cohort.ts +247 -0
  165. package/src/core/aggregation/errors.ts +25 -0
  166. package/src/core/{beacon/aggregation/cohort → aggregation}/messages/base.ts +8 -3
  167. package/src/core/aggregation/messages/constants.ts +28 -0
  168. package/src/core/aggregation/messages/factories.ts +240 -0
  169. package/src/core/aggregation/messages/guards.ts +55 -0
  170. package/src/core/aggregation/messages/index.ts +4 -0
  171. package/src/core/aggregation/participant.ts +510 -0
  172. package/src/core/aggregation/phases.ts +82 -0
  173. package/src/core/aggregation/runner/events.ts +77 -0
  174. package/src/core/aggregation/runner/index.ts +4 -0
  175. package/src/core/aggregation/runner/participant-runner.ts +360 -0
  176. package/src/core/aggregation/runner/service-runner.ts +365 -0
  177. package/src/core/aggregation/runner/typed-emitter.ts +87 -0
  178. package/src/core/aggregation/service.ts +547 -0
  179. package/src/core/aggregation/signing-session.ts +209 -0
  180. package/src/core/aggregation/transport/didcomm.ts +42 -0
  181. package/src/core/aggregation/transport/error.ts +13 -0
  182. package/src/core/aggregation/transport/factory.ts +29 -0
  183. package/src/core/aggregation/transport/index.ts +5 -0
  184. package/src/core/aggregation/transport/nostr.ts +333 -0
  185. package/src/core/aggregation/transport/transport.ts +46 -0
  186. package/src/core/beacon/beacon.ts +126 -6
  187. package/src/core/beacon/cas-beacon.ts +39 -83
  188. package/src/core/beacon/error.ts +0 -12
  189. package/src/core/beacon/factory.ts +2 -2
  190. package/src/core/beacon/fee-estimator.ts +52 -0
  191. package/src/core/beacon/interfaces.ts +13 -4
  192. package/src/core/beacon/signal-discovery.ts +5 -4
  193. package/src/core/beacon/singleton-beacon.ts +21 -81
  194. package/src/core/beacon/smt-beacon.ts +113 -15
  195. package/src/core/beacon/utils.ts +6 -4
  196. package/src/core/identifier.ts +20 -2
  197. package/src/core/interfaces.ts +4 -4
  198. package/src/core/resolver.ts +84 -53
  199. package/src/core/types.ts +6 -5
  200. package/src/core/update.ts +11 -7
  201. package/src/did-btcr2.ts +12 -10
  202. package/src/index.ts +15 -29
  203. package/src/utils/appendix.ts +14 -16
  204. package/src/utils/did-document-builder.ts +3 -2
  205. package/src/utils/did-document.ts +10 -8
  206. package/dist/cjs/core/beacon/aggregation/cohort/index.js +0 -237
  207. package/dist/cjs/core/beacon/aggregation/cohort/index.js.map +0 -1
  208. package/dist/cjs/core/beacon/aggregation/cohort/messages/base.js +0 -26
  209. package/dist/cjs/core/beacon/aggregation/cohort/messages/base.js.map +0 -1
  210. package/dist/cjs/core/beacon/aggregation/cohort/messages/constants.js +0 -11
  211. package/dist/cjs/core/beacon/aggregation/cohort/messages/constants.js.map +0 -1
  212. package/dist/cjs/core/beacon/aggregation/cohort/messages/index.js +0 -98
  213. package/dist/cjs/core/beacon/aggregation/cohort/messages/index.js.map +0 -1
  214. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js +0 -31
  215. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js.map +0 -1
  216. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js +0 -29
  217. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js.map +0 -1
  218. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js +0 -27
  219. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js.map +0 -1
  220. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in.js +0 -23
  221. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in.js.map +0 -1
  222. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/subscribe.js +0 -28
  223. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/subscribe.js.map +0 -1
  224. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js +0 -29
  225. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js.map +0 -1
  226. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/authorization-request.js +0 -30
  227. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/authorization-request.js.map +0 -1
  228. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js +0 -30
  229. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js.map +0 -1
  230. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/request-signature.js +0 -30
  231. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/request-signature.js.map +0 -1
  232. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js +0 -31
  233. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js.map +0 -1
  234. package/dist/cjs/core/beacon/aggregation/cohort/status.js +0 -8
  235. package/dist/cjs/core/beacon/aggregation/cohort/status.js.map +0 -1
  236. package/dist/cjs/core/beacon/aggregation/communication/adapter/did-comm.js +0 -121
  237. package/dist/cjs/core/beacon/aggregation/communication/adapter/did-comm.js.map +0 -1
  238. package/dist/cjs/core/beacon/aggregation/communication/adapter/nostr.js +0 -246
  239. package/dist/cjs/core/beacon/aggregation/communication/adapter/nostr.js.map +0 -1
  240. package/dist/cjs/core/beacon/aggregation/communication/error.js +0 -12
  241. package/dist/cjs/core/beacon/aggregation/communication/error.js.map +0 -1
  242. package/dist/cjs/core/beacon/aggregation/communication/factory.js +0 -21
  243. package/dist/cjs/core/beacon/aggregation/communication/factory.js.map +0 -1
  244. package/dist/cjs/core/beacon/aggregation/communication/service.js +0 -2
  245. package/dist/cjs/core/beacon/aggregation/communication/service.js.map +0 -1
  246. package/dist/cjs/core/beacon/aggregation/coordinator.js +0 -343
  247. package/dist/cjs/core/beacon/aggregation/coordinator.js.map +0 -1
  248. package/dist/cjs/core/beacon/aggregation/participant.js +0 -435
  249. package/dist/cjs/core/beacon/aggregation/participant.js.map +0 -1
  250. package/dist/cjs/core/beacon/aggregation/session/index.js +0 -244
  251. package/dist/cjs/core/beacon/aggregation/session/index.js.map +0 -1
  252. package/dist/cjs/core/beacon/aggregation/session/status.js +0 -11
  253. package/dist/cjs/core/beacon/aggregation/session/status.js.map +0 -1
  254. package/dist/cjs/core/beacon/beacon.js +0 -25
  255. package/dist/cjs/core/beacon/beacon.js.map +0 -1
  256. package/dist/cjs/core/beacon/cas-beacon.js +0 -152
  257. package/dist/cjs/core/beacon/cas-beacon.js.map +0 -1
  258. package/dist/cjs/core/beacon/error.js +0 -37
  259. package/dist/cjs/core/beacon/error.js.map +0 -1
  260. package/dist/cjs/core/beacon/factory.js +0 -29
  261. package/dist/cjs/core/beacon/factory.js.map +0 -1
  262. package/dist/cjs/core/beacon/interfaces.js +0 -2
  263. package/dist/cjs/core/beacon/interfaces.js.map +0 -1
  264. package/dist/cjs/core/beacon/signal-discovery.js +0 -183
  265. package/dist/cjs/core/beacon/signal-discovery.js.map +0 -1
  266. package/dist/cjs/core/beacon/singleton-beacon.js +0 -107
  267. package/dist/cjs/core/beacon/singleton-beacon.js.map +0 -1
  268. package/dist/cjs/core/beacon/smt-beacon.js +0 -39
  269. package/dist/cjs/core/beacon/smt-beacon.js.map +0 -1
  270. package/dist/cjs/core/beacon/utils.js +0 -163
  271. package/dist/cjs/core/beacon/utils.js.map +0 -1
  272. package/dist/cjs/core/identifier.js +0 -248
  273. package/dist/cjs/core/identifier.js.map +0 -1
  274. package/dist/cjs/core/interfaces.js +0 -2
  275. package/dist/cjs/core/interfaces.js.map +0 -1
  276. package/dist/cjs/core/resolver.js +0 -476
  277. package/dist/cjs/core/resolver.js.map +0 -1
  278. package/dist/cjs/core/types.js +0 -2
  279. package/dist/cjs/core/types.js.map +0 -1
  280. package/dist/cjs/core/update.js +0 -112
  281. package/dist/cjs/core/update.js.map +0 -1
  282. package/dist/cjs/did-btcr2.js +0 -193
  283. package/dist/cjs/did-btcr2.js.map +0 -1
  284. package/dist/cjs/index.js.map +0 -1
  285. package/dist/cjs/utils/appendix.js +0 -203
  286. package/dist/cjs/utils/appendix.js.map +0 -1
  287. package/dist/cjs/utils/did-document-builder.js +0 -60
  288. package/dist/cjs/utils/did-document-builder.js.map +0 -1
  289. package/dist/cjs/utils/did-document.js +0 -424
  290. package/dist/cjs/utils/did-document.js.map +0 -1
  291. package/dist/esm/core/beacon/aggregation/cohort/index.js +0 -237
  292. package/dist/esm/core/beacon/aggregation/cohort/index.js.map +0 -1
  293. package/dist/esm/core/beacon/aggregation/cohort/messages/base.js.map +0 -1
  294. package/dist/esm/core/beacon/aggregation/cohort/messages/constants.js +0 -11
  295. package/dist/esm/core/beacon/aggregation/cohort/messages/constants.js.map +0 -1
  296. package/dist/esm/core/beacon/aggregation/cohort/messages/index.js +0 -98
  297. package/dist/esm/core/beacon/aggregation/cohort/messages/index.js.map +0 -1
  298. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js +0 -31
  299. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js.map +0 -1
  300. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js +0 -29
  301. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js.map +0 -1
  302. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js +0 -27
  303. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js.map +0 -1
  304. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in.js +0 -23
  305. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in.js.map +0 -1
  306. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/subscribe.js +0 -28
  307. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/subscribe.js.map +0 -1
  308. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js +0 -29
  309. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js.map +0 -1
  310. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/authorization-request.js +0 -30
  311. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/authorization-request.js.map +0 -1
  312. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js +0 -30
  313. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js.map +0 -1
  314. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/request-signature.js +0 -30
  315. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/request-signature.js.map +0 -1
  316. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js +0 -31
  317. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js.map +0 -1
  318. package/dist/esm/core/beacon/aggregation/cohort/status.js +0 -8
  319. package/dist/esm/core/beacon/aggregation/cohort/status.js.map +0 -1
  320. package/dist/esm/core/beacon/aggregation/communication/adapter/did-comm.js +0 -121
  321. package/dist/esm/core/beacon/aggregation/communication/adapter/did-comm.js.map +0 -1
  322. package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js +0 -246
  323. package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js.map +0 -1
  324. package/dist/esm/core/beacon/aggregation/communication/error.js +0 -12
  325. package/dist/esm/core/beacon/aggregation/communication/error.js.map +0 -1
  326. package/dist/esm/core/beacon/aggregation/communication/factory.js +0 -21
  327. package/dist/esm/core/beacon/aggregation/communication/factory.js.map +0 -1
  328. package/dist/esm/core/beacon/aggregation/communication/service.js +0 -2
  329. package/dist/esm/core/beacon/aggregation/communication/service.js.map +0 -1
  330. package/dist/esm/core/beacon/aggregation/coordinator.js +0 -343
  331. package/dist/esm/core/beacon/aggregation/coordinator.js.map +0 -1
  332. package/dist/esm/core/beacon/aggregation/participant.js +0 -435
  333. package/dist/esm/core/beacon/aggregation/participant.js.map +0 -1
  334. package/dist/esm/core/beacon/aggregation/session/index.js +0 -244
  335. package/dist/esm/core/beacon/aggregation/session/index.js.map +0 -1
  336. package/dist/esm/core/beacon/aggregation/session/status.js +0 -11
  337. package/dist/esm/core/beacon/aggregation/session/status.js.map +0 -1
  338. package/dist/types/core/beacon/aggregation/cohort/index.d.ts +0 -136
  339. package/dist/types/core/beacon/aggregation/cohort/index.d.ts.map +0 -1
  340. package/dist/types/core/beacon/aggregation/cohort/messages/base.d.ts.map +0 -1
  341. package/dist/types/core/beacon/aggregation/cohort/messages/constants.d.ts +0 -11
  342. package/dist/types/core/beacon/aggregation/cohort/messages/constants.d.ts.map +0 -1
  343. package/dist/types/core/beacon/aggregation/cohort/messages/index.d.ts +0 -65
  344. package/dist/types/core/beacon/aggregation/cohort/messages/index.d.ts.map +0 -1
  345. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.d.ts +0 -29
  346. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.d.ts.map +0 -1
  347. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts +0 -26
  348. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts.map +0 -1
  349. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.d.ts +0 -24
  350. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.d.ts.map +0 -1
  351. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in.d.ts +0 -20
  352. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in.d.ts.map +0 -1
  353. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/subscribe.d.ts +0 -25
  354. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/subscribe.d.ts.map +0 -1
  355. package/dist/types/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.d.ts +0 -25
  356. package/dist/types/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.d.ts.map +0 -1
  357. package/dist/types/core/beacon/aggregation/cohort/messages/sign/authorization-request.d.ts +0 -26
  358. package/dist/types/core/beacon/aggregation/cohort/messages/sign/authorization-request.d.ts.map +0 -1
  359. package/dist/types/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.d.ts +0 -26
  360. package/dist/types/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.d.ts.map +0 -1
  361. package/dist/types/core/beacon/aggregation/cohort/messages/sign/request-signature.d.ts +0 -26
  362. package/dist/types/core/beacon/aggregation/cohort/messages/sign/request-signature.d.ts.map +0 -1
  363. package/dist/types/core/beacon/aggregation/cohort/messages/sign/signature-authorization.d.ts +0 -27
  364. package/dist/types/core/beacon/aggregation/cohort/messages/sign/signature-authorization.d.ts.map +0 -1
  365. package/dist/types/core/beacon/aggregation/cohort/status.d.ts +0 -8
  366. package/dist/types/core/beacon/aggregation/cohort/status.d.ts.map +0 -1
  367. package/dist/types/core/beacon/aggregation/communication/adapter/did-comm.d.ts +0 -89
  368. package/dist/types/core/beacon/aggregation/communication/adapter/did-comm.d.ts.map +0 -1
  369. package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts +0 -103
  370. package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts.map +0 -1
  371. package/dist/types/core/beacon/aggregation/communication/error.d.ts.map +0 -1
  372. package/dist/types/core/beacon/aggregation/communication/factory.d.ts +0 -10
  373. package/dist/types/core/beacon/aggregation/communication/factory.d.ts.map +0 -1
  374. package/dist/types/core/beacon/aggregation/communication/service.d.ts +0 -36
  375. package/dist/types/core/beacon/aggregation/communication/service.d.ts.map +0 -1
  376. package/dist/types/core/beacon/aggregation/coordinator.d.ts +0 -116
  377. package/dist/types/core/beacon/aggregation/coordinator.d.ts.map +0 -1
  378. package/dist/types/core/beacon/aggregation/participant.d.ts +0 -192
  379. package/dist/types/core/beacon/aggregation/participant.d.ts.map +0 -1
  380. package/dist/types/core/beacon/aggregation/session/index.d.ts +0 -156
  381. package/dist/types/core/beacon/aggregation/session/index.d.ts.map +0 -1
  382. package/dist/types/core/beacon/aggregation/session/status.d.ts +0 -11
  383. package/dist/types/core/beacon/aggregation/session/status.d.ts.map +0 -1
  384. package/src/core/beacon/aggregation/cohort/index.ts +0 -304
  385. package/src/core/beacon/aggregation/cohort/messages/constants.ts +0 -12
  386. package/src/core/beacon/aggregation/cohort/messages/index.ts +0 -143
  387. package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.ts +0 -43
  388. package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.ts +0 -39
  389. package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.ts +0 -34
  390. package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in.ts +0 -33
  391. package/src/core/beacon/aggregation/cohort/messages/keygen/subscribe.ts +0 -35
  392. package/src/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.ts +0 -38
  393. package/src/core/beacon/aggregation/cohort/messages/sign/authorization-request.ts +0 -39
  394. package/src/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.ts +0 -39
  395. package/src/core/beacon/aggregation/cohort/messages/sign/request-signature.ts +0 -39
  396. package/src/core/beacon/aggregation/cohort/messages/sign/signature-authorization.ts +0 -40
  397. package/src/core/beacon/aggregation/cohort/status.ts +0 -7
  398. package/src/core/beacon/aggregation/communication/adapter/did-comm.ts +0 -147
  399. package/src/core/beacon/aggregation/communication/adapter/nostr.ts +0 -321
  400. package/src/core/beacon/aggregation/communication/error.ts +0 -13
  401. package/src/core/beacon/aggregation/communication/factory.ts +0 -25
  402. package/src/core/beacon/aggregation/communication/service.ts +0 -42
  403. package/src/core/beacon/aggregation/coordinator.ts +0 -415
  404. package/src/core/beacon/aggregation/participant.ts +0 -512
  405. package/src/core/beacon/aggregation/session/index.ts +0 -300
  406. package/src/core/beacon/aggregation/session/status.ts +0 -18
@@ -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,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AAC,CAAC;QAE9D,KAAI,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;YACxB,OAAO,CAAC,KAAK,CAAC,wBAAwB,KAAK,CAAC,EAAE,KAAM,CAA2B,CAAC,MAAM,EAAE,CAAC,CAAC;QAC5F,CAAC;QAED,IAAG,QAAQ,KAAK,CAAC,EAAE,CAAC;YAClB,MAAM,IAAI,qBAAqB,CAC7B,OAAO,OAAO,CAAC,MAAM,4BAA4B,KAAK,CAAC,EAAE,EAAE,EAC3D,eAAe,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAE,CAA2B,CAAC,MAAM,CAAC,CAAC,EAAE,CACjH,CAAC;QACJ,CAAC;IACH,CAAC;IAED,MAAM,CAAC,aAAa,CAAC,IAAY,EAAE,KAAc;QAC/C,IAAG,KAAK,YAAY,UAAU,EAAE,CAAC;YAC/B,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QACxC,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,IAAY,EAAE,KAAc;QAC9C,IAAG,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,SAAS,IAAK,KAAiC,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,CAAC,CAAC;AAUtE;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAgB,MAAM;IAC1B;;OAEG;IACM,OAAO,CAAgB;IAEhC,YAAY,OAAsB;QAChC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAkCD;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACO,KAAK,CAAC,qBAAqB,CACnC,WAAuB,EACvB,SAAmB,EACnB,OAA0B,EAC1B,OAA0B;QAE1B,MAAM,YAAY,GAAG,OAAO,EAAE,YAAY,IAAI,qBAAqB,CAAC;QAEpE,yDAAyD;QACzD,MAAM,cAAc,GAA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ACpD,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.
@@ -44,8 +40,8 @@ export class CASBeacon extends Beacon {
44
40
  // Extract the DID from the beacon service id (strip the #fragment)
45
41
  const did = this.service.id.split('#')[0];
46
42
  for (const signal of signals) {
47
- // Decode signal bytes from hex and re-encode to base64url for sidecar lookup
48
- const announcementHash = encode(decode(signal.signalBytes, 'hex'));
43
+ // Signal bytes are hex matches hex-keyed sidecar maps directly
44
+ const announcementHash = signal.signalBytes;
49
45
  // Look up the CAS Announcement in sidecar casMap
50
46
  const casAnnouncement = sidecar.casMap.get(announcementHash);
51
47
  if (!casAnnouncement) {
@@ -58,11 +54,13 @@ export class CASBeacon extends Beacon {
58
54
  continue;
59
55
  }
60
56
  // Look up this DID's update hash in the CAS Announcement
61
- const updateHash = casAnnouncement[did];
57
+ // Announcement values are base64urlnopad per spec — convert to hex for map lookup
58
+ const updateHashEncoded = casAnnouncement[did];
62
59
  // If no entry for this DID, this announcement doesn't contain an update for us — skip
63
- if (!updateHash) {
60
+ if (!updateHashEncoded) {
64
61
  continue;
65
62
  }
63
+ const updateHash = encode(decode(updateHashEncoded, 'base64urlnopad'), 'hex');
66
64
  // Look up the signed update in sidecar updateMap
67
65
  const signedUpdate = sidecar.updateMap.get(updateHash);
68
66
  if (!signedUpdate) {
@@ -81,71 +79,34 @@ export class CASBeacon extends Beacon {
81
79
  /**
82
80
  * Broadcasts a CAS Beacon signal to the Bitcoin network.
83
81
  *
84
- * Creates a CAS Announcement mapping the DID to the update hash, then broadcasts
85
- * the hash of the announcement via OP_RETURN. The CAS Announcement is distributed
86
- * 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}.
87
86
  *
88
87
  * @param {SignedBTCR2Update} signedUpdate The signed BTCR2 update to broadcast.
89
88
  * @param {KeyBytes} secretKey The secret key for signing the Bitcoin transaction.
90
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`.
91
92
  * @returns {Promise<SignedBTCR2Update>} The signed update that was broadcast.
92
- * @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.
93
94
  */
94
- async broadcastSignal(signedUpdate, secretKey, bitcoin) {
95
+ async broadcastSignal(signedUpdate, secretKey, bitcoin, options) {
95
96
  // Extract the DID from the beacon service id (strip the #fragment)
96
97
  const did = this.service.id.split('#')[0];
97
- // Hash the signed update (base64url for the CAS Announcement entry)
98
+ // Hash the signed update (base64urlnopad for the CAS Announcement entry per spec)
98
99
  const updateHash = canonicalHash(signedUpdate);
99
100
  // Create the CAS Announcement mapping this DID to its update hash
100
101
  const casAnnouncement = { [did]: updateHash };
101
- // TODO: Publish CAS Announcement to content-addressed store (e.g., IPFS via Helia)
102
102
  // Canonicalize and hash the CAS Announcement for the OP_RETURN output
103
103
  const announcementHash = hash(canonicalize(casAnnouncement));
104
- // Convert the serviceEndpoint to a bitcoin address by removing the 'bitcoin:' prefix
105
- const bitcoinAddress = this.service.serviceEndpoint.replace('bitcoin:', '');
106
- // Query the Bitcoin network for UTXOs associated with the bitcoinAddress
107
- const utxos = await bitcoin.rest.address.getUtxos(bitcoinAddress);
108
- // If no utxos are found, throw an error indicating the address is unfunded.
109
- if (!utxos.length) {
110
- 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);
111
109
  }
112
- // Sort utxos by block height and take the most recent one
113
- const utxo = utxos.sort((a, b) => b.status.block_height - a.status.block_height).shift();
114
- // If no utxos are found, throw an error.
115
- if (!utxo) {
116
- throw new CASBeaconError('Beacon bitcoin address unfunded or utxos unconfirmed.', 'UNFUNDED_BEACON_ADDRESS', { bitcoinAddress });
117
- }
118
- // Get the previous tx to the utxo being spent
119
- const prevTx = await bitcoin.rest.transaction.getHex(utxo.txid);
120
- // Construct a spend transaction
121
- const spendTx = new Psbt({ network: bitcoin.data })
122
- // Spend tx contains the utxo as its input
123
- .addInput({
124
- hash: utxo.txid,
125
- index: utxo.vout,
126
- nonWitnessUtxo: hexToBytes(prevTx)
127
- })
128
- // Add a change output minus a fee of 500 sats
129
- // TODO: calculate fee based on transaction vsize and current fee rates
130
- .addOutput({ address: bitcoinAddress, value: BigInt(utxo.value) - BigInt(500) })
131
- // Add an OP_RETURN output containing the CAS Announcement hash
132
- .addOutput({ script: script.compile([opcodes.OP_RETURN, announcementHash]), value: 0n });
133
- // Construct a key pair and PSBT signer from the secret key
134
- const keyPair = SchnorrKeyPair.fromSecret(secretKey);
135
- const signer = {
136
- publicKey: keyPair.publicKey.compressed,
137
- sign: (hash) => keyPair.secretKey.sign(hash, { scheme: 'ecdsa' }),
138
- };
139
- // Sign 0th input, finalize extract to hex in prep for broadcast
140
- const signedTx = spendTx.signInput(0, signer)
141
- .finalizeAllInputs()
142
- .extractTransaction()
143
- .toHex();
144
- // Broadcast spendTx to the Bitcoin network.
145
- const txid = await bitcoin.rest.transaction.send(signedTx);
146
- // Log the txid of the broadcasted transaction
147
- console.info(`CAS Beacon Signal Broadcasted with txid: ${txid}`);
148
- // Return the signed update
149
110
  return signedUpdate;
150
111
  }
151
112
  }
@@ -1 +1 @@
1
- {"version":3,"file":"cas-beacon.js","sourceRoot":"","sources":["../../../../src/core/beacon/cas-beacon.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAY,MAAM,mBAAmB,CAAC;AAEhG,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,MAA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