@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,424 +0,0 @@
1
- import { getNetwork } from '@did-btcr2/bitcoin';
2
- import { canonicalize, DidDocumentError, hash, IdentifierTypes, INVALID_DID_DOCUMENT, JSONUtils } from '@did-btcr2/common';
3
- import { CompressedSecp256k1PublicKey } from '@did-btcr2/keypair';
4
- import { payments } from 'bitcoinjs-lib';
5
- import { BeaconUtils } from '../core/beacon/utils.js';
6
- import { Identifier } from '../core/identifier.js';
7
- import { Appendix } from './appendix.js';
8
- export const BTCR2_DID_DOCUMENT_CONTEXT = [
9
- 'https://www.w3.org/ns/did/v1.1',
10
- 'https://btcr2.dev/context/v1',
11
- ];
12
- export const ID_PLACEHOLDER_VALUE = 'did:btcr2:_';
13
- export const BECH32M_CHARS = '';
14
- export const DID_REGEX = /did:btcr2:(x1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]*)/g;
15
- /**
16
- * DID BTCR2 Verification Method extends the DidVerificationMethod class adding helper methods and properties
17
- * @class DidVerificationMethod
18
- * @type {DidVerificationMethod}
19
- *
20
- */
21
- export class DidVerificationMethod {
22
- id;
23
- type;
24
- controller;
25
- publicKeyMultibase;
26
- secretKeyMultibase;
27
- constructor({ id, type, controller, publicKeyMultibase, secretKeyMultibase }) {
28
- this.id = id;
29
- this.type = type;
30
- this.controller = controller;
31
- this.publicKeyMultibase = publicKeyMultibase;
32
- this.secretKeyMultibase = secretKeyMultibase;
33
- if (!secretKeyMultibase) {
34
- delete this.secretKeyMultibase;
35
- }
36
- }
37
- }
38
- /**
39
- * BTCR2 DID Document extends the DidDocument class adding helper methods and properties
40
- * @class DidDocument
41
- * @type {DidDocument}
42
- * @implements {Btcr2DidDocument}
43
- * @property {string} id - The identifier of the DID Document.
44
- * @property {Array<string | JSONObject>} ['@context'] - The context of the DID Document.
45
- * @property {Array<DidVerificationMethod>} verificationMethod - The verification methods of the DID Document.
46
- * @property {Array<string | DidVerificationMethod>} [authentication] - The authentication methods of the DID Document.
47
- * @property {Array<string | DidVerificationMethod>} [assertionMethod] - The assertion methods of the DID Document.
48
- * @property {Array<string | DidVerificationMethod>} [capabilityInvocation] - The capability invocation methods of the DID Document.
49
- * @property {Array<string | DidVerificationMethod>} [capabilityDelegation] - The capability delegation methods of the DID Document.
50
- * @property {Array<BeaconService>} service - The services of the DID Document.
51
- * @property {boolean} [deactivated] - Indicates if the DID Document is deactivated.
52
- */
53
- export class DidDocument {
54
- id;
55
- '@context' = [
56
- 'https://www.w3.org/ns/did/v1.1',
57
- 'https://btcr2.dev/context/v1',
58
- ];
59
- verificationMethod;
60
- authentication;
61
- assertionMethod;
62
- capabilityInvocation;
63
- capabilityDelegation;
64
- service;
65
- deactivated;
66
- constructor(document) {
67
- // Ensure document has an id
68
- if (!document.id) {
69
- throw new DidDocumentError('DID Document must have an id', INVALID_DID_DOCUMENT, document);
70
- }
71
- // Set the ID and ID type
72
- const idType = document.id.includes('k1')
73
- ? IdentifierTypes.KEY
74
- : IdentifierTypes.EXTERNAL;
75
- // Validate ID and parts for non-intermediate
76
- const isGenesis = document.id === ID_PLACEHOLDER_VALUE;
77
- // Deconstruct the document parts for validation
78
- const { id, verificationMethod: vm, service } = document;
79
- // If not genesis, validate core properties
80
- if (!isGenesis) {
81
- if (!DidDocument.isValidId(id)) {
82
- throw new DidDocumentError(`Invalid id: ${id}`, INVALID_DID_DOCUMENT, document);
83
- }
84
- if (!DidDocument.isValidVerificationMethods(vm)) {
85
- throw new DidDocumentError('Invalid verificationMethod: ' + vm, INVALID_DID_DOCUMENT, document);
86
- }
87
- if (!DidDocument.isValidServices(service)) {
88
- throw new DidDocumentError('Invalid service: ' + service, INVALID_DID_DOCUMENT, document);
89
- }
90
- }
91
- // Set core properties
92
- this.id = document.id;
93
- this.verificationMethod = document.verificationMethod || [];
94
- this.service = document.service || [];
95
- this['@context'] = document['@context'] || [
96
- 'https://www.w3.org/ns/did/v1.1',
97
- 'https://btcr2.dev/context/v1'
98
- ];
99
- // Relationships logic based on idType
100
- if (idType === IdentifierTypes.KEY) {
101
- // auto-generate #initialKey if missing
102
- const keyRef = `${this.id}#initialKey`;
103
- this.authentication = document.authentication || [keyRef];
104
- this.assertionMethod = document.assertionMethod || [keyRef];
105
- this.capabilityInvocation = document.capabilityInvocation || [keyRef];
106
- this.capabilityDelegation = document.capabilityDelegation || [keyRef];
107
- }
108
- else {
109
- // EXTERNAL: use provided arrays, must be defined
110
- this.authentication = document.authentication;
111
- this.assertionMethod = document.assertionMethod;
112
- this.capabilityInvocation = document.capabilityInvocation;
113
- this.capabilityDelegation = document.capabilityDelegation;
114
- }
115
- // Sanitize the DID Document
116
- DidDocument.sanitize(this);
117
- // If the DID Document is not an intermediateDocument, validate it
118
- if (isGenesis) {
119
- this.validateGenesis();
120
- }
121
- else {
122
- DidDocument.validate(this);
123
- }
124
- }
125
- /**
126
- * Convert the DidDocument to a JSON object.
127
- * @returns {DidDocument} The JSON representation of the DidDocument.
128
- */
129
- toJSON() {
130
- return {
131
- id: this.id,
132
- '@context': this['@context'],
133
- verificationMethod: this.verificationMethod,
134
- authentication: this.authentication,
135
- assertionMethod: this.assertionMethod,
136
- capabilityInvocation: this.capabilityInvocation,
137
- capabilityDelegation: this.capabilityDelegation,
138
- service: this.service,
139
- deactivated: this.deactivated
140
- };
141
- }
142
- /**
143
- * Create a minimal DidDocument from "k1" btcr2 identifier.
144
- * @param {string} publicKeyMultibase The public key in multibase format.
145
- * @param {Array<BeaconService>} service The beacon services to be included in the document.
146
- * @returns {DidDocument} A new DidDocument with the placeholder ID.
147
- */
148
- static fromKeyIdentifier(id, publicKeyMultibase, service) {
149
- // Ensure the ID is in the correct format
150
- id = id.includes('#') ? id : `${id}#initialKey`;
151
- // Create the verification method and the DidDocument
152
- const document = {
153
- id,
154
- verificationMethod: [
155
- new DidVerificationMethod({
156
- id,
157
- type: 'Multikey',
158
- controller: id,
159
- publicKeyMultibase
160
- })
161
- ],
162
- service
163
- };
164
- return new DidDocument(document);
165
- }
166
- /**
167
- * Create a DidDocument from "x1" btcr2 identifier.
168
- * @param {ExternalData} data The verification methods of the DID Document.
169
- * @returns {DidDocument} A new DidDocument.
170
- */
171
- static fromExternalIdentifier(data) {
172
- return new DidDocument(data);
173
- }
174
- /**
175
- * Sanitize the DID Document by removing undefined values
176
- * @returns {DidDocument} The sanitized DID Document
177
- */
178
- static sanitize(doc) {
179
- for (const key of Object.keys(doc)) {
180
- if (doc[key] === undefined) {
181
- delete doc[key];
182
- }
183
- }
184
- return doc;
185
- }
186
- /**
187
- * Validates a DidDocument by breaking it into modular validation methods.
188
- * @param {DidDocument} didDocument The DID document to validate.
189
- * @returns {boolean} True if the DID document is valid.
190
- * @throws {DidDocumentError} If any validation check fails.
191
- */
192
- static isValid(didDocument) {
193
- if (!this.isValidContext(didDocument?.['@context'])) {
194
- throw new DidDocumentError('Invalid "@context"', INVALID_DID_DOCUMENT, didDocument);
195
- }
196
- if (!this.isValidId(didDocument?.id)) {
197
- throw new DidDocumentError('Invalid "id"', INVALID_DID_DOCUMENT, didDocument);
198
- }
199
- if (!this.isValidVerificationMethods(didDocument?.verificationMethod)) {
200
- throw new DidDocumentError('Invalid "verificationMethod"', INVALID_DID_DOCUMENT, didDocument);
201
- }
202
- if (!this.isValidServices(didDocument?.service)) {
203
- throw new DidDocumentError('Invalid "service"', INVALID_DID_DOCUMENT, didDocument);
204
- }
205
- if (!this.isValidVerificationRelationships(didDocument)) {
206
- throw new DidDocumentError('Invalid verification relationships', INVALID_DID_DOCUMENT, didDocument);
207
- }
208
- return true;
209
- }
210
- /**
211
- * Validates that "@context" exists and includes correct values.
212
- * @private
213
- * @param {DidDocument['@context']} context The context to validate.
214
- * @returns {boolean} True if the context is valid.
215
- */
216
- static isValidContext(context) {
217
- if (!context)
218
- return false;
219
- if (!Array.isArray(context))
220
- return false;
221
- if (!context.every(ctx => typeof ctx === 'string' && BTCR2_DID_DOCUMENT_CONTEXT.includes(ctx)))
222
- return false;
223
- return true;
224
- }
225
- /**
226
- * Validates that the DID Document has a valid id.
227
- * @private
228
- * @param {string} id The id to validate.
229
- * @returns {boolean} True if the id is valid.
230
- */
231
- static isValidId(id) {
232
- if (typeof id !== 'string')
233
- return false;
234
- try {
235
- Identifier.decode(id);
236
- return true;
237
- }
238
- catch {
239
- return false;
240
- }
241
- }
242
- /**
243
- * Validates that verification methods exist and are correctly formatted.
244
- * @private
245
- * @param {DidVerificationMethod[]} verificationMethod The verification methods to validate.
246
- * @returns {boolean} True if the verification methods are valid.
247
- */
248
- static isValidVerificationMethods(verificationMethod) {
249
- return Array.isArray(verificationMethod) && verificationMethod.every(Appendix.isDidVerificationMethod);
250
- }
251
- /**
252
- * Validates that the DID Document has valid services.
253
- * @private
254
- * @param {DidService[]} service The services to validate.
255
- * @returns {boolean} True if the services are valid.
256
- */
257
- static isValidServices(service) {
258
- return Array.isArray(service) && service.every(BeaconUtils.isBeaconService);
259
- }
260
- /**
261
- * Validates verification relationships (authentication, assertionMethod, capabilityInvocation, capabilityDelegation).
262
- * @private
263
- * @param {DidDocument} didDocument The DID Document to validate.
264
- * @returns {boolean} True if the verification relationships are valid.
265
- */
266
- static isValidVerificationRelationships(didDocument) {
267
- const possibleVerificationRelationships = [
268
- 'authentication',
269
- 'assertionMethod',
270
- 'capabilityInvocation',
271
- 'capabilityDelegation'
272
- ];
273
- const keys = Object.keys(didDocument);
274
- const availableKeys = possibleVerificationRelationships.filter(key => keys.includes(key));
275
- return availableKeys.every((key) => {
276
- const value = didDocument[key];
277
- return value &&
278
- Array.isArray(value) &&
279
- value.every((entry) => typeof entry === 'string' || Appendix.isDidVerificationMethod(entry));
280
- });
281
- }
282
- /**
283
- * Validate the DID Document
284
- * @returns {DidDocument} Validated DID Document.
285
- * @throws {DidDocumentError} If the DID Document is invalid.
286
- */
287
- static validate(didDocument) {
288
- // Validate the DID Document
289
- if (didDocument.id === ID_PLACEHOLDER_VALUE) {
290
- didDocument.validateGenesis();
291
- }
292
- else {
293
- DidDocument.isValid(didDocument);
294
- }
295
- // Return the DID Document
296
- return didDocument;
297
- }
298
- /**
299
- * Validate the GenesisDocument.
300
- * @returns {boolean} True if the GenesisDocument is valid.
301
- */
302
- validateGenesis() {
303
- // Validate the id
304
- if (this.id !== ID_PLACEHOLDER_VALUE) {
305
- throw new DidDocumentError('Invalid GenesisDocument ID', INVALID_DID_DOCUMENT, this);
306
- }
307
- // Validate the verificationMethod
308
- if (!this.verificationMethod.every(vm => vm.id.includes(ID_PLACEHOLDER_VALUE) && vm.controller === ID_PLACEHOLDER_VALUE)) {
309
- throw new DidDocumentError('Invalid GenesisDocument verificationMethod', INVALID_DID_DOCUMENT, this);
310
- }
311
- // Validate the service
312
- if (!this.service.every(svc => svc.id.includes(ID_PLACEHOLDER_VALUE))) {
313
- throw new DidDocumentError('Invalid GenesisDocument service', INVALID_DID_DOCUMENT, this);
314
- }
315
- if (!DidDocument.isValidVerificationRelationships(this)) {
316
- // Return true if all validations pass
317
- throw new DidDocumentError('Invalid GenesisDocument assertionMethod', INVALID_DID_DOCUMENT, this);
318
- }
319
- return true;
320
- }
321
- /**
322
- * Convert the DidDocument to an GenesisDocument.
323
- * @returns {GenesisDocument} The GenesisDocument representation of the DidDocument.
324
- */
325
- toIntermediate() {
326
- if (this.id.includes('k1')) {
327
- throw new DidDocumentError('Cannot convert a key identifier to an intermediate document', INVALID_DID_DOCUMENT, this);
328
- }
329
- return new GenesisDocument(this);
330
- }
331
- }
332
- export class Document {
333
- static isValid(didDocument) {
334
- return new DidDocument(didDocument).validateGenesis();
335
- }
336
- }
337
- /**
338
- * GenesisDocument extends the DidDocument class for creating and managing intermediate DID documents.
339
- * This class is used to create a minimal DID document with a placeholder ID.
340
- * It is used in the process of creating a new DID document.
341
- * @class GenesisDocument
342
- * @extends {DidDocument}
343
- */
344
- export class GenesisDocument extends DidDocument {
345
- constructor(document) {
346
- super(document);
347
- }
348
- /**
349
- * Convert the GenesisDocument to a DidDocument by replacing the placeholder value with the provided DID.
350
- * @param did The DID to replace the placeholder value in the document.
351
- * @returns {DidDocument} A new DidDocument with the placeholder value replaced by the provided DID.
352
- */
353
- toDidDocument(did) {
354
- const stringThis = JSON.stringify(this).replaceAll(ID_PLACEHOLDER_VALUE, did);
355
- const parseThis = JSON.parse(stringThis);
356
- return new DidDocument(parseThis);
357
- }
358
- /**
359
- * Create an GenesisDocument from a DidDocument by replacing the DID with a placeholder value.
360
- * @param {DidDocument} didDocument The DidDocument to convert.
361
- * @returns {GenesisDocument} The GenesisDocument representation of the DidDocument.
362
- */
363
- static fromDidDocument(didDocument) {
364
- const intermediateDocument = JSONUtils.cloneReplace(didDocument, DID_REGEX, ID_PLACEHOLDER_VALUE);
365
- return new GenesisDocument(intermediateDocument);
366
- }
367
- /**
368
- * Create a minimal GenesisDocument with a placeholder ID.
369
- * @param {Array<DidVerificationMethod>} verificationMethod The public key in multibase format.
370
- * @param {VerificationRelationships} relationships The public key in multibase format.
371
- * @param {Array<BeaconService>} service The service to be included in the document.
372
- * @returns {GenesisDocument} A new GenesisDocument with the placeholder ID.
373
- */
374
- static create(verificationMethod, relationships, service) {
375
- return new GenesisDocument({ id: ID_PLACEHOLDER_VALUE, ...relationships, verificationMethod, service, });
376
- }
377
- /**
378
- * Create a minimal GenesisDocument from a public key.
379
- * @param {KeyBytes} publicKey The public key in bytes format.
380
- * @returns {GenesisDocument} A new GenesisDocument with the placeholder ID.
381
- */
382
- static fromPublicKey(publicKey, network) {
383
- const pk = new CompressedSecp256k1PublicKey(publicKey);
384
- const id = ID_PLACEHOLDER_VALUE;
385
- const address = payments.p2pkh({ pubkey: pk.compressed, network: getNetwork(network) })?.address;
386
- const services = [{
387
- id: `${id}#service-0`,
388
- serviceEndpoint: `bitcoin:${address}`,
389
- type: 'SingletonBeacon',
390
- }];
391
- const relationships = {
392
- authentication: [`${id}#key-0`],
393
- assertionMethod: [`${id}#key-0`],
394
- capabilityInvocation: [`${id}#key-0`],
395
- capabilityDelegation: [`${id}#key-0`]
396
- };
397
- const verificationMethod = [
398
- {
399
- id: `${id}#key-0`,
400
- type: 'Multikey',
401
- controller: id,
402
- publicKeyMultibase: pk.multibase.encoded,
403
- }
404
- ];
405
- return GenesisDocument.create(verificationMethod, relationships, services);
406
- }
407
- /**
408
- * Taken an object, convert it to an IntermediateDocuemnt and then to a DidDocument.
409
- * @param {object | DidDocument} object The JSON object to convert.
410
- * @returns {DidDocument} The created DidDocument.
411
- */
412
- static fromJSON(object) {
413
- return new GenesisDocument(object);
414
- }
415
- /**
416
- * Convert a GenesisDocument to genesis bytes.
417
- * @param {GenesisDocument} genesisDocument The GenesisDocument to convert.
418
- * @returns {Bytes} The genesis bytes.
419
- */
420
- static toGenesisBytes(genesisDocument) {
421
- return hash(canonicalize(genesisDocument));
422
- }
423
- }
424
- //# sourceMappingURL=did-document.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"did-document.js","sourceRoot":"","sources":["../../../src/utils/did-document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,IAAI,EAEJ,eAAe,EACf,oBAAoB,EAEpB,SAAS,EAEV,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAElE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,gCAAgC;IAChC,8BAA8B;CAC/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