@did-btcr2/api 0.4.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/browser.js +22152 -34966
- package/dist/browser.mjs +22152 -34966
- package/dist/cjs/index.js +168 -41
- package/dist/esm/api.js +11 -11
- package/dist/esm/api.js.map +1 -1
- package/dist/esm/cas.js +61 -4
- package/dist/esm/cas.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 +10 -5
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/cas.d.ts +34 -1
- package/dist/types/cas.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 -8
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +9 -12
- package/src/api.ts +14 -13
- package/src/cas.ts +84 -5
- 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 -8
- package/dist/esm/kms.js.map +0 -1
- package/dist/types/kms.d.ts.map +0 -1
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LocalKeyManager, } from '@did-btcr2/key-manager';
|
|
2
2
|
import { assertBytes } from './helpers.js';
|
|
3
3
|
/**
|
|
4
4
|
* Key management operations sub-facade.
|
|
5
5
|
*
|
|
6
|
-
* Wraps
|
|
7
|
-
* {@link
|
|
8
|
-
*
|
|
6
|
+
* Wraps any {@link KeyManager} interface implementation. By default uses the
|
|
7
|
+
* bundled {@link LocalKeyManager} (in-process reference implementation); a
|
|
8
|
+
* custom implementation (AWS KMS, GCP KMS, HashiCorp Vault, HSM, etc.) can
|
|
9
|
+
* be injected via {@link ApiConfig}.
|
|
10
|
+
*
|
|
11
|
+
* The field is named `kms` because that's the category label callers use
|
|
12
|
+
* conversationally ("plug in your KMS"); the actual contract is the
|
|
13
|
+
* {@link KeyManager} interface.
|
|
9
14
|
* @public
|
|
10
15
|
*/
|
|
11
16
|
export class KeyManagerApi {
|
|
@@ -13,7 +18,7 @@ export class KeyManagerApi {
|
|
|
13
18
|
kms;
|
|
14
19
|
/** Create a new KeyManagerApi, optionally backed by a custom KeyManager. */
|
|
15
20
|
constructor(kms) {
|
|
16
|
-
this.kms = kms ?? new
|
|
21
|
+
this.kms = kms ?? new LocalKeyManager();
|
|
17
22
|
}
|
|
18
23
|
/** Generate a new key directly in the KMS. */
|
|
19
24
|
generateKey(options) {
|
|
@@ -33,13 +38,17 @@ export class KeyManagerApi {
|
|
|
33
38
|
}
|
|
34
39
|
/**
|
|
35
40
|
* Export a Schnorr keypair from the KMS.
|
|
36
|
-
*
|
|
37
|
-
*
|
|
41
|
+
* Routes through the KeyManager's declared capability (`canExport`) rather
|
|
42
|
+
* than an `instanceof LocalKeyManager` check, so third-party adapters can
|
|
43
|
+
* opt in to export support without coupling to a specific implementation.
|
|
44
|
+
* External adapters (AWS, Vault, HSM) typically advertise `canExport: false`.
|
|
45
|
+
* @throws {Error} If the backing KeyManager does not advertise canExport=true,
|
|
46
|
+
* or omits the optional `exportKey` method.
|
|
38
47
|
*/
|
|
39
48
|
export(id) {
|
|
40
|
-
if (!
|
|
49
|
+
if (!this.kms.canExport || !this.kms.exportKey) {
|
|
41
50
|
throw new Error('Key export is not supported by the current KeyManager implementation. '
|
|
42
|
-
+ '
|
|
51
|
+
+ 'The adapter must advertise `canExport: true` and provide an `exportKey` method.');
|
|
43
52
|
}
|
|
44
53
|
return this.kms.exportKey(id);
|
|
45
54
|
}
|
|
@@ -55,13 +64,13 @@ export class KeyManagerApi {
|
|
|
55
64
|
* Sign data via the KMS.
|
|
56
65
|
* @param data The data to sign (must be non-empty).
|
|
57
66
|
* @param id Optional key identifier; uses the active key if omitted.
|
|
58
|
-
* @param options Signing options
|
|
67
|
+
* @param options Signing options. Defaults: `scheme: 'bip340'`.
|
|
59
68
|
*/
|
|
60
69
|
sign(data, id, options) {
|
|
61
70
|
assertBytes(data, 'data');
|
|
62
71
|
return this.kms.sign(data, id, options);
|
|
63
72
|
}
|
|
64
|
-
/** Verify a signature via the KMS. */
|
|
73
|
+
/** Verify a signature via the KMS. Defaults: `scheme: 'bip340'`. */
|
|
65
74
|
verify(signature, data, id, options) {
|
|
66
75
|
return this.kms.verify(signature, data, id, options);
|
|
67
76
|
}
|
|
@@ -70,4 +79,4 @@ export class KeyManagerApi {
|
|
|
70
79
|
return this.kms.digest(data);
|
|
71
80
|
}
|
|
72
81
|
}
|
|
73
|
-
//# sourceMappingURL=
|
|
82
|
+
//# sourceMappingURL=key-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key-manager.js","sourceRoot":"","sources":["../../src/key-manager.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,eAAe,GAGhB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,aAAa;IACxB,uCAAuC;IAC9B,GAAG,CAAa;IAEzB,4EAA4E;IAC5E,YAAY,GAAgB;QAC1B,IAAI,CAAC,GAAG,GAAG,GAAG,IAAI,IAAI,eAAe,EAAE,CAAC;IAC1C,CAAC;IAED,8CAA8C;IAC9C,WAAW,CAAC,OAA4B;QACtC,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,OAAO,CAAC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QACxF,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;IAED,gCAAgC;IAChC,MAAM,CAAC,IAAgB;QACrB,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;CACF"}
|
package/dist/esm/method.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { decode as decodeHash, IdentifierTypes, NotImplementedError } from '@did-btcr2/common';
|
|
2
|
-
import { BeaconSignalDiscovery, DidBtcr2 } from '@did-btcr2/method';
|
|
1
|
+
import { decode as decodeHash, IdentifierTypes, INVALID_DID_UPDATE, NotImplementedError, UpdateError } from '@did-btcr2/common';
|
|
2
|
+
import { BeaconFactory, BeaconSignalDiscovery, DidBtcr2 } from '@did-btcr2/method';
|
|
3
3
|
import { assertBytes, assertCompressedPubkey, assertString, NOOP_LOGGER } from './helpers.js';
|
|
4
4
|
/**
|
|
5
5
|
* DID method operations sub-facade: create, resolve, update, deactivate.
|
|
@@ -125,22 +125,72 @@ export class DidMethodApi {
|
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
/**
|
|
128
|
-
* Update an existing DID document
|
|
129
|
-
*
|
|
128
|
+
* Update an existing DID document by driving the sans-I/O {@link Updater} state
|
|
129
|
+
* machine (from @did-btcr2/method). This method handles the I/O side:
|
|
130
|
+
* - Signing: supplies the {@link Signer} to `NeedSigningKey`.
|
|
131
|
+
* - Broadcast: establishes a beacon via {@link BeaconFactory} and calls
|
|
132
|
+
* `broadcastSignal()` with the bitcoin connection configured on the API.
|
|
133
|
+
*
|
|
134
|
+
* For multi-party aggregation of SMT/CAS beacons, the caller should drive the
|
|
135
|
+
* Updater directly and delegate `NeedBroadcast` to the aggregation runner
|
|
136
|
+
* rather than using this high-level method.
|
|
137
|
+
*
|
|
130
138
|
* @param params The update parameters.
|
|
131
139
|
* @returns The signed update.
|
|
132
140
|
*/
|
|
133
|
-
async update({ sourceDocument, patches, sourceVersionId, verificationMethodId, beaconId,
|
|
134
|
-
|
|
135
|
-
|
|
141
|
+
async update({ sourceDocument, patches, sourceVersionId, verificationMethodId, beaconId, signer, bitcoin, }) {
|
|
142
|
+
// Bitcoin connection resolution order: per-call `bitcoin` param wins over the
|
|
143
|
+
// BitcoinApi injected at DidBtcr2Api construction time. One of the two must
|
|
144
|
+
// be present; this can't be encoded in the type system, so it's a runtime check.
|
|
145
|
+
const btcConnection = bitcoin ?? this.#btc?.connection;
|
|
146
|
+
if (!btcConnection) {
|
|
147
|
+
throw new UpdateError('Bitcoin connection required for update. Pass a configured `bitcoin` parameter '
|
|
148
|
+
+ 'or configure a BitcoinApi on the DidBtcr2Api instance.', INVALID_DID_UPDATE, { beaconId });
|
|
149
|
+
}
|
|
150
|
+
this.#log.debug('Updating DID', sourceDocument.id, { beaconId, verificationMethodId });
|
|
151
|
+
// Factory validates and returns a sans-I/O state machine
|
|
152
|
+
const updater = DidBtcr2.update({
|
|
136
153
|
sourceDocument,
|
|
137
154
|
patches,
|
|
138
155
|
sourceVersionId,
|
|
139
156
|
verificationMethodId,
|
|
140
157
|
beaconId,
|
|
141
|
-
signingMaterial,
|
|
142
|
-
bitcoin: btcConnection,
|
|
143
158
|
});
|
|
159
|
+
// Drive the state machine. All I/O (signing delegation, Bitcoin broadcast)
|
|
160
|
+
// happens inside the need-handlers below — the Updater itself is pure.
|
|
161
|
+
let state = updater.advance();
|
|
162
|
+
while (state.status === 'action-required') {
|
|
163
|
+
for (const need of state.needs) {
|
|
164
|
+
switch (need.kind) {
|
|
165
|
+
case 'NeedSigningKey': {
|
|
166
|
+
this.#log.debug('Providing signer for', need.verificationMethodId);
|
|
167
|
+
updater.provide(need, signer);
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
case 'NeedFunding': {
|
|
171
|
+
this.#log.debug('Checking funding for beacon address %s', need.beaconAddress);
|
|
172
|
+
const utxos = await btcConnection.rest.address.getUtxos(need.beaconAddress);
|
|
173
|
+
if (!utxos.length) {
|
|
174
|
+
throw new UpdateError(`Beacon address ${need.beaconAddress} is unfunded. `
|
|
175
|
+
+ 'Send BTC to this address before broadcasting the update.', INVALID_DID_UPDATE, { beaconAddress: need.beaconAddress });
|
|
176
|
+
}
|
|
177
|
+
this.#log.debug('Beacon address funded (%d UTXOs)', utxos.length);
|
|
178
|
+
updater.provide(need);
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
case 'NeedBroadcast': {
|
|
182
|
+
this.#log.debug('Broadcasting signed update via %s beacon', need.beaconService.type);
|
|
183
|
+
const beacon = BeaconFactory.establish(need.beaconService);
|
|
184
|
+
await beacon.broadcastSignal(need.signedUpdate, signer, btcConnection);
|
|
185
|
+
updater.provide(need);
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
state = updater.advance();
|
|
191
|
+
}
|
|
192
|
+
this.#log.debug('DID update complete', sourceDocument.id);
|
|
193
|
+
return state.result.signedUpdate;
|
|
144
194
|
}
|
|
145
195
|
/**
|
|
146
196
|
* Get the signing method from a DID document by method ID.
|
|
@@ -162,8 +212,9 @@ export class DidMethodApi {
|
|
|
162
212
|
* .buildUpdate(currentDoc)
|
|
163
213
|
* .patch({ op: 'add', path: '/service/1', value: newService })
|
|
164
214
|
* .version(2)
|
|
165
|
-
* .
|
|
215
|
+
* .verificationMethodId('#initialKey')
|
|
166
216
|
* .beacon('#beacon-0')
|
|
217
|
+
* .signer(new LocalSigner(secretKey))
|
|
167
218
|
* .execute();
|
|
168
219
|
* ```
|
|
169
220
|
*/
|
|
@@ -192,7 +243,7 @@ export class UpdateBuilder {
|
|
|
192
243
|
#sourceVersionId;
|
|
193
244
|
#verificationMethodId;
|
|
194
245
|
#beaconId;
|
|
195
|
-
#
|
|
246
|
+
#signer;
|
|
196
247
|
#bitcoin;
|
|
197
248
|
/** @internal */
|
|
198
249
|
constructor(methodApi, sourceDocument) {
|
|
@@ -214,8 +265,8 @@ export class UpdateBuilder {
|
|
|
214
265
|
this.#sourceVersionId = id;
|
|
215
266
|
return this;
|
|
216
267
|
}
|
|
217
|
-
/** Set the verification method ID used for signing. */
|
|
218
|
-
|
|
268
|
+
/** Set the verification method ID used for signing the update. */
|
|
269
|
+
verificationMethodId(methodId) {
|
|
219
270
|
this.#verificationMethodId = methodId;
|
|
220
271
|
return this;
|
|
221
272
|
}
|
|
@@ -224,37 +275,47 @@ export class UpdateBuilder {
|
|
|
224
275
|
this.#beaconId = beaconId;
|
|
225
276
|
return this;
|
|
226
277
|
}
|
|
227
|
-
/**
|
|
228
|
-
|
|
229
|
-
|
|
278
|
+
/**
|
|
279
|
+
* Set the {@link Signer} that produces the update's BIP-340 Schnorr proof
|
|
280
|
+
* and the beacon transaction's ECDSA input signature. Use `LocalSigner`
|
|
281
|
+
* for in-process secret keys, `KeyManagerSigner` for KMS-managed keys
|
|
282
|
+
* (AWS, Vault, HSM, etc.), or any custom adapter implementing the `Signer`
|
|
283
|
+
* interface.
|
|
284
|
+
*/
|
|
285
|
+
signer(s) {
|
|
286
|
+
this.#signer = s;
|
|
230
287
|
return this;
|
|
231
288
|
}
|
|
232
289
|
/** Override the Bitcoin connection for this update. */
|
|
233
|
-
|
|
290
|
+
bitcoin(connection) {
|
|
234
291
|
this.#bitcoin = connection;
|
|
235
292
|
return this;
|
|
236
293
|
}
|
|
237
294
|
/**
|
|
238
295
|
* Execute the update.
|
|
239
|
-
* @throws {Error} If required fields (version,
|
|
296
|
+
* @throws {Error} If required fields (version, verificationMethodId, beacon, signer) are missing.
|
|
240
297
|
*/
|
|
241
298
|
async execute() {
|
|
242
299
|
if (this.#sourceVersionId === undefined) {
|
|
243
300
|
throw new Error('UpdateBuilder: sourceVersionId is required. Call .version(id) before .execute().');
|
|
244
301
|
}
|
|
245
302
|
if (!this.#verificationMethodId) {
|
|
246
|
-
throw new Error('UpdateBuilder: verificationMethodId is required.
|
|
303
|
+
throw new Error('UpdateBuilder: verificationMethodId is required. '
|
|
304
|
+
+ 'Call .verificationMethodId(id) before .execute().');
|
|
247
305
|
}
|
|
248
306
|
if (!this.#beaconId) {
|
|
249
307
|
throw new Error('UpdateBuilder: beaconId is required. Call .beacon(id) before .execute().');
|
|
250
308
|
}
|
|
309
|
+
if (!this.#signer) {
|
|
310
|
+
throw new Error('UpdateBuilder: signer is required. Call .signer(s) before .execute().');
|
|
311
|
+
}
|
|
251
312
|
return this.#methodApi.update({
|
|
252
313
|
sourceDocument: this.#sourceDocument,
|
|
253
314
|
patches: this.#patches,
|
|
254
315
|
sourceVersionId: this.#sourceVersionId,
|
|
255
316
|
verificationMethodId: this.#verificationMethodId,
|
|
256
317
|
beaconId: this.#beaconId,
|
|
257
|
-
|
|
318
|
+
signer: this.#signer,
|
|
258
319
|
bitcoin: this.#bitcoin,
|
|
259
320
|
});
|
|
260
321
|
}
|
package/dist/esm/method.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"method.js","sourceRoot":"","sources":["../../src/method.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"method.js","sourceRoot":"","sources":["../../src/method.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,eAAe,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhI,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAInF,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG9F;;;;;;GAMG;AACH,MAAM,OAAO,YAAY;IACvB,IAAI,CAAc;IAClB,IAAI,CAAU;IACd,IAAI,CAAS;IAEb,YAAY,GA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I,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,uEAAuE,CAAC,CAAC;QAC3F,CAAC;QAED,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;YAC5B,cAAc,EAAS,IAAI,CAAC,eAAe;YAC3C,OAAO,EAAgB,IAAI,CAAC,QAAQ;YACpC,eAAe,EAAQ,IAAI,CAAC,gBAAgB;YAC5C,oBAAoB,EAAG,IAAI,CAAC,qBAAqB;YACjD,QAAQ,EAAe,IAAI,CAAC,SAAS;YACrC,MAAM,EAAiB,IAAI,CAAC,OAAO;YACnC,OAAO,EAAgB,IAAI,CAAC,QAAQ;SACrC,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/dist/types/api.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
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 {
|
|
4
|
+
import type { Signer } from '@did-btcr2/keypair';
|
|
5
|
+
import type { KeyIdentifier } from '@did-btcr2/key-manager';
|
|
5
6
|
import type { Btcr2DidDocument, DidCreateOptions, ResolutionOptions } from '@did-btcr2/method';
|
|
6
7
|
import type { DidResolutionResult } from '@web5/dids';
|
|
7
8
|
import { BitcoinApi } from './bitcoin.js';
|
|
8
9
|
import { CasApi } from './cas.js';
|
|
9
10
|
import { CryptoApi } from './crypto.js';
|
|
10
11
|
import { DidApi } from './did.js';
|
|
11
|
-
import { KeyManagerApi } from './
|
|
12
|
+
import { KeyManagerApi } from './key-manager.js';
|
|
12
13
|
import { DidMethodApi } from './method.js';
|
|
13
14
|
import type { ApiConfig, ResolutionResult } from './types.js';
|
|
14
15
|
/**
|
|
@@ -35,8 +36,11 @@ export declare class DidBtcr2Api {
|
|
|
35
36
|
get btc(): BitcoinApi;
|
|
36
37
|
/**
|
|
37
38
|
* CAS API sub-facade (lazily initialized).
|
|
38
|
-
*
|
|
39
|
-
*
|
|
39
|
+
*
|
|
40
|
+
* When no `cas` config was provided to the constructor, defaults to a
|
|
41
|
+
* read-only {@link HttpGatewayCasExecutor} backed by the public IPFS
|
|
42
|
+
* gateway (`https://ipfs.io`). Override via `createApi({ cas: { ... } })`.
|
|
43
|
+
* @throws {Error} If the instance has been disposed.
|
|
40
44
|
*/
|
|
41
45
|
get cas(): CasApi;
|
|
42
46
|
/**
|
|
@@ -96,11 +100,12 @@ export declare class DidBtcr2Api {
|
|
|
96
100
|
* @param params The update parameters.
|
|
97
101
|
* @returns The signed update.
|
|
98
102
|
*/
|
|
99
|
-
updateDid({ did, patches, verificationMethodId, beaconId, sourceDocument, sourceVersionId, }: {
|
|
103
|
+
updateDid({ did, patches, verificationMethodId, beaconId, signer, sourceDocument, sourceVersionId, }: {
|
|
100
104
|
did: string;
|
|
101
105
|
patches: PatchOperation[];
|
|
102
106
|
verificationMethodId: string;
|
|
103
107
|
beaconId: string;
|
|
108
|
+
signer: Signer;
|
|
104
109
|
sourceDocument?: Btcr2DidDocument;
|
|
105
110
|
sourceVersionId?: number;
|
|
106
111
|
}): Promise<SignedBTCR2Update>;
|
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,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OA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
2
2
|
import type { Helia } from 'helia';
|
|
3
|
+
/** Default IPFS HTTP gateway used for CAS reads when no CAS config is provided. */
|
|
4
|
+
export declare const DEFAULT_CAS_GATEWAY = "https://ipfs.io";
|
|
3
5
|
/**
|
|
4
6
|
* Executor interface for content-addressed storage.
|
|
5
7
|
*
|
|
@@ -27,15 +29,46 @@ export declare class IpfsCasExecutor implements CasExecutor {
|
|
|
27
29
|
retrieve(hash: string): Promise<Uint8Array | null>;
|
|
28
30
|
publish(data: Uint8Array): Promise<string>;
|
|
29
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Read-only {@link CasExecutor} backed by an IPFS HTTP gateway.
|
|
34
|
+
*
|
|
35
|
+
* Converts the base64url SHA-256 hash to a CIDv1 (raw codec) and fetches
|
|
36
|
+
* the raw block via the
|
|
37
|
+
* {@link https://specs.ipfs.tech/http-gateways/trustless-gateway/ | Trustless Gateway}
|
|
38
|
+
* protocol.
|
|
39
|
+
*
|
|
40
|
+
* Publishing is not supported — use {@link IpfsCasExecutor} with a Helia
|
|
41
|
+
* instance for writes.
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
export declare class HttpGatewayCasExecutor implements CasExecutor {
|
|
45
|
+
#private;
|
|
46
|
+
constructor(gatewayUrl: string);
|
|
47
|
+
retrieve(hash: string): Promise<Uint8Array | null>;
|
|
48
|
+
publish(): Promise<string>;
|
|
49
|
+
}
|
|
50
|
+
/** Default timeout (ms) for CAS operations. */
|
|
51
|
+
export declare const DEFAULT_CAS_TIMEOUT_MS = 30000;
|
|
30
52
|
/**
|
|
31
53
|
* Configuration for the CAS (Content-Addressed Storage) driver.
|
|
54
|
+
*
|
|
55
|
+
* Provide exactly one of `executor`, `helia`, or `gateway`.
|
|
56
|
+
* Priority if multiple are set: `executor` > `helia` > `gateway`.
|
|
32
57
|
* @public
|
|
33
58
|
*/
|
|
34
59
|
export type CasConfig = {
|
|
35
|
-
/** Custom executor implementation (overrides
|
|
60
|
+
/** Custom executor implementation (overrides all other options). */
|
|
36
61
|
executor?: CasExecutor;
|
|
37
62
|
/** Pre-existing Helia instance for the default IPFS executor. */
|
|
38
63
|
helia?: Helia;
|
|
64
|
+
/** IPFS HTTP gateway URL for read-only CAS access (e.g. `'https://ipfs.io'`). */
|
|
65
|
+
gateway?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Timeout in milliseconds for CAS operations. Prevents indefinite hangs
|
|
68
|
+
* when a Helia DHT lookup or gateway request stalls. Default: 30 000 ms.
|
|
69
|
+
* Set to `0` to disable.
|
|
70
|
+
*/
|
|
71
|
+
timeoutMs?: number;
|
|
39
72
|
};
|
|
40
73
|
/**
|
|
41
74
|
* Content-Addressed Storage API sub-facade.
|
package/dist/types/cas.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cas.d.ts","sourceRoot":"","sources":["../../src/cas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAMnC;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,+EAA+E;IAC/E,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IACnD,+DAA+D;IAC/D,OAAO,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC5C;AAED;;;;;;;GAOG;AACH,qBAAa,eAAgB,YAAW,WAAW;;gBAGrC,KAAK,EAAE,KAAK;IAIlB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAUlD,OAAO,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;CAQjD;AAED
|
|
1
|
+
{"version":3,"file":"cas.d.ts","sourceRoot":"","sources":["../../src/cas.ts"],"names":[],"mappings":"AAAA,O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gB7B;;;;OAIG;IACG,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAO5D;;;;;;OAMG;IACG,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAqB/C"}
|
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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;IACH,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,eAAe,GAAG,cAAc;IAKvD;;;;;;OAMG;IACH,MAAM,CAAC,IAAI,EAAE,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,MAAM,mBAAmB,CAAC;AACpD,YAAY,EACV,OAAO,EACP,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,SAAS,EACV,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,KAAK,EACL,eAAe,EACf,aAAa,EACb,SAAS,EACT,GAAG,EACH,UAAU,EACV,QAAQ,EACR,cAAc,EACd,UAAU,EACV,oBAAoB,EACpB,cAAc,EACf,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,YAAY,EAAE,mBAAmB,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAGzF,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,
|
|
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,MAAM,mBAAmB,CAAC;AACpD,YAAY,EACV,OAAO,EACP,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,SAAS,EACV,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,KAAK,EACL,eAAe,EACf,aAAa,EACb,SAAS,EACT,GAAG,EACH,UAAU,EACV,QAAQ,EACR,cAAc,EACd,UAAU,EACV,oBAAoB,EACpB,cAAc,EACf,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,YAAY,EAAE,mBAAmB,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAGzF,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;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,EAC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
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.ts","sourceRoot":"","sources":["../../src/method.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"method.d.ts","sourceRoot":"","sources":["../../src/method.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEjF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAmB,gBAAgB,EAA8D,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE5K,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC;;;;;;GAMG;AACH,qBAAa,YAAY;;gBAKX,GAAG,CAAC,EAAE,UAAU,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IAM3D;;;;;;OAMG;IACH,mBAAmB,CAAC,YAAY,EAAE,QAAQ,EAAE,OAAO,GAAE,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAM,GAAG,MAAM;IAKnG;;;;;;OAMG;IACH,cAAc,CAAC,YAAY,EAAE,a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