@did-btcr2/method 0.18.1 → 0.19.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 (262) hide show
  1. package/dist/browser.js +5217 -6057
  2. package/dist/browser.mjs +5217 -6057
  3. package/dist/cjs/core/beacon/aggregation/cohort/index.js +3 -3
  4. package/dist/cjs/core/beacon/aggregation/cohort/index.js.map +1 -1
  5. package/dist/cjs/core/beacon/aggregation/cohort/messages/base.js +1 -9
  6. package/dist/cjs/core/beacon/aggregation/cohort/messages/base.js.map +1 -1
  7. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js +2 -1
  8. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js.map +1 -1
  9. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js +2 -1
  10. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js.map +1 -1
  11. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js +2 -1
  12. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js.map +1 -1
  13. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in.js +2 -1
  14. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in.js.map +1 -1
  15. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/subscribe.js +2 -1
  16. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/subscribe.js.map +1 -1
  17. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js +2 -1
  18. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js.map +1 -1
  19. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/authorization-request.js +2 -1
  20. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/authorization-request.js.map +1 -1
  21. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js +2 -1
  22. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js.map +1 -1
  23. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/request-signature.js +2 -1
  24. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/request-signature.js.map +1 -1
  25. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js +2 -1
  26. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js.map +1 -1
  27. package/dist/cjs/core/beacon/aggregation/communication/adapter/nostr.js +36 -18
  28. package/dist/cjs/core/beacon/aggregation/communication/adapter/nostr.js.map +1 -1
  29. package/dist/cjs/core/beacon/aggregation/coordinator.js +14 -14
  30. package/dist/cjs/core/beacon/aggregation/coordinator.js.map +1 -1
  31. package/dist/cjs/core/beacon/aggregation/participant.js +4 -3
  32. package/dist/cjs/core/beacon/aggregation/participant.js.map +1 -1
  33. package/dist/cjs/core/beacon/aggregation/session/index.js +1 -1
  34. package/dist/cjs/core/beacon/aggregation/session/index.js.map +1 -1
  35. package/dist/cjs/core/beacon/cas-beacon.js +55 -0
  36. package/dist/cjs/core/beacon/cas-beacon.js.map +1 -0
  37. package/dist/cjs/core/beacon/factory.js +11 -10
  38. package/dist/cjs/core/beacon/factory.js.map +1 -1
  39. package/dist/cjs/core/beacon/interfaces.js +32 -0
  40. package/dist/cjs/core/beacon/interfaces.js.map +1 -0
  41. package/dist/cjs/core/beacon/singleton.js +59 -135
  42. package/dist/cjs/core/beacon/singleton.js.map +1 -1
  43. package/dist/cjs/core/beacon/smt-beacon.js +56 -0
  44. package/dist/cjs/core/beacon/smt-beacon.js.map +1 -0
  45. package/dist/cjs/core/beacon/utils.js +67 -105
  46. package/dist/cjs/core/beacon/utils.js.map +1 -1
  47. package/dist/cjs/core/identifier.js +18 -21
  48. package/dist/cjs/core/identifier.js.map +1 -1
  49. package/dist/cjs/core/interfaces.js +2 -0
  50. package/dist/cjs/core/interfaces.js.map +1 -0
  51. package/dist/cjs/core/resolve.js +511 -0
  52. package/dist/cjs/core/resolve.js.map +1 -0
  53. package/dist/cjs/{utils → core}/types.js.map +1 -1
  54. package/dist/cjs/core/{crud/update.js → update.js} +62 -52
  55. package/dist/cjs/core/update.js.map +1 -0
  56. package/dist/cjs/did-btcr2.js +109 -75
  57. package/dist/cjs/did-btcr2.js.map +1 -1
  58. package/dist/cjs/index.js +14 -15
  59. package/dist/cjs/index.js.map +1 -1
  60. package/dist/cjs/utils/appendix.js +10 -18
  61. package/dist/cjs/utils/appendix.js.map +1 -1
  62. package/dist/cjs/utils/did-document.js +51 -58
  63. package/dist/cjs/utils/did-document.js.map +1 -1
  64. package/dist/cjs/utils/general.js +1 -1
  65. package/dist/cjs/utils/general.js.map +1 -1
  66. package/dist/esm/core/beacon/aggregation/cohort/index.js +3 -3
  67. package/dist/esm/core/beacon/aggregation/cohort/index.js.map +1 -1
  68. package/dist/esm/core/beacon/aggregation/cohort/messages/base.js +1 -9
  69. package/dist/esm/core/beacon/aggregation/cohort/messages/base.js.map +1 -1
  70. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js +2 -1
  71. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js.map +1 -1
  72. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js +2 -1
  73. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js.map +1 -1
  74. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js +2 -1
  75. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js.map +1 -1
  76. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in.js +2 -1
  77. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in.js.map +1 -1
  78. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/subscribe.js +2 -1
  79. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/subscribe.js.map +1 -1
  80. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js +2 -1
  81. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js.map +1 -1
  82. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/authorization-request.js +2 -1
  83. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/authorization-request.js.map +1 -1
  84. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js +2 -1
  85. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js.map +1 -1
  86. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/request-signature.js +2 -1
  87. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/request-signature.js.map +1 -1
  88. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js +2 -1
  89. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js.map +1 -1
  90. package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js +36 -18
  91. package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js.map +1 -1
  92. package/dist/esm/core/beacon/aggregation/coordinator.js +14 -14
  93. package/dist/esm/core/beacon/aggregation/coordinator.js.map +1 -1
  94. package/dist/esm/core/beacon/aggregation/participant.js +4 -3
  95. package/dist/esm/core/beacon/aggregation/participant.js.map +1 -1
  96. package/dist/esm/core/beacon/aggregation/session/index.js +1 -1
  97. package/dist/esm/core/beacon/aggregation/session/index.js.map +1 -1
  98. package/dist/esm/core/beacon/cas-beacon.js +55 -0
  99. package/dist/esm/core/beacon/cas-beacon.js.map +1 -0
  100. package/dist/esm/core/beacon/factory.js +11 -10
  101. package/dist/esm/core/beacon/factory.js.map +1 -1
  102. package/dist/esm/core/beacon/interfaces.js +32 -0
  103. package/dist/esm/core/beacon/interfaces.js.map +1 -0
  104. package/dist/esm/core/beacon/singleton.js +59 -135
  105. package/dist/esm/core/beacon/singleton.js.map +1 -1
  106. package/dist/esm/core/beacon/smt-beacon.js +56 -0
  107. package/dist/esm/core/beacon/smt-beacon.js.map +1 -0
  108. package/dist/esm/core/beacon/utils.js +67 -105
  109. package/dist/esm/core/beacon/utils.js.map +1 -1
  110. package/dist/esm/core/identifier.js +18 -21
  111. package/dist/esm/core/identifier.js.map +1 -1
  112. package/dist/esm/core/interfaces.js +2 -0
  113. package/dist/esm/core/interfaces.js.map +1 -0
  114. package/dist/esm/core/resolve.js +511 -0
  115. package/dist/esm/core/resolve.js.map +1 -0
  116. package/dist/esm/{utils → core}/types.js.map +1 -1
  117. package/dist/esm/core/{crud/update.js → update.js} +62 -52
  118. package/dist/esm/core/update.js.map +1 -0
  119. package/dist/esm/did-btcr2.js +109 -75
  120. package/dist/esm/did-btcr2.js.map +1 -1
  121. package/dist/esm/index.js +14 -15
  122. package/dist/esm/index.js.map +1 -1
  123. package/dist/esm/utils/appendix.js +10 -18
  124. package/dist/esm/utils/appendix.js.map +1 -1
  125. package/dist/esm/utils/did-document.js +51 -58
  126. package/dist/esm/utils/did-document.js.map +1 -1
  127. package/dist/esm/utils/general.js +1 -1
  128. package/dist/esm/utils/general.js.map +1 -1
  129. package/dist/types/core/beacon/aggregation/cohort/index.d.ts +1 -1
  130. package/dist/types/core/beacon/aggregation/cohort/messages/base.d.ts +0 -7
  131. package/dist/types/core/beacon/aggregation/cohort/messages/base.d.ts.map +1 -1
  132. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.d.ts.map +1 -1
  133. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts.map +1 -1
  134. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.d.ts.map +1 -1
  135. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in.d.ts.map +1 -1
  136. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/subscribe.d.ts.map +1 -1
  137. package/dist/types/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.d.ts.map +1 -1
  138. package/dist/types/core/beacon/aggregation/cohort/messages/sign/authorization-request.d.ts.map +1 -1
  139. package/dist/types/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.d.ts.map +1 -1
  140. package/dist/types/core/beacon/aggregation/cohort/messages/sign/request-signature.d.ts.map +1 -1
  141. package/dist/types/core/beacon/aggregation/cohort/messages/sign/signature-authorization.d.ts.map +1 -1
  142. package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts +13 -5
  143. package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts.map +1 -1
  144. package/dist/types/core/beacon/aggregation/coordinator.d.ts +17 -29
  145. package/dist/types/core/beacon/aggregation/coordinator.d.ts.map +1 -1
  146. package/dist/types/core/beacon/aggregation/participant.d.ts.map +1 -1
  147. package/dist/types/core/beacon/cas-beacon.d.ts +47 -0
  148. package/dist/types/core/beacon/cas-beacon.d.ts.map +1 -0
  149. package/dist/types/core/beacon/factory.d.ts +5 -4
  150. package/dist/types/core/beacon/factory.d.ts.map +1 -1
  151. package/dist/types/core/beacon/interfaces.d.ts +98 -0
  152. package/dist/types/core/beacon/interfaces.d.ts.map +1 -0
  153. package/dist/types/core/beacon/singleton.d.ts +22 -65
  154. package/dist/types/core/beacon/singleton.d.ts.map +1 -1
  155. package/dist/types/core/beacon/smt-beacon.d.ts +48 -0
  156. package/dist/types/core/beacon/smt-beacon.d.ts.map +1 -0
  157. package/dist/types/core/beacon/utils.d.ts +19 -97
  158. package/dist/types/core/beacon/utils.d.ts.map +1 -1
  159. package/dist/types/core/identifier.d.ts.map +1 -1
  160. package/dist/types/core/interfaces.d.ts +94 -0
  161. package/dist/types/core/interfaces.d.ts.map +1 -0
  162. package/dist/types/core/resolve.d.ts +105 -0
  163. package/dist/types/core/resolve.d.ts.map +1 -0
  164. package/dist/types/core/types.d.ts +71 -0
  165. package/dist/types/core/types.d.ts.map +1 -0
  166. package/dist/types/core/{crud/update.d.ts → update.d.ts} +21 -20
  167. package/dist/types/core/update.d.ts.map +1 -0
  168. package/dist/types/did-btcr2.d.ts +45 -57
  169. package/dist/types/did-btcr2.d.ts.map +1 -1
  170. package/dist/types/index.d.ts +14 -15
  171. package/dist/types/index.d.ts.map +1 -1
  172. package/dist/types/utils/appendix.d.ts +5 -10
  173. package/dist/types/utils/appendix.d.ts.map +1 -1
  174. package/dist/types/utils/did-document-builder.d.ts +1 -1
  175. package/dist/types/utils/did-document-builder.d.ts.map +1 -1
  176. package/dist/types/utils/did-document.d.ts +31 -29
  177. package/dist/types/utils/did-document.d.ts.map +1 -1
  178. package/package.json +6 -6
  179. package/src/core/beacon/aggregation/cohort/index.ts +3 -3
  180. package/src/core/beacon/aggregation/cohort/messages/base.ts +1 -12
  181. package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.ts +2 -2
  182. package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.ts +2 -2
  183. package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.ts +2 -2
  184. package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in.ts +2 -2
  185. package/src/core/beacon/aggregation/cohort/messages/keygen/subscribe.ts +2 -2
  186. package/src/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.ts +2 -2
  187. package/src/core/beacon/aggregation/cohort/messages/sign/authorization-request.ts +2 -2
  188. package/src/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.ts +2 -2
  189. package/src/core/beacon/aggregation/cohort/messages/sign/request-signature.ts +2 -2
  190. package/src/core/beacon/aggregation/cohort/messages/sign/signature-authorization.ts +2 -2
  191. package/src/core/beacon/aggregation/communication/adapter/nostr.ts +43 -21
  192. package/src/core/beacon/aggregation/coordinator.ts +41 -29
  193. package/src/core/beacon/aggregation/participant.ts +4 -3
  194. package/src/core/beacon/aggregation/session/index.ts +1 -1
  195. package/src/core/beacon/cas-beacon.ts +67 -0
  196. package/src/core/beacon/factory.ts +13 -15
  197. package/src/core/beacon/interfaces.ts +124 -0
  198. package/src/core/beacon/singleton.ts +75 -145
  199. package/src/core/beacon/smt-beacon.ts +70 -0
  200. package/src/core/beacon/utils.ts +80 -170
  201. package/src/core/identifier.ts +21 -24
  202. package/src/core/interfaces.ts +101 -0
  203. package/src/core/resolve.ts +707 -0
  204. package/src/core/types.ts +78 -0
  205. package/src/core/{crud/update.ts → update.ts} +75 -68
  206. package/src/did-btcr2.ts +152 -92
  207. package/src/index.ts +14 -24
  208. package/src/utils/appendix.ts +18 -22
  209. package/src/utils/did-document-builder.ts +1 -1
  210. package/src/utils/did-document.ts +67 -71
  211. package/src/utils/general.ts +1 -1
  212. package/dist/cjs/core/beacon/cid-aggregate.js +0 -116
  213. package/dist/cjs/core/beacon/cid-aggregate.js.map +0 -1
  214. package/dist/cjs/core/beacon/smt-aggregate.js +0 -126
  215. package/dist/cjs/core/beacon/smt-aggregate.js.map +0 -1
  216. package/dist/cjs/core/crud/deactivate.js +0 -14
  217. package/dist/cjs/core/crud/deactivate.js.map +0 -1
  218. package/dist/cjs/core/crud/read.js +0 -679
  219. package/dist/cjs/core/crud/read.js.map +0 -1
  220. package/dist/cjs/core/crud/update.js.map +0 -1
  221. package/dist/cjs/interfaces/beacon.js +0 -41
  222. package/dist/cjs/interfaces/beacon.js.map +0 -1
  223. package/dist/cjs/interfaces/crud.js +0 -2
  224. package/dist/cjs/interfaces/crud.js.map +0 -1
  225. package/dist/esm/core/beacon/cid-aggregate.js +0 -116
  226. package/dist/esm/core/beacon/cid-aggregate.js.map +0 -1
  227. package/dist/esm/core/beacon/smt-aggregate.js +0 -126
  228. package/dist/esm/core/beacon/smt-aggregate.js.map +0 -1
  229. package/dist/esm/core/crud/deactivate.js +0 -14
  230. package/dist/esm/core/crud/deactivate.js.map +0 -1
  231. package/dist/esm/core/crud/read.js +0 -679
  232. package/dist/esm/core/crud/read.js.map +0 -1
  233. package/dist/esm/core/crud/update.js.map +0 -1
  234. package/dist/esm/interfaces/beacon.js +0 -41
  235. package/dist/esm/interfaces/beacon.js.map +0 -1
  236. package/dist/esm/interfaces/crud.js +0 -2
  237. package/dist/esm/interfaces/crud.js.map +0 -1
  238. package/dist/types/core/beacon/cid-aggregate.d.ts +0 -102
  239. package/dist/types/core/beacon/cid-aggregate.d.ts.map +0 -1
  240. package/dist/types/core/beacon/smt-aggregate.d.ts +0 -111
  241. package/dist/types/core/beacon/smt-aggregate.d.ts.map +0 -1
  242. package/dist/types/core/crud/deactivate.d.ts +0 -13
  243. package/dist/types/core/crud/deactivate.d.ts.map +0 -1
  244. package/dist/types/core/crud/read.d.ts +0 -334
  245. package/dist/types/core/crud/read.d.ts.map +0 -1
  246. package/dist/types/core/crud/update.d.ts.map +0 -1
  247. package/dist/types/interfaces/beacon.d.ts +0 -116
  248. package/dist/types/interfaces/beacon.d.ts.map +0 -1
  249. package/dist/types/interfaces/crud.d.ts +0 -32
  250. package/dist/types/interfaces/crud.d.ts.map +0 -1
  251. package/dist/types/utils/types.d.ts +0 -38
  252. package/dist/types/utils/types.d.ts.map +0 -1
  253. package/src/canonicalize.d.ts +0 -6
  254. package/src/core/beacon/cid-aggregate.ts +0 -153
  255. package/src/core/beacon/smt-aggregate.ts +0 -135
  256. package/src/core/crud/deactivate.ts +0 -13
  257. package/src/core/crud/read.ts +0 -948
  258. package/src/interfaces/beacon.ts +0 -137
  259. package/src/interfaces/crud.ts +0 -33
  260. package/src/utils/types.ts +0 -41
  261. /package/dist/cjs/{utils → core}/types.js +0 -0
  262. /package/dist/esm/{utils → core}/types.js +0 -0
