@did-btcr2/api 0.1.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/LICENSE +373 -0
- package/README.md +7 -0
- package/dist/browser.js +191676 -0
- package/dist/browser.mjs +191670 -0
- package/dist/cjs/api.js +180 -0
- package/dist/cjs/api.js.map +1 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/esm/api.js +180 -0
- package/dist/esm/api.js.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/types/api.d.ts +105 -0
- package/dist/types/api.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +137 -0
- package/src/api.ts +302 -0
- package/src/index.ts +1 -0
package/dist/cjs/api.js
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { BitcoinCoreRpcClient, BitcoinRestClient } from '@did-btcr2/bitcoin';
|
|
2
|
+
import { DEFAULT_BLOCK_CONFIRMATIONS, DEFAULT_REST_CONFIG, DEFAULT_RPC_CONFIG, IdentifierTypes, NotImplementedError } from '@did-btcr2/common';
|
|
3
|
+
import { SchnorrMultikey } from '@did-btcr2/cryptosuite';
|
|
4
|
+
import { SchnorrKeyPair, Secp256k1SecretKey } from '@did-btcr2/keypair';
|
|
5
|
+
import { DidBtcr2, DidDocument, DidDocumentBuilder, Identifier } from '@did-btcr2/method';
|
|
6
|
+
export { DidDocument, DidDocumentBuilder, Identifier, IdentifierTypes };
|
|
7
|
+
/* =========================
|
|
8
|
+
* Sub-facade: KeyPair
|
|
9
|
+
* ========================= */
|
|
10
|
+
export class KeyPairApi {
|
|
11
|
+
/** Generate a new Schnorr keypair (secp256k1). */
|
|
12
|
+
static generate() {
|
|
13
|
+
return new SchnorrKeyPair();
|
|
14
|
+
}
|
|
15
|
+
/** Import from secret key bytes or bigint. */
|
|
16
|
+
static fromSecret(ent) {
|
|
17
|
+
const sk = new Secp256k1SecretKey(ent);
|
|
18
|
+
return new SchnorrKeyPair({ secretKey: sk });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export class MultikeyApi {
|
|
22
|
+
/**
|
|
23
|
+
* Create a Schnorr Multikey wrapper (includes verificationMethod, sign/verify).
|
|
24
|
+
* If secret is present, the multikey can sign.
|
|
25
|
+
*/
|
|
26
|
+
static create(params) {
|
|
27
|
+
return new SchnorrMultikey(params);
|
|
28
|
+
}
|
|
29
|
+
/** Produce a DID Verification Method JSON from a multikey. */
|
|
30
|
+
static toVerificationMethod(mk) {
|
|
31
|
+
return mk.toVerificationMethod();
|
|
32
|
+
}
|
|
33
|
+
/** Sign bytes via the multikey (requires secret). */
|
|
34
|
+
static async sign(mk, data) {
|
|
35
|
+
return mk.sign(data);
|
|
36
|
+
}
|
|
37
|
+
/** Verify signature via multikey. */
|
|
38
|
+
static async verify(mk, data, signature) {
|
|
39
|
+
return mk.verify(data, signature);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/* =========================
|
|
43
|
+
* Sub-facade: Crypto
|
|
44
|
+
* ========================= */
|
|
45
|
+
export class CryptoApi {
|
|
46
|
+
static keyPairApi = new KeyPairApi();
|
|
47
|
+
static multikeyApi = new MultikeyApi();
|
|
48
|
+
}
|
|
49
|
+
/* =========================
|
|
50
|
+
* Sub-facade: Bitcoin
|
|
51
|
+
* ========================= */
|
|
52
|
+
export class BitcoinApi {
|
|
53
|
+
rest;
|
|
54
|
+
rpc;
|
|
55
|
+
defaultConfirmations;
|
|
56
|
+
constructor(cfg) {
|
|
57
|
+
const restCfg = {
|
|
58
|
+
host: cfg?.rest?.host ?? DEFAULT_REST_CONFIG.host,
|
|
59
|
+
...cfg?.rest
|
|
60
|
+
};
|
|
61
|
+
const rpcCfg = {
|
|
62
|
+
...DEFAULT_RPC_CONFIG,
|
|
63
|
+
...cfg?.rpc
|
|
64
|
+
};
|
|
65
|
+
this.rest = new BitcoinRestClient(restCfg);
|
|
66
|
+
this.rpc = new BitcoinCoreRpcClient(rpcCfg);
|
|
67
|
+
this.defaultConfirmations = cfg?.defaultConfirmations ?? DEFAULT_BLOCK_CONFIRMATIONS;
|
|
68
|
+
}
|
|
69
|
+
/** Fetch a transaction by txid via REST. */
|
|
70
|
+
async getTransaction(txid) {
|
|
71
|
+
return await this.rest.transaction.get(txid);
|
|
72
|
+
}
|
|
73
|
+
/** Broadcast a raw tx (hex) via REST. */
|
|
74
|
+
async send(rawTxHex) {
|
|
75
|
+
return await this.rest.transaction.send(rawTxHex);
|
|
76
|
+
}
|
|
77
|
+
/** Get UTXOs for an address via REST. */
|
|
78
|
+
async getUtxos(address) {
|
|
79
|
+
return await this.rest.address.getUtxos(address);
|
|
80
|
+
}
|
|
81
|
+
/** Get a block by hash or height via REST. */
|
|
82
|
+
async getBlock(params) {
|
|
83
|
+
return await this.rest.block.get({ blockhash: params.hash, height: params.height });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/* =========================
|
|
87
|
+
* Sub-facade: KeyManager
|
|
88
|
+
* ========================= */
|
|
89
|
+
// export class KeyManagerApi {
|
|
90
|
+
// readonly impl: IMethodKeyManager;
|
|
91
|
+
// constructor(params?: ApiKeyManagerConfig) {
|
|
92
|
+
// this.impl = new MethodKeyManager(params);
|
|
93
|
+
// }
|
|
94
|
+
// setActive(keyUri: string) {
|
|
95
|
+
// this.impl.activeKeyUri = keyUri;
|
|
96
|
+
// }
|
|
97
|
+
// export(keyUri: string) {
|
|
98
|
+
// return this.impl.export(keyUri);
|
|
99
|
+
// }
|
|
100
|
+
// import(mk: SchnorrMultikey, opts?: { importKey?: boolean; active?: boolean }) {
|
|
101
|
+
// return this.impl.import(mk, opts);
|
|
102
|
+
// }
|
|
103
|
+
// sign(keyUri: string, hash: HashBytes): Promise<SignatureBytes> {
|
|
104
|
+
// return this.impl.sign(keyUri, hash);
|
|
105
|
+
// }
|
|
106
|
+
// }
|
|
107
|
+
/* =========================
|
|
108
|
+
* Sub-facade: DID / CRUD
|
|
109
|
+
* ========================= */
|
|
110
|
+
export class DidApi {
|
|
111
|
+
/**
|
|
112
|
+
* Create a deterministic DID from a public key (bytes).
|
|
113
|
+
*/
|
|
114
|
+
async createDeterministic({ genesisBytes, options }) {
|
|
115
|
+
return await DidBtcr2.create({ idType: 'KEY', genesisBytes, options });
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Create from an intermediate DID document (external genesis).
|
|
119
|
+
*/
|
|
120
|
+
async createExternal({ genesisBytes, options }) {
|
|
121
|
+
return await DidBtcr2.create({ idType: 'KEY', genesisBytes, options });
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Resolve DID document from DID (did:btcr2:...).
|
|
125
|
+
*/
|
|
126
|
+
async resolve(did, options) {
|
|
127
|
+
return await DidBtcr2.resolve(did, options);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Update a DID Document using a JSON Patch, signed as capabilityInvocation.
|
|
131
|
+
* You provide the prior DID Document (to pick VM), a JSON Patch, and a signer multikey.
|
|
132
|
+
* This delegates to MethodUpdate (which follows the cryptosuite rules internally).
|
|
133
|
+
*/
|
|
134
|
+
async update({ identifier, sourceDocument, sourceVersionId, patch, verificationMethodId, beaconIds }) {
|
|
135
|
+
// The Update class exposes the algorithm that creates a DID Update Payload and proof;
|
|
136
|
+
// keep this wrapper narrow so testing can mock MethodUpdate directly.
|
|
137
|
+
const result = await DidBtcr2.update({
|
|
138
|
+
identifier,
|
|
139
|
+
sourceDocument,
|
|
140
|
+
sourceVersionId,
|
|
141
|
+
patch,
|
|
142
|
+
verificationMethodId,
|
|
143
|
+
beaconIds,
|
|
144
|
+
});
|
|
145
|
+
return result;
|
|
146
|
+
}
|
|
147
|
+
/** Deactivate convenience: applies the standard `deactivated: true` patch. */
|
|
148
|
+
async deactivate() {
|
|
149
|
+
// This class is a stub in method right now; expose a narrow wrapper for future expansion.
|
|
150
|
+
// return DidBtcr2.deactivate({ identifier, patch }); // No-op holder; implement when core adds behavior.
|
|
151
|
+
throw new NotImplementedError('DidApi.deactivate is not implemented yet.', {
|
|
152
|
+
type: 'DID_API_METHOD_NOT_IMPLEMENTED',
|
|
153
|
+
name: 'NOT_IMPLEMENTED_ERROR'
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/* =========================
|
|
158
|
+
* Root facade
|
|
159
|
+
* ========================= */
|
|
160
|
+
export class DidBtcr2Api {
|
|
161
|
+
bitcoin;
|
|
162
|
+
did;
|
|
163
|
+
keys;
|
|
164
|
+
crypto;
|
|
165
|
+
// readonly keyManager: KeyManagerApi;
|
|
166
|
+
constructor(config) {
|
|
167
|
+
this.bitcoin = new BitcoinApi(config?.bitcoin);
|
|
168
|
+
this.did = new DidApi();
|
|
169
|
+
this.keys = new KeyPairApi();
|
|
170
|
+
this.crypto = new CryptoApi();
|
|
171
|
+
// this.keyManager = new KeyManagerApi(config?.keyManager);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/* =========================
|
|
175
|
+
* Factory
|
|
176
|
+
* ========================= */
|
|
177
|
+
export function createApi(config) {
|
|
178
|
+
return new DidBtcr2Api(config);
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EAKlB,MAAM,oBAAoB,CAAC;AAe5B,OAAO,EAAE,2BAA2B,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE/I,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExE,OAAO,EAAE,QAAQ,EAAE,WA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YACE,IAAI,EAAG,gCAAgC;YACvC,IAAI,EAAG,uBAAuB;SAC/B,CACF,CAAC;IACJ,CAAC;CACF;AAED;;+BAE+B;AAE/B,MAAM,OAAO,WAAW;IACb,OAAO,CAAa;IACpB,GAAG,CAAS;IACZ,IAAI,CAAa;IACjB,MAAM,CAAY;IAC3B,sCAAsC;IAEtC,YAAY,MAAkB;QAC5B,IAAI,CAAC,OAAO,GAAG,IAAI,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC/C,IAAI,CAAC,GAAG,GAAG,IAAI,MAAM,EAAE,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;QAC9B,2DAA2D;IAC7D,CAAC;CACF;AAED;;+BAE+B;AAE/B,MAAM,UAAU,SAAS,CAAC,MAAkB;IAC1C,OAAO,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type": "commonjs"}
|
package/dist/esm/api.js
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { BitcoinCoreRpcClient, BitcoinRestClient } from '@did-btcr2/bitcoin';
|
|
2
|
+
import { DEFAULT_BLOCK_CONFIRMATIONS, DEFAULT_REST_CONFIG, DEFAULT_RPC_CONFIG, IdentifierTypes, NotImplementedError } from '@did-btcr2/common';
|
|
3
|
+
import { SchnorrMultikey } from '@did-btcr2/cryptosuite';
|
|
4
|
+
import { SchnorrKeyPair, Secp256k1SecretKey } from '@did-btcr2/keypair';
|
|
5
|
+
import { DidBtcr2, DidDocument, DidDocumentBuilder, Identifier } from '@did-btcr2/method';
|
|
6
|
+
export { DidDocument, DidDocumentBuilder, Identifier, IdentifierTypes };
|
|
7
|
+
/* =========================
|
|
8
|
+
* Sub-facade: KeyPair
|
|
9
|
+
* ========================= */
|
|
10
|
+
export class KeyPairApi {
|
|
11
|
+
/** Generate a new Schnorr keypair (secp256k1). */
|
|
12
|
+
static generate() {
|
|
13
|
+
return new SchnorrKeyPair();
|
|
14
|
+
}
|
|
15
|
+
/** Import from secret key bytes or bigint. */
|
|
16
|
+
static fromSecret(ent) {
|
|
17
|
+
const sk = new Secp256k1SecretKey(ent);
|
|
18
|
+
return new SchnorrKeyPair({ secretKey: sk });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export class MultikeyApi {
|
|
22
|
+
/**
|
|
23
|
+
* Create a Schnorr Multikey wrapper (includes verificationMethod, sign/verify).
|
|
24
|
+
* If secret is present, the multikey can sign.
|
|
25
|
+
*/
|
|
26
|
+
static create(params) {
|
|
27
|
+
return new SchnorrMultikey(params);
|
|
28
|
+
}
|
|
29
|
+
/** Produce a DID Verification Method JSON from a multikey. */
|
|
30
|
+
static toVerificationMethod(mk) {
|
|
31
|
+
return mk.toVerificationMethod();
|
|
32
|
+
}
|
|
33
|
+
/** Sign bytes via the multikey (requires secret). */
|
|
34
|
+
static async sign(mk, data) {
|
|
35
|
+
return mk.sign(data);
|
|
36
|
+
}
|
|
37
|
+
/** Verify signature via multikey. */
|
|
38
|
+
static async verify(mk, data, signature) {
|
|
39
|
+
return mk.verify(data, signature);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/* =========================
|
|
43
|
+
* Sub-facade: Crypto
|
|
44
|
+
* ========================= */
|
|
45
|
+
export class CryptoApi {
|
|
46
|
+
static keyPairApi = new KeyPairApi();
|
|
47
|
+
static multikeyApi = new MultikeyApi();
|
|
48
|
+
}
|
|
49
|
+
/* =========================
|
|
50
|
+
* Sub-facade: Bitcoin
|
|
51
|
+
* ========================= */
|
|
52
|
+
export class BitcoinApi {
|
|
53
|
+
rest;
|
|
54
|
+
rpc;
|
|
55
|
+
defaultConfirmations;
|
|
56
|
+
constructor(cfg) {
|
|
57
|
+
const restCfg = {
|
|
58
|
+
host: cfg?.rest?.host ?? DEFAULT_REST_CONFIG.host,
|
|
59
|
+
...cfg?.rest
|
|
60
|
+
};
|
|
61
|
+
const rpcCfg = {
|
|
62
|
+
...DEFAULT_RPC_CONFIG,
|
|
63
|
+
...cfg?.rpc
|
|
64
|
+
};
|
|
65
|
+
this.rest = new BitcoinRestClient(restCfg);
|
|
66
|
+
this.rpc = new BitcoinCoreRpcClient(rpcCfg);
|
|
67
|
+
this.defaultConfirmations = cfg?.defaultConfirmations ?? DEFAULT_BLOCK_CONFIRMATIONS;
|
|
68
|
+
}
|
|
69
|
+
/** Fetch a transaction by txid via REST. */
|
|
70
|
+
async getTransaction(txid) {
|
|
71
|
+
return await this.rest.transaction.get(txid);
|
|
72
|
+
}
|
|
73
|
+
/** Broadcast a raw tx (hex) via REST. */
|
|
74
|
+
async send(rawTxHex) {
|
|
75
|
+
return await this.rest.transaction.send(rawTxHex);
|
|
76
|
+
}
|
|
77
|
+
/** Get UTXOs for an address via REST. */
|
|
78
|
+
async getUtxos(address) {
|
|
79
|
+
return await this.rest.address.getUtxos(address);
|
|
80
|
+
}
|
|
81
|
+
/** Get a block by hash or height via REST. */
|
|
82
|
+
async getBlock(params) {
|
|
83
|
+
return await this.rest.block.get({ blockhash: params.hash, height: params.height });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/* =========================
|
|
87
|
+
* Sub-facade: KeyManager
|
|
88
|
+
* ========================= */
|
|
89
|
+
// export class KeyManagerApi {
|
|
90
|
+
// readonly impl: IMethodKeyManager;
|
|
91
|
+
// constructor(params?: ApiKeyManagerConfig) {
|
|
92
|
+
// this.impl = new MethodKeyManager(params);
|
|
93
|
+
// }
|
|
94
|
+
// setActive(keyUri: string) {
|
|
95
|
+
// this.impl.activeKeyUri = keyUri;
|
|
96
|
+
// }
|
|
97
|
+
// export(keyUri: string) {
|
|
98
|
+
// return this.impl.export(keyUri);
|
|
99
|
+
// }
|
|
100
|
+
// import(mk: SchnorrMultikey, opts?: { importKey?: boolean; active?: boolean }) {
|
|
101
|
+
// return this.impl.import(mk, opts);
|
|
102
|
+
// }
|
|
103
|
+
// sign(keyUri: string, hash: HashBytes): Promise<SignatureBytes> {
|
|
104
|
+
// return this.impl.sign(keyUri, hash);
|
|
105
|
+
// }
|
|
106
|
+
// }
|
|
107
|
+
/* =========================
|
|
108
|
+
* Sub-facade: DID / CRUD
|
|
109
|
+
* ========================= */
|
|
110
|
+
export class DidApi {
|
|
111
|
+
/**
|
|
112
|
+
* Create a deterministic DID from a public key (bytes).
|
|
113
|
+
*/
|
|
114
|
+
async createDeterministic({ genesisBytes, options }) {
|
|
115
|
+
return await DidBtcr2.create({ idType: 'KEY', genesisBytes, options });
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Create from an intermediate DID document (external genesis).
|
|
119
|
+
*/
|
|
120
|
+
async createExternal({ genesisBytes, options }) {
|
|
121
|
+
return await DidBtcr2.create({ idType: 'KEY', genesisBytes, options });
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Resolve DID document from DID (did:btcr2:...).
|
|
125
|
+
*/
|
|
126
|
+
async resolve(did, options) {
|
|
127
|
+
return await DidBtcr2.resolve(did, options);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Update a DID Document using a JSON Patch, signed as capabilityInvocation.
|
|
131
|
+
* You provide the prior DID Document (to pick VM), a JSON Patch, and a signer multikey.
|
|
132
|
+
* This delegates to MethodUpdate (which follows the cryptosuite rules internally).
|
|
133
|
+
*/
|
|
134
|
+
async update({ identifier, sourceDocument, sourceVersionId, patch, verificationMethodId, beaconIds }) {
|
|
135
|
+
// The Update class exposes the algorithm that creates a DID Update Payload and proof;
|
|
136
|
+
// keep this wrapper narrow so testing can mock MethodUpdate directly.
|
|
137
|
+
const result = await DidBtcr2.update({
|
|
138
|
+
identifier,
|
|
139
|
+
sourceDocument,
|
|
140
|
+
sourceVersionId,
|
|
141
|
+
patch,
|
|
142
|
+
verificationMethodId,
|
|
143
|
+
beaconIds,
|
|
144
|
+
});
|
|
145
|
+
return result;
|
|
146
|
+
}
|
|
147
|
+
/** Deactivate convenience: applies the standard `deactivated: true` patch. */
|
|
148
|
+
async deactivate() {
|
|
149
|
+
// This class is a stub in method right now; expose a narrow wrapper for future expansion.
|
|
150
|
+
// return DidBtcr2.deactivate({ identifier, patch }); // No-op holder; implement when core adds behavior.
|
|
151
|
+
throw new NotImplementedError('DidApi.deactivate is not implemented yet.', {
|
|
152
|
+
type: 'DID_API_METHOD_NOT_IMPLEMENTED',
|
|
153
|
+
name: 'NOT_IMPLEMENTED_ERROR'
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/* =========================
|
|
158
|
+
* Root facade
|
|
159
|
+
* ========================= */
|
|
160
|
+
export class DidBtcr2Api {
|
|
161
|
+
bitcoin;
|
|
162
|
+
did;
|
|
163
|
+
keys;
|
|
164
|
+
crypto;
|
|
165
|
+
// readonly keyManager: KeyManagerApi;
|
|
166
|
+
constructor(config) {
|
|
167
|
+
this.bitcoin = new BitcoinApi(config?.bitcoin);
|
|
168
|
+
this.did = new DidApi();
|
|
169
|
+
this.keys = new KeyPairApi();
|
|
170
|
+
this.crypto = new CryptoApi();
|
|
171
|
+
// this.keyManager = new KeyManagerApi(config?.keyManager);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/* =========================
|
|
175
|
+
* Factory
|
|
176
|
+
* ========================= */
|
|
177
|
+
export function createApi(config) {
|
|
178
|
+
return new DidBtcr2Api(config);
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EAKlB,MAAM,oBAAoB,CAAC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AQ,CAAC,MAAM,CAAC;YACnC,UAAU;YACV,cAAc;YACd,eAAe;YACf,KAAK;YACL,oBAAoB;YACpB,SAAS;SACV,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,8EAA8E;IAC9E,KAAK,CAAC,UAAU;QACd,0FAA0F;QAC1F,yGAAyG;QACzG,MAAM,IAAI,mBAAmB,CAC3B,2CAA2C,EAC3C;YACE,IAAI,EAAG,gCAAgC;YACvC,IAAI,EAAG,uBAAuB;SAC/B,CACF,CAAC;IACJ,CAAC;CACF;AAED;;+BAE+B;AAE/B,MAAM,OAAO,WAAW;IACb,OAAO,CAAa;IACpB,GAAG,CAAS;IACZ,IAAI,CAAa;IACjB,MAAM,CAAY;IAC3B,sCAAsC;IAEtC,YAAY,MAAkB;QAC5B,IAAI,CAAC,OAAO,GAAG,IAAI,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC/C,IAAI,CAAC,GAAG,GAAG,IAAI,MAAM,EAAE,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;QAC9B,2DAA2D;IAC7D,CAAC;CACF;AAED;;+BAE+B;AAE/B,MAAM,UAAU,SAAS,CAAC,MAAkB;IAC1C,OAAO,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { BitcoinCoreRpcClient, BitcoinRestClient, BlockV3, RawTransactionV2, RestClientConfigParams, RpcClientConfig } from '@did-btcr2/bitcoin';
|
|
2
|
+
import type { Bytes, CryptosuiteName, DocumentBytes, Entropy, HashBytes, Hex, JSONObject, KeyBytes, PatchOperation, ProofBytes, SchnorrKeyPairObject, SignatureBytes } from '@did-btcr2/common';
|
|
3
|
+
import { IdentifierTypes } from '@did-btcr2/common';
|
|
4
|
+
import type { MultikeyObject } from '@did-btcr2/cryptosuite';
|
|
5
|
+
import { SchnorrMultikey } from '@did-btcr2/cryptosuite';
|
|
6
|
+
import { SchnorrKeyPair } from '@did-btcr2/keypair';
|
|
7
|
+
import type { DidCreateOptions, DidResolutionOptions, SignalsMetadata, UpdateParams } from '@did-btcr2/method';
|
|
8
|
+
import { DidDocument, DidDocumentBuilder, Identifier } from '@did-btcr2/method';
|
|
9
|
+
import type { DidResolutionResult, DidService, DidVerificationMethod } from '@web5/dids';
|
|
10
|
+
export { DidDocument, DidDocumentBuilder, Identifier, IdentifierTypes };
|
|
11
|
+
export type { BlockV3, Bytes, CryptosuiteName, DidResolutionResult, DidService, DidVerificationMethod, DocumentBytes, HashBytes, Hex, JSONObject, KeyBytes, MultikeyObject, PatchOperation, ProofBytes, RawTransactionV2, RestClientConfigParams, RpcClientConfig, SchnorrKeyPairObject, SignatureBytes };
|
|
12
|
+
export type NetworkName = 'mainnet' | 'testnet4' | 'signet' | 'regtest';
|
|
13
|
+
export type BitcoinApiConfig = {
|
|
14
|
+
/** Shortcut to compute base URLs and params via @did-btcr2/bitcoin getNetwork */
|
|
15
|
+
network?: NetworkName;
|
|
16
|
+
/** Override REST client settings */
|
|
17
|
+
rest?: RestClientConfigParams;
|
|
18
|
+
/** Override RPC client settings */
|
|
19
|
+
rpc?: RpcClientConfig;
|
|
20
|
+
/** Default number of confirmations to consider "final" */
|
|
21
|
+
defaultConfirmations?: number;
|
|
22
|
+
};
|
|
23
|
+
export type ApiConfig = {
|
|
24
|
+
bitcoin?: BitcoinApiConfig;
|
|
25
|
+
};
|
|
26
|
+
export declare class KeyPairApi {
|
|
27
|
+
/** Generate a new Schnorr keypair (secp256k1). */
|
|
28
|
+
static generate(): SchnorrKeyPair;
|
|
29
|
+
/** Import from secret key bytes or bigint. */
|
|
30
|
+
static fromSecret(ent: Entropy): SchnorrKeyPair;
|
|
31
|
+
}
|
|
32
|
+
export declare class MultikeyApi {
|
|
33
|
+
/**
|
|
34
|
+
* Create a Schnorr Multikey wrapper (includes verificationMethod, sign/verify).
|
|
35
|
+
* If secret is present, the multikey can sign.
|
|
36
|
+
*/
|
|
37
|
+
static create(params: {
|
|
38
|
+
id: string;
|
|
39
|
+
controller: string;
|
|
40
|
+
keys: SchnorrKeyPair;
|
|
41
|
+
}): SchnorrMultikey;
|
|
42
|
+
/** Produce a DID Verification Method JSON from a multikey. */
|
|
43
|
+
static toVerificationMethod(mk: SchnorrMultikey): DidVerificationMethod;
|
|
44
|
+
/** Sign bytes via the multikey (requires secret). */
|
|
45
|
+
static sign(mk: SchnorrMultikey, data: Bytes): Promise<SignatureBytes>;
|
|
46
|
+
/** Verify signature via multikey. */
|
|
47
|
+
static verify(mk: SchnorrMultikey, data: Bytes, signature: SignatureBytes): Promise<boolean>;
|
|
48
|
+
}
|
|
49
|
+
export declare class CryptoApi {
|
|
50
|
+
static keyPairApi: KeyPairApi;
|
|
51
|
+
static multikeyApi: MultikeyApi;
|
|
52
|
+
}
|
|
53
|
+
export declare class BitcoinApi {
|
|
54
|
+
readonly rest: BitcoinRestClient;
|
|
55
|
+
readonly rpc: BitcoinCoreRpcClient;
|
|
56
|
+
readonly defaultConfirmations: number;
|
|
57
|
+
constructor(cfg?: BitcoinApiConfig);
|
|
58
|
+
/** Fetch a transaction by txid via REST. */
|
|
59
|
+
getTransaction(txid: string): Promise<import("@did-btcr2/bitcoin").RawTransactionRest>;
|
|
60
|
+
/** Broadcast a raw tx (hex) via REST. */
|
|
61
|
+
send(rawTxHex: string): Promise<string>;
|
|
62
|
+
/** Get UTXOs for an address via REST. */
|
|
63
|
+
getUtxos(address: string): Promise<import("@did-btcr2/bitcoin").AddressUtxo[]>;
|
|
64
|
+
/** Get a block by hash or height via REST. */
|
|
65
|
+
getBlock(params: {
|
|
66
|
+
hash?: string;
|
|
67
|
+
height?: number;
|
|
68
|
+
}): Promise<import("@did-btcr2/bitcoin").BlockResponse | undefined>;
|
|
69
|
+
}
|
|
70
|
+
export declare class DidApi {
|
|
71
|
+
/**
|
|
72
|
+
* Create a deterministic DID from a public key (bytes).
|
|
73
|
+
*/
|
|
74
|
+
createDeterministic({ genesisBytes, options }: {
|
|
75
|
+
genesisBytes: KeyBytes;
|
|
76
|
+
options: DidCreateOptions;
|
|
77
|
+
}): Promise<string>;
|
|
78
|
+
/**
|
|
79
|
+
* Create from an intermediate DID document (external genesis).
|
|
80
|
+
*/
|
|
81
|
+
createExternal({ genesisBytes, options }: {
|
|
82
|
+
genesisBytes: DocumentBytes;
|
|
83
|
+
options: DidCreateOptions;
|
|
84
|
+
}): Promise<string>;
|
|
85
|
+
/**
|
|
86
|
+
* Resolve DID document from DID (did:btcr2:...).
|
|
87
|
+
*/
|
|
88
|
+
resolve(did: string, options: DidResolutionOptions): Promise<DidResolutionResult>;
|
|
89
|
+
/**
|
|
90
|
+
* Update a DID Document using a JSON Patch, signed as capabilityInvocation.
|
|
91
|
+
* You provide the prior DID Document (to pick VM), a JSON Patch, and a signer multikey.
|
|
92
|
+
* This delegates to MethodUpdate (which follows the cryptosuite rules internally).
|
|
93
|
+
*/
|
|
94
|
+
update({ identifier, sourceDocument, sourceVersionId, patch, verificationMethodId, beaconIds }: UpdateParams): Promise<SignalsMetadata>;
|
|
95
|
+
/** Deactivate convenience: applies the standard `deactivated: true` patch. */
|
|
96
|
+
deactivate(): Promise<SignalsMetadata>;
|
|
97
|
+
}
|
|
98
|
+
export declare class DidBtcr2Api {
|
|
99
|
+
readonly bitcoin: BitcoinApi;
|
|
100
|
+
readonly did: DidApi;
|
|
101
|
+
readonly keys: KeyPairApi;
|
|
102
|
+
readonly crypto: CryptoApi;
|
|
103
|
+
constructor(config?: ApiConfig);
|
|
104
|
+
}
|
|
105
|
+
export declare function createApi(config?: ApiConfig): DidBtcr2Api;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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E3C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './api.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@did-btcr2/api",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "SDK for accessing the did:btcr2 method functionality.",
|
|
6
|
+
"main": "./dist/cjs/index.js",
|
|
7
|
+
"module": "./dist/esm/index.js",
|
|
8
|
+
"types": "./dist/types/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/types/index.d.ts",
|
|
12
|
+
"browser": "./dist/browser.mjs",
|
|
13
|
+
"import": "./dist/esm/index.js",
|
|
14
|
+
"require": "./dist/cjs/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./browser": {
|
|
17
|
+
"type": "./dist/types/index.d.ts",
|
|
18
|
+
"default": "./dist/browser.mjs"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"typesVersions": {
|
|
22
|
+
"*": {
|
|
23
|
+
"browser": [
|
|
24
|
+
"dist/types/index.d.ts"
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist",
|
|
30
|
+
"src"
|
|
31
|
+
],
|
|
32
|
+
"license": "MPL-2.0",
|
|
33
|
+
"contributors": [
|
|
34
|
+
{
|
|
35
|
+
"name": "dcdpr",
|
|
36
|
+
"url": "https://github.com/dcdpr"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"name": "jintekc",
|
|
40
|
+
"url": "https://github.com/jintekc",
|
|
41
|
+
"email": "github@jintek.consulting"
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
"homepage": "https://github.com/dcdpr/did-btcr2-js/tree/main/packages/api",
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "git+ssh://git@github.com:dcdpr/did-btcr2-js.git",
|
|
48
|
+
"directory": "packages/api"
|
|
49
|
+
},
|
|
50
|
+
"bugs": "https://github.com/dcdpr/did-btcr2-js/issues",
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public"
|
|
53
|
+
},
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": ">=22.0.0"
|
|
56
|
+
},
|
|
57
|
+
"keywords": [
|
|
58
|
+
"did",
|
|
59
|
+
"dids",
|
|
60
|
+
"decentralized identity",
|
|
61
|
+
"decentralized identifiers",
|
|
62
|
+
"did method",
|
|
63
|
+
"did:btcr2",
|
|
64
|
+
"btcr2",
|
|
65
|
+
"api"
|
|
66
|
+
],
|
|
67
|
+
"dependencies": {
|
|
68
|
+
"@bitcoinerlab/secp256k1": "^1.2.0",
|
|
69
|
+
"@helia/strings": "^4.0.2",
|
|
70
|
+
"@noble/curves": "^1.8.1",
|
|
71
|
+
"@noble/hashes": "^1.5.0",
|
|
72
|
+
"@noble/secp256k1": "^2.1.0",
|
|
73
|
+
"@scure/base": "^1.1.9",
|
|
74
|
+
"@scure/bip32": "^1.5.0",
|
|
75
|
+
"@scure/bip39": "^1.4.0",
|
|
76
|
+
"@scure/btc-signer": "^1.8.1",
|
|
77
|
+
"@web5/common": "^1.1.0",
|
|
78
|
+
"@web5/crypto": "^1.0.6",
|
|
79
|
+
"@web5/dids": "^1.2.0",
|
|
80
|
+
"bitcoinjs-lib": "7.0.0-rc.0",
|
|
81
|
+
"canonicalize": "^2.1.0",
|
|
82
|
+
"dotenv": "^16.5.0",
|
|
83
|
+
"helia": "^5.2.1",
|
|
84
|
+
"multiformats": "^13.3.1",
|
|
85
|
+
"nostr-tools": "^2.15.0",
|
|
86
|
+
"tiny-secp256k1": "^2.2.3",
|
|
87
|
+
"@did-btcr2/bitcoin": "0.3.1",
|
|
88
|
+
"@did-btcr2/method": "0.17.1",
|
|
89
|
+
"@did-btcr2/common": "2.2.1",
|
|
90
|
+
"@did-btcr2/cryptosuite": "3.2.1",
|
|
91
|
+
"@did-btcr2/keypair": "0.7.0"
|
|
92
|
+
},
|
|
93
|
+
"devDependencies": {
|
|
94
|
+
"@eslint/js": "^9.22.0",
|
|
95
|
+
"@types/chai": "^5.0.1",
|
|
96
|
+
"@types/chai-as-promised": "^8.0.1",
|
|
97
|
+
"@types/eslint": "^9.6.1",
|
|
98
|
+
"@types/mocha": "^10.0.9",
|
|
99
|
+
"@types/node": "^22.5.4",
|
|
100
|
+
"@typescript-eslint/eslint-plugin": "^8.5.0",
|
|
101
|
+
"@typescript-eslint/parser": "^8.5.0",
|
|
102
|
+
"c8": "^10.1.2",
|
|
103
|
+
"chai": "^5.1.2",
|
|
104
|
+
"chai-as-promised": "^8.0.0",
|
|
105
|
+
"esbuild": "^0.24.2",
|
|
106
|
+
"eslint": "^9.14.0",
|
|
107
|
+
"eslint-plugin-mocha": "^10.5.0",
|
|
108
|
+
"globals": "^15.11.0",
|
|
109
|
+
"mocha": "^10.8.2",
|
|
110
|
+
"mocha-junit-reporter": "^2.2.1",
|
|
111
|
+
"node-stdlib-browser": "^1.3.1",
|
|
112
|
+
"rimraf": "^6.0.1",
|
|
113
|
+
"typedoc-plugin-markdown": "^4.7.0",
|
|
114
|
+
"typescript": "^5.6.2",
|
|
115
|
+
"typescript-eslint": "^8.19.1"
|
|
116
|
+
},
|
|
117
|
+
"scripts": {
|
|
118
|
+
"clean:build": "rimraf dist",
|
|
119
|
+
"clean:tests": "rimraf coverage tests/compiled",
|
|
120
|
+
"clean:deps": "rimraf node_modules pnpm-lock.json",
|
|
121
|
+
"clean": "pnpm clean:build && pnpm clean:tests",
|
|
122
|
+
"wipe": "pnpm clean && pnpm clean:deps",
|
|
123
|
+
"reinstall": "pnpm install --force",
|
|
124
|
+
"build": "pnpm clean:build && pnpm build:esm && pnpm build:cjs && pnpm build:browser",
|
|
125
|
+
"build:esm": "rimraf dist/esm dist/types && pnpm tsc -p tsconfig.json",
|
|
126
|
+
"build:cjs": "rimraf dist/cjs && tsc -p tsconfig.cjs.json && echo '{\"type\": \"commonjs\"}' > ./dist/cjs/package.json",
|
|
127
|
+
"build:browser": "rimraf dist/browser.mjs dist/browser.js && node build/bundles.js",
|
|
128
|
+
"build:tests": "pnpm clean:tests && pnpm tsc -p tests/tsconfig.json",
|
|
129
|
+
"build:all": "pnpm build && pnpm build:tests",
|
|
130
|
+
"lint": "eslint . --max-warnings 0",
|
|
131
|
+
"lint:fix": "eslint . --fix",
|
|
132
|
+
"test": "pnpm c8 mocha",
|
|
133
|
+
"build:test": "pnpm build && pnpm build:tests && pnpm c8 mocha",
|
|
134
|
+
"build:lint": "pnpm build && pnpm build:tests && pnpm lint:fix",
|
|
135
|
+
"prepublish": "pnpm build"
|
|
136
|
+
}
|
|
137
|
+
}
|