@did-btcr2/method 0.62.0 → 0.64.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 (46) hide show
  1. package/README.md +14 -1
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/browser.js +3 -3
  4. package/dist/browser.mjs +3 -3
  5. package/dist/cjs/index.js +1269 -986
  6. package/dist/esm/core/beacon/signal-discovery.js +34 -1
  7. package/dist/esm/core/beacon/signal-discovery.js.map +1 -1
  8. package/dist/esm/core/btcr2-update.js +11 -0
  9. package/dist/esm/core/btcr2-update.js.map +1 -1
  10. package/dist/esm/core/resolver.js +345 -252
  11. package/dist/esm/core/resolver.js.map +1 -1
  12. package/dist/esm/core/updater.js +33 -3
  13. package/dist/esm/core/updater.js.map +1 -1
  14. package/dist/esm/did-btcr2.js +53 -20
  15. package/dist/esm/did-btcr2.js.map +1 -1
  16. package/dist/esm/utils/appendix.js +39 -2
  17. package/dist/esm/utils/appendix.js.map +1 -1
  18. package/dist/esm/utils/error-cause.js +16 -0
  19. package/dist/esm/utils/error-cause.js.map +1 -0
  20. package/dist/types/core/beacon/interfaces.d.ts +9 -1
  21. package/dist/types/core/beacon/interfaces.d.ts.map +1 -1
  22. package/dist/types/core/beacon/signal-discovery.d.ts +12 -0
  23. package/dist/types/core/beacon/signal-discovery.d.ts.map +1 -1
  24. package/dist/types/core/btcr2-update.d.ts +15 -8
  25. package/dist/types/core/btcr2-update.d.ts.map +1 -1
  26. package/dist/types/core/interfaces.d.ts +16 -5
  27. package/dist/types/core/interfaces.d.ts.map +1 -1
  28. package/dist/types/core/resolver.d.ts +37 -23
  29. package/dist/types/core/resolver.d.ts.map +1 -1
  30. package/dist/types/core/updater.d.ts.map +1 -1
  31. package/dist/types/did-btcr2.d.ts +24 -3
  32. package/dist/types/did-btcr2.d.ts.map +1 -1
  33. package/dist/types/utils/appendix.d.ts +24 -0
  34. package/dist/types/utils/appendix.d.ts.map +1 -1
  35. package/dist/types/utils/error-cause.d.ts +16 -0
  36. package/dist/types/utils/error-cause.d.ts.map +1 -0
  37. package/package.json +3 -3
  38. package/src/core/beacon/interfaces.ts +10 -1
  39. package/src/core/beacon/signal-discovery.ts +44 -1
  40. package/src/core/btcr2-update.ts +20 -8
  41. package/src/core/interfaces.ts +16 -5
  42. package/src/core/resolver.ts +420 -315
  43. package/src/core/updater.ts +41 -3
  44. package/src/did-btcr2.ts +70 -25
  45. package/src/utils/appendix.ts +48 -2
  46. package/src/utils/error-cause.ts +23 -0
@@ -1,4 +1,3 @@
1
- import type { HashBytes } from '@did-btcr2/common';
2
1
  import type { SignedBTCR2Update } from './btcr2-update.js';
3
2
  import { DidDocument } from '../utils/did-document.js';
4
3
  import type { BeaconService, BeaconSignal, BlockMetadata } from './beacon/interfaces.js';
