@did-btcr2/method 0.19.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +715 -1445
- package/dist/browser.mjs +715 -1445
- package/dist/cjs/core/beacon/beacon.js +25 -0
- package/dist/cjs/core/beacon/beacon.js.map +1 -0
- package/dist/cjs/core/beacon/cas-beacon.js +20 -36
- package/dist/cjs/core/beacon/cas-beacon.js.map +1 -1
- package/dist/cjs/core/beacon/error.js +4 -4
- package/dist/cjs/core/beacon/error.js.map +1 -1
- package/dist/cjs/core/beacon/factory.js +5 -7
- package/dist/cjs/core/beacon/factory.js.map +1 -1
- package/dist/cjs/core/beacon/interfaces.js +1 -31
- package/dist/cjs/core/beacon/interfaces.js.map +1 -1
- package/dist/cjs/core/beacon/signal-discovery.js +183 -0
- package/dist/cjs/core/beacon/signal-discovery.js.map +1 -0
- package/dist/cjs/core/beacon/singleton.js +54 -81
- package/dist/cjs/core/beacon/singleton.js.map +1 -1
- package/dist/cjs/core/beacon/smt-beacon.js +22 -39
- package/dist/cjs/core/beacon/smt-beacon.js.map +1 -1
- package/dist/cjs/core/beacon/utils.js +4 -9
- package/dist/cjs/core/beacon/utils.js.map +1 -1
- package/dist/cjs/core/resolve.js +87 -277
- package/dist/cjs/core/resolve.js.map +1 -1
- package/dist/cjs/core/update.js +62 -153
- package/dist/cjs/core/update.js.map +1 -1
- package/dist/cjs/did-btcr2.js +80 -75
- package/dist/cjs/did-btcr2.js.map +1 -1
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils/appendix.js +6 -15
- package/dist/cjs/utils/appendix.js.map +1 -1
- package/dist/cjs/utils/did-document-builder.js +5 -0
- package/dist/cjs/utils/did-document-builder.js.map +1 -1
- package/dist/cjs/utils/did-document.js +11 -14
- package/dist/cjs/utils/did-document.js.map +1 -1
- package/dist/esm/core/beacon/beacon.js +25 -0
- package/dist/esm/core/beacon/beacon.js.map +1 -0
- package/dist/esm/core/beacon/cas-beacon.js +20 -36
- package/dist/esm/core/beacon/cas-beacon.js.map +1 -1
- package/dist/esm/core/beacon/error.js +4 -4
- package/dist/esm/core/beacon/error.js.map +1 -1
- package/dist/esm/core/beacon/factory.js +5 -7
- package/dist/esm/core/beacon/factory.js.map +1 -1
- package/dist/esm/core/beacon/interfaces.js +1 -31
- package/dist/esm/core/beacon/interfaces.js.map +1 -1
- package/dist/esm/core/beacon/signal-discovery.js +183 -0
- package/dist/esm/core/beacon/signal-discovery.js.map +1 -0
- package/dist/esm/core/beacon/singleton.js +54 -81
- package/dist/esm/core/beacon/singleton.js.map +1 -1
- package/dist/esm/core/beacon/smt-beacon.js +22 -39
- package/dist/esm/core/beacon/smt-beacon.js.map +1 -1
- package/dist/esm/core/beacon/utils.js +4 -9
- package/dist/esm/core/beacon/utils.js.map +1 -1
- package/dist/esm/core/resolve.js +87 -277
- package/dist/esm/core/resolve.js.map +1 -1
- package/dist/esm/core/update.js +62 -153
- package/dist/esm/core/update.js.map +1 -1
- package/dist/esm/did-btcr2.js +80 -75
- package/dist/esm/did-btcr2.js.map +1 -1
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/appendix.js +6 -15
- package/dist/esm/utils/appendix.js.map +1 -1
- package/dist/esm/utils/did-document-builder.js +5 -0
- package/dist/esm/utils/did-document-builder.js.map +1 -1
- package/dist/esm/utils/did-document.js +11 -14
- package/dist/esm/utils/did-document.js.map +1 -1
- package/dist/types/core/beacon/beacon.d.ts +44 -0
- package/dist/types/core/beacon/beacon.d.ts.map +1 -0
- package/dist/types/core/beacon/cas-beacon.d.ts +19 -30
- package/dist/types/core/beacon/cas-beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/error.d.ts +2 -2
- package/dist/types/core/beacon/error.d.ts.map +1 -1
- package/dist/types/core/beacon/factory.d.ts +4 -6
- package/dist/types/core/beacon/factory.d.ts.map +1 -1
- package/dist/types/core/beacon/interfaces.d.ts +7 -46
- package/dist/types/core/beacon/interfaces.d.ts.map +1 -1
- package/dist/types/core/beacon/signal-discovery.d.ts +25 -0
- package/dist/types/core/beacon/signal-discovery.d.ts.map +1 -0
- package/dist/types/core/beacon/singleton.d.ts +16 -29
- package/dist/types/core/beacon/singleton.d.ts.map +1 -1
- package/dist/types/core/beacon/smt-beacon.d.ts +21 -33
- package/dist/types/core/beacon/smt-beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/utils.d.ts.map +1 -1
- package/dist/types/core/interfaces.d.ts +1 -8
- package/dist/types/core/interfaces.d.ts.map +1 -1
- package/dist/types/core/resolve.d.ts +27 -43
- package/dist/types/core/resolve.d.ts.map +1 -1
- package/dist/types/core/types.d.ts +21 -8
- package/dist/types/core/types.d.ts.map +1 -1
- package/dist/types/core/update.d.ts +30 -73
- package/dist/types/core/update.d.ts.map +1 -1
- package/dist/types/did-btcr2.d.ts +37 -44
- package/dist/types/did-btcr2.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/utils/appendix.d.ts.map +1 -1
- package/dist/types/utils/did-document-builder.d.ts +5 -0
- package/dist/types/utils/did-document-builder.d.ts.map +1 -1
- package/dist/types/utils/did-document.d.ts +16 -14
- package/dist/types/utils/did-document.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/core/beacon/beacon.ts +58 -0
- package/src/core/beacon/cas-beacon.ts +30 -44
- package/src/core/beacon/error.ts +5 -6
- package/src/core/beacon/factory.ts +7 -9
- package/src/core/beacon/interfaces.ts +7 -64
- package/src/core/beacon/signal-discovery.ts +237 -0
- package/src/core/beacon/singleton.ts +74 -94
- package/src/core/beacon/smt-beacon.ts +32 -49
- package/src/core/beacon/utils.ts +16 -13
- package/src/core/interfaces.ts +1 -9
- package/src/core/resolve.ts +116 -360
- package/src/core/types.ts +25 -8
- package/src/core/update.ts +90 -235
- package/src/did-btcr2.ts +131 -95
- package/src/index.ts +8 -1
- package/src/utils/appendix.ts +8 -22
- package/src/utils/did-document-builder.ts +5 -0
- package/src/utils/did-document.ts +41 -45
|
@@ -1,48 +1,36 @@
|
|
|
1
1
|
import { BitcoinNetworkConnection } from '@did-btcr2/bitcoin';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { KeyBytes } from '@did-btcr2/common';
|
|
3
|
+
import { SignedBTCR2Update } from '@did-btcr2/cryptosuite';
|
|
4
4
|
import { SidecarData } from '../types.js';
|
|
5
|
-
import {
|
|
5
|
+
import { Beacon } from './beacon.js';
|
|
6
|
+
import { BeaconService, BeaconSignal, BlockMetadata } from './interfaces.js';
|
|
6
7
|
/**
|
|
7
|
-
* TODO: Finish implementation
|
|
8
8
|
* Implements {@link https://dcdpr.github.io/did-btcr2/terminology.html#smt-beacon | SMTBeacon}.
|
|
9
9
|
* @class SMTBeacon
|
|
10
10
|
* @type {SMTBeacon}
|
|
11
|
-
* @extends {
|
|
11
|
+
* @extends {Beacon}
|
|
12
12
|
*/
|
|
13
|
-
export declare class SMTBeacon extends
|
|
13
|
+
export declare class SMTBeacon extends Beacon {
|
|
14
14
|
/**
|
|
15
|
-
* Creates an instance of
|
|
15
|
+
* Creates an instance of SMTBeacon.
|
|
16
16
|
* @param {BeaconService} service The Beacon service.
|
|
17
|
-
* @param {Array<BeaconSignal>} signals The SingletonBeacon sidecar data.
|
|
18
|
-
* @param {SidecarData} sidecar The sidecar data.
|
|
19
17
|
*/
|
|
20
|
-
constructor(service: BeaconService
|
|
18
|
+
constructor(service: BeaconService);
|
|
21
19
|
/**
|
|
22
|
-
*
|
|
23
|
-
* @param {
|
|
24
|
-
* @param {SidecarData} sidecar The sidecar data.
|
|
25
|
-
* @returns {
|
|
20
|
+
* Implements {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#process-smt-beacon | 7.2.e.1 Process SMT Beacon}.
|
|
21
|
+
* @param {Array<BeaconSignal>} signals The array of Beacon Signals to process.
|
|
22
|
+
* @param {SidecarData} sidecar The sidecar data associated with the SMT Beacon.
|
|
23
|
+
* @returns {Promise<Array<[SignedBTCR2Update, BlockMetadata]>>} The processed signals.
|
|
24
|
+
* @throws {SMTBeaconError} if processing fails.
|
|
26
25
|
*/
|
|
27
|
-
|
|
26
|
+
processSignals(signals: Array<BeaconSignal>, sidecar: SidecarData): Promise<Array<[SignedBTCR2Update, BlockMetadata]>>;
|
|
28
27
|
/**
|
|
29
|
-
*
|
|
30
|
-
* @param {
|
|
31
|
-
* @
|
|
32
|
-
* @
|
|
28
|
+
* Broadcast CAS Beacon signal to the Bitcoin network.
|
|
29
|
+
* @param {SignedBTCR2Update} signedUpdate The signed BTCR2 update to broadcast.
|
|
30
|
+
* @param {KeyBytes} secretKey The secret key for signing the Bitcoin transaction.
|
|
31
|
+
* @param {BitcoinNetworkConnection} bitcoin The Bitcoin network connection.
|
|
32
|
+
* @return {Promise<SignedBTCR2Update>} The signed update that was broadcasted.
|
|
33
|
+
* @throws {SMTBeaconError} if broadcasting fails.
|
|
33
34
|
*/
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Process SMTBeacon signals.
|
|
37
|
-
* @returns {Promise<Array<BTCR2SignedUpdate>>} The processed signed update or undefined.
|
|
38
|
-
* @throws {MethodError} if the signal processing fails.
|
|
39
|
-
*/
|
|
40
|
-
processSignals(): Promise<Array<[BTCR2SignedUpdate, BlockMetadata]>>;
|
|
41
|
-
/**
|
|
42
|
-
* Broadcast a SMTBeacon signal.
|
|
43
|
-
* @param {HexString} updateHash The hash of the BTCR2 update to broadcast.
|
|
44
|
-
* @returns {Promise<SignalsMetadata>} The result of the broadcast.
|
|
45
|
-
* @throws {MethodError} if the broadcast fails.
|
|
46
|
-
*/
|
|
47
|
-
broadcastSignal(updateHash: HexString): Promise<HexString>;
|
|
35
|
+
broadcastSignal(signedUpdate: SignedBTCR2Update, secretKey: KeyBytes, bitcoin: BitcoinNetworkConnection): Promise<SignedBTCR2Update>;
|
|
48
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smt-beacon.d.ts","sourceRoot":"","sources":["../../../../src/core/beacon/smt-beacon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"smt-beacon.d.ts","sourceRoot":"","sources":["../../../../src/core/beacon/smt-beacon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE7E;;;;;GAKG;AACH,qBAAa,SAAU,SAAQ,MAAM;IACnC;;;OAGG;gBACS,OAAO,EAAE,aAAa;IAIlC;;;;;;OAMG;IACH,cAAc,CACZ,OAAO,EAAE,KAAK,CAAC,YAAY,CAAC,EAC5B,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,KAAK,CAAC,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC,CAAC;IAIrD;;;;;;;OAOG;IACG,eAAe,CACnB,YAAY,EAAE,iBAAiB,EAC/B,SAAS,EAAE,QAAQ,EACnB,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,iBAAiB,CAAC;CAG9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/core/beacon/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,QAAQ,EAAE,KAAK,EAAe,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAY,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/core/beacon/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,QAAQ,EAAE,KAAK,EAAe,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAY,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD;;;;GAIG;AACH,qBAAa,WAAW;IACtB;;;;;OAKG;IACH,MAAM,CAAC,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAO/C;;;;OAIG;IACH,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,OAAO;IAc1D;;;;;OAKG;IACH,MAAM,CAAC,iBAAiB,CAAC,WAAW,EAAE,WAAW,GAAG,aAAa,EAAE;IAKnE;;;;;OAKG;IACH,MAAM,CAAC,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,KAAK,CAAC,aAAa,CAAC;IAiBlF;;;;;;;OAOG;IACH,MAAM,CAAC,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,aAAa;IAsBpH;;;;;OAKG;IACH,MAAM,CAAC,sBAAsB,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE;QACpE,EAAE,EAAE,MAAM,CAAC;QACX,SAAS,EAAE,QAAQ,CAAC;QACpB,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC;QAC1B,UAAU,EAAE,MAAM,CAAC;KACpB,GAAG,KAAK,CAAC,aAAa,CAAC;IAoCxB;;;;OAIG;IACH,MAAM,CAAC,0BAA0B,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa;IAIvE;;;;OAIG;IACH,MAAM,CAAC,oBAAoB,CAAC,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC;IAQtF;;;;OAIG;IACH,MAAM,CAAC,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,EAAE;CAG/D"}
|
|
@@ -38,16 +38,9 @@ export interface ResolutionOptions extends ResolutionOptionsCore {
|
|
|
38
38
|
/**
|
|
39
39
|
* Drivers for interacting with external systems, such as the Bitcoin network.
|
|
40
40
|
*/
|
|
41
|
-
drivers
|
|
41
|
+
drivers?: {
|
|
42
42
|
bitcoin?: BitcoinNetworkConnection;
|
|
43
43
|
};
|
|
44
|
-
/**
|
|
45
|
-
* Flag to signal a full blockchain search for beacon signals from genesis
|
|
46
|
-
* block to chain tip during resolution, instead of using an indexer.
|
|
47
|
-
* @type {boolean}
|
|
48
|
-
* @default false
|
|
49
|
-
*/
|
|
50
|
-
fullBlockchainTraversal?: boolean;
|
|
51
44
|
}
|
|
52
45
|
/**
|
|
53
46
|
* {@link https://dcdpr.github.io/did-btcr2/terminology.html#smt-proof | SMT Proof}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/core/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,MAAM,WAAW,cAAc;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;CAC5B;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAsB,SAAQ,oBAAoB;IACjE;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAkB,SAAQ,qBAAqB;IAC9D;;OAEG;IACH,OAAO,EAAE;
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/core/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,MAAM,WAAW,cAAc;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;CAC5B;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAsB,SAAQ,oBAAoB;IACjE;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAkB,SAAQ,qBAAqB;IAC9D;;OAEG;IACH,OAAO,CAAC,EAAE;QACR,OAAO,CAAC,EAAE,wBAAwB,CAAC;KACpC,CAAC;CACH;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BitcoinNetworkConnection } from '@did-btcr2/bitcoin';
|
|
2
|
-
import {
|
|
2
|
+
import { SignedBTCR2Update } from '@did-btcr2/cryptosuite';
|
|
3
3
|
import { DidDocument } from '../utils/did-document.js';
|
|
4
|
-
import { BeaconService,
|
|
4
|
+
import { BeaconService, BlockMetadata } from './beacon/interfaces.js';
|
|
5
5
|
import { DidComponents } from './identifier.js';
|
|
6
6
|
import { Sidecar, SidecarData } from './types.js';
|
|
7
7
|
/**
|
|
@@ -23,22 +23,6 @@ export interface DidResolutionResponse {
|
|
|
23
23
|
* @type {Resolve}
|
|
24
24
|
*/
|
|
25
25
|
export declare class Resolve {
|
|
26
|
-
/**
|
|
27
|
-
* Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#process-sidecar-data | Process Sidecar Data}
|
|
28
|
-
* @param {Sidecar} sidecar The sidecar data to process.
|
|
29
|
-
* @returns {SidecarData} The processed sidecar data containing maps of updates, CAS announcements, and SMT proofs.
|
|
30
|
-
*/
|
|
31
|
-
static processSidecarData(sidecar?: Sidecar): SidecarData;
|
|
32
|
-
/**
|
|
33
|
-
* Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#establish-current-document | 7.2.d Establish current_document}.
|
|
34
|
-
* Resolution begins by creating an Initial Did Document called current_document (Current DID Document).
|
|
35
|
-
* The current_document is iteratively patched with BTCR2 Signed Updates announced by Authorized Beacon Signals.
|
|
36
|
-
* @param {DidComponents} didComponents The decoded components of the did.
|
|
37
|
-
* @param {GenesisDocument} genesisDocument The genesis document for resolving the DID Document.
|
|
38
|
-
* @returns {Promise<DidDocument>} The resolved DID Document object.
|
|
39
|
-
* @throws {DidError} if the DID hrp is invalid, no sidecarData passed and hrp = "x".
|
|
40
|
-
*/
|
|
41
|
-
static establishCurrentDocument(didComponents: DidComponents, genesisDocument?: object): Promise<DidDocument>;
|
|
42
26
|
/**
|
|
43
27
|
* Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#if-genesis_bytes-is-a-secp256k1-public-key | 7.2.d.1 if genesis bytes is a secp256k1 Public Key}.
|
|
44
28
|
* @param {DidComponents} didComponents The decoded components of the did.
|
|
@@ -50,56 +34,56 @@ export declare class Resolve {
|
|
|
50
34
|
* @param {DidComponents} didComponents BTCR2 DID components used to resolve the DID Document
|
|
51
35
|
* @param {GenesisDocument} genesisDocument The genesis document for resolving the DID Document.
|
|
52
36
|
* @returns {Promise<DidDocument>} The resolved DID Document object
|
|
53
|
-
* @throws {
|
|
37
|
+
* @throws {ResolveError} InvalidDidDocument if not conformant to DID Core v1.1
|
|
54
38
|
*/
|
|
55
39
|
static external(didComponents: DidComponents, genesisDocument: object): Promise<DidDocument>;
|
|
40
|
+
/**
|
|
41
|
+
* Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#process-sidecar-data | Process Sidecar Data}
|
|
42
|
+
* @param {Sidecar} sidecar The sidecar data to process.
|
|
43
|
+
* @returns {ProcessedSidecar} The processed sidecar data containing maps of updates, CAS announcements, and SMT proofs.
|
|
44
|
+
*/
|
|
45
|
+
static sidecarData(sidecar?: Sidecar): SidecarData;
|
|
46
|
+
/**
|
|
47
|
+
* Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#establish-current-document | 7.2.d Establish current_document}.
|
|
48
|
+
* Resolution begins by creating an Initial Did Document called current_document (Current DID Document).
|
|
49
|
+
* The current_document is iteratively patched with BTCR2 Signed Updates announced by Authorized Beacon Signals.
|
|
50
|
+
* @param {DidComponents} didComponents The decoded components of the did.
|
|
51
|
+
* @param {GenesisDocument} genesisDocument The genesis document for resolving the DID Document.
|
|
52
|
+
* @returns {Promise<DidDocument>} The resolved DID Document object.
|
|
53
|
+
* @throws {ResolveError} if the DID hrp is invalid, no sidecarData passed and hrp = "x".
|
|
54
|
+
*/
|
|
55
|
+
static currentDocument(didComponents: DidComponents, genesisDocument?: object): Promise<DidDocument>;
|
|
56
56
|
/**
|
|
57
57
|
* Finds uses the beacon services in the currentDocument to scan for onchain Beacon Signals (transactions) containing
|
|
58
58
|
* Signal Bytes (last output in OP_RETURN transaction).
|
|
59
59
|
* @param {Array<BeaconService>} beaconServices The array of BeaconService objects to search for signals.
|
|
60
60
|
* @param {SidecarData} sidecarData The sidecar data containing maps of updates, CAS announcements, and SMT proofs.
|
|
61
61
|
* @param {BitcoinNetworkConnection} bitcoin The bitcoin network connection used to fetch beacon signals
|
|
62
|
-
* @
|
|
63
|
-
* @returns {Promise<Array<[BTCR2SignedUpdate, BlockMetadata]>>} The array of BTCR2 Signed Updates announced by the Beacon Signals.
|
|
62
|
+
* @returns {Promise<Array<[SignedBTCR2Update, BlockMetadata]>>} The array of BTCR2 Signed Updates announced by the Beacon Signals.
|
|
64
63
|
*/
|
|
65
|
-
static
|
|
64
|
+
static beaconSignals(beaconServices: Array<BeaconService>, sidecarData: SidecarData, bitcoin: BitcoinNetworkConnection): Promise<Array<[SignedBTCR2Update, BlockMetadata]>>;
|
|
66
65
|
/**
|
|
67
66
|
* Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#process-updates | 7.2.f Process updates Array}.
|
|
68
67
|
* @param {DidDocument} currentDocument The current DID Document to apply the updates to.
|
|
69
|
-
* @param {Array<[
|
|
68
|
+
* @param {Array<[SignedBTCR2Update, BlockMetadata]>} unsortedUpdates The unsorted array of BTCR2 Signed Updates and their associated Block Metadata.
|
|
70
69
|
* @param {string} [versionTime] The optional version time to limit updates to.
|
|
71
70
|
* @param {string} [versionId] The optional version id to limit updates to.
|
|
72
71
|
* @returns {Promise<DidResolutionResponse>} The updated DID Document, number of confirmations, and version id.
|
|
73
72
|
*/
|
|
74
|
-
static
|
|
75
|
-
/**
|
|
76
|
-
* Retrieves the beacon signals for the given array of BeaconService objects
|
|
77
|
-
* using a esplora/electrs REST API connection via a bitcoin I/O driver.
|
|
78
|
-
* @param {Array<BeaconService>} beaconServices Array of BeaconService objects to retrieve signals for
|
|
79
|
-
* @param {BitcoinNetworkConnection} bitcoin Bitcoin network connection to use for REST calls
|
|
80
|
-
* @returns {Promise<Array<BeaconSignal>>} Promise resolving to an array of BeaconSignal objects
|
|
81
|
-
*/
|
|
82
|
-
static queryBlockchainIndexer(beaconServices: Array<BeaconService>, bitcoin: BitcoinNetworkConnection): Promise<Map<BeaconService, Array<BeaconSignal>>>;
|
|
83
|
-
/**
|
|
84
|
-
* Traverse the full blockchain from genesis to chain top looking for beacon signals.
|
|
85
|
-
* @param {Array<BeaconService>} beaconServices Array of BeaconService objects to search for signals.
|
|
86
|
-
* @param {BitcoinNetworkConnection} bitcoin Bitcoin network connection to use for RPC calls.
|
|
87
|
-
* @returns {Promise<Array<BeaconSignal>>} Promise resolving to an array of BeaconSignal objects.
|
|
88
|
-
*/
|
|
89
|
-
static traverseFullBlockchain(beaconServices: Array<BeaconService>, bitcoin: BitcoinNetworkConnection): Promise<Map<BeaconService, Array<BeaconSignal>>>;
|
|
73
|
+
static updates(currentDocument: DidDocument, unsortedUpdates: Array<[SignedBTCR2Update, BlockMetadata]>, versionTime?: string, versionId?: string): Promise<DidResolutionResponse>;
|
|
90
74
|
/**
|
|
91
75
|
* Implements subsection {@link https://dcdpr.github.io/did-btcr2/#confirm-duplicate-update | 7.2.f.1 Confirm Duplicate Update}.
|
|
92
76
|
* This step confirms that an update with a lower-than-expected targetVersionId is a true duplicate.
|
|
93
|
-
* @param {
|
|
77
|
+
* @param {SignedBTCR2Update} update The BTCR2 Signed Update to confirm as a duplicate.
|
|
94
78
|
* @returns {void} Does not return a value, but throws an error if the update is not a valid duplicate.
|
|
95
79
|
*/
|
|
96
|
-
static
|
|
80
|
+
static confirmDuplicate(update: SignedBTCR2Update, updateHashHistory: string[]): void;
|
|
97
81
|
/**
|
|
98
82
|
* Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#apply-update | 7.2.f.3 Apply Update}.
|
|
99
83
|
* @param {DidDocument} currentDocument The current DID Document to apply the update to.
|
|
100
|
-
* @param {
|
|
84
|
+
* @param {SignedBTCR2Update} update The BTCR2 Signed Update to apply.
|
|
101
85
|
* @returns {Promise<DidDocument>} The updated DID Document after applying the update.
|
|
102
86
|
* @throws {ResolveError} If the update is invalid or cannot be applied.
|
|
103
87
|
*/
|
|
104
|
-
static
|
|
88
|
+
static applyUpdate(currentDocument: DidDocument, update: SignedBTCR2Update): Promise<DidDocument>;
|
|
105
89
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../src/core/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../src/core/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EAEzB,MAAM,oBAAoB,CAAC;AAa5B,OAAO,EAIL,iBAAiB,EAElB,MAAM,wBAAwB,CAAC;AAKhC,OAAO,EAAE,WAAW,EAAwB,MAAM,0BAA0B,CAAC;AAE7E,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGtE,OAAO,EAAE,aAAa,EAAc,MAAM,iBAAiB,CAAC;AAE5D,OAAO,EAAmB,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,eAAe,EAAE,WAAW,CAAC;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;GAQG;AACH,qBAAa,OAAO;IAClB;;;;OAIG;IACH,MAAM,CAAC,aAAa,CAAC,aAAa,EAAE,aAAa,GAAG,WAAW;IA+B/D;;;;;;OAMG;WACU,QAAQ,CACnB,aAAa,EAAE,aAAa,EAC5B,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,WAAW,CAAC;IA2BvB;;;;OAIG;IACH,MAAM,CAAC,WAAW,CAAC,OAAO,GAAE,OAAuB,GAAG,WAAW;IAyBjE;;;;;;;;OAQG;WAEU,eAAe,CAC1B,aAAa,EAAE,aAAa,EAC5B,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,WAAW,CAAC;IA+BvB;;;;;;;OAOG;WACU,aAAa,CACxB,cAAc,EAAE,KAAK,CAAC,aAAa,CAAC,EACpC,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,KAAK,CAAC,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC,CAAC;IAmBrD;;;;;;;OAOG;WACU,OAAO,CAClB,eAAe,EAAE,WAAW,EAC5B,eAAe,EAAE,KAAK,CAAC,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC,EAC1D,WAAW,CAAC,EAAE,MAAM,EACpB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,qBAAqB,CAAC;IAmGjC;;;;;OAKG;IACH,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,EAAE,GAAG,IAAI;IAmBrF;;;;;;OAMG;WACU,WAAW,CACtB,eAAe,EAAE,WAAW,EAC5B,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,WAAW,CAAC;CAiFxB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HexString } from '@did-btcr2/common';
|
|
2
|
-
import {
|
|
2
|
+
import { SignedBTCR2Update } from '@did-btcr2/cryptosuite';
|
|
3
3
|
import { SMTProof } from './interfaces.js';
|
|
4
4
|
/**
|
|
5
5
|
* {@link https://dcdpr.github.io/did-btcr2/data-structures.html#cas-announcement | CAS Announcement }
|
|
@@ -37,7 +37,7 @@ export type Sidecar = {
|
|
|
37
37
|
* Optional array of BTCR2 Signed Updates. Required if the DID being resolved
|
|
38
38
|
* has ever had a published BTCR2 Update.
|
|
39
39
|
*/
|
|
40
|
-
updates?: Array<
|
|
40
|
+
updates?: Array<SignedBTCR2Update>;
|
|
41
41
|
/**
|
|
42
42
|
* Optional array of CAS Announcements. Required if the DID being reslved has
|
|
43
43
|
* used a CAS Beacon to publish a BTCR2 Update.
|
|
@@ -49,23 +49,36 @@ export type Sidecar = {
|
|
|
49
49
|
*/
|
|
50
50
|
smtProofs?: Array<SMTProof>;
|
|
51
51
|
};
|
|
52
|
+
/**
|
|
53
|
+
* The Sidecar data structure used for Singleton Beacons.
|
|
54
|
+
*/
|
|
55
|
+
export type SingletonBeaconSidecarData = Map<HexString, SignedBTCR2Update>;
|
|
56
|
+
/**
|
|
57
|
+
* The Sidecar data structure used for CAS Beacons.
|
|
58
|
+
*/
|
|
59
|
+
export type CASBeaconSidecarData = Map<HexString, CASAnnouncement>;
|
|
60
|
+
/**
|
|
61
|
+
* The Sidecar data structure used for SMT Beacons.
|
|
62
|
+
*/
|
|
63
|
+
export type SMTBeaconSidecarData = Map<string, SMTProof>;
|
|
52
64
|
/**
|
|
53
65
|
* The Sidecar data structure post-processing used for resolution.
|
|
54
66
|
*/
|
|
55
67
|
export type SidecarData = {
|
|
56
68
|
/**
|
|
57
69
|
* Map of BTCR2 Signed Updates by their hash bytes.
|
|
58
|
-
* @type {Map<HexString, BTCR2SignedUpdate>}
|
|
59
70
|
*/
|
|
60
|
-
updateMap:
|
|
71
|
+
updateMap: SingletonBeaconSidecarData;
|
|
61
72
|
/**
|
|
62
73
|
* Map of CAS Announcements by their hash bytes.
|
|
63
|
-
* @type {Map<HexString, CASAnnouncement>}
|
|
64
74
|
*/
|
|
65
|
-
casMap:
|
|
75
|
+
casMap: CASBeaconSidecarData;
|
|
66
76
|
/**
|
|
67
77
|
* Map of SMT Proofs by their ID.
|
|
68
|
-
* @type {Map<string, SMTProof>}
|
|
69
78
|
*/
|
|
70
|
-
smtMap:
|
|
79
|
+
smtMap: SMTBeaconSidecarData;
|
|
71
80
|
};
|
|
81
|
+
/**
|
|
82
|
+
* Union type for all Beacon Sidecar data structures.
|
|
83
|
+
*/
|
|
84
|
+
export type BeaconSidecarData = SingletonBeaconSidecarData | CASBeaconSidecarData | SMTBeaconSidecarData;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CACtB,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,OAAO,GAAG;IACpB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;OAGG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAA;IAElC;;;OAGG;IACH,UAAU,CAAC,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;IAEpC;;;OAGG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CACtB,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,OAAO,GAAG;IACpB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;OAGG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAA;IAElC;;;OAGG;IACH,UAAU,CAAC,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;IAEpC;;;OAGG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG,GAAG,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC;AAC3E;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,GAAG,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;AACnE;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAEzD;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,SAAS,EAAE,0BAA0B,CAAC;IAEtC;;OAEG;IACH,MAAM,EAAE,oBAAoB,CAAC;IAE7B;;OAEG;IACH,MAAM,EAAE,oBAAoB,CAAC;CAC9B,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,0BAA0B,GAAG,oBAAoB,GAAG,oBAAoB,CAAC"}
|
|
@@ -1,24 +1,10 @@
|
|
|
1
|
-
import { PatchOperation } from '@did-btcr2/common';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
identifier: string;
|
|
7
|
-
sourceDocument: DidDocument;
|
|
8
|
-
sourceVersionId: number;
|
|
9
|
-
patch: PatchOperation[];
|
|
10
|
-
}
|
|
11
|
-
export interface UpdateParams extends ConstructUpdateParams {
|
|
12
|
-
verificationMethodId: string;
|
|
13
|
-
beaconIds: string[];
|
|
14
|
-
}
|
|
15
|
-
export type InvokePayloadParams = {
|
|
16
|
-
identifier: string;
|
|
17
|
-
BTCR2SignedUpdate: BTCR2SignedUpdate;
|
|
18
|
-
verificationMethod: DidVerificationMethod;
|
|
19
|
-
};
|
|
1
|
+
import { KeyBytes, PatchOperation } from '@did-btcr2/common';
|
|
2
|
+
import { SignedBTCR2Update, UnsignedBTCR2Update } from '@did-btcr2/cryptosuite';
|
|
3
|
+
import { Btcr2DidDocument, DidVerificationMethod } from '../utils/did-document.js';
|
|
4
|
+
import { BeaconService } from './beacon/interfaces.js';
|
|
5
|
+
import { BitcoinNetworkConnection } from '@did-btcr2/bitcoin';
|
|
20
6
|
/**
|
|
21
|
-
* Implements {@link https://dcdpr.github.io/did-btcr2
|
|
7
|
+
* Implements {@link https://dcdpr.github.io/did-btcr2/operations/update.html | 7.3 Update}.
|
|
22
8
|
*
|
|
23
9
|
* An update to a did:btcr2 document is an invoked capability using the ZCAP-LD
|
|
24
10
|
* data format, signed by a verificationMethod that has the authority to make
|
|
@@ -31,64 +17,35 @@ export type InvokePayloadParams = {
|
|
|
31
17
|
*/
|
|
32
18
|
export declare class Update {
|
|
33
19
|
/**
|
|
34
|
-
* Implements {@link https://dcdpr.github.io/did-btcr2
|
|
35
|
-
*
|
|
36
|
-
* The Construct DID Update Payload algorithm applies the documentPatch to the sourceDocument and verifies the
|
|
37
|
-
* resulting targetDocument is a conformant DID document. It takes in a Identifier, sourceDocument,
|
|
38
|
-
* sourceVersionId, and documentPatch objects. It returns an unsigned DID Update Payload.
|
|
20
|
+
* Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/update.html#construct-btcr2-unsigned-update | 7.3.b Construct BTCR2 Unsigned Update}.
|
|
21
|
+
* This process constructs a BTCR2 Unsigned Update conformant to the spec template.
|
|
39
22
|
*
|
|
40
|
-
* @param {
|
|
41
|
-
* @param {
|
|
42
|
-
* @param {
|
|
43
|
-
* @
|
|
44
|
-
* @
|
|
45
|
-
* @returns {Promise<BTCR2SignedUpdate>} The constructed BTCR2SignedUpdate object.
|
|
46
|
-
* @throws {MethodError} InvalidDid if sourceDocument.id does not match identifier.
|
|
23
|
+
* @param {Btcr2DidDocument} sourceDocument The source DID document to be updated.
|
|
24
|
+
* @param {PatchOperation[]} patches The array of JSON Patch operations to apply to the sourceDocument.
|
|
25
|
+
* @param {number} sourceVersionId The version ID of the source document.
|
|
26
|
+
* @returns {Promise<SignedBTCR2Update>} The constructed SignedBTCR2Update object.
|
|
27
|
+
* @throws {UpdateError} InvalidDid if sourceDocument.id does not match identifier.
|
|
47
28
|
*/
|
|
48
|
-
static construct(
|
|
49
|
-
identifier: string;
|
|
50
|
-
sourceDocument: DidDocument;
|
|
51
|
-
sourceVersionId: number;
|
|
52
|
-
patch: PatchOperation[];
|
|
53
|
-
}): Promise<BTCR2UnsignedUpdate>;
|
|
29
|
+
static construct(sourceDocument: Btcr2DidDocument, patches: PatchOperation[], sourceVersionId: number): Promise<UnsignedBTCR2Update>;
|
|
54
30
|
/**
|
|
55
|
-
* {@link
|
|
31
|
+
* Implements subsection {@link http://dcdpr.github.io/did-btcr2/operations/update.html#construct-btcr2-signed-update | 7.3.c Construct BTCR2 Signed Update }.
|
|
32
|
+
* This process constructs a BTCR2 Signed Update from a BTCR2 Unsigned Update.
|
|
56
33
|
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* @param {InvokePayloadParams} params Required params for calling the invokePayload method
|
|
63
|
-
* @param {string} params.identifier The did-btcr2 identifier to derive the root capability from
|
|
64
|
-
* @param {BTCR2SignedUpdate} params.BTCR2SignedUpdate The updatePayload object to be signed
|
|
65
|
-
* @param {DidVerificationMethod} params.verificationMethod The verificationMethod object to be used for signing
|
|
66
|
-
* @returns {BTCR2SignedUpdate} Did update payload secured with a proof => BTCR2SignedUpdate
|
|
67
|
-
* @throws {MethodError} if the privateKeyBytes are invalid
|
|
34
|
+
* @param {string} did The did-btcr2 identifier to derive the root capability from
|
|
35
|
+
* @param {UnsignedBTCR2Update} unsignedUpdate The updatePayload object to be signed
|
|
36
|
+
* @param {DidVerificationMethod} verificationMethod The verificationMethod object to be used for signing
|
|
37
|
+
* @returns {SignedBTCR2Update} Did update payload secured with a proof => SignedBTCR2Update
|
|
38
|
+
* @throws {UpdateError} if the privateKeyBytes are invalid
|
|
68
39
|
*/
|
|
69
|
-
static
|
|
70
|
-
identifier: string;
|
|
71
|
-
unsignedUpdate: BTCR2UnsignedUpdate;
|
|
72
|
-
verificationMethod: DidVerificationMethod;
|
|
73
|
-
}): Promise<BTCR2SignedUpdate>;
|
|
40
|
+
static sign(did: string, unsignedUpdate: UnsignedBTCR2Update, verificationMethod: DidVerificationMethod, secretKey: KeyBytes): Promise<SignedBTCR2Update>;
|
|
74
41
|
/**
|
|
75
|
-
* Implements {@link https://dcdpr.github.io/did-btcr2
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* data to validate the Beacon Signal
|
|
81
|
-
*
|
|
82
|
-
* @param {AnnounceUpdatePayloadParams} params Required params for calling the announcePayload method
|
|
83
|
-
* @param {DidDocument} params.sourceDocument The did-btcr2 did document to derive the root capability from
|
|
84
|
-
* @param {string[]} params.beaconIds The BTCR2SignedUpdate object to be signed
|
|
85
|
-
* @param {BTCR2SignedUpdate} params.BTCR2SignedUpdate The verificationMethod object to be used for signing
|
|
86
|
-
* @returns {BTCR2SignedUpdate} The BTCR2SignedUpdate object containing data to validate the Beacon Signal
|
|
87
|
-
* @throws {MethodError} if the beaconService type is invalid
|
|
42
|
+
* Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/update.html#announce-did-update | 7.3.d Announce DID Update}.
|
|
43
|
+
* BTCR2 Signed Updates are announced to the Bitcoin blockchain depending on the Beacon Type.
|
|
44
|
+
* @param {BeaconService} beaconService The BeaconService object representing the funded beacon to announce the update to.
|
|
45
|
+
* @param {SignedBTCR2Update} update The signed update object to be announced.
|
|
46
|
+
* @param {KeyBytes} secretKey The private key used to sign the update for announcement.
|
|
47
|
+
* @returns {SignedBTCR2Update} The SignedBTCR2Update object containing data to validate the Beacon Signal
|
|
48
|
+
* @throws {UpdateError} if the beaconService type is invalid
|
|
88
49
|
*/
|
|
89
|
-
static announce(
|
|
90
|
-
sourceDocument: DidDocument;
|
|
91
|
-
beaconIds: string[];
|
|
92
|
-
signedUpdate: BTCR2SignedUpdate;
|
|
93
|
-
}): Promise<SidecarData>;
|
|
50
|
+
static announce(beaconService: BeaconService, update: SignedBTCR2Update, secretKey: KeyBytes, bitcoin: BitcoinNetworkConnection): Promise<SignedBTCR2Update>;
|
|
94
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/core/update.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/core/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,QAAQ,EACR,cAAc,EAEf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAGL,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,gBAAgB,EAAe,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEhG,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D;;;;;;;;;;;GAWG;AACH,qBAAa,MAAM;IACjB;;;;;;;;;OASG;WACU,SAAS,CACpB,cAAc,EAAE,gBAAgB,EAChC,OAAO,EAAE,cAAc,EAAE,EACzB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,mBAAmB,CAAC;IAoC/B;;;;;;;;;OASG;WACU,IAAI,CACf,GAAG,EAAE,MAAM,EACX,cAAc,EAAE,mBAAmB,EACnC,kBAAkB,EAAE,qBAAqB,EACzC,SAAS,EAAE,QAAQ,GAClB,OAAO,CAAC,iBAAiB,CAAC;IAgC7B;;;;;;;;OAQG;WACU,QAAQ,CACnB,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,iBAAiB,EACzB,SAAS,EAAE,QAAQ,EACnB,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,iBAAiB,CAAC;CAU9B"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BitcoinNetworkConnection } from '@did-btcr2/bitcoin';
|
|
2
|
+
import { Canonicalization, DocumentBytes, HexString, KeyBytes, PatchOperation } from '@did-btcr2/common';
|
|
3
|
+
import { SignedBTCR2Update } from '@did-btcr2/cryptosuite';
|
|
2
4
|
import { DidMethod, DidResolutionResult } from '@web5/dids';
|
|
3
5
|
import { ResolutionOptions } from './core/interfaces.js';
|
|
4
|
-
import {
|
|
5
|
-
import { DidDocument, DidVerificationMethod } from './utils/did-document.js';
|
|
6
|
+
import { Btcr2DidDocument, DidVerificationMethod } from './utils/did-document.js';
|
|
6
7
|
export declare const canonicalization: Canonicalization;
|
|
7
8
|
export type Btcr2Identifier = string;
|
|
8
9
|
export interface DidCreateOptions {
|
|
@@ -27,7 +28,9 @@ export interface DidCreateOptions {
|
|
|
27
28
|
* @implements {DidMethod}
|
|
28
29
|
*/
|
|
29
30
|
export declare class DidBtcr2 implements DidMethod {
|
|
30
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* Name of the DID method, as defined in the DID BTCR2 specification
|
|
33
|
+
*/
|
|
31
34
|
static methodName: string;
|
|
32
35
|
/**
|
|
33
36
|
* Implements section {@link https://dcdpr.github.io/did-btcr2/operations/create.html | 7.1 Create}.
|
|
@@ -42,7 +45,7 @@ export declare class DidBtcr2 implements DidMethod {
|
|
|
42
45
|
*/
|
|
43
46
|
static create(genesisBytes: KeyBytes | DocumentBytes, options?: DidCreateOptions): Promise<Btcr2Identifier>;
|
|
44
47
|
/**
|
|
45
|
-
* Entry point for section {@link https://dcdpr.github.io/did-btcr2
|
|
48
|
+
* Entry point for section {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html | 7.2 Resolve}.
|
|
46
49
|
* See specification for the {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#process | Resolve Process}.
|
|
47
50
|
* See {@link Resolve | Resolve (class)} for class implementation.
|
|
48
51
|
*
|
|
@@ -51,14 +54,10 @@ export declare class DidBtcr2 implements DidMethod {
|
|
|
51
54
|
* blockchain by Authorized Beacon Signals. The Initial DID Document is either
|
|
52
55
|
* deterministically created from the DID or provided by Sidecar Data.
|
|
53
56
|
*
|
|
54
|
-
* @param {string} did
|
|
55
|
-
* @param {ResolutionOptions} resolutionOptions
|
|
56
|
-
* @param {number} resolutionOptions.versionId optional version of the identifier and/or DID document
|
|
57
|
-
* @param {number} resolutionOptions.versionTime optional timestamp used during resolution as a bound for when to stop resolving
|
|
58
|
-
* @param {DidDocument} resolutionOptions.sidecar optional data necessary for resolving a DID
|
|
57
|
+
* @param {string} did The did:btcr2 identifier to be resolved.
|
|
58
|
+
* @param {ResolutionOptions} resolutionOptions Options used during the resolution process.
|
|
59
59
|
* @returns {Promise<DidResolutionResult>} Promise resolving to a DID Resolution Result containing the `targetDocument`
|
|
60
|
-
* @throws {
|
|
61
|
-
* @throws {DidError} InvalidDid if the identifier is invalid
|
|
60
|
+
* @throws {ResolveError} If the resolution process fails at any step.
|
|
62
61
|
* @example
|
|
63
62
|
* ```ts
|
|
64
63
|
* const resolution = await DidBtcr2.resolve(
|
|
@@ -68,49 +67,43 @@ export declare class DidBtcr2 implements DidMethod {
|
|
|
68
67
|
*/
|
|
69
68
|
static resolve(did: string, resolutionOptions?: ResolutionOptions): Promise<DidResolutionResult>;
|
|
70
69
|
/**
|
|
71
|
-
* Entry point for section {@link https://dcdpr.github.io/did-btcr2/#
|
|
72
|
-
* See {@link
|
|
73
|
-
*
|
|
74
|
-
* An update to a did:btcr2 document is an invoked capability using the ZCAP-LD data format, signed by a
|
|
75
|
-
* verificationMethod that has the authority to make the update as specified in the previous DID document. Capability
|
|
76
|
-
* invocations for updates MUST be authorized using Data Integrity following the bip340-jcs-2025
|
|
77
|
-
* cryptosuite with a proofPurpose of capabilityInvocation.
|
|
78
|
-
*
|
|
79
|
-
* The Update algorithm takes as inputs a Identifier, sourceDocument, sourceVersionId, documentPatch, a
|
|
80
|
-
* verificationMethodId and an array of beaconIds. The sourceDocument is the DID document being updated. The
|
|
81
|
-
* documentPatch is a JSON Patch object containing a set of transformations to be applied to the sourceDocument.
|
|
82
|
-
* The result of these transformations MUST produce a DID document conformant to the DID Core specification. The
|
|
83
|
-
* verificationMethodId is an identifier for a verificationMethod within the sourceDocument. The verificationMethod
|
|
84
|
-
* identified MUST be a BIP340 Multikey. The beaconIds MUST identify service endpoints with one of the three Beacon
|
|
85
|
-
* Types SingletonBeacon, CASBeacon, and SMTBeacon.
|
|
70
|
+
* Entry point for section {@link https://dcdpr.github.io/did-btcr2/#read | 7.3 Update}.
|
|
71
|
+
* See specification for the {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#process | Resolve Process}.
|
|
72
|
+
* See {@link Update | Update (class)} for class implementation.
|
|
86
73
|
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* @param
|
|
91
|
-
* @param {
|
|
92
|
-
* @param {
|
|
93
|
-
* @param {string
|
|
94
|
-
* @
|
|
95
|
-
* @
|
|
74
|
+
* BTCR2 DID documents can be updated by anchoring BTCR2 Updates to Bitcoin transactions. These transactions MAY be
|
|
75
|
+
* published to the Bitcoin network. Any property in the DID document may be updated except the id. Doing so would
|
|
76
|
+
* invalidate the DID document.
|
|
77
|
+
* @param params An object containing the parameters for the update operation.
|
|
78
|
+
* @param {Btcr2DidDocument} params.sourceDocument The DID document being updated.
|
|
79
|
+
* @param {PatchOperation[]} params.patches The array of JSON Patch operations to apply to the sourceDocument.
|
|
80
|
+
* @param {string} params.sourceVersionId The version ID before applying the update.
|
|
81
|
+
* @param {string} params.verificationMethodId The verificationMethod ID to sign the update with.
|
|
82
|
+
* @param {string} params.beaconId The beacon ID associated with the update.
|
|
83
|
+
* @param {KeyBytes | HexString} [params.signingMaterial] Optional signing material (key bytes or hex string).
|
|
84
|
+
* @param {BitcoinNetworkConnection} [params.bitcoin] Optional Bitcoin network connection for announcing the update. If not provided, a default connection will be initialized.
|
|
85
|
+
* @return {Promise<SignedBTCR2Update>} Promise resolving to the signed BTCR2 update.
|
|
86
|
+
* @throws {UpdateError} if no verificationMethod, verificationMethod type is not `Multikey` or the publicKeyMultibase
|
|
87
|
+
* header is not `zQ3s`
|
|
96
88
|
*/
|
|
97
|
-
static update(
|
|
98
|
-
|
|
99
|
-
|
|
89
|
+
static update({ sourceDocument, patches, sourceVersionId, verificationMethodId, beaconId, signingMaterial, bitcoin, }: {
|
|
90
|
+
sourceDocument: Btcr2DidDocument;
|
|
91
|
+
patches: PatchOperation[];
|
|
100
92
|
sourceVersionId: number;
|
|
101
|
-
patch: PatchOperation[];
|
|
102
93
|
verificationMethodId: string;
|
|
103
|
-
|
|
104
|
-
|
|
94
|
+
beaconId: string;
|
|
95
|
+
signingMaterial?: KeyBytes | HexString;
|
|
96
|
+
bitcoin?: BitcoinNetworkConnection;
|
|
97
|
+
}): Promise<SignedBTCR2Update>;
|
|
105
98
|
/**
|
|
106
99
|
* Given the W3C DID Document of a `did:btcr2` identifier, return the signing verification method that will be used
|
|
107
100
|
* for signing messages and credentials. If given, the `methodId` parameter is used to select the
|
|
108
101
|
* verification method. If not given, the Identity Key's verification method with an ID fragment
|
|
109
102
|
* of '#initialKey' is used.
|
|
110
|
-
* @param {
|
|
103
|
+
* @param {Btcr2DidDocument} didDocument The DID Document of the `did:btcr2` identifier.
|
|
111
104
|
* @param {string} [methodId] Optional verification method ID to be used for signing.
|
|
112
105
|
* @returns {DidVerificationMethod} Promise resolving to the {@link DidVerificationMethod} object used for signing.
|
|
113
106
|
* @throws {DidError} if the parsed did method does not match `btcr2` or signing method could not be determined.
|
|
114
107
|
*/
|
|
115
|
-
static getSigningMethod(didDocument:
|
|
108
|
+
static getSigningMethod(didDocument: Btcr2DidDocument, methodId?: string): DidVerificationMethod;
|
|
116
109
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"did-btcr2.d.ts","sourceRoot":"","sources":["../../src/did-btcr2.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"did-btcr2.d.ts","sourceRoot":"","sources":["../../src/did-btcr2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,SAAS,EAIT,QAAQ,EAIR,cAAc,EAGf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAIL,SAAS,EACT,mBAAmB,EAEpB,MAAM,YAAY,CAAC;AAMpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAIzD,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAGlF,eAAO,MAAM,gBAAgB,kBAAyB,CAAC;AAEvD,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC;AAErC,MAAM,WAAW,gBAAgB;IAC/B,qDAAqD;IACrD,MAAM,EAAE,KAAK,GAAG,UAAU,CAAC;IAC3B,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sBAAsB;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAMD;;;;;;;;;;;;GAYG;AACH,qBAAa,QAAS,YAAW,SAAS;IACxC;;OAEG;IACH,MAAM,CAAC,UAAU,EAAE,MAAM,CAAW;IAEpC;;;;;;;;;;OAUG;WACU,MAAM,CACjB,YAAY,EAAE,QAAQ,GAAG,aAAa,EACtC,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,eAAe,CAAC;IAe3B;;;;;;;;;;;;;;;;;;;;OAoBG;WACU,OAAO,CAClB,GAAG,EAAE,MAAM,EACX,iBAAiB,GAAE,iBAAmC,GACrD,OAAO,CAAC,mBAAmB,CAAC;IA0G/B;;;;;;;;;;;;;;;;;;;OAmBG;WACU,MAAM,CAAC,EAClB,cAAc,EACd,OAAO,EACP,eAAe,EACf,oBAAoB,EACpB,QAAQ,EACR,eAAe,EACf,OAAO,GACR,EAAE;QACD,cAAc,EAAE,gBAAgB,CAAC;QACjC,OAAO,EAAE,cAAc,EAAE,CAAC;QAC1B,eAAe,EAAE,MAAM,CAAC;QACxB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,QAAQ,EAAE,MAAM,CAAC;QACjB,eAAe,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;QACvC,OAAO,CAAC,EAAE,wBAAwB,CAAC;KACpC,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA+E9B;;;;;;;;;OASG;IACH,MAAM,CAAC,gBAAgB,CAAC,WAAW,EAAE,gBAAgB,EAAG,QAAQ,CAAC,EAAE,MAAM,GAAG,qBAAqB;CA0BlG"}
|