@did-btcr2/method 0.19.0 → 0.20.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 (119) hide show
  1. package/dist/browser.js +715 -1445
  2. package/dist/browser.mjs +715 -1445
  3. package/dist/cjs/core/beacon/beacon.js +25 -0
  4. package/dist/cjs/core/beacon/beacon.js.map +1 -0
  5. package/dist/cjs/core/beacon/cas-beacon.js +20 -36
  6. package/dist/cjs/core/beacon/cas-beacon.js.map +1 -1
  7. package/dist/cjs/core/beacon/error.js +4 -4
  8. package/dist/cjs/core/beacon/error.js.map +1 -1
  9. package/dist/cjs/core/beacon/factory.js +5 -7
  10. package/dist/cjs/core/beacon/factory.js.map +1 -1
  11. package/dist/cjs/core/beacon/interfaces.js +1 -31
  12. package/dist/cjs/core/beacon/interfaces.js.map +1 -1
  13. package/dist/cjs/core/beacon/signal-discovery.js +183 -0
  14. package/dist/cjs/core/beacon/signal-discovery.js.map +1 -0
  15. package/dist/cjs/core/beacon/singleton.js +54 -81
  16. package/dist/cjs/core/beacon/singleton.js.map +1 -1
  17. package/dist/cjs/core/beacon/smt-beacon.js +22 -39
  18. package/dist/cjs/core/beacon/smt-beacon.js.map +1 -1
  19. package/dist/cjs/core/beacon/utils.js +4 -9
  20. package/dist/cjs/core/beacon/utils.js.map +1 -1
  21. package/dist/cjs/core/resolve.js +87 -277
  22. package/dist/cjs/core/resolve.js.map +1 -1
  23. package/dist/cjs/core/update.js +62 -153
  24. package/dist/cjs/core/update.js.map +1 -1
  25. package/dist/cjs/did-btcr2.js +80 -75
  26. package/dist/cjs/did-btcr2.js.map +1 -1
  27. package/dist/cjs/index.js +3 -1
  28. package/dist/cjs/index.js.map +1 -1
  29. package/dist/cjs/utils/appendix.js +6 -15
  30. package/dist/cjs/utils/appendix.js.map +1 -1
  31. package/dist/cjs/utils/did-document-builder.js +5 -0
  32. package/dist/cjs/utils/did-document-builder.js.map +1 -1
  33. package/dist/cjs/utils/did-document.js +11 -14
  34. package/dist/cjs/utils/did-document.js.map +1 -1
  35. package/dist/esm/core/beacon/beacon.js +25 -0
  36. package/dist/esm/core/beacon/beacon.js.map +1 -0
  37. package/dist/esm/core/beacon/cas-beacon.js +20 -36
  38. package/dist/esm/core/beacon/cas-beacon.js.map +1 -1
  39. package/dist/esm/core/beacon/error.js +4 -4
  40. package/dist/esm/core/beacon/error.js.map +1 -1
  41. package/dist/esm/core/beacon/factory.js +5 -7
  42. package/dist/esm/core/beacon/factory.js.map +1 -1
  43. package/dist/esm/core/beacon/interfaces.js +1 -31
  44. package/dist/esm/core/beacon/interfaces.js.map +1 -1
  45. package/dist/esm/core/beacon/signal-discovery.js +183 -0
  46. package/dist/esm/core/beacon/signal-discovery.js.map +1 -0
  47. package/dist/esm/core/beacon/singleton.js +54 -81
  48. package/dist/esm/core/beacon/singleton.js.map +1 -1
  49. package/dist/esm/core/beacon/smt-beacon.js +22 -39
  50. package/dist/esm/core/beacon/smt-beacon.js.map +1 -1
  51. package/dist/esm/core/beacon/utils.js +4 -9
  52. package/dist/esm/core/beacon/utils.js.map +1 -1
  53. package/dist/esm/core/resolve.js +87 -277
  54. package/dist/esm/core/resolve.js.map +1 -1
  55. package/dist/esm/core/update.js +62 -153
  56. package/dist/esm/core/update.js.map +1 -1
  57. package/dist/esm/did-btcr2.js +80 -75
  58. package/dist/esm/did-btcr2.js.map +1 -1
  59. package/dist/esm/index.js +3 -1
  60. package/dist/esm/index.js.map +1 -1
  61. package/dist/esm/utils/appendix.js +6 -15
  62. package/dist/esm/utils/appendix.js.map +1 -1
  63. package/dist/esm/utils/did-document-builder.js +5 -0
  64. package/dist/esm/utils/did-document-builder.js.map +1 -1
  65. package/dist/esm/utils/did-document.js +11 -14
  66. package/dist/esm/utils/did-document.js.map +1 -1
  67. package/dist/types/core/beacon/beacon.d.ts +44 -0
  68. package/dist/types/core/beacon/beacon.d.ts.map +1 -0
  69. package/dist/types/core/beacon/cas-beacon.d.ts +19 -30
  70. package/dist/types/core/beacon/cas-beacon.d.ts.map +1 -1
  71. package/dist/types/core/beacon/error.d.ts +2 -2
  72. package/dist/types/core/beacon/error.d.ts.map +1 -1
  73. package/dist/types/core/beacon/factory.d.ts +4 -6
  74. package/dist/types/core/beacon/factory.d.ts.map +1 -1
  75. package/dist/types/core/beacon/interfaces.d.ts +7 -46
  76. package/dist/types/core/beacon/interfaces.d.ts.map +1 -1
  77. package/dist/types/core/beacon/signal-discovery.d.ts +25 -0
  78. package/dist/types/core/beacon/signal-discovery.d.ts.map +1 -0
  79. package/dist/types/core/beacon/singleton.d.ts +16 -29
  80. package/dist/types/core/beacon/singleton.d.ts.map +1 -1
  81. package/dist/types/core/beacon/smt-beacon.d.ts +21 -33
  82. package/dist/types/core/beacon/smt-beacon.d.ts.map +1 -1
  83. package/dist/types/core/beacon/utils.d.ts.map +1 -1
  84. package/dist/types/core/interfaces.d.ts +1 -8
  85. package/dist/types/core/interfaces.d.ts.map +1 -1
  86. package/dist/types/core/resolve.d.ts +27 -43
  87. package/dist/types/core/resolve.d.ts.map +1 -1
  88. package/dist/types/core/types.d.ts +21 -8
  89. package/dist/types/core/types.d.ts.map +1 -1
  90. package/dist/types/core/update.d.ts +30 -73
  91. package/dist/types/core/update.d.ts.map +1 -1
  92. package/dist/types/did-btcr2.d.ts +37 -44
  93. package/dist/types/did-btcr2.d.ts.map +1 -1
  94. package/dist/types/index.d.ts +3 -1
  95. package/dist/types/index.d.ts.map +1 -1
  96. package/dist/types/utils/appendix.d.ts.map +1 -1
  97. package/dist/types/utils/did-document-builder.d.ts +5 -0
  98. package/dist/types/utils/did-document-builder.d.ts.map +1 -1
  99. package/dist/types/utils/did-document.d.ts +16 -14
  100. package/dist/types/utils/did-document.d.ts.map +1 -1
  101. package/package.json +4 -4
  102. package/src/core/beacon/beacon.ts +58 -0
  103. package/src/core/beacon/cas-beacon.ts +30 -44
  104. package/src/core/beacon/error.ts +5 -6
  105. package/src/core/beacon/factory.ts +7 -9
  106. package/src/core/beacon/interfaces.ts +7 -64
  107. package/src/core/beacon/signal-discovery.ts +237 -0
  108. package/src/core/beacon/singleton.ts +74 -94
  109. package/src/core/beacon/smt-beacon.ts +32 -49
  110. package/src/core/beacon/utils.ts +16 -13
  111. package/src/core/interfaces.ts +1 -9
  112. package/src/core/resolve.ts +116 -360
  113. package/src/core/types.ts +25 -8
  114. package/src/core/update.ts +90 -235
  115. package/src/did-btcr2.ts +131 -95
  116. package/src/index.ts +8 -1
  117. package/src/utils/appendix.ts +8 -22
  118. package/src/utils/did-document-builder.ts +5 -0
  119. package/src/utils/did-document.ts +41 -45
