@did-btcr2/method 0.61.0 → 0.63.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.
- package/README.md +6 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/browser.js +3 -3
- package/dist/browser.mjs +3 -3
- package/dist/cjs/index.js +213 -151
- package/dist/esm/core/beacon/signal-discovery.js +34 -1
- package/dist/esm/core/beacon/signal-discovery.js.map +1 -1
- package/dist/esm/core/identifier.js +12 -2
- package/dist/esm/core/identifier.js.map +1 -1
- package/dist/esm/core/resolver.js +209 -197
- package/dist/esm/core/resolver.js.map +1 -1
- package/dist/types/core/beacon/interfaces.d.ts +9 -1
- package/dist/types/core/beacon/interfaces.d.ts.map +1 -1
- package/dist/types/core/beacon/signal-discovery.d.ts +12 -0
- package/dist/types/core/beacon/signal-discovery.d.ts.map +1 -1
- package/dist/types/core/identifier.d.ts.map +1 -1
- package/dist/types/core/interfaces.d.ts +16 -5
- package/dist/types/core/interfaces.d.ts.map +1 -1
- package/dist/types/core/resolver.d.ts +19 -27
- package/dist/types/core/resolver.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/core/beacon/interfaces.ts +10 -1
- package/src/core/beacon/signal-discovery.ts +44 -1
- package/src/core/identifier.ts +14 -2
- package/src/core/interfaces.ts +16 -5
- package/src/core/resolver.ts +268 -249
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identifier.js","sourceRoot":"","sources":["../../../src/core/identifier.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,WAAW,EACX,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,4BAA4B,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;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H,MAAM,CAAC,YAAY,CAAC,GAAW;QAC7B,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACxD,IAAG,MAAM,KAAK,KAAK,EAAE,CAAC;YACpB,MAAM,IAAI,eAAe,CACvB,gDAAgD,GAAG,2DAA2D,EAC9G,WAAW,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,CAC7B,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,4BAA4B,CAAC,YAAY,CAAC,CAAC;IACxD,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,OAAO,CAAC,UAAkB;QAC/B,IAAI,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YACxB,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getNetwork } from '@did-btcr2/bitcoin';
|
|
2
|
-
import { canonicalHash, canonicalHashBytes, canonicalize, DateUtils, encode as encodeHash, decode as decodeHash, INTERNAL_ERROR,
|
|
2
|
+
import { canonicalHash, canonicalHashBytes, canonicalize, DateUtils, encode as encodeHash, decode as decodeHash, INTERNAL_ERROR, INVALID_DID, INVALID_DID_UPDATE, INVALID_OPTIONS, JSONPatch, JSONUtils, LATE_PUBLISHING_ERROR, NOT_FOUND, ResolveError } from '@did-btcr2/common';
|
|
3
3
|
import { BTCR2_UPDATE_CONTEXT, isBtcr2UpdateContext } from './btcr2-update.js';
|
|
4
4
|
import { BIP340Cryptosuite, BIP340DataIntegrityProof, SchnorrMultikey } from '@did-btcr2/cryptosuite';
|
|
5
5
|
import { CompressedSecp256k1PublicKey } from '@did-btcr2/keypair';
|
|
@@ -63,18 +63,62 @@ function validateMinConf(value) {
|
|
|
63
63
|
return DEFAULT_MIN_CONF;
|
|
64
64
|
if (typeof value === 'number' && Number.isInteger(value) && value >= 1)
|
|
65
65
|
return value;
|
|
66
|
-
|
|
67
|
-
throw new ResolveError(`Invalid resolution option minConf: expected a positive integer (minimum 1), got ${shown}.`, INVALID_OPTIONS, { minConf: value });
|
|
66
|
+
throw new ResolveError(`Invalid resolution option minConf: expected a positive integer (minimum 1), got ${shown(value)}.`, INVALID_OPTIONS, { minConf: value });
|
|
68
67
|
}
|
|
68
|
+
/** Render an option value for an error message: a string in quotes, any other value as is. */
|
|
69
|
+
function shown(value) {
|
|
70
|
+
return typeof value === 'string' ? JSON.stringify(value) : String(value);
|
|
71
|
+
}
|
|
72
|
+
/** An ASCII string of an integer: an optional minus sign, then digits. */
|
|
73
|
+
const ASCII_INTEGER = /^-?[0-9]+$/;
|
|
74
|
+
/**
|
|
75
|
+
* Parse `ResolutionOptions.versionId`. The specification says that the value MUST
|
|
76
|
+
* parse as an integer, and DID Resolution v1 types the option as a string. The
|
|
77
|
+
* accepted form is an ASCII string of an integer inside the safe integer range.
|
|
78
|
+
* @returns {number | undefined} The integer, or `undefined` when the option is absent.
|
|
79
|
+
* @throws {ResolveError} `INVALID_OPTIONS` for every other value.
|
|
80
|
+
*/
|
|
81
|
+
function validateVersionId(value) {
|
|
82
|
+
if (value === undefined)
|
|
83
|
+
return undefined;
|
|
84
|
+
if (typeof value === 'string' && ASCII_INTEGER.test(value) && Number.isSafeInteger(Number(value))) {
|
|
85
|
+
return Number(value);
|
|
86
|
+
}
|
|
87
|
+
throw new ResolveError(`Invalid resolution option versionId: expected an ASCII string of an integer, got ${shown(value)}.`, INVALID_OPTIONS, { versionId: value });
|
|
88
|
+
}
|
|
89
|
+
/** An XML Datetime in UTC with the `Z` designator and no fraction, for example `2026-07-01T00:00:00Z`. */
|
|
90
|
+
const UTC_XSD_DATETIME = /^-?\d{4,}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/;
|
|
69
91
|
/**
|
|
70
|
-
*
|
|
92
|
+
* Parse `ResolutionOptions.versionTime`. DID Resolution v1 requires an XML Datetime
|
|
93
|
+
* normalized to UTC without sub-second precision. The specification raises
|
|
94
|
+
* `INVALID_OPTIONS` for a value that does not parse.
|
|
95
|
+
* @returns {number | undefined} The instant in milliseconds since the Unix epoch, or `undefined` when the option is absent.
|
|
96
|
+
* @throws {ResolveError} `INVALID_OPTIONS` for every other value.
|
|
97
|
+
*/
|
|
98
|
+
function validateVersionTime(value) {
|
|
99
|
+
if (value === undefined)
|
|
100
|
+
return undefined;
|
|
101
|
+
if (typeof value === 'string' && UTC_XSD_DATETIME.test(value) && DateUtils.isValidXsdDateTime(value)) {
|
|
102
|
+
const ms = Date.parse(value);
|
|
103
|
+
if (Number.isFinite(ms))
|
|
104
|
+
return ms;
|
|
105
|
+
}
|
|
106
|
+
throw new ResolveError('Invalid resolution option versionTime: expected an XML Datetime in UTC without a fraction '
|
|
107
|
+
+ `(for example "2026-07-01T00:00:00Z"), got ${shown(value)}.`, INVALID_OPTIONS, { versionTime: value });
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The phases of the resolution process. Each pass of the specification loop is
|
|
111
|
+
* BeaconDiscovery (the scan of the beacon addresses the resolver did not scan yet),
|
|
112
|
+
* BeaconProcess (the tuples of the signals the caller provided), and ProcessUpdate
|
|
113
|
+
* (one tuple). GenesisDocument runs once, for an EXTERNAL identifier whose genesis
|
|
114
|
+
* document is not in the sidecar.
|
|
71
115
|
*/
|
|
72
116
|
var ResolverPhase;
|
|
73
117
|
(function (ResolverPhase) {
|
|
74
118
|
ResolverPhase["GenesisDocument"] = "GenesisDocument";
|
|
75
119
|
ResolverPhase["BeaconDiscovery"] = "BeaconDiscovery";
|
|
76
120
|
ResolverPhase["BeaconProcess"] = "BeaconProcess";
|
|
77
|
-
ResolverPhase["
|
|
121
|
+
ResolverPhase["ProcessUpdate"] = "ProcessUpdate";
|
|
78
122
|
ResolverPhase["Complete"] = "Complete";
|
|
79
123
|
})(ResolverPhase || (ResolverPhase = {}));
|
|
80
124
|
/**
|
|
@@ -102,7 +146,9 @@ var ResolverPhase;
|
|
|
102
146
|
export class Resolver {
|
|
103
147
|
// --- Immutable inputs ---
|
|
104
148
|
#didComponents;
|
|
149
|
+
/** The parsed `ResolutionOptions.versionId`, or `undefined` when the option is absent. */
|
|
105
150
|
#versionId;
|
|
151
|
+
/** The parsed `ResolutionOptions.versionTime` in milliseconds since the Unix epoch, or `undefined`. */
|
|
106
152
|
#versionTime;
|
|
107
153
|
/**
|
|
108
154
|
* The specific phase the Resolver is current in.
|
|
@@ -113,22 +159,28 @@ export class Resolver {
|
|
|
113
159
|
#providedGenesisDocument = null;
|
|
114
160
|
#beaconServicesSignals = new Map();
|
|
115
161
|
#processedServices = new Set();
|
|
162
|
+
/** The beacon addresses the resolver requested signals for: `scanned_beacons` of the specification. */
|
|
116
163
|
#requestCache = new Set();
|
|
164
|
+
/**
|
|
165
|
+
* The tuples of the specification's `updates` list: a signed update and the metadata of
|
|
166
|
+
* the block that announced it. BeaconProcess appends; ProcessUpdate sorts the list and
|
|
167
|
+
* removes one tuple per step. A tuple that one pass does not reach waits for the next.
|
|
168
|
+
*/
|
|
117
169
|
#unsortedUpdates = [];
|
|
118
170
|
#resolvedResponse = null;
|
|
119
171
|
/**
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
* announced on beacons that earlier updates added: round two would forget it had
|
|
128
|
-
* already reached version two, see version three, and raise a late-publishing error.
|
|
172
|
+
* The state of the specification loop, carried across every pass: the version counter
|
|
173
|
+
* (`current_version_id`), the update-hash history that backs duplicate confirmation
|
|
174
|
+
* (`update_hash_history`), the confirmations of the block that contains the most
|
|
175
|
+
* recently applied unique update (`block_confirmations`), and the header time of that
|
|
176
|
+
* block as `updated`. A pass that finds a new beacon address returns to discovery, so
|
|
177
|
+
* the state must not restart: a restart would reject a linear history whose later
|
|
178
|
+
* updates are announced on beacons that earlier updates added.
|
|
129
179
|
*/
|
|
130
180
|
#currentVersionId = 1;
|
|
131
181
|
#updateHashHistory = [];
|
|
182
|
+
#blockConfirmations = 0;
|
|
183
|
+
#updated;
|
|
132
184
|
/**
|
|
133
185
|
* Opt-in upper bound on multi-round beacon-discovery passes. `Infinity` (the
|
|
134
186
|
* default) leaves discovery unbounded; termination is already guaranteed by
|
|
@@ -153,14 +205,20 @@ export class Resolver {
|
|
|
153
205
|
this.#didComponents = didComponents;
|
|
154
206
|
this.#sidecarData = sidecarData;
|
|
155
207
|
this.#currentDocument = currentDocument;
|
|
156
|
-
|
|
157
|
-
|
|
208
|
+
// The resolution options fail here, before any data need is emitted, so the
|
|
209
|
+
// caller does no I/O for a request it cannot serve. DID Resolution v1 defines
|
|
210
|
+
// versionId and versionTime as mutually exclusive; the specification raises
|
|
211
|
+
// INVALID_OPTIONS for a request with both, and for a value that does not parse.
|
|
212
|
+
if (options?.versionId !== undefined && options?.versionTime !== undefined) {
|
|
213
|
+
throw new ResolveError('Invalid resolution options: versionId and versionTime are mutually exclusive. Pass one of them.', INVALID_OPTIONS, { versionId: options.versionId, versionTime: options.versionTime });
|
|
214
|
+
}
|
|
215
|
+
this.#versionId = validateVersionId(options?.versionId);
|
|
216
|
+
this.#versionTime = validateVersionTime(options?.versionTime);
|
|
158
217
|
// Discovery is unbounded by default; a positive maxDiscoveryRounds opts into a
|
|
159
218
|
// finite resource guard. A non-positive or omitted value means no limit.
|
|
160
219
|
const rounds = options?.maxDiscoveryRounds;
|
|
161
220
|
this.#maxDiscoveryRounds = typeof rounds === 'number' && rounds > 0 ? rounds : Infinity;
|
|
162
|
-
// The signal confirmation threshold.
|
|
163
|
-
// data need is emitted, so the caller does no I/O for a request it cannot serve.
|
|
221
|
+
// The signal confirmation threshold.
|
|
164
222
|
this.#minConf = validateMinConf(options?.minConf);
|
|
165
223
|
// If a genesis document was provided (from sidecar), pre-seed it for validation
|
|
166
224
|
if (options?.genesisDocument) {
|
|
@@ -206,14 +264,15 @@ export class Resolver {
|
|
|
206
264
|
* @param {DidComponents} didComponents BTCR2 DID components used to resolve the DID Document
|
|
207
265
|
* @param {object} genesisDocument The genesis document for resolving the DID Document.
|
|
208
266
|
* @returns {DidDocument} The resolved DID Document object
|
|
209
|
-
* @throws {ResolveError}
|
|
267
|
+
* @throws {ResolveError} `INVALID_DID` if the hash of the genesis document is not the genesis bytes of the identifier
|
|
210
268
|
*/
|
|
211
269
|
static external(didComponents, genesisDocument) {
|
|
212
270
|
// Canonicalize and sha256 hash the genesis document
|
|
213
271
|
const genesisDocumentHash = canonicalHashBytes(genesisDocument);
|
|
214
|
-
// Compare genesis bytes from identifier against the document hash (byte comparison)
|
|
272
|
+
// Compare genesis bytes from identifier against the document hash (byte comparison).
|
|
273
|
+
// The specification raises INVALID_DID when the computed hash does not match genesis_bytes.
|
|
215
274
|
if (!equalBytes(didComponents.genesisBytes, genesisDocumentHash)) {
|
|
216
|
-
throw new ResolveError(`Initial document mismatch: genesisBytes !== genesisDocumentHash`,
|
|
275
|
+
throw new ResolveError(`Initial document mismatch: genesisBytes !== genesisDocumentHash`, INVALID_DID, {
|
|
217
276
|
genesisBytes: encodeHash(didComponents.genesisBytes, 'hex'),
|
|
218
277
|
genesisDocumentHash: encodeHash(genesisDocumentHash, 'hex')
|
|
219
278
|
});
|
|
@@ -253,125 +312,7 @@ export class Resolver {
|
|
|
253
312
|
return { updateMap, casMap, smtMap };
|
|
254
313
|
}
|
|
255
314
|
/**
|
|
256
|
-
* Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#
|
|
257
|
-
* @param {DidDocument} currentDocument The current DID Document to apply the updates to.
|
|
258
|
-
* @param {Array<[SignedBTCR2Update, BlockMetadata]>} unsortedUpdates The unsorted array of BTCR2 Signed Updates and their associated Block Metadata.
|
|
259
|
-
* @param {string} [versionTime] The optional version time to limit updates to.
|
|
260
|
-
* @param {string} [versionId] The optional version id to limit updates to.
|
|
261
|
-
* @param {{ currentVersionId: number; updateHashHistory: HashBytes[] }} [resolutionState]
|
|
262
|
-
* Version counter and update-hash history carried from earlier discovery rounds.
|
|
263
|
-
* Standalone callers omit it and start fresh at version 1 with an empty history.
|
|
264
|
-
* @returns {DidResolutionResponse} The updated DID Document, number of confirmations, and version id.
|
|
265
|
-
*
|
|
266
|
-
* Confirmation depth is not checked here. The BeaconProcess phase excludes a
|
|
267
|
-
* signal below `ResolutionOptions.minConf` before its update reaches this method,
|
|
268
|
-
* so every tuple here comes from a block at or above the threshold.
|
|
269
|
-
*/
|
|
270
|
-
static updates(currentDocument, unsortedUpdates, versionTime, versionId, resolutionState = { currentVersionId: 1, updateHashHistory: [] }) {
|
|
271
|
-
// Continue the version counter and update-hash history from earlier discovery
|
|
272
|
-
// rounds so the whole resolution is one monotonic sequence, matching the spec's
|
|
273
|
-
// single signal-processing loop. updateHashHistory is shared by reference, so the
|
|
274
|
-
// appends made below are visible to the next round.
|
|
275
|
-
let currentVersionId = resolutionState.currentVersionId;
|
|
276
|
-
const updateHashHistory = resolutionState.updateHashHistory;
|
|
277
|
-
// 1. Sort updates by targetVersionId (ascending), using blockheight as tie-breaker
|
|
278
|
-
const updates = unsortedUpdates.sort(([upd0, blk0], [upd1, blk1]) => upd0.targetVersionId - upd1.targetVersionId || blk0.height - blk1.height);
|
|
279
|
-
// Create a default response object
|
|
280
|
-
const response = {
|
|
281
|
-
didDocument: currentDocument,
|
|
282
|
-
metadata: {
|
|
283
|
-
versionId: `${currentVersionId}`,
|
|
284
|
-
confirmations: 0,
|
|
285
|
-
updated: '',
|
|
286
|
-
deactivated: currentDocument.deactivated || false
|
|
287
|
-
}
|
|
288
|
-
};
|
|
289
|
-
// Iterate over each (update block) pair
|
|
290
|
-
for (const [update, block] of updates) {
|
|
291
|
-
// Get the hash of the current document as raw bytes
|
|
292
|
-
const currentDocumentHash = canonicalHashBytes(response.didDocument);
|
|
293
|
-
// Safely convert block.time to timestamp
|
|
294
|
-
const blocktime = DateUtils.blocktimeToTimestamp(block.time);
|
|
295
|
-
// Set the updated field to the blocktime of the current update
|
|
296
|
-
response.metadata.updated = DateUtils.toISOStringNonFractional(blocktime);
|
|
297
|
-
// Set confirmations to the block confirmations
|
|
298
|
-
response.metadata.confirmations = block.confirmations;
|
|
299
|
-
// Check update.targetVersionId against currentVersionId.
|
|
300
|
-
// If update.targetVersionId <= currentVersionId, this update re-announces a version
|
|
301
|
-
// that has already been applied. Confirm it is a true duplicate, then skip it: a
|
|
302
|
-
// duplicate does not advance the version counter (the increment and the
|
|
303
|
-
// metadata.versionId it sets run only on the apply path below), and confirmation
|
|
304
|
-
// compares against the update-hash history without appending to it, because the
|
|
305
|
-
// history already holds the applied update at updateHashHistory[targetVersionId - 2].
|
|
306
|
-
// Holding the increment off the duplicate path is the deliberate did:btcr2 deviation
|
|
307
|
-
// recorded in ADR 067: the read algorithm's "Increment current_version_id" belongs
|
|
308
|
-
// to the apply branch, not to every tuple. Duplicates are confirmed whatever their
|
|
309
|
-
// blocktime, before the versionTime check below, so a re-announcement mined after
|
|
310
|
-
// versionTime can neither truncate the in-window history nor dodge late-publishing
|
|
311
|
-
// detection (ADR 068).
|
|
312
|
-
if (update.targetVersionId <= currentVersionId) {
|
|
313
|
-
this.confirmDuplicate(update, updateHashHistory);
|
|
314
|
-
continue;
|
|
315
|
-
}
|
|
316
|
-
// if resolutionOptions.versionTime is defined and the blocktime is more recent, return
|
|
317
|
-
// currentDocument. Evaluated only for tuples that would change state (apply or late
|
|
318
|
-
// publishing). The spec places this check before the duplicate branch, where the sort
|
|
319
|
-
// by targetVersionId lets a duplicate of an early version mined after versionTime end
|
|
320
|
-
// resolution before genuine in-window updates are processed; checking it here is the
|
|
321
|
-
// deliberate deviation recorded in ADR 068.
|
|
322
|
-
if (versionTime) {
|
|
323
|
-
// Safely convert versionTime to timestamp
|
|
324
|
-
if (blocktime > DateUtils.dateStringToTimestamp(versionTime)) {
|
|
325
|
-
return response;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
// If update.targetVersionId == currentVersionId + 1, apply the update
|
|
329
|
-
if (update.targetVersionId === currentVersionId + 1) {
|
|
330
|
-
// Check if update.sourceHash !== currentDocumentHash (byte comparison)
|
|
331
|
-
const sourceHashBytes = decodeHash(update.sourceHash, 'base64urlnopad');
|
|
332
|
-
if (!equalBytes(sourceHashBytes, currentDocumentHash)) {
|
|
333
|
-
throw new ResolveError(`Hash mismatch: update.sourceHash !== currentDocumentHash`, INVALID_DID_UPDATE, {
|
|
334
|
-
sourceHash: update.sourceHash,
|
|
335
|
-
currentDocumentHash: encodeHash(currentDocumentHash, 'hex')
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
// Apply the update to the currentDocument and set it in the response
|
|
339
|
-
response.didDocument = this.applyUpdate(response.didDocument, update);
|
|
340
|
-
// Create unsigned_update by removing the proof property from update.
|
|
341
|
-
const unsignedUpdate = JSONUtils.deleteKeys(update, ['proof']);
|
|
342
|
-
// Push the canonicalized unsigned update hash bytes to the updateHashHistory
|
|
343
|
-
updateHashHistory.push(canonicalHashBytes(unsignedUpdate));
|
|
344
|
-
}
|
|
345
|
-
// Otherwise update.targetVersionId > currentVersionId + 1: a version was skipped,
|
|
346
|
-
// so throw LATE_PUBLISHING error. The duplicate case already continued above.
|
|
347
|
-
else {
|
|
348
|
-
throw new ResolveError(`Version Id Mismatch: targetVersionId cannot be > currentVersionId + 1`, LATE_PUBLISHING_ERROR, {
|
|
349
|
-
targetVersionId: update.targetVersionId,
|
|
350
|
-
currentVersionId: currentVersionId + 1
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
// Increment currentVersionId
|
|
354
|
-
currentVersionId++;
|
|
355
|
-
// Set response.versionId to be the new currentVersionId
|
|
356
|
-
response.metadata.versionId = `${currentVersionId}`;
|
|
357
|
-
// If resolutionOptions.versionId is defined and <= currentVersionId, return currentDocument
|
|
358
|
-
const versionIdNumber = Number(versionId);
|
|
359
|
-
if (!isNaN(versionIdNumber) && versionIdNumber <= currentVersionId) {
|
|
360
|
-
return response;
|
|
361
|
-
}
|
|
362
|
-
// Check if the current document is deactivated before further processing
|
|
363
|
-
if (response.didDocument.deactivated) {
|
|
364
|
-
// Set the response deactivated flag to true
|
|
365
|
-
response.metadata.deactivated = response.didDocument.deactivated;
|
|
366
|
-
// If deactivated, stop processing further updates and return the response
|
|
367
|
-
return response;
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
// Return response data
|
|
371
|
-
return response;
|
|
372
|
-
}
|
|
373
|
-
/**
|
|
374
|
-
* Implements subsection {@link https://dcdpr.github.io/did-btcr2/#confirm-duplicate-update | 7.2.f.1 Confirm Duplicate Update}.
|
|
315
|
+
* Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#confirm-duplicate-update | Confirm Duplicate Update}.
|
|
375
316
|
* This step confirms that an update with a lower-than-expected targetVersionId is a true duplicate.
|
|
376
317
|
* @param {SignedBTCR2Update} update The BTCR2 Signed Update to confirm as a duplicate.
|
|
377
318
|
* @param {HashBytes[]} updateHashHistory The accumulated hash history for comparison.
|
|
@@ -410,14 +351,24 @@ export class Resolver {
|
|
|
410
351
|
}
|
|
411
352
|
}
|
|
412
353
|
/**
|
|
413
|
-
* Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#apply-update |
|
|
354
|
+
* Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#apply-update | Apply update}
|
|
414
355
|
* and its step {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#check-update-proof | Check update.proof}.
|
|
415
356
|
* @param {DidDocument} currentDocument The current DID Document to apply the update to.
|
|
416
357
|
* @param {SignedBTCR2Update} update The BTCR2 Signed Update to apply.
|
|
417
358
|
* @returns {DidDocument} The updated DID Document after applying the update.
|
|
418
|
-
* @throws {ResolveError}
|
|
359
|
+
* @throws {ResolveError} `INVALID_DID_UPDATE` if the update is invalid or cannot be applied.
|
|
419
360
|
*/
|
|
420
361
|
static applyUpdate(currentDocument, update) {
|
|
362
|
+
// Spec "Apply update": the hash of the current document must be the decoded
|
|
363
|
+
// update.sourceHash (byte comparison).
|
|
364
|
+
const currentDocumentHash = canonicalHashBytes(currentDocument);
|
|
365
|
+
const sourceHashBytes = decodeHash(update.sourceHash, 'base64urlnopad');
|
|
366
|
+
if (!equalBytes(sourceHashBytes, currentDocumentHash)) {
|
|
367
|
+
throw new ResolveError(`Hash mismatch: update.sourceHash !== currentDocumentHash`, INVALID_DID_UPDATE, {
|
|
368
|
+
sourceHash: update.sourceHash,
|
|
369
|
+
currentDocumentHash: encodeHash(currentDocumentHash, 'hex')
|
|
370
|
+
});
|
|
371
|
+
}
|
|
421
372
|
// Spec "Check update.proof": the update @context must be the array that the BTCR2
|
|
422
373
|
// Unsigned Update data structure pins, and the proof @context must equal it, member
|
|
423
374
|
// for member and in order. The array is inside the hashed and signed bytes, so an
|
|
@@ -489,14 +440,14 @@ export class Resolver {
|
|
|
489
440
|
const updatedDocument = JSONPatch.apply(currentDocument, update.patch);
|
|
490
441
|
// Verify that updatedDocument is conformant to DID Core v1.1.
|
|
491
442
|
DidDocument.validate(updatedDocument);
|
|
492
|
-
// Canonicalize and hash the updatedDocument
|
|
493
|
-
const
|
|
494
|
-
// Prepare the update targetHash for comparison with
|
|
443
|
+
// Canonicalize and hash the updatedDocument (raw bytes).
|
|
444
|
+
const updatedDocumentHash = canonicalHashBytes(updatedDocument);
|
|
445
|
+
// Prepare the update targetHash for comparison with updatedDocumentHash.
|
|
495
446
|
const updateTargetHash = decodeHash(update.targetHash);
|
|
496
|
-
// Make sure the update.targetHash equals
|
|
497
|
-
if (!equalBytes(updateTargetHash,
|
|
447
|
+
// Make sure the update.targetHash equals updatedDocumentHash.
|
|
448
|
+
if (!equalBytes(updateTargetHash, updatedDocumentHash)) {
|
|
498
449
|
// If they do not match, throw INVALID_DID_UPDATE error.
|
|
499
|
-
throw new ResolveError(`Invalid update: update.targetHash !==
|
|
450
|
+
throw new ResolveError(`Invalid update: update.targetHash !== updatedDocumentHash`, INVALID_DID_UPDATE, { updateTargetHash, updatedDocumentHash });
|
|
500
451
|
}
|
|
501
452
|
// Return final updatedDocument.
|
|
502
453
|
return updatedDocument;
|
|
@@ -585,64 +536,118 @@ export class Resolver {
|
|
|
585
536
|
if (allNeeds.length > 0) {
|
|
586
537
|
return { status: 'action-required', needs: allNeeds };
|
|
587
538
|
}
|
|
588
|
-
this.#phase = ResolverPhase.
|
|
539
|
+
this.#phase = ResolverPhase.ProcessUpdate;
|
|
589
540
|
continue;
|
|
590
541
|
}
|
|
591
|
-
// Phase:
|
|
592
|
-
//
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
542
|
+
// Phase: ProcessUpdate
|
|
543
|
+
// Spec "Process Next Update": one tuple per step. The phase repeats until
|
|
544
|
+
// the document resolves, or until an applied update adds a beacon address
|
|
545
|
+
// that the resolver did not scan (then the pass returns to BeaconDiscovery).
|
|
546
|
+
case ResolverPhase.ProcessUpdate: {
|
|
547
|
+
const document = this.#currentDocument;
|
|
548
|
+
// Step 1: the requested version is reached. The test runs before Apply,
|
|
549
|
+
// so version 1 is reachable.
|
|
550
|
+
if (this.#versionId !== undefined && this.#currentVersionId === this.#versionId) {
|
|
551
|
+
this.#phase = ResolverPhase.Complete;
|
|
552
|
+
continue;
|
|
553
|
+
}
|
|
554
|
+
// Step 2: no tuple is left, or the document is deactivated. A requested
|
|
555
|
+
// version that the history does not reach is NOT_FOUND.
|
|
556
|
+
if (this.#unsortedUpdates.length === 0 || document.deactivated) {
|
|
557
|
+
if (this.#versionId !== undefined) {
|
|
558
|
+
throw new ResolveError(`Version ${this.#versionId} of the DID does not exist: the history `
|
|
559
|
+
+ (document.deactivated
|
|
560
|
+
? `ends with the deactivation at version ${this.#currentVersionId}.`
|
|
561
|
+
: `ends at version ${this.#currentVersionId}.`), NOT_FOUND, { versionId: this.#versionId, currentVersionId: this.#currentVersionId });
|
|
562
|
+
}
|
|
563
|
+
this.#phase = ResolverPhase.Complete;
|
|
564
|
+
continue;
|
|
565
|
+
}
|
|
566
|
+
// Step 3: sort the tuples by targetVersionId (ascending), then by block
|
|
567
|
+
// height, and remove the first one. The sort runs on every step because
|
|
568
|
+
// a scan between two steps can add a tuple with a lower version.
|
|
569
|
+
this.#unsortedUpdates.sort(([upd0, blk0], [upd1, blk1]) => upd0.targetVersionId - upd1.targetVersionId || blk0.height - blk1.height);
|
|
570
|
+
const [update, block] = this.#unsortedUpdates.shift();
|
|
571
|
+
// Check targetVersionId, first arm: update.targetVersionId <= currentVersionId
|
|
572
|
+
// re-announces an applied version. Confirm that it is a true duplicate, then
|
|
573
|
+
// skip it. A duplicate does not advance the version counter, does not append
|
|
574
|
+
// to the history (the slot already holds the applied update, ADR 067), and
|
|
575
|
+
// does not stamp the metadata: confirmations refers to the block of the most
|
|
576
|
+
// recently applied unique update. The branch runs before the versionTime
|
|
577
|
+
// test (ADR 068): a re-announcement mined after versionTime can neither end
|
|
578
|
+
// the resolution early nor dodge late-publishing detection.
|
|
579
|
+
if (update.targetVersionId <= this.#currentVersionId) {
|
|
580
|
+
Resolver.confirmDuplicate(update, this.#updateHashHistory);
|
|
581
|
+
continue;
|
|
582
|
+
}
|
|
583
|
+
// Step 4: the versionTime stop. The block mediantime of the tuple is after
|
|
584
|
+
// versionTime: resolve the current document. The boundary is inclusive, so a
|
|
585
|
+
// tuple whose mediantime equals versionTime applies. The stopped tuple stamps
|
|
586
|
+
// nothing: the metadata reports the last applied update.
|
|
587
|
+
if (this.#versionTime !== undefined && block.mediantime * 1000 > this.#versionTime) {
|
|
588
|
+
this.#phase = ResolverPhase.Complete;
|
|
589
|
+
continue;
|
|
590
|
+
}
|
|
591
|
+
// Check targetVersionId, third arm: a version was skipped, so raise LATE_PUBLISHING.
|
|
592
|
+
if (update.targetVersionId !== this.#currentVersionId + 1) {
|
|
593
|
+
throw new ResolveError(`Version Id Mismatch: targetVersionId cannot be > currentVersionId + 1`, LATE_PUBLISHING_ERROR, {
|
|
594
|
+
targetVersionId: update.targetVersionId,
|
|
595
|
+
currentVersionId: this.#currentVersionId + 1
|
|
610
596
|
});
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
597
|
+
}
|
|
598
|
+
// Second arm: update.targetVersionId == currentVersionId + 1. Apply the update,
|
|
599
|
+
// append the unsigned update hash to the history, increment the version.
|
|
600
|
+
this.#currentDocument = Resolver.applyUpdate(document, update);
|
|
601
|
+
const unsignedUpdate = JSONUtils.deleteKeys(update, ['proof']);
|
|
602
|
+
this.#updateHashHistory.push(canonicalHashBytes(unsignedUpdate));
|
|
603
|
+
this.#currentVersionId++;
|
|
604
|
+
// Step 5: block_confirmations, and the header time as `updated`. On the apply
|
|
605
|
+
// path only: the stop above and the duplicate branch stamp nothing.
|
|
606
|
+
this.#blockConfirmations = block.confirmations;
|
|
607
|
+
this.#updated = DateUtils.toISOStringNonFractional(DateUtils.blocktimeToTimestamp(block.time));
|
|
608
|
+
// The applied update can add a beacon service. "Find Beacon Signals" runs at
|
|
609
|
+
// the top of every pass for the addresses that are not scanned yet, so the
|
|
610
|
+
// pass returns to BeaconDiscovery before the next tuple. Discovery is
|
|
611
|
+
// unbounded by default: termination is guaranteed by address
|
|
612
|
+
// de-duplication (#requestCache). An opt-in maxDiscoveryRounds lets a caller
|
|
613
|
+
// bound the work as a resource guard. Exceeding it is a limit the caller
|
|
614
|
+
// imposed, not a malformed document, so it surfaces as INTERNAL_ERROR.
|
|
615
|
+
if (this.#hasUnscannedBeacons()) {
|
|
616
|
+
if (++this.#discoveryRounds > this.#maxDiscoveryRounds) {
|
|
617
|
+
throw new ResolveError(`Exceeded the configured maximum of ${this.#maxDiscoveryRounds} beacon-discovery `
|
|
618
|
+
+ 'rounds. Raise or remove ResolutionOptions.maxDiscoveryRounds to resolve this DID.', INTERNAL_ERROR, { maxDiscoveryRounds: this.#maxDiscoveryRounds, discoveryRounds: this.#discoveryRounds });
|
|
625
619
|
}
|
|
620
|
+
this.#phase = ResolverPhase.BeaconDiscovery;
|
|
626
621
|
}
|
|
627
|
-
this.#phase = ResolverPhase.Complete;
|
|
628
622
|
continue;
|
|
629
623
|
}
|
|
630
624
|
// Phase: Complete
|
|
625
|
+
// The document metadata of the specification: versionId is current_version_id,
|
|
626
|
+
// confirmations is block_confirmations (0 when no update applied), deactivated
|
|
627
|
+
// is the flag of the document. `updated` is present after the first apply.
|
|
631
628
|
case ResolverPhase.Complete: {
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
}
|
|
629
|
+
this.#resolvedResponse ??= {
|
|
630
|
+
didDocument: this.#currentDocument,
|
|
631
|
+
metadata: {
|
|
632
|
+
versionId: `${this.#currentVersionId}`,
|
|
633
|
+
confirmations: this.#blockConfirmations,
|
|
634
|
+
...(this.#updated !== undefined ? { updated: this.#updated } : {}),
|
|
635
|
+
deactivated: this.#currentDocument.deactivated || false
|
|
640
636
|
}
|
|
641
637
|
};
|
|
638
|
+
return { status: 'resolved', result: this.#resolvedResponse };
|
|
642
639
|
}
|
|
643
640
|
}
|
|
644
641
|
}
|
|
645
642
|
}
|
|
643
|
+
/**
|
|
644
|
+
* True if the current document carries a beacon service whose address the resolver
|
|
645
|
+
* did not request signals for. "Find Beacon Signals" scans such an address on the
|
|
646
|
+
* next pass.
|
|
647
|
+
*/
|
|
648
|
+
#hasUnscannedBeacons() {
|
|
649
|
+
return BeaconUtils.getBeaconServices(this.#currentDocument).some(service => !this.#requestCache.has(BeaconUtils.parseBitcoinAddress(service.serviceEndpoint)));
|
|
650
|
+
}
|
|
646
651
|
/**
|
|
647
652
|
* Return the signals of one beacon service that resolution may process: the
|
|
648
653
|
* signals with at least `#minConf` confirmations. The specification removes a
|
|
@@ -651,10 +656,11 @@ export class Resolver {
|
|
|
651
656
|
* integer confirmation count is excluded too: that is a mempool transaction
|
|
652
657
|
* from a driver that did not skip it.
|
|
653
658
|
*
|
|
654
|
-
* An eligible signal must carry a finite block height
|
|
655
|
-
* signal that passes the count but lacks them is
|
|
656
|
-
* here with a typed error, in the style of the
|
|
657
|
-
* not later with an invalid date
|
|
659
|
+
* An eligible signal must carry a finite block height, block time, and block
|
|
660
|
+
* median time past. A signal that passes the count but lacks them is
|
|
661
|
+
* malformed. It fails fast here with a typed error, in the style of the
|
|
662
|
+
* {@link provide} guards, and not later with an invalid date or a false
|
|
663
|
+
* `versionTime` comparison in the ProcessUpdate phase.
|
|
658
664
|
* @param {Array<BeaconSignal>} signals The signals the caller provided for one service.
|
|
659
665
|
* @returns {Array<BeaconSignal>} The signals at or above the threshold, in the given order.
|
|
660
666
|
* @throws {ResolveError} `INVALID_DID_UPDATE` for an eligible signal with no valid block metadata.
|
|
@@ -667,9 +673,15 @@ export class Resolver {
|
|
|
667
673
|
if (!Number.isInteger(confirmations) || confirmations < this.#minConf) {
|
|
668
674
|
continue;
|
|
669
675
|
}
|
|
670
|
-
if (!Number.isFinite(block?.height) || !Number.isFinite(block?.time)) {
|
|
676
|
+
if (!Number.isFinite(block?.height) || !Number.isFinite(block?.time) || !Number.isFinite(block?.mediantime)) {
|
|
671
677
|
throw new ResolveError(`Beacon signal ${signal.signalBytes} has ${confirmations} confirmations `
|
|
672
|
-
+ 'but no valid block height or block
|
|
678
|
+
+ 'but no valid block height, block time, or block mediantime.', INVALID_DID_UPDATE, {
|
|
679
|
+
signalBytes: signal.signalBytes,
|
|
680
|
+
confirmations,
|
|
681
|
+
height: block?.height,
|
|
682
|
+
time: block?.time,
|
|
683
|
+
mediantime: block?.mediantime
|
|
684
|
+
});
|
|
673
685
|
}
|
|
674
686
|
eligible.push(signal);
|
|
675
687
|
}
|