@@ -150,26 +149,7 @@ export declare class Resolver {
150
149
  */
151
150
  static sidecarData(sidecar?: Sidecar): SidecarData;
152
151
  /**
153
- * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#process-updates | 7.2.f Process updates Array}.
154
- * @param {DidDocument} currentDocument The current DID Document to apply the updates to.
155
- * @param {Array<[SignedBTCR2Update, BlockMetadata]>} unsortedUpdates The unsorted array of BTCR2 Signed Updates and their associated Block Metadata.
156
- * @param {string} [versionTime] The optional version time to limit updates to.
157
- * @param {string} [versionId] The optional version id to limit updates to.
158
- * @param {{ currentVersionId: number; updateHashHistory: HashBytes[] }} [resolutionState]
159
- * Version counter and update-hash history carried from earlier discovery rounds.
160
- * Standalone callers omit it and start fresh at version 1 with an empty history.
161
- * @returns {DidResolutionResponse} The updated DID Document, number of confirmations, and version id.
162
- *
163
- * Confirmation depth is not checked here. The BeaconProcess phase excludes a
164
- * signal below `ResolutionOptions.minConf` before its update reaches this method,
165
- * so every tuple here comes from a block at or above the threshold.
166
- */
167
- static updates(currentDocument: DidDocument, unsortedUpdates: Array<[SignedBTCR2Update, BlockMetadata]>, versionTime?: string, versionId?: string, resolutionState?: {
168
- currentVersionId: number;
169
- updateHashHistory: HashBytes[];
170
- }): DidResolutionResponse;
171
- /**
172
- * Implements subsection {@link https://dcdpr.github.io/did-btcr2/#confirm-duplicate-update | 7.2.f.1 Confirm Duplicate Update}.
152
+ * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#confirm-duplicate-update | Confirm Duplicate Update}.
173
153
  * This step confirms that an update with a lower-than-expected targetVersionId is a true duplicate.
174
154
  * @param {SignedBTCR2Update} update The BTCR2 Signed Update to confirm as a duplicate.
175
155
  * @param {HashBytes[]} updateHashHistory The accumulated hash history for comparison.
@@ -177,12 +157,46 @@ export declare class Resolver {
177
157
  */
178
158
  private static confirmDuplicate;
179
159
  /**
180
- * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#apply-update | 7.2.f.3 Apply Update}
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;
190
+ /**
191
+ * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#apply-update | Apply update}
181
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`.
182
195
  * @param {DidDocument} currentDocument The current DID Document to apply the update to.
183
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.
184
198
  * @returns {DidDocument} The updated DID Document after applying the update.
185
- * @throws {ResolveError} If the update is invalid or cannot be applied.
199
+ * @throws {ResolveError} `INVALID_DID_UPDATE` if the update is invalid or cannot be applied.
186
200
  */
187
201
  private static applyUpdate;
188
202
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../../src/core/resolver.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,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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eAAe,EAAE,MAAM,GACtB,mBAAmB;IAgDtB;;;;;;;;OAQG;IACH,MAAM,CAAC,IAAI,CACT,GAAG,EAAE,MAAM,EACX,cAAc,EAAE,mBAAmB,EACnC,kBAAkB,EAAE,qBAAqB,EACzC,MAAM,EAAE,MAAM,GACb,iBAAiB;IA4FpB;;;;;;;;;;;;;;;OAeG;WACU,QAAQ,CACnB,aAAa,EAAE,aAAa,EAC5B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,iBAAiB,EACzB,MAAM,EAAE,MAAM,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,gBAAg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,GACT,EAAE;QACD,cAAc,EAAE,gBAAgB,CAAC;QACjC,eAAe,EAAE,MAAM,CAAC;QACxB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,QAAQ,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO;IAUX;;;;;;;;;OASG;IACH,MAAM,CAAC,gBAAgB,CAAC,WAAW,EAAE,gBAAgB,EAAG,QAAQ,CAAC,EAAE,MAAM,GAAG,qBAAqB;CAkClG"}
@@ -39,6 +39,30 @@ export declare class Appendix {
39
39
  * @returns {string | 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,qBAAa,QAAQ;IACnB;;;;;;;;;;;OAWG;WACW,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAM7E;;;;;;;;;;;;;;;;;OAiBG;WACW,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAOnF;;;;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;CA8CtE"}
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,qBAAa,QAAQ;IACnB;;;;;;;;;;;OAWG;WACW,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAM7E;;;;;;;;;;;;;;;;;OAiBG;WACW,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAOnF;;;;;;;;;;;OAWG;WACW,yBAAyB,CACrC,QAAQ,EAAE,WAAW,EACrB,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.62.0",
3
+ "version": "0.64.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,9 +70,9 @@
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
- "@did-btcr2/smt": "^0.3.0",
73
+ "@did-btcr2/common": "^9.6.0",
75
74
  "@did-btcr2/keypair": "^0.13.1",
75
+ "@did-btcr2/smt": "^0.3.0",
76
76
  "@did-btcr2/cryptosuite": "^10.0.0"
77
77
  },
78
78
  "devDependencies": {
@@ -35,10 +35,19 @@ export interface BlockMetadata {
35
35
  height: number;
36
36
 
37
37
  /**
38
- * The timestamp of the block containing the Beacon Signal.
38
+ * The timestamp in the header of the block that contains the Beacon Signal.
39
+ * The resolver reports it as `updated` in the document metadata.
39
40
  */
40
41
  time: UnixTimestamp;
41
42
 
43
+ /**
44
+ * The median time past of the block that contains the Beacon Signal: the
45
+ * median of the header timestamps of that block and the ten blocks before it.
46
+ * The value does not decrease from one block to the next, and no single miner
47
+ * can change it. The resolver compares it with `ResolutionOptions.versionTime`.
48
+ */
49
+ mediantime: UnixTimestamp;
50
+
42
51
  /**
43
52
  * The number of confirmations for the block containing the Beacon Signal.
44
53
  */
@@ -7,7 +7,7 @@ import {
7
7
  GENESIS_TX_ID,
8
8
  TXIN_WITNESS_COINBASE
9
9
  } from '@did-btcr2/bitcoin';
10
- import { ResolveError } from '@did-btcr2/common';
10
+ import { INTERNAL_ERROR, ResolveError } from '@did-btcr2/common';
11
11
  import type { BeaconService, BeaconSignal } from './interfaces.js';
12
12
  import { BeaconUtils } from './utils.js';
13
13
 
@@ -136,6 +136,10 @@ export class BeaconSignalDiscovery {
136
136
  // Fetch the current block count once before the loop
137
137
  const currentBlockCount = await bitcoin.rest.block.count();
138
138
 
139
+ // The median time past of each block that holds a signal, keyed by block hash.
140
+ // One fetch per distinct block for the whole run.
141
+ const mediantimes = new Map<string, number>();
142
+
139
143
  // Iterate over each beacon
140
144
  for (const beaconService of beaconServices) {
141
145
  beaconServiceSignals.set(beaconService, []);
@@ -193,6 +197,11 @@ export class BeaconSignalDiscovery {
193
197
  // Use the pre-fetched block count instead of calling per-signal
194
198
  const confirmations = currentBlockCount - status.block_height + 1;
195
199
 
200
+ // The address listing carries the header time of the block, not its median
201
+ // time past. The resolver compares `versionTime` with the median time past,
202
+ // so read it from the block record.
203
+ const mediantime = await BeaconSignalDiscovery.mediantime(status.block_hash, bitcoin, mediantimes);
204
+
196
205
  // Push the beacon signal object to the signals array for the beacon service
197
206
  beaconServiceSignals.get(beaconService)?.push({
198
207
  tx : beaconSignal,
@@ -201,6 +210,7 @@ export class BeaconSignalDiscovery {
201
210
  confirmations,
202
211
  height : status.block_height,
203
212
  time : status.block_time,
213
+ mediantime,
204
214
  }
205
215
  });
206
216
  }
@@ -209,6 +219,38 @@ export class BeaconSignalDiscovery {
209
219
  return beaconServiceSignals;
210
220
  }
211
221
 
222
+ /**
223
+ * Return the median time past of a block, from the per-run cache or from the
224
+ * Esplora block record (`GET /block/:hash`). The specification compares
225
+ * `versionTime` with the block `mediantime`, and the address listing does not
226
+ * carry it. One block record serves every signal in that block.
227
+ * @param {string} blockhash The hash of the block that contains a signal.
228
+ * @param {BitcoinConnection} bitcoin Bitcoin network connection to use for REST calls.
229
+ * @param {Map<string, number>} cache The median time past values fetched so far, keyed by block hash.
230
+ * @returns {Promise<number>} The median time past of the block, in Unix seconds.
231
+ * @throws {ResolveError} `INTERNAL_ERROR` if the backend returns no block record or no `mediantime` for the hash.
232
+ */
233
+ private static async mediantime(
234
+ blockhash: string,
235
+ bitcoin: BitcoinConnection,
236
+ cache: Map<string, number>
237
+ ): Promise<number> {
238
+ const cached = cache.get(blockhash);
239
+ if(cached !== undefined) {
240
+ return cached;
241
+ }
242
+ const block = await bitcoin.rest.block.get({ blockhash });
243
+ const mediantime = block?.mediantime;
244
+ if(typeof mediantime !== 'number' || !Number.isFinite(mediantime)) {
245
+ throw new ResolveError(
246
+ `Block ${blockhash} has no mediantime in the block record of the Bitcoin REST backend.`,
247
+ INTERNAL_ERROR, { blockhash, block }
248
+ );
249
+ }
250
+ cache.set(blockhash, mediantime);
251
+ return mediantime;
252
+ }
253
+
212
254
  /**
213
255
  * Traverse the full blockchain from genesis to chain top looking for beacon signals.
214
256
  * @param {Array<BeaconService>} beaconServices Array of BeaconService objects to search for signals.
@@ -357,6 +399,7 @@ export class BeaconSignalDiscovery {
357
399
  blockMetadata : {
358
400
  height : block.height,
359
401
  time : block.time,
402
+ mediantime : block.mediantime,
360
403
  confirmations : block.confirmations
361
404
  }
362
405
  });
@@ -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
  };
@@ -18,15 +18,26 @@ export interface RootCapability {
18
18
  */
19
19
  export interface ResolutionOptions extends DidResolutionOptions {
20
20
  /**
21
- * Optional ASCII string representation of the specific version of a DID document
22
- * to be resolved.
21
+ * The version of the DID document to resolve, as an ASCII string of an integer
22
+ * (for example `"2"`). The versions start at `"1"`, the genesis document. The
23
+ * resolver stops before it applies the update that yields the next version, so
24
+ * `"1"` returns the genesis document also when updates exist. A version that the
25
+ * history does not reach, also a version after a deactivation, fails with a
26
+ * `ResolveError` of type `NOT_FOUND`. A value that is not an ASCII string of an
27
+ * integer fails with `INVALID_OPTIONS`. Mutually exclusive with `versionTime`:
28
+ * a request with both fails with `INVALID_OPTIONS`.
23
29
  */
24
30
  versionId?: string
25
31
 
26
32
  /**
27
- * Optional XML Datetime normalized to UTC without sub-second decimal precision.
28
- * The DID document to be resolved is the most recent version of the DID document
29
- * that was valid for the DID before the specified versionTime.
33
+ * An XML Datetime in UTC with the `Z` designator and no fraction (for example
34
+ * `"2026-07-01T00:00:00Z"`), the form that DID Resolution v1 requires. The
35
+ * resolver applies each update whose block `mediantime` (median time past) is
36
+ * at or before this instant, and stops at the first update whose block
37
+ * `mediantime` is after it. The boundary is inclusive. Every conformant resolver
38
+ * reads the same `mediantime` from the block chain, so every resolver selects
39
+ * the same version. A value in another form fails with `INVALID_OPTIONS`.
40
+ * Mutually exclusive with `versionId`.
30
41
  */
31
42
  versionTime?: string;
32
43