@did-btcr2/method 0.63.0 → 0.65.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.
@@ -1,5 +1,6 @@
1
1
  import { IdentifierHrp, INVALID_DID_DOCUMENT, INVALID_DID_UPDATE, METHOD_NOT_SUPPORTED, MethodError, UpdateError } from '@did-btcr2/common';
2
2
  import { Did, DidError, DidErrorCode } from '@web5/dids';
3
+ import { DEACTIVATION_PATCH } from './core/btcr2-update.js';
3
4
  import { Identifier } from './core/identifier.js';
4
5
  import { Resolver } from './core/resolver.js';
5
6
  import { Updater } from './core/updater.js';
@@ -108,26 +109,34 @@ export class DidBtcr2 {
108
109
  * @param {string} params.verificationMethodId The verification method ID to sign with.
109
110
  * @param {string} params.beaconId The beacon service ID to broadcast through.
110
111
  * @returns {Updater} A sans-I/O state machine for driving the update.
111
- * @throws {UpdateError} If the verification method is not authorized, not found,
112
- * not of type `Multikey`, or does not have a `zQ3s` publicKeyMultibase prefix.
113
- * Also throws if the beacon service is not found.
112
+ * @throws {UpdateError} `INVALID_DID_UPDATE` if `sourceVersionId` is not an integer of at
113
+ * least 1, if no entry of `capabilityInvocation` identifies the verification method, if a
114
+ * reference entry names no member of `verificationMethod`, or if the beacon service is not
115
+ * found. `INVALID_DID_DOCUMENT` if the method is not of type `Multikey` or does not have a
116
+ * `zQ3s` publicKeyMultibase prefix.
114
117
  */
115
118
  static update({ sourceDocument, patches, sourceVersionId, verificationMethodId, beaconId, }) {
116
- // Validate that the verificationMethodId is authorized for capabilityInvocation.
117
- // Both sides are resolved to absolute DID URLs first, so the caller's spelling of the
118
- // reference and the document's spelling of the entry may differ: either is legal per
119
- // DID Core. This is the same rule the read path applies to an update's proof, so an
120
- // update this factory authorizes is one the resolver will also accept.
121
- const authorizedMethodId = Appendix.relationshipMethodId(verificationMethodId, sourceDocument.id);
122
- const authorized = authorizedMethodId !== undefined && sourceDocument.capabilityInvocation?.some(entry => Appendix.relationshipMethodId(entry, sourceDocument.id) === authorizedMethodId);
123
- if (!authorized) {
124
- throw new UpdateError('Invalid verificationMethodId: not authorized for capabilityInvocation', INVALID_DID_DOCUMENT, sourceDocument);
119
+ // The version of the source document is a positive integer: versionId starts at 1, and
120
+ // targetVersionId is sourceVersionId + 1. Without the guard, Number(undefined) + 1 is
121
+ // NaN, and the update carries no usable version.
122
+ if (!Number.isInteger(sourceVersionId) || sourceVersionId < 1) {
123
+ throw new UpdateError(`Invalid sourceVersionId: expected an integer of at least 1, got ${String(sourceVersionId)}.`, INVALID_DID_UPDATE, { sourceVersionId });
125
124
  }
126
- // Get the verification method to be used for signing the update
127
- const verificationMethod = this.getSigningMethod(sourceDocument, verificationMethodId);
128
- // Validate the verificationMethod exists in the sourceDocument
125
+ // Spec "Construct BTCR2 Signed Update": an entry of capabilityInvocation must identify
126
+ // the verificationMethodId, in the reference form or the embedded form. Both sides are
127
+ // resolved to absolute DID URLs first, so the caller's spelling of the reference and the
128
+ // document's spelling of the entry may differ: either is legal per DID Core. This is the
129
+ // same rule the read path applies to an update's proof, so an update this factory
130
+ // authorizes is one the resolver will also accept.
131
+ const entry = Appendix.capabilityInvocationEntry(sourceDocument, verificationMethodId);
132
+ if (entry === undefined) {
133
+ throw new UpdateError('Invalid verificationMethodId: not authorized for capabilityInvocation', INVALID_DID_UPDATE, { verificationMethodId, capabilityInvocation: sourceDocument.capabilityInvocation });
134
+ }
135
+ // The verification method is the embedded object of the entry, or the member of
136
+ // verificationMethod[] that a reference entry names.
137
+ const verificationMethod = Appendix.verificationMethodOfEntry(sourceDocument, entry);
129
138
  if (!verificationMethod) {
130
- throw new UpdateError('Invalid verificationMethod: not found in source document', INVALID_DID_DOCUMENT, { sourceDocument, verificationMethodId });
139
+ throw new UpdateError('Invalid verificationMethodId: not found in source document', INVALID_DID_UPDATE, { verificationMethodId });
131
140
  }
132
141
  // Validate the verificationMethod is of type 'Multikey'
133
142
  if (verificationMethod.type !== MULTIKEY_VERIFICATION_METHOD_TYPE) {
@@ -149,15 +158,38 @@ export class DidBtcr2 {
149
158
  if (!beaconService) {
150
159
  throw new UpdateError('No beacon service found for provided beaconId', INVALID_DID_UPDATE, { sourceDocument, beaconId });
151
160
  }
152
- // Return a sans-I/O state machine the caller will drive
161
+ // Return a sans-I/O state machine the caller will drive. The prefix check above proves
162
+ // that the method carries a publicKeyMultibase, which the btcr2 method type requires.
153
163
  return new Updater({
154
164
  sourceDocument,
155
165
  patches,
156
166
  sourceVersionId,
157
- verificationMethod,
167
+ verificationMethod: verificationMethod,
158
168
  beaconService,
159
169
  });
160
170
  }
171
+ /**
172
+ * Entry point for section {@link https://dcdpr.github.io/did-btcr2/operations/deactivate.html | 7.4 Deactivate}.
173
+ *
174
+ * Deactivate is the Update operation with the predetermined patch {@link DEACTIVATION_PATCH}:
175
+ * it adds the `deactivated` property with the value `true`. The factory returns the
176
+ * {@link Updater} that {@link DidBtcr2.update} returns for that patch, and the caller drives
177
+ * it in the same way. Resolution stops at the deactivation for good. The factory does not
178
+ * refuse a source document that is deactivated already; the api does (ADR 100).
179
+ *
180
+ * @param params Deactivation parameters: the parameters of {@link DidBtcr2.update} without `patches`.
181
+ * @returns {Updater} A sans-I/O state machine for driving the deactivation.
182
+ * @throws {UpdateError} As {@link DidBtcr2.update}.
183
+ */
184
+ static deactivate({ sourceDocument, sourceVersionId, verificationMethodId, beaconId, }) {
185
+ return this.update({
186
+ sourceDocument,
187
+ patches: [{ ...DEACTIVATION_PATCH }],
188
+ sourceVersionId,
189
+ verificationMethodId,
190
+ beaconId,
191
+ });
192
+ }
161
193
  /**
162
194
  * Given the W3C DID Document of a `did:btcr2` identifier, return the signing verification method that will be used
163
195
  * for signing messages and credentials. If given, the `methodId` parameter is used to select the
@@ -184,8 +216,9 @@ export class DidBtcr2 {
184
216
  ?? Appendix.relationshipMethodId(didDocument.assertionMethod?.[0], didDocument.id);
185
217
  // An unusable target matches nothing: without this guard it compares equal to every
186
218
  // method whose own id is unusable, and the document's first malformed method is
187
- // returned as the signing method.
188
- const verificationMethod = targetId === undefined ? undefined : didDocument.verificationMethod?.find((vm) => Appendix.absoluteDidUrl(vm.id, didDocument.id) === targetId);
219
+ // returned as the signing method. The search covers verificationMethod[] first, then the
220
+ // methods that a verification relationship embeds.
221
+ const verificationMethod = targetId === undefined ? undefined : Appendix.getVerificationMethods(didDocument).find(vm => Appendix.absoluteDidUrl(vm.id, didDocument.id) === targetId);
189
222
  // If no verification method is found, throw an error
190
223
  if (!(verificationMethod && verificationMethod.publicKeyMultibase)) {
191
224
  throw new DidError(DidErrorCode.InternalError, 'A verification method intended for signing could not be determined from the DID Document');
@@ -1 +1 @@
1
- {"version":3,"file":"did-btcr2.js","sourceRoot":"","sources":["../../src/did-btcr2.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,WAAW,EACX,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,GAAG,EACH,QAAQ,EACR,YAAY,EACb,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EACL,oCAAoC,EACpC,iCAAiC,EAClC,MAAM,yBAAyB,CAAC;AAYjC;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,QAAQ;IACnB;;OAEG;IACH,MAAM,CAAC,UAAU,GAAW,OAAO,CAAC;IAEpC;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,MAAM,CAAC,YAAsC,EAAE,OAA0B;QAC9E,8FAA8F;QAC9F,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,CAAC,EAAE,OAAO,GAAG,SAAS,EAAE,GAAG,OAAO,IAAI,EAA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CAAC;QACJ,CAAC;QACD,OAAO,kBAA2C,CAAC;IACrD,CAAC"}
@@ -50,6 +50,42 @@ export class Appendix {
50
50
  : entry;
51
51
  return Appendix.absoluteDidUrl(id, did);
52
52
  }
53
+ /**
54
+ * Finds the entry of `document.capabilityInvocation` that identifies `methodId`. A
55
+ * reference entry identifies it when the two DID URLs are equal. An embedded verification
56
+ * method object identifies it when its `id` is equal. Both spellings of a DID URL compare
57
+ * equal, as in {@link relationshipMethodId}. This is the lookup of the specification steps
58
+ * "Check `update.proof`" (the read path) and "Construct BTCR2 Signed Update" (the write
59
+ * path); the caller raises `INVALID_DID_UPDATE` when no entry identifies the method.
60
+ *
61
+ * @param {DidDocument} document The DID document.
62
+ * @param {unknown} methodId The verification method id, absolute or relative. A non-string yields `undefined`.
63
+ * @returns {string | DidVerificationMethod | undefined} The entry, or `undefined` if no entry identifies the id.
64
+ */
65
+ static capabilityInvocationEntry(document, methodId) {
66
+ const targetId = Appendix.relationshipMethodId(methodId, document.id);
67
+ if (targetId === undefined)
68
+ return undefined;
69
+ return document.capabilityInvocation?.find(entry => Appendix.relationshipMethodId(entry, document.id) === targetId);
70
+ }
71
+ /**
72
+ * Returns the verification method that a relationship entry denotes: the object itself
73
+ * when the entry embeds the method, else the member of `document.verificationMethod` whose
74
+ * `id` equals the reference. Both spellings of a DID URL compare equal. The caller raises
75
+ * `INVALID_DID_UPDATE` when a reference names no member.
76
+ *
77
+ * @param {DidDocument} document The DID document.
78
+ * @param {string | DidVerificationMethod} entry The relationship entry: a reference, or an embedded method.
79
+ * @returns {DidVerificationMethod | undefined} The method, or `undefined` if a reference names no member.
80
+ */
81
+ static verificationMethodOfEntry(document, entry) {
82
+ if (Appendix.isDidVerificationMethod(entry))
83
+ return entry;
84
+ const targetId = Appendix.absoluteDidUrl(entry, document.id);
85
+ if (targetId === undefined)
86
+ return undefined;
87
+ return document.verificationMethod?.find(method => Appendix.absoluteDidUrl(method?.id, document.id) === targetId);
88
+ }
53
89
  /**
54
90
  * Validates that the given object is a DidVerificationMethod
55
91
  * @param {unknown} obj The object to validate
@@ -183,12 +219,13 @@ export class Appendix {
183
219
  // 1. Set rootCapability to an empty object.
184
220
  const rootCapability = {};
185
221
  // 2. Set components to the result of capabilityId.split(":").
186
- const [urn, zcap, root, did] = capabilityId.split(':') ?? [];
222
+ const components = capabilityId.split(':');
187
223
  // 3. Validate components:
188
224
  // 1. Assert length of components is 4.
189
- if ([urn, zcap, root, did].length !== 4) {
225
+ if (components.length !== 4) {
190
226
  throw new DidError(DidErrorCode.InvalidDid, `Invalid capabilityId: ${capabilityId}`);
191
227
  }
228
+ const [urn, zcap, root, did] = components;
192
229
  // 2. components[0] == urn.
193
230
  if (!urn || urn !== 'urn') {
194
231
  throw new DidError(DidErrorCode.InvalidDid, `Invalid capabilityId: ${capabilityId}`);
@@ -1 +1 @@
1
- {"version":3,"file":"appendix.js","sourceRoot":"","sources":["../../../src/utils/appendix.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,2BAA2B,EAC5B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAGrD;;;;;GAKG;AACH,MAAM,OAAO,QAAQ;IACnB;;;;;;;;;;;OAWG;IACI,MAAM,CAAC,cAAc,CAAC,KAAc,EAAE,GAAW;QACtD,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,OAAO,SAAS,CAAC;QAChD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,SAAS,CAAC;QACzC,OAAO,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IAC1D,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACI,MAAM,CAAC,oBAAoB,CAAC,KAAc,EAAE,GAAW;QAC5D,MAAM,EAAE,GAAG,CAAC,OAAO,KAAK,KA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BAAkB,CAAC,YAAY,CAAC,CAAC;QAEpD,4CAA4C;QAC5C,cAAc,CAAC,EAAE,GAAG,YAAY,CAAC;QAEjC,kDAAkD;QAClD,cAAc,CAAC,UAAU,GAAG,UAAU,CAAC;QAEvC,wDAAwD;QACxD,cAAc,CAAC,gBAAgB,GAAG,UAAU,CAAC;QAE7C,4BAA4B;QAC5B,OAAO,cAAc,CAAC;IACxB,CAAC;CACF"}
@@ -0,0 +1,16 @@
1
+ import { DidMethodError } from '@did-btcr2/common';
2
+ /**
3
+ * Describe an inner error for the `data.cause` of a wrapping typed error. The update paths
4
+ * raise `INVALID_DID_UPDATE` for every failure that the specification names; the inner error
5
+ * of the cryptosuite, the multikey, the hash decoder, or the common package rides along here.
6
+ * @param {unknown} error The inner error.
7
+ * @returns {ErrorCause} The type and the message of the inner error.
8
+ */
9
+ export function errorCause(error) {
10
+ if (error instanceof DidMethodError)
11
+ return { type: error.type, message: error.message };
12
+ if (error instanceof Error)
13
+ return { type: error.name, message: error.message };
14
+ return { type: 'unknown', message: String(error) };
15
+ }
16
+ //# sourceMappingURL=error-cause.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-cause.js","sourceRoot":"","sources":["../../../src/utils/error-cause.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAWnD;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,IAAG,KAAK,YAAY,cAAc;QAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;IACxF,IAAG,KAAK,YAAY,KAAK;QAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;IAC/E,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;AACrD,CAAC"}
@@ -19,6 +19,13 @@ export declare const BTCR2_UPDATE_CONTEXT: readonly ["https://w3id.org/json-ld-p
19
19
  * @returns {boolean} True if the two arrays are equal.
20
20
  */
21
21
  export declare function isBtcr2UpdateContext(value: unknown, expected?: readonly string[]): value is string[];
22
+ /**
23
+ * The JSON Patch operation of the Deactivate operation: it adds the `deactivated` property
24
+ * with the value `true`. Deactivate is the Update operation with this predetermined patch, and
25
+ * resolution stops at the deactivation for good. See
26
+ * {@link https://dcdpr.github.io/did-btcr2/operations/deactivate.html | Deactivate}.
27
+ */
28
+ export declare const DEACTIVATION_PATCH: Readonly<PatchOperation>;
22
29
  /**
23
30
  * A {@link https://dcdpr.github.io/did-btcr2/terminology.html#btcr2-update | BTCR2 Update} without a data integrity proof.
24
31
  * See {@link https://dcdpr.github.io/did-btcr2/data-structures.html#btcr2-unsigned-update | BTCR2 Unsigned Update (data structure)}.
@@ -63,10 +70,10 @@ export type UnsignedBTCR2Update = {
63
70
  * ZCAP capability-invocation fields a did:btcr2 update proof carries.
64
71
  */
65
72
  export type Btcr2DataIntegrityProof = DataIntegrityProofObject & {
66
- /** The root capability being invoked, e.g. `urn:zcap:root:<urlencoded-did>`. */
67
- capability?: string;
68
- /** The action performed under the capability, set to `"Write"` for DID document updates. */
69
- capabilityAction?: string;
73
+ /** The root capability being invoked: `urn:zcap:root:${encodeURIComponent(did)}`. */
74
+ capability: string;
75
+ /** The action performed under the capability: `"Write"` for a DID document update. */
76
+ capabilityAction: string;
70
77
  };
71
78
  /**
72
79
  * A {@link https://dcdpr.github.io/did-btcr2/terminology.html#btcr2-signed-update | BTCR2 Update} with a data integrity proof.
@@ -87,9 +94,9 @@ export type BTCR2Update = UnsignedBTCR2Update | SignedBTCR2Update;
87
94
  export type Btcr2DataIntegrityConfig = DataIntegrityProofOptions & {
88
95
  /** The same array as the update `@context`: {@link BTCR2_UPDATE_CONTEXT}. */
89
96
  '@context': string[];
90
- /** The root capability being invoked, e.g. `urn:zcap:root:<urlencoded-did>`. */
91
- capability?: string;
92
- /** The action performed under the capability, set to `"Write"` for DID document updates. */
93
- capabilityAction?: string;
97
+ /** The root capability being invoked: `urn:zcap:root:${encodeURIComponent(did)}`. */
98
+ capability: string;
99
+ /** The action performed under the capability: `"Write"` for a DID document update. */
100
+ capabilityAction: string;
94
101
  };
95
102
  //# sourceMappingURL=btcr2-update.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"btcr2-update.d.ts","sourceRoot":"","sources":["../../../src/core/btcr2-update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAElG;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,2JAKtB,CAAC;AAEZ;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,EACd,QAAQ,GAAE,SAAS,MAAM,EAAyB,GACjD,KAAK,IAAI,MAAM,EAAE,CAInB;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;OAGG;IACH,UAAU,EAAE,MAAM,EAAE,CAAC;IAErB;;;;OAIG;IACH,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IAE7B;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG,wBAAwB,GAAG;IAC/D,gFAAgF;IAChF,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,4FAA4F;IAC5F,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,mBAAmB,GAAG;IACpD,sFAAsF;I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rF,UAAU,EAAE,MAAM,CAAC;IAEnB,sFAAsF;IACtF,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,mBAAmB,GAAG;IACpD,sFAAsF;IACtF,KAAK,EAAE,uBAAuB,CAAC;CAChC,CAAC;AAEF,qCAAqC;AACrC,MAAM,MAAM,WAAW,GAAG,mBAAmB,GAAG,iBAAiB,CAAC;AAElE;;;;;GAKG;AACH,MAAM,MAAM,wBAAwB,GAAG,yBAAyB,GAAG;IACjE,6EAA6E;IAC7E,UAAU,EAAE,MAAM,EAAE,CAAC;IAErB,qFAAqF;IACrF,UAAU,EAAE,MAAM,CAAC;IAEnB,sFAAsF;IACtF,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC"}
@@ -156,11 +156,45 @@ export declare class Resolver {
156
156
  * @returns {void} Does not return a value, but throws an error if the update is not a valid duplicate.
157
157
  */
158
158
  private static confirmDuplicate;
159
+ /**
160
+ * Decode a hash of a BTCR2 Update (`sourceHash` or `targetHash`). The specification encodes
161
+ * both with base64url without padding.
162
+ * @param {unknown} value The encoded hash.
163
+ * @param {'sourceHash' | 'targetHash'} field The name of the field, for the error.
164
+ * @returns {HashBytes} The decoded bytes.
165
+ * @throws {ResolveError} `INVALID_DID_UPDATE` if the value is not a string or does not decode.
166
+ */
167
+ private static decodeUpdateHash;
168
+ /**
169
+ * Parse a `created` or `expires` value of an update proof. Data Integrity types both as an
170
+ * XML Schema `dateTimeStamp`: an XML Datetime with a timezone. A value without a timezone
171
+ * names no fixed instant, so two resolvers would read two instants; it is rejected.
172
+ * @param {Btcr2DataIntegrityProof} proof The update proof.
173
+ * @param {'created' | 'expires'} field The field to parse.
174
+ * @returns {number | undefined} The instant in milliseconds since the Unix epoch, or `undefined` when the field is absent.
175
+ * @throws {ResolveError} `INVALID_DID_UPDATE` for a value that is not an XML Datetime with a timezone.
176
+ */
177
+ private static proofInstant;
178
+ /**
179
+ * Spec "Check `update.proof`": the proof time window against the block that contains the
180
+ * Beacon Signal. `created` must not be after the header time of the block: a controller
181
+ * signs a short time before the block, and on mainnet the header time is about one hour
182
+ * after the `mediantime`. `expires` must not be before the block `mediantime`: it limits a
183
+ * replay, and a single miner cannot change `mediantime`. `expires` must not be before
184
+ * `created`. Each comparison has no tolerance.
185
+ * @param {Btcr2DataIntegrityProof} proof The update proof.
186
+ * @param {BlockMetadata} block The block of the Beacon Signal.
187
+ * @throws {ResolveError} `INVALID_DID_UPDATE` if a value is outside the window.
188
+ */
189
+ private static checkProofWindow;
159
190
  /**
160
191
  * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#apply-update | Apply update}
161
192
  * and its step {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#check-update-proof | Check update.proof}.
193
+ * Every failure that the specification names raises `INVALID_DID_UPDATE`. An error of the
194
+ * cryptosuite, the multikey, the hash decoder, or the patch rides along as `data.cause`.
162
195
  * @param {DidDocument} currentDocument The current DID Document to apply the update to.
163
196
  * @param {SignedBTCR2Update} update The BTCR2 Signed Update to apply.
197
+ * @param {BlockMetadata} block The block that contains the Beacon Signal that announced the update.
164
198
  * @returns {DidDocument} The updated DID Document after applying the update.
165
199
  * @throws {ResolveError} `INVALID_DID_UPDATE` if the update is invalid or cannot be applied.
166
200
  */
@@ -1 +1 @@
1
- {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../../src/core/resolver.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EACV,iBAAiB,EAElB,MAAM,mBAAmB,CAAC;AAU3B,OAAO,EAAE,WAAW,EAAwB,MAAM,0BAA0B,CAAC;AAE7E,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEzF,OAAO,KAAK,EAAE,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAEpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAA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AM,EACd,OAAO,EAAE,iBAAiB,EAC1B,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,eAAe,CAAC;IAa3B;;;;OAIG;IACH,OAAO,IAAI,YAAY;IAkEvB;;;;;;OAMG;IACH,OAAO,CAAC,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IACjD,OAAO,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,CAAC,EAAE,YAAY,GAAG,IAAI;IACtD,OAAO,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI;CAkEnC"}
@@ -88,9 +88,11 @@ export declare class DidBtcr2 implements DidMethod {
88
88
  * @param {string} params.verificationMethodId The verification method ID to sign with.
89
89
  * @param {string} params.beaconId The beacon service ID to broadcast through.
90
90
  * @returns {Updater} A sans-I/O state machine for driving the update.
91
- * @throws {UpdateError} If the verification method is not authorized, not found,
92
- * not of type `Multikey`, or does not have a `zQ3s` publicKeyMultibase prefix.
93
- * Also throws if the beacon service is not found.
91
+ * @throws {UpdateError} `INVALID_DID_UPDATE` if `sourceVersionId` is not an integer of at
92
+ * least 1, if no entry of `capabilityInvocation` identifies the verification method, if a
93
+ * reference entry names no member of `verificationMethod`, or if the beacon service is not
94
+ * found. `INVALID_DID_DOCUMENT` if the method is not of type `Multikey` or does not have a
95
+ * `zQ3s` publicKeyMultibase prefix.
94
96
  */
95
97
  static update({ sourceDocument, patches, sourceVersionId, verificationMethodId, beaconId, }: {
96
98
  sourceDocument: Btcr2DidDocument;
@@ -99,6 +101,25 @@ export declare class DidBtcr2 implements DidMethod {
99
101
  verificationMethodId: string;
100
102
  beaconId: string;
101
103
  }): Updater;
104
+ /**
105
+ * Entry point for section {@link https://dcdpr.github.io/did-btcr2/operations/deactivate.html | 7.4 Deactivate}.
106
+ *
107
+ * Deactivate is the Update operation with the predetermined patch {@link DEACTIVATION_PATCH}:
108
+ * it adds the `deactivated` property with the value `true`. The factory returns the
109
+ * {@link Updater} that {@link DidBtcr2.update} returns for that patch, and the caller drives
110
+ * it in the same way. Resolution stops at the deactivation for good. The factory does not
111
+ * refuse a source document that is deactivated already; the api does (ADR 100).
112
+ *
113
+ * @param params Deactivation parameters: the parameters of {@link DidBtcr2.update} without `patches`.
114
+ * @returns {Updater} A sans-I/O state machine for driving the deactivation.
115
+ * @throws {UpdateError} As {@link DidBtcr2.update}.
116
+ */
117
+ static deactivate({ sourceDocument, sourceVersionId, verificationMethodId, beaconId, }: {
118
+ sourceDocument: Btcr2DidDocument;
119
+ sourceVersionId: number;
120
+ verificationMethodId: string;
121
+ beaconId: string;
122
+ }): Updater;
102
123
  /**
103
124
  * Given the W3C DID Document of a `did:btcr2` identifier, return the signing verification method that will be used
104
125
  * for signing messages and credentials. If given, the `methodId` parameter is used to select the
@@ -1 +1 @@
1
- {"version":3,"file":"did-btcr2.d.ts","sourceRoot":"","sources":["../../src/did-btcr2.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,QAAQ,EACR,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAS3C,OAAO,KAAK,EACV,SAAS,EAAC,MAAM,YAAY,CAAC;AAQ/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAM5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEvF,MAAM,WAAW,gBAAgB;IAC/B,qDAAqD;IACrD,MAAM,EAAE,MAAM,CAAC;IACf,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sBAAsB;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,QAAS,YAAW,SAAS;IACxC;;OAEG;IACH,MAAM,CAAC,UAAU,EAAE,MAAM,CAAW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undefined} The absolute DID URL, or `undefined` if unusable.
40
40
  */
41
41
  static relationshipMethodId(entry: unknown, did: string): string | undefined;
42
+ /**
43
+ * Finds the entry of `document.capabilityInvocation` that identifies `methodId`. A
44
+ * reference entry identifies it when the two DID URLs are equal. An embedded verification
45
+ * method object identifies it when its `id` is equal. Both spellings of a DID URL compare
46
+ * equal, as in {@link relationshipMethodId}. This is the lookup of the specification steps
47
+ * "Check `update.proof`" (the read path) and "Construct BTCR2 Signed Update" (the write
48
+ * path); the caller raises `INVALID_DID_UPDATE` when no entry identifies the method.
49
+ *
50
+ * @param {DidDocument} document The DID document.
51
+ * @param {unknown} methodId The verification method id, absolute or relative. A non-string yields `undefined`.
52
+ * @returns {string | DidVerificationMethod | undefined} The entry, or `undefined` if no entry identifies the id.
53
+ */
54
+ static capabilityInvocationEntry(document: DidDocument, methodId: unknown): string | DidVerificationMethod | undefined;
55
+ /**
56
+ * Returns the verification method that a relationship entry denotes: the object itself
57
+ * when the entry embeds the method, else the member of `document.verificationMethod` whose
58
+ * `id` equals the reference. Both spellings of a DID URL compare equal. The caller raises
59
+ * `INVALID_DID_UPDATE` when a reference names no member.
60
+ *
61
+ * @param {DidDocument} document The DID document.
62
+ * @param {string | DidVerificationMethod} entry The relationship entry: a reference, or an embedded method.
63
+ * @returns {DidVerificationMethod | undefined} The method, or `undefined` if a reference names no member.
64
+ */
65
+ static verificationMethodOfEntry(document: DidDocument, entry: string | DidVerificationMethod): DidVerificationMethod | undefined;
42
66
  /**
43
67
  * Validates that the given object is a DidVerificationMethod
44
68
  * @param {unknown} obj The object to validate
@@ -1 +1 @@
1
- {"version":3,"file":"appendix.d.ts","sourceRoot":"","sources":["../../../src/utils/appendix.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,qBAAqB,EAAC,MAAM,YAAY,CAAC;AAO3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D;;;;;GAKG;AACH,qBAA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,QAAQ,EAAE,OAAO,GAChB,MAAM,GAAG,qBAAqB,GAAG,SAAS;IAQ7C;;;;;;;;;OASG;WACW,yBAAyB,CACrC,QAAQ,EAAE,WAAW,EACrB,KAAK,EAAE,MAAM,GAAG,qBAAqB,GACpC,qBAAqB,GAAG,SAAS;IASpC;;;;OAIG;WACW,uBAAuB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,qBAAqB;IAcjF;;;;OAIG;WACW,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,UAAU;IAW3D;;;;;OAKG;WACW,sBAAsB,CAAC,WAAW,EAAE,WAAW,GAAG,qBAAqB,EAAE;IAgBvF;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,MAAM,CAAC,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,cAAc;IAU/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;WACW,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,cAAc;CA+CtE"}
@@ -0,0 +1,16 @@
1
+ /** The type and the message of an inner error, carried as `data.cause` by a wrapping error. */
2
+ export interface ErrorCause {
3
+ /** The `type` of a typed error, or the `name` of a plain `Error`. */
4
+ type: string;
5
+ /** The message of the inner error. */
6
+ message: string;
7
+ }
8
+ /**
9
+ * Describe an inner error for the `data.cause` of a wrapping typed error. The update paths
10
+ * raise `INVALID_DID_UPDATE` for every failure that the specification names; the inner error
11
+ * of the cryptosuite, the multikey, the hash decoder, or the common package rides along here.
12
+ * @param {unknown} error The inner error.
13
+ * @returns {ErrorCause} The type and the message of the inner error.
14
+ */
15
+ export declare function errorCause(error: unknown): ErrorCause;
16
+ //# sourceMappingURL=error-cause.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-cause.d.ts","sourceRoot":"","sources":["../../../src/utils/error-cause.ts"],"names":[],"mappings":"AAEA,+FAA+F;AAC/F,MAAM,WAAW,UAAU;IACzB,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IAEb,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAIrD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@did-btcr2/method",
3
- "version": "0.63.0",
3
+ "version": "0.65.0",
4
4
  "type": "module",
5
5
  "description": "Reference implementation for the did:btcr2 DID method written in TypeScript and JavaScript. did:btcr2 is a censorship resistant DID Method using the Bitcoin blockchain as a Verifiable Data Registry to announce changes to the DID document. This is the core method implementation for the did-btcr2-js monorepo.",
6
6
  "main": "./dist/cjs/index.js",
@@ -70,10 +70,10 @@
70
70
  "@scure/btc-signer": "^1.8.1",
71
71
  "@web5/dids": "^1.2.0",
72
72
  "@did-btcr2/bitcoin": "^0.11.0",
73
- "@did-btcr2/common": "^9.5.0",
74
73
  "@did-btcr2/cryptosuite": "^10.0.0",
75
74
  "@did-btcr2/keypair": "^0.13.1",
76
- "@did-btcr2/smt": "^0.3.0"
75
+ "@did-btcr2/smt": "^0.3.0",
76
+ "@did-btcr2/common": "^9.6.0"
77
77
  },
78
78
  "devDependencies": {
79
79
  "@eslint/js": "^9.39.4",
@@ -34,6 +34,18 @@ export function isBtcr2UpdateContext(
34
34
  && value.every((url, i) => url === expected[i]);
35
35
  }
36
36
 
37
+ /**
38
+ * The JSON Patch operation of the Deactivate operation: it adds the `deactivated` property
39
+ * with the value `true`. Deactivate is the Update operation with this predetermined patch, and
40
+ * resolution stops at the deactivation for good. See
41
+ * {@link https://dcdpr.github.io/did-btcr2/operations/deactivate.html | Deactivate}.
42
+ */
43
+ export const DEACTIVATION_PATCH: Readonly<PatchOperation> = Object.freeze({
44
+ op : 'add',
45
+ path : '/deactivated',
46
+ value : true,
47
+ });
48
+
37
49
  /**
38
50
  * A {@link https://dcdpr.github.io/did-btcr2/terminology.html#btcr2-update | BTCR2 Update} without a data integrity proof.
39
51
  * See {@link https://dcdpr.github.io/did-btcr2/data-structures.html#btcr2-unsigned-update | BTCR2 Unsigned Update (data structure)}.
@@ -83,11 +95,11 @@ export type UnsignedBTCR2Update = {
83
95
  * ZCAP capability-invocation fields a did:btcr2 update proof carries.
84
96
  */
85
97
  export type Btcr2DataIntegrityProof = DataIntegrityProofObject & {
86
- /** The root capability being invoked, e.g. `urn:zcap:root:<urlencoded-did>`. */
87
- capability?: string;
98
+ /** The root capability being invoked: `urn:zcap:root:${encodeURIComponent(did)}`. */
99
+ capability: string;
88
100
 
89
- /** The action performed under the capability, set to `"Write"` for DID document updates. */
90
- capabilityAction?: string;
101
+ /** The action performed under the capability: `"Write"` for a DID document update. */
102
+ capabilityAction: string;
91
103
  };
92
104
 
93
105
  /**
@@ -112,9 +124,9 @@ export type Btcr2DataIntegrityConfig = DataIntegrityProofOptions & {
112
124
  /** The same array as the update `@context`: {@link BTCR2_UPDATE_CONTEXT}. */
113
125
  '@context': string[];
114
126
 
115
- /** The root capability being invoked, e.g. `urn:zcap:root:<urlencoded-did>`. */
116
- capability?: string;
127
+ /** The root capability being invoked: `urn:zcap:root:${encodeURIComponent(did)}`. */
128
+ capability: string;
117
129
 
118
- /** The action performed under the capability, set to `"Write"` for DID document updates. */
119
- capabilityAction?: string;
130
+ /** The action performed under the capability: `"Write"` for a DID document update. */
131
+ capabilityAction: string;
120
132
  };