@@ -2,19 +2,21 @@ import { getNetwork } from '@did-btcr2/bitcoin';
2
2
  import {
3
3
  BTCR2_DID_DOCUMENT_CONTEXT,
4
4
  DidDocumentError,
5
- ID_PLACEHOLDER_VALUE,
6
5
  IdentifierTypes,
7
6
  INVALID_DID_DOCUMENT,
8
7
  JSONObject,
9
- KeyBytes,
8
+ JSONUtils,
9
+ KeyBytes
10
10
  } from '@did-btcr2/common';
11
11
  import { CompressedSecp256k1PublicKey } from '@did-btcr2/keypair';
12
12
  import { DidService, DidDocument as IIDidDocument, DidVerificationMethod as IIDidVerificationMethod } from '@web5/dids';
13
- import { BeaconService } from '../interfaces/beacon.js';
13
+ import { BeaconService } from '../core/beacon/interfaces.js';
14
14
  import { BeaconUtils } from '../core/beacon/utils.js';
15
15
  import { Identifier } from '../core/identifier.js';
16
16
  import { Appendix } from './appendix.js';
17
+ import { payments } from 'bitcoinjs-lib';
17
18
 
19
+ export const ID_PLACEHOLDER_VALUE = 'did:btcr2:_';
18
20
  export const BECH32M_CHARS = '';
