@did-btcr2/method 0.26.0 → 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 (282) hide show
  1. package/README.md +86 -233
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/browser.js +24111 -20342
  4. package/dist/browser.mjs +24111 -20342
  5. package/dist/cjs/index.js +2463 -2174
  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 +15 -56
  53. package/dist/esm/core/beacon/cas-beacon.js.map +1 -1
  54. package/dist/esm/core/beacon/error.js +0 -10
  55. package/dist/esm/core/beacon/error.js.map +1 -1
  56. package/dist/esm/core/beacon/fee-estimator.js +30 -0
  57. package/dist/esm/core/beacon/fee-estimator.js.map +1 -0
  58. package/dist/esm/core/beacon/singleton-beacon.js +10 -53
  59. package/dist/esm/core/beacon/singleton-beacon.js.map +1 -1
  60. package/dist/esm/core/beacon/smt-beacon.js +85 -9
  61. package/dist/esm/core/beacon/smt-beacon.js.map +1 -1
  62. package/dist/esm/core/identifier.js +13 -0
  63. package/dist/esm/core/identifier.js.map +1 -1
  64. package/dist/esm/core/resolver.js +9 -0
  65. package/dist/esm/core/resolver.js.map +1 -1
  66. package/dist/esm/index.js +14 -24
  67. package/dist/esm/index.js.map +1 -1
  68. package/dist/types/core/aggregation/cohort.d.ts +94 -0
  69. package/dist/types/core/aggregation/cohort.d.ts.map +1 -0
  70. package/dist/types/core/aggregation/errors.d.ts +14 -0
  71. package/dist/types/core/aggregation/errors.d.ts.map +1 -0
  72. package/dist/types/core/{beacon/aggregation/cohort → aggregation}/messages/base.d.ts +7 -1
  73. package/dist/types/core/aggregation/messages/base.d.ts.map +1 -0
  74. package/dist/types/core/aggregation/messages/constants.d.ts +23 -0
  75. package/dist/types/core/aggregation/messages/constants.d.ts.map +1 -0
  76. package/dist/types/core/aggregation/messages/factories.d.ts +177 -0
  77. package/dist/types/core/aggregation/messages/factories.d.ts.map +1 -0
  78. package/dist/types/core/aggregation/messages/guards.d.ts +11 -0
  79. package/dist/types/core/aggregation/messages/guards.d.ts.map +1 -0
  80. package/dist/types/core/aggregation/messages/index.d.ts +5 -0
  81. package/dist/types/core/aggregation/messages/index.d.ts.map +1 -0
  82. package/dist/types/core/aggregation/participant.d.ts +101 -0
  83. package/dist/types/core/aggregation/participant.d.ts.map +1 -0
  84. package/dist/types/core/aggregation/phases.d.ts +49 -0
  85. package/dist/types/core/aggregation/phases.d.ts.map +1 -0
  86. package/dist/types/core/aggregation/runner/events.d.ts +89 -0
  87. package/dist/types/core/aggregation/runner/events.d.ts.map +1 -0
  88. package/dist/types/core/aggregation/runner/index.d.ts +5 -0
  89. package/dist/types/core/aggregation/runner/index.d.ts.map +1 -0
  90. package/dist/types/core/aggregation/runner/participant-runner.d.ts +107 -0
  91. package/dist/types/core/aggregation/runner/participant-runner.d.ts.map +1 -0
  92. package/dist/types/core/aggregation/runner/service-runner.d.ts +102 -0
  93. package/dist/types/core/aggregation/runner/service-runner.d.ts.map +1 -0
  94. package/dist/types/core/aggregation/runner/typed-emitter.d.ts +41 -0
  95. package/dist/types/core/aggregation/runner/typed-emitter.d.ts.map +1 -0
  96. package/dist/types/core/aggregation/service.d.ts +112 -0
  97. package/dist/types/core/aggregation/service.d.ts.map +1 -0
  98. package/dist/types/core/aggregation/signing-session.d.ts +69 -0
  99. package/dist/types/core/aggregation/signing-session.d.ts.map +1 -0
  100. package/dist/types/core/aggregation/transport/didcomm.d.ts +20 -0
  101. package/dist/types/core/aggregation/transport/didcomm.d.ts.map +1 -0
  102. package/dist/types/core/{beacon/aggregation/communication → aggregation/transport}/error.d.ts +2 -2
  103. package/dist/types/core/aggregation/transport/error.d.ts.map +1 -0
  104. package/dist/types/core/aggregation/transport/factory.d.ts +13 -0
  105. package/dist/types/core/aggregation/transport/factory.d.ts.map +1 -0
  106. package/dist/types/core/aggregation/transport/index.d.ts +6 -0
  107. package/dist/types/core/aggregation/transport/index.d.ts.map +1 -0
  108. package/dist/types/core/aggregation/transport/nostr.d.ts +55 -0
  109. package/dist/types/core/aggregation/transport/nostr.d.ts.map +1 -0
  110. package/dist/types/core/aggregation/transport/transport.d.ts +37 -0
  111. package/dist/types/core/aggregation/transport/transport.d.ts.map +1 -0
  112. package/dist/types/core/beacon/beacon.d.ts +37 -2
  113. package/dist/types/core/beacon/beacon.d.ts.map +1 -1
  114. package/dist/types/core/beacon/cas-beacon.d.ts +19 -7
  115. package/dist/types/core/beacon/cas-beacon.d.ts.map +1 -1
  116. package/dist/types/core/beacon/error.d.ts +0 -6
  117. package/dist/types/core/beacon/error.d.ts.map +1 -1
  118. package/dist/types/core/beacon/fee-estimator.d.ts +40 -0
  119. package/dist/types/core/beacon/fee-estimator.d.ts.map +1 -0
  120. package/dist/types/core/beacon/interfaces.d.ts +8 -0
  121. package/dist/types/core/beacon/interfaces.d.ts.map +1 -1
  122. package/dist/types/core/beacon/singleton-beacon.d.ts +9 -2
  123. package/dist/types/core/beacon/singleton-beacon.d.ts.map +1 -1
  124. package/dist/types/core/beacon/smt-beacon.d.ts +27 -7
  125. package/dist/types/core/beacon/smt-beacon.d.ts.map +1 -1
  126. package/dist/types/core/identifier.d.ts +8 -0
  127. package/dist/types/core/identifier.d.ts.map +1 -1
  128. package/dist/types/core/interfaces.d.ts +2 -2
  129. package/dist/types/core/resolver.d.ts +11 -1
  130. package/dist/types/core/resolver.d.ts.map +1 -1
  131. package/dist/types/index.d.ts +9 -24
  132. package/dist/types/index.d.ts.map +1 -1
  133. package/package.json +31 -30
  134. package/src/core/aggregation/cohort.ts +247 -0
  135. package/src/core/aggregation/errors.ts +25 -0
  136. package/src/core/{beacon/aggregation/cohort → aggregation}/messages/base.ts +8 -3
  137. package/src/core/aggregation/messages/constants.ts +28 -0
  138. package/src/core/aggregation/messages/factories.ts +240 -0
  139. package/src/core/aggregation/messages/guards.ts +55 -0
  140. package/src/core/aggregation/messages/index.ts +4 -0
  141. package/src/core/aggregation/participant.ts +510 -0
  142. package/src/core/aggregation/phases.ts +82 -0
  143. package/src/core/aggregation/runner/events.ts +77 -0
  144. package/src/core/aggregation/runner/index.ts +4 -0
  145. package/src/core/aggregation/runner/participant-runner.ts +360 -0
  146. package/src/core/aggregation/runner/service-runner.ts +365 -0
  147. package/src/core/aggregation/runner/typed-emitter.ts +87 -0
  148. package/src/core/aggregation/service.ts +547 -0
  149. package/src/core/aggregation/signing-session.ts +209 -0
  150. package/src/core/aggregation/transport/didcomm.ts +42 -0
  151. package/src/core/aggregation/transport/error.ts +13 -0
  152. package/src/core/aggregation/transport/factory.ts +29 -0
  153. package/src/core/aggregation/transport/index.ts +5 -0
  154. package/src/core/aggregation/transport/nostr.ts +333 -0
  155. package/src/core/aggregation/transport/transport.ts +46 -0
  156. package/src/core/beacon/beacon.ts +122 -2
  157. package/src/core/beacon/cas-beacon.ts +28 -76
  158. package/src/core/beacon/error.ts +0 -12
  159. package/src/core/beacon/fee-estimator.ts +52 -0
  160. package/src/core/beacon/interfaces.ts +10 -1
  161. package/src/core/beacon/singleton-beacon.ts +14 -75
  162. package/src/core/beacon/smt-beacon.ts +109 -11
  163. package/src/core/identifier.ts +17 -0
  164. package/src/core/interfaces.ts +2 -2
  165. package/src/core/resolver.ts +25 -2
  166. package/src/index.ts +15 -29
  167. package/dist/esm/core/beacon/aggregation/cohort/index.js +0 -237
  168. package/dist/esm/core/beacon/aggregation/cohort/index.js.map +0 -1
  169. package/dist/esm/core/beacon/aggregation/cohort/messages/base.js.map +0 -1
  170. package/dist/esm/core/beacon/aggregation/cohort/messages/constants.js +0 -11
  171. package/dist/esm/core/beacon/aggregation/cohort/messages/constants.js.map +0 -1
  172. package/dist/esm/core/beacon/aggregation/cohort/messages/index.js +0 -98
  173. package/dist/esm/core/beacon/aggregation/cohort/messages/index.js.map +0 -1
  174. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js +0 -31
  175. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js.map +0 -1
  176. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js +0 -29
  177. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js.map +0 -1
  178. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js +0 -27
  179. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js.map +0 -1
  180. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in.js +0 -23
  181. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in.js.map +0 -1
  182. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/subscribe.js +0 -28
  183. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/subscribe.js.map +0 -1
  184. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js +0 -29
  185. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js.map +0 -1
  186. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/authorization-request.js +0 -30
  187. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/authorization-request.js.map +0 -1
  188. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js +0 -30
  189. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js.map +0 -1
  190. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/request-signature.js +0 -30
  191. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/request-signature.js.map +0 -1
  192. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js +0 -31
  193. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js.map +0 -1
  194. package/dist/esm/core/beacon/aggregation/cohort/status.js +0 -8
  195. package/dist/esm/core/beacon/aggregation/cohort/status.js.map +0 -1
  196. package/dist/esm/core/beacon/aggregation/communication/adapter/did-comm.js +0 -121
  197. package/dist/esm/core/beacon/aggregation/communication/adapter/did-comm.js.map +0 -1
  198. package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js +0 -245
  199. package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js.map +0 -1
  200. package/dist/esm/core/beacon/aggregation/communication/error.js +0 -12
  201. package/dist/esm/core/beacon/aggregation/communication/error.js.map +0 -1
  202. package/dist/esm/core/beacon/aggregation/communication/factory.js +0 -21
  203. package/dist/esm/core/beacon/aggregation/communication/factory.js.map +0 -1
  204. package/dist/esm/core/beacon/aggregation/communication/service.js +0 -2
  205. package/dist/esm/core/beacon/aggregation/communication/service.js.map +0 -1
  206. package/dist/esm/core/beacon/aggregation/coordinator.js +0 -343
  207. package/dist/esm/core/beacon/aggregation/coordinator.js.map +0 -1
  208. package/dist/esm/core/beacon/aggregation/participant.js +0 -435
  209. package/dist/esm/core/beacon/aggregation/participant.js.map +0 -1
  210. package/dist/esm/core/beacon/aggregation/session/index.js +0 -244
  211. package/dist/esm/core/beacon/aggregation/session/index.js.map +0 -1
  212. package/dist/esm/core/beacon/aggregation/session/status.js +0 -11
  213. package/dist/esm/core/beacon/aggregation/session/status.js.map +0 -1
  214. package/dist/types/core/beacon/aggregation/cohort/index.d.ts +0 -136
  215. package/dist/types/core/beacon/aggregation/cohort/index.d.ts.map +0 -1
  216. package/dist/types/core/beacon/aggregation/cohort/messages/base.d.ts.map +0 -1
  217. package/dist/types/core/beacon/aggregation/cohort/messages/constants.d.ts +0 -11
  218. package/dist/types/core/beacon/aggregation/cohort/messages/constants.d.ts.map +0 -1
  219. package/dist/types/core/beacon/aggregation/cohort/messages/index.d.ts +0 -65
  220. package/dist/types/core/beacon/aggregation/cohort/messages/index.d.ts.map +0 -1
  221. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.d.ts +0 -29
  222. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.d.ts.map +0 -1
  223. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts +0 -26
  224. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts.map +0 -1
  225. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.d.ts +0 -24
  226. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.d.ts.map +0 -1
  227. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in.d.ts +0 -20
  228. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in.d.ts.map +0 -1
  229. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/subscribe.d.ts +0 -25
  230. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/subscribe.d.ts.map +0 -1
  231. package/dist/types/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.d.ts +0 -25
  232. package/dist/types/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.d.ts.map +0 -1
  233. package/dist/types/core/beacon/aggregation/cohort/messages/sign/authorization-request.d.ts +0 -26
  234. package/dist/types/core/beacon/aggregation/cohort/messages/sign/authorization-request.d.ts.map +0 -1
  235. package/dist/types/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.d.ts +0 -26
  236. package/dist/types/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.d.ts.map +0 -1
  237. package/dist/types/core/beacon/aggregation/cohort/messages/sign/request-signature.d.ts +0 -26
  238. package/dist/types/core/beacon/aggregation/cohort/messages/sign/request-signature.d.ts.map +0 -1
  239. package/dist/types/core/beacon/aggregation/cohort/messages/sign/signature-authorization.d.ts +0 -27
  240. package/dist/types/core/beacon/aggregation/cohort/messages/sign/signature-authorization.d.ts.map +0 -1
  241. package/dist/types/core/beacon/aggregation/cohort/status.d.ts +0 -8
  242. package/dist/types/core/beacon/aggregation/cohort/status.d.ts.map +0 -1
  243. package/dist/types/core/beacon/aggregation/communication/adapter/did-comm.d.ts +0 -89
  244. package/dist/types/core/beacon/aggregation/communication/adapter/did-comm.d.ts.map +0 -1
  245. package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts +0 -103
  246. package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts.map +0 -1
  247. package/dist/types/core/beacon/aggregation/communication/error.d.ts.map +0 -1
  248. package/dist/types/core/beacon/aggregation/communication/factory.d.ts +0 -10
  249. package/dist/types/core/beacon/aggregation/communication/factory.d.ts.map +0 -1
  250. package/dist/types/core/beacon/aggregation/communication/service.d.ts +0 -36
  251. package/dist/types/core/beacon/aggregation/communication/service.d.ts.map +0 -1
  252. package/dist/types/core/beacon/aggregation/coordinator.d.ts +0 -116
  253. package/dist/types/core/beacon/aggregation/coordinator.d.ts.map +0 -1
  254. package/dist/types/core/beacon/aggregation/participant.d.ts +0 -192
  255. package/dist/types/core/beacon/aggregation/participant.d.ts.map +0 -1
  256. package/dist/types/core/beacon/aggregation/session/index.d.ts +0 -156
  257. package/dist/types/core/beacon/aggregation/session/index.d.ts.map +0 -1
  258. package/dist/types/core/beacon/aggregation/session/status.d.ts +0 -11
  259. package/dist/types/core/beacon/aggregation/session/status.d.ts.map +0 -1
  260. package/src/core/beacon/aggregation/cohort/index.ts +0 -305
  261. package/src/core/beacon/aggregation/cohort/messages/constants.ts +0 -12
  262. package/src/core/beacon/aggregation/cohort/messages/index.ts +0 -143
  263. package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.ts +0 -44
  264. package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.ts +0 -40
  265. package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.ts +0 -35
  266. package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in.ts +0 -34
  267. package/src/core/beacon/aggregation/cohort/messages/keygen/subscribe.ts +0 -36
  268. package/src/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.ts +0 -39
  269. package/src/core/beacon/aggregation/cohort/messages/sign/authorization-request.ts +0 -40
  270. package/src/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.ts +0 -40
  271. package/src/core/beacon/aggregation/cohort/messages/sign/request-signature.ts +0 -40
  272. package/src/core/beacon/aggregation/cohort/messages/sign/signature-authorization.ts +0 -41
  273. package/src/core/beacon/aggregation/cohort/status.ts +0 -7
  274. package/src/core/beacon/aggregation/communication/adapter/did-comm.ts +0 -148
  275. package/src/core/beacon/aggregation/communication/adapter/nostr.ts +0 -323
  276. package/src/core/beacon/aggregation/communication/error.ts +0 -13
  277. package/src/core/beacon/aggregation/communication/factory.ts +0 -25
  278. package/src/core/beacon/aggregation/communication/service.ts +0 -42
  279. package/src/core/beacon/aggregation/coordinator.ts +0 -419
  280. package/src/core/beacon/aggregation/participant.ts +0 -517
  281. package/src/core/beacon/aggregation/session/index.ts +0 -301
  282. 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 type { CohortAdvertMessage } from './keygen/cohort-advert.js';
