@did-btcr2/method 0.25.3 → 0.26.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 (233) hide show
  1. package/dist/.tsbuildinfo +1 -0
  2. package/dist/browser.js +125307 -122227
  3. package/dist/browser.mjs +125266 -122186
  4. package/dist/cjs/index.js +5043 -43
  5. package/dist/esm/core/beacon/aggregation/cohort/index.js.map +1 -1
  6. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js.map +1 -1
  7. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js.map +1 -1
  8. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js.map +1 -1
  9. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in.js.map +1 -1
  10. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/subscribe.js.map +1 -1
  11. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js.map +1 -1
  12. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/authorization-request.js.map +1 -1
  13. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js.map +1 -1
  14. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/request-signature.js.map +1 -1
  15. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js.map +1 -1
  16. package/dist/esm/core/beacon/aggregation/communication/adapter/did-comm.js.map +1 -1
  17. package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js +1 -2
  18. package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js.map +1 -1
  19. package/dist/esm/core/beacon/aggregation/coordinator.js.map +1 -1
  20. package/dist/esm/core/beacon/aggregation/participant.js.map +1 -1
  21. package/dist/esm/core/beacon/aggregation/session/index.js.map +1 -1
  22. package/dist/esm/core/beacon/cas-beacon.js +6 -4
  23. package/dist/esm/core/beacon/cas-beacon.js.map +1 -1
  24. package/dist/esm/core/beacon/signal-discovery.js +1 -1
  25. package/dist/esm/core/beacon/signal-discovery.js.map +1 -1
  26. package/dist/esm/core/beacon/singleton-beacon.js +3 -3
  27. package/dist/esm/core/beacon/singleton-beacon.js.map +1 -1
  28. package/dist/esm/core/beacon/utils.js.map +1 -1
  29. package/dist/esm/core/identifier.js.map +1 -1
  30. package/dist/esm/core/resolver.js +41 -35
  31. package/dist/esm/core/resolver.js.map +1 -1
  32. package/dist/esm/core/update.js.map +1 -1
  33. package/dist/esm/did-btcr2.js +1 -1
  34. package/dist/esm/did-btcr2.js.map +1 -1
  35. package/dist/esm/utils/appendix.js +7 -6
  36. package/dist/esm/utils/appendix.js.map +1 -1
  37. package/dist/esm/utils/did-document-builder.js.map +1 -1
  38. package/dist/esm/utils/did-document.js +2 -2
  39. package/dist/esm/utils/did-document.js.map +1 -1
  40. package/dist/types/core/beacon/aggregation/cohort/index.d.ts +2 -2
  41. package/dist/types/core/beacon/aggregation/cohort/index.d.ts.map +1 -1
  42. package/dist/types/core/beacon/aggregation/cohort/messages/index.d.ts +10 -10
  43. package/dist/types/core/beacon/aggregation/cohort/messages/index.d.ts.map +1 -1
  44. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.d.ts +1 -1
  45. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.d.ts.map +1 -1
  46. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts +1 -1
  47. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts.map +1 -1
  48. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.d.ts +1 -1
  49. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.d.ts.map +1 -1
  50. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in.d.ts +1 -1
  51. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in.d.ts.map +1 -1
  52. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/subscribe.d.ts +1 -1
  53. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/subscribe.d.ts.map +1 -1
  54. package/dist/types/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.d.ts +1 -1
  55. package/dist/types/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.d.ts.map +1 -1
  56. package/dist/types/core/beacon/aggregation/cohort/messages/sign/authorization-request.d.ts +1 -1
  57. package/dist/types/core/beacon/aggregation/cohort/messages/sign/authorization-request.d.ts.map +1 -1
  58. package/dist/types/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.d.ts +1 -1
  59. package/dist/types/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.d.ts.map +1 -1
  60. package/dist/types/core/beacon/aggregation/cohort/messages/sign/request-signature.d.ts +1 -1
  61. package/dist/types/core/beacon/aggregation/cohort/messages/sign/request-signature.d.ts.map +1 -1
  62. package/dist/types/core/beacon/aggregation/cohort/messages/sign/signature-authorization.d.ts +1 -1
  63. package/dist/types/core/beacon/aggregation/cohort/messages/sign/signature-authorization.d.ts.map +1 -1
  64. package/dist/types/core/beacon/aggregation/communication/adapter/did-comm.d.ts +4 -4
  65. package/dist/types/core/beacon/aggregation/communication/adapter/did-comm.d.ts.map +1 -1
  66. package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts +6 -6
  67. package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts.map +1 -1
  68. package/dist/types/core/beacon/aggregation/communication/factory.d.ts +1 -1
  69. package/dist/types/core/beacon/aggregation/communication/factory.d.ts.map +1 -1
  70. package/dist/types/core/beacon/aggregation/communication/service.d.ts +3 -3
  71. package/dist/types/core/beacon/aggregation/communication/service.d.ts.map +1 -1
  72. package/dist/types/core/beacon/aggregation/coordinator.d.ts +3 -3
  73. package/dist/types/core/beacon/aggregation/coordinator.d.ts.map +1 -1
  74. package/dist/types/core/beacon/aggregation/participant.d.ts +6 -6
  75. package/dist/types/core/beacon/aggregation/participant.d.ts.map +1 -1
  76. package/dist/types/core/beacon/aggregation/session/index.d.ts +2 -2
  77. package/dist/types/core/beacon/aggregation/session/index.d.ts.map +1 -1
  78. package/dist/types/core/beacon/beacon.d.ts +5 -5
  79. package/dist/types/core/beacon/beacon.d.ts.map +1 -1
  80. package/dist/types/core/beacon/cas-beacon.d.ts +5 -5
  81. package/dist/types/core/beacon/cas-beacon.d.ts.map +1 -1
  82. package/dist/types/core/beacon/factory.d.ts +2 -2
  83. package/dist/types/core/beacon/factory.d.ts.map +1 -1
  84. package/dist/types/core/beacon/interfaces.d.ts +3 -3
  85. package/dist/types/core/beacon/interfaces.d.ts.map +1 -1
  86. package/dist/types/core/beacon/signal-discovery.d.ts +3 -3
  87. package/dist/types/core/beacon/signal-discovery.d.ts.map +1 -1
  88. package/dist/types/core/beacon/singleton-beacon.d.ts +5 -5
  89. package/dist/types/core/beacon/singleton-beacon.d.ts.map +1 -1
  90. package/dist/types/core/beacon/smt-beacon.d.ts +5 -5
  91. package/dist/types/core/beacon/smt-beacon.d.ts.map +1 -1
  92. package/dist/types/core/beacon/utils.d.ts +4 -4
  93. package/dist/types/core/beacon/utils.d.ts.map +1 -1
  94. package/dist/types/core/identifier.d.ts +2 -2
  95. package/dist/types/core/identifier.d.ts.map +1 -1
  96. package/dist/types/core/interfaces.d.ts +2 -2
  97. package/dist/types/core/interfaces.d.ts.map +1 -1
  98. package/dist/types/core/resolver.d.ts +8 -8
  99. package/dist/types/core/resolver.d.ts.map +1 -1
  100. package/dist/types/core/types.d.ts +6 -5
  101. package/dist/types/core/types.d.ts.map +1 -1
  102. package/dist/types/core/update.d.ts +5 -5
  103. package/dist/types/core/update.d.ts.map +1 -1
  104. package/dist/types/did-btcr2.d.ts +6 -6
  105. package/dist/types/did-btcr2.d.ts.map +1 -1
  106. package/dist/types/utils/appendix.d.ts +7 -7
  107. package/dist/types/utils/appendix.d.ts.map +1 -1
  108. package/dist/types/utils/did-document-builder.d.ts +3 -2
  109. package/dist/types/utils/did-document-builder.d.ts.map +1 -1
  110. package/dist/types/utils/did-document.d.ts +3 -3
  111. package/dist/types/utils/did-document.d.ts.map +1 -1
  112. package/package.json +7 -6
  113. package/src/core/beacon/aggregation/cohort/index.ts +3 -2
  114. package/src/core/beacon/aggregation/cohort/messages/index.ts +10 -10
  115. package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.ts +2 -1
  116. package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.ts +2 -1
  117. package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.ts +2 -1
  118. package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in.ts +2 -1
  119. package/src/core/beacon/aggregation/cohort/messages/keygen/subscribe.ts +2 -1
  120. package/src/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.ts +2 -1
  121. package/src/core/beacon/aggregation/cohort/messages/sign/authorization-request.ts +2 -1
  122. package/src/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.ts +2 -1
  123. package/src/core/beacon/aggregation/cohort/messages/sign/request-signature.ts +2 -1
  124. package/src/core/beacon/aggregation/cohort/messages/sign/signature-authorization.ts +2 -1
  125. package/src/core/beacon/aggregation/communication/adapter/did-comm.ts +5 -4
  126. package/src/core/beacon/aggregation/communication/adapter/nostr.ts +9 -7
  127. package/src/core/beacon/aggregation/communication/factory.ts +1 -1
  128. package/src/core/beacon/aggregation/communication/service.ts +3 -3
  129. package/src/core/beacon/aggregation/coordinator.ts +12 -8
  130. package/src/core/beacon/aggregation/participant.ts +12 -7
  131. package/src/core/beacon/aggregation/session/index.ts +3 -2
  132. package/src/core/beacon/beacon.ts +5 -5
  133. package/src/core/beacon/cas-beacon.ts +13 -9
  134. package/src/core/beacon/factory.ts +2 -2
  135. package/src/core/beacon/interfaces.ts +3 -3
  136. package/src/core/beacon/signal-discovery.ts +5 -4
  137. package/src/core/beacon/singleton-beacon.ts +8 -7
  138. package/src/core/beacon/smt-beacon.ts +5 -5
  139. package/src/core/beacon/utils.ts +6 -4
  140. package/src/core/identifier.ts +3 -2
  141. package/src/core/interfaces.ts +2 -2
  142. package/src/core/resolver.ts +59 -51
  143. package/src/core/types.ts +6 -5
  144. package/src/core/update.ts +11 -7
  145. package/src/did-btcr2.ts +12 -10
  146. package/src/utils/appendix.ts +14 -16
  147. package/src/utils/did-document-builder.ts +3 -2
  148. package/src/utils/did-document.ts +10 -8
  149. package/dist/cjs/core/beacon/aggregation/cohort/index.js +0 -237
  150. package/dist/cjs/core/beacon/aggregation/cohort/index.js.map +0 -1
  151. package/dist/cjs/core/beacon/aggregation/cohort/messages/base.js +0 -26
  152. package/dist/cjs/core/beacon/aggregation/cohort/messages/base.js.map +0 -1
  153. package/dist/cjs/core/beacon/aggregation/cohort/messages/constants.js +0 -11
  154. package/dist/cjs/core/beacon/aggregation/cohort/messages/constants.js.map +0 -1
  155. package/dist/cjs/core/beacon/aggregation/cohort/messages/index.js +0 -98
  156. package/dist/cjs/core/beacon/aggregation/cohort/messages/index.js.map +0 -1
  157. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js +0 -31
  158. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js.map +0 -1
  159. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js +0 -29
  160. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js.map +0 -1
  161. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js +0 -27
  162. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js.map +0 -1
  163. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in.js +0 -23
  164. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in.js.map +0 -1
  165. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/subscribe.js +0 -28
  166. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/subscribe.js.map +0 -1
  167. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js +0 -29
  168. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js.map +0 -1
  169. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/authorization-request.js +0 -30
  170. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/authorization-request.js.map +0 -1
  171. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js +0 -30
  172. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js.map +0 -1
  173. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/request-signature.js +0 -30
  174. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/request-signature.js.map +0 -1
  175. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js +0 -31
  176. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js.map +0 -1
  177. package/dist/cjs/core/beacon/aggregation/cohort/status.js +0 -8
  178. package/dist/cjs/core/beacon/aggregation/cohort/status.js.map +0 -1
  179. package/dist/cjs/core/beacon/aggregation/communication/adapter/did-comm.js +0 -121
  180. package/dist/cjs/core/beacon/aggregation/communication/adapter/did-comm.js.map +0 -1
  181. package/dist/cjs/core/beacon/aggregation/communication/adapter/nostr.js +0 -246
  182. package/dist/cjs/core/beacon/aggregation/communication/adapter/nostr.js.map +0 -1
  183. package/dist/cjs/core/beacon/aggregation/communication/error.js +0 -12
  184. package/dist/cjs/core/beacon/aggregation/communication/error.js.map +0 -1
  185. package/dist/cjs/core/beacon/aggregation/communication/factory.js +0 -21
  186. package/dist/cjs/core/beacon/aggregation/communication/factory.js.map +0 -1
  187. package/dist/cjs/core/beacon/aggregation/communication/service.js +0 -2
  188. package/dist/cjs/core/beacon/aggregation/communication/service.js.map +0 -1
  189. package/dist/cjs/core/beacon/aggregation/coordinator.js +0 -343
  190. package/dist/cjs/core/beacon/aggregation/coordinator.js.map +0 -1
  191. package/dist/cjs/core/beacon/aggregation/participant.js +0 -435
  192. package/dist/cjs/core/beacon/aggregation/participant.js.map +0 -1
  193. package/dist/cjs/core/beacon/aggregation/session/index.js +0 -244
  194. package/dist/cjs/core/beacon/aggregation/session/index.js.map +0 -1
  195. package/dist/cjs/core/beacon/aggregation/session/status.js +0 -11
  196. package/dist/cjs/core/beacon/aggregation/session/status.js.map +0 -1
  197. package/dist/cjs/core/beacon/beacon.js +0 -25
  198. package/dist/cjs/core/beacon/beacon.js.map +0 -1
  199. package/dist/cjs/core/beacon/cas-beacon.js +0 -152
  200. package/dist/cjs/core/beacon/cas-beacon.js.map +0 -1
  201. package/dist/cjs/core/beacon/error.js +0 -37
  202. package/dist/cjs/core/beacon/error.js.map +0 -1
  203. package/dist/cjs/core/beacon/factory.js +0 -29
  204. package/dist/cjs/core/beacon/factory.js.map +0 -1
  205. package/dist/cjs/core/beacon/interfaces.js +0 -2
  206. package/dist/cjs/core/beacon/interfaces.js.map +0 -1
  207. package/dist/cjs/core/beacon/signal-discovery.js +0 -183
  208. package/dist/cjs/core/beacon/signal-discovery.js.map +0 -1
  209. package/dist/cjs/core/beacon/singleton-beacon.js +0 -107
  210. package/dist/cjs/core/beacon/singleton-beacon.js.map +0 -1
  211. package/dist/cjs/core/beacon/smt-beacon.js +0 -39
  212. package/dist/cjs/core/beacon/smt-beacon.js.map +0 -1
  213. package/dist/cjs/core/beacon/utils.js +0 -163
  214. package/dist/cjs/core/beacon/utils.js.map +0 -1
  215. package/dist/cjs/core/identifier.js +0 -248
  216. package/dist/cjs/core/identifier.js.map +0 -1
  217. package/dist/cjs/core/interfaces.js +0 -2
  218. package/dist/cjs/core/interfaces.js.map +0 -1
  219. package/dist/cjs/core/resolver.js +0 -476
  220. package/dist/cjs/core/resolver.js.map +0 -1
  221. package/dist/cjs/core/types.js +0 -2
  222. package/dist/cjs/core/types.js.map +0 -1
  223. package/dist/cjs/core/update.js +0 -112
  224. package/dist/cjs/core/update.js.map +0 -1
  225. package/dist/cjs/did-btcr2.js +0 -193
  226. package/dist/cjs/did-btcr2.js.map +0 -1
  227. package/dist/cjs/index.js.map +0 -1
  228. package/dist/cjs/utils/appendix.js +0 -203
  229. package/dist/cjs/utils/appendix.js.map +0 -1
  230. package/dist/cjs/utils/did-document-builder.js +0 -60
  231. package/dist/cjs/utils/did-document-builder.js.map +0 -1
  232. package/dist/cjs/utils/did-document.js +0 -424
  233. package/dist/cjs/utils/did-document.js.map +0 -1