@@ -1 +1 @@
1
- {"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../../src/core/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,EACb,UAAU,EAEV,qBAAqB,EACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,SAAS,EACT,aAAa,EACb,WAAW,EACX,oBAAoB,EACpB,kBAAkB,EAClB,SAAS,EACT,SAAS,EACT,qBAAqB,EACrB,WAAW,EACX,mBAAmB,EACnB,YAAY,EACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EAGxB,eAAe,EAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAiB,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAc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E,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,CAC9D,CAAC;QACJ,CAAC;QAED,iCAAiC;QACjC,OAAO,eAAe,CAAC;IACzB,CAAC;CACF"}
@@ -1,13 +1,10 @@
1
- import { INVALID_DID_DOCUMENT, INVALID_DID_UPDATE, INVALID_PUBLIC_KEY_TYPE, JSONPatch, MethodError, NOT_FOUND, UpdateError } from '@did-btcr2/common';
1
+ import { INVALID_DID_UPDATE, JSONPatch, UpdateError } from '@did-btcr2/common';
2
2
  import { SchnorrMultikey } from '@did-btcr2/cryptosuite';
3
- import { CompressedSecp256k1PublicKey, SchnorrKeyPair, Secp256k1SecretKey } from '@did-btcr2/keypair';
4
- import { Kms } from '@did-btcr2/kms';
5
3
  import { canonicalization } from '../did-btcr2.js';
6
- import { Appendix } from '../utils/appendix.js';
7
4
  import { DidDocument } from '../utils/did-document.js';
8
- import { Identifier } from './identifier.js';
5
+ import { BeaconFactory } from './beacon/factory.js';
9
6
  /**
10
- * Implements {@link https://dcdpr.github.io/did-btcr2/#update | 4.3 Update}.
7
+ * Implements {@link https://dcdpr.github.io/did-btcr2/operations/update.html | 7.3 Update}.
11
8
  *
12
9
  * An update to a did:btcr2 document is an invoked capability using the ZCAP-LD
13
10
  * data format, signed by a verificationMethod that has the authority to make
@@ -20,109 +17,62 @@ import { Identifier } from './identifier.js';
20
17
  */
