@did-btcr2/method 0.19.0 → 0.22.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 +223 -1
- package/dist/browser.js +3496 -4202
- package/dist/browser.mjs +3496 -4202
- 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 +56 -86
- 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 +121 -307
- package/dist/cjs/core/resolve.js.map +1 -1
- package/dist/cjs/core/update.js +62 -154
- package/dist/cjs/core/update.js.map +1 -1
- package/dist/cjs/did-btcr2.js +100 -91
- 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 -6
- package/dist/cjs/utils/did-document-builder.js.map +1 -1
- package/dist/cjs/utils/did-document.js +42 -38
- 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 +56 -86
- 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 +121 -307
- package/dist/esm/core/resolve.js.map +1 -1
- package/dist/esm/core/update.js +62 -154
- package/dist/esm/core/update.js.map +1 -1
- package/dist/esm/did-btcr2.js +100 -91
- 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 -6
- package/dist/esm/utils/did-document-builder.js.map +1 -1
- package/dist/esm/utils/did-document.js +42 -38
- 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 +17 -30
- 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 +34 -47
- 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 +44 -47
- 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 -1
- package/dist/types/utils/did-document-builder.d.ts.map +1 -1
- package/dist/types/utils/did-document.d.ts +26 -21
- package/dist/types/utils/did-document.d.ts.map +1 -1
- package/package.json +8 -7
- 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 +78 -100
- 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 +163 -395
- package/src/core/types.ts +25 -8
- package/src/core/update.ts +91 -236
- package/src/did-btcr2.ts +154 -116
- package/src/index.ts +8 -1
- package/src/utils/appendix.ts +8 -22
- package/src/utils/did-document-builder.ts +5 -7
- package/src/utils/did-document.ts +80 -73
|
@@ -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,EAIL,QAAQ,EACR,cAAc,EAEf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAGL,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,wBAAwB,CAAC;AAChC,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,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BitcoinNetworkConnection } from '@did-btcr2/bitcoin';
|
|
2
|
+
import { 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
|
-
export declare const canonicalization: Canonicalization;
|
|
6
|
+
import { Btcr2DidDocument, DidVerificationMethod } from './utils/did-document.js';
|
|
7
7
|
export type Btcr2Identifier = string;
|
|
8
8
|
export interface DidCreateOptions {
|
|
9
9
|
/** Type of identifier to create (key or external) */
|
|
@@ -27,7 +27,9 @@ export interface DidCreateOptions {
|
|
|
27
27
|
* @implements {DidMethod}
|
|
28
28
|
*/
|
|
29
29
|
export declare class DidBtcr2 implements DidMethod {
|
|
30
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Name of the DID method, as defined in the DID BTCR2 specification
|
|
32
|
+
*/
|
|
31
33
|
static methodName: string;
|
|
32
34
|
/**
|
|
33
35
|
* Implements section {@link https://dcdpr.github.io/did-btcr2/operations/create.html | 7.1 Create}.
|
|
@@ -39,10 +41,15 @@ export declare class DidBtcr2 implements DidMethod {
|
|
|
39
41
|
* @param {string} options.network The Bitcoin network to use for the identifier, e.g. 'bitcoin', 'testnet', etc. Defaults to 'bitcoin'.
|
|
40
42
|
* @returns {Promise<Btcr2Identifier>} Promise resolving to a Btcr2Identifier string.
|
|
41
43
|
* @throws {MethodError} if any of the checks fail
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* const genesisBytes = SchnorrKeyPair.generate().publicKey.compressed;
|
|
47
|
+
* const did = DidBtcr2.create(genesisBytes, { idType: 'KEY', network: 'regtest' });
|
|
48
|
+
* ```
|
|
42
49
|
*/
|
|
43
|
-
static create(genesisBytes: KeyBytes | DocumentBytes, options?: DidCreateOptions):
|
|
50
|
+
static create(genesisBytes: KeyBytes | DocumentBytes, options?: DidCreateOptions): Btcr2Identifier;
|
|
44
51
|
/**
|
|
45
|
-
* Entry point for section {@link https://dcdpr.github.io/did-btcr2
|
|
52
|
+
* Entry point for section {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html | 7.2 Resolve}.
|
|
46
53
|
* See specification for the {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#process | Resolve Process}.
|
|
47
54
|
* See {@link Resolve | Resolve (class)} for class implementation.
|
|
48
55
|
*
|
|
@@ -51,66 +58,56 @@ export declare class DidBtcr2 implements DidMethod {
|
|
|
51
58
|
* blockchain by Authorized Beacon Signals. The Initial DID Document is either
|
|
52
59
|
* deterministically created from the DID or provided by Sidecar Data.
|
|
53
60
|
*
|
|
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
|
|
61
|
+
* @param {string} did The did:btcr2 identifier to be resolved.
|
|
62
|
+
* @param {ResolutionOptions} resolutionOptions Options used during the resolution process.
|
|
59
63
|
* @returns {Promise<DidResolutionResult>} Promise resolving to a DID Resolution Result containing the `targetDocument`
|
|
60
|
-
* @throws {
|
|
61
|
-
* @throws {DidError} InvalidDid if the identifier is invalid
|
|
64
|
+
* @throws {ResolveError} If the resolution process fails at any step.
|
|
62
65
|
* @example
|
|
63
66
|
* ```ts
|
|
64
67
|
* const resolution = await DidBtcr2.resolve(
|
|
65
|
-
* 'did:btcr2:
|
|
68
|
+
* 'did:btcr2:k1qgpr45cheptyjekl3cex80xfnkwhxnlclecwwf92gvdjrszm2uwhzlcxu5xte'
|
|
66
69
|
* )
|
|
67
70
|
* ```
|
|
68
71
|
*/
|
|
69
72
|
static resolve(did: string, resolutionOptions?: ResolutionOptions): Promise<DidResolutionResult>;
|
|
70
73
|
/**
|
|
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.
|
|
74
|
+
* Entry point for section {@link https://dcdpr.github.io/did-btcr2/#read | 7.3 Update}.
|
|
75
|
+
* See specification for the {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#process | Resolve Process}.
|
|
76
|
+
* See {@link Update | Update (class)} for class implementation.
|
|
86
77
|
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* @param
|
|
91
|
-
* @param {
|
|
92
|
-
* @param {
|
|
93
|
-
* @param {string
|
|
94
|
-
* @
|
|
95
|
-
* @
|
|
78
|
+
* BTCR2 DID documents can be updated by anchoring BTCR2 Updates to Bitcoin transactions. These transactions MAY be
|
|
79
|
+
* published to the Bitcoin network. Any property in the DID document may be updated except the id. Doing so would
|
|
80
|
+
* invalidate the DID document.
|
|
81
|
+
* @param params An object containing the parameters for the update operation.
|
|
82
|
+
* @param {Btcr2DidDocument} params.sourceDocument The DID document being updated.
|
|
83
|
+
* @param {PatchOperation[]} params.patches The array of JSON Patch operations to apply to the sourceDocument.
|
|
84
|
+
* @param {string} params.sourceVersionId The version ID before applying the update.
|
|
85
|
+
* @param {string} params.verificationMethodId The verificationMethod ID to sign the update with.
|
|
86
|
+
* @param {string} params.beaconId The beacon ID associated with the update.
|
|
87
|
+
* @param {KeyBytes | HexString} [params.signingMaterial] Optional signing material (key bytes or hex string).
|
|
88
|
+
* @param {BitcoinNetworkConnection} [params.bitcoin] Optional Bitcoin network connection for announcing the update. If not provided, a default connection will be initialized.
|
|
89
|
+
* @return {Promise<SignedBTCR2Update>} Promise resolving to the signed BTCR2 update.
|
|
90
|
+
* @throws {UpdateError} if no verificationMethod, verificationMethod type is not `Multikey` or the publicKeyMultibase
|
|
91
|
+
* header is not `zQ3s`
|
|
96
92
|
*/
|
|
97
|
-
static update(
|
|
98
|
-
|
|
99
|
-
|
|
93
|
+
static update({ sourceDocument, patches, sourceVersionId, verificationMethodId, beaconId, signingMaterial, bitcoin, }: {
|
|
94
|
+
sourceDocument: Btcr2DidDocument;
|
|
95
|
+
patches: PatchOperation[];
|
|
100
96
|
sourceVersionId: number;
|
|
101
|
-
patch: PatchOperation[];
|
|
102
97
|
verificationMethodId: string;
|
|
103
|
-
|
|
104
|
-
|
|
98
|
+
beaconId: string;
|
|
99
|
+
signingMaterial?: KeyBytes | HexString;
|
|
100
|
+
bitcoin?: BitcoinNetworkConnection;
|
|
101
|
+
}): Promise<SignedBTCR2Update>;
|
|
105
102
|
/**
|
|
106
103
|
* Given the W3C DID Document of a `did:btcr2` identifier, return the signing verification method that will be used
|
|
107
104
|
* for signing messages and credentials. If given, the `methodId` parameter is used to select the
|
|
108
105
|
* verification method. If not given, the Identity Key's verification method with an ID fragment
|
|
109
106
|
* of '#initialKey' is used.
|
|
110
|
-
* @param {
|
|
107
|
+
* @param {Btcr2DidDocument} didDocument The DID Document of the `did:btcr2` identifier.
|
|
111
108
|
* @param {string} [methodId] Optional verification method ID to be used for signing.
|
|
112
109
|
* @returns {DidVerificationMethod} Promise resolving to the {@link DidVerificationMethod} object used for signing.
|
|
113
110
|
* @throws {DidError} if the parsed did method does not match `btcr2` or signing method could not be determined.
|
|
114
111
|
*/
|
|
115
|
-
static getSigningMethod(didDocument:
|
|
112
|
+
static getSigningMethod(didDocument: Btcr2DidDocument, methodId?: string): DidVerificationMethod;
|
|
116
113
|
}
|
|
@@ -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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AAe,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"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './core/beacon/aggregation/cohort/index.js';
|
|
2
|
+
export * from './core/beacon/aggregation/cohort/status.js';
|
|
2
3
|
export * from './core/beacon/aggregation/cohort/messages/base.js';
|
|
3
4
|
export * from './core/beacon/aggregation/cohort/messages/constants.js';
|
|
4
5
|
export * from './core/beacon/aggregation/cohort/messages/index.js';
|
|
@@ -12,7 +13,6 @@ export * from './core/beacon/aggregation/cohort/messages/sign/authorization-requ
|
|
|
12
13
|
export * from './core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js';
|
|
13
14
|
export * from './core/beacon/aggregation/cohort/messages/sign/request-signature.js';
|
|
14
15
|
export * from './core/beacon/aggregation/cohort/messages/sign/signature-authorization.js';
|
|
15
|
-
export * from './core/beacon/aggregation/cohort/status.js';
|
|
16
16
|
export * from './core/beacon/aggregation/communication/adapter/did-comm.js';
|
|
17
17
|
export * from './core/beacon/aggregation/communication/adapter/nostr.js';
|
|
18
18
|
export * from './core/beacon/aggregation/communication/error.js';
|
|
@@ -22,10 +22,12 @@ export * from './core/beacon/aggregation/coordinator.js';
|
|
|
22
22
|
export * from './core/beacon/aggregation/participant.js';
|
|
23
23
|
export * from './core/beacon/aggregation/session/index.js';
|
|
24
24
|
export * from './core/beacon/aggregation/session/status.js';
|
|
25
|
+
export * from './core/beacon/beacon.js';
|
|
25
26
|
export * from './core/beacon/cas-beacon.js';
|
|
26
27
|
export * from './core/beacon/error.js';
|
|
27
28
|
export * from './core/beacon/factory.js';
|
|
28
29
|
export * from './core/beacon/interfaces.js';
|
|
30
|
+
export * from './core/beacon/signal-discovery.js';
|
|
29
31
|
export * from './core/beacon/singleton.js';
|
|
30
32
|
export * from './core/beacon/smt-beacon.js';
|
|
31
33
|
export * from './core/beacon/utils.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2CAA2C,CAAC;AAC1D,cAAc,mDAAmD,CAAC;AAClE,cAAc,wDAAwD,CAAC;AACvE,cAAc,oDAAoD,CAAC;AACnE,cAAc,gEAAgE,CAAC;AAC/E,cAAc,mEAAmE,CAAC;AAClF,cAAc,kEAAkE,CAAC;AACjF,cAAc,mEAAmE,CAAC;AAClF,cAAc,4DAA4D,CAAC;AAC3E,cAAc,oEAAoE,CAAC;AACnF,cAAc,yEAAyE,CAAC;AACxF,cAAc,sEAAsE,CAAC;AACrF,cAAc,qEAAqE,CAAC;AACpF,cAAc,2EAA2E,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2CAA2C,CAAC;AAC1D,cAAc,4CAA4C,CAAC;AAE3D,cAAc,mDAAmD,CAAC;AAClE,cAAc,wDAAwD,CAAC;AACvE,cAAc,oDAAoD,CAAC;AACnE,cAAc,gEAAgE,CAAC;AAC/E,cAAc,mEAAmE,CAAC;AAClF,cAAc,kEAAkE,CAAC;AACjF,cAAc,mEAAmE,CAAC;AAClF,cAAc,4DAA4D,CAAC;AAC3E,cAAc,oEAAoE,CAAC;AACnF,cAAc,yEAAyE,CAAC;AACxF,cAAc,sEAAsE,CAAC;AACrF,cAAc,qEAAqE,CAAC;AACpF,cAAc,2EAA2E,CAAC;AAE1F,cAAc,6DAA6D,CAAC;AAC5E,cAAc,0DAA0D,CAAC;AAEzE,cAAc,kDAAkD,CAAC;AACjE,cAAc,oDAAoD,CAAC;AACnE,cAAc,oDAAoD,CAAC;AAEnE,cAAc,0CAA0C,CAAC;AACzD,cAAc,0CAA0C,CAAC;AACzD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,6CAA6C,CAAC;AAE5D,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAClD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AAEvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AAEnC,cAAc,gBAAgB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appendix.d.ts","sourceRoot":"","sources":["../../../src/utils/appendix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"appendix.d.ts","sourceRoot":"","sources":["../../../src/utils/appendix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EACL,WAAW,EAGX,UAAU,EACV,qBAAqB,EAEtB,MAAM,YAAY,CAAC;AAIpB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD;;;;;GAKG;AACH,qBAAa,QAAQ;IACnB;;;;OAIG;WACW,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS;IAMpE;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuCG;WACW,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,cAAc;IA+CrE;;;;OAIG;WACU,YAAY,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;CAW7E"}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { BeaconService } from '../core/beacon/interfaces.js';
|
|
2
2
|
import { DidDocument, DidVerificationMethod } from './did-document.js';
|
|
3
|
+
/**
|
|
4
|
+
* A builder class for constructing DID Documents.
|
|
5
|
+
* @type {DidDocumentBuilder}
|
|
6
|
+
* @class DidDocumentBuilder
|
|
7
|
+
*/
|
|
3
8
|
export declare class DidDocumentBuilder {
|
|
4
9
|
private document;
|
|
5
10
|
constructor(initialDocument: Partial<DidDocument>);
|
|
6
|
-
withController(controller?: Array<string>): this;
|
|
7
11
|
withAuthentication(authentication: Array<string | DidVerificationMethod>): this;
|
|
8
12
|
withAssertionMethod(assertionMethod: Array<string | DidVerificationMethod>): this;
|
|
9
13
|
withCapabilityInvocation(capabilityInvocation: Array<string | DidVerificationMethod>): this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"did-document-builder.d.ts","sourceRoot":"","sources":["../../../src/utils/did-document-builder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAEvE,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAA4B;gBAEhC,eAAe,EAAE,OAAO,CAAC,WAAW,CAAC;IAYjD,
|
|
1
|
+
{"version":3,"file":"did-document-builder.d.ts","sourceRoot":"","sources":["../../../src/utils/did-document-builder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAEvE;;;;GAIG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAA4B;gBAEhC,eAAe,EAAE,OAAO,CAAC,WAAW,CAAC;IAYjD,kBAAkB,CAAC,cAAc,EAAE,KAAK,CAAC,MAAM,GAAG,qBAAqB,CAAC,GAAG,IAAI;IAO/E,mBAAmB,CAAC,eAAe,EAAE,KAAK,CAAC,MAAM,GAAG,qBAAqB,CAAC,GAAG,IAAI;IAOjF,wBAAwB,CAAC,oBAAoB,EAAE,KAAK,CAAC,MAAM,GAAG,qBAAqB,CAAC,GAAG,IAAI;IAO3F,wBAAwB,CAAC,oBAAoB,EAAE,KAAK,CAAC,MAAM,GAAG,qBAAqB,CAAC,GAAG,IAAI;IAO3F,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,IAAI;IAOhD,KAAK,IAAI,WAAW;CAWrB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { JSONObject, KeyBytes } from '@did-btcr2/common';
|
|
2
|
-
import { DidDocument as
|
|
1
|
+
import { HashBytes, JSONObject, KeyBytes } from '@did-btcr2/common';
|
|
2
|
+
import { DidDocument as W3CDidDocument, DidVerificationMethod as W3CDidVerificationMethod } from '@web5/dids';
|
|
3
3
|
import { BeaconService } from '../core/beacon/interfaces.js';
|
|
4
4
|
export declare const ID_PLACEHOLDER_VALUE = "did:btcr2:_";
|
|
5
5
|
export declare const BECH32M_CHARS = "";
|
|
@@ -19,7 +19,10 @@ export type VerificationRelationships = {
|
|
|
19
19
|
capabilityInvocation?: Array<string | DidVerificationMethod>;
|
|
20
20
|
capabilityDelegation?: Array<string | DidVerificationMethod>;
|
|
21
21
|
};
|
|
22
|
-
|
|
22
|
+
/** Loose type for unvalidated DID / Genesis document-like input objects. */
|
|
23
|
+
export type DidDocumentLike = Partial<Btcr2DidDocument>;
|
|
24
|
+
export type GenesisDocumentLike = Partial<Btcr2DidDocument>;
|
|
25
|
+
export interface Btcr2VerificationMethod extends W3CDidVerificationMethod {
|
|
23
26
|
id: string;
|
|
24
27
|
type: string;
|
|
25
28
|
controller: string;
|
|
@@ -32,21 +35,20 @@ export interface IDidVerificationMethod extends IIDidVerificationMethod {
|
|
|
32
35
|
* @type {DidVerificationMethod}
|
|
33
36
|
*
|
|
34
37
|
*/
|
|
35
|
-
export declare class DidVerificationMethod implements
|
|
38
|
+
export declare class DidVerificationMethod implements Btcr2VerificationMethod {
|
|
36
39
|
id: string;
|
|
37
40
|
type: string;
|
|
38
41
|
controller: string;
|
|
39
42
|
publicKeyMultibase: string;
|
|
40
43
|
secretKeyMultibase?: string | undefined;
|
|
41
|
-
constructor({ id, type, controller, publicKeyMultibase, secretKeyMultibase }:
|
|
44
|
+
constructor({ id, type, controller, publicKeyMultibase, secretKeyMultibase }: Btcr2VerificationMethod);
|
|
42
45
|
}
|
|
43
46
|
/**
|
|
44
47
|
* BTCR2 DID Document Interface
|
|
45
|
-
* @interface
|
|
46
|
-
* @type {
|
|
47
|
-
* @extends {
|
|
48
|
+
* @interface Btcr2DidDocument
|
|
49
|
+
* @type {Btcr2DidDocument}
|
|
50
|
+
* @extends {W3CDidDocument}
|
|
48
51
|
* @property {string} id - The identifier of the DID Document.
|
|
49
|
-
* @property {Array<string>} [controller] - The controller of the DID Document.
|
|
50
52
|
* @property {Array<string | JSONObject>} ['@context'] - The context of the DID Document.
|
|
51
53
|
* @property {Array<DidVerificationMethod>} verificationMethod - The verification methods of the DID Document.
|
|
52
54
|
* @property {Array<string | DidVerificationMethod>} [authentication] - The authentication methods of the DID Document.
|
|
@@ -55,9 +57,8 @@ export declare class DidVerificationMethod implements IDidVerificationMethod {
|
|
|
55
57
|
* @property {Array<string | DidVerificationMethod>} [capabilityDelegation] - The capability delegation methods of the DID Document.
|
|
56
58
|
* @property {Array<BeaconService>} service - The services of the DID Document.
|
|
57
59
|
*/
|
|
58
|
-
export interface
|
|
60
|
+
export interface Btcr2DidDocument extends W3CDidDocument {
|
|
59
61
|
id: string;
|
|
60
|
-
controller?: Array<string>;
|
|
61
62
|
'@context'?: Array<string | JSONObject>;
|
|
62
63
|
verificationMethod: Array<DidVerificationMethod>;
|
|
63
64
|
authentication?: Array<string | DidVerificationMethod>;
|
|
@@ -70,9 +71,8 @@ export interface IDidDocument extends IIDidDocument {
|
|
|
70
71
|
* BTCR2 DID Document extends the DidDocument class adding helper methods and properties
|
|
71
72
|
* @class DidDocument
|
|
72
73
|
* @type {DidDocument}
|
|
73
|
-
* @implements {
|
|
74
|
+
* @implements {Btcr2DidDocument}
|
|
74
75
|
* @property {string} id - The identifier of the DID Document.
|
|
75
|
-
* @property {Array<string>} [controller] - The controller of the DID Document.
|
|
76
76
|
* @property {Array<string | JSONObject>} ['@context'] - The context of the DID Document.
|
|
77
77
|
* @property {Array<DidVerificationMethod>} verificationMethod - The verification methods of the DID Document.
|
|
78
78
|
* @property {Array<string | DidVerificationMethod>} [authentication] - The authentication methods of the DID Document.
|
|
@@ -81,9 +81,8 @@ export interface IDidDocument extends IIDidDocument {
|
|
|
81
81
|
* @property {Array<string | DidVerificationMethod>} [capabilityDelegation] - The capability delegation methods of the DID Document.
|
|
82
82
|
* @property {Array<BeaconService>} service - The services of the DID Document.
|
|
83
83
|
*/
|
|
84
|
-
export declare class DidDocument implements
|
|
84
|
+
export declare class DidDocument implements Btcr2DidDocument {
|
|
85
85
|
id: string;
|
|
86
|
-
controller?: Array<string>;
|
|
87
86
|
'@context'?: Array<string | JSONObject>;
|
|
88
87
|
verificationMethod: Array<DidVerificationMethod>;
|
|
89
88
|
authentication?: Array<string | DidVerificationMethod>;
|
|
@@ -92,12 +91,12 @@ export declare class DidDocument implements IDidDocument {
|
|
|
92
91
|
capabilityDelegation?: Array<string | DidVerificationMethod>;
|
|
93
92
|
service: Array<BeaconService>;
|
|
94
93
|
deactivated?: boolean;
|
|
95
|
-
constructor(document:
|
|
94
|
+
constructor(document: DidDocumentLike);
|
|
96
95
|
/**
|
|
97
96
|
* Convert the DidDocument to a JSON object.
|
|
98
97
|
* @returns {DidDocument} The JSON representation of the DidDocument.
|
|
99
98
|
*/
|
|
100
|
-
json():
|
|
99
|
+
json(): object;
|
|
101
100
|
/**
|
|
102
101
|
* Create a minimal DidDocument from "k1" btcr2 identifier.
|
|
103
102
|
* @param {string} publicKeyMultibase The public key in multibase format.
|
|
@@ -122,7 +121,7 @@ export declare class DidDocument implements IDidDocument {
|
|
|
122
121
|
* @returns {boolean} True if the DID document is valid.
|
|
123
122
|
* @throws {DidDocumentError} If any validation check fails.
|
|
124
123
|
*/
|
|
125
|
-
static isValid(didDocument:
|
|
124
|
+
static isValid(didDocument: DidDocumentLike): boolean;
|
|
126
125
|
/**
|
|
127
126
|
* Validates that "@context" exists and includes correct values.
|
|
128
127
|
* @private
|
|
@@ -163,13 +162,13 @@ export declare class DidDocument implements IDidDocument {
|
|
|
163
162
|
* @param {DidDocument} didDocument The DID Document to validate.
|
|
164
163
|
* @returns {boolean} True if the verification relationships are valid.
|
|
165
164
|
*/
|
|
166
|
-
static isValidVerificationRelationships(didDocument:
|
|
165
|
+
static isValidVerificationRelationships(didDocument: DidDocumentLike): boolean;
|
|
167
166
|
/**
|
|
168
167
|
* Validate the DID Document
|
|
169
168
|
* @returns {DidDocument} Validated DID Document.
|
|
170
169
|
* @throws {DidDocumentError} If the DID Document is invalid.
|
|
171
170
|
*/
|
|
172
|
-
static validate(didDocument:
|
|
171
|
+
static validate(didDocument: any): DidDocument;
|
|
173
172
|
/**
|
|
174
173
|
* Validate the GenesisDocument.
|
|
175
174
|
* @returns {boolean} True if the GenesisDocument is valid.
|
|
@@ -192,7 +191,7 @@ export declare class Document {
|
|
|
192
191
|
* @extends {DidDocument}
|
|
193
192
|
*/
|
|
194
193
|
export declare class GenesisDocument extends DidDocument {
|
|
195
|
-
constructor(document:
|
|
194
|
+
constructor(document: DidDocumentLike);
|
|
196
195
|
/**
|
|
197
196
|
* Convert the GenesisDocument to a DidDocument by replacing the placeholder value with the provided DID.
|
|
198
197
|
* @param did The DID to replace the placeholder value in the document.
|
|
@@ -225,4 +224,10 @@ export declare class GenesisDocument extends DidDocument {
|
|
|
225
224
|
* @returns {DidDocument} The created DidDocument.
|
|
226
225
|
*/
|
|
227
226
|
static fromJSON(object: object | DidDocument): GenesisDocument;
|
|
227
|
+
/**
|
|
228
|
+
* Convert a GenesisDocument to genesis bytes.
|
|
229
|
+
* @param {GenesisDocument} genesisDocument The GenesisDocument to convert.
|
|
230
|
+
* @returns {Bytes} The genesis bytes.
|
|
231
|
+
*/
|
|
232
|
+
static toGenesisBytes(genesisDocument: GenesisDocumentLike): HashBytes;
|
|
228
233
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"did-document.d.ts","sourceRoot":"","sources":["../../../src/utils/did-document.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"did-document.d.ts","sourceRoot":"","sources":["../../../src/utils/did-document.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,SAAS,EAGT,UAAU,EAEV,QAAQ,EACT,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,WAAW,IAAI,cAAc,EAAE,qBAAqB,IAAI,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAE9G,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAK7D,eAAO,MAAM,oBAAoB,gBAAgB,CAAC;AAClD,eAAO,MAAM,aA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;;;;OAIG;IACI,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW;IAO9C;;;;OAIG;WACW,eAAe,CAAC,WAAW,EAAE,WAAW,GAAG,eAAe;IAKxE;;;;;;OAMG;WACW,MAAM,CAClB,kBAAkB,EAAE,KAAK,CAAC,qBAAqB,CAAC,EAChD,aAAa,EAAE,yBAAyB,EACxC,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,GAC5B,eAAe;IAIlB;;;;OAIG;WACW,aAAa,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,eAAe;IA4BlF;;;;OAIG;WACW,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,eAAe;IAIrE;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,eAAe,EAAE,mBAAmB,GAAG,SAAS;CAGvE"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@did-btcr2/method",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "
|
|
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",
|
|
7
7
|
"module": "./dist/esm/index.js",
|
|
8
8
|
"types": "./dist/types/index.d.ts",
|
|
@@ -84,10 +84,10 @@
|
|
|
84
84
|
"nostr-tools": "^2.15.0",
|
|
85
85
|
"tiny-secp256k1": "^2.2.3",
|
|
86
86
|
"@did-btcr2/bitcoin": "0.3.4",
|
|
87
|
-
"@did-btcr2/cryptosuite": "
|
|
88
|
-
"@did-btcr2/
|
|
89
|
-
"@did-btcr2/
|
|
90
|
-
"@did-btcr2/
|
|
87
|
+
"@did-btcr2/cryptosuite": "5.1.0",
|
|
88
|
+
"@did-btcr2/kms": "0.2.0",
|
|
89
|
+
"@did-btcr2/keypair": "0.9.1",
|
|
90
|
+
"@did-btcr2/common": "4.0.1"
|
|
91
91
|
},
|
|
92
92
|
"devDependencies": {
|
|
93
93
|
"@eslint/js": "^9.22.0",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"@types/chai-as-promised": "^8.0.1",
|
|
96
96
|
"@types/eslint": "^9.6.1",
|
|
97
97
|
"@types/mocha": "^10.0.9",
|
|
98
|
-
"@types/node": "^
|
|
98
|
+
"@types/node": "^25.3.0",
|
|
99
99
|
"@typescript-eslint/eslint-plugin": "^8.5.0",
|
|
100
100
|
"@typescript-eslint/parser": "^8.5.0",
|
|
101
101
|
"c8": "^10.1.2",
|
|
@@ -138,6 +138,7 @@
|
|
|
138
138
|
"build:test": "pnpm build && pnpm build:tests && pnpm c8 mocha",
|
|
139
139
|
"build:lint:test": "pnpm build && pnpm build:tests && pnpm lint:fix",
|
|
140
140
|
"prepublish": "pnpm build",
|
|
141
|
+
"generate:vector": "pnpm tsx lib/generate-vector.ts",
|
|
141
142
|
"do": "pnpm tsx",
|
|
142
143
|
"do:lib": "${PWD}/lib/run-lib.sh",
|
|
143
144
|
"pack:local": "pnpm pack && mv *.tgz ./release"
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { KeyBytes } from '@did-btcr2/common';
|
|
2
|
+
import { BitcoinNetworkConnection } from '../../../../bitcoin/dist/types/bitcoin.js';
|
|
3
|
+
import { SignedBTCR2Update } from '../../../../cryptosuite/dist/types/data-integrity-proof/interface.js';
|
|
4
|
+
import { SidecarData } from '../types.js';
|
|
5
|
+
import { BeaconService, BeaconSignal, BlockMetadata } from './interfaces.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Abstract base class for all BTCR2 Beacon types.
|
|
9
|
+
* A Beacon is a service listed in a BTCR2 DID document that informs resolvers
|
|
10
|
+
* how to find authentic updates to the DID.
|
|
11
|
+
*
|
|
12
|
+
* Beacons are lightweight typed wrappers around a {@link BeaconService} configuration.
|
|
13
|
+
* Dependencies (signals, sidecar data, bitcoin connection) are passed as method
|
|
14
|
+
* parameters rather than held as instance state.
|
|
15
|
+
*
|
|
16
|
+
* Use {@link BeaconFactory.establish} to create typed instances from service config.
|
|
17
|
+
*
|
|
18
|
+
* @abstract
|
|
19
|
+
* @class Beacon
|
|
20
|
+
* @type {Beacon}
|
|
21
|
+
*/
|
|
22
|
+
export abstract class Beacon {
|
|
23
|
+
/**
|
|
24
|
+
* The Beacon service configuration parsed from the DID Document.
|
|
25
|
+
*/
|
|
26
|
+
readonly service: BeaconService;
|
|
27
|
+
|
|
28
|
+
constructor(service: BeaconService) {
|
|
29
|
+
this.service = service;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Processes an array of Beacon Signals to extract BTCR2 Signed Updates.
|
|
34
|
+
* Used during the resolve path.
|
|
35
|
+
* @param {Array<BeaconSignal>} signals The beacon signals discovered on-chain.
|
|
36
|
+
* @param {SidecarData} sidecar The processed sidecar data containing update/CAS/SMT maps.
|
|
37
|
+
* @returns {Promise<Array<[SignedBTCR2Update, BlockMetadata]>>} The updates announced by the signals.
|
|
38
|
+
*/
|
|
39
|
+
abstract processSignals(
|
|
40
|
+
signals: Array<BeaconSignal>,
|
|
41
|
+
sidecar: SidecarData,
|
|
42
|
+
): Promise<Array<[SignedBTCR2Update, BlockMetadata]>>;
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Broadcasts a signed update as a Beacon Signal to the Bitcoin network.
|
|
47
|
+
* Used during the update path.
|
|
48
|
+
* @param {SignedBTCR2Update} signedUpdate The signed BTCR2 update to broadcast.
|
|
49
|
+
* @param {KeyBytes} secretKey The secret key for signing the Bitcoin transaction.
|
|
50
|
+
* @param {BitcoinNetworkConnection} bitcoin The Bitcoin network connection.
|
|
51
|
+
* @returns {Promise<SignedBTCR2Update>} The signed update that was broadcast.
|
|
52
|
+
*/
|
|
53
|
+
abstract broadcastSignal(
|
|
54
|
+
signedUpdate: SignedBTCR2Update,
|
|
55
|
+
secretKey: KeyBytes,
|
|
56
|
+
bitcoin: BitcoinNetworkConnection
|
|
57
|
+
): Promise<SignedBTCR2Update>;
|
|
58
|
+
}
|