@@ -1,30 +0,0 @@
1
- import { JSONUtils } from '@did-btcr2/common';
2
- import { BaseMessage } from '../base.js';
3
- import { BEACON_COHORT_NONCE_CONTRIBUTION } from '../constants.js';
4
- /**
5
- * Represents a message containing a nonce contribution for a cohort participant.
6
- * Participant → Coordinator. Participant sending their public nonce points for the ongoing signing session.
7
- * @class BeaconCohortNonceContributionMessage
8
- * @extends BaseMessage
9
- * @type {BeaconCohortNonceContributionMessage}
10
- */
11
- export class BeaconCohortNonceContributionMessage extends BaseMessage {
12
- constructor({ to, from, cohortId, sessionId, nonceContribution }) {
13
- const body = { cohortId, sessionId, nonceContribution };
14
- const type = BEACON_COHORT_NONCE_CONTRIBUTION;
15
- super({ to, from, body, type });
16
- }
17
- /**
18
- * Initializes a NonceContributionMessage from a given CohortNonceContributionMessage object.
19
- * @param {CohortNonceContributionMessage} data The data object to initialize the BeaconCohortNonceContributionMessage.
20
- * @returns {BeaconCohortNonceContributionMessage} The new BeaconCohortNonceContributionMessage.
21
- */
22
- static fromJSON(data) {
23
- const message = JSONUtils.isParsable(data) ? JSON.parse(data) : data;
24
- if (message.type != BEACON_COHORT_NONCE_CONTRIBUTION) {
25
- throw new Error(`Invalid type: ${message.type}`);
26
- }
27
- return new BeaconCohortNonceContributionMessage(message);
28
- }
29
- }
30
- //# sourceMappingURL=nonce-contribution.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"nonce-contribution.js","sourceRoot":"","sources":["../../../../../../../../src/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAS,MAAM,mBAAmB,CAAC;AACrD,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,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACrE,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"}
@@ -1,30 +0,0 @@
1
- import { JSONUtils } from '@did-btcr2/common';
2
- import { BaseMessage } from '../base.js';
3
- import { BEACON_COHORT_REQUEST_SIGNATURE } from '../constants.js';
4
- /**
5
- * Coordinator → Participants. Returns the aggregation of all participant nonces
6
- * so each participant can produce a correct partial signature.
7
- * @class BeaconCohortRequestSignatureMessage
8
- * @extends BaseMessage
9
- * @type {BeaconCohortRequestSignatureMessage}
10
- */
11
- export class BeaconCohortRequestSignatureMessage extends BaseMessage {
12
- constructor({ to, from, cohortId, sessionId, data }) {
13
- const body = { cohortId, sessionId, data };
14
- const type = BEACON_COHORT_REQUEST_SIGNATURE;
15
- super({ to, from, body, type });
16
- }
17
- /**
18
- * Initializes an BeaconCohortRequestSignatureMessage from a possible CohortRequestSignatureMessage object.
19
- * @param {CohortRequestSignatureMessage} data The data object to initialize the BeaconCohortRequestSignatureMessage.
20
- * @returns {BeaconCohortRequestSignatureMessage} The new BeaconCohortRequestSignatureMessage.
21
- */
22
- static fromJSON(data) {
23
- const message = JSONUtils.isParsable(data) ? JSON.parse(data) : data;
24
- if (message.type != BEACON_COHORT_REQUEST_SIGNATURE) {
25
- throw new Error(`Invalid type: ${message.type}`);
26
- }
27
- return new BeaconCohortRequestSignatureMessage(message);
28
- }
29
- }
30
- //# sourceMappingURL=request-signature.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"request-signature.js","sourceRoot":"","sources":["../../../../../../../../src/core/beacon/aggregation/cohort/messages/sign/request-signature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAS,MAAM,mBAAmB,CAAC;AACrD,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,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACrE,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"}
@@ -1,31 +0,0 @@
1
- import { JSONUtils } from '@did-btcr2/common';
2
- import { BaseMessage } from '../base.js';
3
- import { BEACON_COHORT_SIGNATURE_AUTHORIZATION } from '../constants.js';
4
- /**
5
- * Participant → Coordinator. Delivers the participant’s partial signature over
6
- * the PSBT, authorizing the final Beacon signal (transaction) once all signatures
7
- * are collected.
8
- * @class BeaconCohortSignatureAuthorizationMessage
9
- * @extends BaseMessage
10
- * @type {BeaconCohortSignatureAuthorizationMessage}
11
- */
12
- export class BeaconCohortSignatureAuthorizationMessage extends BaseMessage {
13
- constructor({ to, from, cohortId, sessionId, partialSignature }) {
14
- const body = { cohortId, sessionId, partialSignature };
15
- const type = BEACON_COHORT_SIGNATURE_AUTHORIZATION;
16
- super({ to, from, body, type });
17
- }
18
- /**
19
- * Initializes an BeaconCohortSignatureAuthorizationMessage from a given CohortSignatureAuthorizationMessage object.
20
- * @param {CohortSignatureAuthorizationMessage} data The data object to initialize the BeaconCohortSignatureAuthorizationMessage.
21
- * @returns {BeaconCohortSignatureAuthorizationMessage} The serialized BeaconCohortSignatureAuthorizationMessage.
22
- */
23
- static fromJSON(data) {
24
- const message = JSONUtils.isParsable(data) ? JSON.parse(data) : data;
25
- if (message.type != BEACON_COHORT_SIGNATURE_AUTHORIZATION) {
26
- throw new Error(`Invalid type: ${message.type}`);
27
- }
28
- return new BeaconCohortSignatureAuthorizationMessage(message);
29
- }
30
- }
31
- //# sourceMappingURL=signature-authorization.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"signature-authorization.js","sourceRoot":"","sources":["../../../../../../../../src/core/beacon/aggregation/cohort/messages/sign/signature-authorization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAS,MAAM,mBAAmB,CAAC;AACrD,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,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACrE,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"}
@@ -1,8 +0,0 @@
1
- export var COHORT_STATUS;
2
- (function (COHORT_STATUS) {
3
- COHORT_STATUS["COHORT_ADVERTISED"] = "ADVERTISED";
4
- COHORT_STATUS["COHORT_OPTED_IN"] = "OPTED_IN";
5
- COHORT_STATUS["COHORT_SET_STATUS"] = "COHORT_SET";
6
- COHORT_STATUS["COHORT_FAILED"] = "FAILED";
7
- })(COHORT_STATUS || (COHORT_STATUS = {}));
8
- //# sourceMappingURL=status.js.map
@@ -1 +0,0 @@
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"}
@@ -1,121 +0,0 @@
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(this.keys.public, this.components);
30
- this.coordinatorDids = config?.coordinatorDids || [];
31
- }
32
- }
33
- /**
34
- * DidCommAdapter implements the CommunicationService interface for DidComm protocol.
35
- * It handles message sending, receiving, and identity generation using DidComm.
36
- * @class DidCommAdapter
37
- * @implements {CommunicationService}
38
- * @type {DidCommAdapter}
39
- */
40
- export class DidCommAdapter {
41
- /**
42
- * The name of the communication service.
43
- * @type {string}
44
- */
45
- name = 'didcomm';
46
- /**
47
- * The configuration for the DidComm adapter.
48
- * @type {DidCommAdapterConfig}
49
- */
50
- config;
51
- /**
52
- * A map of message handlers for different message types.
53
- * @type {Map<string, MessageHandler>}
54
- */
55
- handlers = new Map();
56
- /**
57
- * Constructs a new DidCommAdapter instance with the provided configuration.
58
- * @param {DidCommAdapterConfig} [config] The configuration for the Nostr adapter.
59
- */
60
- constructor(config = {}) {
61
- this.config = new DidCommAdapterConfig(config);
62
- }
63
- /**
64
- * Starts the DidComm service.
65
- * @returns {void} Returns the DidCommAdapter instance for method chaining.
66
- */
67
- start() {
68
- throw new NotImplementedError('DidCommAdapter is not implemented. Use NostrAdapter instead.');
69
- }
70
- /**
71
- * Sets the keys used for Nostr communication.
72
- * @param {ServiceAdapterIdentity<NostrKeys>} keys The keys to set.
73
- */
74
- setKeys(keys) {
75
- this.config.keys = keys;
76
- }
77
- /**
78
- * Registers a message handler for a specific message type.
79
- * @param {string} messageType The type of message to handle.
80
- * @param {MessageHandler} handler The handler function that processes the message.
81
- */
82
- registerMessageHandler(messageType, handler) {
83
- this.handlers.set(messageType, handler);
84
- }
85
- /**
86
- * Sends a message to a recipient using the Nostr protocol.
87
- * This method is a placeholder and should be implemented with actual Nostr message sending logic.
88
- * @param {AggregateBeaconMessageType} _message The message to send, typically containing the content and metadata.
89
- * @param {string} _recipient The public key or identifier of the recipient.
90
- * @param {string} _sender The public key or identifier of the sender.
91
- * @returns {Promise<void>} A promise that resolves when the message is sent.
92
- */
93
- async sendMessage(_message, _recipient, _sender) {
94
- throw new NotImplementedError('DidCommAdapter.start() is not implemented. Use NostrAdapter instead.');
95
- }
96
- /**
97
- * Generates a DidComm identity.
98
- * @param {RawKeyPair} [keys] Optional keys to use for identity generation.
99
- * @returns {ServiceAdapterConfig} The generated DidComm identity configuration.
100
- */
101
- generateIdentity(keys) {
102
- if (!keys) {
103
- this.config.keys.secret = Secp256k1SecretKey.random();
104
- this.config.keys.public = Secp256k1SecretKey.getPublicKey(this.config.keys.secret).compressed;
105
- this.config.did = Identifier.encode(this.config.keys.public, {
106
- idType: this.config.components.idType || 'KEY',
107
- version: this.config.components.version || 1,
108
- network: this.config.components.network || 'regtest',
109
- });
110
- return this.config;
111
- }
112
- this.config.keys = keys;
113
- this.config.did = Identifier.encode(this.config.keys.public, {
114
- idType: this.config.components.idType || 'KEY',
115
- version: this.config.components.version || 1,
116
- network: this.config.components.network || 'regtest',
117
- });
118
- return this.config;
119
- }
120
- }
121
- //# sourceMappingURL=did-comm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"did-comm.js","sourceRoot":"","sources":["../../../../../../../src/core/beacon/aggregation/communication/adapter/did-comm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAqB,cAAc,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAKvD;;;;;;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,CAAC,GAAG;YACzD,IAAI,CAAC,UAAU,GAAG,MAAM,EAAE,UAAU,IAAI;gBACtC,OAAO,EAAG,CAAC;gBACX,MAAM,EAAI,KAAK;gBACf,OAAO,EAAG,WAAW;aACtB,CAAC;QACF,IAAI,CAAC,GAAG,GAAG,MAAM,EAAE,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC/E,IAAI,CAAC,eAAe,GAAG,MAAM,EAAE,eAAe,IAAI,EAAE,CAAC;IACvD,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,OAAO,cAAc;IACzB;;;OAGG;IACI,IAAI,GAA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CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,IAAI,CAAC;gBAClD,OAAO,EAAQ,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,IAAI,SAAS;aAC3D,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,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EACzD;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,SAAS;SAC3D,CACF,CAAC;QACF,OAAO,IAAI,CAAC,MAA8B,CAAC;IAC7C,CAAC;CACF"}
@@ -1,246 +0,0 @@
1
- // TODO: Finish nostr adapter implementation. Rethink patterns used.
2
- import { CompressedSecp256k1PublicKey, SchnorrKeyPair, Secp256k1SecretKey } from '@did-btcr2/keypair';
3
- import { bytesToHex } from '@noble/hashes/utils';
4
- import { nonceGen } from '@scure/btc-signer/musig2';
5
- import { finalizeEvent, nip44 } from 'nostr-tools';
6
- import { SimplePool } from 'nostr-tools/pool';
7
- import { Identifier } from '../../../../identifier.js';
8
- 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';
9
- import { AggregateBeaconMessage } from '../../cohort/messages/index.js';
10
- import { CommunicationAdapterError } from '../error.js';
11
- /**
12
- * TODO: Determine set of default Nostr relays to use.
13
- * DEFAULT_NOSTR_RELAYS provides a list of default Nostr relay URLs for communication.
14
- * These relays are used to connect to the Nostr network for sending and receiving messages.
15
- * @constant {Array<string>} DEFAULT_NOSTR_RELAYS
16
- */
17
- export const DEFAULT_NOSTR_RELAYS = [
18
- 'wss://relay.damus.io',
19
- // 'wss://nos.lol',
20
- // 'wss://relay.snort.social',
21
- // 'wss://nostr-pub.wellorder.net',
22
- ];
23
- /**
24
- * NostrAdapter implements the CommunicationService interface for Nostr protocol communication.
25
- * It provides methods for starting the service, sending messages, and handling incoming events.
26
- * @class NostrAdapter
27
- * @type {NostrAdapter}
28
- * @implements {CommunicationService}
29
- */
30
- export class NostrAdapter {
31
- /**
32
- * The name of the NostrAdapter service.
33
- * @type {string}
34
- */
35
- name = 'nostr';
36
- /**
37
- * The configuration for the NostrAdapter.
38
- * @type {NostrAdapterConfig}
39
- */
40
- config;
41
- /**
42
- * A map of message handlers for different message types.
43
- * @type {Map<string, MessageHandler>}
44
- */
45
- #handlers = new Map();
46
- /**
47
- * The SimplePool instance for managing Nostr subscriptions.
48
- * @type {SimplePool}
49
- */
50
- pool;
51
- /**
52
- * Constructs a new NostrAdapter instance with the given configuration.
53
- * @param {NostrAdapterConfig} config - The configuration for the NostrAdapter.
54
- * If no configuration is provided, a new key pair is generated and default relays are used.
55
- * @constructor
56
- */
57
- constructor(config = { keys: {}, components: {}, relays: DEFAULT_NOSTR_RELAYS }) {
58
- this.config = config;
59
- this.config.keys = this.config.keys || SchnorrKeyPair.generate().raw;
60
- this.config.did = config.did || Identifier.encode(this.config.keys.public, {
61
- idType: config.components.idType || 'KEY',
62
- version: config.components.version || 1,
63
- network: config.components.network || 'signet'
64
- });
65
- }
66
- /**
67
- * Sets the keys for the NostrAdapter.
68
- * @param {ServiceAdapterIdentity<RawSchnorrKeyPair>} keys - The key pair to set.
69
- */
70
- setKeys(keys) {
71
- this.config.keys = keys;
72
- }
73
- /**
74
- * TODO: Complete this method. Figure out best subscription patterns.
75
- * Starts the Nostr communication service by subscribing to relays.
76
- * @returns {ServiceAdapter<NostrAdapter>} Returns the NostrAdapter instance for method chaining.
77
- */
78
- start() {
79
- this.pool = new SimplePool();
80
- this.pool.subscribe(this.config.relays, { kinds: [1] }, {
81
- onclose: (reasons) => console.log('Subscription to kind 1 closed', reasons),
82
- onevent: this.onEvent.bind(this),
83
- });
84
- // this.pool.subscribe(this.config.relays, { kinds: [1059] } as Filter, {
85
- // onclose : (reasons: string[]) => console.log('Subscription to kind 1059 closed for reasons:', reasons),
86
- // onevent : this.onEvent.bind(this),
87
- // oneose : () => { Logger.info('EOSE kinds 1059'); }
88
- // });
89
- return this;
90
- }
91
- /**
92
- * TODO: Complete this method. Figure out best way to filter incoming nostr events.
93
- * Handles incoming Nostr events and dispatches them to the appropriate message handler.
94
- * @param {Event} event The Nostr event received from the relay.
95
- */
96
- async onEvent(event) {
97
- // Logger.debug('nostr.onEvent: event.tags', event.tags);
98
- // Dispatch the event to the registered handler
99
- const ptags = event.tags.filter(([name, _]) => name === 'p') ?? [];
100
- // Logger.debug('nostr.onEvent: event.tags.find => ptags', ptags);
101
- for (const [p, pk] of ptags) {
102
- if (pk === 'b71d3052dcdc8ba4564388948b655b58aaa7f37497ef1fc98829f9191adc8f85') {
103
- console.debug('nostr.onEvent: event.tags.find => p, pk', p, pk);
104
- }
105
- }
106
- // if(!type && !value) {
107
- // // Logger.warn(`Event ${event.id} does not have a valid tag, skipping handler dispatch.`);
108
- // return;
109
- // }
110
- // Logger.debug('nostr.onEvent: event.tags.find => type, value', type, value);
111
- // Logger.debug('nostr.onEvent: event', event);
112
- // Logger.debug('nostr.onEvent: event.tags', event.tags);
113
- // if(event.kind === 1 && !AggregateBeaconMessage.isKeyGenMessageValue(value)) {
114
- // Logger.warn(`Event ${event.id} is not a key generation message type: ${value}, skipping handler dispatch.`);
115
- // return;
116
- // }
117
- // if(event.kind === 1059 && !AggregateBeaconMessage.isSignMessageValue(value)) {
118
- // Logger.warn(`Event ${event.id} has an invalid title tag: ${value}, skipping handler dispatch.`);
119
- // return;
120
- // }
121
- // const handler = this.handlers.get(value);
122
- // if (!handler) {
123
- // Logger.warn(`No handler found for message with tag value: ${value}`);
124
- // return;
125
- // }
126
- // await handler(event);
127
- }
128
- /**
129
- * Registers a message handler for a specific message type.
130
- * @param {string} messageType The type of message to handle.
131
- * @param {MessageHandler} handler The handler function that processes the message.
132
- */
133
- registerMessageHandler(messageType, handler) {
134
- this.#handlers.set(messageType, handler);
135
- }
136
- /**
137
- * TODO: Clean up and complete this method.
138
- * Sends a message to a recipient using the Nostr protocol.
139
- * This method is a placeholder and should be implemented with actual Nostr message sending logic.
140
- * @param {AggregateBeaconMessageType} message The message to send, typically containing the content and metadata.
141
- * @param {Did} from The identifier of the sender.
142
- * @param {Did} [to] The identifier of the recipient.
143
- * @returns {Promise<void>} A promise that resolves when the message is sent.
144
- */
145
- async sendMessage(message, from, to) {
146
- // Check if the sender and recipient DIDs are valid identifiers
147
- if ([from, to]
148
- .filter(did => !!did)
149
- .every(did => !Identifier.isValid(did))) {
150
- console.error(`Invalid identifiers: sender ${from}, recipient ${to}`);
151
- throw new CommunicationAdapterError(`Invalid identifiers: sender ${from}, recipient ${to}`, 'SEND_MESSAGE_ERROR', { adapter: this.name });
152
- }
153
- // Decode the sender and recipient DIDs to get their genesis bytes in hex
154
- const sender = new CompressedSecp256k1PublicKey(Identifier.decode(from).genesisBytes);
155
- console.info(`Sending message from ${sender}:`, message);
156
- // if(message.type === BEACON_COHORT_SUBSCRIBE_ACCEPT) {
157
- // this.config.coordinatorDids.push(recipient);
158
- // }
159
- const tags = [['p', bytesToHex(sender.x)]];
160
- if (to) {
161
- const recipient = new CompressedSecp256k1PublicKey(Identifier.decode(to).genesisBytes);
162
- tags.push(['p', bytesToHex(recipient.x)]);
163
- }
164
- const { type } = message ?? {};
165
- if (!type) {
166
- console.error('Message type is undefined:', message);
167
- throw new CommunicationAdapterError('Message type is undefined', 'SEND_MESSAGE_ERROR', { adapter: this.name });
168
- }
169
- if (AggregateBeaconMessage.isKeyGenMessageValue(type)) {
170
- switch (type) {
171
- case BEACON_COHORT_ADVERT:
172
- console.info('Add tag', ['BEACON_COHORT_ADVERT', type]);
173
- break;
174
- case BEACON_COHORT_OPT_IN:
175
- console.info('Add tag', ['BEACON_COHORT_OPT_IN', type]);
176
- break;
177
- case BEACON_COHORT_OPT_IN_ACCEPT:
178
- console.info('Add tag', ['BEACON_COHORT_OPT_IN_ACCEPT', type]);
179
- break;
180
- case BEACON_COHORT_READY:
181
- console.info('Add tag', ['BEACON_COHORT_READY', type]);
182
- break;
183
- }
184
- const event = finalizeEvent({
185
- kind: 1,
186
- created_at: Math.floor(Date.now() / 1000),
187
- tags,
188
- content: JSON.stringify(message)
189
- }, this.config.keys.secret);
190
- console.info(`Sending message kind 1 event ...`, event);
191
- return this.pool?.publish(this.config.relays, event);
192
- }
193
- if (AggregateBeaconMessage.isSignMessageValue(type)) {
194
- switch (type) {
195
- case BEACON_COHORT_REQUEST_SIGNATURE:
196
- console.info('Add tag', ['BEACON_COHORT_REQUEST_SIGNATURE', type]);
197
- break;
198
- case BEACON_COHORT_AUTHORIZATION_REQUEST:
199
- console.info('Add tag', ['BEACON_COHORT_AUTHORIZATION_REQUEST', type]);
200
- break;
201
- case BEACON_COHORT_NONCE_CONTRIBUTION:
202
- console.info('Add tag', ['BEACON_COHORT_NONCE_CONTRIBUTION', type]);
203
- break;
204
- case BEACON_COHORT_AGGREGATED_NONCE:
205
- console.info('Add tag', ['BEACON_COHORT_AGGREGATED_NONCE', type]);
206
- break;
207
- case BEACON_COHORT_SIGNATURE_AUTHORIZATION:
208
- console.info('Add tag', ['BEACON_COHORT_SIGNATURE_AUTHORIZATION', type]);
209
- break;
210
- }
211
- const { publicKey, secretKey } = SchnorrKeyPair.generate();
212
- const content = nip44.encrypt(JSON.stringify(message), secretKey.bytes, nonceGen(publicKey.x).public);
213
- console.debug('NostrAdapter content:', content);
214
- const event = finalizeEvent({ content, tags, kind: 1059 }, this.config.keys.secret);
215
- console.debug('NostrAdapter event:', event);
216
- return this.pool?.publish(this.config.relays, event);
217
- }
218
- console.error(`Unsupported message type: ${type}`);
219
- }
220
- /**
221
- * TODO: Determine if this method is needed.
222
- * Generates a Nostr identity using the Secp256k1SecretKey and Identifier classes.
223
- * @param {RawSchnorrKeyPair} [keys] Optional keys to use for identity generation.
224
- * @returns {ServiceAdapterConfig} The generated Nostr identity configuration.
225
- */
226
- generateIdentity(keys) {
227
- if (!keys) {
228
- this.config.keys.secret = Secp256k1SecretKey.random();
229
- this.config.keys.public = Secp256k1SecretKey.getPublicKey(this.config.keys.secret).compressed;
230
- this.config.did = Identifier.encode(this.config.keys.public, {
231
- idType: this.config.components.idType || 'KEY',
232
- version: this.config.components.version || 1,
233
- network: this.config.components.network || 'signet',
234
- });
235
- return this.config;
236
- }
237
- this.config.keys = keys;
238
- this.config.did = Identifier.encode(this.config.keys.public, {
239
- idType: this.config.components.idType || 'KEY',
240
- version: this.config.components.version || 1,
241
- network: this.config.components.network || 'signet',
242
- });
243
- return this.config;
244
- }
245
- }
246
- //# sourceMappingURL=nostr.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"nostr.js","sourceRoot":"","sources":["../../../../../../../src/core/beacon/aggregation/communication/adapter/nostr.ts"],"names":[],"mappings":"AAAA,oEAAoE;AAGpE,OAAO,EAAE,4BAA4B,EAAqB,cAAc,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACzH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAgC,aAAa,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAA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I,CAAC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,MAAM,CAAC,GAAG,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EACzD;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;SAC1D,CACF,CAAC;QACF,OAAO,IAAI,CAAC,MAA8B,CAAC;IAC7C,CAAC;CACF"}
@@ -1,12 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,21 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"service.js","sourceRoot":"","sources":["../../../../../../src/core/beacon/aggregation/communication/service.ts"],"names":[],"mappings":""}