@did-btcr2/method 0.17.2 → 0.18.1

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 (366) hide show
  1. package/dist/browser.js +30127 -19554
  2. package/dist/browser.mjs +30126 -19553
  3. package/dist/cjs/core/beacon/aggregation/cohort/index.js +225 -0
  4. package/dist/cjs/core/beacon/aggregation/cohort/index.js.map +1 -0
  5. package/dist/{esm/core/beacon/aggregation → cjs/core/beacon/aggregation/cohort}/messages/base.js +3 -11
  6. package/dist/cjs/core/beacon/aggregation/cohort/messages/base.js.map +1 -0
  7. package/dist/cjs/core/beacon/aggregation/cohort/messages/constants.js +11 -0
  8. package/dist/cjs/core/beacon/aggregation/cohort/messages/constants.js.map +1 -0
  9. package/dist/cjs/core/beacon/aggregation/cohort/messages/index.js +98 -0
  10. package/dist/cjs/core/beacon/aggregation/cohort/messages/index.js.map +1 -0
  11. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js +30 -0
  12. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js.map +1 -0
  13. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js +28 -0
  14. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js.map +1 -0
  15. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js +26 -0
  16. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js.map +1 -0
  17. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in.js +22 -0
  18. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in.js.map +1 -0
  19. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/subscribe.js +27 -0
  20. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/subscribe.js.map +1 -0
  21. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js +28 -0
  22. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js.map +1 -0
  23. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/authorization-request.js +29 -0
  24. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/authorization-request.js.map +1 -0
  25. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js +29 -0
  26. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js.map +1 -0
  27. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/request-signature.js +29 -0
  28. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/request-signature.js.map +1 -0
  29. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js +30 -0
  30. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js.map +1 -0
  31. package/dist/cjs/core/beacon/aggregation/cohort/status.js.map +1 -0
  32. package/dist/cjs/core/beacon/aggregation/communication/adapter/did-comm.js +126 -0
  33. package/dist/cjs/core/beacon/aggregation/communication/adapter/did-comm.js.map +1 -0
  34. package/dist/cjs/core/beacon/aggregation/communication/adapter/nostr.js +230 -0
  35. package/dist/cjs/core/beacon/aggregation/communication/adapter/nostr.js.map +1 -0
  36. package/dist/cjs/core/beacon/aggregation/communication/error.js +12 -0
  37. package/dist/cjs/core/beacon/aggregation/communication/error.js.map +1 -0
  38. package/dist/cjs/core/beacon/aggregation/communication/factory.js +21 -0
  39. package/dist/cjs/core/beacon/aggregation/communication/factory.js.map +1 -0
  40. package/dist/cjs/core/beacon/aggregation/communication/service.js.map +1 -0
  41. package/dist/cjs/core/beacon/aggregation/coordinator.js +282 -56
  42. package/dist/cjs/core/beacon/aggregation/coordinator.js.map +1 -1
  43. package/dist/cjs/core/beacon/aggregation/participant.js +435 -1
  44. package/dist/cjs/core/beacon/aggregation/participant.js.map +1 -1
  45. package/dist/cjs/core/beacon/aggregation/session/index.js +233 -0
  46. package/dist/cjs/core/beacon/aggregation/session/index.js.map +1 -0
  47. package/dist/cjs/core/beacon/aggregation/session/status.js +11 -0
  48. package/dist/cjs/core/beacon/aggregation/session/status.js.map +1 -0
  49. package/dist/cjs/core/beacon/cid-aggregate.js.map +1 -1
  50. package/dist/cjs/core/beacon/error.js +37 -0
  51. package/dist/cjs/core/beacon/error.js.map +1 -0
  52. package/dist/cjs/core/beacon/factory.js.map +1 -1
  53. package/dist/cjs/core/beacon/singleton.js +8 -5
  54. package/dist/cjs/core/beacon/singleton.js.map +1 -1
  55. package/dist/cjs/core/beacon/smt-aggregate.js.map +1 -1
  56. package/dist/cjs/{utils/beacons.js → core/beacon/utils.js} +4 -4
  57. package/dist/cjs/core/beacon/utils.js.map +1 -0
  58. package/dist/cjs/core/crud/read.js +2 -9
  59. package/dist/cjs/core/crud/read.js.map +1 -1
  60. package/dist/cjs/core/crud/update.js +18 -19
  61. package/dist/cjs/core/crud/update.js.map +1 -1
  62. package/dist/{esm/utils → cjs/core}/identifier.js +18 -3
  63. package/dist/cjs/core/identifier.js.map +1 -0
  64. package/dist/cjs/did-btcr2.js +2 -2
  65. package/dist/cjs/did-btcr2.js.map +1 -1
  66. package/dist/cjs/index.js +28 -6
  67. package/dist/cjs/index.js.map +1 -1
  68. package/dist/cjs/interfaces/beacon.js.map +1 -1
  69. package/dist/cjs/utils/appendix.js +2 -3
  70. package/dist/cjs/utils/appendix.js.map +1 -1
  71. package/dist/cjs/utils/did-document.js +4 -6
  72. package/dist/cjs/utils/did-document.js.map +1 -1
  73. package/dist/cjs/utils/types.js +2 -0
  74. package/dist/cjs/utils/types.js.map +1 -0
  75. package/dist/esm/core/beacon/aggregation/cohort/index.js +225 -0
  76. package/dist/esm/core/beacon/aggregation/cohort/index.js.map +1 -0
  77. package/dist/{cjs/core/beacon/aggregation → esm/core/beacon/aggregation/cohort}/messages/base.js +3 -11
  78. package/dist/esm/core/beacon/aggregation/cohort/messages/base.js.map +1 -0
  79. package/dist/esm/core/beacon/aggregation/cohort/messages/constants.js +11 -0
  80. package/dist/esm/core/beacon/aggregation/cohort/messages/constants.js.map +1 -0
  81. package/dist/esm/core/beacon/aggregation/cohort/messages/index.js +98 -0
  82. package/dist/esm/core/beacon/aggregation/cohort/messages/index.js.map +1 -0
  83. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js +30 -0
  84. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js.map +1 -0
  85. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js +28 -0
  86. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js.map +1 -0
  87. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js +26 -0
  88. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js.map +1 -0
  89. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in.js +22 -0
  90. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in.js.map +1 -0
  91. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/subscribe.js +27 -0
  92. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/subscribe.js.map +1 -0
  93. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js +28 -0
  94. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js.map +1 -0
  95. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/authorization-request.js +29 -0
  96. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/authorization-request.js.map +1 -0
  97. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js +29 -0
  98. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js.map +1 -0
  99. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/request-signature.js +29 -0
  100. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/request-signature.js.map +1 -0
  101. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js +30 -0
  102. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js.map +1 -0
  103. package/dist/esm/core/beacon/aggregation/cohort/status.js.map +1 -0
  104. package/dist/esm/core/beacon/aggregation/communication/adapter/did-comm.js +126 -0
  105. package/dist/esm/core/beacon/aggregation/communication/adapter/did-comm.js.map +1 -0
  106. package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js +230 -0
  107. package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js.map +1 -0
  108. package/dist/esm/core/beacon/aggregation/communication/error.js +12 -0
  109. package/dist/esm/core/beacon/aggregation/communication/error.js.map +1 -0
  110. package/dist/esm/core/beacon/aggregation/communication/factory.js +21 -0
  111. package/dist/esm/core/beacon/aggregation/communication/factory.js.map +1 -0
  112. package/dist/esm/core/beacon/aggregation/communication/service.js.map +1 -0
  113. package/dist/esm/core/beacon/aggregation/coordinator.js +282 -56
  114. package/dist/esm/core/beacon/aggregation/coordinator.js.map +1 -1
  115. package/dist/esm/core/beacon/aggregation/participant.js +435 -1
  116. package/dist/esm/core/beacon/aggregation/participant.js.map +1 -1
  117. package/dist/esm/core/beacon/aggregation/session/index.js +233 -0
  118. package/dist/esm/core/beacon/aggregation/session/index.js.map +1 -0
  119. package/dist/esm/core/beacon/aggregation/session/status.js +11 -0
  120. package/dist/esm/core/beacon/aggregation/session/status.js.map +1 -0
  121. package/dist/esm/core/beacon/cid-aggregate.js.map +1 -1
  122. package/dist/esm/core/beacon/error.js +37 -0
  123. package/dist/esm/core/beacon/error.js.map +1 -0
  124. package/dist/esm/core/beacon/factory.js.map +1 -1
  125. package/dist/esm/core/beacon/singleton.js +8 -5
  126. package/dist/esm/core/beacon/singleton.js.map +1 -1
  127. package/dist/esm/core/beacon/smt-aggregate.js.map +1 -1
  128. package/dist/esm/{utils/beacons.js → core/beacon/utils.js} +4 -4
  129. package/dist/esm/core/beacon/utils.js.map +1 -0
  130. package/dist/esm/core/crud/read.js +2 -9
  131. package/dist/esm/core/crud/read.js.map +1 -1
  132. package/dist/esm/core/crud/update.js +18 -19
  133. package/dist/esm/core/crud/update.js.map +1 -1
  134. package/dist/{cjs/utils → esm/core}/identifier.js +18 -3
  135. package/dist/esm/core/identifier.js.map +1 -0
  136. package/dist/esm/did-btcr2.js +2 -2
  137. package/dist/esm/did-btcr2.js.map +1 -1
  138. package/dist/esm/index.js +28 -6
  139. package/dist/esm/index.js.map +1 -1
  140. package/dist/esm/interfaces/beacon.js.map +1 -1
  141. package/dist/esm/utils/appendix.js +2 -3
  142. package/dist/esm/utils/appendix.js.map +1 -1
  143. package/dist/esm/utils/did-document.js +4 -6
  144. package/dist/esm/utils/did-document.js.map +1 -1
  145. package/dist/esm/utils/types.js +2 -0
  146. package/dist/esm/utils/types.js.map +1 -0
  147. package/dist/types/core/beacon/aggregation/cohort/index.d.ts +135 -0
  148. package/dist/types/core/beacon/aggregation/cohort/index.d.ts.map +1 -0
  149. package/dist/types/core/beacon/aggregation/{messages → cohort/messages}/base.d.ts +13 -8
  150. package/dist/types/core/beacon/aggregation/cohort/messages/base.d.ts.map +1 -0
  151. package/dist/types/core/beacon/aggregation/cohort/messages/constants.d.ts +10 -0
  152. package/dist/types/core/beacon/aggregation/cohort/messages/constants.d.ts.map +1 -0
  153. package/dist/types/core/beacon/aggregation/cohort/messages/index.d.ts +64 -0
  154. package/dist/types/core/beacon/aggregation/cohort/messages/index.d.ts.map +1 -0
  155. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.d.ts +28 -0
  156. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.d.ts.map +1 -0
  157. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts +26 -0
  158. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts.map +1 -0
  159. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.d.ts +23 -0
  160. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.d.ts.map +1 -0
  161. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in.d.ts +19 -0
  162. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in.d.ts.map +1 -0
  163. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/subscribe.d.ts +24 -0
  164. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/subscribe.d.ts.map +1 -0
  165. package/dist/types/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.d.ts +24 -0
  166. package/dist/types/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.d.ts.map +1 -0
  167. package/dist/types/core/beacon/aggregation/cohort/messages/sign/authorization-request.d.ts +25 -0
  168. package/dist/types/core/beacon/aggregation/cohort/messages/sign/authorization-request.d.ts.map +1 -0
  169. package/dist/types/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.d.ts +25 -0
  170. package/dist/types/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.d.ts.map +1 -0
  171. package/dist/types/core/beacon/aggregation/cohort/messages/sign/request-signature.d.ts +25 -0
  172. package/dist/types/core/beacon/aggregation/cohort/messages/sign/request-signature.d.ts.map +1 -0
  173. package/dist/types/core/beacon/aggregation/cohort/messages/sign/signature-authorization.d.ts +26 -0
  174. package/dist/types/core/beacon/aggregation/cohort/messages/sign/signature-authorization.d.ts.map +1 -0
  175. package/dist/types/core/beacon/aggregation/cohort/status.d.ts.map +1 -0
  176. package/dist/types/core/beacon/aggregation/communication/adapter/did-comm.d.ts +88 -0
  177. package/dist/types/core/beacon/aggregation/communication/adapter/did-comm.d.ts.map +1 -0
  178. package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts +93 -0
  179. package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts.map +1 -0
  180. package/dist/types/core/beacon/aggregation/communication/error.d.ts +7 -0
  181. package/dist/types/core/beacon/aggregation/communication/error.d.ts.map +1 -0
  182. package/dist/types/core/beacon/aggregation/communication/factory.d.ts +9 -0
  183. package/dist/types/core/beacon/aggregation/communication/factory.d.ts.map +1 -0
  184. package/dist/types/core/beacon/aggregation/communication/service.d.ts +35 -0
  185. package/dist/types/core/beacon/aggregation/communication/service.d.ts.map +1 -0
  186. package/dist/types/core/beacon/aggregation/coordinator.d.ts +79 -26
  187. package/dist/types/core/beacon/aggregation/coordinator.d.ts.map +1 -1
  188. package/dist/types/core/beacon/aggregation/participant.d.ts +190 -0
  189. package/dist/types/core/beacon/aggregation/participant.d.ts.map +1 -1
  190. package/dist/types/core/beacon/aggregation/session/index.d.ts +155 -0
  191. package/dist/types/core/beacon/aggregation/session/index.d.ts.map +1 -0
  192. package/dist/types/core/beacon/aggregation/session/status.d.ts +10 -0
  193. package/dist/types/core/beacon/aggregation/session/status.d.ts.map +1 -0
  194. package/dist/types/core/beacon/cid-aggregate.d.ts +3 -4
  195. package/dist/types/core/beacon/cid-aggregate.d.ts.map +1 -1
  196. package/dist/types/core/beacon/error.d.ts +22 -0
  197. package/dist/types/core/beacon/error.d.ts.map +1 -0
  198. package/dist/types/core/beacon/factory.d.ts +2 -3
  199. package/dist/types/core/beacon/factory.d.ts.map +1 -1
  200. package/dist/types/core/beacon/singleton.d.ts +2 -3
  201. package/dist/types/core/beacon/singleton.d.ts.map +1 -1
  202. package/dist/types/core/beacon/smt-aggregate.d.ts +3 -4
  203. package/dist/types/core/beacon/smt-aggregate.d.ts.map +1 -1
  204. package/dist/types/{utils/beacons.d.ts → core/beacon/utils.d.ts} +3 -3
  205. package/dist/types/core/beacon/utils.d.ts.map +1 -0
  206. package/dist/types/core/crud/read.d.ts +3 -3
  207. package/dist/types/core/crud/read.d.ts.map +1 -1
  208. package/dist/types/core/crud/update.d.ts +1 -1
  209. package/dist/types/core/crud/update.d.ts.map +1 -1
  210. package/dist/types/{utils → core}/identifier.d.ts +24 -3
  211. package/dist/types/core/identifier.d.ts.map +1 -0
  212. package/dist/types/did-btcr2.d.ts +1 -1
  213. package/dist/types/did-btcr2.d.ts.map +1 -1
  214. package/dist/types/index.d.ts +28 -6
  215. package/dist/types/index.d.ts.map +1 -1
  216. package/dist/types/interfaces/beacon.d.ts +65 -5
  217. package/dist/types/interfaces/beacon.d.ts.map +1 -1
  218. package/dist/types/interfaces/crud.d.ts +1 -1
  219. package/dist/types/interfaces/crud.d.ts.map +1 -1
  220. package/dist/types/utils/appendix.d.ts +2 -10
  221. package/dist/types/utils/appendix.d.ts.map +1 -1
  222. package/dist/types/utils/did-document-builder.d.ts +1 -1
  223. package/dist/types/utils/did-document-builder.d.ts.map +1 -1
  224. package/dist/types/utils/did-document.d.ts +1 -1
  225. package/dist/types/utils/did-document.d.ts.map +1 -1
  226. package/dist/types/{types/crud.d.ts → utils/types.d.ts} +2 -2
  227. package/dist/types/utils/types.d.ts.map +1 -0
  228. package/package.json +5 -4
  229. package/src/core/beacon/aggregation/cohort/index.ts +292 -0
  230. package/src/core/beacon/aggregation/{messages → cohort/messages}/base.ts +14 -16
  231. package/src/core/beacon/aggregation/cohort/messages/constants.ts +12 -0
  232. package/src/core/beacon/aggregation/cohort/messages/index.ts +143 -0
  233. package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.ts +43 -0
  234. package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.ts +39 -0
  235. package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.ts +34 -0
  236. package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in.ts +33 -0
  237. package/src/core/beacon/aggregation/cohort/messages/keygen/subscribe.ts +35 -0
  238. package/src/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.ts +38 -0
  239. package/src/core/beacon/aggregation/cohort/messages/sign/authorization-request.ts +39 -0
  240. package/src/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.ts +39 -0
  241. package/src/core/beacon/aggregation/cohort/messages/sign/request-signature.ts +39 -0
  242. package/src/core/beacon/aggregation/cohort/messages/sign/signature-authorization.ts +40 -0
  243. package/src/core/beacon/aggregation/communication/adapter/did-comm.ts +153 -0
  244. package/src/core/beacon/aggregation/communication/adapter/nostr.ts +300 -0
  245. package/src/core/beacon/aggregation/communication/error.ts +13 -0
  246. package/src/core/beacon/aggregation/communication/factory.ts +25 -0
  247. package/src/core/beacon/aggregation/communication/service.ts +42 -0
  248. package/src/core/beacon/aggregation/coordinator.ts +338 -67
  249. package/src/core/beacon/aggregation/participant.ts +512 -0
  250. package/src/core/beacon/aggregation/session/index.ts +289 -0
  251. package/src/core/beacon/aggregation/session/status.ts +18 -0
  252. package/src/core/beacon/cid-aggregate.ts +4 -5
  253. package/src/core/beacon/error.ts +44 -0
  254. package/src/core/beacon/factory.ts +2 -3
  255. package/src/core/beacon/singleton.ts +10 -8
  256. package/src/core/beacon/smt-aggregate.ts +4 -5
  257. package/src/{utils/beacons.ts → core/beacon/utils.ts} +5 -5
  258. package/src/core/crud/read.ts +7 -16
  259. package/src/core/crud/update.ts +25 -22
  260. package/src/{utils → core}/identifier.ts +35 -5
  261. package/src/did-btcr2.ts +4 -4
  262. package/src/index.ts +36 -8
  263. package/src/interfaces/beacon.ts +75 -5
  264. package/src/interfaces/crud.ts +1 -1
  265. package/src/utils/appendix.ts +3 -11
  266. package/src/utils/did-document-builder.ts +1 -1
  267. package/src/utils/did-document.ts +4 -7
  268. package/src/{types/crud.ts → utils/types.ts} +2 -2
  269. package/dist/cjs/core/beacon/aggregation/messages/advert.js +0 -24
  270. package/dist/cjs/core/beacon/aggregation/messages/advert.js.map +0 -1
  271. package/dist/cjs/core/beacon/aggregation/messages/base.js.map +0 -1
  272. package/dist/cjs/core/beacon/aggregation/messages/cohort-set.js +0 -25
  273. package/dist/cjs/core/beacon/aggregation/messages/cohort-set.js.map +0 -1
  274. package/dist/cjs/core/beacon/aggregation/messages/keygen.js +0 -8
  275. package/dist/cjs/core/beacon/aggregation/messages/keygen.js.map +0 -1
  276. package/dist/cjs/core/beacon/aggregation/messages/opt-in.js +0 -23
  277. package/dist/cjs/core/beacon/aggregation/messages/opt-in.js.map +0 -1
  278. package/dist/cjs/core/beacon/aggregation/messages/sign.js +0 -7
  279. package/dist/cjs/core/beacon/aggregation/messages/sign.js.map +0 -1
  280. package/dist/cjs/core/beacon/aggregation/models/cohort/index.js +0 -92
  281. package/dist/cjs/core/beacon/aggregation/models/cohort/index.js.map +0 -1
  282. package/dist/cjs/core/beacon/aggregation/models/cohort/status.js.map +0 -1
  283. package/dist/cjs/core/beacon/aggregation/protocol/nostr.js +0 -57
  284. package/dist/cjs/core/beacon/aggregation/protocol/nostr.js.map +0 -1
  285. package/dist/cjs/core/beacon/aggregation/protocol/service.js.map +0 -1
  286. package/dist/cjs/core/key-manager/index.js +0 -290
  287. package/dist/cjs/core/key-manager/index.js.map +0 -1
  288. package/dist/cjs/core/key-manager/interface.js +0 -2
  289. package/dist/cjs/core/key-manager/interface.js.map +0 -1
  290. package/dist/cjs/interfaces/ibeacon.js +0 -2
  291. package/dist/cjs/interfaces/ibeacon.js.map +0 -1
  292. package/dist/cjs/types/crud.js +0 -2
  293. package/dist/cjs/types/crud.js.map +0 -1
  294. package/dist/cjs/utils/beacons.js.map +0 -1
  295. package/dist/cjs/utils/identifier.js.map +0 -1
  296. package/dist/esm/core/beacon/aggregation/messages/advert.js +0 -24
  297. package/dist/esm/core/beacon/aggregation/messages/advert.js.map +0 -1
  298. package/dist/esm/core/beacon/aggregation/messages/base.js.map +0 -1
  299. package/dist/esm/core/beacon/aggregation/messages/cohort-set.js +0 -25
  300. package/dist/esm/core/beacon/aggregation/messages/cohort-set.js.map +0 -1
  301. package/dist/esm/core/beacon/aggregation/messages/keygen.js +0 -8
  302. package/dist/esm/core/beacon/aggregation/messages/keygen.js.map +0 -1
  303. package/dist/esm/core/beacon/aggregation/messages/opt-in.js +0 -23
  304. package/dist/esm/core/beacon/aggregation/messages/opt-in.js.map +0 -1
  305. package/dist/esm/core/beacon/aggregation/messages/sign.js +0 -7
  306. package/dist/esm/core/beacon/aggregation/messages/sign.js.map +0 -1
  307. package/dist/esm/core/beacon/aggregation/models/cohort/index.js +0 -92
  308. package/dist/esm/core/beacon/aggregation/models/cohort/index.js.map +0 -1
  309. package/dist/esm/core/beacon/aggregation/models/cohort/status.js.map +0 -1
  310. package/dist/esm/core/beacon/aggregation/protocol/nostr.js +0 -57
  311. package/dist/esm/core/beacon/aggregation/protocol/nostr.js.map +0 -1
  312. package/dist/esm/core/beacon/aggregation/protocol/service.js.map +0 -1
  313. package/dist/esm/core/key-manager/index.js +0 -290
  314. package/dist/esm/core/key-manager/index.js.map +0 -1
  315. package/dist/esm/core/key-manager/interface.js +0 -2
  316. package/dist/esm/core/key-manager/interface.js.map +0 -1
  317. package/dist/esm/interfaces/ibeacon.js +0 -2
  318. package/dist/esm/interfaces/ibeacon.js.map +0 -1
  319. package/dist/esm/types/crud.js +0 -2
  320. package/dist/esm/types/crud.js.map +0 -1
  321. package/dist/esm/utils/beacons.js.map +0 -1
  322. package/dist/esm/utils/identifier.js.map +0 -1
  323. package/dist/types/core/beacon/aggregation/messages/advert.d.ts +0 -22
  324. package/dist/types/core/beacon/aggregation/messages/advert.d.ts.map +0 -1
  325. package/dist/types/core/beacon/aggregation/messages/base.d.ts.map +0 -1
  326. package/dist/types/core/beacon/aggregation/messages/cohort-set.d.ts +0 -23
  327. package/dist/types/core/beacon/aggregation/messages/cohort-set.d.ts.map +0 -1
  328. package/dist/types/core/beacon/aggregation/messages/keygen.d.ts +0 -6
  329. package/dist/types/core/beacon/aggregation/messages/keygen.d.ts.map +0 -1
  330. package/dist/types/core/beacon/aggregation/messages/opt-in.d.ts +0 -22
  331. package/dist/types/core/beacon/aggregation/messages/opt-in.d.ts.map +0 -1
  332. package/dist/types/core/beacon/aggregation/messages/sign.d.ts +0 -5
  333. package/dist/types/core/beacon/aggregation/messages/sign.d.ts.map +0 -1
  334. package/dist/types/core/beacon/aggregation/models/cohort/index.d.ts +0 -77
  335. package/dist/types/core/beacon/aggregation/models/cohort/index.d.ts.map +0 -1
  336. package/dist/types/core/beacon/aggregation/models/cohort/status.d.ts.map +0 -1
  337. package/dist/types/core/beacon/aggregation/protocol/nostr.d.ts +0 -36
  338. package/dist/types/core/beacon/aggregation/protocol/nostr.d.ts.map +0 -1
  339. package/dist/types/core/beacon/aggregation/protocol/service.d.ts +0 -6
  340. package/dist/types/core/beacon/aggregation/protocol/service.d.ts.map +0 -1
  341. package/dist/types/core/key-manager/index.d.ts +0 -145
  342. package/dist/types/core/key-manager/index.d.ts.map +0 -1
  343. package/dist/types/core/key-manager/interface.d.ts +0 -113
  344. package/dist/types/core/key-manager/interface.d.ts.map +0 -1
  345. package/dist/types/interfaces/ibeacon.d.ts +0 -65
  346. package/dist/types/interfaces/ibeacon.d.ts.map +0 -1
  347. package/dist/types/types/crud.d.ts.map +0 -1
  348. package/dist/types/utils/beacons.d.ts.map +0 -1
  349. package/dist/types/utils/identifier.d.ts.map +0 -1
  350. package/src/core/beacon/aggregation/messages/advert.ts +0 -36
  351. package/src/core/beacon/aggregation/messages/cohort-set.ts +0 -37
  352. package/src/core/beacon/aggregation/messages/keygen.ts +0 -8
  353. package/src/core/beacon/aggregation/messages/opt-in.ts +0 -35
  354. package/src/core/beacon/aggregation/messages/sign.ts +0 -7
  355. package/src/core/beacon/aggregation/models/cohort/index.ts +0 -112
  356. package/src/core/beacon/aggregation/protocol/nostr.ts +0 -81
  357. package/src/core/beacon/aggregation/protocol/service.ts +0 -6
  358. package/src/core/key-manager/index.ts +0 -364
  359. package/src/core/key-manager/interface.ts +0 -129
  360. package/src/interfaces/ibeacon.ts +0 -75
  361. /package/dist/cjs/core/beacon/aggregation/{models/cohort → cohort}/status.js +0 -0
  362. /package/dist/cjs/core/beacon/aggregation/{protocol → communication}/service.js +0 -0
  363. /package/dist/esm/core/beacon/aggregation/{models/cohort → cohort}/status.js +0 -0
  364. /package/dist/esm/core/beacon/aggregation/{protocol → communication}/service.js +0 -0
  365. /package/dist/types/core/beacon/aggregation/{models/cohort → cohort}/status.d.ts +0 -0
  366. /package/src/core/beacon/aggregation/{models/cohort → cohort}/status.ts +0 -0
