@did-btcr2/api 0.5.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +131 -2
- package/dist/.tsbuildinfo +1 -1
- package/dist/browser.js +22006 -35294
- package/dist/browser.mjs +22006 -35294
- package/dist/cjs/index.js +100 -29
- package/dist/esm/api.js +3 -2
- package/dist/esm/api.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/{kms.js → key-manager.js} +21 -12
- package/dist/esm/key-manager.js.map +1 -0
- package/dist/esm/method.js +81 -20
- package/dist/esm/method.js.map +1 -1
- package/dist/types/api.d.ts +5 -3
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/crypto.d.ts +2 -2
- package/dist/types/crypto.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/{kms.d.ts → key-manager.d.ts} +19 -11
- package/dist/types/key-manager.d.ts.map +1 -0
- package/dist/types/method.d.ts +28 -12
- package/dist/types/method.d.ts.map +1 -1
- package/dist/types/types.d.ts +1 -1
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +9 -12
- package/src/api.ts +6 -2
- package/src/crypto.ts +2 -2
- package/src/index.ts +1 -1
- package/src/{kms.ts → key-manager.ts} +25 -16
- package/src/method.ts +98 -22
- package/src/types.ts +1 -1
- package/dist/esm/kms.js.map +0 -1
- package/dist/types/kms.d.ts.map +0 -1
package/dist/types/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,KAAK,EAAE,iBAAiB,EAAE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,wBAAgB,SAAS,CAAC,MAAM,CAAC,EAAE,SAAS,GAAG,WAAW,CAEzD"}
|
package/dist/types/crypto.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import type { Bytes, Entropy, HexString, KeyBytes, SchnorrKeyPairObject, Signatu
|
|
|
2
2
|
import type { BTCR2Update, DataIntegrityConfig, DataIntegrityProofObject, SignedBTCR2Update, UnsignedBTCR2Update, VerificationResult } from '@did-btcr2/cryptosuite';
|
|
3
3
|
import { BIP340Cryptosuite, BIP340DataIntegrityProof, type FromPublicKey, type Multikey, SchnorrMultikey } from '@did-btcr2/cryptosuite';
|
|
4
4
|
import { CompressedSecp256k1PublicKey, SchnorrKeyPair, Secp256k1SecretKey } from '@did-btcr2/keypair';
|
|
5
|
-
import type { KeyIdentifier } from '@did-btcr2/
|
|
5
|
+
import type { KeyIdentifier } from '@did-btcr2/key-manager';
|
|
6
6
|
import type { DidVerificationMethod } from '@web5/dids';
|
|
7
|
-
import type { KeyManagerApi } from './
|
|
7
|
+
import type { KeyManagerApi } from './key-manager.js';
|
|
8
8
|
/**
|
|
9
9
|
* Schnorr keypair operations.
|
|
10
10
|
* @public
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../src/crypto.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnH,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,wBAAwB,EACxB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,KAAK,aAAa,EAClB,KAAK,QAAQ,EACb,eAAe,EAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,4BAA4B,EAAE,cAAc,EAAE,kBAAkB,EAAE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AAE,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,EAAE,CAAC,EAAE,eAAe,GAAG,OAAO;CAa9E;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,SAAS;IACpB,kCAAkC;IAClC,QAAQ,CAAC,OAAO,aAAoB;IAEpC,yDAAyD;IACzD,QAAQ,CAAC,QAAQ,cAAqB;IAEtC,4DAA4D;IAC5D,QAAQ,CAAC,WAAW,iBAAwB;IAE5C,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,wBAA+B;IAE7C;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,EAAE,eAAe,GAAG,IAAI;IASnC;;OAEG;IACH,UAAU,IAAI,IAAI;IAMlB;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,KAAK,GAAG,cAAc;IAIjC;;;;;;OAMG;IACH,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,cAAc,GAAG,OAAO;IAIvD;;;;;;;;;OASG;IACH,YAAY,CAAC,QAAQ,EAAE,mBAAmB,EAAE,MAAM,EAAE,mBAAmB,GAAG,iBAAiB;IAI3F;;;;;OAKG;IACH,cAAc,CAAC,QAAQ,EAAE,iBAAiB,GAAG,kBAAkB;CAGhE"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export * from './types.js';
|
|
|
8
8
|
export * from './helpers.js';
|
|
9
9
|
export * from './bitcoin.js';
|
|
10
10
|
export * from './cas.js';
|
|
11
|
-
export * from './
|
|
11
|
+
export * from './key-manager.js';
|
|
12
12
|
export * from './crypto.js';
|
|
13
13
|
export * from './did.js';
|
|
14
14
|
export * from './method.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,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C;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import type { Bytes, HashBytes, SignatureBytes } from '@did-btcr2/common';
|
|
2
2
|
import type { SchnorrKeyPair } from '@did-btcr2/keypair';
|
|
3
|
-
import type
|
|
4
|
-
import { type GenerateKeyOptions, type ImportKeyOptions, type SignOptions } from '@did-btcr2/kms';
|
|
3
|
+
import { type KeyIdentifier, type KeyManager, type GenerateKeyOptions, type ImportKeyOptions, type SignOptions, type VerifyOptions } from '@did-btcr2/key-manager';
|
|
5
4
|
/**
|
|
6
5
|
* Key management operations sub-facade.
|
|
7
6
|
*
|
|
8
|
-
* Wraps
|
|
9
|
-
* {@link
|
|
10
|
-
*
|
|
7
|
+
* Wraps any {@link KeyManager} interface implementation. By default uses the
|
|
8
|
+
* bundled {@link LocalKeyManager} (in-process reference implementation); a
|
|
9
|
+
* custom implementation (AWS KMS, GCP KMS, HashiCorp Vault, HSM, etc.) can
|
|
10
|
+
* be injected via {@link ApiConfig}.
|
|
11
|
+
*
|
|
12
|
+
* The field is named `kms` because that's the category label callers use
|
|
13
|
+
* conversationally ("plug in your KMS"); the actual contract is the
|
|
14
|
+
* {@link KeyManager} interface.
|
|
11
15
|
* @public
|
|
12
16
|
*/
|
|
13
17
|
export declare class KeyManagerApi {
|
|
@@ -25,8 +29,12 @@ export declare class KeyManagerApi {
|
|
|
25
29
|
import(kp: SchnorrKeyPair, options?: ImportKeyOptions): KeyIdentifier;
|
|
26
30
|
/**
|
|
27
31
|
* Export a Schnorr keypair from the KMS.
|
|
28
|
-
*
|
|
29
|
-
*
|
|
32
|
+
* Routes through the KeyManager's declared capability (`canExport`) rather
|
|
33
|
+
* than an `instanceof LocalKeyManager` check, so third-party adapters can
|
|
34
|
+
* opt in to export support without coupling to a specific implementation.
|
|
35
|
+
* External adapters (AWS, Vault, HSM) typically advertise `canExport: false`.
|
|
36
|
+
* @throws {Error} If the backing KeyManager does not advertise canExport=true,
|
|
37
|
+
* or omits the optional `exportKey` method.
|
|
30
38
|
*/
|
|
31
39
|
export(id: KeyIdentifier): SchnorrKeyPair;
|
|
32
40
|
/** List all managed key identifiers. */
|
|
@@ -39,12 +47,12 @@ export declare class KeyManagerApi {
|
|
|
39
47
|
* Sign data via the KMS.
|
|
40
48
|
* @param data The data to sign (must be non-empty).
|
|
41
49
|
* @param id Optional key identifier; uses the active key if omitted.
|
|
42
|
-
* @param options Signing options
|
|
50
|
+
* @param options Signing options. Defaults: `scheme: 'bip340'`.
|
|
43
51
|
*/
|
|
44
52
|
sign(data: Bytes, id?: KeyIdentifier, options?: SignOptions): SignatureBytes;
|
|
45
|
-
/** Verify a signature via the KMS. */
|
|
46
|
-
verify(signature: SignatureBytes, data: Bytes, id?: KeyIdentifier, options?:
|
|
53
|
+
/** Verify a signature via the KMS. Defaults: `scheme: 'bip340'`. */
|
|
54
|
+
verify(signature: SignatureBytes, data: Bytes, id?: KeyIdentifier, options?: VerifyOptions): boolean;
|
|
47
55
|
/** Compute a SHA-256 digest. */
|
|
48
56
|
digest(data: Uint8Array): HashBytes;
|
|
49
57
|
}
|
|
50
|
-
//# sourceMappingURL=
|
|
58
|
+
//# sourceMappingURL=key-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key-manager.d.ts","sourceRoot":"","sources":["../../src/key-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EAErB,KAAK,WAAW,EAChB,KAAK,aAAa,EACnB,MAAM,wBAAwB,CAAC;AAGhC;;;;;;;;;;;;GAYG;AACH,qBAAa,aAAa;IACxB,uCAAuC;IACvC,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;IAEzB,4EAA4E;gBAChE,GAAG,CAAC,EAAE,UAAU;IAI5B,8CAA8C;IAC9C,WAAW,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,aAAa;IAIxD,4CAA4C;IAC5C,SAAS,CAAC,EAAE,EAAE,aAAa,GAAG,IAAI;IAIlC,qDAAqD;IACrD,YAAY,CAAC,EAAE,CAAC,EAAE,aAAa,GAAG,KAAK;IAIvC,6CAA6C;IAC7C,MAAM,CAAC,EAAE,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,aAAa;IAIrE;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,EAAE,aAAa,GAAG,cAAc;IAUzC,wCAAwC;IACxC,QAAQ,IAAI,aAAa,EAAE;IAI3B,iCAAiC;IACjC,SAAS,CAAC,EAAE,EAAE,aAAa,EAAE,OAAO,GAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,IAAI;IAIrE;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,cAAc;IAK5E,oEAAoE;IACpE,MAAM,CAAC,SAAS,EAAE,cAAc,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO;IAIpG,gCAAgC;IAChC,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS;CAGpC"}
|
package/dist/types/method.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { BitcoinConnection } from '@did-btcr2/bitcoin';
|
|
2
|
-
import type { DocumentBytes,
|
|
2
|
+
import type { DocumentBytes, KeyBytes, PatchOperation } from '@did-btcr2/common';
|
|
3
3
|
import type { SignedBTCR2Update } from '@did-btcr2/cryptosuite';
|
|
4
|
+
import type { Signer } from '@did-btcr2/keypair';
|
|
4
5
|
import type { Btcr2DidDocument, DidCreateOptions, ResolutionOptions } from '@did-btcr2/method';
|
|
5
6
|
import type { DidResolutionResult, DidVerificationMethod } from '@web5/dids';
|
|
6
7
|
import type { BitcoinApi } from './bitcoin.js';
|
|
@@ -42,18 +43,26 @@ export declare class DidMethodApi {
|
|
|
42
43
|
*/
|
|
43
44
|
resolve(did: string, options?: ResolutionOptions): Promise<DidResolutionResult>;
|
|
44
45
|
/**
|
|
45
|
-
* Update an existing DID document
|
|
46
|
-
*
|
|
46
|
+
* Update an existing DID document by driving the sans-I/O {@link Updater} state
|
|
47
|
+
* machine (from @did-btcr2/method). This method handles the I/O side:
|
|
48
|
+
* - Signing: supplies the {@link Signer} to `NeedSigningKey`.
|
|
49
|
+
* - Broadcast: establishes a beacon via {@link BeaconFactory} and calls
|
|
50
|
+
* `broadcastSignal()` with the bitcoin connection configured on the API.
|
|
51
|
+
*
|
|
52
|
+
* For multi-party aggregation of SMT/CAS beacons, the caller should drive the
|
|
53
|
+
* Updater directly and delegate `NeedBroadcast` to the aggregation runner
|
|
54
|
+
* rather than using this high-level method.
|
|
55
|
+
*
|
|
47
56
|
* @param params The update parameters.
|
|
48
57
|
* @returns The signed update.
|
|
49
58
|
*/
|
|
50
|
-
update({ sourceDocument, patches, sourceVersionId, verificationMethodId, beaconId,
|
|
59
|
+
update({ sourceDocument, patches, sourceVersionId, verificationMethodId, beaconId, signer, bitcoin, }: {
|
|
51
60
|
sourceDocument: Btcr2DidDocument;
|
|
52
61
|
patches: PatchOperation[];
|
|
53
62
|
sourceVersionId: number;
|
|
54
63
|
verificationMethodId: string;
|
|
55
64
|
beaconId: string;
|
|
56
|
-
|
|
65
|
+
signer: Signer;
|
|
57
66
|
bitcoin?: BitcoinConnection;
|
|
58
67
|
}): Promise<SignedBTCR2Update>;
|
|
59
68
|
/**
|
|
@@ -74,8 +83,9 @@ export declare class DidMethodApi {
|
|
|
74
83
|
* .buildUpdate(currentDoc)
|
|
75
84
|
* .patch({ op: 'add', path: '/service/1', value: newService })
|
|
76
85
|
* .version(2)
|
|
77
|
-
* .
|
|
86
|
+
* .verificationMethodId('#initialKey')
|
|
78
87
|
* .beacon('#beacon-0')
|
|
88
|
+
* .signer(new LocalSigner(secretKey))
|
|
79
89
|
* .execute();
|
|
80
90
|
* ```
|
|
81
91
|
*/
|
|
@@ -100,17 +110,23 @@ export declare class UpdateBuilder {
|
|
|
100
110
|
patches(ops: PatchOperation[]): this;
|
|
101
111
|
/** Set the source version ID. */
|
|
102
112
|
version(id: number): this;
|
|
103
|
-
/** Set the verification method ID used for signing. */
|
|
104
|
-
|
|
113
|
+
/** Set the verification method ID used for signing the update. */
|
|
114
|
+
verificationMethodId(methodId: string): this;
|
|
105
115
|
/** Set the beacon ID for the update announcement. */
|
|
106
116
|
beacon(beaconId: string): this;
|
|
107
|
-
/**
|
|
108
|
-
|
|
117
|
+
/**
|
|
118
|
+
* Set the {@link Signer} that produces the update's BIP-340 Schnorr proof
|
|
119
|
+
* and the beacon transaction's ECDSA input signature. Use `LocalSigner`
|
|
120
|
+
* for in-process secret keys, `KeyManagerSigner` for KMS-managed keys
|
|
121
|
+
* (AWS, Vault, HSM, etc.), or any custom adapter implementing the `Signer`
|
|
122
|
+
* interface.
|
|
123
|
+
*/
|
|
124
|
+
signer(s: Signer): this;
|
|
109
125
|
/** Override the Bitcoin connection for this update. */
|
|
110
|
-
|
|
126
|
+
bitcoin(connection: BitcoinConnection): this;
|
|
111
127
|
/**
|
|
112
128
|
* Execute the update.
|
|
113
|
-
* @throws {Error} If required fields (version,
|
|
129
|
+
* @throws {Error} If required fields (version, verificationMethodId, beacon, signer) are missing.
|
|
114
130
|
*/
|
|
115
131
|
execute(): Promise<SignedBTCR2Update>;
|
|
116
132
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"method.d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AAI;IAKvB,uDAAuD;IACvD,OAAO,CAAC,UAAU,EAAE,iBAAiB,GAAG,IAAI;IAK5C;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,iBAAiB,CAAC;CA2B5C"}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HttpExecutor, NetworkName, RestConfig, RpcConfig } from '@did-btcr2/bitcoin';
|
|
2
|
-
import type { KeyManager } from '@did-btcr2/
|
|
2
|
+
import type { KeyManager } from '@did-btcr2/key-manager';
|
|
3
3
|
import type { Btcr2DidDocument } from '@did-btcr2/method';
|
|
4
4
|
import type { DidResolutionResult } from '@web5/dids';
|
|
5
5
|
import type { CasConfig } from './cas.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC3F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC3F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACjD,IAAI,CAAC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IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,GAAG,CAAC,EAAE,gBAAgB,CAAC;IACvB,GAAG,CAAC,EAAE,SAAS,CAAC;IAChB,GAAG,CAAC,EAAE,UAAU,CAAC;IACjB,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@did-btcr2/api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "SDK for accessing the did:btcr2 method functionality.",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -65,10 +65,9 @@
|
|
|
65
65
|
"api"
|
|
66
66
|
],
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@bitcoinerlab/secp256k1": "^1.2.0",
|
|
69
68
|
"@helia/strings": "^4.0.2",
|
|
70
|
-
"@noble/curves": "^
|
|
71
|
-
"@noble/hashes": "^
|
|
69
|
+
"@noble/curves": "^2.0.1",
|
|
70
|
+
"@noble/hashes": "^2.0.1",
|
|
72
71
|
"@noble/secp256k1": "^2.1.0",
|
|
73
72
|
"@scure/base": "^1.1.9",
|
|
74
73
|
"@scure/bip32": "^1.5.0",
|
|
@@ -77,19 +76,17 @@
|
|
|
77
76
|
"@web5/common": "^1.1.0",
|
|
78
77
|
"@web5/crypto": "^1.0.6",
|
|
79
78
|
"@web5/dids": "^1.2.0",
|
|
80
|
-
"bitcoinjs-lib": "7.0.0-rc.0",
|
|
81
79
|
"canonicalize": "^2.1.0",
|
|
82
80
|
"dotenv": "^16.5.0",
|
|
83
81
|
"helia": "^5.2.1",
|
|
84
82
|
"multiformats": "^13.3.1",
|
|
85
83
|
"nostr-tools": "^2.15.0",
|
|
86
|
-
"
|
|
87
|
-
"@did-btcr2/
|
|
88
|
-
"@did-btcr2/
|
|
89
|
-
"@did-btcr2/
|
|
90
|
-
"@did-btcr2/
|
|
91
|
-
"@did-btcr2/
|
|
92
|
-
"@did-btcr2/method": "^0.26.0"
|
|
84
|
+
"@did-btcr2/bitcoin": "^0.6.0",
|
|
85
|
+
"@did-btcr2/common": "^9.1.0",
|
|
86
|
+
"@did-btcr2/key-manager": "^0.6.0",
|
|
87
|
+
"@did-btcr2/keypair": "^0.13.0",
|
|
88
|
+
"@did-btcr2/cryptosuite": "^8.0.0",
|
|
89
|
+
"@did-btcr2/method": "^0.33.0"
|
|
93
90
|
},
|
|
94
91
|
"devDependencies": {
|
|
95
92
|
"@eslint/js": "^9.22.0",
|
package/src/api.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { NetworkName } from '@did-btcr2/bitcoin';
|
|
2
2
|
import type { DocumentBytes, KeyBytes, PatchOperation } from '@did-btcr2/common';
|
|
3
3
|
import type { SignedBTCR2Update } from '@did-btcr2/cryptosuite';
|
|
4
|
+
import type { Signer } from '@did-btcr2/keypair';
|
|
4
5
|
import { SchnorrKeyPair } from '@did-btcr2/keypair';
|
|
5
|
-
import type { KeyIdentifier } from '@did-btcr2/
|
|
6
|
+
import type { KeyIdentifier } from '@did-btcr2/key-manager';
|
|
6
7
|
import type { Btcr2DidDocument, DidCreateOptions, ResolutionOptions } from '@did-btcr2/method';
|
|
7
8
|
import type { DidResolutionResult } from '@web5/dids';
|
|
8
9
|
import { BitcoinApi } from './bitcoin.js';
|
|
@@ -10,7 +11,7 @@ import { CasApi, DEFAULT_CAS_GATEWAY, type CasConfig } from './cas.js';
|
|
|
10
11
|
import { CryptoApi } from './crypto.js';
|
|
11
12
|
import { DidApi } from './did.js';
|
|
12
13
|
import { assertString, NOOP_LOGGER } from './helpers.js';
|
|
13
|
-
import { KeyManagerApi } from './
|
|
14
|
+
import { KeyManagerApi } from './key-manager.js';
|
|
14
15
|
import { DidMethodApi } from './method.js';
|
|
15
16
|
import type { ApiConfig, BitcoinApiConfig, Logger, ResolutionResult } from './types.js';
|
|
16
17
|
|
|
@@ -204,6 +205,7 @@ export class DidBtcr2Api {
|
|
|
204
205
|
patches,
|
|
205
206
|
verificationMethodId,
|
|
206
207
|
beaconId,
|
|
208
|
+
signer,
|
|
207
209
|
sourceDocument,
|
|
208
210
|
sourceVersionId,
|
|
209
211
|
}: {
|
|
@@ -211,6 +213,7 @@ export class DidBtcr2Api {
|
|
|
211
213
|
patches: PatchOperation[];
|
|
212
214
|
verificationMethodId: string;
|
|
213
215
|
beaconId: string;
|
|
216
|
+
signer: Signer;
|
|
214
217
|
sourceDocument?: Btcr2DidDocument;
|
|
215
218
|
sourceVersionId?: number;
|
|
216
219
|
}): Promise<SignedBTCR2Update> {
|
|
@@ -257,6 +260,7 @@ export class DidBtcr2Api {
|
|
|
257
260
|
sourceVersionId : versionId,
|
|
258
261
|
verificationMethodId,
|
|
259
262
|
beaconId,
|
|
263
|
+
signer,
|
|
260
264
|
});
|
|
261
265
|
}
|
|
262
266
|
|
package/src/crypto.ts
CHANGED
|
@@ -15,9 +15,9 @@ import {
|
|
|
15
15
|
SchnorrMultikey
|
|
16
16
|
} from '@did-btcr2/cryptosuite';
|
|
17
17
|
import { CompressedSecp256k1PublicKey, SchnorrKeyPair, Secp256k1SecretKey } from '@did-btcr2/keypair';
|
|
18
|
-
import type { KeyIdentifier } from '@did-btcr2/
|
|
18
|
+
import type { KeyIdentifier } from '@did-btcr2/key-manager';
|
|
19
19
|
import type { DidVerificationMethod } from '@web5/dids';
|
|
20
|
-
import type { KeyManagerApi } from './
|
|
20
|
+
import type { KeyManagerApi } from './key-manager.js';
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Schnorr keypair operations.
|
package/src/index.ts
CHANGED
|
@@ -30,7 +30,7 @@ export * from './types.js';
|
|
|
30
30
|
export * from './helpers.js';
|
|
31
31
|
export * from './bitcoin.js';
|
|
32
32
|
export * from './cas.js';
|
|
33
|
-
export * from './
|
|
33
|
+
export * from './key-manager.js';
|
|
34
34
|
export * from './crypto.js';
|
|
35
35
|
export * from './did.js';
|
|
36
36
|
export * from './method.js';
|
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
import type { Bytes, HashBytes, SignatureBytes } from '@did-btcr2/common';
|
|
2
2
|
import type { SchnorrKeyPair } from '@did-btcr2/keypair';
|
|
3
|
-
import type {
|
|
4
|
-
KeyIdentifier,
|
|
5
|
-
KeyManager} from '@did-btcr2/kms';
|
|
6
3
|
import {
|
|
4
|
+
type KeyIdentifier,
|
|
5
|
+
type KeyManager,
|
|
7
6
|
type GenerateKeyOptions,
|
|
8
7
|
type ImportKeyOptions,
|
|
9
|
-
|
|
8
|
+
LocalKeyManager,
|
|
10
9
|
type SignOptions,
|
|
11
|
-
|
|
10
|
+
type VerifyOptions,
|
|
11
|
+
} from '@did-btcr2/key-manager';
|
|
12
12
|
import { assertBytes } from './helpers.js';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Key management operations sub-facade.
|
|
16
16
|
*
|
|
17
|
-
* Wraps
|
|
18
|
-
* {@link
|
|
19
|
-
*
|
|
17
|
+
* Wraps any {@link KeyManager} interface implementation. By default uses the
|
|
18
|
+
* bundled {@link LocalKeyManager} (in-process reference implementation); a
|
|
19
|
+
* custom implementation (AWS KMS, GCP KMS, HashiCorp Vault, HSM, etc.) can
|
|
20
|
+
* be injected via {@link ApiConfig}.
|
|
21
|
+
*
|
|
22
|
+
* The field is named `kms` because that's the category label callers use
|
|
23
|
+
* conversationally ("plug in your KMS"); the actual contract is the
|
|
24
|
+
* {@link KeyManager} interface.
|
|
20
25
|
* @public
|
|
21
26
|
*/
|
|
22
27
|
export class KeyManagerApi {
|
|
@@ -25,7 +30,7 @@ export class KeyManagerApi {
|
|
|
25
30
|
|
|
26
31
|
/** Create a new KeyManagerApi, optionally backed by a custom KeyManager. */
|
|
27
32
|
constructor(kms?: KeyManager) {
|
|
28
|
-
this.kms = kms ?? new
|
|
33
|
+
this.kms = kms ?? new LocalKeyManager();
|
|
29
34
|
}
|
|
30
35
|
|
|
31
36
|
/** Generate a new key directly in the KMS. */
|
|
@@ -50,14 +55,18 @@ export class KeyManagerApi {
|
|
|
50
55
|
|
|
51
56
|
/**
|
|
52
57
|
* Export a Schnorr keypair from the KMS.
|
|
53
|
-
*
|
|
54
|
-
*
|
|
58
|
+
* Routes through the KeyManager's declared capability (`canExport`) rather
|
|
59
|
+
* than an `instanceof LocalKeyManager` check, so third-party adapters can
|
|
60
|
+
* opt in to export support without coupling to a specific implementation.
|
|
61
|
+
* External adapters (AWS, Vault, HSM) typically advertise `canExport: false`.
|
|
62
|
+
* @throws {Error} If the backing KeyManager does not advertise canExport=true,
|
|
63
|
+
* or omits the optional `exportKey` method.
|
|
55
64
|
*/
|
|
56
65
|
export(id: KeyIdentifier): SchnorrKeyPair {
|
|
57
|
-
if (!
|
|
66
|
+
if (!this.kms.canExport || !this.kms.exportKey) {
|
|
58
67
|
throw new Error(
|
|
59
68
|
'Key export is not supported by the current KeyManager implementation. '
|
|
60
|
-
+ '
|
|
69
|
+
+ 'The adapter must advertise `canExport: true` and provide an `exportKey` method.'
|
|
61
70
|
);
|
|
62
71
|
}
|
|
63
72
|
return this.kms.exportKey(id);
|
|
@@ -77,15 +86,15 @@ export class KeyManagerApi {
|
|
|
77
86
|
* Sign data via the KMS.
|
|
78
87
|
* @param data The data to sign (must be non-empty).
|
|
79
88
|
* @param id Optional key identifier; uses the active key if omitted.
|
|
80
|
-
* @param options Signing options
|
|
89
|
+
* @param options Signing options. Defaults: `scheme: 'bip340'`.
|
|
81
90
|
*/
|
|
82
91
|
sign(data: Bytes, id?: KeyIdentifier, options?: SignOptions): SignatureBytes {
|
|
83
92
|
assertBytes(data, 'data');
|
|
84
93
|
return this.kms.sign(data, id, options);
|
|
85
94
|
}
|
|
86
95
|
|
|
87
|
-
/** Verify a signature via the KMS. */
|
|
88
|
-
verify(signature: SignatureBytes, data: Bytes, id?: KeyIdentifier, options?:
|
|
96
|
+
/** Verify a signature via the KMS. Defaults: `scheme: 'bip340'`. */
|
|
97
|
+
verify(signature: SignatureBytes, data: Bytes, id?: KeyIdentifier, options?: VerifyOptions): boolean {
|
|
89
98
|
return this.kms.verify(signature, data, id, options);
|
|
90
99
|
}
|
|
91
100
|
|