@did-btcr2/method 0.18.1 → 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 +4917 -6487
- package/dist/browser.mjs +4917 -6487
- package/dist/cjs/core/beacon/aggregation/cohort/index.js +3 -3
- package/dist/cjs/core/beacon/aggregation/cohort/index.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/base.js +1 -9
- package/dist/cjs/core/beacon/aggregation/cohort/messages/base.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js +2 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js +2 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js +2 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in.js +2 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/subscribe.js +2 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/subscribe.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js +2 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/authorization-request.js +2 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/authorization-request.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js +2 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/request-signature.js +2 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/request-signature.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js +2 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/communication/adapter/nostr.js +36 -18
- package/dist/cjs/core/beacon/aggregation/communication/adapter/nostr.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/coordinator.js +14 -14
- package/dist/cjs/core/beacon/aggregation/coordinator.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/participant.js +4 -3
- package/dist/cjs/core/beacon/aggregation/participant.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/session/index.js +1 -1
- package/dist/cjs/core/beacon/aggregation/session/index.js.map +1 -1
- 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 +39 -0
- package/dist/cjs/core/beacon/cas-beacon.js.map +1 -0
- 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 +10 -11
- package/dist/cjs/core/beacon/factory.js.map +1 -1
- package/dist/cjs/core/beacon/interfaces.js +2 -0
- package/dist/cjs/core/beacon/interfaces.js.map +1 -0
- 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 +75 -178
- package/dist/cjs/core/beacon/singleton.js.map +1 -1
- package/dist/cjs/core/beacon/smt-beacon.js +39 -0
- package/dist/cjs/core/beacon/smt-beacon.js.map +1 -0
- package/dist/cjs/core/beacon/utils.js +71 -114
- package/dist/cjs/core/beacon/utils.js.map +1 -1
- package/dist/cjs/core/identifier.js +18 -21
- package/dist/cjs/core/identifier.js.map +1 -1
- package/dist/cjs/core/interfaces.js +2 -0
- package/dist/cjs/core/interfaces.js.map +1 -0
- package/dist/cjs/core/resolve.js +321 -0
- package/dist/cjs/core/resolve.js.map +1 -0
- package/dist/cjs/{utils → core}/types.js.map +1 -1
- package/dist/cjs/core/update.js +113 -0
- package/dist/cjs/core/update.js.map +1 -0
- package/dist/cjs/did-btcr2.js +168 -129
- package/dist/cjs/did-btcr2.js.map +1 -1
- package/dist/cjs/index.js +17 -16
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils/appendix.js +16 -33
- 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 +62 -72
- package/dist/cjs/utils/did-document.js.map +1 -1
- package/dist/cjs/utils/general.js +1 -1
- package/dist/cjs/utils/general.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/index.js +3 -3
- package/dist/esm/core/beacon/aggregation/cohort/index.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/base.js +1 -9
- package/dist/esm/core/beacon/aggregation/cohort/messages/base.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js +2 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js +2 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js +2 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in.js +2 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/subscribe.js +2 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/subscribe.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js +2 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/authorization-request.js +2 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/authorization-request.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js +2 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/request-signature.js +2 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/request-signature.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js +2 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js +36 -18
- package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/coordinator.js +14 -14
- package/dist/esm/core/beacon/aggregation/coordinator.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/participant.js +4 -3
- package/dist/esm/core/beacon/aggregation/participant.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/session/index.js +1 -1
- package/dist/esm/core/beacon/aggregation/session/index.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 +39 -0
- package/dist/esm/core/beacon/cas-beacon.js.map +1 -0
- 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 +10 -11
- package/dist/esm/core/beacon/factory.js.map +1 -1
- package/dist/esm/core/beacon/interfaces.js +2 -0
- package/dist/esm/core/beacon/interfaces.js.map +1 -0
- 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 +75 -178
- package/dist/esm/core/beacon/singleton.js.map +1 -1
- package/dist/esm/core/beacon/smt-beacon.js +39 -0
- package/dist/esm/core/beacon/smt-beacon.js.map +1 -0
- package/dist/esm/core/beacon/utils.js +71 -114
- package/dist/esm/core/beacon/utils.js.map +1 -1
- package/dist/esm/core/identifier.js +18 -21
- package/dist/esm/core/identifier.js.map +1 -1
- package/dist/esm/core/interfaces.js +2 -0
- package/dist/esm/core/interfaces.js.map +1 -0
- package/dist/esm/core/resolve.js +321 -0
- package/dist/esm/core/resolve.js.map +1 -0
- package/dist/esm/{utils → core}/types.js.map +1 -1
- package/dist/esm/core/update.js +113 -0
- package/dist/esm/core/update.js.map +1 -0
- package/dist/esm/did-btcr2.js +168 -129
- package/dist/esm/did-btcr2.js.map +1 -1
- package/dist/esm/index.js +17 -16
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/appendix.js +16 -33
- 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 +62 -72
- package/dist/esm/utils/did-document.js.map +1 -1
- package/dist/esm/utils/general.js +1 -1
- package/dist/esm/utils/general.js.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/index.d.ts +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/base.d.ts +0 -7
- package/dist/types/core/beacon/aggregation/cohort/messages/base.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/subscribe.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/authorization-request.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/request-signature.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/signature-authorization.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts +13 -5
- package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/coordinator.d.ts +17 -29
- package/dist/types/core/beacon/aggregation/coordinator.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/participant.d.ts.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 +36 -0
- package/dist/types/core/beacon/cas-beacon.d.ts.map +1 -0
- 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 -5
- package/dist/types/core/beacon/factory.d.ts.map +1 -1
- package/dist/types/core/beacon/interfaces.d.ts +59 -0
- package/dist/types/core/beacon/interfaces.d.ts.map +1 -0
- 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 +20 -76
- package/dist/types/core/beacon/singleton.d.ts.map +1 -1
- package/dist/types/core/beacon/smt-beacon.d.ts +36 -0
- package/dist/types/core/beacon/smt-beacon.d.ts.map +1 -0
- package/dist/types/core/beacon/utils.d.ts +19 -97
- package/dist/types/core/beacon/utils.d.ts.map +1 -1
- package/dist/types/core/identifier.d.ts.map +1 -1
- package/dist/types/core/interfaces.d.ts +87 -0
- package/dist/types/core/interfaces.d.ts.map +1 -0
- package/dist/types/core/resolve.d.ts +89 -0
- package/dist/types/core/resolve.d.ts.map +1 -0
- package/dist/types/core/types.d.ts +84 -0
- package/dist/types/core/types.d.ts.map +1 -0
- package/dist/types/core/update.d.ts +51 -0
- package/dist/types/core/update.d.ts.map +1 -0
- package/dist/types/did-btcr2.d.ts +70 -89
- package/dist/types/did-btcr2.d.ts.map +1 -1
- package/dist/types/index.d.ts +17 -16
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/utils/appendix.d.ts +5 -10
- package/dist/types/utils/appendix.d.ts.map +1 -1
- package/dist/types/utils/did-document-builder.d.ts +6 -1
- package/dist/types/utils/did-document-builder.d.ts.map +1 -1
- package/dist/types/utils/did-document.d.ts +46 -42
- package/dist/types/utils/did-document.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/core/beacon/aggregation/cohort/index.ts +3 -3
- package/src/core/beacon/aggregation/cohort/messages/base.ts +1 -12
- package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.ts +2 -2
- package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.ts +2 -2
- package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.ts +2 -2
- package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in.ts +2 -2
- package/src/core/beacon/aggregation/cohort/messages/keygen/subscribe.ts +2 -2
- package/src/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.ts +2 -2
- package/src/core/beacon/aggregation/cohort/messages/sign/authorization-request.ts +2 -2
- package/src/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.ts +2 -2
- package/src/core/beacon/aggregation/cohort/messages/sign/request-signature.ts +2 -2
- package/src/core/beacon/aggregation/cohort/messages/sign/signature-authorization.ts +2 -2
- package/src/core/beacon/aggregation/communication/adapter/nostr.ts +43 -21
- package/src/core/beacon/aggregation/coordinator.ts +41 -29
- package/src/core/beacon/aggregation/participant.ts +4 -3
- package/src/core/beacon/aggregation/session/index.ts +1 -1
- package/src/core/beacon/beacon.ts +58 -0
- package/src/core/beacon/cas-beacon.ts +53 -0
- package/src/core/beacon/error.ts +5 -6
- package/src/core/beacon/factory.ts +12 -16
- package/src/core/beacon/interfaces.ts +67 -0
- package/src/core/beacon/signal-discovery.ts +237 -0
- package/src/core/beacon/singleton.ts +107 -197
- package/src/core/beacon/smt-beacon.ts +53 -0
- package/src/core/beacon/utils.ts +95 -182
- package/src/core/identifier.ts +21 -24
- package/src/core/interfaces.ts +93 -0
- package/src/core/resolve.ts +463 -0
- package/src/core/types.ts +95 -0
- package/src/core/update.ts +154 -0
- package/src/did-btcr2.ts +255 -159
- package/src/index.ts +19 -22
- package/src/utils/appendix.ts +26 -44
- package/src/utils/did-document-builder.ts +6 -1
- package/src/utils/did-document.ts +105 -113
- package/src/utils/general.ts +1 -1
- package/dist/cjs/core/beacon/cid-aggregate.js +0 -116
- package/dist/cjs/core/beacon/cid-aggregate.js.map +0 -1
- package/dist/cjs/core/beacon/smt-aggregate.js +0 -126
- package/dist/cjs/core/beacon/smt-aggregate.js.map +0 -1
- package/dist/cjs/core/crud/deactivate.js +0 -14
- package/dist/cjs/core/crud/deactivate.js.map +0 -1
- package/dist/cjs/core/crud/read.js +0 -679
- package/dist/cjs/core/crud/read.js.map +0 -1
- package/dist/cjs/core/crud/update.js +0 -194
- package/dist/cjs/core/crud/update.js.map +0 -1
- package/dist/cjs/interfaces/beacon.js +0 -41
- package/dist/cjs/interfaces/beacon.js.map +0 -1
- package/dist/cjs/interfaces/crud.js +0 -2
- package/dist/cjs/interfaces/crud.js.map +0 -1
- package/dist/esm/core/beacon/cid-aggregate.js +0 -116
- package/dist/esm/core/beacon/cid-aggregate.js.map +0 -1
- package/dist/esm/core/beacon/smt-aggregate.js +0 -126
- package/dist/esm/core/beacon/smt-aggregate.js.map +0 -1
- package/dist/esm/core/crud/deactivate.js +0 -14
- package/dist/esm/core/crud/deactivate.js.map +0 -1
- package/dist/esm/core/crud/read.js +0 -679
- package/dist/esm/core/crud/read.js.map +0 -1
- package/dist/esm/core/crud/update.js +0 -194
- package/dist/esm/core/crud/update.js.map +0 -1
- package/dist/esm/interfaces/beacon.js +0 -41
- package/dist/esm/interfaces/beacon.js.map +0 -1
- package/dist/esm/interfaces/crud.js +0 -2
- package/dist/esm/interfaces/crud.js.map +0 -1
- package/dist/types/core/beacon/cid-aggregate.d.ts +0 -102
- package/dist/types/core/beacon/cid-aggregate.d.ts.map +0 -1
- package/dist/types/core/beacon/smt-aggregate.d.ts +0 -111
- package/dist/types/core/beacon/smt-aggregate.d.ts.map +0 -1
- package/dist/types/core/crud/deactivate.d.ts +0 -13
- package/dist/types/core/crud/deactivate.d.ts.map +0 -1
- package/dist/types/core/crud/read.d.ts +0 -334
- package/dist/types/core/crud/read.d.ts.map +0 -1
- package/dist/types/core/crud/update.d.ts +0 -93
- package/dist/types/core/crud/update.d.ts.map +0 -1
- package/dist/types/interfaces/beacon.d.ts +0 -116
- package/dist/types/interfaces/beacon.d.ts.map +0 -1
- package/dist/types/interfaces/crud.d.ts +0 -32
- package/dist/types/interfaces/crud.d.ts.map +0 -1
- package/dist/types/utils/types.d.ts +0 -38
- package/dist/types/utils/types.d.ts.map +0 -1
- package/src/canonicalize.d.ts +0 -6
- package/src/core/beacon/cid-aggregate.ts +0 -153
- package/src/core/beacon/smt-aggregate.ts +0 -135
- package/src/core/crud/deactivate.ts +0 -13
- package/src/core/crud/read.ts +0 -948
- package/src/core/crud/update.ts +0 -292
- package/src/interfaces/beacon.ts +0 -137
- package/src/interfaces/crud.ts +0 -33
- package/src/utils/types.ts +0 -41
- /package/dist/cjs/{utils → core}/types.js +0 -0
- /package/dist/esm/{utils → core}/types.js +0 -0
|
@@ -1,32 +1,7 @@
|
|
|
1
1
|
import { KeyBytes, Maybe } from '@did-btcr2/common';
|
|
2
2
|
import { networks } from 'bitcoinjs-lib';
|
|
3
|
-
import { BeaconService, BeaconServiceAddress } from '../../interfaces/beacon.js';
|
|
4
3
|
import { DidDocument } from '../../utils/did-document.js';
|
|
5
|
-
|
|
6
|
-
identifier: string;
|
|
7
|
-
publicKey: KeyBytes;
|
|
8
|
-
network: networks.Network;
|
|
9
|
-
type: string;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Required parameters for generating Beacon Services.
|
|
13
|
-
* @interface GenerateBitcoinAddrsParams
|
|
14
|
-
* @type {GenerateBitcoinAddrsParams}
|
|
15
|
-
*/
|
|
16
|
-
export interface GenerateBitcoinAddrsParams {
|
|
17
|
-
publicKey: KeyBytes;
|
|
18
|
-
network: networks.Network;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Required parameters for generating Beacon Services.
|
|
22
|
-
* @interface GenerateBeaconServicesParams
|
|
23
|
-
* @type {GenerateBeaconServicesParams}
|
|
24
|
-
*/
|
|
25
|
-
export interface GenerateBeaconServicesParams {
|
|
26
|
-
publicKey: KeyBytes;
|
|
27
|
-
network: networks.Network;
|
|
28
|
-
beaconType: string;
|
|
29
|
-
}
|
|
4
|
+
import { BeaconService } from './interfaces.js';
|
|
30
5
|
/**
|
|
31
6
|
* Static class of utility functions for the Beacon Service
|
|
32
7
|
* @class BeaconUtils
|
|
@@ -54,98 +29,45 @@ export declare class BeaconUtils {
|
|
|
54
29
|
*/
|
|
55
30
|
static getBeaconServices(didDocument: DidDocument): BeaconService[];
|
|
56
31
|
/**
|
|
57
|
-
*
|
|
58
|
-
* @param {
|
|
59
|
-
* @param {KeyBytes} params.publicKey Public key bytes used to generate the beacon object serviceEndpoint.
|
|
60
|
-
* @param {Network} params.network Bitcoin network interface from bitcoinlib-js.
|
|
32
|
+
* Create the 3 default Beacon Service Endpoints for a given `k` (public-key-based) identifier.
|
|
33
|
+
* @param {string} did The DID for which to create the beacon services.
|
|
61
34
|
* @returns {Array<Array<string>>} 2D Array of bitcoin addresses (p2pkh, p2wpkh, p2tr).
|
|
62
35
|
* @throws {DidMethodError} if the bitcoin address is invalid.
|
|
63
36
|
*/
|
|
64
|
-
static
|
|
65
|
-
identifier: string;
|
|
66
|
-
publicKey: KeyBytes;
|
|
67
|
-
network: networks.Network;
|
|
68
|
-
}): Array<Array<string>>;
|
|
37
|
+
static createBeaconServices(did: string, beaconType: string): Array<BeaconService>;
|
|
69
38
|
/**
|
|
70
39
|
* Generate a set of Beacon Services for a given public key.
|
|
71
|
-
* @param {
|
|
72
|
-
* @param {
|
|
73
|
-
* @param {
|
|
74
|
-
* @param {string} params.beaconType The type of beacon service to create.
|
|
75
|
-
* @param {string} params.addressType The type of address to create (p2pkh, p2wpkh, p2tr).
|
|
40
|
+
* @param {string} did The did for the beacon service.
|
|
41
|
+
* @param {string} addressType The type of bitcoin address to generate (p2pkh, p2wpkh, p2tr).
|
|
42
|
+
* @param {string} beaconType The type of beacon service to create.
|
|
76
43
|
* @returns {BeaconService} A BeaconService object.
|
|
77
44
|
* @throws {DidMethodError} if the bitcoin address is invalid.
|
|
78
45
|
*/
|
|
79
|
-
static
|
|
80
|
-
id: string;
|
|
81
|
-
publicKey: KeyBytes;
|
|
82
|
-
network: networks.Network;
|
|
83
|
-
addressType: 'p2pkh' | 'p2wpkh' | 'p2tr';
|
|
84
|
-
type: string;
|
|
85
|
-
}): BeaconService;
|
|
46
|
+
static createBeaconService(did: string, addressType: 'p2pkh' | 'p2wpkh' | 'p2tr', beaconType: string): BeaconService;
|
|
86
47
|
/**
|
|
87
|
-
* Generate
|
|
88
|
-
* @param {
|
|
89
|
-
* @returns
|
|
48
|
+
* Generate three default Beacon Service Endpoints for a given `k` (public-key-based) identifier.
|
|
49
|
+
* @param {string} did The DID for which to create the beacon services.
|
|
50
|
+
* @returns {Array<Array<string>>} 2D Array of bitcoin addresses (p2pkh, p2wpkh, p2tr).
|
|
51
|
+
* @throws {DidMethodError} if the bitcoin address is invalid.
|
|
90
52
|
*/
|
|
91
|
-
static
|
|
53
|
+
static generateBeaconServices({ id, publicKey, network, beaconType }: {
|
|
92
54
|
id: string;
|
|
93
55
|
publicKey: KeyBytes;
|
|
94
56
|
network: networks.Network;
|
|
95
|
-
|
|
96
|
-
type: string;
|
|
97
|
-
}): BeaconService;
|
|
98
|
-
/**
|
|
99
|
-
* Generate beacon services.
|
|
100
|
-
* @param {GenerateBeaconServicesParams} params Required parameters for generating Beacon Services.
|
|
101
|
-
* @param {string} params.network The name of the Bitcoin network to use.
|
|
102
|
-
* @param {Uint8Array} params.publicKey Byte array representation of a public key used to generate a new btcr2 key-id-type.
|
|
103
|
-
* @param {string} params.beaconType Optional beacon type to use (default: SingletonBeacon).
|
|
104
|
-
* @returns {DidService[]} Array of DidService objects.
|
|
105
|
-
*/
|
|
106
|
-
static generateBeaconServices({ identifier, network, type, publicKey }: {
|
|
107
|
-
identifier: string;
|
|
108
|
-
publicKey: KeyBytes;
|
|
109
|
-
network: networks.Network;
|
|
110
|
-
type: string;
|
|
57
|
+
beaconType: string;
|
|
111
58
|
}): Array<BeaconService>;
|
|
112
|
-
/**
|
|
113
|
-
* Generate a single beacon service.
|
|
114
|
-
* @param {GenerateBeaconParams} params Required parameters for generating a single Beacon Service.
|
|
115
|
-
* @param {string} params.identifier The identifier for the beacon service.
|
|
116
|
-
* @param {string} params.network The name of the Bitcoin network to use.
|
|
117
|
-
* @param {Uint8Array} params.publicKey Byte array representation of a public key used to generate a new btcr2 key-id-type.
|
|
118
|
-
* @param {string} params.type The type of beacon service to create.
|
|
119
|
-
* @returns {BeaconService} A BeaconService object.
|
|
120
|
-
* @throws {DidMethodError} if the bitcoin address is invalid.
|
|
121
|
-
*/
|
|
122
|
-
static generateBeacon({ identifier, network, type, publicKey }: {
|
|
123
|
-
identifier: string;
|
|
124
|
-
publicKey: KeyBytes;
|
|
125
|
-
network: networks.Network;
|
|
126
|
-
type: string;
|
|
127
|
-
}): BeaconService;
|
|
128
|
-
/**
|
|
129
|
-
* Manufacture a pre-filled Beacon using the BeaconFactory.
|
|
130
|
-
* @param {BeaconServicesParams} params Required parameters for generating a single Beacon Service.
|
|
131
|
-
* @param {string} params.serviceId The type of service being created (#initialP2PKH, #initialP2WPKH, #initialP2TR).
|
|
132
|
-
* @param {string} params.beaconType The type of beacon service being created (SingletonBeacon, SMTAggregatorBeacon).
|
|
133
|
-
* @param {string} params.bitcoinAddress The bitcoin address to use for the service endpoint.
|
|
134
|
-
* @returns {BeaconService} One BeaconService object.
|
|
135
|
-
*/
|
|
136
|
-
static manufactureBeacon(params: BeaconService): BeaconService;
|
|
137
59
|
/**
|
|
138
60
|
* Convert beacon service endpoints from BIP-21 URIs to addresses.
|
|
139
|
-
* @param {
|
|
140
|
-
* @returns {
|
|
61
|
+
* @param {BeaconService} beacon The beacon service to parse.
|
|
62
|
+
* @returns {BeaconServiceAddress} The beacon service with the address field extracted from the serviceEndpoint.
|
|
141
63
|
*/
|
|
142
|
-
static
|
|
64
|
+
static parseBeaconServiceEndpoint(beacon: BeaconService): BeaconService;
|
|
143
65
|
/**
|
|
144
66
|
* Create a map of address => beaconService with address field.
|
|
145
67
|
* @param {Array<BeaconService>} beacons The list of beacon services.
|
|
146
|
-
* @returns {Map<string,
|
|
68
|
+
* @returns {Map<string, BeaconService>} A map of address => beaconService.
|
|
147
69
|
*/
|
|
148
|
-
static
|
|
70
|
+
static getBeaconServicesMap(beacons: Array<BeaconService>): Map<string, BeaconService>;
|
|
149
71
|
/**
|
|
150
72
|
* Get the beacon service ids from a list of beacon services.
|
|
151
73
|
* @param {DidDocument} didDocument The DID Document to extract the services from.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/core/beacon/utils.ts"],"names":[],"mappings":"
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identifier.d.ts","sourceRoot":"","sources":["../../../src/core/identifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,
|
|
1
|
+
{"version":3,"file":"identifier.d.ts","sourceRoot":"","sources":["../../../src/core/identifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,EAAuE,MAAM,mBAAmB,CAAC;AACpI,OAAO,EAAgC,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGlF;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAa;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,KAAK,CAAC;CACvB;AAED;;;;;;;;;;GAUG;AACH,qBAAa,UAAU;IACrB;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE;QACxD,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,YAAY,EAAE,KAAK,CAAC;KACrB,GAAG,MAAM;IAoFV;;;;;;;OAOG;IACH,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,aAAa;IA8HhD;;;OAGG;IACH,MAAM,CAAC,QAAQ,IAAI;QAAE,IAAI,EAAE,cAAc,CAAC;QAAC,UAAU,EAAE;YAAE,UAAU,EAAE,MAAM,CAAC;YAAC,EAAE,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE;IAY3F;;;;OAIG;IACH,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;CAQ5C"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { BitcoinNetworkConnection } from '@did-btcr2/bitcoin';
|
|
2
|
+
import { DidResolutionOptions } from '@web5/dids';
|
|
3
|
+
import { Sidecar } from './types.js';
|
|
4
|
+
export interface RootCapability {
|
|
5
|
+
'@context': string;
|
|
6
|
+
id: string;
|
|
7
|
+
controller: string;
|
|
8
|
+
invocationTarget: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* See {@link https://dcdpr.github.io/did-btcr2/data-structures.html#resolution-options-example-panel-show | Resolution Options}
|
|
12
|
+
* for data structure details.
|
|
13
|
+
*/
|
|
14
|
+
export interface ResolutionOptionsCore extends DidResolutionOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Optional ASCII string representation of the specific version of a DID document
|
|
17
|
+
* to be resolved.
|
|
18
|
+
*/
|
|
19
|
+
versionId?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Optional XML Datetime normalized to UTC without sub-second decimal precision.
|
|
22
|
+
* The DID document to be resolved is the most recent version of the DID document
|
|
23
|
+
* that was valid for the DID before the specified versionTime.
|
|
24
|
+
*/
|
|
25
|
+
versionTime?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Data transmitted via {@link https://dcdpr.github.io/did-btcr2/data-structures.html#sidecar-data-example-panel-show | Sidecar (data structure)}.
|
|
28
|
+
* Includes Singleton beacon updates, CAS announcements, and SMT proofs.
|
|
29
|
+
*/
|
|
30
|
+
sidecar?: Sidecar;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Full set of resolution options for the did:btcr2 method. See {@link ResolutionOptionsCore}
|
|
34
|
+
* for the resolution options defined by the specification.
|
|
35
|
+
* @extends ResolutionOptionsCore
|
|
36
|
+
*/
|
|
37
|
+
export interface ResolutionOptions extends ResolutionOptionsCore {
|
|
38
|
+
/**
|
|
39
|
+
* Drivers for interacting with external systems, such as the Bitcoin network.
|
|
40
|
+
*/
|
|
41
|
+
drivers?: {
|
|
42
|
+
bitcoin?: BitcoinNetworkConnection;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* {@link https://dcdpr.github.io/did-btcr2/terminology.html#smt-proof | SMT Proof}
|
|
47
|
+
* a set of SHA-256 hashes for nodes in a Sparse Merkle Tree that together form
|
|
48
|
+
* a path from a leaf in the tree to the Merkle root, proving that the leaf is in the tree.
|
|
49
|
+
* See {@link https://dcdpr.github.io/did-btcr2/data-structures.html#smt-proof | SMT Proof (data structure)}.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```json
|
|
53
|
+
* {
|
|
54
|
+
* "id": "<< Hexadecimal of Root Hash >>",
|
|
55
|
+
* "nonce": "<< Hexadecimal of Nonce 1101 >>",
|
|
56
|
+
* "updateId": "<< Hexadecimal of hash(Data Block 1101) >>",
|
|
57
|
+
* "collapsed": "<< Hexadecimal of 0001 >>",
|
|
58
|
+
* "hashes": [
|
|
59
|
+
* "<< Hexadecimal of Hash 1110 >>",
|
|
60
|
+
* "<< Hexadecimal of Hash 1001 >>",
|
|
61
|
+
* "<< Hexadecimal of Hash 0 >>"
|
|
62
|
+
* ]
|
|
63
|
+
* }
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export interface SMTProof {
|
|
67
|
+
/**
|
|
68
|
+
* The SHA-256 hash of the root node of the Sparse Merkle Tree.
|
|
69
|
+
*/
|
|
70
|
+
id: string;
|
|
71
|
+
/**
|
|
72
|
+
* Optional 256-bit nonce generated for each update. MUST be encoded as a string using the "base64url" [RFC4648] encoding.
|
|
73
|
+
*/
|
|
74
|
+
nonce?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Optional BTCR2 Signed Update (data structure) hashed with the JSON Document Hashing algorithm.
|
|
77
|
+
*/
|
|
78
|
+
updateId?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Bitmap of zero nodes within the path (see: collapsed leaves).
|
|
81
|
+
*/
|
|
82
|
+
collapsed: string;
|
|
83
|
+
/**
|
|
84
|
+
* Array of SHA-256 hashes representing the sibling SMT nodes from the leaf, containing the SHA-256 hash of the BTCR2 Signed Update or the “zero identity”, to the root.
|
|
85
|
+
*/
|
|
86
|
+
hashes: string[];
|
|
87
|
+
}
|
|
@@ -0,0 +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,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"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { BitcoinNetworkConnection } from '@did-btcr2/bitcoin';
|
|
2
|
+
import { SignedBTCR2Update } from '@did-btcr2/cryptosuite';
|
|
3
|
+
import { DidDocument } from '../utils/did-document.js';
|
|
4
|
+
import { BeaconService, BlockMetadata } from './beacon/interfaces.js';
|
|
5
|
+
import { DidComponents } from './identifier.js';
|
|
6
|
+
import { Sidecar, SidecarData } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* The response object for DID Resolution.
|
|
9
|
+
*/
|
|
10
|
+
export interface DidResolutionResponse {
|
|
11
|
+
currentDocument: DidDocument;
|
|
12
|
+
confirmations: number;
|
|
13
|
+
versionId: string;
|
|
14
|
+
updated: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Implements {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html | 7.2 Resolve}.
|
|
18
|
+
* Resolving a did:btcr2 identifier iteratively builds a DID document by applying BTCR2 Updates
|
|
19
|
+
* to an Initial DID Document that have been committed to the Bitcoin blockchain by Authorized
|
|
20
|
+
* Beacon Signals. The Initial DID Document is either deterministically created from the DID or
|
|
21
|
+
* provided by Sidecar Data.
|
|
22
|
+
* @class Resolve
|
|
23
|
+
* @type {Resolve}
|
|
24
|
+
*/
|
|
25
|
+
export declare class Resolve {
|
|
26
|
+
/**
|
|
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}.
|
|
28
|
+
* @param {DidComponents} didComponents The decoded components of the did.
|
|
29
|
+
* @returns {DidDocument} The resolved DID Document object.
|
|
30
|
+
*/
|
|
31
|
+
static deterministic(didComponents: DidComponents): DidDocument;
|
|
32
|
+
/**
|
|
33
|
+
* Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#if-genesis_bytes-is-a-sha-256-hash | 7.2.d.2 if genesis_bytes is a SHA-256 Hash}.
|
|
34
|
+
* @param {DidComponents} didComponents BTCR2 DID components used to resolve the DID Document
|
|
35
|
+
* @param {GenesisDocument} genesisDocument The genesis document for resolving the DID Document.
|
|
36
|
+
* @returns {Promise<DidDocument>} The resolved DID Document object
|
|
37
|
+
* @throws {ResolveError} InvalidDidDocument if not conformant to DID Core v1.1
|
|
38
|
+
*/
|
|
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
|
+
/**
|
|
57
|
+
* Finds uses the beacon services in the currentDocument to scan for onchain Beacon Signals (transactions) containing
|
|
58
|
+
* Signal Bytes (last output in OP_RETURN transaction).
|
|
59
|
+
* @param {Array<BeaconService>} beaconServices The array of BeaconService objects to search for signals.
|
|
60
|
+
* @param {SidecarData} sidecarData The sidecar data containing maps of updates, CAS announcements, and SMT proofs.
|
|
61
|
+
* @param {BitcoinNetworkConnection} bitcoin The bitcoin network connection used to fetch beacon signals
|
|
62
|
+
* @returns {Promise<Array<[SignedBTCR2Update, BlockMetadata]>>} The array of BTCR2 Signed Updates announced by the Beacon Signals.
|
|
63
|
+
*/
|
|
64
|
+
static beaconSignals(beaconServices: Array<BeaconService>, sidecarData: SidecarData, bitcoin: BitcoinNetworkConnection): Promise<Array<[SignedBTCR2Update, BlockMetadata]>>;
|
|
65
|
+
/**
|
|
66
|
+
* Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#process-updates | 7.2.f Process updates Array}.
|
|
67
|
+
* @param {DidDocument} currentDocument The current DID Document to apply the updates to.
|
|
68
|
+
* @param {Array<[SignedBTCR2Update, BlockMetadata]>} unsortedUpdates The unsorted array of BTCR2 Signed Updates and their associated Block Metadata.
|
|
69
|
+
* @param {string} [versionTime] The optional version time to limit updates to.
|
|
70
|
+
* @param {string} [versionId] The optional version id to limit updates to.
|
|
71
|
+
* @returns {Promise<DidResolutionResponse>} The updated DID Document, number of confirmations, and version id.
|
|
72
|
+
*/
|
|
73
|
+
static updates(currentDocument: DidDocument, unsortedUpdates: Array<[SignedBTCR2Update, BlockMetadata]>, versionTime?: string, versionId?: string): Promise<DidResolutionResponse>;
|
|
74
|
+
/**
|
|
75
|
+
* Implements subsection {@link https://dcdpr.github.io/did-btcr2/#confirm-duplicate-update | 7.2.f.1 Confirm Duplicate Update}.
|
|
76
|
+
* This step confirms that an update with a lower-than-expected targetVersionId is a true duplicate.
|
|
77
|
+
* @param {SignedBTCR2Update} update The BTCR2 Signed Update to confirm as a duplicate.
|
|
78
|
+
* @returns {void} Does not return a value, but throws an error if the update is not a valid duplicate.
|
|
79
|
+
*/
|
|
80
|
+
static confirmDuplicate(update: SignedBTCR2Update, updateHashHistory: string[]): void;
|
|
81
|
+
/**
|
|
82
|
+
* Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#apply-update | 7.2.f.3 Apply Update}.
|
|
83
|
+
* @param {DidDocument} currentDocument The current DID Document to apply the update to.
|
|
84
|
+
* @param {SignedBTCR2Update} update The BTCR2 Signed Update to apply.
|
|
85
|
+
* @returns {Promise<DidDocument>} The updated DID Document after applying the update.
|
|
86
|
+
* @throws {ResolveError} If the update is invalid or cannot be applied.
|
|
87
|
+
*/
|
|
88
|
+
static applyUpdate(currentDocument: DidDocument, update: SignedBTCR2Update): Promise<DidDocument>;
|
|
89
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { HexString } from '@did-btcr2/common';
|
|
2
|
+
import { SignedBTCR2Update } from '@did-btcr2/cryptosuite';
|
|
3
|
+
import { SMTProof } from './interfaces.js';
|
|
4
|
+
/**
|
|
5
|
+
* {@link https://dcdpr.github.io/did-btcr2/data-structures.html#cas-announcement | CAS Announcement }
|
|
6
|
+
* a data structure that maps DIDs to BTCR2 Signed Update hashes. All BTCR2 Signed
|
|
7
|
+
* Updates (data structure) MUST be hashed with the JSON Document Hashing algorithm.
|
|
8
|
+
* The concrete representation of this data structure will be published to a CAS.
|
|
9
|
+
* @example
|
|
10
|
+
* ```json
|
|
11
|
+
* {
|
|
12
|
+
* "did:btcr2:k1q5pa5tq86fzrl0ez32nh8e0ks4tzzkxnnmn8tdvxk04ahzt70u09dag02h0cp": "a4ayc_80_OGda4BO_1o_V0etpOqiLx1JwB5S3beHW0s",
|
|
13
|
+
* "did:btcr2:x1qhjw6jnhwcyu5wau4x0cpwvz74c3g82c3uaehqpaf7lzfgmnwsd7spmmf54": "1HNeOiZeFu7gP1lxi5tdAwGcB9i2xR-Q2jpmbuwTqzU",
|
|
14
|
+
* "did:btcr2:k1qgp5h79scv4sfqkzak5g6y89dsy3cq0pd2nussu2cm3zjfhn4ekwrucc4q7t7": "TgdAhWK-24tgzgXB3s_jrRa3IjCWfeAfZAt-Rym0n84"
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export type CASAnnouncement = {
|
|
19
|
+
[key: string]: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* See {@link https://dcdpr.github.io/did-btcr2/terminology.html#sidecar | Sidecar }
|
|
23
|
+
* for more details about the sidecar mechanism. See {@link https://dcdpr.github.io/did-btcr2/data-structures.html#sidecar-data | Sidecar Data}
|
|
24
|
+
* for more details about the data structure.
|
|
25
|
+
*/
|
|
26
|
+
export type Sidecar = {
|
|
27
|
+
/**
|
|
28
|
+
* The context string "https://btcr2.dev/context/v1"
|
|
29
|
+
*/
|
|
30
|
+
'@context'?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Optional Genesis Did Document. Required when resolving did:btcr2 identifiers
|
|
33
|
+
* with `x` HRP.D
|
|
34
|
+
*/
|
|
35
|
+
genesisDocument?: object;
|
|
36
|
+
/**
|
|
37
|
+
* Optional array of BTCR2 Signed Updates. Required if the DID being resolved
|
|
38
|
+
* has ever had a published BTCR2 Update.
|
|
39
|
+
*/
|
|
40
|
+
updates?: Array<SignedBTCR2Update>;
|
|
41
|
+
/**
|
|
42
|
+
* Optional array of CAS Announcements. Required if the DID being reslved has
|
|
43
|
+
* used a CAS Beacon to publish a BTCR2 Update.
|
|
44
|
+
*/
|
|
45
|
+
casUpdates?: Array<CASAnnouncement>;
|
|
46
|
+
/**
|
|
47
|
+
* Optional array of SMT Proofs. Required if the DID being resolved has used
|
|
48
|
+
* an SMT Beacon to publish a BTCR2 Update.
|
|
49
|
+
*/
|
|
50
|
+
smtProofs?: Array<SMTProof>;
|
|
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>;
|
|
64
|
+
/**
|
|
65
|
+
* The Sidecar data structure post-processing used for resolution.
|
|
66
|
+
*/
|
|
67
|
+
export type SidecarData = {
|
|
68
|
+
/**
|
|
69
|
+
* Map of BTCR2 Signed Updates by their hash bytes.
|
|
70
|
+
*/
|
|
71
|
+
updateMap: SingletonBeaconSidecarData;
|
|
72
|
+
/**
|
|
73
|
+
* Map of CAS Announcements by their hash bytes.
|
|
74
|
+
*/
|
|
75
|
+
casMap: CASBeaconSidecarData;
|
|
76
|
+
/**
|
|
77
|
+
* Map of SMT Proofs by their ID.
|
|
78
|
+
*/
|
|
79
|
+
smtMap: SMTBeaconSidecarData;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Union type for all Beacon Sidecar data structures.
|
|
83
|
+
*/
|
|
84
|
+
export type BeaconSidecarData = SingletonBeaconSidecarData | CASBeaconSidecarData | SMTBeaconSidecarData;
|
|
@@ -0,0 +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,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"}
|
|
@@ -0,0 +1,51 @@
|
|
|
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';
|
|
6
|
+
/**
|
|
7
|
+
* Implements {@link https://dcdpr.github.io/did-btcr2/operations/update.html | 7.3 Update}.
|
|
8
|
+
*
|
|
9
|
+
* An update to a did:btcr2 document is an invoked capability using the ZCAP-LD
|
|
10
|
+
* data format, signed by a verificationMethod that has the authority to make
|
|
11
|
+
* the update as specified in the previous DID document. Capability invocations
|
|
12
|
+
* for updates MUST be authorized using Data Integrity following the
|
|
13
|
+
* bip340-jcs-2025 cryptosuite with a proofPurpose of capabilityInvocation.
|
|
14
|
+
*
|
|
15
|
+
* @class Update
|
|
16
|
+
* @type {Update}
|
|
17
|
+
*/
|
|
18
|
+
export declare class Update {
|
|
19
|
+
/**
|
|
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.
|
|
22
|
+
*
|
|
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.
|
|
28
|
+
*/
|
|
29
|
+
static construct(sourceDocument: Btcr2DidDocument, patches: PatchOperation[], sourceVersionId: number): Promise<UnsignedBTCR2Update>;
|
|
30
|
+
/**
|
|
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.
|
|
33
|
+
*
|
|
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
|
|
39
|
+
*/
|
|
40
|
+
static sign(did: string, unsignedUpdate: UnsignedBTCR2Update, verificationMethod: DidVerificationMethod, secretKey: KeyBytes): Promise<SignedBTCR2Update>;
|
|
41
|
+
/**
|
|
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
|
|
49
|
+
*/
|
|
50
|
+
static announce(beaconService: BeaconService, update: SignedBTCR2Update, secretKey: KeyBytes, bitcoin: BitcoinNetworkConnection): Promise<SignedBTCR2Update>;
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|