@@ -1,7 +1,17 @@
1
- import { OptInMessage } from './messages/opt-in.js';
2
- import { OPT_IN, SUBSCRIBE, SUBSCRIBE_ACCEPT } from './messages/keygen.js';
3
- import { NostrAdapter } from './protocol/nostr.js';
4
- import { NONCE_CONTRIBUTION, REQUEST_SIGNATURE, SIGNATURE_AUTHORIZATION } from './messages/sign.js';
1
+ import { Logger } from '@did-btcr2/common';
2
+ import { BeaconCoordinatorError } from '../error.js';
3
+ import { AggregateBeaconCohort } from './cohort/index.js';
4
+ import { BEACON_COHORT_ADVERT, BEACON_COHORT_NONCE_CONTRIBUTION, BEACON_COHORT_OPT_IN, BEACON_COHORT_OPT_IN_ACCEPT, BEACON_COHORT_REQUEST_SIGNATURE, BEACON_COHORT_SIGNATURE_AUTHORIZATION } from './cohort/messages/constants.js';
5
+ import { BeaconCohortAdvertMessage } from './cohort/messages/keygen/cohort-advert.js';
6
+ import { BeaconCohortReadyMessage } from './cohort/messages/keygen/cohort-ready.js';
7
+ import { BeaconCohortOptInMessage } from './cohort/messages/keygen/opt-in.js';
8
+ import { BeaconCohortAggregatedNonceMessage } from './cohort/messages/sign/aggregated-nonce.js';
9
+ import { BeaconCohortNonceContributionMessage } from './cohort/messages/sign/nonce-contribution.js';
10
+ import { BeaconCohortRequestSignatureMessage } from './cohort/messages/sign/request-signature.js';
11
+ import { BeaconCohortSignatureAuthorizationMessage } from './cohort/messages/sign/signature-authorization.js';
12
+ import { NostrAdapter } from './communication/adapter/nostr.js';
13
+ import { CommunicationFactory } from './communication/factory.js';
14
+ import { SIGNING_SESSION_STATUS } from './session/status.js';
5
15
  /**
6
16
  * The BeaconCoordinator class is responsible for managing the coordination of beacon aggregation.
7
17
  * @class BeaconCoordinator
@@ -12,109 +22,325 @@ export class BeaconCoordinator {
12
22
  * The name of the BeaconCoordinator service.
13
23
  * @type {string}
14
24
  */