21
18
  export class Update {
22
19
  /**
23
- * Implements {@link https://dcdpr.github.io/did-btcr2/#construct-did-update-payload | 4.3.1 Construct DID Update Payload}.
20
+ * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/update.html#construct-btcr2-unsigned-update | 7.3.b Construct BTCR2 Unsigned Update}.
21
+ * This process constructs a BTCR2 Unsigned Update conformant to the spec template.
24
22
  *
25
- * The Construct DID Update Payload algorithm applies the documentPatch to the sourceDocument and verifies the
26
- * resulting targetDocument is a conformant DID document. It takes in a Identifier, sourceDocument,
27
- * sourceVersionId, and documentPatch objects. It returns an unsigned DID Update Payload.
28
- *
29
- * @param {ConstructPayloadParams} params See {@link ConstructPayloadParams} for more details.
30
- * @param {string} params.identifier The did-btcr2 identifier to use for verification.
31
- * @param {DidDocument} params.sourceDocument The source document to be updated.
32
- * @param {string} params.sourceVersionId The versionId of the source document.
33
- * @param {DidDocumentPatch} params.patch The JSON patch to be applied to the source document.
34
- * @returns {Promise<BTCR2SignedUpdate>} The constructed BTCR2SignedUpdate object.
35
- * @throws {MethodError} InvalidDid if sourceDocument.id does not match identifier.
23
+ * @param {Btcr2DidDocument} sourceDocument The source DID document to be updated.
24
+ * @param {PatchOperation[]} patches The array of JSON Patch operations to apply to the sourceDocument.
25
+ * @param {number} sourceVersionId The version ID of the source document.
26
+ * @returns {Promise<SignedBTCR2Update>} The constructed SignedBTCR2Update object.
27
+ * @throws {UpdateError} InvalidDid if sourceDocument.id does not match identifier.
36
28
  */
37
- static async construct({ identifier, sourceDocument, sourceVersionId, patch, }) {
38
- // 1. Check that sourceDocument.id equals identifier else MUST raise invalidDIDUpdate error.
39
- if (sourceDocument.id !== identifier) {
40
- throw new UpdateError('Identifier mismatch: sourceDocument.id !== identifier', INVALID_DID_UPDATE, { sourceDocument, identifier });
41
- }
42
- // 2. Initialize an unsigned update.
29
+ static async construct(sourceDocument, patches, sourceVersionId) {
30
+ // Initialize an unsigned update conformant to btcr2 spec.
43
31
  const unsignedUpdate = {
44
- // 3. Set BTCR2SignedUpdate.@context to the following list
45
32
  '@context': [
46
33
  'https://w3id.org/security/v2',
47
34
  'https://w3id.org/zcap/v1',
48
35
  'https://w3id.org/json-ld-patch/v1',
49
36
  'https://btcr2.dev/context/v1'
50
37
  ],
51
- // 4. Set BTCR2SignedUpdate.patch to documentPatch.
52
- patch,
38
+ patch: patches,
53
39
  targetHash: '',
54
- targetVersionId: 0,
55
- sourceHash: '',
40
+ targetVersionId: sourceVersionId + 1,
41
+ sourceHash: canonicalization.process(sourceDocument, { encoding: 'base58' }),
56
42
  };
57
- // 5. Set targetDocument to the result of applying the documentPatch to the sourceDocument, following the JSON Patch
58
- // specification.
59
- const targetDocument = JSONPatch.apply(sourceDocument, patch);
60
- // 6. Validate targetDocument is a conformant DID document, else MUST raise invalidDIDUpdate error.
61
- DidDocument.validate(targetDocument);
62
- // 7. Set sourceHashBytes to the result of passing sourceDocument into the JSON Canonicalization and Hash algorithm.
63
- // 8. Set BTCR2SignedUpdate.sourceHash to the base58-btc Multibase encoding of sourceHashBytes.
64
- unsignedUpdate.sourceHash = (canonicalization.process(sourceDocument, { encoding: 'base58' })).slice(1);
65
- // TODO: Question - is base58btc the correct encoding scheme?
66
- // 9. Set targetHashBytes to the result of passing targetDocument into the JSON Canonicalization and Hash algorithm.
67
- // 10. Set BTCR2SignedUpdate.targetHash to the base58-btc Multibase encoding of targetHashBytes.
68
- unsignedUpdate.targetHash = (canonicalization.process(targetDocument, { encoding: 'base58' })).slice(1);
69
- // 11. Set BTCR2SignedUpdate.targetVersionId to sourceVersionId + 1.
70
- unsignedUpdate.targetVersionId = sourceVersionId + 1;
71
- // 12. Return updatePayload.
43
+ // Apply all JSON patches to sourceDocument.
44
+ const targetDocument = JSONPatch.apply(sourceDocument, patches);
45
+ try {
46
+ // Ensure the targetDocument is conformant to DID Core v1.1.
47
+ DidDocument.isValid(targetDocument);
48
+ }
49
+ catch (error) {
50
+ // If validation fails, throw an UpdateError with INVALID_DID_UPDATE.
51
+ throw new UpdateError('Error validating targetDocument: ' + (error instanceof Error ? error.message : String(error)), INVALID_DID_UPDATE, targetDocument);
52
+ }
53
+ // Set the targetHash by canonicalizing the targetDocument and encoding it in base58.
54
+ unsignedUpdate.targetHash = canonicalization.process(targetDocument, { encoding: 'base58' });
55
+ // Return unsignedUpdate.
72
56
  return unsignedUpdate;
73
57
  }
74
58
  /**
75
- * {@link https://dcdpr.github.io/did-btcr2/#invoke-did-update-payload | 4.3.2 Invoke DID Update Payload}.
59
+ * Implements subsection {@link http://dcdpr.github.io/did-btcr2/operations/update.html#construct-btcr2-signed-update | 7.3.c Construct BTCR2 Signed Update }.
60
+ * This process constructs a BTCR2 Signed Update from a BTCR2 Unsigned Update.
76
61
  *
77
- * The Invoke DID Update Payload algorithm takes in a Identifier, an unsigned BTCR2SignedUpdate, and a
78
- * verificationMethod. It retrieves the privateKeyBytes for the verificationMethod and adds a capability invocation in
79
- * the form of a Data Integrity proof following the Authorization Capabilities (ZCAP-LD) and VC Data Integrity
80
- * specifications. It returns the invoked DID Update Payload.
81
- *
82
- * @param {InvokePayloadParams} params Required params for calling the invokePayload method
83
- * @param {string} params.identifier The did-btcr2 identifier to derive the root capability from
84
- * @param {BTCR2SignedUpdate} params.BTCR2SignedUpdate The updatePayload object to be signed
85
- * @param {DidVerificationMethod} params.verificationMethod The verificationMethod object to be used for signing
86
- * @returns {BTCR2SignedUpdate} Did update payload secured with a proof => BTCR2SignedUpdate
87
- * @throws {MethodError} if the privateKeyBytes are invalid
62
+ * @param {string} did The did-btcr2 identifier to derive the root capability from
63
+ * @param {UnsignedBTCR2Update} unsignedUpdate The updatePayload object to be signed
64
+ * @param {DidVerificationMethod} verificationMethod The verificationMethod object to be used for signing
65
+ * @returns {SignedBTCR2Update} Did update payload secured with a proof => SignedBTCR2Update
66
+ * @throws {UpdateError} if the privateKeyBytes are invalid
88
67
  */
89
- static async invoke({ identifier, unsignedUpdate, verificationMethod }) {
90
- // Deconstruct the verificationMethod
91
- const { id: fullId, controller, publicKeyMultibase, secretKeyMultibase } = verificationMethod;
92
- // Validate the verificationMethod
93
- if (!publicKeyMultibase) {
94
- throw new MethodError('Invalid publicKeyMultibase: cannot be undefined', INVALID_PUBLIC_KEY_TYPE, verificationMethod);
95
- }
96
- // 1. Set privateKeyBytes to the result of retrieving the private key bytes
97
- // associated with the verificationMethod value.
98
- // 1.1 Let id be the fragment portion of verificationMethod.id.
99
- const id = fullId.slice(fullId.indexOf('#'));
100
- // 1.2 Retrieve the key pair from the KMS or from the secretKeyMultibase
101
- const components = Identifier.decode(id);
102
- const keyUri = new CompressedSecp256k1PublicKey(components.genesisBytes).hex;
103
- const keys = secretKeyMultibase
104
- ? new SchnorrKeyPair({ secretKey: Secp256k1SecretKey.decode(secretKeyMultibase) })
105
- : Kms.getKey(keyUri);
106
- if (!keys) {
107
- throw new MethodError('No privateKey found in kms or vm', NOT_FOUND, verificationMethod);
108
- }
109
- // 1.3 Set multikey to the result of passing verificationMethod and privateKeyBytes into the Multikey Creation algorithm.
110
- const multikey = SchnorrMultikey.create({ id, controller, keys });
111
- // 1.4 If the privateKey is not found, throw an error
112
- if (!multikey) {
113
- throw new MethodError('Failed to create multikey from verification method', 'MULTKEY_CREATE_FAILED', verificationMethod);
114
- }
115
- // 2. Set rootCapability to the result of passing Identifier into the Derive Root Capability from did:btcr2
116
- // Identifier algorithm.
117
- const rootCapability = Appendix.deriveRootCapability(identifier);
118
- const cryptosuite = 'bip340-jcs-2025';
119
- // 3. Initialize proofOptions to an empty object.
120
- // 4. Set proofOptions.type to DataIntegrityProof.
121
- // 5. Set proofOptions.cryptosuite to schnorr-secp256k1-jcs-2025.
122
- // 6. Set proofOptions.verificationMethod to verificationMethod.id.
123
- // 7. Set proofOptions.proofPurpose to capabilityInvocation.
124
- // 8. Set proofOptions.capability to rootCapability.id.
125
- // 9. Set proofOptions.capabilityAction to Write.
68
+ static async sign(did, unsignedUpdate, verificationMethod, secretKey) {
69
+ // Parse the controller from the verificationMethod
70
+ const controller = verificationMethod.controller;
71
+ // Parse the fragment from the vmId
72
+ const id = verificationMethod.id.slice(verificationMethod.id.indexOf('#'));
73
+ // Construct a Schnorr Multikey
74
+ const multikey = SchnorrMultikey.fromSecretKey(id, controller, secretKey);
75
+ // Define the Data Integrity proof config
126
76
  const config = {
127
77
  '@context': [
128
78
  'https://w3id.org/security/v2',
@@ -130,75 +80,34 @@ export class Update {
130
80
  'https://w3id.org/json-ld-patch/v1',
131
81
  'https://btcr2.dev/context/v1'
132
82
  ],
133
- cryptosuite,
83
+ cryptosuite: 'bip340-jcs-2025',
134
84
  type: 'DataIntegrityProof',
135
- verificationMethod: fullId,
85
+ verificationMethod: verificationMethod.id,
136
86
  proofPurpose: 'capabilityInvocation',
137
- capability: rootCapability.id,
87
+ capability: `urn:zcap:root:${encodeURIComponent(did)}`,
138
88
  capabilityAction: 'Write',
139
89
  };
140
- // 10. Set cryptosuite to the result of executing the Cryptosuite Instantiation algorithm from the BIP340 Data
141
- // Integrity specification passing in proofOptions.
90
+ // Go from multikey => cryptosuite => diproof
142
91
  const diproof = multikey.toCryptosuite().toDataIntegrityProof();
143
- // 12. Set BTCR2SignedUpdate to the result of executing the Add Proof algorithm from VC Data Integrity passing
144
- // BTCR2SignedUpdate as the input document, cryptosuite, and the set of proofOptions.
145
- // 13. Return BTCR2SignedUpdate.
146
- return await diproof.addProof(unsignedUpdate, config);
92
+ // Use the config to add a proof to the unsigned update
93
+ return diproof.addProof(unsignedUpdate, config);
147
94
  }
148
95
  /**
149
- * Implements {@link https://dcdpr.github.io/did-btcr2/#announce-did-update | 4.3.3 Announce DID Update}.
150
- *
151
- * The Announce DID Update algorithm retrieves beaconServices from the sourceDocument and calls the Broadcast DID
152
- * Update algorithm corresponding to the type of the Beacon. It takes in a Identifier, sourceDocument, an array of
153
- * beaconIds, and a BTCR2SignedUpdate. It returns an array of signalsMetadata, containing the necessary
154
- * data to validate the Beacon Signal against the BTCR2SignedUpdate.
155
- *
156
- * @param {AnnounceUpdatePayloadParams} params Required params for calling the announcePayload method
157
- * @param {DidDocument} params.sourceDocument The did-btcr2 did document to derive the root capability from
158
- * @param {string[]} params.beaconIds The BTCR2SignedUpdate object to be signed
159
- * @param {BTCR2SignedUpdate} params.BTCR2SignedUpdate The verificationMethod object to be used for signing
160
- * @returns {BTCR2SignedUpdate} The BTCR2SignedUpdate object containing data to validate the Beacon Signal
161
- * @throws {MethodError} if the beaconService type is invalid
96
+ * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/update.html#announce-did-update | 7.3.d Announce DID Update}.
97
+ * BTCR2 Signed Updates are announced to the Bitcoin blockchain depending on the Beacon Type.
98
+ * @param {BeaconService} beaconService The BeaconService object representing the funded beacon to announce the update to.
99
+ * @param {SignedBTCR2Update} update The signed update object to be announced.
100
+ * @param {KeyBytes} secretKey The private key used to sign the update for announcement.
101
+ * @returns {SignedBTCR2Update} The SignedBTCR2Update object containing data to validate the Beacon Signal
102
+ * @throws {UpdateError} if the beaconService type is invalid
162
103
  */
163
- static async announce({ sourceDocument, beaconIds, signedUpdate }) {
164
- // 1. Set beaconServices to an empty array.
165
- const beaconServices = [];
166
- // 2. sidecarData to an empty array.
167
- let sidecarData;
168
- // 3. For beaconId in beaconIds:
169
- for (const beaconId of beaconIds) {
170
- // 3.1 Find the beacon services in the sourceDocument
171
- const beaconService = sourceDocument.service.find((s) => s.id === beaconId);
172
- // 3.2 If no beaconService MUST throw beaconNotFound error.
173
- if (!beaconService) {
174
- throw new MethodError('Not found: sourceDocument does not contain beaconId', INVALID_DID_DOCUMENT, { beaconId });
175
- }
176
- // 3.3 Push beaconService to beaconServices.
177
- beaconServices.push(beaconService);
178
- }
179
- // 4. For beaconService in beaconServices:
180
- for (const beaconService of beaconServices) {
181
- // 4.1 Set signalMetadata to null.
182
- // 4.2 If beaconService.type == SingletonBeacon:
183
- // 4.2.1 Set signalMetadata to the result of passing beaconService and BTCR2SignedUpdate to the Broadcast
184
- // Singleton Beacon Signal algorithm.
185
- // 4.3 Else If beaconService.type == CASBeacon:
186
- // 4.3.1 Set signalMetadata to the result of passing Identifier, beaconService and BTCR2SignedUpdate to
187
- // the Broadcast CIDAggregate Beacon Signal algorithm.
188
- // 4.4 Else If beaconService.type == SMTBeacon:
189
- // 4.4.1 Set signalMetadata to the result of passing Identifier, beaconService and BTCR2SignedUpdate to
190
- // the Broadcast SMTAggregate Beacon Signal algorithm.
191
- // 4.5 Else:
192
- // 4.5.1 MUST throw invalidBeacon error.
193
- // const beacon = BeaconFactory.establish(beaconService);
194
- // sidecarData = await beacon.broadcastSignal(signedUpdate);
195
- console.log('TODO: refactor this code', signedUpdate, beaconService);
196
- }
197
- if (!sidecarData) {
198
- throw new MethodError('Invalid beacon: no sidecarData found', INVALID_DID_DOCUMENT, { beaconServices });
199
- }
104
+ static async announce(beaconService, update, secretKey, bitcoin) {
105
+ // Establish a beacon object
106
+ const beacon = BeaconFactory.establish(beaconService);
107
+ // Broadcast the update
108
+ const result = await beacon.broadcastSignal(update, secretKey, bitcoin);
200
109
  // Return the sidecarData
201
- return sidecarData;
110
+ return result;
202
111
  }
203
112
  }
204
113
  //# sourceMappingURL=update.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/core/update.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,uBAAuB,EACvB,SAAS,EACT,WAAW,EACX,SAAS,EAET,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAA+D,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACtH,OAAO,EAAE,4BAA4B,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACtG,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAErC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAyB,MAAM,0BAA0B,CAAC;AAE9E,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAqB7C;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,MAAM;IACjB;;;;;;;;;;;;;;OAcG;IACI,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,EAC5B,UAAU,EACV,cAAc,EACd,eAAe,EACf,KAAK,GAMN;QAEC,4FAA4F;QAC5F,IAAI,cAAc,CAAC,EAAE,KAAK,UAAU,EAAE,CAAC;YACrC,MAAM,IAAI,WAAW,CACnB,uDAAuD,EACvD,kBAAkB,EAAE,EAAE,cAAc,EAAE,UAAU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BACnC,8BAA8B;aAC/B;YACD,WAAW,EAAU,iBAAiB;YACtC,IAAI,EAAiB,oBAAoB;YACzC,kBAAkB,EAAG,kBAAkB,CAAC,EAAE;YAC1C,YAAY,EAAS,sBAAsB;YAC3C,UAAU,EAAW,iBAAiB,kBAAkB,CAAC,GAAG,CAAC,EAAE;YAC/D,gBAAgB,EAAK,OAAO;SAC7B,CAAC;QAEF,6CAA6C;QAC7C,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,EAAE,CAAC,oBAAoB,EAAE,CAAC;QAEhE,uDAAuD;QACvD,OAAO,OAAO,CAAC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;IAClD,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,KAAK,CAAC,QAAQ,CACnB,aAA4B,EAC5B,MAAyB,EACzB,SAAmB,EACnB,OAAiC;QAEjC,4BAA4B;QAC5B,MAAM,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;QAEtD,uBAAuB;QACvB,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QAExE,yBAAyB;QACzB,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
@@ -1,5 +1,5 @@
1
1
  import { BitcoinNetworkConnection } from '@did-btcr2/bitcoin';
2
- import { Canonicalization, IdentifierHrp, INVALID_DID_DOCUMENT, METHOD_NOT_SUPPORTED, MethodError, MISSING_UPDATE_DATA, ResolveError } from '@did-btcr2/common';
2
+ import { Canonicalization, IdentifierHrp, INVALID_DID_DOCUMENT, INVALID_DID_UPDATE, METHOD_NOT_SUPPORTED, MethodError, MISSING_UPDATE_DATA, ResolveError, UpdateError } from '@did-btcr2/common';
3
3
  import { Did, DidError, DidErrorCode, EMPTY_DID_RESOLUTION_RESULT } from '@web5/dids';
4
4
  import { initEccLib } from 'bitcoinjs-lib';
5
5
  import * as tinysecp from 'tiny-secp256k1';
@@ -8,9 +8,9 @@ import { Identifier } from './core/identifier.js';
8
8
  import { Resolve } from './core/resolve.js';
9
9
  import { Update } from './core/update.js';
10
10
  import { Appendix } from './utils/appendix.js';
11
- // TODO: convert to API driver
11
+ // TODO: convert to API driver?
12
12
  export const canonicalization = new Canonicalization();
13
- // TODO: convert to API driver
13
+ // TODO: convert to API driver?
14
14
  /** Initialize tiny secp256k1 */
15
15
  initEccLib(tinysecp);
16
16
  /**
@@ -27,7 +27,9 @@ initEccLib(tinysecp);
27
27
  * @implements {DidMethod}
28
28
  */
29
29
  export class DidBtcr2 {
30
- /** @type {string} Name of the DID method, as defined in the DID BTCR2 specification */
30
+ /**
31
+ * Name of the DID method, as defined in the DID BTCR2 specification
32
+ */
31
33
  static methodName = 'btcr2';
32
34
  /**
33
35
  * Implements section {@link https://dcdpr.github.io/did-btcr2/operations/create.html | 7.1 Create}.
@@ -50,7 +52,7 @@ export class DidBtcr2 {
50
52
  return Identifier.encode({ idType, genesisBytes, version, network });
51
53
  }
52
54
  /**
53
- * Entry point for section {@link https://dcdpr.github.io/did-btcr2/#read | 7.2 Resolve}.
55
+ * Entry point for section {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html | 7.2 Resolve}.
54
56
  * See specification for the {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#process | Resolve Process}.
55
57
  * See {@link Resolve | Resolve (class)} for class implementation.
56
58
  *
@@ -59,14 +61,10 @@ export class DidBtcr2 {
59
61
  * blockchain by Authorized Beacon Signals. The Initial DID Document is either
60
62
  * deterministically created from the DID or provided by Sidecar Data.
61
63
  *
62
- * @param {string} did a valid did:btcr2 identifier to be resolved
63
- * @param {ResolutionOptions} resolutionOptions see {@link https://www.w3.org/TR/did-1.0/#did-resolution-options | ResolutionOptions}
64
- * @param {number} resolutionOptions.versionId optional version of the identifier and/or DID document
65
- * @param {number} resolutionOptions.versionTime optional timestamp used during resolution as a bound for when to stop resolving
66
- * @param {DidDocument} resolutionOptions.sidecar optional data necessary for resolving a DID
64
+ * @param {string} did The did:btcr2 identifier to be resolved.
65
+ * @param {ResolutionOptions} resolutionOptions Options used during the resolution process.
67
66
  * @returns {Promise<DidResolutionResult>} Promise resolving to a DID Resolution Result containing the `targetDocument`
68
- * @throws {Error} if the resolution fails for any reason
69
- * @throws {DidError} InvalidDid if the identifier is invalid
67
+ * @throws {ResolveError} If the resolution process fails at any step.
70
68
  * @example
71
69
  * ```ts
72
70
  * const resolution = await DidBtcr2.resolve(
@@ -91,9 +89,12 @@ export class DidBtcr2 {
91
89
  // Decode the did to be resolved
92
90
  const didComponents = Identifier.decode(did);
93
91
  // Process sidecar if provided
94
- const sidecarData = Resolve.processSidecarData(resolutionOptions.sidecar);
95
- // Establish a connection to a bitcoin network
96
- if (!resolutionOptions.drivers.bitcoin) {
92
+ const sidecarData = Resolve.sidecarData(resolutionOptions.sidecar);
93
+ // Check if bitcoin driver provided
94
+ if (!resolutionOptions?.drivers?.bitcoin) {
95
+ // If not, initialize default drivers
96
+ resolutionOptions.drivers = resolutionOptions.drivers || {};
97
+ // Set bitcoin driver to default BitcoinNetworkConnection
97
98
  resolutionOptions.drivers.bitcoin = new BitcoinNetworkConnection();
98
99
  // Set the network based on the decoded identifier
99
100
  resolutionOptions.drivers.bitcoin.setActiveNetwork(didComponents.network);
@@ -107,13 +108,15 @@ export class DidBtcr2 {
107
108
  throw new ResolveError('External resolution requires genesisDocument', MISSING_UPDATE_DATA, { resolutionOptions });
108
109
  }
109
110
  // Establish the current document
110
- const currentDocument = await Resolve.establishCurrentDocument(didComponents, genesisDocument);
111
+ const currentDocument = await Resolve.currentDocument(didComponents, genesisDocument);
111
112
  // Extract all Beacon services from the current DID Document
112
113
  const beaconServices = currentDocument.service
113
114
  .filter(BeaconUtils.isBeaconService)
114
115
  .map(BeaconUtils.parseBeaconServiceEndpoint);
116
+ console.log('beaconServices', beaconServices);
115
117
  // Process the Beacon Signals to get the required updates
116
- const unsortedUpdates = await Resolve.processBeaconSignals(beaconServices, sidecarData, resolutionOptions.drivers.bitcoin, resolutionOptions.fullBlockchainTraversal);
118
+ const unsortedUpdates = await Resolve.beaconSignals(beaconServices, sidecarData, resolutionOptions.drivers.bitcoin);
119
+ console.log('unsortedUpdates', unsortedUpdates);
117
120
  // If no updates found, return the current document
118
121
  if (!unsortedUpdates.length) {
119
122
  // Set the current document in the didResolutionResult
@@ -124,7 +127,7 @@ export class DidBtcr2 {
124
127
  return didResolutionResult;
125
128
  }
126
129
  // Process the updates to apply updates to bring the current DID Document to its more current state
127
- const result = await Resolve.processUpdatesArray(currentDocument, unsortedUpdates, resolutionOptions.versionTime, resolutionOptions.versionId);
130
+ const result = await Resolve.updates(currentDocument, unsortedUpdates, resolutionOptions.versionTime, resolutionOptions.versionId);
128
131
  // Set all of the required fields in the didResolutionResult
129
132
  didResolutionResult.didDocument = result.currentDocument;
130
133
  didResolutionResult.didDocumentMetadata.confirmations = result.confirmations;
@@ -149,77 +152,79 @@ export class DidBtcr2 {
149
152
  }
150
153
  }
151
154
  /**
152
- * Entry point for section {@link https://dcdpr.github.io/did-btcr2/#update | 4.3 Update}.
153
- * See {@link Update} for implementation details.
154
- *
155
- * An update to a did:btcr2 document is an invoked capability using the ZCAP-LD data format, signed by a
156
- * verificationMethod that has the authority to make the update as specified in the previous DID document. Capability
157
- * invocations for updates MUST be authorized using Data Integrity following the bip340-jcs-2025
158
- * cryptosuite with a proofPurpose of capabilityInvocation.
159
- *
160
- * The Update algorithm takes as inputs a Identifier, sourceDocument, sourceVersionId, documentPatch, a
161
- * verificationMethodId and an array of beaconIds. The sourceDocument is the DID document being updated. The
162
- * documentPatch is a JSON Patch object containing a set of transformations to be applied to the sourceDocument.
163
- * The result of these transformations MUST produce a DID document conformant to the DID Core specification. The
164
- * verificationMethodId is an identifier for a verificationMethod within the sourceDocument. The verificationMethod
165
- * identified MUST be a BIP340 Multikey. The beaconIds MUST identify service endpoints with one of the three Beacon
166
- * Types SingletonBeacon, CASBeacon, and SMTBeacon.
155
+ * Entry point for section {@link https://dcdpr.github.io/did-btcr2/#read | 7.3 Update}.
156
+ * See specification for the {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#process | Resolve Process}.
157
+ * See {@link Update | Update (class)} for class implementation.
167
158
  *
168
- * @param {UpdateParams} params Required parameters for the update operation.
169
- * @param {string} params.identifier The btcr2 identifier to be updated.
170
- * @param {DidDocument} params.sourceDocument The DID document being updated.
171
- * @param {string} params.sourceVersionId The versionId of the source document.
172
- * @param {PatchOperation} params.documentPatch The JSON patch to be applied to the source document.
173
- * @param {string} params.verificationMethodId The verificationMethod ID to sign the update
174
- * @param {string[]} params.beaconIds The beacon IDs to announce the update
175
- * @returns {Promise<void>} Promise resolving to void
176
- * @throws {MethodError} if the verificationMethod type is not `Multikey` or the publicKeyMultibase header is not `zQ3s`
159
+ * BTCR2 DID documents can be updated by anchoring BTCR2 Updates to Bitcoin transactions. These transactions MAY be
160
+ * published to the Bitcoin network. Any property in the DID document may be updated except the id. Doing so would
161
+ * invalidate the DID document.
162
+ * @param params An object containing the parameters for the update operation.
163
+ * @param {Btcr2DidDocument} params.sourceDocument The DID document being updated.
164
+ * @param {PatchOperation[]} params.patches The array of JSON Patch operations to apply to the sourceDocument.
165
+ * @param {string} params.sourceVersionId The version ID before applying the update.
166
+ * @param {string} params.verificationMethodId The verificationMethod ID to sign the update with.
167
+ * @param {string} params.beaconId The beacon ID associated with the update.
168
+ * @param {KeyBytes | HexString} [params.signingMaterial] Optional signing material (key bytes or hex string).
169
+ * @param {BitcoinNetworkConnection} [params.bitcoin] Optional Bitcoin network connection for announcing the update. If not provided, a default connection will be initialized.
170
+ * @return {Promise<SignedBTCR2Update>} Promise resolving to the signed BTCR2 update.
171
+ * @throws {UpdateError} if no verificationMethod, verificationMethod type is not `Multikey` or the publicKeyMultibase
172
+ * header is not `zQ3s`
177
173
  */
178
- static async update(params) {
179
- // Deconstruct the params
180
- const { identifier, sourceDocument, sourceVersionId, patch, verificationMethodId: methodId, beaconIds, } = params;
181
- // 1. Set unsignedUpdate to the result of passing Identifier, sourceDocument,
182
- // sourceVersionId, and documentPatch into the Construct DID Update
183
- // Payload algorithm.
184
- const unsignedUpdate = await Update.construct({
185
- identifier,
186
- sourceDocument,
187
- sourceVersionId,
188
- patch,
189
- });
190
- // 2. Set verificationMethod to the result of retrieving the verificationMethod
191
- // from sourceDocument using the verificationMethodId.
192
- const verificationMethod = this.getSigningMethod(sourceDocument, methodId);
174
+ static async update({ sourceDocument, patches, sourceVersionId, verificationMethodId, beaconId, signingMaterial, bitcoin, }) {
175
+ // TODO: provide KMS as alternative
176
+ // If no signingMaterial provided, throw an UpdateError with INVALID_DID_UPDATE.
177
+ if (!signingMaterial) {
178
+ throw new UpdateError('Missing signing material for update', INVALID_DID_UPDATE, { signingMaterial });
179
+ }
180
+ // Convert signingMaterial to bytes if it's a hex string
181
+ const secretKey = typeof signingMaterial === 'string'
182
+ ? Buffer.from(signingMaterial, 'hex')
183
+ : signingMaterial;
184
+ // Validate that the verificationMethodId is authorized for capabilityInvocation
185
+ if (!sourceDocument.capabilityInvocation?.some(vr => vr === verificationMethodId)) {
186
+ throw new UpdateError('Invalid verificationMethodId: not authorized for capabilityInvocation', INVALID_DID_DOCUMENT, sourceDocument);
187
+ }
188
+ // Get the verification method to be used for signing the update
189
+ const verificationMethod = this.getSigningMethod(sourceDocument, verificationMethodId);
193
190
  // Validate the verificationMethod exists in the sourceDocument
194
191
  if (!verificationMethod) {
195
- throw new MethodError('Verification method not found in did document', INVALID_DID_DOCUMENT, sourceDocument);
192
+ throw new UpdateError('Invalid verificationMethod: not found in source document', INVALID_DID_DOCUMENT, { sourceDocument, verificationMethodId });
196
193
  }
197
- // 3. Validate the verificationMethod is a BIP340 Multikey:
198
- // 3.1 verificationMethod.type == Multikey
194
+ // Validate the verificationMethod is of type 'Multikey'
199
195
  if (verificationMethod.type !== 'Multikey') {
200
- throw new MethodError('Invalid type: must be type "Multikey"', INVALID_DID_DOCUMENT, verificationMethod);
196
+ throw new UpdateError('Invalid verificationMethod: verificationMethod.type must be "Multikey"', INVALID_DID_DOCUMENT, verificationMethod);
197
+ }
198
+ // Validate the publicKeyMultibase prefix is 'zQ3s'
199
+ if (verificationMethod.publicKeyMultibase?.slice(0, 4) !== 'zQ3s') {
200
+ throw new UpdateError('Invalid verificationMethodId: publicKeyMultibase prefix must start with "zQ3s"', INVALID_DID_DOCUMENT, verificationMethod);
201
201
  }
202
- // 3.2 verificationMethod.publicKeyMultibase[4] == zQ3s
203
- const mbasePrefix = verificationMethod.publicKeyMultibase?.slice(0, 4);
204
- if (mbasePrefix !== 'zQ3s') {
205
- throw new MethodError(`Invalid publicKeyMultibase prefix ${mbasePrefix}`, INVALID_DID_DOCUMENT, verificationMethod);
202
+ // Construct an unsigned update following the BTCR2 Update construction algorithm
203
+ const update = await Update.construct(sourceDocument, patches, sourceVersionId);
204
+ // Sign the unsigned update using the specified verification method
205
+ const signed = await Update.sign(sourceDocument.id, update, verificationMethod, secretKey);
206
+ // Filter sourceDocument services to get beaconServices matching beaconIds
207
+ const beaconService = sourceDocument.service
208
+ .filter((service) => service.id === beaconId)
209
+ .filter((service) => !!service)
210
+ .shift();
211
+ // If no matching beacon service found, throw an UpdateError with INVALID_DID_UPDATE.
212
+ if (!beaconService) {
213
+ throw new UpdateError('No beacon service found for provided beaconId', INVALID_DID_UPDATE, { sourceDocument, beaconId });
206
214
  }
207
- // 4. Set didUpdateInvocation to the result of passing Identifier, unsignedUpdate as didUpdatePayload, and
208
- // verificationMethod to the Invoke DID Update Payload algorithm.
209
- const signedUpdate = await Update.invoke({ identifier, verificationMethod, unsignedUpdate });
210
- // 5. Set signalsMetadata to the result of passing Identifier, sourceDocument, beaconIds and didUpdateInvocation
211
- // to the Announce DID Update algorithm.
212
- const signalsMetadata = await Update.announce({ sourceDocument, beaconIds, signedUpdate });
213
- // 6. Return signalsMetadata. It is up to implementations to ensure that the signalsMetadata is persisted.
214
- return signalsMetadata;
215
- // TODO: Should we be applying the patch, producing a target did document and returning it?
215
+ // If no bitcoin network connection provided, initialize default
216
+ bitcoin ??= new BitcoinNetworkConnection();
217
+ // Announce the signed update to the blockchain using the specified beacon(s)
218
+ // await Update.announce(beaconService, signed, secretKey, bitcoin);
219
+ // Return signed update if announced successfully
220
+ return signed;
216
221
  }
217
222
  /**
218
223
  * Given the W3C DID Document of a `did:btcr2` identifier, return the signing verification method that will be used
219
224
  * for signing messages and credentials. If given, the `methodId` parameter is used to select the
220
225
  * verification method. If not given, the Identity Key's verification method with an ID fragment
221
226
  * of '#initialKey' is used.
222
- * @param {DidDocument} didDocument The DID Document of the `did:btcr2` identifier.
227
+ * @param {Btcr2DidDocument} didDocument The DID Document of the `did:btcr2` identifier.
223
228
  * @param {string} [methodId] Optional verification method ID to be used for signing.
224
229
  * @returns {DidVerificationMethod} Promise resolving to the {@link DidVerificationMethod} object used for signing.
225
230
  * @throws {DidError} if the parsed did method does not match `btcr2` or signing method could not be determined.