13
- import type { CohortReadyMessage } from './keygen/cohort-ready.js';
14
- import type { CohortOptInAcceptMessage } from './keygen/opt-in-accept.js';
15
- import type { CohortOptInMessage } from './keygen/opt-in.js';
16
- import type { CohortSubscribeMessage } from './keygen/subscribe.js';
17
- import type { CohortAggregatedNonceMessage } from './sign/aggregated-nonce.js';
18
- import type { CohortAuthorizationRequestMessage } from './sign/authorization-request.js';
19
- import type { CohortNonceContributionMessage } from './sign/nonce-contribution.js';
20
- import type { CohortRequestSignatureMessage } from './sign/request-signature.js';
21
- import type { 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,44 +0,0 @@
1
- import type { Maybe } from '@did-btcr2/common';
2
- import { JSONUtils } from '@did-btcr2/common';
3
- import { BaseMessage } from '../base.js';
4
- import { BEACON_COHORT_ADVERT } from '../constants.js';
5
-
6
- export interface CohortAdvertMessage {
7
- type?: typeof BEACON_COHORT_ADVERT;
8
- id?: string;
9
- from: string;
10
- cohortId: string;
11
- cohortSize: number;
12
- beaconType: string;
13
- network: string;
14
- }
15
-
16
- /**
17
- * Represents a message advertising a cohort to potential participants.
18
- * @class BeaconCohortAdvertMessage
19
- * @extends BaseMessage
20
- * @type {BeaconCohortAdvertMessage}
21
- */
22
- export class BeaconCohortAdvertMessage extends BaseMessage {
23
- public id: string;
24
-
25
- constructor({ from, id, cohortId, cohortSize, beaconType, network }: CohortAdvertMessage) {
26
- const body = { cohortId, cohortSize, beaconType, network };
27
- const type = BEACON_COHORT_ADVERT;
28
- super({ from, body, type });
29
- this.id = id || `${type}/${cohortId}`;
30
- }
31
-
32
- /**
33
- * Initializes a BeaconCohortAdvertMessage from a possible CohortAdvertMessage object.
34
- * @param {CohortAdvertMessage} data The CohortAdvertMessage object to initialize the BeaconCohortAdvertMessage.
35
- * @returns {BeaconCohortAdvertMessage} The new BeaconCohortAdvertMessage.
36
- */
37
- public static fromJSON(data: Maybe<CohortAdvertMessage>): BeaconCohortAdvertMessage {
38
- const message = JSONUtils.isParsable(data) ? JSON.parse(data) : data;
39
- if (message.type !== BEACON_COHORT_ADVERT){
40
- throw new Error(`Invalid type: ${message.type}`);
41
- }
42
- return new BeaconCohortAdvertMessage(message);
43
- }
44
- }
@@ -1,40 +0,0 @@
1
- import type { Maybe } from '@did-btcr2/common';
2
- import { JSONUtils } from '@did-btcr2/common';
3
- import { BaseMessage } from '../base.js';
4
- import { BEACON_COHORT_READY } from '../constants.js';
5
-
6
- export interface CohortReadyMessage {
7
- type?: string;
8
- to: string;
9
- from: string;
10
- cohortId: string;
11
- beaconAddress: string;
12
- cohortKeys: Array<Uint8Array>;
13
- }
14
-
15
- /**
16
- * Represents a message indicating that a cohort has met the required conditions.
17
- * @class BeaconCohortReadyMessage
18
- * @extends BaseMessage
19
- * @type {BeaconCohortReadyMessage}
20
- */
21
- export class BeaconCohortReadyMessage extends BaseMessage {
22
- constructor({ from, to, cohortId, beaconAddress, cohortKeys }: CohortReadyMessage) {
23
- const body = { cohortId, beaconAddress, cohortKeys };
24
- const type = BEACON_COHORT_READY;
25
- super({ from, to, body, type });
26
- }
27
-
28
- /**
29
- * Initializes an BeaconCohortReadyMessage from a given OptIn object.
30
- * @param {CohortReadyMessage} data The CohortReadyMessage object to initialize the BeaconCohortReadyMessage.
31
- * @returns {BeaconCohortReadyMessage} The new BeaconCohortReadyMessage.
32
- */
33
- public static fromJSON(data: Maybe<CohortReadyMessage>): BeaconCohortReadyMessage {
34
- const message = JSONUtils.isParsable(data) ? JSON.parse(data) : data;
35
- if (message.type !== BEACON_COHORT_READY) {
36
- throw new Error(`Invalid type: ${message.type}`);
37
- }
38
- return new BeaconCohortReadyMessage(message);
39
- }
40
- }
@@ -1,35 +0,0 @@
1
- import type { Maybe } from '@did-btcr2/common';
2
- import { JSONUtils } from '@did-btcr2/common';
3
- import { BaseMessage } from '../base.js';
4
- import { BEACON_COHORT_OPT_IN_ACCEPT } from '../constants.js';
5
-
6
- export interface CohortOptInAcceptMessage {
7
- type?: typeof BEACON_COHORT_OPT_IN_ACCEPT;
8
- to: string;
9
- from: string;
10
- }
11
-
12
- /**
13
- * Represents a message for a coordinator accepting a participant subscribe to a cohort.
14
- * @class BeaconCohortOptInAcceptMessage
15
- * @extends BaseMessage
16
- * @type {BeaconCohortOptInAcceptMessage}
17
- */
18
- export class BeaconCohortOptInAcceptMessage extends BaseMessage {
19
- constructor({ to, from }: CohortOptInAcceptMessage) {
20
- super({ to, from, type: BEACON_COHORT_OPT_IN_ACCEPT });
21
- }
22
-
23
- /**
24
- * Initializes a BeaconCohortOptInAcceptMessage from a possible CohortOptInAcceptMessage object.
25
- * @param {CohortOptInAcceptMessage} data The CohortOptInAcceptMessage object to initialize the BeaconCohortOptInAcceptMessage.
26
- * @returns {BeaconCohortOptInAcceptMessage} The new BeaconCohortOptInAcceptMessage.
27
- */
28
- public static fromJSON(data: Maybe<CohortOptInAcceptMessage>): BeaconCohortOptInAcceptMessage {
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 BeaconCohortOptInAcceptMessage(message);
34
- }
35
- }
@@ -1,34 +0,0 @@
1
- import type { Maybe } from '@did-btcr2/common';
2
- import { JSONUtils } from '@did-btcr2/common';
3
- import { BaseMessage } from '../base.js';
4
- import { BEACON_COHORT_OPT_IN } from '../constants.js';
5
-
6
- export interface CohortOptInMessage {
7
- type?: typeof BEACON_COHORT_OPT_IN;
8
- to: string;
9
- from: string;
10
- cohortId: string;
11
- participantPk: Uint8Array;
12
- }
13
-
14
- export class BeaconCohortOptInMessage extends BaseMessage {
15
-
16
- constructor({ from, to, cohortId, participantPk }: CohortOptInMessage) {
17
- const body = { cohortId, participantPk };
18
- const type = BEACON_COHORT_OPT_IN;
19
- super({ from, to, body, type });
20
- }
21
-
22
- /**
23
- * Initializes a BeaconCohortOptInMessage from a possible CohortOptInMessage object.
24
- * @param {CohortOptInMessage} data The CohortOptInMessage object to initialize the BeaconCohortOptInMessage.
25
- * @returns {BeaconCohortOptInMessage} The new BeaconCohortOptInMessage.
26
- */
27
- public static fromJSON(data: Maybe<CohortOptInMessage>): BeaconCohortOptInMessage {
28
- const message = JSONUtils.isParsable(data) ? JSON.parse(data) : data;
29
- if (message.type != BEACON_COHORT_OPT_IN) {
30
- throw new Error(`Invalid type: ${message.type}`);
31
- }
32
- return new BeaconCohortOptInMessage(message);
33
- }
34
- }
@@ -1,36 +0,0 @@
1
- import type { Maybe } from '@did-btcr2/common';
2
- import { JSONUtils } from '@did-btcr2/common';
3
- import { BaseMessage } from '../base.js';
4
- import { BEACON_COHORT_OPT_IN_ACCEPT } from '../constants.js';
5
-
6
- export interface CohortSubscribeMessage {
7
- type?: typeof BEACON_COHORT_OPT_IN_ACCEPT;
8
- to: string;
9
- from: string;
10
- }
11
-
12
- /**
13
- * Represents a message for subscribing to a cohort.
14
- * This message is sent by a coordinator to a participant to indicate acceptance in the cohort.
15
- * @class BeaconCohortSubscribeMessage
16
- * @extends BaseMessage
17
- * @type {BeaconCohortSubscribeMessage}
18
- */
19
- export class BeaconCohortSubscribeMessage extends BaseMessage {
20
- constructor({ to, from }: CohortSubscribeMessage) {
21
- super({ to, from, type: BEACON_COHORT_OPT_IN_ACCEPT });
22
- }
23
-
24
- /**
25
- * Initializes a BeaconCohortSubscribeMessage from a possible CohortSubscribeMessage object.
26
- * @param {CohortSubscribeMessage} data The Subscribe object to initialize the SubscribeMessage.
27
- * @returns {BeaconCohortSubscribeMessage} The serialized SubscribeMessage.
28
- */
29
- public static fromJSON(data: Maybe<CohortSubscribeMessage>): BeaconCohortSubscribeMessage {
30
- const message = JSONUtils.isParsable(data) ? JSON.parse(data) : data;
31
- if (message.type != BEACON_COHORT_OPT_IN_ACCEPT) {
32
- throw new Error(`Invalid type: ${message.type}`);
33
- }
34
- return new BeaconCohortSubscribeMessage(message);
35
- }
36
- }
@@ -1,39 +0,0 @@
1
- import type { Maybe } from '@did-btcr2/common';
2
- import { JSONUtils } from '@did-btcr2/common';
3
- import { BaseMessage } from '../base.js';
4
- import { BEACON_COHORT_AGGREGATED_NONCE } from '../constants.js';
5
-
6
- export interface CohortAggregatedNonceMessage {
7
- to: string;
8
- from: string;
9
- cohortId: string;
10
- sessionId: string;
11
- aggregatedNonce: Uint8Array;
12
- }
13
-
14
- /**
15
- * Represents a message containing an aggregated nonce for a cohort in the Beacon protocol.
16
- * @class BeaconCohortAggregatedNonceMessage
17
- * @extends BaseMessage
18
- * @type {BeaconCohortAggregatedNonceMessage}
19
- */
20
- export class BeaconCohortAggregatedNonceMessage extends BaseMessage {
21
- constructor({ to, from, cohortId, sessionId, aggregatedNonce }: CohortAggregatedNonceMessage) {
22
- const body = { cohortId, sessionId, aggregatedNonce };
23
- const type = BEACON_COHORT_AGGREGATED_NONCE;
24
- super({ to, from, body, type });
25
- }
26
-
27
- /**
28
- * Initializes a BeaconCohortAggregatedNonceMessage from a given AggregatedNonce object.
29
- * @param {CohortAggregatedNonceMessage} data The data object to initialize the BeaconCohortAggregatedNonceMessage.
30
- * @returns {BeaconCohortAggregatedNonceMessage} The new BeaconCohortAggregatedNonceMessage.
31
- */
32
- public static fromJSON(data: Maybe<CohortAggregatedNonceMessage>): BeaconCohortAggregatedNonceMessage {
33
- const message = JSONUtils.isParsable(data) ? JSON.parse(data) : data;
34
- if (message.type != BEACON_COHORT_AGGREGATED_NONCE) {
35
- throw new Error(`Invalid type: ${message.type}`);
36
- }
37
- return new BeaconCohortAggregatedNonceMessage(message);
38
- }
39
- }
@@ -1,40 +0,0 @@
1
- import type { Maybe } from '@did-btcr2/common';
2
- import { JSONUtils } from '@did-btcr2/common';
3
- import { BaseMessage } from '../base.js';
4
- import { BEACON_COHORT_AUTHORIZATION_REQUEST } from '../constants.js';
5
-
6
- export interface CohortAuthorizationRequestMessage {
7
- to: string;
8
- from: string;
9
- cohortId: string;
10
- sessionId: string;
11
- pendingTx: string;
12
- }
13
-
14
- /**
15
- * Sends the unsigned PSBT that spends the Beacon UTXO (plus any SMT proofs).
16
- * Asks the cohort to begin a MuSig2 signing session.
17
- * @class BeaconCohortAuthorizationRequestMessage
18
- * @extends BaseMessage
19
- * @type {CohortAuthorizationRequestMessage}
20
- */
21
- export class BeaconCohortAuthorizationRequestMessage extends BaseMessage {
22
- constructor({ to, from, cohortId, sessionId, pendingTx }: CohortAuthorizationRequestMessage) {
23
- const body = { cohortId, sessionId, pendingTx };
24
- const type = BEACON_COHORT_AUTHORIZATION_REQUEST;
25
- super({ to, from, body, type });
26
- }
27
-
28
- /**
29
- * Initializes a BeaconCohortAuthorizationRequestMessage from a given AuthorizationRequest object.
30
- * @param {CohortAuthorizationRequestMessage} data The data object to initialize the BeaconCohortAuthorizationRequestMessage.
31
- * @returns {BeaconCohortAuthorizationRequestMessage} The serialized BeaconCohortAuthorizationRequestMessage.
32
- */
33
- public static fromJSON(data: Maybe<CohortAuthorizationRequestMessage>): BeaconCohortAuthorizationRequestMessage {
34
- const message = JSONUtils.isParsable(data) ? JSON.parse(data) : data;
35
- if (message.type != BEACON_COHORT_AUTHORIZATION_REQUEST) {
36
- throw new Error(`Invalid type: ${message.type}`);
37
- }
38
- return new BeaconCohortAuthorizationRequestMessage(message);
39
- }
40
- }
@@ -1,40 +0,0 @@
1
- import type { Maybe } from '@did-btcr2/common';
2
- import { JSONUtils } from '@did-btcr2/common';
3
- import { BaseMessage } from '../base.js';
4
- import { BEACON_COHORT_NONCE_CONTRIBUTION } from '../constants.js';
5
-
6
- export interface CohortNonceContributionMessage {
7
- to: string;
8
- from: string;
9
- cohortId: string;
10
- sessionId: string;
11
- nonceContribution: Uint8Array;
12
- }
13
-
14
- /**
15
- * Represents a message containing a nonce contribution for a cohort participant.
16
- * Participant → Coordinator. Participant sending their public nonce points for the ongoing signing session.
17
- * @class BeaconCohortNonceContributionMessage
18
- * @extends BaseMessage
19
- * @type {BeaconCohortNonceContributionMessage}
20
- */
21
- export class BeaconCohortNonceContributionMessage extends BaseMessage {
22
- constructor({ to, from, cohortId, sessionId, nonceContribution }: CohortNonceContributionMessage) {
23
- const body = { cohortId, sessionId, nonceContribution };
24
- const type = BEACON_COHORT_NONCE_CONTRIBUTION;
25
- super({ to, from, body, type });
26
- }
27
-
28
- /**
29
- * Initializes a NonceContributionMessage from a given CohortNonceContributionMessage object.
30
- * @param {CohortNonceContributionMessage} data The data object to initialize the BeaconCohortNonceContributionMessage.
31
- * @returns {BeaconCohortNonceContributionMessage} The new BeaconCohortNonceContributionMessage.
32
- */
33
- public static fromJSON(data: Maybe<CohortNonceContributionMessage>): BeaconCohortNonceContributionMessage {
34
- const message = JSONUtils.isParsable(data) ? JSON.parse(data) : data;
35
- if (message.type != BEACON_COHORT_NONCE_CONTRIBUTION) {
36
- throw new Error(`Invalid type: ${message.type}`);
37
- }
38
- return new BeaconCohortNonceContributionMessage(message);
39
- }
40
- }
@@ -1,40 +0,0 @@
1
- import type { Maybe } from '@did-btcr2/common';
2
- import { JSONUtils } from '@did-btcr2/common';
3
- import { BaseMessage } from '../base.js';
4
- import { BEACON_COHORT_REQUEST_SIGNATURE } from '../constants.js';
5
-
6
- export type CohortRequestSignatureMessage = {
7
- to: string;
8
- from: string;
9
- cohortId: string;
10
- sessionId?: string;
11
- data: string;
12
- }
13
-
14
- /**
15
- * Coordinator → Participants. Returns the aggregation of all participant nonces
16
- * so each participant can produce a correct partial signature.
17
- * @class BeaconCohortRequestSignatureMessage
18
- * @extends BaseMessage
19
- * @type {BeaconCohortRequestSignatureMessage}
20
- */
21
- export class BeaconCohortRequestSignatureMessage extends BaseMessage {
22
- constructor({ to, from, cohortId, sessionId, data }: CohortRequestSignatureMessage) {
23
- const body = { cohortId, sessionId, data };
24
- const type = BEACON_COHORT_REQUEST_SIGNATURE;
25
- super({ to, from, body, type });
26
- }
27
-
28
- /**
29
- * Initializes an BeaconCohortRequestSignatureMessage from a possible CohortRequestSignatureMessage object.
30
- * @param {CohortRequestSignatureMessage} data The data object to initialize the BeaconCohortRequestSignatureMessage.
31
- * @returns {BeaconCohortRequestSignatureMessage} The new BeaconCohortRequestSignatureMessage.
32
- */
33
- public static fromJSON(data: Maybe<CohortRequestSignatureMessage>): BeaconCohortRequestSignatureMessage {
34
- const message = JSONUtils.isParsable(data) ? JSON.parse(data) : data;
35
- if (message.type != BEACON_COHORT_REQUEST_SIGNATURE) {
36
- throw new Error(`Invalid type: ${message.type}`);
37
- }
38
- return new BeaconCohortRequestSignatureMessage(message);
39
- }
40
- }
@@ -1,41 +0,0 @@
1
- import type { Maybe } from '@did-btcr2/common';
2
- import { JSONUtils } from '@did-btcr2/common';
3
- import { BaseMessage } from '../base.js';
4
- import { BEACON_COHORT_SIGNATURE_AUTHORIZATION } from '../constants.js';
5
-
6
- export type CohortSignatureAuthorizationMessage = {
7
- to: string;
8
- from: string;
9
- cohortId: string;
10
- sessionId: string;
11
- partialSignature: Uint8Array;
12
- }
13
-
14
- /**
15
- * Participant → Coordinator. Delivers the participant’s partial signature over
16
- * the PSBT, authorizing the final Beacon signal (transaction) once all signatures
17
- * are collected.
18
- * @class BeaconCohortSignatureAuthorizationMessage
19
- * @extends BaseMessage
20
- * @type {BeaconCohortSignatureAuthorizationMessage}
21
- */
22
- export class BeaconCohortSignatureAuthorizationMessage extends BaseMessage {
23
- constructor({ to, from, cohortId, sessionId, partialSignature }: CohortSignatureAuthorizationMessage) {
24
- const body = { cohortId, sessionId, partialSignature };
25
- const type = BEACON_COHORT_SIGNATURE_AUTHORIZATION;
26
- super({ to, from, body, type });
27
- }
28
-
29
- /**
30
- * Initializes an BeaconCohortSignatureAuthorizationMessage from a given CohortSignatureAuthorizationMessage object.
31
- * @param {CohortSignatureAuthorizationMessage} data The data object to initialize the BeaconCohortSignatureAuthorizationMessage.
32
- * @returns {BeaconCohortSignatureAuthorizationMessage} The serialized BeaconCohortSignatureAuthorizationMessage.
33
- */
34
- public static fromJSON(data: Maybe<CohortSignatureAuthorizationMessage>): BeaconCohortSignatureAuthorizationMessage {
35
- const message = JSONUtils.isParsable(data) ? JSON.parse(data) : data;
36
- if (message.type != BEACON_COHORT_SIGNATURE_AUTHORIZATION) {
37
- throw new Error(`Invalid type: ${message.type}`);
38
- }
39
- return new BeaconCohortSignatureAuthorizationMessage(message);
40
- }
41
- }
@@ -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
- }