15
- name = 'BeaconCoordinator';
25
+ name;
16
26
  /**
17
27
  * The DID of the BeaconCoordinator.
18
28
  * @type {Array<string>}
19
29
  */
20
- did = '';
30
+ did;
21
31
  /**
22
- * The protocol service used for communication.
23
- * @type {ProtocolService}
32
+ * The communication protocol used by the BeaconCoordinator.
33
+ * @type {CommunicationService}
24
34
  */
25
35
  protocol;
26
36
  /**
27
- * List of subscribers to the BeaconCoordinator service.
37
+ * List of subscribers engaged in a Musig2 Cohort signing session with the BeaconCoordinator.
28
38
  * @type {Array<string>}
29
39
  */
30
40
  cohorts = [];
31
41
  /**
32
- * List of subscribers to the BeaconCoordinator service.
33
- * @type {Array<string>}
42
+ * Active signing sessions for the BeaconCoordinator.
43
+ * @type {Record<string, BeaconCohortSigningSession>}
34
44
  */
35
- subscribers = [];
45
+ activeSigningSessions = new Map();
36
46
  /**
37
47
  * Constructs a new BeaconCoordinator instance.
38
- * @param {ProtocolService} protocol The protocol service used for communication.
39
- * @param {string} [did] Optional DID to use for the coordinator. If not provided, a new DID will be generated.
48
+ * @param {BeaconCoordinatorParams} params The parameters for the coordinator.
49
+ * @param {CommunicationService} params.protocol The protocol service used for communication.
50
+ * @param {string} [params.name] Optional name for the coordinator. If not provided, a default name will be generated.
51
+ * @param {string} [params.did] Optional DID to use for the coordinator. If not provided, a new DID will be generated.
52
+ * @param {ServiceAdapterIdentity<RawKeyPair>} params.keys The keys used for cryptographic operations.
40
53
  */
