@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
@@ -1,12 +0,0 @@
1
- export const BEACON_COHORT_MESSAGE_PREFIX = 'https://btcr2.dev';
2
-
3
- export const BEACON_COHORT_ADVERT = `${BEACON_COHORT_MESSAGE_PREFIX}/musig2/keygen/beacon/cohort_advert`;
4
- export const BEACON_COHORT_OPT_IN = `${BEACON_COHORT_MESSAGE_PREFIX}/musig2/keygen/beacon/cohort_opt_in`;
5
- export const BEACON_COHORT_OPT_IN_ACCEPT = `${BEACON_COHORT_MESSAGE_PREFIX}/musig2/keygen/beacon/cohort_opt_in_accept`;
6
- export const BEACON_COHORT_READY = `${BEACON_COHORT_MESSAGE_PREFIX}/musig2/keygen/beacon/cohort_ready`;
7
-
8
- export const BEACON_COHORT_REQUEST_SIGNATURE = `${BEACON_COHORT_MESSAGE_PREFIX}/musig2/sign/beacon/cohort_request_signature`;
9
- export const BEACON_COHORT_AUTHORIZATION_REQUEST = `${BEACON_COHORT_MESSAGE_PREFIX}/musig2/sign/beacon/cohort_authorization_request`;
10
- export const BEACON_COHORT_NONCE_CONTRIBUTION = `${BEACON_COHORT_MESSAGE_PREFIX}/musig2/sign/beacon/cohort_nonce_contribution`;
11
- export const BEACON_COHORT_AGGREGATED_NONCE = `${BEACON_COHORT_MESSAGE_PREFIX}/musig2/sign/beacon/cohort_aggregated_nonce`;
12
- export const BEACON_COHORT_SIGNATURE_AUTHORIZATION = `${BEACON_COHORT_MESSAGE_PREFIX}/musig2/sign/beacon/cohort_signature_authorization`;
@@ -1,143 +0,0 @@
1
- import {
2
- BEACON_COHORT_ADVERT,
3
- BEACON_COHORT_AGGREGATED_NONCE,
4
- BEACON_COHORT_AUTHORIZATION_REQUEST,
5
- BEACON_COHORT_NONCE_CONTRIBUTION,
6
- BEACON_COHORT_OPT_IN,
7
- BEACON_COHORT_OPT_IN_ACCEPT,
8
- BEACON_COHORT_READY,
9
- BEACON_COHORT_REQUEST_SIGNATURE,
10
- BEACON_COHORT_SIGNATURE_AUTHORIZATION
11
- } from './constants.js';
12
- import { CohortAdvertMessage } from './keygen/cohort-advert.js';
13
- import { CohortReadyMessage } from './keygen/cohort-ready.js';
14
- import { CohortOptInAcceptMessage } from './keygen/opt-in-accept.js';
15
- import { CohortOptInMessage } from './keygen/opt-in.js';
16
- import { CohortSubscribeMessage } from './keygen/subscribe.js';
17
- import { CohortAggregatedNonceMessage } from './sign/aggregated-nonce.js';
18
- import { CohortAuthorizationRequestMessage } from './sign/authorization-request.js';
19
- import { CohortNonceContributionMessage } from './sign/nonce-contribution.js';
20
- import { CohortRequestSignatureMessage } from './sign/request-signature.js';
21
- import { CohortSignatureAuthorizationMessage } from './sign/signature-authorization.js';
22
-
23
- export type KeyGenMessageType =
24
- | CohortAdvertMessage
25
- | CohortReadyMessage
26
- | CohortOptInMessage
27
- | CohortOptInAcceptMessage
28
- | CohortSubscribeMessage;
29
-
30
- export type SignMessageType =
31
- | CohortAggregatedNonceMessage
32
- | CohortAuthorizationRequestMessage
33
- | CohortNonceContributionMessage
34
- | CohortRequestSignatureMessage
35
- | CohortSignatureAuthorizationMessage;
36
-
37
- export type AggregateBeaconMessageType = KeyGenMessageType | SignMessageType;
38
-
39
- /**
40
- * AggregateBeaconMessage is a utility class that provides constants and type checks
41
- * for various message types used in the aggregate beacon communication protocol.
42
- * It includes methods to validate message types and retrieve message types from objects.
43
- * @class AggregateBeaconMessage
44
- * @type {AggregateBeaconMessageType}
45
- */
46
- export class AggregateBeaconMessage {
47
- static BEACON_COHORT_ADVERT = BEACON_COHORT_ADVERT;
48
- static BEACON_COHORT_OPT_IN = BEACON_COHORT_OPT_IN;
49
- static BEACON_COHORT_READY = BEACON_COHORT_READY;
50
- static BEACON_COHORT_OPT_IN_ACCEPT = BEACON_COHORT_OPT_IN_ACCEPT;
51
-
52
- static BEACON_COHORT_KEY_GEN_MESSAGES: Map<string, string> = new Map([
53
- ['BEACON_COHORT_ADVERT', 'BEACON_COHORT_ADVERT'],
54
- ['BEACON_COHORT_OPT_IN', 'BEACON_COHORT_OPT_IN'],
55
- ['BEACON_COHORT_READY', 'BEACON_COHORT_READY'],
56
- ['BEACON_COHORT_OPT_IN_ACCEPT', 'BEACON_COHORT_OPT_IN_ACCEPT'],
57
- ]);
58
-
59
- static BEACON_COHORT_REQUEST_SIGNATURE = BEACON_COHORT_REQUEST_SIGNATURE;
60
- static BEACON_COHORT_AUTHORIZATION_REQUEST = BEACON_COHORT_AUTHORIZATION_REQUEST;
61
- static BEACON_COHORT_NONCE_CONTRIBUTION = BEACON_COHORT_NONCE_CONTRIBUTION;
62
- static BEACON_COHORT_AGGREGATED_NONCE = BEACON_COHORT_AGGREGATED_NONCE;
63
- static BEACON_COHORT_SIGNATURE_AUTHORIZATION = BEACON_COHORT_SIGNATURE_AUTHORIZATION;
64
-
65
- static BEACON_COHORT_SIGN_MESSAGES: Map<string, string> = new Map([
66
- ['BEACON_COHORT_REQUEST_SIGNATURE', 'BEACON_COHORT_REQUEST_SIGNATURE'],
67
- ['BEACON_COHORT_AUTHORIZATION_REQUEST', 'BEACON_COHORT_AUTHORIZATION_REQUEST'],
68
- ['BEACON_COHORT_NONCE_CONTRIBUTION', 'BEACON_COHORT_NONCE_CONTRIBUTION'],
69
- ['BEACON_COHORT_AGGREGATED_NONCE', 'BEACON_COHORT_AGGREGATED_NONCE'],
70
- ['BEACON_COHORT_SIGNATURE_AUTHORIZATION', 'BEACON_COHORT_SIGNATURE_AUTHORIZATION'],
71
- ]);
72
-
73
- static ALL_MESSAGES: string[] = [
74
- BEACON_COHORT_ADVERT,
75
- BEACON_COHORT_OPT_IN,
76
- BEACON_COHORT_READY,
77
- BEACON_COHORT_OPT_IN_ACCEPT,
78
- BEACON_COHORT_REQUEST_SIGNATURE,
79
- BEACON_COHORT_AUTHORIZATION_REQUEST,
80
- BEACON_COHORT_NONCE_CONTRIBUTION,
81
- BEACON_COHORT_AGGREGATED_NONCE,
82
- BEACON_COHORT_SIGNATURE_AUTHORIZATION
83
- ];
84
-
85
- /**
86
- * Checks if the name provided is a valid message name.
87
- * @param {string} type - The type of the message.
88
- * @returns
89
- */
90
- static isValidType(type: string): boolean {
91
- return this.BEACON_COHORT_KEY_GEN_MESSAGES.has(type) || this.BEACON_COHORT_SIGN_MESSAGES.has(type);
92
- }
93
-
94
- /**
95
- * Get the message value based on the type.
96
- * @param {string} type - The type (or name) of the message.
97
- * @returns {string | undefined} - The corresponding type value.
98
- */
99
- static getMessageValueByType(type: string): string | undefined {
100
- if(!this.isValidType(type)) {
101
- return undefined;
102
- }
103
- return this.BEACON_COHORT_KEY_GEN_MESSAGES.get(type) || this.BEACON_COHORT_SIGN_MESSAGES.get(type);
104
- }
105
-
106
- /**
107
- * Checks if the provided type is a valid AggregateBeaconMessageType.
108
- * @param {string} type - The message type to check.
109
- * @returns {boolean} - Returns true if the type is valid, otherwise false.
110
- */
111
- static isValidValue(type: string): boolean {
112
- return this.ALL_MESSAGES.includes(type);
113
- }
114
-
115
- /**
116
- * Checks if the provided type is a valid KeyGenMessageType.
117
- * @param {string} value - The message type to check.
118
- * @returns {boolean} - Returns true if the type is a key generation message type, otherwise false.
119
- */
120
- static isKeyGenMessageValue(value: string): boolean {
121
- return this.isValidValue(value) && [
122
- BEACON_COHORT_ADVERT,
123
- BEACON_COHORT_READY,
124
- BEACON_COHORT_OPT_IN,
125
- BEACON_COHORT_OPT_IN_ACCEPT,
126
- ].includes(value);
127
- }
128
-
129
- /**
130
- * Checks if the provided type is a valid SignMessageType.
131
- * @param {string} value - The message type to check.
132
- * @returns {boolean} - Returns true if the type is a sign message type, otherwise false.
133
- */
134
- static isSignMessageValue(value: string): boolean {
135
- return this.isValidValue(value) && [
136
- BEACON_COHORT_AGGREGATED_NONCE,
137
- BEACON_COHORT_AUTHORIZATION_REQUEST,
138
- BEACON_COHORT_NONCE_CONTRIBUTION,
139
- BEACON_COHORT_REQUEST_SIGNATURE,
140
- BEACON_COHORT_SIGNATURE_AUTHORIZATION
141
- ].includes(value);
142
- }
143
- }
@@ -1,43 +0,0 @@
1
- import { JSONUtils, Maybe } from '@did-btcr2/common';
2
- import { BaseMessage } from '../base.js';
3
- import { BEACON_COHORT_ADVERT } from '../constants.js';
4
-
5
- export interface CohortAdvertMessage {
6
- type?: typeof BEACON_COHORT_ADVERT;
7
- id?: string;
8
- from: string;
9
- cohortId: string;
10
- cohortSize: number;
11
- beaconType: string;
12
- network: string;
13
- }
14
-
15
- /**
16
- * Represents a message advertising a cohort to potential participants.
17
- * @class BeaconCohortAdvertMessage
18
- * @extends BaseMessage
19
- * @type {BeaconCohortAdvertMessage}
20
- */
21
- export class BeaconCohortAdvertMessage extends BaseMessage {
22
- public id: string;
23
-
24
- constructor({ from, id, cohortId, cohortSize, beaconType, network }: CohortAdvertMessage) {
25
- const body = { cohortId, cohortSize, beaconType, network };
26
- const type = BEACON_COHORT_ADVERT;
27
- super({ from, body, type });
28
- this.id = id || `${type}/${cohortId}`;
29
- }
30
-
31
- /**
32
- * Initializes a BeaconCohortAdvertMessage from a possible CohortAdvertMessage object.
33
- * @param {CohortAdvertMessage} data The CohortAdvertMessage object to initialize the BeaconCohortAdvertMessage.
34
- * @returns {BeaconCohortAdvertMessage} The new BeaconCohortAdvertMessage.
35
- */
36
- public static fromJSON(data: Maybe<CohortAdvertMessage>): BeaconCohortAdvertMessage {
37
- const message = JSONUtils.isParsable(data) ? JSON.parse(data) : data;
38
- if (message.type !== BEACON_COHORT_ADVERT){
39
- throw new Error(`Invalid type: ${message.type}`);
40
- }
41
- return new BeaconCohortAdvertMessage(message);
42
- }
43
- }
@@ -1,39 +0,0 @@
1
- import { JSONUtils, Maybe } from '@did-btcr2/common';
2
- import { BaseMessage } from '../base.js';
3
- import { BEACON_COHORT_READY } from '../constants.js';
4
-
5
- export interface CohortReadyMessage {
6
- type?: string;
7
- to: string;
8
- from: string;
9
- cohortId: string;
10
- beaconAddress: string;
11
- cohortKeys: Array<Uint8Array>;
12
- }
13
-
14
- /**
15
- * Represents a message indicating that a cohort has met the required conditions.
16
- * @class BeaconCohortReadyMessage
17
- * @extends BaseMessage
18
- * @type {BeaconCohortReadyMessage}
19
- */
20
- export class BeaconCohortReadyMessage extends BaseMessage {
21
- constructor({ from, to, cohortId, beaconAddress, cohortKeys }: CohortReadyMessage) {
22
- const body = { cohortId, beaconAddress, cohortKeys };
23
- const type = BEACON_COHORT_READY;
24
- super({ from, to, body, type });
25
- }
26
-
27
- /**
28
- * Initializes an BeaconCohortReadyMessage from a given OptIn object.
29
- * @param {CohortReadyMessage} data The CohortReadyMessage object to initialize the BeaconCohortReadyMessage.
30
- * @returns {BeaconCohortReadyMessage} The new BeaconCohortReadyMessage.
31
- */
32
- public static fromJSON(data: Maybe<CohortReadyMessage>): BeaconCohortReadyMessage {
33
- const message = JSONUtils.isParsable(data) ? JSON.parse(data) : data;
34
- if (message.type !== BEACON_COHORT_READY) {
35
- throw new Error(`Invalid type: ${message.type}`);
36
- }
37
- return new BeaconCohortReadyMessage(message);
38
- }
39
- }
@@ -1,34 +0,0 @@
1
- import { JSONUtils, Maybe } from '@did-btcr2/common';
2
- import { BaseMessage } from '../base.js';
3
- import { BEACON_COHORT_OPT_IN_ACCEPT } from '../constants.js';
4
-
5
- export interface CohortOptInAcceptMessage {
6
- type?: typeof BEACON_COHORT_OPT_IN_ACCEPT;
7
- to: string;
8
- from: string;
9
- }
10
-
11
- /**
12
- * Represents a message for a coordinator accepting a participant subscribe to a cohort.
13
- * @class BeaconCohortOptInAcceptMessage
14
- * @extends BaseMessage
15
- * @type {BeaconCohortOptInAcceptMessage}
16
- */
17
- export class BeaconCohortOptInAcceptMessage extends BaseMessage {
18
- constructor({ to, from }: CohortOptInAcceptMessage) {
19
- super({ to, from, type: BEACON_COHORT_OPT_IN_ACCEPT });
20
- }
21
-
22
- /**
23
- * Initializes a BeaconCohortOptInAcceptMessage from a possible CohortOptInAcceptMessage object.
24
- * @param {CohortOptInAcceptMessage} data The CohortOptInAcceptMessage object to initialize the BeaconCohortOptInAcceptMessage.
25
- * @returns {BeaconCohortOptInAcceptMessage} The new BeaconCohortOptInAcceptMessage.
26
- */
27
- public static fromJSON(data: Maybe<CohortOptInAcceptMessage>): BeaconCohortOptInAcceptMessage {
28
- const message = JSONUtils.isParsable(data) ? JSON.parse(data) : data;
29
- if (message.type != BEACON_COHORT_OPT_IN_ACCEPT) {
30
- throw new Error(`Invalid type: ${message.type}`);
31
- }
32
- return new BeaconCohortOptInAcceptMessage(message);
33
- }
34
- }
@@ -1,33 +0,0 @@
1
- import { JSONUtils, Maybe } from '@did-btcr2/common';
2
- import { BaseMessage } from '../base.js';
3
- import { BEACON_COHORT_OPT_IN } from '../constants.js';
4
-
5
- export interface CohortOptInMessage {
6
- type?: typeof BEACON_COHORT_OPT_IN;
7
- to: string;
8
- from: string;
9
- cohortId: string;
10
- participantPk: Uint8Array;
11
- }
12
-
13
- export class BeaconCohortOptInMessage extends BaseMessage {
14
-
15
- constructor({ from, to, cohortId, participantPk }: CohortOptInMessage) {
16
- const body = { cohortId, participantPk };
17
- const type = BEACON_COHORT_OPT_IN;
18
- super({ from, to, body, type });
19
- }
20
-
21
- /**
22
- * Initializes a BeaconCohortOptInMessage from a possible CohortOptInMessage object.
23
- * @param {CohortOptInMessage} data The CohortOptInMessage object to initialize the BeaconCohortOptInMessage.
24
- * @returns {BeaconCohortOptInMessage} The new BeaconCohortOptInMessage.
25
- */
26
- public static fromJSON(data: Maybe<CohortOptInMessage>): BeaconCohortOptInMessage {
27
- const message = JSONUtils.isParsable(data) ? JSON.parse(data) : data;
28
- if (message.type != BEACON_COHORT_OPT_IN) {
29
- throw new Error(`Invalid type: ${message.type}`);
30
- }
31
- return new BeaconCohortOptInMessage(message);
32
- }
33
- }
@@ -1,35 +0,0 @@
1
- import { JSONUtils, Maybe } from '@did-btcr2/common';
2
- import { BaseMessage } from '../base.js';
3
- import { BEACON_COHORT_OPT_IN_ACCEPT } from '../constants.js';
4
-
5
- export interface CohortSubscribeMessage {
6
- type?: typeof BEACON_COHORT_OPT_IN_ACCEPT;
7
- to: string;
8
- from: string;
9
- }
10
-
11
- /**
12
- * Represents a message for subscribing to a cohort.
13
- * This message is sent by a coordinator to a participant to indicate acceptance in the cohort.
14
- * @class BeaconCohortSubscribeMessage
15
- * @extends BaseMessage
16
- * @type {BeaconCohortSubscribeMessage}
17
- */
18
- export class BeaconCohortSubscribeMessage extends BaseMessage {
19
- constructor({ to, from }: CohortSubscribeMessage) {
20
- super({ to, from, type: BEACON_COHORT_OPT_IN_ACCEPT });
21
- }
22
-
23
- /**
24
- * Initializes a BeaconCohortSubscribeMessage from a possible CohortSubscribeMessage object.
25
- * @param {CohortSubscribeMessage} data The Subscribe object to initialize the SubscribeMessage.
26
- * @returns {BeaconCohortSubscribeMessage} The serialized SubscribeMessage.
27
- */
28
- public static fromJSON(data: Maybe<CohortSubscribeMessage>): BeaconCohortSubscribeMessage {
29
- const message = JSONUtils.isParsable(data) ? JSON.parse(data) : data;
30
- if (message.type != BEACON_COHORT_OPT_IN_ACCEPT) {
31
- throw new Error(`Invalid type: ${message.type}`);
32
- }
33
- return new BeaconCohortSubscribeMessage(message);
34
- }
35
- }
@@ -1,38 +0,0 @@
1
- import { JSONUtils, Maybe } from '@did-btcr2/common';
2
- import { BaseMessage } from '../base.js';
3
- import { BEACON_COHORT_AGGREGATED_NONCE } from '../constants.js';
4
-
5
- export interface CohortAggregatedNonceMessage {
6
- to: string;
7
- from: string;
8
- cohortId: string;
9
- sessionId: string;
10
- aggregatedNonce: Uint8Array;
11
- }
12
-
13
- /**
14
- * Represents a message containing an aggregated nonce for a cohort in the Beacon protocol.
15
- * @class BeaconCohortAggregatedNonceMessage
16
- * @extends BaseMessage
17
- * @type {BeaconCohortAggregatedNonceMessage}
18
- */
19
- export class BeaconCohortAggregatedNonceMessage extends BaseMessage {
20
- constructor({ to, from, cohortId, sessionId, aggregatedNonce }: CohortAggregatedNonceMessage) {
21
- const body = { cohortId, sessionId, aggregatedNonce };
22
- const type = BEACON_COHORT_AGGREGATED_NONCE;
23
- super({ to, from, body, type });
24
- }
25
-
26
- /**
27
- * Initializes a BeaconCohortAggregatedNonceMessage from a given AggregatedNonce object.
28
- * @param {CohortAggregatedNonceMessage} data The data object to initialize the BeaconCohortAggregatedNonceMessage.
29
- * @returns {BeaconCohortAggregatedNonceMessage} The new BeaconCohortAggregatedNonceMessage.
30
- */
31
- public static fromJSON(data: Maybe<CohortAggregatedNonceMessage>): BeaconCohortAggregatedNonceMessage {
32
- const message = JSONUtils.isParsable(data) ? JSON.parse(data) : data;
33
- if (message.type != BEACON_COHORT_AGGREGATED_NONCE) {
34
- throw new Error(`Invalid type: ${message.type}`);
35
- }
36
- return new BeaconCohortAggregatedNonceMessage(message);
37
- }
38
- }
@@ -1,39 +0,0 @@
1
- import { JSONUtils, Maybe } from '@did-btcr2/common';
2
- import { BaseMessage } from '../base.js';
3
- import { BEACON_COHORT_AUTHORIZATION_REQUEST } from '../constants.js';
4
-
5
- export interface CohortAuthorizationRequestMessage {
6
- to: string;
7
- from: string;
8
- cohortId: string;
9
- sessionId: string;
10
- pendingTx: string;
11
- }
12
-
13
- /**
14
- * Sends the unsigned PSBT that spends the Beacon UTXO (plus any SMT proofs).
15
- * Asks the cohort to begin a MuSig2 signing session.
16
- * @class BeaconCohortAuthorizationRequestMessage
17
- * @extends BaseMessage
18
- * @type {CohortAuthorizationRequestMessage}
19
- */
20
- export class BeaconCohortAuthorizationRequestMessage extends BaseMessage {
21
- constructor({ to, from, cohortId, sessionId, pendingTx }: CohortAuthorizationRequestMessage) {
22
- const body = { cohortId, sessionId, pendingTx };
23
- const type = BEACON_COHORT_AUTHORIZATION_REQUEST;
24
- super({ to, from, body, type });
25
- }
26
-
27
- /**
28
- * Initializes a BeaconCohortAuthorizationRequestMessage from a given AuthorizationRequest object.
29
- * @param {CohortAuthorizationRequestMessage} data The data object to initialize the BeaconCohortAuthorizationRequestMessage.
30
- * @returns {BeaconCohortAuthorizationRequestMessage} The serialized BeaconCohortAuthorizationRequestMessage.
31
- */
32
- public static fromJSON(data: Maybe<CohortAuthorizationRequestMessage>): BeaconCohortAuthorizationRequestMessage {
33
- const message = JSONUtils.isParsable(data) ? JSON.parse(data) : data;
34
- if (message.type != BEACON_COHORT_AUTHORIZATION_REQUEST) {
35
- throw new Error(`Invalid type: ${message.type}`);
36
- }
37
- return new BeaconCohortAuthorizationRequestMessage(message);
38
- }
39
- }
@@ -1,39 +0,0 @@
1
- import { JSONUtils, Maybe } from '@did-btcr2/common';
2
- import { BaseMessage } from '../base.js';
3
- import { BEACON_COHORT_NONCE_CONTRIBUTION } from '../constants.js';
4
-
5
- export interface CohortNonceContributionMessage {
6
- to: string;
7
- from: string;
8
- cohortId: string;
9
- sessionId: string;
10
- nonceContribution: Uint8Array;
11
- }
12
-
13
- /**
14
- * Represents a message containing a nonce contribution for a cohort participant.
15
- * Participant → Coordinator. Participant sending their public nonce points for the ongoing signing session.
16
- * @class BeaconCohortNonceContributionMessage
17
- * @extends BaseMessage
18
- * @type {BeaconCohortNonceContributionMessage}
19
- */
20
- export class BeaconCohortNonceContributionMessage extends BaseMessage {
21
- constructor({ to, from, cohortId, sessionId, nonceContribution }: CohortNonceContributionMessage) {
22
- const body = { cohortId, sessionId, nonceContribution };
23
- const type = BEACON_COHORT_NONCE_CONTRIBUTION;
24
- super({ to, from, body, type });
25
- }
26
-
27
- /**
28
- * Initializes a NonceContributionMessage from a given CohortNonceContributionMessage object.
29
- * @param {CohortNonceContributionMessage} data The data object to initialize the BeaconCohortNonceContributionMessage.
30
- * @returns {BeaconCohortNonceContributionMessage} The new BeaconCohortNonceContributionMessage.
31
- */
32
- public static fromJSON(data: Maybe<CohortNonceContributionMessage>): BeaconCohortNonceContributionMessage {
33
- const message = JSONUtils.isParsable(data) ? JSON.parse(data) : data;
34
- if (message.type != BEACON_COHORT_NONCE_CONTRIBUTION) {
35
- throw new Error(`Invalid type: ${message.type}`);
36
- }
37
- return new BeaconCohortNonceContributionMessage(message);
38
- }
39
- }
@@ -1,39 +0,0 @@
1
- import { JSONUtils, Maybe } from '@did-btcr2/common';
2
- import { BaseMessage } from '../base.js';
3
- import { BEACON_COHORT_REQUEST_SIGNATURE } from '../constants.js';
4
-
5
- export type CohortRequestSignatureMessage = {
6
- to: string;
7
- from: string;
8
- cohortId: string;
9
- sessionId?: string;
10
- data: string;
11
- }
12
-
13
- /**
14
- * Coordinator → Participants. Returns the aggregation of all participant nonces
15
- * so each participant can produce a correct partial signature.
16
- * @class BeaconCohortRequestSignatureMessage
17
- * @extends BaseMessage
18
- * @type {BeaconCohortRequestSignatureMessage}
19
- */
20
- export class BeaconCohortRequestSignatureMessage extends BaseMessage {
21
- constructor({ to, from, cohortId, sessionId, data }: CohortRequestSignatureMessage) {
22
- const body = { cohortId, sessionId, data };
23
- const type = BEACON_COHORT_REQUEST_SIGNATURE;
24
- super({ to, from, body, type });
25
- }
26
-
27
- /**
28
- * Initializes an BeaconCohortRequestSignatureMessage from a possible CohortRequestSignatureMessage object.
29
- * @param {CohortRequestSignatureMessage} data The data object to initialize the BeaconCohortRequestSignatureMessage.
30
- * @returns {BeaconCohortRequestSignatureMessage} The new BeaconCohortRequestSignatureMessage.
31
- */
32
- public static fromJSON(data: Maybe<CohortRequestSignatureMessage>): BeaconCohortRequestSignatureMessage {
33
- const message = JSONUtils.isParsable(data) ? JSON.parse(data) : data;
34
- if (message.type != BEACON_COHORT_REQUEST_SIGNATURE) {
35
- throw new Error(`Invalid type: ${message.type}`);
36
- }
37
- return new BeaconCohortRequestSignatureMessage(message);
38
- }
39
- }
@@ -1,40 +0,0 @@
1
- import { JSONUtils, Maybe } from '@did-btcr2/common';
2
- import { BaseMessage } from '../base.js';
3
- import { BEACON_COHORT_SIGNATURE_AUTHORIZATION } from '../constants.js';
4
-
5
- export type CohortSignatureAuthorizationMessage = {
6
- to: string;
7
- from: string;
8
- cohortId: string;
9
- sessionId: string;
10
- partialSignature: Uint8Array;
11
- }
12
-
13
- /**
14
- * Participant → Coordinator. Delivers the participant’s partial signature over
15
- * the PSBT, authorizing the final Beacon signal (transaction) once all signatures
16
- * are collected.
17
- * @class BeaconCohortSignatureAuthorizationMessage
18
- * @extends BaseMessage
19
- * @type {BeaconCohortSignatureAuthorizationMessage}
20
- */
21
- export class BeaconCohortSignatureAuthorizationMessage extends BaseMessage {
22
- constructor({ to, from, cohortId, sessionId, partialSignature }: CohortSignatureAuthorizationMessage) {
23
- const body = { cohortId, sessionId, partialSignature };
24
- const type = BEACON_COHORT_SIGNATURE_AUTHORIZATION;
25
- super({ to, from, body, type });
26
- }
27
-
28
- /**
29
- * Initializes an BeaconCohortSignatureAuthorizationMessage from a given CohortSignatureAuthorizationMessage object.
30
- * @param {CohortSignatureAuthorizationMessage} data The data object to initialize the BeaconCohortSignatureAuthorizationMessage.
31
- * @returns {BeaconCohortSignatureAuthorizationMessage} The serialized BeaconCohortSignatureAuthorizationMessage.
32
- */
33
- public static fromJSON(data: Maybe<CohortSignatureAuthorizationMessage>): BeaconCohortSignatureAuthorizationMessage {
34
- const message = JSONUtils.isParsable(data) ? JSON.parse(data) : data;
35
- if (message.type != BEACON_COHORT_SIGNATURE_AUTHORIZATION) {
36
- throw new Error(`Invalid type: ${message.type}`);
37
- }
38
- return new BeaconCohortSignatureAuthorizationMessage(message);
39
- }
40
- }
@@ -1,7 +0,0 @@
1
- export type COHORT_STATUS_TYPE = 'ADVERTISED' | 'OPTED_IN' | 'COHORT_SET' | 'FAILED';
2
- export enum COHORT_STATUS {
3
- COHORT_ADVERTISED = 'ADVERTISED',
4
- COHORT_OPTED_IN = 'OPTED_IN',
5
- COHORT_SET_STATUS = 'COHORT_SET',
6
- COHORT_FAILED = 'FAILED',
7
- }