19
21
  export const DID_REGEX = /did:btcr2:(x1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]*)/g;
20
22
 
@@ -120,18 +122,22 @@ export class DidDocument implements IDidDocument {
120
122
  capabilityInvocation?: Array<string | DidVerificationMethod>;
121
123
  capabilityDelegation?: Array<string | DidVerificationMethod>;
122
124
  service: Array<BeaconService>;
125
+ deactivated?: boolean;
123
126
 
124
127
  constructor(document: IDidDocument) {
125
128
  // Set the ID and ID type
126
- const idType = document.id.includes('k1')
129
+ const idType = document.id.includes('k')
127
130
  ? IdentifierTypes.KEY
128
131
  : IdentifierTypes.EXTERNAL;
129
132
 
130
133
  // Validate ID and parts for non-intermediate
131
- const isIntermediate = document.id === ID_PLACEHOLDER_VALUE;
134
+ const isGenesis = document.id === ID_PLACEHOLDER_VALUE;
135
+
132
136
  // Deconstruct the document parts for validation
133
137
  const { id, controller, verificationMethod: vm, service } = document;
134
- if (!isIntermediate) {
138
+
139
+ // If not genesis, validate core properties
140
+ if (!isGenesis) {
135
141
  if (!DidDocument.isValidId(id)) {
136
142
  throw new DidDocumentError(`Invalid id: ${id}`, INVALID_DID_DOCUMENT, document);
137
143
  }
@@ -172,29 +178,19 @@ export class DidDocument implements IDidDocument {
172
178
  // Sanitize the DID Document
173
179
  DidDocument.sanitize(this);
174
180
  // If the DID Document is not an intermediateDocument, validate it
175
- if (!isIntermediate) {
181
+ if (!isGenesis) {
176
182
  DidDocument.validate(this);
177
183
  } else {
178
- this.validateIntermediate();
184
+ this.validateGenesis();
179
185
  }
180
186
  }
181
187
 
182
188
  /**
183
189
  * Convert the DidDocument to a JSON object.
184
- * @returns {JSONObject} The JSON representation of the DidDocument.
190
+ * @returns {DidDocument} The JSON representation of the DidDocument.
185
191
  */
186
- public json(): JSONObject {
187
- return {
188
- id : this.id,
189
- controller : this.controller,
190
- '@context' : this['@context'],
191
- verificationMethod : this.verificationMethod,
192
- authentication : this.authentication,
193
- assertionMethod : this.assertionMethod,
194
- capabilityInvocation : this.capabilityInvocation,
195
- capabilityDelegation : this.capabilityDelegation,
196
- service : this.service
197
- };
192
+ public json(): DidDocument {
193
+ return Object.fromEntries(Object.entries(this)) as DidDocument;
198
194
  }
199
195
 
200
196
  /**
@@ -374,10 +370,10 @@ export class DidDocument implements IDidDocument {
374
370
  * @returns {DidDocument} Validated DID Document.
375
371
  * @throws {DidDocumentError} If the DID Document is invalid.
376
372
  */
377
- public static validate(didDocument: DidDocument | IntermediateDidDocument): DidDocument {
373
+ public static validate(didDocument: DidDocument | GenesisDocument): DidDocument {
378
374
  // Validate the DID Document
379
375
  if (didDocument.id === ID_PLACEHOLDER_VALUE) {
380
- (didDocument as IntermediateDidDocument).validateIntermediate();
376
+ (didDocument as GenesisDocument).validateGenesis();
381
377
  } else {
382
378
  DidDocument.isValid(didDocument);
383
379
  }
@@ -386,60 +382,67 @@ export class DidDocument implements IDidDocument {
386
382
  }
387
383
 
388
384
  /**
389
- * Validate the IntermediateDidDocument.
390
- * @returns {boolean} True if the IntermediateDidDocument is valid.
385
+ * Validate the GenesisDocument.
386
+ * @returns {boolean} True if the GenesisDocument is valid.
391
387
  */
392
- public validateIntermediate(): boolean {
388
+ public validateGenesis(): boolean {
393
389
  // Validate the id
394
390
  if(this.id !== ID_PLACEHOLDER_VALUE) {
395
- throw new DidDocumentError('Invalid IntermediateDidDocument ID', INVALID_DID_DOCUMENT, this);
391
+ throw new DidDocumentError('Invalid GenesisDocument ID', INVALID_DID_DOCUMENT, this);
396
392
  }
397
393
  // Validate the controller
398
394
  if(!this.controller?.every(c => c === ID_PLACEHOLDER_VALUE)) {
399
- throw new DidDocumentError('Invalid IntermediateDidDocument controller', INVALID_DID_DOCUMENT, this);
395
+ throw new DidDocumentError('Invalid GenesisDocument controller', INVALID_DID_DOCUMENT, this);
400
396
  }
401
397
  // Validate the verificationMethod
402
398
  if(!this.verificationMethod.every(vm => vm.id.includes(ID_PLACEHOLDER_VALUE) && vm.controller === ID_PLACEHOLDER_VALUE)) {
403
- throw new DidDocumentError('Invalid IntermediateDidDocument verificationMethod', INVALID_DID_DOCUMENT, this);
399
+ throw new DidDocumentError('Invalid GenesisDocument verificationMethod', INVALID_DID_DOCUMENT, this);
404
400
  }
405
401
  // Validate the service
406
402
  if(!this.service.every(svc => svc.id.includes(ID_PLACEHOLDER_VALUE))) {
407
- throw new DidDocumentError('Invalid IntermediateDidDocument service', INVALID_DID_DOCUMENT, this);
403
+ throw new DidDocumentError('Invalid GenesisDocument service', INVALID_DID_DOCUMENT, this);
408
404
  }
409
405
  if(!DidDocument.isValidVerificationRelationships(this)) {
410
406
  // Return true if all validations pass
411
- throw new DidDocumentError('Invalid IntermediateDidDocument assertionMethod', INVALID_DID_DOCUMENT, this);
407
+ throw new DidDocumentError('Invalid GenesisDocument assertionMethod', INVALID_DID_DOCUMENT, this);
412
408
  }
413
409
 
414
410
  return true;
415
411
  }
416
412
 
417
413
  /**
418
- * Convert the DidDocument to an IntermediateDidDocument.
419
- * @returns {IntermediateDidDocument} The IntermediateDidDocument representation of the DidDocument.
414
+ * Convert the DidDocument to an GenesisDocument.
415
+ * @returns {GenesisDocument} The GenesisDocument representation of the DidDocument.
420
416
  */
421
- public toIntermediate(): IntermediateDidDocument {
417
+ public toIntermediate(): GenesisDocument {
422
418
  if(this.id.includes('k1')) {
423
419
  throw new DidDocumentError('Cannot convert a key identifier to an intermediate document', INVALID_DID_DOCUMENT, this);
424
420
  }
425
- return new IntermediateDidDocument(this);
421
+ return new GenesisDocument(this);
422
+ }
423
+ }
424
+
425
+ export class Document {
426
+ public static isValid(didDocument: DidDocument | GenesisDocument): boolean {
427
+ return new DidDocument(didDocument).validateGenesis();
426
428
  }
427
429
  }
428
430
 
431
+
429
432
  /**
430
- * IntermediateDidDocument extends the DidDocument class for creating and managing intermediate DID documents.
433
+ * GenesisDocument extends the DidDocument class for creating and managing intermediate DID documents.
431
434
  * This class is used to create a minimal DID document with a placeholder ID.
432
435
  * It is used in the process of creating a new DID document.
433
- * @class IntermediateDidDocument
436
+ * @class GenesisDocument
434
437
  * @extends {DidDocument}
435
438
  */
436
- export class IntermediateDidDocument extends DidDocument {
437
- constructor(document: JSONObject) {
438
- super(document as IDidDocument);
439
+ export class GenesisDocument extends DidDocument {
440
+ constructor(document: object | DidDocument) {
441
+ super(document as DidDocument);
439
442
  }
440
443
 
441
444
  /**
442
- * Convert the IntermediateDidDocument to a DidDocument by replacing the placeholder value with the provided DID.
445
+ * Convert the GenesisDocument to a DidDocument by replacing the placeholder value with the provided DID.
443
446
  * @param did The DID to replace the placeholder value in the document.
444
447
  * @returns {DidDocument} A new DidDocument with the placeholder value replaced by the provided DID.
445
448
  */
@@ -451,46 +454,45 @@ export class IntermediateDidDocument extends DidDocument {
451
454
 
452
455
 
453
456
  /**
454
- * Create an IntermediateDidDocument from a DidDocument by replacing the DID with a placeholder value.
457
+ * Create an GenesisDocument from a DidDocument by replacing the DID with a placeholder value.
455
458
  * @param {DidDocument} didDocument The DidDocument to convert.
456
- * @returns {IntermediateDidDocument} The IntermediateDidDocument representation of the DidDocument.
459
+ * @returns {GenesisDocument} The GenesisDocument representation of the DidDocument.
457
460
  */
458
- public static fromDidDocument(didDocument: DidDocument): IntermediateDidDocument {
459
- const intermediateDocument = JSON.cloneReplace(didDocument, DID_REGEX, ID_PLACEHOLDER_VALUE) as IDidDocument;
460
- return new IntermediateDidDocument(intermediateDocument);
461
+ public static fromDidDocument(didDocument: DidDocument): GenesisDocument {
462
+ const intermediateDocument = JSONUtils.cloneReplace(didDocument, DID_REGEX, ID_PLACEHOLDER_VALUE) as IDidDocument;
463
+ return new GenesisDocument(intermediateDocument);
461
464
  }
462
465
 
463
466
  /**
464
- * Create a minimal IntermediateDidDocument with a placeholder ID.
467
+ * Create a minimal GenesisDocument with a placeholder ID.
465
468
  * @param {Array<DidVerificationMethod>} verificationMethod The public key in multibase format.
466
469
  * @param {VerificationRelationships} relationships The public key in multibase format.
467
470
  * @param {Array<BeaconService>} service The service to be included in the document.
468
- * @returns {IntermediateDidDocument} A new IntermediateDidDocument with the placeholder ID.
471
+ * @returns {GenesisDocument} A new GenesisDocument with the placeholder ID.
469
472
  */
470
473
  public static create(
471
474
  verificationMethod: Array<DidVerificationMethod>,
472
475
  relationships: VerificationRelationships,
473
476
  service: Array<BeaconService>
474
- ): IntermediateDidDocument {
477
+ ): GenesisDocument {
475
478
  const id = ID_PLACEHOLDER_VALUE;
476
- return new IntermediateDidDocument({ id, ...relationships, verificationMethod, service, });
479
+ return new GenesisDocument({ id, ...relationships, verificationMethod, service, });
477
480
  }
478
481
 
479
482
  /**
480
- * Create a minimal IntermediateDidDocument from a public key.
483
+ * Create a minimal GenesisDocument from a public key.
481
484
  * @param {KeyBytes} publicKey The public key in bytes format.
482
- * @returns {IntermediateDidDocument} A new IntermediateDidDocument with the placeholder ID.
485
+ * @returns {GenesisDocument} A new GenesisDocument with the placeholder ID.
483
486
  */
484
- public static fromPublicKey(publicKey: KeyBytes, network: string): IntermediateDidDocument {
487
+ public static fromPublicKey(publicKey: KeyBytes, network: string): GenesisDocument {
485
488
  const pk = new CompressedSecp256k1PublicKey(publicKey);
486
489
  const id = ID_PLACEHOLDER_VALUE;
487
- const service = BeaconUtils.generateBeaconService({
488
- id : `${id}#key-0`,
489
- publicKey : pk.compressed,
490
- network : getNetwork(network),
491
- addressType : 'p2pkh',
492
- type : 'SingletonBeacon',
493
- });
490
+ const address = payments.p2pkh({ pubkey: pk.compressed, network: getNetwork(network) })?.address;
491
+ const services = [{
492
+ id : `${id}#key-0`,
493
+ serviceEndpoint : `bitcoin:${address}`,
494
+ type : 'SingletonBeacon',
495
+ }];
494
496
 
495
497
  const relationships = {
496
498
  authentication : [`${id}#key-0`],
@@ -507,21 +509,15 @@ export class IntermediateDidDocument extends DidDocument {
507
509
  }
508
510
  ];
509
511
 
510
- return IntermediateDidDocument.create(verificationMethod, relationships, [service]);
512
+ return GenesisDocument.create(verificationMethod, relationships, services);
511
513
  }
512
514
 
513
515
  /**
514
516
  * Taken an object, convert it to an IntermediateDocuemnt and then to a DidDocument.
515
- * @param {JSONObject} object The JSON object to convert.
517
+ * @param {object | DidDocument} object The JSON object to convert.
516
518
  * @returns {DidDocument} The created DidDocument.
517
519
  */
518
- public static fromJSON(object: JSONObject): IntermediateDidDocument {
519
- return new IntermediateDidDocument(object as IDidDocument);
520
- }
521
- }
522
-
523
- export class Document {
524
- public static isValid(didDocument: DidDocument | IntermediateDidDocument): boolean {
525
- return new DidDocument(didDocument).validateIntermediate();
520
+ public static fromJSON(object: object | DidDocument): GenesisDocument {
521
+ return new GenesisDocument(object as IDidDocument);
526
522
  }
527
- }
523
+ }
@@ -36,7 +36,7 @@ export class GeneralUtils {
36
36
  */
37
37
  static bigintToBuffer(value: bigint): Buffer {
38
38
  const hex = value.toString(16).padStart(64, '0');
39
- return Buffer.fromHex(hex);
39
+ return Buffer.from(hex, 'hex');
40
40
  }
41
41
 
42
42
  /**
@@ -1,116 +0,0 @@
1
- import { MethodError } from '@did-btcr2/common';
2
- import { Beacon } from '../../interfaces/beacon.js';
3
- /**
4
- * Implements {@link https://dcdpr.github.io/did-btcr2/#cidaggregate-beacon | 5.2 CIDAggregate Beacon}.
5
- *
6
- * A Beacon of the type CIDAggregatoBeacon is a Beacon that publishes Bitcoin transactions containing a Content
7
- * Identifier (CID) announcing an Aggregated DID Update Bundle. An Aggregated DID Update Bundle is a JSON object that
8
- * maps did:btcr2 identifiers to CID values for the individual DID Update Payloads. The Aggregated DID Update Bundle CID
9
- * (bundleCID) SHOULD be resolvable against a Content Addressable Storage (CAS) system such as IPFS, while the CID for
10
- * the DID Update Payload (payloadCID) MAY be resolvable against a CAS or provided through a Sidecar mechanism. It is
11
- * RECOMMENDED that this type of Beacon is only included in a DID document if the DID controller is REQUIRED to
12
- * participate in authorizing Bitcoin transactions from this Beacon. In other words, this Beacon SHOULD identify an
13
- * n-of-n P2TR Bitcoin address where n is the number of unique DID controllers submitting updates through the Beacon.
14
- *
15
- * @class CIDAggregateBeacon
16
- * @type {CIDAggregateBeacon}
17
- * @extends {Beacon}
18
- */
19
- export class CIDAggregateBeacon extends Beacon {
20
- /**
21
- * Creates an instance of CIDAggregateBeacon.
22
- * @param {BeaconService} service The service of the Beacon.
23
- * @param {?BeaconSidecarData} [sidecar] The sidecar data of the Beacon.
24
- */
25
- constructor(service, sidecar) {
26
- super({ ...service, type: 'CIDAggregateBeacon' }, sidecar);
27
- }
28
- get service() {
29
- return {
30
- type: this.type,
31
- id: this.id,
32
- serviceEndpoint: this.serviceEndpoint
33
- };
34
- }
35
- /**
36
- * TODO: Finish implementation
37
- *
38
- * Implements {@link https://dcdpr.github.io/did-btcr2/#establish-cidaggregate-beacon | 5.2.1 Establish CIDAggregate Beacon}.
39
- *
40
- * To establish a CIDAggregatorBeacon, a cohort of cooperating parties SHOULD generate an n-of-n P2TR Bitcoin address
41
- * where each party contributes a public key. Furthermore, each party SHOULD verify that their key is part of the
42
- * address and all other keys that are part of the address are keys with controllers able to produce valid signatures.
43
- * To establish a Beacon there are two roles. One is the cohort participant, they want to join a Beacon cohort and
44
- * submit a request to do so with a key and proof of control over that key. The other is the Beacon coordinator, they
45
- * advertise and curate Beacon cohorts by combining Beacon participants into cohorts, verifying proofs of control, and
46
- * producing Beacon addresses.
47
- *
48
- * @param {string} id The identifier of the Beacon.
49
- * @param {string} type The type of the Beacon.
50
- * @param {DidServiceEndpoint} serviceEndpoint The service endpoint of the Beacon.
51
- * @returns {CIDAggregateBeacon} The established CIDAggregate Beacon.
52
- */
53
- static establish(id, type, serviceEndpoint) {
54
- return new CIDAggregateBeacon({ id, type, serviceEndpoint });
55
- }
56
- /**
57
- * TODO: Figure out if this is necessary or not.
58
- * @param {string} didUpdatePayload The DID Update Payload to generate the signal for.
59
- * @returns {BeaconSignal} The generated signal.
60
- * @throws {MethodError} if the signal is invalid.
61
- */
62
- generateSignal(didUpdatePayload) {
63
- throw new MethodError('Method not implemented.', `METHOD_NOT_IMPLEMENTED`, { didUpdatePayload });
64
- }
65
- /**
66
- * TODO: Finish implementation
67
- *
68
- * Implements {@link https://dcdpr.github.io/did-btcr2/#process-cidaggregate-beacon-signal | 5.2.3 Process CIDAggregate Beacon Signal}.
69
- *
70
- * A Beacon Signal from a CIDAggregate Beacon is a Bitcoin transaction that contains the hashBytes of a DID Update
71
- * Bundle in its first transaction output. The corresponding DID Update Bundle MUST either be provided through Sidecar
72
- * Data or by converting hashBytes into a IPFS v1 Content Identifier and attempting to retrieve it from Content
73
- * Addressable Storage. The DID Update Bundle maps from did:btcr2 identifiers to hashes of DID Update payloads
74
- * applicable for that identifier. Again this algorithm attempts to retrieve and validate the DID Update Payload
75
- * identified for the identifier being resolved. If successful, the DID Update Payload is returned.
76
- *
77
- * The Process CIDAggregate Beacon Signal algorithm is called by the Process Beacon Signals algorithm as part of the
78
- * Read operation.
79
- *
80
- * It takes as inputs a did:btcr2 identifier, Identifier, a Beacon Signal, tx, and a optional
81
- * object, signalSidecarData, containing any sidecar data provided to the resolver for the Beacon Signal identified by
82
- * the Bitcoin transaction identifier.
83
- *
84
- * It returns the DID Update payload announced by the Beacon Signal for the
85
- * did:btcr2 identifier being resolved or throws an error.
86
- *
87
- * @param {RawTransactionV2} signal Bitcoin transaction representing a Beacon Signal.
88
- * @param {SignalsMetadata} signalsMetadata Optional sidecar data for the Beacon Signal.
89
- * @returns {Promise<DidUpdatePayload | undefined>} The DID Update payload announced by the Beacon Signal.
90
- * @throws {DidError} if the signalTx is invalid or the signalsMetadata is invalid.
91
- */
92
- processSignal(signal, signalsMetadata) {
93
- throw new MethodError('Method not implemented.', `METHOD_NOT_IMPLEMENTED`, { signal, signalsMetadata });
94
- }
95
- /**
96
- * TODO: Finish implementation
97
- *
98
- * Implements {@link https://dcdpr.github.io/did-btcr2/#broadcast-cidaggregate-beacon-signal | 5.2.2 Broadcast CIDAggregate Beacon Signal}.
99
- *
100
- * The Broadcast CIDAggregate Beacon Signal algorithm involving two roles: a set of cohort participants and a Beacon
101
- * coordinator. The Beacon coordinator collects individual DID Update Payload Content Identifiers (CIDs) for specific
102
- * did:btcr2 idntifiers and aggregates them into a DID Update Bundle, which is then published to a Content Addressable
103
- * Storage (CAS). The CID for the DID Update Bundle is included in a Partially Signed Bitcoin Transaction (PSBT) transaction
104
- * output spent from the Beacon’s n-of-n address. Each of the n cohort participants in the Beacon MUST sign the
105
- * transaction before it can be broadcast to the network. It is RECOMMENDED that cohort participants keep a copy of
106
- * the DID Update Bundle and separately pin it to the CAS.
107
- *
108
- * @param {DidUpdatePayload} didUpdatePayload The verificationMethod object to be used for signing.
109
- * @returns {SignalsMetadata} Successful output of a bitcoin transaction.
110
- * @throws {SingletonBeaconError} if the bitcoin address is invalid or unfunded.
111
- */
112
- broadcastSignal(didUpdatePayload) {
113
- throw new MethodError('Method not implemented.', `METHOD_NOT_IMPLEMENTED`, didUpdatePayload);
114
- }
115
- }
116
- //# sourceMappingURL=cid-aggregate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cid-aggregate.js","sourceRoot":"","sources":["../../../../src/core/beacon/cid-aggregate.ts"],"names":[],"mappings":"AACA,OAAO,EAAyC,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEvF,OAAO,EAAE,MAAM,EAA+B,MAAM,4BAA4B,CAAC;AAGjF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,kBAAmB,SAAQ,MAAM;IAC5C;;;;OAIG;IACH,YAAY,OAAsB,EAAE,OAAgD;QAClF,KAAK,CAAC,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAE,EAAE,OAAO,CAAC,CAAC;IAC7D,CAAC;IACD,IAAI,OAAO;QACT,OAAO;YACL,IAAI,EAAc,IAAI,CAAC,IAAI;YAC3B,EAAE,EAAgB,IAAI,CAAC,EAAE;YACzB,eAAe,EAAG,IAAI,CAAC,eAAe;SACvC,CAAC;IACJ,CAAC;IAGD;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,SAAS,CAAC,EAAU,EAAE,IAAY,EAAE,eAAmC;QAC5E,OAAO,IAAI,kBAAkB,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,CAAC;IAC/D,CAAC;IAGD;;;;;OAKG;IACH,cAAc,CAAC,gBAAwB;QACrC,MAAM,IAAI,WAAW,CAAC,yBAAyB,EAAE,wBAAwB,EAAE,EAAC,gBAAgB,EAAC,CAAC,CAAC;IACjG,CAAC;IAGD;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,aAAa,CAAC,MAAwB,EAAE,eAAgC;QACtE,MAAM,IAAI,WAAW,CAAC,yBAAyB,EAAE,wBAAwB,EAAE,EAAC,MAAM,EAAE,eAAe,EAAC,CAAC,CAAC;IACxG,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,eAAe,CAAC,gBAAkC;QAChD,MAAM,IAAI,WAAW,CAAC,yBAAyB,EAAE,wBAAwB,EAAE,gBAAgB,CAAC,CAAC;IAC/F,CAAC;CA4BF"}
@@ -1,126 +0,0 @@
1
- import { MethodError } from '@did-btcr2/common';
2
- import { Beacon } from '../../interfaces/beacon.js';
3
- /**
4
- * TODO: Finish implementation
5
- *
6
- * Implements {@link https://dcdpr.github.io/did-btcr2/#smtaggregate-beacon | 5.3 SMTAggregate Beacon}.
7
- *
8
- * A SMTAggregate Beacon is a Beacon whose Beacon Signals are Bitcoin transactions containing the root of a Sparse
9
- * Merkle Tree (SMT). The SMT root attests to a set of DID Update Payloads, however, the updates themselves MUST be
10
- * provided along with a proof of inclusion against the SMT root through a Sidecar mechanism during resolution. Using
11
- * the SMT root a resolver can then verify the inclusion proof for the given DID Update Payload. If a DID document
12
- * includes a SMTAggregator Beacon in their set of Beacon services, then they MUST provide proofs for each signal that
13
- * the Beacon broadcasts. If they did not submit an update to their DID in a signal, then they MUST provide a proof of
14
- * non-inclusion for that signal.
15
- *
16
- * @class SMTAggregateBeacon
17
- * @type {SMTAggregateBeacon}
18
- * @extends {Beacon}
19
- */
20
- export class SMTAggregateBeacon extends Beacon {
21
- /**
22
- * Creates an instance of SMTAggregateBeacon.
23
- * @param {BeaconService} service The Beacon service.
24
- * @param {?BeaconSidecarData} [sidecar] Optional sidecar data.
25
- */
26
- constructor(service, sidecar) {
27
- super({ ...service, type: 'SMTAggregateBeacon' }, sidecar);
28
- }
29
- /**
30
- * Get the Beacon service.
31
- * @readonly
32
- * @type {BeaconService} The Beacon service.
33
- */
34
- get service() {
35
- const service = {
36
- type: this.type,
37
- id: this.id,
38
- serviceEndpoint: this.serviceEndpoint
39
- };
40
- return service;
41
- }
42
- /**
43
- * TODO: Figure out if this is necessary or not.
44
- * @param {string} didUpdatePayload The DID Update Payload to generate the signal for.
45
- * @returns {BeaconSignal} The generated signal.
46
- * @throws {MethodError} if the signal is invalid.
47
- */
48
- generateSignal(didUpdatePayload) {
49
- throw new MethodError('Method not implemented.', `METHOD_NOT_IMPLEMENTED`, { didUpdatePayload });
50
- }
51
- /**
52
- * Implements {@link https://dcdpr.github.io/did-btcr2/#establish-beacon | 5.3.1 Establish Beacon}.
53
- *
54
- * The Establish Beacon algorithm is essentially the same as for the CIDAggregate Beacon in Establish CIDAggregate
55
- * Beacon. A cohort of DID controllers need to coordinate to produce a Bitcoin address that will act as the Beacon.
56
- * It is RECOMMENDED this is an n-of-n P2TR address, with n being the set of DID controllers in the cohort. Once the
57
- * address has been created, and all parties in the cohort acknowledge their intention to participate in that Beacon,
58
- * each DID controller SHOULD add the Beacon as a service to their DID document.
59
- *
60
- * Additionally, the SMTAggregate Beacon cohort participants MUST register the did:btcr2 identifiers they intend use
61
- * this Beacon with. This is so the Beacon coordinator can generate the necessary proofs of both inclusion and
62
- * non-inclusion for each DID.
63
- *
64
- * Static, convenience method for establishing a Beacon object.
65
- *
66
- * @param {string} id The Beacon ID.
67
- * @param {string} type The Beacon type.
68
- * @param {DidServiceEndpoint} serviceEndpoint The service endpoint.
69
- * @returns {Beacon} The Beacon.
70
- */
71
- static establish(id, type, serviceEndpoint) {
72
- return new SMTAggregateBeacon({ id, type, serviceEndpoint });
73
- }
74
- /**
75
- *
76
- * Implements {@link https://dcdpr.github.io/did-btcr2/#broadcast-smtaggregate-beacon-signal | 5.3.2 Broadcast SMTAggregate Beacon Signal}.
77
- *
78
- * See {@link Beacon.broadcastSignal | Beacon Interface Method broadcastSignal} for more information.
79
- *
80
- * To publish a DID Update Payload, the DID controller MUST get a hash of the DID Update Payload included at the leaf
81
- * of the Sparse Merkle Tree (SMT) identified by their did:btcr2 identifier and receive an inclusion proof for this
82
- * data. If a member of the Beacon cohort does not wish to announce an update in a Beacon Signal, they MUST receive
83
- * and verify a proof of non-inclusion for their DID. Upon verifying the non-inclusion proof against the SMT root
84
- * contained in the Beacon Signal, they SHOULD accept and authorize the signal following the MuSig2 protocol. Once all
85
- * members of the cohort have authorized the signal, it can be broadcast as a transaction to the Bitcoin network. DID
86
- * controllers are responsible for persisting their DID updates and proofs, these will need to be provided through a
87
- * Sidecar mechanism during a resolution process.
88
- *
89
- * @param {DidUpdatePayload} didUpdatePayload The DID Update Payload to broadcast.
90
- * @returns {Promise<SignalMetadata>} The signal metadata.
91
- * @throws {MethodError} if the signal is invalid.
92
- */
93
- broadcastSignal(didUpdatePayload) {
94
- throw new MethodError('Method not implemented.', `METHOD_NOT_IMPLEMENTED`, didUpdatePayload);
95
- }
96
- /**
97
- * Implements {@link https://dcdpr.github.io/did-btcr2/#process-smtaggregate-beacon-signal | 5.3.3 Process SMTAggregate Beacon Signal}.
98
- *
99
- * See {@link Beacon.processSignal | Beacon Interface Method processSignal} for more information.
100
- *
101
- * A Beacon Signal from a SMTAggregate Beacon is a Bitcoin transaction with the first transaction output of the format
102
- * [OP_RETURN, OP_PUSH32, <32bytes>]. The 32 bytes of data contained within this transaction output represent the root
103
- * of a Sparse Merkle Tree (SMT). This SMT aggregates a set of hashes of DID Update payloads. In order to process
104
- * these Beacon Signals, the resolver MUST have been passed Sidecar data for this signal containing either the DID
105
- * Update payload object and a SMT proof that the hash of this object is in the SMT at the leaf indexed by the
106
- * did:Identifier being resolved. Or theSidecar data:: MUST contain a proof that the leaf indexed by the
107
- * did:Identifier is empty, thereby proving that theSMT:: does not contain an update for their identifier.
108
- *
109
- * The Process SMTAggregate Beacon Signal is called by the Process Beacon Signals algorithm as part of the Read
110
- * operation. It takes as inputs a did:btcr2 identifier, Identifier, a Beacon Signal, tx, and a optional object,
111
- * signalSidecarData, containing any sidecar data provided to the resolver for the Beacon Signal identified by the
112
- * Bitcoin transaction identifier.
113
- *
114
- * It returns the DID Update payload announced by the Beacon Signal for the did:btcr2 identifier being resolved or
115
- * throws an error.
116
- *
117
- * @param {RawTransactionV2} signal The raw transaction signal.
118
- * @param {SignalsMetadata} signalsMetadata The signals metadata.
119
- * @returns {Promise<DidUpdatePayload | undefined>} The updated DID document.
120
- * @throws {MethodError} if the signal is invalid.
121
- */
122
- processSignal(signal, signalsMetadata) {
123
- throw new MethodError('Method not implemented.', `METHOD_NOT_IMPLEMENTED`, { signal, signalsMetadata });
124
- }
125
- }
126
- //# sourceMappingURL=smt-aggregate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"smt-aggregate.js","sourceRoot":"","sources":["../../../../src/core/beacon/smt-aggregate.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAElE,OAAO,EAAE,MAAM,EAA+B,MAAM,4BAA4B,CAAC;AAGjF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,kBAAmB,SAAQ,MAAM;IAC5C;;;;OAIG;IACH,YAAY,OAAsB,EAAE,OAAgD;QAClF,KAAK,CAAC,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAE,EAAE,OAAO,CAAC,CAAC;IAC7D,CAAC;IAED;;;;OAIG;IACH,IAAI,OAAO;QACT,MAAM,OAAO,GAAG;YACd,IAAI,EAAc,IAAI,CAAC,IAAI;YAC3B,EAAE,EAAgB,IAAI,CAAC,EAAE;YACzB,eAAe,EAAG,IAAI,CAAC,eAAe;SACvC,CAAC;QACF,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;;;;OAKG;IACI,cAAc,CAAC,gBAAwB;QAC5C,MAAM,IAAI,WAAW,CAAC,yBAAyB,EAAE,wBAAwB,EAAE,EAAC,gBAAgB,EAAC,CAAC,CAAC;IACjG,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACI,MAAM,CAAC,SAAS,CAAC,EAAU,EAAE,IAAY,EAAE,eAAmC;QACnF,OAAO,IAAI,kBAAkB,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,CAAC;IAC/D,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACI,eAAe,CAAC,gBAAkC;QACvD,MAAM,IAAI,WAAW,CAAC,yBAAyB,EAAE,wBAAwB,EAAE,gBAAgB,CAAC,CAAC;IAC/F,CAAC;IAGD;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACI,aAAa,CAAC,MAAwB,EAAE,eAAgC;QAC7E,MAAM,IAAI,WAAW,CAAC,yBAAyB,EAAE,wBAAwB,EAAE,EAAC,MAAM,EAAE,eAAe,EAAC,CAAC,CAAC;IACxG,CAAC;CACF"}
@@ -1,14 +0,0 @@
1
- import { DidBtcr2 } from '../../did-btcr2.js';
2
- /**
3
- * Implements {@link https://dcdpr.github.io/did-btcr2/#deactivate | 4.4 Deactivate}
4
- * To deactivate a did:btcr2, the DID controller MUST add the property deactivated with the value true on the DID
5
- * document. To do this, the DID controller constructs a valid DID Update Payload with a JSON patch that adds this
6
- * property and announces the payload through a Beacon in their current DID document following the algorithm in Update.
7
- * Once a did:btcr2 has been deactivated this state is considered permanent and resolution MUST terminate.
8
- * @class Deactivate
9
- * @type {Deactivate}
10
- * @extends {DidBtcr2}
11
- */
12
- export class Deactivate extends DidBtcr2 {
13
- }
14
- //# sourceMappingURL=deactivate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deactivate.js","sourceRoot":"","sources":["../../../../src/core/crud/deactivate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C;;;;;;;;;GASG;AACH,MAAM,OAAO,UAAW,SAAQ,QAAQ;CAAG"}