@did-btcr2/method 0.13.1
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/LICENSE +373 -0
- package/README.md +7 -0
- package/dist/browser.js +2364 -0
- package/dist/browser.js.map +7 -0
- package/dist/browser.mjs +2364 -0
- package/dist/browser.mjs.map +7 -0
- package/dist/cjs/bitcoin/constants.js +20 -0
- package/dist/cjs/bitcoin/constants.js.map +1 -0
- package/dist/cjs/bitcoin/errors.js +11 -0
- package/dist/cjs/bitcoin/errors.js.map +1 -0
- package/dist/cjs/bitcoin/index.js +95 -0
- package/dist/cjs/bitcoin/index.js.map +1 -0
- package/dist/cjs/bitcoin/interface.js +2 -0
- package/dist/cjs/bitcoin/interface.js.map +1 -0
- package/dist/cjs/bitcoin/network.js +17 -0
- package/dist/cjs/bitcoin/network.js.map +1 -0
- package/dist/cjs/bitcoin/rest-client.js +289 -0
- package/dist/cjs/bitcoin/rest-client.js.map +1 -0
- package/dist/cjs/bitcoin/rpc-client.js +722 -0
- package/dist/cjs/bitcoin/rpc-client.js.map +1 -0
- package/dist/cjs/bitcoin/taproot.js +219 -0
- package/dist/cjs/bitcoin/taproot.js.map +1 -0
- package/dist/cjs/btcr2/beacon/aggregation/coordinator.js +120 -0
- package/dist/cjs/btcr2/beacon/aggregation/coordinator.js.map +1 -0
- package/dist/cjs/btcr2/beacon/aggregation/messages/advert.js +24 -0
- package/dist/cjs/btcr2/beacon/aggregation/messages/advert.js.map +1 -0
- package/dist/cjs/btcr2/beacon/aggregation/messages/base.js +37 -0
- package/dist/cjs/btcr2/beacon/aggregation/messages/base.js.map +1 -0
- package/dist/cjs/btcr2/beacon/aggregation/messages/cohort-set.js +25 -0
- package/dist/cjs/btcr2/beacon/aggregation/messages/cohort-set.js.map +1 -0
- package/dist/cjs/btcr2/beacon/aggregation/messages/keygen.js +8 -0
- package/dist/cjs/btcr2/beacon/aggregation/messages/keygen.js.map +1 -0
- package/dist/cjs/btcr2/beacon/aggregation/messages/opt-in.js +23 -0
- package/dist/cjs/btcr2/beacon/aggregation/messages/opt-in.js.map +1 -0
- package/dist/cjs/btcr2/beacon/aggregation/messages/sign.js +7 -0
- package/dist/cjs/btcr2/beacon/aggregation/messages/sign.js.map +1 -0
- package/dist/cjs/btcr2/beacon/aggregation/models/cohort/index.js +92 -0
- package/dist/cjs/btcr2/beacon/aggregation/models/cohort/index.js.map +1 -0
- package/dist/cjs/btcr2/beacon/aggregation/models/cohort/status.js +8 -0
- package/dist/cjs/btcr2/beacon/aggregation/models/cohort/status.js.map +1 -0
- package/dist/cjs/btcr2/beacon/aggregation/participant.js +2 -0
- package/dist/cjs/btcr2/beacon/aggregation/participant.js.map +1 -0
- package/dist/cjs/btcr2/beacon/aggregation/protocol/nostr.js +57 -0
- package/dist/cjs/btcr2/beacon/aggregation/protocol/nostr.js.map +1 -0
- package/dist/cjs/btcr2/beacon/aggregation/protocol/service.js +2 -0
- package/dist/cjs/btcr2/beacon/aggregation/protocol/service.js.map +1 -0
- package/dist/cjs/btcr2/beacon/cid-aggregate.js +116 -0
- package/dist/cjs/btcr2/beacon/cid-aggregate.js.map +1 -0
- package/dist/cjs/btcr2/beacon/factory.js +30 -0
- package/dist/cjs/btcr2/beacon/factory.js.map +1 -0
- package/dist/cjs/btcr2/beacon/singleton.js +220 -0
- package/dist/cjs/btcr2/beacon/singleton.js.map +1 -0
- package/dist/cjs/btcr2/beacon/smt-aggregate.js +126 -0
- package/dist/cjs/btcr2/beacon/smt-aggregate.js.map +1 -0
- package/dist/cjs/btcr2/crud/create.js +102 -0
- package/dist/cjs/btcr2/crud/create.js.map +1 -0
- package/dist/cjs/btcr2/crud/deactivate.js +14 -0
- package/dist/cjs/btcr2/crud/deactivate.js.map +1 -0
- package/dist/cjs/btcr2/crud/read.js +686 -0
- package/dist/cjs/btcr2/crud/read.js.map +1 -0
- package/dist/cjs/btcr2/crud/update.js +195 -0
- package/dist/cjs/btcr2/crud/update.js.map +1 -0
- package/dist/cjs/btcr2/key-manager/index.js +290 -0
- package/dist/cjs/btcr2/key-manager/index.js.map +1 -0
- package/dist/cjs/btcr2/key-manager/interface.js +2 -0
- package/dist/cjs/btcr2/key-manager/interface.js.map +1 -0
- package/dist/cjs/did-btcr2.js +222 -0
- package/dist/cjs/did-btcr2.js.map +1 -0
- package/dist/cjs/index.js +27 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/interfaces/beacon.js +41 -0
- package/dist/cjs/interfaces/beacon.js.map +1 -0
- package/dist/cjs/interfaces/crud.js +2 -0
- package/dist/cjs/interfaces/crud.js.map +1 -0
- package/dist/cjs/interfaces/ibeacon.js +2 -0
- package/dist/cjs/interfaces/ibeacon.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/types/bitcoin.js +62 -0
- package/dist/cjs/types/bitcoin.js.map +1 -0
- package/dist/cjs/types/crud.js +2 -0
- package/dist/cjs/types/crud.js.map +1 -0
- package/dist/cjs/utils/appendix.js +221 -0
- package/dist/cjs/utils/appendix.js.map +1 -0
- package/dist/cjs/utils/beacons.js +206 -0
- package/dist/cjs/utils/beacons.js.map +1 -0
- package/dist/cjs/utils/did-document-builder.js +61 -0
- package/dist/cjs/utils/did-document-builder.js.map +1 -0
- package/dist/cjs/utils/did-document.js +380 -0
- package/dist/cjs/utils/did-document.js.map +1 -0
- package/dist/cjs/utils/general.js +195 -0
- package/dist/cjs/utils/general.js.map +1 -0
- package/dist/cjs/utils/identifier.js +238 -0
- package/dist/cjs/utils/identifier.js.map +1 -0
- package/dist/esm/bitcoin/constants.js +20 -0
- package/dist/esm/bitcoin/constants.js.map +1 -0
- package/dist/esm/bitcoin/errors.js +11 -0
- package/dist/esm/bitcoin/errors.js.map +1 -0
- package/dist/esm/bitcoin/index.js +95 -0
- package/dist/esm/bitcoin/index.js.map +1 -0
- package/dist/esm/bitcoin/interface.js +2 -0
- package/dist/esm/bitcoin/interface.js.map +1 -0
- package/dist/esm/bitcoin/network.js +17 -0
- package/dist/esm/bitcoin/network.js.map +1 -0
- package/dist/esm/bitcoin/rest-client.js +289 -0
- package/dist/esm/bitcoin/rest-client.js.map +1 -0
- package/dist/esm/bitcoin/rpc-client.js +722 -0
- package/dist/esm/bitcoin/rpc-client.js.map +1 -0
- package/dist/esm/bitcoin/taproot.js +219 -0
- package/dist/esm/bitcoin/taproot.js.map +1 -0
- package/dist/esm/btcr2/beacon/aggregation/coordinator.js +120 -0
- package/dist/esm/btcr2/beacon/aggregation/coordinator.js.map +1 -0
- package/dist/esm/btcr2/beacon/aggregation/messages/advert.js +24 -0
- package/dist/esm/btcr2/beacon/aggregation/messages/advert.js.map +1 -0
- package/dist/esm/btcr2/beacon/aggregation/messages/base.js +37 -0
- package/dist/esm/btcr2/beacon/aggregation/messages/base.js.map +1 -0
- package/dist/esm/btcr2/beacon/aggregation/messages/cohort-set.js +25 -0
- package/dist/esm/btcr2/beacon/aggregation/messages/cohort-set.js.map +1 -0
- package/dist/esm/btcr2/beacon/aggregation/messages/keygen.js +8 -0
- package/dist/esm/btcr2/beacon/aggregation/messages/keygen.js.map +1 -0
- package/dist/esm/btcr2/beacon/aggregation/messages/opt-in.js +23 -0
- package/dist/esm/btcr2/beacon/aggregation/messages/opt-in.js.map +1 -0
- package/dist/esm/btcr2/beacon/aggregation/messages/sign.js +7 -0
- package/dist/esm/btcr2/beacon/aggregation/messages/sign.js.map +1 -0
- package/dist/esm/btcr2/beacon/aggregation/models/cohort/index.js +92 -0
- package/dist/esm/btcr2/beacon/aggregation/models/cohort/index.js.map +1 -0
- package/dist/esm/btcr2/beacon/aggregation/models/cohort/status.js +8 -0
- package/dist/esm/btcr2/beacon/aggregation/models/cohort/status.js.map +1 -0
- package/dist/esm/btcr2/beacon/aggregation/participant.js +2 -0
- package/dist/esm/btcr2/beacon/aggregation/participant.js.map +1 -0
- package/dist/esm/btcr2/beacon/aggregation/protocol/nostr.js +57 -0
- package/dist/esm/btcr2/beacon/aggregation/protocol/nostr.js.map +1 -0
- package/dist/esm/btcr2/beacon/aggregation/protocol/service.js +2 -0
- package/dist/esm/btcr2/beacon/aggregation/protocol/service.js.map +1 -0
- package/dist/esm/btcr2/beacon/cid-aggregate.js +116 -0
- package/dist/esm/btcr2/beacon/cid-aggregate.js.map +1 -0
- package/dist/esm/btcr2/beacon/factory.js +30 -0
- package/dist/esm/btcr2/beacon/factory.js.map +1 -0
- package/dist/esm/btcr2/beacon/singleton.js +220 -0
- package/dist/esm/btcr2/beacon/singleton.js.map +1 -0
- package/dist/esm/btcr2/beacon/smt-aggregate.js +126 -0
- package/dist/esm/btcr2/beacon/smt-aggregate.js.map +1 -0
- package/dist/esm/btcr2/crud/create.js +102 -0
- package/dist/esm/btcr2/crud/create.js.map +1 -0
- package/dist/esm/btcr2/crud/deactivate.js +14 -0
- package/dist/esm/btcr2/crud/deactivate.js.map +1 -0
- package/dist/esm/btcr2/crud/read.js +686 -0
- package/dist/esm/btcr2/crud/read.js.map +1 -0
- package/dist/esm/btcr2/crud/update.js +195 -0
- package/dist/esm/btcr2/crud/update.js.map +1 -0
- package/dist/esm/btcr2/key-manager/index.js +290 -0
- package/dist/esm/btcr2/key-manager/index.js.map +1 -0
- package/dist/esm/btcr2/key-manager/interface.js +2 -0
- package/dist/esm/btcr2/key-manager/interface.js.map +1 -0
- package/dist/esm/did-btcr2.js +222 -0
- package/dist/esm/did-btcr2.js.map +1 -0
- package/dist/esm/index.js +27 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/interfaces/beacon.js +41 -0
- package/dist/esm/interfaces/beacon.js.map +1 -0
- package/dist/esm/interfaces/crud.js +2 -0
- package/dist/esm/interfaces/crud.js.map +1 -0
- package/dist/esm/interfaces/ibeacon.js +2 -0
- package/dist/esm/interfaces/ibeacon.js.map +1 -0
- package/dist/esm/types/bitcoin.js +62 -0
- package/dist/esm/types/bitcoin.js.map +1 -0
- package/dist/esm/types/crud.js +2 -0
- package/dist/esm/types/crud.js.map +1 -0
- package/dist/esm/utils/appendix.js +221 -0
- package/dist/esm/utils/appendix.js.map +1 -0
- package/dist/esm/utils/beacons.js +206 -0
- package/dist/esm/utils/beacons.js.map +1 -0
- package/dist/esm/utils/did-document-builder.js +61 -0
- package/dist/esm/utils/did-document-builder.js.map +1 -0
- package/dist/esm/utils/did-document.js +380 -0
- package/dist/esm/utils/did-document.js.map +1 -0
- package/dist/esm/utils/general.js +195 -0
- package/dist/esm/utils/general.js.map +1 -0
- package/dist/esm/utils/identifier.js +238 -0
- package/dist/esm/utils/identifier.js.map +1 -0
- package/dist/types/bitcoin/constants.d.ts +19 -0
- package/dist/types/bitcoin/constants.d.ts.map +1 -0
- package/dist/types/bitcoin/errors.d.ts +5 -0
- package/dist/types/bitcoin/errors.d.ts.map +1 -0
- package/dist/types/bitcoin/index.d.ts +75 -0
- package/dist/types/bitcoin/index.d.ts.map +1 -0
- package/dist/types/bitcoin/interface.d.ts +86 -0
- package/dist/types/bitcoin/interface.d.ts.map +1 -0
- package/dist/types/bitcoin/network.d.ts +2 -0
- package/dist/types/bitcoin/network.d.ts.map +1 -0
- package/dist/types/bitcoin/rest-client.d.ts +268 -0
- package/dist/types/bitcoin/rest-client.d.ts.map +1 -0
- package/dist/types/bitcoin/rpc-client.d.ts +506 -0
- package/dist/types/bitcoin/rpc-client.d.ts.map +1 -0
- package/dist/types/bitcoin/taproot.d.ts +34 -0
- package/dist/types/bitcoin/taproot.d.ts.map +1 -0
- package/dist/types/btcr2/beacon/aggregation/coordinator.d.ts +74 -0
- package/dist/types/btcr2/beacon/aggregation/coordinator.d.ts.map +1 -0
- package/dist/types/btcr2/beacon/aggregation/messages/advert.d.ts +22 -0
- package/dist/types/btcr2/beacon/aggregation/messages/advert.d.ts.map +1 -0
- package/dist/types/btcr2/beacon/aggregation/messages/base.d.ts +36 -0
- package/dist/types/btcr2/beacon/aggregation/messages/base.d.ts.map +1 -0
- package/dist/types/btcr2/beacon/aggregation/messages/cohort-set.d.ts +23 -0
- package/dist/types/btcr2/beacon/aggregation/messages/cohort-set.d.ts.map +1 -0
- package/dist/types/btcr2/beacon/aggregation/messages/keygen.d.ts +6 -0
- package/dist/types/btcr2/beacon/aggregation/messages/keygen.d.ts.map +1 -0
- package/dist/types/btcr2/beacon/aggregation/messages/opt-in.d.ts +22 -0
- package/dist/types/btcr2/beacon/aggregation/messages/opt-in.d.ts.map +1 -0
- package/dist/types/btcr2/beacon/aggregation/messages/sign.d.ts +5 -0
- package/dist/types/btcr2/beacon/aggregation/messages/sign.d.ts.map +1 -0
- package/dist/types/btcr2/beacon/aggregation/models/cohort/index.d.ts +77 -0
- package/dist/types/btcr2/beacon/aggregation/models/cohort/index.d.ts.map +1 -0
- package/dist/types/btcr2/beacon/aggregation/models/cohort/status.d.ts +7 -0
- package/dist/types/btcr2/beacon/aggregation/models/cohort/status.d.ts.map +1 -0
- package/dist/types/btcr2/beacon/aggregation/participant.d.ts +1 -0
- package/dist/types/btcr2/beacon/aggregation/participant.d.ts.map +1 -0
- package/dist/types/btcr2/beacon/aggregation/protocol/nostr.d.ts +36 -0
- package/dist/types/btcr2/beacon/aggregation/protocol/nostr.d.ts.map +1 -0
- package/dist/types/btcr2/beacon/aggregation/protocol/service.d.ts +6 -0
- package/dist/types/btcr2/beacon/aggregation/protocol/service.d.ts.map +1 -0
- package/dist/types/btcr2/beacon/cid-aggregate.d.ts +103 -0
- package/dist/types/btcr2/beacon/cid-aggregate.d.ts.map +1 -0
- package/dist/types/btcr2/beacon/factory.d.ts +17 -0
- package/dist/types/btcr2/beacon/factory.d.ts.map +1 -0
- package/dist/types/btcr2/beacon/singleton.d.ts +93 -0
- package/dist/types/btcr2/beacon/singleton.d.ts.map +1 -0
- package/dist/types/btcr2/beacon/smt-aggregate.d.ts +112 -0
- package/dist/types/btcr2/beacon/smt-aggregate.d.ts.map +1 -0
- package/dist/types/btcr2/crud/create.d.ts +92 -0
- package/dist/types/btcr2/crud/create.d.ts.map +1 -0
- package/dist/types/btcr2/crud/deactivate.d.ts +13 -0
- package/dist/types/btcr2/crud/deactivate.d.ts.map +1 -0
- package/dist/types/btcr2/crud/read.d.ts +341 -0
- package/dist/types/btcr2/crud/read.d.ts.map +1 -0
- package/dist/types/btcr2/crud/update.d.ts +83 -0
- package/dist/types/btcr2/crud/update.d.ts.map +1 -0
- package/dist/types/btcr2/key-manager/index.d.ts +145 -0
- package/dist/types/btcr2/key-manager/index.d.ts.map +1 -0
- package/dist/types/btcr2/key-manager/interface.d.ts +113 -0
- package/dist/types/btcr2/key-manager/interface.d.ts.map +1 -0
- package/dist/types/did-btcr2.d.ts +117 -0
- package/dist/types/did-btcr2.d.ts.map +1 -0
- package/dist/types/index.d.ts +26 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/interfaces/beacon.d.ts +57 -0
- package/dist/types/interfaces/beacon.d.ts.map +1 -0
- package/dist/types/interfaces/crud.d.ts +35 -0
- package/dist/types/interfaces/crud.d.ts.map +1 -0
- package/dist/types/interfaces/ibeacon.d.ts +66 -0
- package/dist/types/interfaces/ibeacon.d.ts.map +1 -0
- package/dist/types/types/bitcoin.d.ts +827 -0
- package/dist/types/types/bitcoin.d.ts.map +1 -0
- package/dist/types/types/crud.d.ts +38 -0
- package/dist/types/types/crud.d.ts.map +1 -0
- package/dist/types/utils/appendix.d.ts +118 -0
- package/dist/types/utils/appendix.d.ts.map +1 -0
- package/dist/types/utils/beacons.d.ts +156 -0
- package/dist/types/utils/beacons.d.ts.map +1 -0
- package/dist/types/utils/did-document-builder.d.ts +13 -0
- package/dist/types/utils/did-document-builder.d.ts.map +1 -0
- package/dist/types/utils/did-document.d.ts +211 -0
- package/dist/types/utils/did-document.d.ts.map +1 -0
- package/dist/types/utils/general.d.ts +85 -0
- package/dist/types/utils/general.d.ts.map +1 -0
- package/dist/types/utils/identifier.d.ts +59 -0
- package/dist/types/utils/identifier.d.ts.map +1 -0
- package/package.json +137 -0
- package/src/bitcoin/constants.ts +19 -0
- package/src/bitcoin/errors.ts +10 -0
- package/src/bitcoin/index.ts +154 -0
- package/src/bitcoin/interface.ts +160 -0
- package/src/bitcoin/network.ts +17 -0
- package/src/bitcoin/rest-client.ts +415 -0
- package/src/bitcoin/rpc-client.ts +888 -0
- package/src/bitcoin/taproot.ts +237 -0
- package/src/btcr2/beacon/aggregation/coordinator.ts +135 -0
- package/src/btcr2/beacon/aggregation/messages/advert.ts +36 -0
- package/src/btcr2/beacon/aggregation/messages/base.ts +59 -0
- package/src/btcr2/beacon/aggregation/messages/cohort-set.ts +37 -0
- package/src/btcr2/beacon/aggregation/messages/keygen.ts +8 -0
- package/src/btcr2/beacon/aggregation/messages/opt-in.ts +35 -0
- package/src/btcr2/beacon/aggregation/messages/sign.ts +7 -0
- package/src/btcr2/beacon/aggregation/models/cohort/index.ts +112 -0
- package/src/btcr2/beacon/aggregation/models/cohort/status.ts +7 -0
- package/src/btcr2/beacon/aggregation/participant.ts +0 -0
- package/src/btcr2/beacon/aggregation/protocol/nostr.ts +81 -0
- package/src/btcr2/beacon/aggregation/protocol/service.ts +6 -0
- package/src/btcr2/beacon/cid-aggregate.ts +154 -0
- package/src/btcr2/beacon/factory.ts +36 -0
- package/src/btcr2/beacon/singleton.ts +257 -0
- package/src/btcr2/beacon/smt-aggregate.ts +136 -0
- package/src/btcr2/crud/create.ts +160 -0
- package/src/btcr2/crud/deactivate.ts +13 -0
- package/src/btcr2/crud/read.ts +946 -0
- package/src/btcr2/crud/update.ts +277 -0
- package/src/btcr2/key-manager/index.ts +364 -0
- package/src/btcr2/key-manager/interface.ts +129 -0
- package/src/canonicalize.d.ts +6 -0
- package/src/did-btcr2.ts +288 -0
- package/src/index.ts +34 -0
- package/src/interfaces/beacon.ts +68 -0
- package/src/interfaces/crud.ts +36 -0
- package/src/interfaces/ibeacon.ts +76 -0
- package/src/types/bitcoin.ts +1028 -0
- package/src/types/crud.ts +41 -0
- package/src/utils/appendix.ts +257 -0
- package/src/utils/beacons.ts +276 -0
- package/src/utils/did-document-builder.ts +73 -0
- package/src/utils/did-document.ts +474 -0
- package/src/utils/general.ts +204 -0
- package/src/utils/identifier.ts +276 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { HashBytes, Hex, SchnorrKeyPairObject, KeyBytes, SignatureBytes } from '@did-btcr2/common';
|
|
2
|
+
import { SchnorrMultikey } from '@did-btcr2/cryptosuite';
|
|
3
|
+
import { SchnorrKeyPair, PublicKey } from '@did-btcr2/keypair';
|
|
4
|
+
import { KeyIdentifier } from '@web5/crypto';
|
|
5
|
+
import { Multibase } from 'multiformats';
|
|
6
|
+
import { AvailableNetworks } from '../../bitcoin/index.js';
|
|
7
|
+
import { BitcoinSigner, Btc1KeyManagerOptions, CryptoSigner, KeyManager, KeyManagerParams } from './interface.js';
|
|
8
|
+
export interface Btc1Signer {
|
|
9
|
+
multikey: SchnorrMultikey;
|
|
10
|
+
network: keyof AvailableNetworks;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Class for managing cryptographic keys for the B DID method.
|
|
14
|
+
* @class Btc1KeyManager
|
|
15
|
+
* @type {Btc1KeyManager}
|
|
16
|
+
*/
|
|
17
|
+
export declare class Btc1KeyManager implements KeyManager, CryptoSigner, BitcoinSigner {
|
|
18
|
+
#private;
|
|
19
|
+
/**
|
|
20
|
+
* The `activeKeyUri` property is a string that represents the URI of the currently active key.
|
|
21
|
+
* It is used to identify the key that will be used for signing and verifying operations.
|
|
22
|
+
* This property is optional and can be set to a specific key URI when initializing the
|
|
23
|
+
* `Btc1KeyManager` instance. If not set, the key manager will use the default key URI.
|
|
24
|
+
* @type {KeyIdentifier}
|
|
25
|
+
*/
|
|
26
|
+
activeKeyUri?: KeyIdentifier;
|
|
27
|
+
/**
|
|
28
|
+
* The `_store` private variable in `Btc1KeyManager` is a `KeyValueStore` instance used for
|
|
29
|
+
* storing and managing cryptographic keys. It allows the `Btc1KeyManager` class to save,
|
|
30
|
+
* retrieve, and handle keys efficiently within the local Key Management System (KMS) context.
|
|
31
|
+
* This variable can be configured to use different storage backends, like in-memory storage or
|
|
32
|
+
* persistent storage, providing flexibility in key management according to the application's
|
|
33
|
+
* requirements.
|
|
34
|
+
* @private
|
|
35
|
+
* @readonly
|
|
36
|
+
* @type {KeyValueStore<KeyIdentifier, SchnorrKeyPair>} The key store for managing cryptographic keys.
|
|
37
|
+
*/
|
|
38
|
+
private readonly _store;
|
|
39
|
+
/**
|
|
40
|
+
* Creates an instance of Btc1KeyManager.
|
|
41
|
+
* @param {?KeyManagerParams} params The parameters to initialize the key manager.
|
|
42
|
+
* @param {KeyValueStore<KeyIdentifier, SchnorrMultikey>} params.store An optional property to specify a custom
|
|
43
|
+
* `KeyValueStore` instance for key management. If not provided, {@link Btc1KeyManager} uses a default `MemoryStore`
|
|
44
|
+
* instance. This store is responsible for managing cryptographic keys, allowing them to be retrieved, stored, and
|
|
45
|
+
* managed during cryptographic operations.
|
|
46
|
+
* @param {KeyIdentifier} params.keyUri An optional property to specify the active key URI for the key manager.
|
|
47
|
+
*/
|
|
48
|
+
constructor({ store, keyUri, keys }?: KeyManagerParams);
|
|
49
|
+
/**
|
|
50
|
+
* Gets the singleton instance of the Btc1KeyManager.
|
|
51
|
+
* @returns {Btc1KeyManager} The singleton instance of the Btc1KeyManager.
|
|
52
|
+
*/
|
|
53
|
+
static get instance(): Btc1KeyManager;
|
|
54
|
+
/**
|
|
55
|
+
* Signs a transaction using the key associated with the key URI.
|
|
56
|
+
* @param {Hex} txHex The transaction hex to sign.
|
|
57
|
+
* @param {KeyIdentifier} keyUri The URI of the key to sign the transaction with.
|
|
58
|
+
* @returns {Promise<Hex>} A promise resolving to the signed transaction hex.
|
|
59
|
+
*/
|
|
60
|
+
signTransaction(txHex: Hex, keyUri?: KeyIdentifier): Promise<Hex>;
|
|
61
|
+
/**
|
|
62
|
+
* Gets the key pair from the key store and returns a PublicKey.
|
|
63
|
+
* @param {KeyIdentifier} keyUri The URI of the key to get the public key for.
|
|
64
|
+
* @returns {Promise<PublicKey>} The public key associated with the key URI.
|
|
65
|
+
*/
|
|
66
|
+
getPublicKey(keyUri?: KeyIdentifier): Promise<PublicKey>;
|
|
67
|
+
/**
|
|
68
|
+
* Signs the given data using the key associated with the key URI.
|
|
69
|
+
* @param {Hex} data The data to sign.
|
|
70
|
+
* @param {?KeyIdentifier} keyUri The URI of the key to sign the data with.
|
|
71
|
+
* @returns {Promise<SignatureBytes>} A promise resolving to the signature of the data.
|
|
72
|
+
*/
|
|
73
|
+
sign(data: Hex, keyUri?: KeyIdentifier): Promise<SignatureBytes>;
|
|
74
|
+
/**
|
|
75
|
+
* Verifies a signature using the key associated with the key URI.
|
|
76
|
+
* @param {KeyIdentifier} keyUri The URI of the key to verify the signature with.
|
|
77
|
+
* @param {SignatureBytes} signature The signature to verify.
|
|
78
|
+
* @param {Hex} data The data to verify the signature with.
|
|
79
|
+
* @returns {Promise<boolean>} A promise resolving to a boolean indicating the verification result.
|
|
80
|
+
*/
|
|
81
|
+
verify(signature: SignatureBytes, data: Hex, keyUri?: KeyIdentifier): Promise<boolean>;
|
|
82
|
+
/**
|
|
83
|
+
* Gets the key pair from the key store.
|
|
84
|
+
* @param {KeyIdentifier} keyUri The URI of the key to get.
|
|
85
|
+
* @returns {Promise<SchnorrKeyPair>} The key pair associated with the key URI.
|
|
86
|
+
* @throws {Btcr2KeyManagerError} If the key is not found in the key store.
|
|
87
|
+
*/
|
|
88
|
+
private getKey;
|
|
89
|
+
/**
|
|
90
|
+
* Exports the full multikeypair from the key store.
|
|
91
|
+
* @returns {Promise<SchnorrKeyPair>} The key pair associated with the key URI.
|
|
92
|
+
* @throws {Btcr2KeyManagerError} If the key is not found in the key store.
|
|
93
|
+
*/
|
|
94
|
+
exportKey(keyUri?: KeyIdentifier): Promise<SchnorrMultikey | undefined>;
|
|
95
|
+
/**
|
|
96
|
+
* Imports a keypair to the store.
|
|
97
|
+
* @param {SchnorrKeyPair} keys The keypair to import.
|
|
98
|
+
* @param {KeyIdentifier} keyUri The URI of the key to import.
|
|
99
|
+
* @param {Btc1KeyManagerOptions} options Relevant import options.
|
|
100
|
+
* @param {boolean} options.active A flag to set the key as active (optional, default: false).
|
|
101
|
+
* @returns {Promise<KeyIdentifier>} A promise that resolves to the key identifier of the imported key.
|
|
102
|
+
*/
|
|
103
|
+
importKey(keys: SchnorrKeyPair, keyUri: string, options?: Btc1KeyManagerOptions): Promise<KeyIdentifier>;
|
|
104
|
+
/**
|
|
105
|
+
* Computes the hash of the given data.
|
|
106
|
+
* @param {Uint8Array} data The data to hash.
|
|
107
|
+
* @returns {HashBytes} The hash of the data.
|
|
108
|
+
*/
|
|
109
|
+
digest(data: Uint8Array): HashBytes;
|
|
110
|
+
/**
|
|
111
|
+
* Computes the key URI of a given keypair.
|
|
112
|
+
* @param {string} id The fragment identifier (e.g. 'key-1').
|
|
113
|
+
* @param {string} [controller] The DID controller (e.g. 'did:btcr2:xyz').
|
|
114
|
+
* @returns {KeyIdentifier} A full DID fragment URI (e.g. 'did:btcr2:xyz#key-1')
|
|
115
|
+
*/
|
|
116
|
+
static computeKeyUri(id: string, controller: string): KeyIdentifier;
|
|
117
|
+
/**
|
|
118
|
+
* Computes a multibase-compliant URI from a key.
|
|
119
|
+
* @param key A SchnorrKeyPair, PublicKey, or multibase string
|
|
120
|
+
* @returns {string} A multibase URI (e.g. 'urn:mb:zQ3s...')
|
|
121
|
+
*/
|
|
122
|
+
static toMultibaseUri(data: SchnorrKeyPair | PublicKey | Multibase<'zQ3s'>): string;
|
|
123
|
+
/**
|
|
124
|
+
* Initializes a singleton Btc1KeyManager instance.
|
|
125
|
+
* @param {SchnorrKeyPair} keys The keypair used to initialize the key manager.
|
|
126
|
+
* @returns {void}
|
|
127
|
+
*/
|
|
128
|
+
static initialize(keys: SchnorrKeyPair | SchnorrKeyPairObject, keyUri: string): Promise<Btc1KeyManager>;
|
|
129
|
+
/**
|
|
130
|
+
* Retrieves a keypair from the key store using the provided key URI.
|
|
131
|
+
* @public
|
|
132
|
+
* @param {KeyIdentifier} keyUri The URI of the keypair to retrieve.
|
|
133
|
+
* @returns {Promise<SchnorrKeyPair | undefined>} The retrieved keypair, or undefined if not found.
|
|
134
|
+
*/
|
|
135
|
+
static getKeyPair(keyUri?: KeyIdentifier): Promise<SchnorrMultikey | undefined>;
|
|
136
|
+
getKeySigner(keyUri: KeyIdentifier, network: keyof AvailableNetworks): Promise<Signer>;
|
|
137
|
+
}
|
|
138
|
+
export declare class Signer {
|
|
139
|
+
multikey: SchnorrMultikey;
|
|
140
|
+
network: keyof AvailableNetworks;
|
|
141
|
+
constructor(params: Btc1Signer);
|
|
142
|
+
get publicKey(): KeyBytes;
|
|
143
|
+
sign(hash: Hex): SignatureBytes;
|
|
144
|
+
signSchnorr(hash: Hex): SignatureBytes;
|
|
145
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/btcr2/key-manager/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EACT,GAAG,EACH,oBAAoB,EAGpB,QAAQ,EACR,cAAc,EACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElH,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,eAAe,CAAC;IAC1B,OAAO,EAAE,MAAM,iBAAiB,CAAC;CAClC;AAED;;;;GAIG;AACH,qBAAa,cAAe,YAAW,UAAU,EAAE,YAAY,EAAE,aAAa;;IAQ5E;;;;;;OAMG;IACI,YAAY,CAAC,EAAE,aAAa,C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AAc,GAAG,oBAAoB,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAoCpH;;;;;OAKG;WACiB,UAAU,CAAC,MAAM,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC;IAO/E,YAAY,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;CAOpG;AAED,qBAAa,MAAM;IACV,QAAQ,EAAE,eAAe,CAAC;IAC1B,OAAO,EAAE,MAAM,iBAAiB,CAAC;gBAE5B,MAAM,EAAE,UAAU;IAK9B,IAAI,SAAS,IAAI,QAAQ,CAGxB;IAEM,IAAI,CAAC,IAAI,EAAE,GAAG,GAAG,cAAc;IAI/B,WAAW,CAAC,IAAI,EAAE,GAAG,GAAG,cAAc;CAG9C"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { HashBytes, Hex, SignatureBytes } from '@did-btcr2/common';
|
|
2
|
+
import { Multikey, SchnorrMultikey } from '@did-btcr2/cryptosuite';
|
|
3
|
+
import { SchnorrKeyPair, PublicKey } from '@did-btcr2/keypair';
|
|
4
|
+
import { KeyValueStore } from '@web5/common';
|
|
5
|
+
export type Btc1KeyManagerOptions = {
|
|
6
|
+
importKey?: boolean;
|
|
7
|
+
active?: boolean;
|
|
8
|
+
};
|
|
9
|
+
/** Alias type for Btc1KeyManager keyUri */
|
|
10
|
+
export type KeyIdentifier = string;
|
|
11
|
+
/** Params for initializing a Btc1KeyManager class instance. */
|
|
12
|
+
export type KeyManagerParams = {
|
|
13
|
+
/**
|
|
14
|
+
* An optional property to specify a custom `KeyValueStore` instance for key management. If not
|
|
15
|
+
* provided, {@link Btc1KeyManager | `Btc1KeyManager`} uses a default `MemoryStore` instance.
|
|
16
|
+
* This store is responsible for managing cryptographic keys, allowing them to be retrieved,
|
|
17
|
+
* stored, and managed during cryptographic operations.
|
|
18
|
+
* @type {KeyValueStore<KeyIdentifier, KeyPair>}
|
|
19
|
+
*/
|
|
20
|
+
store?: KeyValueStore<KeyIdentifier, SchnorrMultikey>;
|
|
21
|
+
/**
|
|
22
|
+
* An optional property to specify a key URI for the key manager. If not provided, the key manager
|
|
23
|
+
* will generate a key URI based on the public key of the key pair.
|
|
24
|
+
* @type {KeyIdentifier}
|
|
25
|
+
*/
|
|
26
|
+
keyUri?: KeyIdentifier;
|
|
27
|
+
/**
|
|
28
|
+
* An optional property to specify the DID contoller id.
|
|
29
|
+
* @type {string}
|
|
30
|
+
*/
|
|
31
|
+
id?: string;
|
|
32
|
+
/**
|
|
33
|
+
* An optional property to specify the DID controller.\
|
|
34
|
+
* @type {string}
|
|
35
|
+
*/
|
|
36
|
+
controller?: string;
|
|
37
|
+
/**
|
|
38
|
+
* An optional property to pass in an initial key pair
|
|
39
|
+
* @type {SchnorrKeyPair}
|
|
40
|
+
*/
|
|
41
|
+
keys?: SchnorrKeyPair;
|
|
42
|
+
};
|
|
43
|
+
export type GenerateKeyParams = {
|
|
44
|
+
id: string;
|
|
45
|
+
controller: string;
|
|
46
|
+
options: Btc1KeyManagerOptions;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* The interface for the Btc1KeyManager class.
|
|
50
|
+
* @interface KeyManager
|
|
51
|
+
* @type {KeyManager}
|
|
52
|
+
*/
|
|
53
|
+
export interface KeyManager {
|
|
54
|
+
/**
|
|
55
|
+
* The URI of the active key.
|
|
56
|
+
* @type {KeyIdentifier}
|
|
57
|
+
*/
|
|
58
|
+
activeKeyUri?: KeyIdentifier;
|
|
59
|
+
/**
|
|
60
|
+
* Exports the full key pair from the key store.
|
|
61
|
+
* @param {KeyIdentifier} keyUri The URI of the key to export.
|
|
62
|
+
* @returns {Promise<Multikey | undefined>} The key pair associated with the key URI.
|
|
63
|
+
* @throws {Btc1KeyManagerError} If the key is not found in the key store.
|
|
64
|
+
*/
|
|
65
|
+
exportKey(keyUri?: KeyIdentifier): Promise<Multikey | undefined>;
|
|
66
|
+
/**
|
|
67
|
+
* Gets the public key of a key pair.
|
|
68
|
+
* @param {KeyIdentifier} keyUri The URI of the key to get the public key for.
|
|
69
|
+
* @returns {Promise<PublicKey>} The public key of the key pair.
|
|
70
|
+
*/
|
|
71
|
+
getPublicKey(keyUri: KeyIdentifier): Promise<PublicKey>;
|
|
72
|
+
/**
|
|
73
|
+
* Imports a key pair into the key store.
|
|
74
|
+
* @param {SchnorrKeyPair} keyPair The key pair to import.
|
|
75
|
+
* @param {string} keyUri The full DID controller + fragment identifier (e.g. 'did:btcr2:xyz#key-1').
|
|
76
|
+
* @param {Btc1KeyManagerOptions} options The options for importing the key pair.
|
|
77
|
+
* @param {boolean} options.active Whether to set the imported key as active.
|
|
78
|
+
* @returns {Promise<KeyIdentifier>} A promise that resolves to the key identifier of the imported key.
|
|
79
|
+
*/
|
|
80
|
+
importKey(keyPair: SchnorrKeyPair, keyUri: string, options: Btc1KeyManagerOptions): Promise<KeyIdentifier>;
|
|
81
|
+
}
|
|
82
|
+
export interface CryptoSigner {
|
|
83
|
+
/**
|
|
84
|
+
* Signs a message with a key pair.
|
|
85
|
+
* @param {Hex} data The data to sign.
|
|
86
|
+
* @param {?KeyIdentifier} keyUri The URI of the key to sign the data with.
|
|
87
|
+
* @returns {Promise<SignatureBytes>} The signature of the input data.
|
|
88
|
+
*/
|
|
89
|
+
sign(data: Hex, keyUri?: KeyIdentifier): Promise<SignatureBytes>;
|
|
90
|
+
/**
|
|
91
|
+
* Verifies if a signature was produced by a key pair.
|
|
92
|
+
* @param {SignatureBytes} signature The signature to verify.
|
|
93
|
+
* @param {Hex} data The data that was signed.
|
|
94
|
+
* @param {?KeyIdentifier} keyUri The URI of the key to use for verification.
|
|
95
|
+
* @returns {Promise<boolean>} A promise that resolves if the signature is valid, and rejects otherwise.
|
|
96
|
+
*/
|
|
97
|
+
verify(signature: SignatureBytes, data: Hex, keyUri?: KeyIdentifier): Promise<boolean>;
|
|
98
|
+
/**
|
|
99
|
+
* Returns the sha256 hash of the input data.
|
|
100
|
+
* @param {Uint8Array} data The data to hash.
|
|
101
|
+
* @returns {HashBytes} The sha256 hash of the input data.
|
|
102
|
+
*/
|
|
103
|
+
digest(data: Uint8Array): HashBytes;
|
|
104
|
+
}
|
|
105
|
+
export interface BitcoinSigner {
|
|
106
|
+
/**
|
|
107
|
+
* Signs a Bitcoin transaction with a key pair.
|
|
108
|
+
* @param txHex The hex-encoded transaction to sign.
|
|
109
|
+
* @param keyUri The URI of the key to sign the transaction with.
|
|
110
|
+
* @returns {Promise<Hex>} A promise that resolves to the hex-encoded signed transaction.
|
|
111
|
+
*/
|
|
112
|
+
signTransaction(txHex: Hex, keyUri?: KeyIdentifier): Promise<Hex>;
|
|
113
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../../src/btcr2/key-manager/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,CAAC;AAEF,2CAA2C;AAC3C,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC;AAEnC,+DAA+D;AAC/D,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;IAEtD;;;;OAIG;IACH,MAAM,CAAC,EAAE,aAAa,CAAC;IAEvB;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,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
1
|
+
import { PatchOperation } from '@did-btcr2/common';
|
|
2
|
+
import type { DidResolutionResult } from '@web5/dids';
|
|
3
|
+
import { DidMethod } from '@web5/dids';
|
|
4
|
+
import { Btc1CreateParams, Btc1CreateResponse } from './btcr2/crud/create.js';
|
|
5
|
+
import { DidResolutionOptions } from './interfaces/crud.js';
|
|
6
|
+
import { Btc1DidDocument, Btc1VerificationMethod } from './utils/did-document.js';
|
|
7
|
+
/**
|
|
8
|
+
* Implements {@link https://dcdpr.github.io/did-btcr2 | did:btcr2 DID Method Specification}.
|
|
9
|
+
* did:btcr2 is a censorship resistant DID Method using the Bitcoin blockchain as a Verifiable Data Registry to announce
|
|
10
|
+
* changes to the DID document. It improves on prior work by allowing: zero-cost off-chain DID creation; aggregated
|
|
11
|
+
* updates for scalable on-chain update costs; long-term identifiers that can support frequent updates; private
|
|
12
|
+
* communication of the DID document; private DID resolution; and non-repudiation appropriate for serious contracts.
|
|
13
|
+
*
|
|
14
|
+
* @class DidBtc1
|
|
15
|
+
* @type {DidBtc1}
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
export declare class DidBtc1 implements DidMethod {
|
|
19
|
+
/** @type {string} Name of the DID method, as defined in the DID BTCR2 specification */
|
|
20
|
+
static methodName: string;
|
|
21
|
+
/**
|
|
22
|
+
* Entry point for section {@link https://dcdpr.github.io/did-btcr2/#create | 4.1 Create}.
|
|
23
|
+
* See {@link Btc1Create} for implementation details.
|
|
24
|
+
*
|
|
25
|
+
* A did:btcr2 identifier and associated DID document can either be created deterministically from a cryptographic
|
|
26
|
+
* seed, or it can be created from an arbitrary genesis intermediate DID document representation. In both cases,
|
|
27
|
+
* DID creation can be undertaken in an offline manner, i.e., the DID controller does not need to interact with the
|
|
28
|
+
* Bitcoin network to create their DID.
|
|
29
|
+
* @param {Btc1CreateParams} params See {@link Btc1CreateParams} for details.
|
|
30
|
+
* @param {IdType} params.idType Type of identifier to create (key or external).
|
|
31
|
+
* @param {KeyBytes} params.pubKeyBytes Public key byte array used to create a btcr2 "key" identifier.
|
|
32
|
+
* @param {IntermediateDocument} params.intermediateDocument DID Document used to create a btcr2 "external" identifier.
|
|
33
|
+
* @param {DidCreateOptions} params.options See {@link DidCreateOptions} for create options.
|
|
34
|
+
* @param {number} params.options.version Version number of the btcr2 method.
|
|
35
|
+
* @param {string} params.options.network Bitcoin network name (mainnet, testnet, signet, regtest).
|
|
36
|
+
* @returns {Promise<CreateResponse>} Promise resolving to a CreateResponse object.
|
|
37
|
+
* @throws {DidBtc1Error} if any of the checks fail
|
|
38
|
+
*/
|
|
39
|
+
static create(params: Btc1CreateParams): Promise<Btc1CreateResponse>;
|
|
40
|
+
/**
|
|
41
|
+
* Entry point for section {@link https://dcdpr.github.io/did-btcr2/#read | 7.2 Read}.
|
|
42
|
+
* See {@link Btc1Read} for implementation details.
|
|
43
|
+
*
|
|
44
|
+
* The Read operation is an algorithm consisting of a series of subroutine algorithms executed by a resolver after a
|
|
45
|
+
* resolution request identifying a specific did:btcr2 identifier is received from a client at Resolution Time. The
|
|
46
|
+
* request MUST always contain the resolutionOptions object containing additional information to be used in resolution.
|
|
47
|
+
* This object MAY be empty. See the DID Resolution specification for further details about the DID Resolution Options
|
|
48
|
+
* object. The resolver then attempts to resolve the DID document of the identifier at a specific Target Time. The
|
|
49
|
+
* Target Time is either provided in resolutionOptions or is set to the Resolution Time of the request.
|
|
50
|
+
*
|
|
51
|
+
* @param {string} identifier a valid did:btcr2 identifier to be resolved
|
|
52
|
+
* @param {DidResolutionOptions} [resolutionsOptions] see {@link https://www.w3.org/TR/did-1.0/#did-resolution-options | DidResolutionOptions}
|
|
53
|
+
* @param {number} options.versionId the version of the identifier and/or DID document
|
|
54
|
+
* @param {number} options.versionTime a timestamp used during resolution as a bound for when to stop resolving
|
|
55
|
+
* @param {Btc1DidDocument} options.sidecarData data necessary for resolving a DID
|
|
56
|
+
* @param {string} options.network Bitcoin network name (mainnet, testnet, signet, regtest).
|
|
57
|
+
* @returns {DidResolutionResult} Promise resolving to a DID Resolution Result containing the `targetDocument`
|
|
58
|
+
* @throws {Error} if the resolution fails for any reason
|
|
59
|
+
* @throws {DidError} InvalidDid if the identifier is invalid
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* const resolution = await DidBtc1.resolve('did:btcr2:k1q0dygyp3gz969tp46dychzy4q78c2k3js68kvyr0shanzg67jnuez2cfplh')
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
static resolve(identifier: string, resolutionsOptions?: DidResolutionOptions): Promise<DidResolutionResult>;
|
|
66
|
+
/**
|
|
67
|
+
* Entry point for section {@link https://dcdpr.github.io/did-btcr2/#update | 4.3 Update}.
|
|
68
|
+
* See {@link Btc1Update} for implementation details.
|
|
69
|
+
*
|
|
70
|
+
* An update to a did:btcr2 document is an invoked capability using the ZCAP-LD data format, signed by a
|
|
71
|
+
* verificationMethod that has the authority to make the update as specified in the previous DID document. Capability
|
|
72
|
+
* invocations for updates MUST be authorized using Data Integrity following the bip340-jcs-2025
|
|
73
|
+
* cryptosuite with a proofPurpose of capabilityInvocation.
|
|
74
|
+
*
|
|
75
|
+
* The Update algorithm takes as inputs a btc1Identifier, sourceDocument, sourceVersionId, documentPatch, a
|
|
76
|
+
* verificationMethodId and an array of beaconIds. The sourceDocument is the DID document being updated. The
|
|
77
|
+
* documentPatch is a JSON Patch object containing a set of transformations to be applied to the sourceDocument.
|
|
78
|
+
* The result of these transformations MUST produce a DID document conformant to the DID Core specification. The
|
|
79
|
+
* verificationMethodId is an identifier for a verificationMethod within the sourceDocument. The verificationMethod
|
|
80
|
+
* identified MUST be a BIP340 Multikey. The beaconIds MUST identify service endpoints with one of the three Beacon
|
|
81
|
+
* Types SingletonBeacon, CIDAggregateBeacon, and SMTAggregateBeacon.
|
|
82
|
+
*
|
|
83
|
+
* @param {Btc1UpdateParams} params Required parameters for the update operation.
|
|
84
|
+
* @param {string} params.identifier The btcr2 identifier to be updated.
|
|
85
|
+
* @param {Btc1DidDocument} params.sourceDocument The DID document being updated.
|
|
86
|
+
* @param {string} params.sourceVersionId The versionId of the source document.
|
|
87
|
+
* @param {Btc1DocumentPatch} params.documentPatch The JSON patch to be applied to the source document.
|
|
88
|
+
* @param {string} params.verificationMethodId The verificationMethod ID to sign the update
|
|
89
|
+
* @param {string[]} params.beaconIds The beacon IDs to announce the update
|
|
90
|
+
* @returns {Promise<void>} Promise resolving to void
|
|
91
|
+
* @throws {Btcr2Error} if the verificationMethod type is not `Multikey` or the publicKeyMultibase header is not `zQ3s`
|
|
92
|
+
*/
|
|
93
|
+
static update(params: {
|
|
94
|
+
identifier: string;
|
|
95
|
+
sourceDocument: Btc1DidDocument;
|
|
96
|
+
sourceVersionId: number;
|
|
97
|
+
patch: PatchOperation[];
|
|
98
|
+
verificationMethodId: string;
|
|
99
|
+
beaconIds: string[];
|
|
100
|
+
}): Promise<any>;
|
|
101
|
+
/**
|
|
102
|
+
* Given the W3C DID Document of a `did:btcr2` identifier, return the signing verification method that will be used
|
|
103
|
+
* for signing messages and credentials. If given, the `methodId` parameter is used to select the
|
|
104
|
+
* verification method. If not given, the Identity Key's verification method with an ID fragment
|
|
105
|
+
* of '#initialKey' is used.
|
|
106
|
+
*
|
|
107
|
+
* @param {{ didDocument: Btc1DidDocument; methodId?: string; }} params Parameters for the `getSigningMethod` method.
|
|
108
|
+
* @param {DidDocument} params.didDocument DID Document to get the verification method from.
|
|
109
|
+
* @param {string} params.methodId Optional ID of the verification method to use for signing.
|
|
110
|
+
* @returns {Btc1VerificationMethod} Promise resolving to the {@link Btc1VerificationMethod} object used for signing.
|
|
111
|
+
* @throws {DidError} if the parsed did method does not match `btcr2` or signing method could not be determined.
|
|
112
|
+
*/
|
|
113
|
+
static getSigningMethod({ didDocument, methodId }: {
|
|
114
|
+
didDocument: Btc1DidDocument;
|
|
115
|
+
methodId?: string;
|
|
116
|
+
}): Btc1VerificationMethod;
|
|
117
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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AG,sBAAsB;CA0B3B"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export * from './bitcoin/constants.js';
|
|
2
|
+
export * from './bitcoin/interface.js';
|
|
3
|
+
export * from './bitcoin/network.js';
|
|
4
|
+
export * from './bitcoin/rpc-client.js';
|
|
5
|
+
export * from './btcr2/beacon/cid-aggregate.js';
|
|
6
|
+
export * from './btcr2/beacon/factory.js';
|
|
7
|
+
export * from './btcr2/beacon/singleton.js';
|
|
8
|
+
export * from './btcr2/beacon/smt-aggregate.js';
|
|
9
|
+
export * from './btcr2/crud/create.js';
|
|
10
|
+
export * from './btcr2/crud/deactivate.js';
|
|
11
|
+
export * from './btcr2/crud/read.js';
|
|
12
|
+
export * from './btcr2/crud/update.js';
|
|
13
|
+
export * from './btcr2/key-manager/index.js';
|
|
14
|
+
export * from './btcr2/key-manager/interface.js';
|
|
15
|
+
export * from './interfaces/beacon.js';
|
|
16
|
+
export * from './interfaces/crud.js';
|
|
17
|
+
export * from './interfaces/ibeacon.js';
|
|
18
|
+
export * from './types/bitcoin.js';
|
|
19
|
+
export * from './types/crud.js';
|
|
20
|
+
export * from './utils/appendix.js';
|
|
21
|
+
export * from './utils/beacons.js';
|
|
22
|
+
export * from './utils/did-document-builder.js';
|
|
23
|
+
export * from './utils/did-document.js';
|
|
24
|
+
export * from './utils/general.js';
|
|
25
|
+
export * from './utils/identifier.js';
|
|
26
|
+
export * from './did-btcr2.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AAExC,cAAc,iCAAiC,CAAC;AAChD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAEhD,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kCAAkC,CAAC;AAEjD,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AAExC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAEhC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AAEtC,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { DidUpdatePayload } from '@did-btcr2/common';
|
|
2
|
+
import { DidServiceEndpoint } from '@web5/dids';
|
|
3
|
+
import { RawTransactionRest } from '../bitcoin/rest-client.js';
|
|
4
|
+
import { RawTransactionV2 } from '../types/bitcoin.js';
|
|
5
|
+
import { SidecarData, SignalsMetadata } from '../types/crud.js';
|
|
6
|
+
import { BeaconService, BeaconSignal, IBeacon } from './ibeacon.js';
|
|
7
|
+
/**
|
|
8
|
+
* Implements {@link https://dcdpr.github.io/did-btcr2/#update-beacons | 5. Beacons}.
|
|
9
|
+
* Beacons are the mechanism by which a DID controller announces an update to their DID document by broadcasting an
|
|
10
|
+
* attestation to this update onto the public Bitcoin network. Beacons are identified by a Bitcoin address and emit
|
|
11
|
+
* Beacon Signals by broadcasting a valid Bitcoin transaction that spends from this Beacon address. These transactions
|
|
12
|
+
* include attestations to a set of didUpdatePayloads, either in the form of Content Identifiers (CIDs) or Sparse Merkle
|
|
13
|
+
* Tree (SMT) roots. Beacons are included as a service in DID documents, with the Service Endpoint identifying a Bitcoin
|
|
14
|
+
* address to watch for Beacon Signals. All Beacon Signals broadcast from this Beacon MUST be processed as part of
|
|
15
|
+
* resolution (see Read). The type of the Beacon service in the DID document defines how Beacon Signals SHOULD be
|
|
16
|
+
* processed.
|
|
17
|
+
* did:btcr2 supports different Beacon Types, with each type defining a set of algorithms for:
|
|
18
|
+
* 1. How a Beacon can be established and added as a service to a DID document.
|
|
19
|
+
* 2. How attestations to DID updates are broadcast within Beacon Signals.
|
|
20
|
+
* 3. How a resolver processes a Beacon Signal, identifying, verifying, and applying the authorized mutations to a
|
|
21
|
+
* DID document for a specific DID.
|
|
22
|
+
* This is an extendable mechanism, such that in the future new Beacon Types could be added. It would be up to the
|
|
23
|
+
* resolver to determine if the Beacon Type is a mechanism they support and are willing to trust. If they are unable to
|
|
24
|
+
* support a Beacon Type and a DID they are resolving uses that type then the DID MUST be treated as invalid.
|
|
25
|
+
* The current, active Beacons of a DID document are specified in the document’s service property. By updating the DID
|
|
26
|
+
* document, a DID controller can change the set of Beacons they can use to broadcast updates to their DID document over
|
|
27
|
+
* time. Resolution of a DID MUST process signals from all Beacons identified in the latest DID document and apply them
|
|
28
|
+
* in order determined by the version specified by the didUpdatePayload.
|
|
29
|
+
* All resolvers of did:btcr2 DIDs MUST support the core Beacon Types defined in this specification.
|
|
30
|
+
*
|
|
31
|
+
* @abstract
|
|
32
|
+
* @class Beacon
|
|
33
|
+
* @type {Beacon}
|
|
34
|
+
*/
|
|
35
|
+
export declare abstract class Beacon implements IBeacon {
|
|
36
|
+
id: string;
|
|
37
|
+
type: string;
|
|
38
|
+
serviceEndpoint: DidServiceEndpoint;
|
|
39
|
+
sidecar?: SidecarData;
|
|
40
|
+
constructor({ id, type, serviceEndpoint }: BeaconService, sidecar?: SidecarData);
|
|
41
|
+
/**
|
|
42
|
+
* Returns the Beacon Service object.
|
|
43
|
+
*/
|
|
44
|
+
abstract get service(): BeaconService;
|
|
45
|
+
/**
|
|
46
|
+
* Generates a Beacon Signal (implemented by subclasses).
|
|
47
|
+
*/
|
|
48
|
+
abstract generateSignal(didUpdatePayload: string): BeaconSignal;
|
|
49
|
+
/**
|
|
50
|
+
* Processes a Beacon Signal (implemented by subclasses).
|
|
51
|
+
*/
|
|
52
|
+
abstract processSignal(signal: RawTransactionRest | RawTransactionV2, signalsMetadata: SignalsMetadata): Promise<DidUpdatePayload | undefined>;
|
|
53
|
+
/**
|
|
54
|
+
* Broadcasts a Beacon Signal (implemented by subclasses).
|
|
55
|
+
*/
|
|
56
|
+
abstract broadcastSignal(didUpdatePayload: DidUpdatePayload): Promise<SignalsMetadata>;
|
|
57
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"beacon.d.ts","sourceRoot":"","sources":["../../../src/interfaces/beacon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,8BAAsB,MAAO,YAAW,OAAO;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,kBAAkB,CAAC;IACpC,OAAO,CAAC,EAAE,WAAW,CAAC;gBAEjB,EAAE,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,WAAW;IAO/E;;OAEG;IACH,QAAQ,KAAK,OAAO,IAAI,aAAa,CAAC;IAEtC;;OAEG;IACH,QAAQ,CAAC,cAAc,CAAC,gBAAgB,EAAE,MAAM,GAAG,YAAY;IAE/D;;OAEG;IACH,QAAQ,CAAC,aAAa,CAAC,MAAM,EAAE,kBAAkB,GAAG,gBAAgB,EAAE,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAE9I;;OAEG;IACH,QAAQ,CAAC,eAAe,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC;CACvF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { BitcoinNetworkNames, UnixTimestamp } from '@did-btcr2/common';
|
|
2
|
+
import { DidResolutionOptions as IDidResolutionOptions } from '@web5/dids';
|
|
3
|
+
import BitcoinRpc from '../bitcoin/rpc-client.js';
|
|
4
|
+
import { SidecarData } from '../types/crud.js';
|
|
5
|
+
import { Btc1DidDocument } from '../utils/did-document.js';
|
|
6
|
+
/**
|
|
7
|
+
* Options for resolving a DID Document
|
|
8
|
+
* @param {?number} versionId The versionId for resolving the DID Document
|
|
9
|
+
* @param {?UnixTimestamp} versionTime The versionTime for resolving the DID Document
|
|
10
|
+
* @param {?BitcoinRpc} rpc BitcoinRpc client connection
|
|
11
|
+
* @param {?SidecarData} sidecarData The sidecar data for resolving the DID Document
|
|
12
|
+
*/
|
|
13
|
+
export interface DidResolutionOptions extends IDidResolutionOptions {
|
|
14
|
+
versionId?: number;
|
|
15
|
+
versionTime?: UnixTimestamp;
|
|
16
|
+
sidecarData?: SidecarData;
|
|
17
|
+
network?: BitcoinNetworkNames;
|
|
18
|
+
rpc?: BitcoinRpc;
|
|
19
|
+
}
|
|
20
|
+
export interface Btc1RootCapability {
|
|
21
|
+
'@context': string;
|
|
22
|
+
id: string;
|
|
23
|
+
controller: string;
|
|
24
|
+
invocationTarget: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ReadBlockchainParams {
|
|
27
|
+
contemporaryDidDocument: Btc1DidDocument;
|
|
28
|
+
contemporaryBlockHeight: number | 1;
|
|
29
|
+
currentVersionId: number | 1;
|
|
30
|
+
targetVersionId?: number;
|
|
31
|
+
targetBlockHeight: number;
|
|
32
|
+
updateHashHistory: string[];
|
|
33
|
+
sidecarData?: SidecarData;
|
|
34
|
+
options?: DidResolutionOptions;
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crud.d.ts","sourceRoot":"","sources":["../../../src/interfaces/crud.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,oBAAoB,IAAI,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAC3E,OAAO,UAAU,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D;;;;;;GAMG;AACH,MAAM,WAAW,oBAAqB,SAAQ,qBAAqB;IACjE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,aAAa,CAAC;IAC5B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,GAAG,CAAC,EAAE,UAAU,CAAC;CAClB;AACD,MAAM,WAAW,kBAAkB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;CAC5B;AACD,MAAM,WAAW,oBAAoB;IACnC,uBAAuB,EAAE,eAAe,CAAC;IACzC,uBAAuB,EAAE,MAAM,GAAG,CAAC,CAAC;IACpC,gBAAgB,EAAE,MAAM,GAAG,CAAC,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAChC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { DidUpdatePayload, UnixTimestamp } from '@did-btcr2/common';
|
|
2
|
+
import { DidServiceEndpoint, DidService as IDidService } from '@web5/dids';
|
|
3
|
+
import { RawTransactionV2 } from '../types/bitcoin.js';
|
|
4
|
+
import { SignalsMetadata } from '../types/crud.js';
|
|
5
|
+
import { RawTransactionRest } from '../bitcoin/rest-client.js';
|
|
6
|
+
/**
|
|
7
|
+
* Beacon interface
|
|
8
|
+
* @interface IBeacon
|
|
9
|
+
* @type {IBeacon}
|
|
10
|
+
*/
|
|
11
|
+
export interface IBeacon {
|
|
12
|
+
/**
|
|
13
|
+
* A unique identifier for the Beacon
|
|
14
|
+
* @type {string}
|
|
15
|
+
*/
|
|
16
|
+
id: string;
|
|
17
|
+
/**
|
|
18
|
+
* The type of the Beacon
|
|
19
|
+
* @type {string}
|
|
20
|
+
*/
|
|
21
|
+
type: string;
|
|
22
|
+
/**
|
|
23
|
+
* The service endpoint of the Beacon
|
|
24
|
+
* @type {string}
|
|
25
|
+
*/
|
|
26
|
+
serviceEndpoint: DidServiceEndpoint;
|
|
27
|
+
/**
|
|
28
|
+
* Returns the Beacon Service object
|
|
29
|
+
* @type {BeaconService}
|
|
30
|
+
*/
|
|
31
|
+
service: BeaconService;
|
|
32
|
+
/**
|
|
33
|
+
* Generates a Beacon Signal Transaction
|
|
34
|
+
* @param {string} didUpdatePayload The DID update payload
|
|
35
|
+
* @returns {BeaconSignal} The Beacon Signal
|
|
36
|
+
*/
|
|
37
|
+
generateSignal(didUpdatePayload: string): BeaconSignal;
|
|
38
|
+
/**
|
|
39
|
+
* Processes a Beacon Signal.
|
|
40
|
+
* @param {RawTransactionV2} signal The raw transaction
|
|
41
|
+
* @param {SidecarData} signalsMetadata The signals metadata from the sidecar data
|
|
42
|
+
* @returns {Promise<DidUpdatePayload | undefined>} The DID update payload
|
|
43
|
+
*/
|
|
44
|
+
processSignal(signal: RawTransactionV2, signalsMetadata: SignalsMetadata): Promise<DidUpdatePayload | undefined>;
|
|
45
|
+
/**
|
|
46
|
+
* Broadcasts a signal.
|
|
47
|
+
* @param {DidUpdatePayload} didUpdatePayload The DID update payload.
|
|
48
|
+
* @returns {Promise<SignalMetadata>} The signal metadata.
|
|
49
|
+
*/
|
|
50
|
+
broadcastSignal(didUpdatePayload: DidUpdatePayload): Promise<SignalsMetadata>;
|
|
51
|
+
}
|
|
52
|
+
export interface BeaconService extends IDidService {
|
|
53
|
+
serviceEndpoint: DidServiceEndpoint;
|
|
54
|
+
casType?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface BeaconServiceAddress extends BeaconService {
|
|
57
|
+
address: string;
|
|
58
|
+
}
|
|
59
|
+
export interface BeaconSignal {
|
|
60
|
+
beaconId: string;
|
|
61
|
+
beaconType: string;
|
|
62
|
+
beaconAddress: string;
|
|
63
|
+
tx: RawTransactionRest | RawTransactionV2;
|
|
64
|
+
blockheight: number;
|
|
65
|
+
blocktime: UnixTimestamp;
|
|
66
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ibeacon.d.ts","sourceRoot":"","sources":["../../../src/interfaces/ibeacon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,UAAU,IAAI,WAAW,EAAE,MAAM,YAAY,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D;;;;GAIG;AACH,MAAM,WAAW,OAAO;IACpB;;;OAGG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,eAAe,EAAE,kBAAkB,CAAC;IAEpC;;;OAGG;IACH,OAAO,EAAE,aAAa,CAAC;IAEvB;;;;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