@did-btcr2/method 0.17.2 → 0.18.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 (366) hide show
  1. package/dist/browser.js +30124 -19552
  2. package/dist/browser.mjs +30123 -19551
  3. package/dist/cjs/core/beacon/aggregation/cohort/index.js +225 -0
  4. package/dist/cjs/core/beacon/aggregation/cohort/index.js.map +1 -0
  5. package/dist/{esm/core/beacon/aggregation → cjs/core/beacon/aggregation/cohort}/messages/base.js +3 -11
  6. package/dist/cjs/core/beacon/aggregation/cohort/messages/base.js.map +1 -0
  7. package/dist/cjs/core/beacon/aggregation/cohort/messages/constants.js +11 -0
  8. package/dist/cjs/core/beacon/aggregation/cohort/messages/constants.js.map +1 -0
  9. package/dist/cjs/core/beacon/aggregation/cohort/messages/index.js +98 -0
  10. package/dist/cjs/core/beacon/aggregation/cohort/messages/index.js.map +1 -0
  11. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js +30 -0
  12. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js.map +1 -0
  13. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js +28 -0
  14. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js.map +1 -0
  15. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js +26 -0
  16. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js.map +1 -0
  17. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in.js +22 -0
  18. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in.js.map +1 -0
  19. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/subscribe.js +27 -0
  20. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/subscribe.js.map +1 -0
  21. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js +28 -0
  22. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js.map +1 -0
  23. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/authorization-request.js +29 -0
  24. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/authorization-request.js.map +1 -0
  25. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js +29 -0
  26. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js.map +1 -0
  27. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/request-signature.js +29 -0
  28. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/request-signature.js.map +1 -0
  29. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js +30 -0
  30. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js.map +1 -0
  31. package/dist/cjs/core/beacon/aggregation/cohort/status.js.map +1 -0
  32. package/dist/cjs/core/beacon/aggregation/communication/adapter/did-comm.js +126 -0
  33. package/dist/cjs/core/beacon/aggregation/communication/adapter/did-comm.js.map +1 -0
  34. package/dist/cjs/core/beacon/aggregation/communication/adapter/nostr.js +230 -0
  35. package/dist/cjs/core/beacon/aggregation/communication/adapter/nostr.js.map +1 -0
  36. package/dist/cjs/core/beacon/aggregation/communication/error.js +12 -0
  37. package/dist/cjs/core/beacon/aggregation/communication/error.js.map +1 -0
  38. package/dist/cjs/core/beacon/aggregation/communication/factory.js +21 -0
  39. package/dist/cjs/core/beacon/aggregation/communication/factory.js.map +1 -0
  40. package/dist/cjs/core/beacon/aggregation/communication/service.js.map +1 -0
  41. package/dist/cjs/core/beacon/aggregation/coordinator.js +282 -56
  42. package/dist/cjs/core/beacon/aggregation/coordinator.js.map +1 -1
  43. package/dist/cjs/core/beacon/aggregation/participant.js +435 -1
  44. package/dist/cjs/core/beacon/aggregation/participant.js.map +1 -1
  45. package/dist/cjs/core/beacon/aggregation/session/index.js +233 -0
  46. package/dist/cjs/core/beacon/aggregation/session/index.js.map +1 -0
  47. package/dist/cjs/core/beacon/aggregation/session/status.js +11 -0
  48. package/dist/cjs/core/beacon/aggregation/session/status.js.map +1 -0
  49. package/dist/cjs/core/beacon/cid-aggregate.js.map +1 -1
  50. package/dist/cjs/core/beacon/error.js +37 -0
  51. package/dist/cjs/core/beacon/error.js.map +1 -0
  52. package/dist/cjs/core/beacon/factory.js.map +1 -1
  53. package/dist/cjs/core/beacon/singleton.js +8 -5
  54. package/dist/cjs/core/beacon/singleton.js.map +1 -1
  55. package/dist/cjs/core/beacon/smt-aggregate.js.map +1 -1
  56. package/dist/cjs/{utils/beacons.js → core/beacon/utils.js} +4 -4
  57. package/dist/cjs/core/beacon/utils.js.map +1 -0
  58. package/dist/cjs/core/crud/read.js +2 -9
  59. package/dist/cjs/core/crud/read.js.map +1 -1
  60. package/dist/cjs/core/crud/update.js +18 -19
  61. package/dist/cjs/core/crud/update.js.map +1 -1
  62. package/dist/{esm/utils → cjs/core}/identifier.js +18 -3
  63. package/dist/cjs/core/identifier.js.map +1 -0
  64. package/dist/cjs/did-btcr2.js +2 -2
  65. package/dist/cjs/did-btcr2.js.map +1 -1
  66. package/dist/cjs/index.js +28 -6
  67. package/dist/cjs/index.js.map +1 -1
  68. package/dist/cjs/interfaces/beacon.js.map +1 -1
  69. package/dist/cjs/utils/appendix.js +2 -3
  70. package/dist/cjs/utils/appendix.js.map +1 -1
  71. package/dist/cjs/utils/did-document.js +4 -6
  72. package/dist/cjs/utils/did-document.js.map +1 -1
  73. package/dist/cjs/utils/types.js +2 -0
  74. package/dist/cjs/utils/types.js.map +1 -0
  75. package/dist/esm/core/beacon/aggregation/cohort/index.js +225 -0
  76. package/dist/esm/core/beacon/aggregation/cohort/index.js.map +1 -0
  77. package/dist/{cjs/core/beacon/aggregation → esm/core/beacon/aggregation/cohort}/messages/base.js +3 -11
  78. package/dist/esm/core/beacon/aggregation/cohort/messages/base.js.map +1 -0
  79. package/dist/esm/core/beacon/aggregation/cohort/messages/constants.js +11 -0
  80. package/dist/esm/core/beacon/aggregation/cohort/messages/constants.js.map +1 -0
  81. package/dist/esm/core/beacon/aggregation/cohort/messages/index.js +98 -0
  82. package/dist/esm/core/beacon/aggregation/cohort/messages/index.js.map +1 -0
  83. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js +30 -0
  84. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js.map +1 -0
  85. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js +28 -0
  86. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js.map +1 -0
  87. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js +26 -0
  88. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js.map +1 -0
  89. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in.js +22 -0
  90. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in.js.map +1 -0
  91. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/subscribe.js +27 -0
  92. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/subscribe.js.map +1 -0
  93. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js +28 -0
  94. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js.map +1 -0
  95. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/authorization-request.js +29 -0
  96. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/authorization-request.js.map +1 -0
  97. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js +29 -0
  98. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js.map +1 -0
  99. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/request-signature.js +29 -0
  100. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/request-signature.js.map +1 -0
  101. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js +30 -0
  102. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js.map +1 -0
  103. package/dist/esm/core/beacon/aggregation/cohort/status.js.map +1 -0
  104. package/dist/esm/core/beacon/aggregation/communication/adapter/did-comm.js +126 -0
  105. package/dist/esm/core/beacon/aggregation/communication/adapter/did-comm.js.map +1 -0
  106. package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js +230 -0
  107. package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js.map +1 -0
  108. package/dist/esm/core/beacon/aggregation/communication/error.js +12 -0
  109. package/dist/esm/core/beacon/aggregation/communication/error.js.map +1 -0
  110. package/dist/esm/core/beacon/aggregation/communication/factory.js +21 -0
  111. package/dist/esm/core/beacon/aggregation/communication/factory.js.map +1 -0
  112. package/dist/esm/core/beacon/aggregation/communication/service.js.map +1 -0
  113. package/dist/esm/core/beacon/aggregation/coordinator.js +282 -56
  114. package/dist/esm/core/beacon/aggregation/coordinator.js.map +1 -1
  115. package/dist/esm/core/beacon/aggregation/participant.js +435 -1
  116. package/dist/esm/core/beacon/aggregation/participant.js.map +1 -1
  117. package/dist/esm/core/beacon/aggregation/session/index.js +233 -0
  118. package/dist/esm/core/beacon/aggregation/session/index.js.map +1 -0
  119. package/dist/esm/core/beacon/aggregation/session/status.js +11 -0
  120. package/dist/esm/core/beacon/aggregation/session/status.js.map +1 -0
  121. package/dist/esm/core/beacon/cid-aggregate.js.map +1 -1
  122. package/dist/esm/core/beacon/error.js +37 -0
  123. package/dist/esm/core/beacon/error.js.map +1 -0
  124. package/dist/esm/core/beacon/factory.js.map +1 -1
  125. package/dist/esm/core/beacon/singleton.js +8 -5
  126. package/dist/esm/core/beacon/singleton.js.map +1 -1
  127. package/dist/esm/core/beacon/smt-aggregate.js.map +1 -1
  128. package/dist/esm/{utils/beacons.js → core/beacon/utils.js} +4 -4
  129. package/dist/esm/core/beacon/utils.js.map +1 -0
  130. package/dist/esm/core/crud/read.js +2 -9
  131. package/dist/esm/core/crud/read.js.map +1 -1
  132. package/dist/esm/core/crud/update.js +18 -19
  133. package/dist/esm/core/crud/update.js.map +1 -1
  134. package/dist/{cjs/utils → esm/core}/identifier.js +18 -3
  135. package/dist/esm/core/identifier.js.map +1 -0
  136. package/dist/esm/did-btcr2.js +2 -2
  137. package/dist/esm/did-btcr2.js.map +1 -1
  138. package/dist/esm/index.js +28 -6
  139. package/dist/esm/index.js.map +1 -1
  140. package/dist/esm/interfaces/beacon.js.map +1 -1
  141. package/dist/esm/utils/appendix.js +2 -3
  142. package/dist/esm/utils/appendix.js.map +1 -1
  143. package/dist/esm/utils/did-document.js +4 -6
  144. package/dist/esm/utils/did-document.js.map +1 -1
  145. package/dist/esm/utils/types.js +2 -0
  146. package/dist/esm/utils/types.js.map +1 -0
  147. package/dist/types/core/beacon/aggregation/cohort/index.d.ts +135 -0
  148. package/dist/types/core/beacon/aggregation/cohort/index.d.ts.map +1 -0
  149. package/dist/types/core/beacon/aggregation/{messages → cohort/messages}/base.d.ts +13 -8
  150. package/dist/types/core/beacon/aggregation/cohort/messages/base.d.ts.map +1 -0
  151. package/dist/types/core/beacon/aggregation/cohort/messages/constants.d.ts +10 -0
  152. package/dist/types/core/beacon/aggregation/cohort/messages/constants.d.ts.map +1 -0
  153. package/dist/types/core/beacon/aggregation/cohort/messages/index.d.ts +64 -0
  154. package/dist/types/core/beacon/aggregation/cohort/messages/index.d.ts.map +1 -0
  155. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.d.ts +28 -0
  156. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.d.ts.map +1 -0
  157. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts +26 -0
  158. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts.map +1 -0
  159. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.d.ts +23 -0
  160. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.d.ts.map +1 -0
  161. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in.d.ts +19 -0
  162. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in.d.ts.map +1 -0
  163. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/subscribe.d.ts +24 -0
  164. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/subscribe.d.ts.map +1 -0
  165. package/dist/types/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.d.ts +24 -0
  166. package/dist/types/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.d.ts.map +1 -0
  167. package/dist/types/core/beacon/aggregation/cohort/messages/sign/authorization-request.d.ts +25 -0
  168. package/dist/types/core/beacon/aggregation/cohort/messages/sign/authorization-request.d.ts.map +1 -0
  169. package/dist/types/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.d.ts +25 -0
  170. package/dist/types/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.d.ts.map +1 -0
  171. package/dist/types/core/beacon/aggregation/cohort/messages/sign/request-signature.d.ts +25 -0
  172. package/dist/types/core/beacon/aggregation/cohort/messages/sign/request-signature.d.ts.map +1 -0
  173. package/dist/types/core/beacon/aggregation/cohort/messages/sign/signature-authorization.d.ts +26 -0
  174. package/dist/types/core/beacon/aggregation/cohort/messages/sign/signature-authorization.d.ts.map +1 -0
  175. package/dist/types/core/beacon/aggregation/cohort/status.d.ts.map +1 -0
  176. package/dist/types/core/beacon/aggregation/communication/adapter/did-comm.d.ts +88 -0
  177. package/dist/types/core/beacon/aggregation/communication/adapter/did-comm.d.ts.map +1 -0
  178. package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts +93 -0
  179. package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts.map +1 -0
  180. package/dist/types/core/beacon/aggregation/communication/error.d.ts +7 -0
  181. package/dist/types/core/beacon/aggregation/communication/error.d.ts.map +1 -0
  182. package/dist/types/core/beacon/aggregation/communication/factory.d.ts +9 -0
  183. package/dist/types/core/beacon/aggregation/communication/factory.d.ts.map +1 -0
  184. package/dist/types/core/beacon/aggregation/communication/service.d.ts +35 -0
  185. package/dist/types/core/beacon/aggregation/communication/service.d.ts.map +1 -0
  186. package/dist/types/core/beacon/aggregation/coordinator.d.ts +79 -26
  187. package/dist/types/core/beacon/aggregation/coordinator.d.ts.map +1 -1
  188. package/dist/types/core/beacon/aggregation/participant.d.ts +190 -0
  189. package/dist/types/core/beacon/aggregation/participant.d.ts.map +1 -1
  190. package/dist/types/core/beacon/aggregation/session/index.d.ts +155 -0
  191. package/dist/types/core/beacon/aggregation/session/index.d.ts.map +1 -0
  192. package/dist/types/core/beacon/aggregation/session/status.d.ts +10 -0
  193. package/dist/types/core/beacon/aggregation/session/status.d.ts.map +1 -0
  194. package/dist/types/core/beacon/cid-aggregate.d.ts +3 -4
  195. package/dist/types/core/beacon/cid-aggregate.d.ts.map +1 -1
  196. package/dist/types/core/beacon/error.d.ts +22 -0
  197. package/dist/types/core/beacon/error.d.ts.map +1 -0
  198. package/dist/types/core/beacon/factory.d.ts +2 -3
  199. package/dist/types/core/beacon/factory.d.ts.map +1 -1
  200. package/dist/types/core/beacon/singleton.d.ts +2 -3
  201. package/dist/types/core/beacon/singleton.d.ts.map +1 -1
  202. package/dist/types/core/beacon/smt-aggregate.d.ts +3 -4
  203. package/dist/types/core/beacon/smt-aggregate.d.ts.map +1 -1
  204. package/dist/types/{utils/beacons.d.ts → core/beacon/utils.d.ts} +3 -3
  205. package/dist/types/core/beacon/utils.d.ts.map +1 -0
  206. package/dist/types/core/crud/read.d.ts +3 -3
  207. package/dist/types/core/crud/read.d.ts.map +1 -1
  208. package/dist/types/core/crud/update.d.ts +1 -1
  209. package/dist/types/core/crud/update.d.ts.map +1 -1
  210. package/dist/types/{utils → core}/identifier.d.ts +24 -3
  211. package/dist/types/core/identifier.d.ts.map +1 -0
  212. package/dist/types/did-btcr2.d.ts +1 -1
  213. package/dist/types/did-btcr2.d.ts.map +1 -1
  214. package/dist/types/index.d.ts +28 -6
  215. package/dist/types/index.d.ts.map +1 -1
  216. package/dist/types/interfaces/beacon.d.ts +65 -5
  217. package/dist/types/interfaces/beacon.d.ts.map +1 -1
  218. package/dist/types/interfaces/crud.d.ts +1 -1
  219. package/dist/types/interfaces/crud.d.ts.map +1 -1
  220. package/dist/types/utils/appendix.d.ts +2 -10
  221. package/dist/types/utils/appendix.d.ts.map +1 -1
  222. package/dist/types/utils/did-document-builder.d.ts +1 -1
  223. package/dist/types/utils/did-document-builder.d.ts.map +1 -1
  224. package/dist/types/utils/did-document.d.ts +1 -1
  225. package/dist/types/utils/did-document.d.ts.map +1 -1
  226. package/dist/types/{types/crud.d.ts → utils/types.d.ts} +2 -2
  227. package/dist/types/utils/types.d.ts.map +1 -0
  228. package/package.json +4 -3
  229. package/src/core/beacon/aggregation/cohort/index.ts +292 -0
  230. package/src/core/beacon/aggregation/{messages → cohort/messages}/base.ts +14 -16
  231. package/src/core/beacon/aggregation/cohort/messages/constants.ts +12 -0
  232. package/src/core/beacon/aggregation/cohort/messages/index.ts +143 -0
  233. package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.ts +43 -0
  234. package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.ts +39 -0
  235. package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.ts +34 -0
  236. package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in.ts +33 -0
  237. package/src/core/beacon/aggregation/cohort/messages/keygen/subscribe.ts +35 -0
  238. package/src/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.ts +38 -0
  239. package/src/core/beacon/aggregation/cohort/messages/sign/authorization-request.ts +39 -0
  240. package/src/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.ts +39 -0
  241. package/src/core/beacon/aggregation/cohort/messages/sign/request-signature.ts +39 -0
  242. package/src/core/beacon/aggregation/cohort/messages/sign/signature-authorization.ts +40 -0
  243. package/src/core/beacon/aggregation/communication/adapter/did-comm.ts +153 -0
  244. package/src/core/beacon/aggregation/communication/adapter/nostr.ts +300 -0
  245. package/src/core/beacon/aggregation/communication/error.ts +13 -0
  246. package/src/core/beacon/aggregation/communication/factory.ts +25 -0
  247. package/src/core/beacon/aggregation/communication/service.ts +42 -0
  248. package/src/core/beacon/aggregation/coordinator.ts +338 -67
  249. package/src/core/beacon/aggregation/participant.ts +512 -0
  250. package/src/core/beacon/aggregation/session/index.ts +289 -0
  251. package/src/core/beacon/aggregation/session/status.ts +18 -0
  252. package/src/core/beacon/cid-aggregate.ts +4 -5
  253. package/src/core/beacon/error.ts +44 -0
  254. package/src/core/beacon/factory.ts +2 -3
  255. package/src/core/beacon/singleton.ts +10 -8
  256. package/src/core/beacon/smt-aggregate.ts +4 -5
  257. package/src/{utils/beacons.ts → core/beacon/utils.ts} +5 -5
  258. package/src/core/crud/read.ts +7 -16
  259. package/src/core/crud/update.ts +25 -22
  260. package/src/{utils → core}/identifier.ts +35 -5
  261. package/src/did-btcr2.ts +4 -4
  262. package/src/index.ts +36 -8
  263. package/src/interfaces/beacon.ts +75 -5
  264. package/src/interfaces/crud.ts +1 -1
  265. package/src/utils/appendix.ts +3 -11
  266. package/src/utils/did-document-builder.ts +1 -1
  267. package/src/utils/did-document.ts +4 -7
  268. package/src/{types/crud.ts → utils/types.ts} +2 -2
  269. package/dist/cjs/core/beacon/aggregation/messages/advert.js +0 -24
  270. package/dist/cjs/core/beacon/aggregation/messages/advert.js.map +0 -1
  271. package/dist/cjs/core/beacon/aggregation/messages/base.js.map +0 -1
  272. package/dist/cjs/core/beacon/aggregation/messages/cohort-set.js +0 -25
  273. package/dist/cjs/core/beacon/aggregation/messages/cohort-set.js.map +0 -1
  274. package/dist/cjs/core/beacon/aggregation/messages/keygen.js +0 -8
  275. package/dist/cjs/core/beacon/aggregation/messages/keygen.js.map +0 -1
  276. package/dist/cjs/core/beacon/aggregation/messages/opt-in.js +0 -23
  277. package/dist/cjs/core/beacon/aggregation/messages/opt-in.js.map +0 -1
  278. package/dist/cjs/core/beacon/aggregation/messages/sign.js +0 -7
  279. package/dist/cjs/core/beacon/aggregation/messages/sign.js.map +0 -1
  280. package/dist/cjs/core/beacon/aggregation/models/cohort/index.js +0 -92
  281. package/dist/cjs/core/beacon/aggregation/models/cohort/index.js.map +0 -1
  282. package/dist/cjs/core/beacon/aggregation/models/cohort/status.js.map +0 -1
  283. package/dist/cjs/core/beacon/aggregation/protocol/nostr.js +0 -57
  284. package/dist/cjs/core/beacon/aggregation/protocol/nostr.js.map +0 -1
  285. package/dist/cjs/core/beacon/aggregation/protocol/service.js.map +0 -1
  286. package/dist/cjs/core/key-manager/index.js +0 -290
  287. package/dist/cjs/core/key-manager/index.js.map +0 -1
  288. package/dist/cjs/core/key-manager/interface.js +0 -2
  289. package/dist/cjs/core/key-manager/interface.js.map +0 -1
  290. package/dist/cjs/interfaces/ibeacon.js +0 -2
  291. package/dist/cjs/interfaces/ibeacon.js.map +0 -1
  292. package/dist/cjs/types/crud.js +0 -2
  293. package/dist/cjs/types/crud.js.map +0 -1
  294. package/dist/cjs/utils/beacons.js.map +0 -1
  295. package/dist/cjs/utils/identifier.js.map +0 -1
  296. package/dist/esm/core/beacon/aggregation/messages/advert.js +0 -24
  297. package/dist/esm/core/beacon/aggregation/messages/advert.js.map +0 -1
  298. package/dist/esm/core/beacon/aggregation/messages/base.js.map +0 -1
  299. package/dist/esm/core/beacon/aggregation/messages/cohort-set.js +0 -25
  300. package/dist/esm/core/beacon/aggregation/messages/cohort-set.js.map +0 -1
  301. package/dist/esm/core/beacon/aggregation/messages/keygen.js +0 -8
  302. package/dist/esm/core/beacon/aggregation/messages/keygen.js.map +0 -1
  303. package/dist/esm/core/beacon/aggregation/messages/opt-in.js +0 -23
  304. package/dist/esm/core/beacon/aggregation/messages/opt-in.js.map +0 -1
  305. package/dist/esm/core/beacon/aggregation/messages/sign.js +0 -7
  306. package/dist/esm/core/beacon/aggregation/messages/sign.js.map +0 -1
  307. package/dist/esm/core/beacon/aggregation/models/cohort/index.js +0 -92
  308. package/dist/esm/core/beacon/aggregation/models/cohort/index.js.map +0 -1
  309. package/dist/esm/core/beacon/aggregation/models/cohort/status.js.map +0 -1
  310. package/dist/esm/core/beacon/aggregation/protocol/nostr.js +0 -57
  311. package/dist/esm/core/beacon/aggregation/protocol/nostr.js.map +0 -1
  312. package/dist/esm/core/beacon/aggregation/protocol/service.js.map +0 -1
  313. package/dist/esm/core/key-manager/index.js +0 -290
  314. package/dist/esm/core/key-manager/index.js.map +0 -1
  315. package/dist/esm/core/key-manager/interface.js +0 -2
  316. package/dist/esm/core/key-manager/interface.js.map +0 -1
  317. package/dist/esm/interfaces/ibeacon.js +0 -2
  318. package/dist/esm/interfaces/ibeacon.js.map +0 -1
  319. package/dist/esm/types/crud.js +0 -2
  320. package/dist/esm/types/crud.js.map +0 -1
  321. package/dist/esm/utils/beacons.js.map +0 -1
  322. package/dist/esm/utils/identifier.js.map +0 -1
  323. package/dist/types/core/beacon/aggregation/messages/advert.d.ts +0 -22
  324. package/dist/types/core/beacon/aggregation/messages/advert.d.ts.map +0 -1
  325. package/dist/types/core/beacon/aggregation/messages/base.d.ts.map +0 -1
  326. package/dist/types/core/beacon/aggregation/messages/cohort-set.d.ts +0 -23
  327. package/dist/types/core/beacon/aggregation/messages/cohort-set.d.ts.map +0 -1
  328. package/dist/types/core/beacon/aggregation/messages/keygen.d.ts +0 -6
  329. package/dist/types/core/beacon/aggregation/messages/keygen.d.ts.map +0 -1
  330. package/dist/types/core/beacon/aggregation/messages/opt-in.d.ts +0 -22
  331. package/dist/types/core/beacon/aggregation/messages/opt-in.d.ts.map +0 -1
  332. package/dist/types/core/beacon/aggregation/messages/sign.d.ts +0 -5
  333. package/dist/types/core/beacon/aggregation/messages/sign.d.ts.map +0 -1
  334. package/dist/types/core/beacon/aggregation/models/cohort/index.d.ts +0 -77
  335. package/dist/types/core/beacon/aggregation/models/cohort/index.d.ts.map +0 -1
  336. package/dist/types/core/beacon/aggregation/models/cohort/status.d.ts.map +0 -1
  337. package/dist/types/core/beacon/aggregation/protocol/nostr.d.ts +0 -36
  338. package/dist/types/core/beacon/aggregation/protocol/nostr.d.ts.map +0 -1
  339. package/dist/types/core/beacon/aggregation/protocol/service.d.ts +0 -6
  340. package/dist/types/core/beacon/aggregation/protocol/service.d.ts.map +0 -1
  341. package/dist/types/core/key-manager/index.d.ts +0 -145
  342. package/dist/types/core/key-manager/index.d.ts.map +0 -1
  343. package/dist/types/core/key-manager/interface.d.ts +0 -113
  344. package/dist/types/core/key-manager/interface.d.ts.map +0 -1
  345. package/dist/types/interfaces/ibeacon.d.ts +0 -65
  346. package/dist/types/interfaces/ibeacon.d.ts.map +0 -1
  347. package/dist/types/types/crud.d.ts.map +0 -1
  348. package/dist/types/utils/beacons.d.ts.map +0 -1
  349. package/dist/types/utils/identifier.d.ts.map +0 -1
  350. package/src/core/beacon/aggregation/messages/advert.ts +0 -36
  351. package/src/core/beacon/aggregation/messages/cohort-set.ts +0 -37
  352. package/src/core/beacon/aggregation/messages/keygen.ts +0 -8
  353. package/src/core/beacon/aggregation/messages/opt-in.ts +0 -35
  354. package/src/core/beacon/aggregation/messages/sign.ts +0 -7
  355. package/src/core/beacon/aggregation/models/cohort/index.ts +0 -112
  356. package/src/core/beacon/aggregation/protocol/nostr.ts +0 -81
  357. package/src/core/beacon/aggregation/protocol/service.ts +0 -6
  358. package/src/core/key-manager/index.ts +0 -364
  359. package/src/core/key-manager/interface.ts +0 -129
  360. package/src/interfaces/ibeacon.ts +0 -75
  361. /package/dist/cjs/core/beacon/aggregation/{models/cohort → cohort}/status.js +0 -0
  362. /package/dist/cjs/core/beacon/aggregation/{protocol → communication}/service.js +0 -0
  363. /package/dist/esm/core/beacon/aggregation/{models/cohort → cohort}/status.js +0 -0
  364. /package/dist/esm/core/beacon/aggregation/{protocol → communication}/service.js +0 -0
  365. /package/dist/types/core/beacon/aggregation/{models/cohort → cohort}/status.d.ts +0 -0
  366. /package/src/core/beacon/aggregation/{models/cohort → cohort}/status.ts +0 -0