41
- constructor(protocol, did) {
42
- this.protocol = protocol ?? new NostrAdapter();
43
- this.setup(did);
54
+ constructor(params) {
55
+ this.name = params.name || `btcr2-beacon-coordinator-${crypto.randomUUID()}`;
56
+ this.did = params.did;
57
+ this.protocol = params.protocol || new NostrAdapter();
58
+ this.protocol.setKeys(params.keys);
44
59
  }
45
60
  /**
46
- * Sets up the BeaconCoordinator by registering message handlers and optionally generating a DID.
61
+ * Setup and start the BeaconCoordinator communication protocol.
47
62
  * @returns {void}
48
63
  */
49
- setup(did) {
50
- this.did = did || this.protocol.generateIdentity();
51
- this.protocol.registerMessageHandler(SUBSCRIBE, this._handleSubscribe.bind(this));
52
- this.protocol.registerMessageHandler(OPT_IN, this._handleOptIn.bind(this));
53
- this.protocol.registerMessageHandler(REQUEST_SIGNATURE, this._handleSubscribe.bind(this));
54
- this.protocol.registerMessageHandler(NONCE_CONTRIBUTION, this._handleSubscribe.bind(this));
55
- this.protocol.registerMessageHandler(SIGNATURE_AUTHORIZATION, this._handleSubscribe.bind(this));
56
- }
57
- /**
58
- * Initializes the BeaconCoordinator by setting up the protocol and starting it.
59
- * @param {string} [did] Optional DID to use for the coordinator. If not provided, the existing DID will be used.
60
- */
61
- async initialize(did) {
62
- this.setup(did);
63
- await this.protocol.start();
64
- }
65
- /**
66
- * Handles subscription requests from other participants.
67
- * @param {Base} message The message containing the subscription request.
68
- * @returns {Promise<void>}
69
- */
70
- async _handleSubscribe(message) {
71
- const sender = message.from;
72
- if (!this.subscribers.includes(sender)) {
73
- this.subscribers.push(sender);
74
- await this.acceptSubscription(sender);
75
- }
64
+ start() {
65
+ Logger.info(`Setting up BeaconCoordinator ${this.name} (${this.did}) on ${this.protocol.name} ...`);
66
+ this.protocol.registerMessageHandler(BEACON_COHORT_OPT_IN, this._handleOptIn.bind(this));
67
+ this.protocol.registerMessageHandler(BEACON_COHORT_REQUEST_SIGNATURE, this._handleRequestSignature.bind(this));
68
+ this.protocol.registerMessageHandler(BEACON_COHORT_NONCE_CONTRIBUTION, this._handleNonceContribution.bind(this));
69
+ this.protocol.registerMessageHandler(BEACON_COHORT_SIGNATURE_AUTHORIZATION, this._handleSignatureAuthorization.bind(this));
70
+ this.protocol.start();
76
71
  }
77
72
  /**
78
73
  * Handles opt-in requests from participants to join a cohort.
79
- * @param {any} message The message containing the opt-in request.
74
+ * @param {OptInMessage} message The message containing the opt-in request.
80
75
  * @returns {Promise<void>}
81
76
  */
82
77
  async _handleOptIn(message) {
83
- const optIn = OptInMessage.fromJSON(message);
84
- const cohortId = optIn.cohortId;
78
+ const optIn = BeaconCohortOptInMessage.fromJSON(message);
79
+ const cohortId = optIn.body?.cohortId;
85
80
  const participant = optIn.from;
86
- const participantPk = optIn.participantPk;
81
+ const participantPk = optIn.body?.participantPk;
82
+ if (!cohortId || !participant || !participantPk) {
83
+ Logger.warn(`Invalid opt-in message from ${participant}: missing cohortId, participant or participantPk`);
84
+ return;
85
+ }
87
86
  const cohort = this.cohorts.find(c => c.id === cohortId);
88
87
  if (cohort && !cohort.participants.includes(participant)) {
89
88
  cohort.participants.push(participant);
90
89
  cohort.cohortKeys.push(participantPk);
91
90
  await this.acceptSubscription(participant);
91
+ // If the cohort has enough participants, start the key generation process.
92
92
  if (cohort.participants.length >= cohort.minParticipants) {
93
93
  await this._startKeyGeneration(cohort);
94
94
  }
95
95
  }
96
96
  }
97
+ /**
98
+ * Handles request signature messages from participants.
99
+ * @private
100
+ * @param {CohortRequestSignatureMessage} message The message containing the request signature.
101
+ * @returns {Promise<void>}
102
+ */
103
+ async _handleRequestSignature(message) {
104
+ const signatureRequest = BeaconCohortRequestSignatureMessage.fromJSON(message);
105
+ const cohortId = signatureRequest.body?.cohortId;
106
+ if (!cohortId) {
107
+ Logger.warn(`Signature request missing cohort ID from ${signatureRequest.from}`);
108
+ return;
109
+ }
110
+ const cohort = this.cohorts.find(c => c.id === cohortId);
111
+ if (!cohort) {
112
+ Logger.error(`Cohort with ID ${cohortId} not found.`);
113
+ return;
114
+ }
115
+ cohort.addSignatureRequest(signatureRequest);
116
+ Logger.info(`Received signature request from ${signatureRequest.from} for cohort ${cohortId}.`);
117
+ }
118
+ /**
119
+ * Handles nonce contribution messages from participants.
120
+ * @param {CohortNonceContributionMessage} message The message containing the nonce contribution.
121
+ * @returns {Promise<void>}
122
+ */
123
+ async _handleNonceContribution(message) {
124
+ // Cast message to NonceContributionMessage type.
125
+ const nonceContribMessage = BeaconCohortNonceContributionMessage.fromJSON(message);
126
+ const cohortId = nonceContribMessage.body?.cohortId;
127
+ if (!cohortId) {
128
+ Logger.warn(`Nonce contribution message missing cohort ID from ${nonceContribMessage.from}`);
129
+ return;
130
+ }
131
+ const sessionId = nonceContribMessage.body?.sessionId;
132
+ if (!sessionId) {
133
+ Logger.warn(`Nonce contribution message missing session ID from ${nonceContribMessage.from}`);
134
+ return;
135
+ }
136
+ // Get the signing session using the cohort ID from the message.
137
+ const signingSession = this.activeSigningSessions.get(cohortId || sessionId);
138
+ // If the signing session does not exist, log an error and return.
139
+ if (!signingSession) {
140
+ Logger.error(`Session ${cohortId || sessionId} not found.`);
141
+ return;
142
+ }
143
+ // If the message.cohortId does not match the signingSession.cohortId, throw an error.
144
+ if (cohortId !== signingSession.cohort.id) {
145
+ throw new BeaconCoordinatorError(`Nonce contribution for wrong cohort: ${signingSession.cohort.id} != ${cohortId}`, 'NONCE_CONTRIBUTION_ERROR', message);
146
+ }
147
+ const nonceContribution = nonceContribMessage.body?.nonceContribution;
148
+ if (!nonceContribution) {
149
+ Logger.warn(`Nonce contribution message missing nonce contribution from ${nonceContribMessage.from}`);
150
+ return;
151
+ }
152
+ // Add the nonce contribution to the signing session.
153
+ signingSession.addNonceContribution(nonceContribMessage.from, nonceContribution);
154
+ Logger.info(`Nonce contribution received from ${nonceContribMessage.from} for session ${sessionId}.`);
155
+ if (signingSession.status !== SIGNING_SESSION_STATUS.NONCE_CONTRIBUTIONS_RECEIVED) {
156
+ await this.sendAggregatedNonce(signingSession);
157
+ }
158
+ }
159
+ /**
160
+ * Handles signature authorization messages from participants.
161
+ * @param {Maybe<CohortSignatureAuthorizationMessage>} message The message containing the signature authorization request.
162
+ * @returns {Promise<void>}
163
+ */
164
+ async _handleSignatureAuthorization(message) {
165
+ const sigAuthMessage = BeaconCohortSignatureAuthorizationMessage.fromJSON(message);
166
+ const cohortId = sigAuthMessage.body?.cohortId;
167
+ if (!cohortId) {
168
+ Logger.warn(`Signature authorization message missing cohort ID from ${sigAuthMessage.from}`);
169
+ return;
170
+ }
171
+ const sessionId = sigAuthMessage.body?.sessionId;
172
+ if (!sessionId) {
173
+ Logger.warn(`Signature authorization message missing session ID from ${sigAuthMessage.from}`);
174
+ return;
175
+ }
176
+ const signingSession = this.activeSigningSessions.get(cohortId || sessionId);
177
+ if (!signingSession) {
178
+ Logger.error(`Session ${sessionId} not found.`);
179
+ return;
180
+ }
181
+ if (signingSession.id !== sessionId) {
182
+ throw new BeaconCoordinatorError(`Signature authorization for wrong session: ${signingSession.id} != ${sessionId}`, 'SIGNATURE_AUTHORIZATION_ERROR', message);
183
+ }
184
+ if (signingSession.status !== SIGNING_SESSION_STATUS.AWAITING_PARTIAL_SIGNATURES) {
185
+ throw new BeaconCoordinatorError(`Partial signature received but not expected. Current status: ${signingSession.status}`, 'SIGNATURE_AUTHORIZATION_ERROR', message);
186
+ }
187
+ const partialSignature = sigAuthMessage.body?.partialSignature;
188
+ if (!partialSignature) {
189
+ Logger.warn(`Signature authorization message missing partial signature from ${sigAuthMessage.from}`);
190
+ return;
191
+ }
192
+ // Add the signature authorization to the signing session.
193
+ signingSession.addPartialSignature(sigAuthMessage.from, partialSignature);
194
+ Logger.info(`Received partial signature from ${sigAuthMessage.from} for session ${sessionId}.`);
195
+ if (signingSession.partialSignatures.size === signingSession.cohort.participants.length) {
196
+ signingSession.status = SIGNING_SESSION_STATUS.PARTIAL_SIGNATURES_RECEIVED;
197
+ }
198
+ if (signingSession.status === SIGNING_SESSION_STATUS.PARTIAL_SIGNATURES_RECEIVED) {
199
+ const signature = await signingSession.generateFinalSignature();
200
+ Logger.info(`Final signature ${signature.toHex()} generated for session ${signingSession.id}`);
201
+ }
202
+ }
97
203
  /**
98
204
  * Starts the key generation process for a cohort once it has enough participants.
99
205
  * @param {Musig2Cohort} cohort The cohort for which to start key generation.
100
206
  * @returns {Promise<void>}
101
207
  */
102
208
  async _startKeyGeneration(cohort) {
209
+ Logger.info(`Starting key generation for cohort ${cohort.id} with participants: ${cohort.participants.join(', ')}`);
103
210
  cohort.finalize();
211
+ for (const participant of cohort.participants) {
212
+ const message = cohort.getCohortReadyMessage(participant, this.did);
213
+ Logger.info(`Sending BEACON_COHORT_READY message to ${participant}`);
214
+ await this.protocol.sendMessage(message, participant, this.did);
215
+ }
216
+ Logger.info(`Finished sending BEACON_COHORT_READY message to ${cohort.participants.length} participants`);
104
217
  }
105
218
  /**
106
219
  * Accepts a subscription request from a participant.
107
- * @param {string} sender The DID of the participant requesting the subscription.
220
+ * @param {string} participant The DID of the participant requesting the subscription.
108
221
  * @returns {Promise<void>}
109
222
  */
110
- async acceptSubscription(sender) {
111
- console.log(`Accepting subscription from ${sender}`);
112
- const response = {
113
- type: SUBSCRIBE_ACCEPT,
114
- to: sender,
223
+ async acceptSubscription(participant) {
224
+ Logger.info(`Accepting subscription from ${participant}`);
225
+ const message = {
226
+ type: BEACON_COHORT_OPT_IN_ACCEPT,
227
+ to: participant,
115
228
  from: this.did
116
229
  };
117
- await this.protocol.sendMessage(response, sender, this.did);
230
+ await this.protocol.sendMessage(message, this.did, participant);
231
+ }
232
+ /**
233
+ * Sends the aggregated nonce to all participants in the session.
234
+ * @param {BeaconCohortSigningSession} session The session containing the aggregated nonce.
235
+ * @returns {Promise<void>}
236
+ */
237
+ async sendAggregatedNonce(session) {
238
+ const aggregatedNonce = session.generateAggregatedNonce();
239
+ Logger.info(`Aggregated Nonces for session ${session.id}:`, aggregatedNonce);
240
+ session.status = SIGNING_SESSION_STATUS.AWAITING_PARTIAL_SIGNATURES;
241
+ for (const participant of session.cohort.participants) {
242
+ const message = new BeaconCohortAggregatedNonceMessage({
243
+ to: participant,
244
+ from: this.did,
245
+ cohortId: session.cohort.id,
246
+ sessionId: session.id,
247
+ aggregatedNonce: aggregatedNonce
248
+ });
249
+ Logger.info(`Sending AGGREGATED_NONCE message to ${participant}`);
250
+ await this.protocol.sendMessage(message, participant, this.did);
251
+ }
252
+ Logger.info(`Successfully sent aggregated nonce message to all participants in session ${session.id}.`);
253
+ }
254
+ /**
255
+ * Announces a new cohort to all subscribers.
256
+ * @param {number} minParticipants The minimum number of participants required for the cohort.
257
+ * @param {string} [network='mutinynet'] The network on which the cohort operates (default is 'signet').
258
+ * @param {string} [beaconType='SMTAggregateBeacon'] The type of beacon to be used (default is 'SMTAggregateBeacon').
259
+ * @returns {Promise<AggregateBeaconCohort>} The newly created cohort.
260
+ */
261
+ async advertiseCohort(minParticipants, network = 'mutinynet', beaconType = 'SMTAggregateBeacon') {
262
+ const cohort = new AggregateBeaconCohort({ minParticipants, network, beaconType });
263
+ Logger.info(`Advertising new cohort ${cohort.id} ...`);
264
+ this.cohorts.push(cohort);
265
+ const message = new BeaconCohortAdvertMessage({
266
+ from: this.did,
267
+ cohortId: cohort.id,
268
+ cohortSize: cohort.minParticipants,
269
+ network: cohort.network,
270
+ beaconType
271
+ });
272
+ Logger.info(`Sending ${BEACON_COHORT_ADVERT} message to network ...`, message);
273
+ await this.protocol.sendMessage(message, this.did);
274
+ Logger.info(`Cohort ${cohort.id} advertised successfully.`);
275
+ return cohort;
276
+ }
277
+ /**
278
+ * Announces to all subscribers a cohort is ready for signing.
279
+ * @param {string} cohortId The minimum number of participants required for the cohort.
280
+ * @returns {Promise<AggregateBeaconCohort>} The newly created cohort.
281
+ */
282
+ async announceCohortReady(cohortId) {
283
+ const cohort = this.cohorts.find(c => c.id === cohortId);
284
+ if (!cohort) {
285
+ Logger.error(`Cohort with ID ${cohortId} not found.`);
286
+ throw new BeaconCoordinatorError(`Cohort with ID ${cohortId} not found.`, 'COHORT_NOT_FOUND', { cohortId });
287
+ }
288
+ Logger.info(`Announcing cohort ${cohort.id} to ${cohort.participants.length} subscribers...`);
289
+ this.cohorts.push(cohort);
290
+ for (const participant of cohort.participants) {
291
+ const message = new BeaconCohortReadyMessage({
292
+ to: participant,
293
+ from: this.did,
294
+ cohortId: cohort.id,
295
+ beaconAddress: cohort.beaconAddress,
296
+ cohortKeys: cohort.cohortKeys,
297
+ });
298
+ Logger.info(`Sending ${BEACON_COHORT_ADVERT} message to ${participant}`);
299
+ await this.protocol.sendMessage(message, this.did, participant);
300
+ }
301
+ return cohort;
302
+ }
303
+ /**
304
+ * Starts a signing session for a given cohort.
305
+ * @param {string} cohortId The ID of the cohort for which to start a signing session.
306
+ * @returns {Promise<BeaconCohortSigningSession>} The started signing session.
307
+ * @throws {BeaconCoordinatorError} If the cohort with the given ID is not found.
308
+ */
309
+ async startSigningSession(cohortId) {
310
+ Logger.info(`Attempting to start signing session for cohort ${cohortId}`);
311
+ const cohort = this.cohorts.find(c => c.id === cohortId);
312
+ if (!cohort) {
313
+ Logger.error(`Cohort with ID ${cohortId} not found.`);
314
+ throw new BeaconCoordinatorError(`Cohort with ID ${cohortId} not found.`, 'COHORT_NOT_FOUND');
315
+ }
316
+ Logger.info(`Cohort ${cohortId} found. Starting signing session.`);
317
+ const signingSession = cohort.startSigningSession();
318
+ Logger.info(`Starting signing session ${signingSession.id} for cohort ${cohortId}`);
319
+ for (const participant of cohort.participants) {
320
+ const msg = signingSession.getAuthorizationRequest(participant, this.did);
321
+ Logger.info(`Sending authorization request to ${participant}`);
322
+ await this.protocol.sendMessage(msg, this.did, participant).catch(error => {
323
+ Logger.error(`Error sending authorization request to ${participant}: ${error.message}`);
324
+ });
325
+ }
326
+ this.activeSigningSessions.set(cohortId, signingSession);
327
+ Logger.info(`Signing session ${signingSession.id} started for cohort ${cohortId}`);
328
+ return signingSession;
329
+ }
330
+ /**
331
+ * Static initialization method for the BeaconCoordinator.
332
+ * @param {Service} service The communication service configuration.
333
+ * @returns {BeaconCoordinator} Initialized BeaconCoordinator instance.
334
+ */
335
+ static initialize(service) {
336
+ const communicationService = CommunicationFactory.establish(service);
337
+ const coordinator = new BeaconCoordinator({
338
+ protocol: communicationService,
339
+ did: service.did,
340
+ keys: service.keys,
341
+ });
342
+ Logger.info(`BeaconCoordinator ${coordinator.name} initialized with DID ${coordinator.did}. Run .start() to listen for messages`);
343
+ return coordinator;
118
344
  }
119
345
  }
120
346
  //# sourceMappingURL=coordinator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"coordinator.js","sourceRoot":"","sources":["../../../../../src/core/beacon/aggregation/coordinator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE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,CAAC;YACtC,MAAM,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;YAC3C,IAAI,MAAM,CAAC,YAAY,CAAC,MAAM,IAAI,MAAM,CAAC,eAAe,EAAE,CAAC;gBACzD,MAAM,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;YACzC,CAAC;QACH,CAAC;IACH,CAAC;IAED;;;;OAIG;IACK,KAAK,CAAC,mBAAmB,CAAC,MAAoB;QACpD,MAAM,CAAC,QAAQ,EAAE,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,kBAAkB,CAAC,MAAc;QAC5C,OAAO,CAAC,GAAG,CAAC,+BAA+B,MAAM,EAAE,CAAC,CAAC;QACrD,MAAM,QAAQ,GAAG;YACf,IAAI,EAAG,gBAAgB;YACvB,EAAE,EAAK,MAAM;YACb,IAAI,EAAG,IAAI,CAAC,GAAG;SAChB,CAAC;QACF,MAAM,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9D,CAAC;CACF"}
1
+ {"version":3,"file":"coordinator.js","sourceRoot":"","sources":["../../../../../src/core/beacon/aggregation/coordinator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAS,MAAM,mBAAmB,CAAC;AAElD,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EACL,oBAAoB,EACpB,gCAAgC,EAChC,oBAAoB,EACpB,2BAA2B,EAC3B,+BAA+B,EAC/B,qCAAqC,EACtC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAC;AACpF,OAAO,EAAE,wBAAwB,EAAsB,MAAM,oCAAoC,CAAC;AAClG,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