@@ -0,0 +1,29 @@
1
+ import { BaseMessage } from '../base.js';
2
+ import { BEACON_COHORT_NONCE_CONTRIBUTION } from '../constants.js';
3
+ /**
4
+ * Represents a message containing a nonce contribution for a cohort participant.
5
+ * Participant → Coordinator. Participant sending their public nonce points for the ongoing signing session.
6
+ * @class BeaconCohortNonceContributionMessage
7
+ * @extends BaseMessage
8
+ * @type {BeaconCohortNonceContributionMessage}
9
+ */
10
+ export class BeaconCohortNonceContributionMessage extends BaseMessage {
11
+ constructor({ to, from, cohortId, sessionId, nonceContribution }) {
12
+ const body = { cohortId, sessionId, nonceContribution };
13
+ const type = BEACON_COHORT_NONCE_CONTRIBUTION;
14
+ super({ to, from, body, type });
15
+ }
16
+ /**
17
+ * Initializes a NonceContributionMessage from a given CohortNonceContributionMessage object.
18
+ * @param {CohortNonceContributionMessage} data The data object to initialize the BeaconCohortNonceContributionMessage.
19
+ * @returns {BeaconCohortNonceContributionMessage} The new BeaconCohortNonceContributionMessage.
20
+ */
21
+ static fromJSON(data) {
22
+ const message = JSON.parse(data);
23
+ if (message.type != BEACON_COHORT_NONCE_CONTRIBUTION) {
24
+ throw new Error(`Invalid type: ${message.type}`);
25
+ }
26
+ return new BeaconCohortNonceContributionMessage(message);
27
+ }
28
+ }
29
+ //# sourceMappingURL=nonce-contribution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nonce-contribution.js","sourceRoot":"","sources":["../../../../../../../../src/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,gCAAgC,EAAE,MAAM,iBAAiB,CAAC;AAUnE;;;;;;GAMG;AACH,MAAM,OAAO,oCAAqC,SAAQ,WAAW;IACnE,YAAY,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,iBAAiB,EAAkC;QAC9F,MAAM,IAAI,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;QACxD,MAAM,IAAI,GAAG,gCAAgC,CAAC;QAC9C,KAAK,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,QAAQ,CAAC,IAA2C;QAChE,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,OAAO,CAAC,IAAI,IAAI,gCAAgC,EAAE,CAAC;YACrD,MAAM,IAAI,KAAK,CAAC,iBAAiB,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QACnD,CAAC;QACD,OAAO,IAAI,oCAAoC,CAAC,OAAO,CAAC,CAAC;IAC3D,CAAC;CACF"}
@@ -0,0 +1,29 @@
1
+ import { BaseMessage } from '../base.js';
2
+ import { BEACON_COHORT_REQUEST_SIGNATURE } from '../constants.js';
3
+ /**
4
+ * Coordinator → Participants. Returns the aggregation of all participant nonces
5
+ * so each participant can produce a correct partial signature.
6
+ * @class BeaconCohortRequestSignatureMessage
7
+ * @extends BaseMessage
8
+ * @type {BeaconCohortRequestSignatureMessage}
9
+ */
10
+ export class BeaconCohortRequestSignatureMessage extends BaseMessage {
11
+ constructor({ to, from, cohortId, sessionId, data }) {
12
+ const body = { cohortId, sessionId, data };
13
+ const type = BEACON_COHORT_REQUEST_SIGNATURE;
14
+ super({ to, from, body, type });
15
+ }
16
+ /**
17
+ * Initializes an BeaconCohortRequestSignatureMessage from a possible CohortRequestSignatureMessage object.
18
+ * @param {CohortRequestSignatureMessage} data The data object to initialize the BeaconCohortRequestSignatureMessage.
19
+ * @returns {BeaconCohortRequestSignatureMessage} The new BeaconCohortRequestSignatureMessage.
20
+ */
21
+ static fromJSON(data) {
22
+ const message = JSON.parse(data);
23
+ if (message.type != BEACON_COHORT_REQUEST_SIGNATURE) {
24
+ throw new Error(`Invalid type: ${message.type}`);
25
+ }
26
+ return new BeaconCohortRequestSignatureMessage(message);
27
+ }
28
+ }
29
+ //# sourceMappingURL=request-signature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-signature.js","sourceRoot":"","sources":["../../../../../../../../src/core/beacon/aggregation/cohort/messages/sign/request-signature.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,+BAA+B,EAAE,MAAM,iBAAiB,CAAC;AAUlE;;;;;;GAMG;AACH,MAAM,OAAO,mCAAoC,SAAQ,WAAW;IAClE,YAAY,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAiC;QAChF,MAAM,IAAI,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QAC3C,MAAM,IAAI,GAAG,+BAA+B,CAAC;QAC7C,KAAK,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,QAAQ,CAAC,IAA0C;QAC/D,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,OAAO,CAAC,IAAI,IAAI,+BAA+B,EAAE,CAAC;YACpD,MAAM,IAAI,KAAK,CAAC,iBAAiB,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QACnD,CAAC;QACD,OAAO,IAAI,mCAAmC,CAAC,OAAO,CAAC,CAAC;IAC1D,CAAC;CACF"}
@@ -0,0 +1,30 @@
1
+ import { BaseMessage } from '../base.js';
2
+ import { BEACON_COHORT_SIGNATURE_AUTHORIZATION } from '../constants.js';
3
+ /**
4
+ * Participant → Coordinator. Delivers the participant’s partial signature over
5
+ * the PSBT, authorizing the final Beacon signal (transaction) once all signatures
6
+ * are collected.
7
+ * @class BeaconCohortSignatureAuthorizationMessage
8
+ * @extends BaseMessage
9
+ * @type {BeaconCohortSignatureAuthorizationMessage}
10
+ */
11
+ export class BeaconCohortSignatureAuthorizationMessage extends BaseMessage {
12
+ constructor({ to, from, cohortId, sessionId, partialSignature }) {
13
+ const body = { cohortId, sessionId, partialSignature };
14
+ const type = BEACON_COHORT_SIGNATURE_AUTHORIZATION;
15
+ super({ to, from, body, type });
16
+ }
17
+ /**
18
+ * Initializes an BeaconCohortSignatureAuthorizationMessage from a given CohortSignatureAuthorizationMessage object.
19
+ * @param {CohortSignatureAuthorizationMessage} data The data object to initialize the BeaconCohortSignatureAuthorizationMessage.
20
+ * @returns {BeaconCohortSignatureAuthorizationMessage} The serialized BeaconCohortSignatureAuthorizationMessage.
21
+ */
22
+ static fromJSON(data) {
23
+ const message = JSON.parse(data);
24
+ if (message.type != BEACON_COHORT_SIGNATURE_AUTHORIZATION) {
25
+ throw new Error(`Invalid type: ${message.type}`);
26
+ }
27
+ return new BeaconCohortSignatureAuthorizationMessage(message);
28
+ }
29
+ }
30
+ //# sourceMappingURL=signature-authorization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signature-authorization.js","sourceRoot":"","sources":["../../../../../../../../src/core/beacon/aggregation/cohort/messages/sign/signature-authorization.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,qCAAqC,EAAE,MAAM,iBAAiB,CAAC;AAUxE;;;;;;;GAOG;AACH,MAAM,OAAO,yCAA0C,SAAQ,WAAW;IACxE,YAAY,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,gBAAgB,EAAuC;QAClG,MAAM,IAAI,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC;QACvD,MAAM,IAAI,GAAG,qCAAqC,CAAC;QACnD,KAAK,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,QAAQ,CAAC,IAAgD;QACrE,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,OAAO,CAAC,IAAI,IAAI,qCAAqC,EAAE,CAAC;YAC1D,MAAM,IAAI,KAAK,CAAC,iBAAiB,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QACnD,CAAC;QACD,OAAO,IAAI,yCAAyC,CAAC,OAAO,CAAC,CAAC;IAChE,CAAC;CACF"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.js","sourceRoot":"","sources":["../../../../../../src/core/beacon/aggregation/cohort/status.ts"],"names":[],"mappings":"AACA,MAAM,CAAN,IAAY,aAKX;AALD,WAAY,aAAa;IACvB,iDAAgC,CAAA;IAChC,6CAA4B,CAAA;IAC5B,iDAAgC,CAAA;IAChC,yCAAwB,CAAA;AAC1B,CAAC,EALW,aAAa,KAAb,aAAa,QAKxB"}
@@ -0,0 +1,126 @@
1
+ import { NotImplementedError } from '@did-btcr2/common';
2
+ import { SchnorrKeyPair, Secp256k1SecretKey } from '@did-btcr2/keypair';
3
+ import { Identifier } from '../../../../identifier.js';
4
+ /**
5
+ * DidCommAdapterConfig is a configuration class for the DidCommAdapter.
6
+ * It holds the necessary parameters to connect to Nostr relays and manage keys.
7
+ * @class DidCommAdapterConfig
8
+ * @implements {ServiceAdapterConfig}
9
+ * @type {DidCommAdapterConfig}
10
+ */
11
+ export class DidCommAdapterConfig {
12
+ keys;
13
+ components;
14
+ did;
15
+ coordinatorDids;
16
+ /**
17
+ * Constructs a new DidCommAdapterConfig instance.
18
+ * @param {Partial<ServiceAdapterConfig>} [config] Optional configuration parameters to initialize the adapter.
19
+ * @constructor
20
+ * @type {DidCommAdapterConfig}
21
+ */
22
+ constructor(config) {
23
+ this.keys = config?.keys || SchnorrKeyPair.generate().raw,
24
+ this.components = config?.components || {
25
+ version: 1,
26
+ idType: 'KEY',
27
+ network: 'mutinynet'
28
+ };
29
+ this.did = config?.did || Identifier.encode({
30
+ ...this.components,
31
+ genesisBytes: this.keys.public
32
+ });
33
+ this.coordinatorDids = config?.coordinatorDids || [];
34
+ }
35
+ }
36
+ /**
37
+ * DidCommAdapter implements the CommunicationService interface for DidComm protocol.
38
+ * It handles message sending, receiving, and identity generation using DidComm.
39
+ * @class DidCommAdapter
40
+ * @implements {CommunicationService}
41
+ * @type {DidCommAdapter}
42
+ */
43
+ export class DidCommAdapter {
44
+ /**
45
+ * The name of the communication service.
46
+ * @type {string}
47
+ */
48
+ name = 'didcomm';
49
+ /**
50
+ * The configuration for the DidComm adapter.
51
+ * @type {DidCommAdapterConfig}
52
+ */
53
+ config;
54
+ /**
55
+ * A map of message handlers for different message types.
56
+ * @type {Map<string, MessageHandler>}
57
+ */
58
+ handlers = new Map();
59
+ /**
60
+ * Constructs a new DidCommAdapter instance with the provided configuration.
61
+ * @param {DidCommAdapterConfig} [config] The configuration for the Nostr adapter.
62
+ */
63
+ constructor(config = {}) {
64
+ this.config = new DidCommAdapterConfig(config);
65
+ }
66
+ /**
67
+ * Starts the DidComm service.
68
+ * @returns {void} Returns the DidCommAdapter instance for method chaining.
69
+ */
70
+ start() {
71
+ throw new NotImplementedError('DidCommAdapter is not implemented. Use NostrAdapter instead.');
72
+ }
73
+ /**
74
+ * Sets the keys used for Nostr communication.
75
+ * @param {ServiceAdapterIdentity<NostrKeys>} keys The keys to set.
76
+ */
77
+ setKeys(keys) {
78
+ this.config.keys = keys;
79
+ }
80
+ /**
81
+ * Registers a message handler for a specific message type.
82
+ * @param {string} messageType The type of message to handle.
83
+ * @param {MessageHandler} handler The handler function that processes the message.
84
+ */
85
+ registerMessageHandler(messageType, handler) {
86
+ this.handlers.set(messageType, handler);
87
+ }
88
+ /**
89
+ * Sends a message to a recipient using the Nostr protocol.
90
+ * This method is a placeholder and should be implemented with actual Nostr message sending logic.
91
+ * @param {Maybe<AggregateBeaconMessageType>} _message The message to send, typically containing the content and metadata.
92
+ * @param {string} _recipient The public key or identifier of the recipient.
93
+ * @param {string} _sender The public key or identifier of the sender.
94
+ * @returns {Promise<void>} A promise that resolves when the message is sent.
95
+ */
96
+ async sendMessage(_message, _recipient, _sender) {
97
+ throw new NotImplementedError('DidCommAdapter.start() is not implemented. Use NostrAdapter instead.');
98
+ }
99
+ /**
100
+ * Generates a DidComm identity.
101
+ * @param {RawKeyPair} [keys] Optional keys to use for identity generation.
102
+ * @returns {ServiceAdapterConfig} The generated DidComm identity configuration.
103
+ */
104
+ generateIdentity(keys) {
105
+ if (!keys) {
106
+ this.config.keys.secret = Secp256k1SecretKey.random();
107
+ this.config.keys.public = Secp256k1SecretKey.getPublicKey(this.config.keys.secret).compressed;
108
+ this.config.did = Identifier.encode({
109
+ idType: this.config.components.idType || 'KEY',
110
+ version: this.config.components.version || 1,
111
+ network: this.config.components.network || 'signet',
112
+ genesisBytes: this.config.keys.public
113
+ });
114
+ return this.config;
115
+ }
116
+ this.config.keys = keys;
117
+ this.config.did = Identifier.encode({
118
+ idType: this.config.components.idType || 'KEY',
119
+ version: this.config.components.version || 1,
120
+ network: this.config.components.network || 'signet',
121
+ genesisBytes: this.config.keys.public
122
+ });
123
+ return this.config;
124
+ }
125
+ }
126
+ //# sourceMappingURL=did-comm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"did-comm.js","sourceRoot":"","sources":["../../../../../../../src/core/beacon/aggregation/communication/adapter/did-comm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAqB,cAAc,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAIvD;;;;;;GAMG;AACH,MAAM,OAAO,oBAAoB;IACxB,IAAI,CAAoB;IACxB,UAAU,CAIf;IACK,GAAG,CAAS;IACZ,eAAe,CAAW;IAEjC;;;;;OAKG;IACH,YAAY,MAAsC;QAChD,IAAI,CAAC,IAAI,GAAG,MAAM,EAAE,IAAI,IAAI,cAAc,CAAC,QAAQ,EAAE,CA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keypair';
2
+ import { nonceGen } from '@scure/btc-signer/musig2';
3
+ import { finalizeEvent, nip44 } from 'nostr-tools';
4
+ import { SimplePool } from 'nostr-tools/pool';
5
+ import { Identifier } from '../../../../identifier.js';
6
+ import { BEACON_COHORT_ADVERT, BEACON_COHORT_AGGREGATED_NONCE, BEACON_COHORT_AUTHORIZATION_REQUEST, BEACON_COHORT_NONCE_CONTRIBUTION, BEACON_COHORT_OPT_IN, BEACON_COHORT_OPT_IN_ACCEPT, BEACON_COHORT_READY, BEACON_COHORT_REQUEST_SIGNATURE, BEACON_COHORT_SIGNATURE_AUTHORIZATION } from '../../cohort/messages/constants.js';
7
+ import { AggregateBeaconMessage } from '../../cohort/messages/index.js';
8
+ import { CommunicationAdapterError } from '../error.js';
9
+ /**
10
+ * DEFAULT_NOSTR_RELAYS provides a list of default Nostr relay URLs for communication.
11
+ * These relays are used to connect to the Nostr network for sending and receiving messages.
12
+ * @constant {Array<string>} DEFAULT_NOSTR_RELAYS
13
+ */
14
+ export const DEFAULT_NOSTR_RELAYS = [
15
+ 'wss://relay.damus.io',
16
+ // 'wss://nos.lol',
17
+ // 'wss://relay.snort.social',
18
+ // 'wss://nostr-pub.wellorder.net',
19
+ ];
20
+ export class NostrAdapter {
21
+ /**
22
+ * The name of the NostrAdapter service.
23
+ * @type {string}
24
+ */
25
+ name = 'nostr';
26
+ /**
27
+ * The configuration for the NostrAdapter.
28
+ * @type {NostrAdapterConfig}
29
+ */
30
+ config;
31
+ /**
32
+ * A map of message handlers for different message types.
33
+ * @type {Map<string, MessageHandler>}
34
+ */
35
+ handlers = new Map();
36
+ /**
37
+ * The SimplePool instance for managing Nostr subscriptions.
38
+ * @type {SimplePool}
39
+ */
40
+ pool;
41
+ /**
42
+ * Constructs a new NostrAdapter instance with the given configuration.
43
+ * @param {NostrAdapterConfig} config - The configuration for the NostrAdapter.
44
+ * If no configuration is provided, a new key pair is generated and default relays are used.
45
+ * @constructor
46
+ */
47
+ constructor(config = { keys: {}, components: {}, relays: DEFAULT_NOSTR_RELAYS }) {
48
+ this.config = config;
49
+ this.config.keys = this.config.keys || SchnorrKeyPair.generate().raw;
50
+ this.config.did = config.did || Identifier.encode({
51
+ idType: config.components.idType || 'KEY',
52
+ version: config.components.version || 1,
53
+ network: config.components.network || 'signet',
54
+ genesisBytes: this.config.keys.public
55
+ });
56
+ }
57
+ /**
58
+ * Sets the keys for the NostrAdapter.
59
+ * @param {ServiceAdapterIdentity<RawSchnorrKeyPair>} keys - The key pair to set.
60
+ */
61
+ setKeys(keys) {
62
+ this.config.keys = keys;
63
+ }
64
+ /**
65
+ * Starts the Nostr communication service by subscribing to relays.
66
+ * @returns {ServiceAdapter<NostrAdapter>} Returns the NostrAdapter instance for method chaining.
67
+ */
68
+ start() {
69
+ this.pool = new SimplePool();
70
+ this.pool.subscribe(this.config.relays, { kinds: [1] }, {
71
+ onclose: (reasons) => console.log('Subscription to kind 1 closed', reasons),
72
+ onevent: this.onEvent.bind(this),
73
+ });
74
+ // this.pool.subscribe(this.config.relays, { kinds: [1059] } as Filter, {
75
+ // onclose : (reasons: string[]) => console.log('Subscription to kind 1059 closed for reasons:', reasons),
76
+ // onevent : this.onEvent.bind(this),
77
+ // oneose : () => { Logger.info('EOSE kinds 1059'); }
78
+ // });
79
+ return this;
80
+ }
81
+ /**
82
+ * Handles incoming Nostr events and dispatches them to the appropriate message handler.
83
+ * @param {Event} event The Nostr event received from the relay.
84
+ */
85
+ async onEvent(event) {
86
+ // Logger.debug('nostr.onEvent: event.tags', event.tags);
87
+ // Dispatch the event to the registered handler
88
+ const ptags = event.tags.filter(([name, _]) => name === 'p') ?? [];
89
+ // Logger.debug('nostr.onEvent: event.tags.find => ptags', ptags);
90
+ for (const [p, pk] of ptags) {
91
+ if (pk === 'b71d3052dcdc8ba4564388948b655b58aaa7f37497ef1fc98829f9191adc8f85') {
92
+ console.debug('nostr.onEvent: event.tags.find => p, pk', p, pk);
93
+ }
94
+ }
95
+ // if(!type && !value) {
96
+ // // Logger.warn(`Event ${event.id} does not have a valid tag, skipping handler dispatch.`);
97
+ // return;
98
+ // }
99
+ // Logger.debug('nostr.onEvent: event.tags.find => type, value', type, value);
100
+ // Logger.debug('nostr.onEvent: event', event);
101
+ // Logger.debug('nostr.onEvent: event.tags', event.tags);
102
+ // if(event.kind === 1 && !AggregateBeaconMessage.isKeyGenMessageValue(value)) {
103
+ // Logger.warn(`Event ${event.id} is not a key generation message type: ${value}, skipping handler dispatch.`);
104
+ // return;
105
+ // }
106
+ // if(event.kind === 1059 && !AggregateBeaconMessage.isSignMessageValue(value)) {
107
+ // Logger.warn(`Event ${event.id} has an invalid title tag: ${value}, skipping handler dispatch.`);
108
+ // return;
109
+ // }
110
+ // const handler = this.handlers.get(value);
111
+ // if (!handler) {
112
+ // Logger.warn(`No handler found for message with tag value: ${value}`);
113
+ // return;
114
+ // }
115
+ // await handler(event);
116
+ }
117
+ /**
118
+ * Registers a message handler for a specific message type.
119
+ * @param {string} messageType The type of message to handle.
120
+ * @param {MessageHandler} handler The handler function that processes the message.
121
+ */
122
+ registerMessageHandler(messageType, handler) {
123
+ this.handlers.set(messageType, handler);
124
+ }
125
+ /**
126
+ * Sends a message to a recipient using the Nostr protocol.
127
+ * This method is a placeholder and should be implemented with actual Nostr message sending logic.
128
+ * @param {Maybe<AggregateBeaconMessageType>} message The message to send, typically containing the content and metadata.
129
+ * @param {Did} from The identifier of the sender.
130
+ * @param {Did} [to] The identifier of the recipient.
131
+ * @returns {Promise<void>} A promise that resolves when the message is sent.
132
+ */
133
+ async sendMessage(message, from, to) {
134
+ // Check if the sender and recipient DIDs are valid Btc1 identifiers
135
+ if ([from, to]
136
+ .filter(did => !!did)
137
+ .every(did => !Identifier.isValid(did))) {
138
+ console.error(`Invalid Btc1 identifiers: sender ${from}, recipient ${to}`);
139
+ throw new CommunicationAdapterError(`Invalid identifiers: sender ${from}, recipient ${to}`, 'SEND_MESSAGE_ERROR', { adapter: this.name });
140
+ }
141
+ // Decode the sender and recipient DIDs to get their genesis bytes in hex
142
+ const sender = new CompressedSecp256k1PublicKey(Identifier.decode(from).genesisBytes);
143
+ console.info(`Sending message from ${sender}:`, message);
144
+ // if(message.type === BEACON_COHORT_SUBSCRIBE_ACCEPT) {
145
+ // this.config.coordinatorDids.push(recipient);
146
+ // }
147
+ const tags = [['p', Buffer.from(sender.x).toString('hex')]];
148
+ if (to) {
149
+ const recipient = new CompressedSecp256k1PublicKey(Identifier.decode(to).genesisBytes);
150
+ tags.push(['p', Buffer.from(recipient.x).toString('hex')]);
151
+ }
152
+ if (AggregateBeaconMessage.isKeyGenMessageValue(message.type)) {
153
+ switch (message.type) {
154
+ case BEACON_COHORT_ADVERT:
155
+ console.info('Add tag', ['BEACON_COHORT_ADVERT', message.type]);
156
+ break;
157
+ case BEACON_COHORT_OPT_IN:
158
+ console.info('Add tag', ['BEACON_COHORT_OPT_IN', message.type]);
159
+ break;
160
+ case BEACON_COHORT_OPT_IN_ACCEPT:
161
+ console.info('Add tag', ['BEACON_COHORT_OPT_IN_ACCEPT', message.type]);
162
+ break;
163
+ case BEACON_COHORT_READY:
164
+ console.info('Add tag', ['BEACON_COHORT_READY', message.type]);
165
+ break;
166
+ }
167
+ const event = finalizeEvent({
168
+ kind: 1,
169
+ created_at: Math.floor(Date.now() / 1000),
170
+ tags,
171
+ content: JSON.stringify(message)
172
+ }, this.config.keys.secret);
173
+ console.info(`Sending message kind 1 event ...`, event);
174
+ return this.pool?.publish(this.config.relays, event);
175
+ }
176
+ if (AggregateBeaconMessage.isSignMessageValue(message.type)) {
177
+ switch (message.type) {
178
+ case BEACON_COHORT_REQUEST_SIGNATURE:
179
+ console.info('Add tag', ['BEACON_COHORT_REQUEST_SIGNATURE', message.type]);
180
+ break;
181
+ case BEACON_COHORT_AUTHORIZATION_REQUEST:
182
+ console.info('Add tag', ['BEACON_COHORT_AUTHORIZATION_REQUEST', message.type]);
183
+ break;
184
+ case BEACON_COHORT_NONCE_CONTRIBUTION:
185
+ console.info('Add tag', ['BEACON_COHORT_NONCE_CONTRIBUTION', message.type]);
186
+ break;
187
+ case BEACON_COHORT_AGGREGATED_NONCE:
188
+ console.info('Add tag', ['BEACON_COHORT_AGGREGATED_NONCE', message.type]);
189
+ break;
190
+ case BEACON_COHORT_SIGNATURE_AUTHORIZATION:
191
+ console.info('Add tag', ['BEACON_COHORT_SIGNATURE_AUTHORIZATION', message.type]);
192
+ break;
193
+ }
194
+ const { publicKey, secretKey } = SchnorrKeyPair.generate();
195
+ const content = nip44.encrypt(JSON.stringify(message), secretKey.bytes, nonceGen(publicKey.x).public);
196
+ console.debug('NostrAdapter content:', content);
197
+ const event = finalizeEvent({ content, tags, kind: 1059 }, this.config.keys.secret);
198
+ console.debug('NostrAdapter event:', event);
199
+ return this.pool?.publish(this.config.relays, event);
200
+ }
201
+ console.error(`Unsupported message type: ${message.type}`);
202
+ }
203
+ /**
204
+ * Generates a Nostr identity using the Secp256k1SecretKey and Identifier classes.
205
+ * @param {RawSchnorrKeyPair} [keys] Optional keys to use for identity generation.
206
+ * @returns {ServiceAdapterConfig} The generated Nostr identity configuration.
207
+ */
208
+ generateIdentity(keys) {
209
+ if (!keys) {
210
+ this.config.keys.secret = Secp256k1SecretKey.random();
211
+ this.config.keys.public = Secp256k1SecretKey.getPublicKey(this.config.keys.secret).compressed;
212
+ this.config.did = Identifier.encode({
213
+ idType: this.config.components.idType || 'KEY',
214
+ version: this.config.components.version || 1,
215
+ network: this.config.components.network || 'signet',
216
+ genesisBytes: this.config.keys.public
217
+ });
218
+ return this.config;
219
+ }
220
+ this.config.keys = keys;
221
+ this.config.did = Identifier.encode({
222
+ idType: this.config.components.idType || 'KEY',
223
+ version: this.config.components.version || 1,
224
+ network: this.config.components.network || 'signet',
225
+ genesisBytes: this.config.keys.public
226
+ });
227
+ return this.config;
228
+ }
229
+ }
230
+ //# sourceMappingURL=nostr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nostr.js","sourceRoot":"","sources":["../../../../../../../src/core/beacon/aggregation/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M,IAAK,KAAK;gBACtD,OAAO,EAAQ,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,IAAI,CAAC;gBAClD,OAAO,EAAQ,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,IAAI,QAAQ;gBACzD,YAAY,EAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM;aACvC,CACF,CAAC;YACF,OAAO,IAAI,CAAC,MAA8B,CAAC;QAC7C,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,MAAM,CAAC,GAAG,GAAG,UAAU,CAAC,MAAM,CACjC;YACE,MAAM,EAAS,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,IAAK,KAAK;YACtD,OAAO,EAAQ,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,IAAI,CAAC;YAClD,OAAO,EAAQ,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,IAAI,QAAQ;YACzD,YAAY,EAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM;SACvC,CACF,CAAC;QACF,OAAO,IAAI,CAAC,MAA8B,CAAC;IAC7C,CAAC;CACF"}
@@ -0,0 +1,12 @@
1
+ import { MethodError } from '@did-btcr2/common';
2
+ export class CommunicationServiceError extends MethodError {
3
+ constructor(message, type = 'CommunicationServiceError', data) {
4
+ super(message, type, data);
5
+ }
6
+ }
7
+ export class CommunicationAdapterError extends MethodError {
8
+ constructor(message, type = 'CommunicationAdapterError', data) {
9
+ super(message, type, data);
10
+ }
11
+ }
12
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../../../../../../src/core/beacon/aggregation/communication/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,OAAO,yBAA0B,SAAQ,WAAW;IACxD,YAAY,OAAe,EAAE,OAAe,2BAA2B,EAAE,IAA0B;QACjG,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF;AAED,MAAM,OAAO,yBAA0B,SAAQ,WAAW;IACxD,YAAY,OAAe,EAAE,OAAe,2BAA2B,EAAE,IAA0B;QACjG,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF"}
@@ -0,0 +1,21 @@
1
+ import { NotImplementedError } from '@did-btcr2/common';
2
+ import { NostrAdapter } from './adapter/nostr.js';
3
+ import { CommunicationServiceError } from './error.js';
4
+ /**
5
+ * Communication Factory pattern to create Communication Service instances.
6
+ * @class CommunicationFactory
7
+ * @type {CommunicationFactory}
8
+ */
9
+ export class CommunicationFactory {
10
+ static establish(service) {
11
+ switch (service.type) {
12
+ case 'nostr':
13
+ return new NostrAdapter();
14
+ case 'didcomm':
15
+ throw new NotImplementedError('DID Comm service not implemented yet.');
16
+ default:
17
+ throw new CommunicationServiceError(`Invalid service type ${service.type}`, 'INVALID_BEACON_ERROR', { service });
18
+ }
19
+ }
20
+ }
21
+ //# sourceMappingURL=factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../../../../src/core/beacon/aggregation/communication/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAGvD;;;;GAIG;AACH,MAAM,OAAO,oBAAoB;IAC/B,MAAM,CAAC,SAAS,CAAC,OAAgB;QAC/B,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;YACrB,KAAK,OAAO;gBACV,OAAO,IAAI,YAAY,EAAE,CAAC;YAC5B,KAAK,SAAS;gBACZ,MAAM,IAAI,mBAAmB,CAAC,uCAAuC,CAAC,CAAC;YACzE;gBACE,MAAM,IAAI,yBAAyB,CACjC,wBAAwB,OAAO,CAAC,IAAI,EAAE,EACtC,sBAAsB,EAAE,EAAE,OAAO,EAAE,CACpC,CAAC;QACN,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../../../../../src/core/beacon/aggregation/communication/service.ts"],"names":[],"mappings":""}