@babylonlabs-io/ts-sdk 0.59.1 → 0.59.2
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/{batchPoll-L9LzMl1E.js → batchPoll-BotUFjtF.js} +234 -210
- package/dist/batchPoll-BotUFjtF.js.map +1 -0
- package/dist/batchPoll-CbbCcNZP.cjs +2 -0
- package/dist/batchPoll-CbbCcNZP.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/tbv/core/clients/eth/__tests__/operation-key-reader.test.d.ts +2 -0
- package/dist/tbv/core/clients/eth/__tests__/operation-key-reader.test.d.ts.map +1 -0
- package/dist/tbv/core/clients/eth/operation-key-reader.d.ts.map +1 -1
- package/dist/tbv/core/clients/index.cjs +1 -1
- package/dist/tbv/core/clients/index.js +1 -1
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +1 -1
- package/package.json +1 -1
- package/dist/batchPoll-C4hwVFa8.cjs +0 -2
- package/dist/batchPoll-C4hwVFa8.cjs.map +0 -1
- package/dist/batchPoll-L9LzMl1E.js.map +0 -1
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var f = (r, e, t) =>
|
|
1
|
+
var Ce = Object.defineProperty;
|
|
2
|
+
var Te = (r, e, t) => e in r ? Ce(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var f = (r, e, t) => Te(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import { B } from "./BTCVaultRegistry.abi-B3BLhpJ4.js";
|
|
5
5
|
import { A as R, P as y } from "./ProtocolParams.abi-CV938AYZ.js";
|
|
6
|
-
import { k as
|
|
7
|
-
import { X as O, C as j, s as I, S as
|
|
8
|
-
import { D as
|
|
6
|
+
import { k as $e, v as U, l as Ve, j as Ie } from "./mempoolApi-BQKF5MTr.js";
|
|
7
|
+
import { X as O, C as j, s as I, S as Re, h as Oe, p as fe } from "./bitcoin-d9eaaZB_.js";
|
|
8
|
+
import { D as Ne, a as _e, e as Be } from "./json-rpc-client-DuUARJvV.js";
|
|
9
9
|
import { C as ee } from "./constants-GjWXdaqV.js";
|
|
10
10
|
import { H as k } from "./validation-Dj3dqYtl.js";
|
|
11
|
-
import * as
|
|
12
|
-
import { payments as
|
|
11
|
+
import * as K from "@bitcoin-js/tiny-secp256k1-asmjs";
|
|
12
|
+
import { payments as Ge, Transaction as X } from "bitcoinjs-lib";
|
|
13
13
|
import { Buffer as V } from "buffer";
|
|
14
14
|
import { s as Y } from "./sha2-BYVxyZzX.js";
|
|
15
|
-
async function
|
|
15
|
+
async function cr(r, e) {
|
|
16
16
|
const [t, n] = await r.multicall({
|
|
17
17
|
contracts: [
|
|
18
18
|
{
|
|
@@ -33,14 +33,20 @@ async function or(r, e) {
|
|
|
33
33
|
applicationRegistry: n
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function te(r, e, t) {
|
|
37
|
+
if (r !== e)
|
|
38
|
+
throw new Error(
|
|
39
|
+
`${t}: multicall returned ${r} results for ${e} calls, so the results are not roster-aligned; refusing to use them`
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
function De(r, e) {
|
|
37
43
|
return {
|
|
38
44
|
vaultProvider: r[0],
|
|
39
45
|
vaultKeepers: r.slice(1, 1 + e),
|
|
40
46
|
universalChallengers: r.slice(1 + e)
|
|
41
47
|
};
|
|
42
48
|
}
|
|
43
|
-
class
|
|
49
|
+
class lr {
|
|
44
50
|
constructor(e, t) {
|
|
45
51
|
this.publicClient = e, this.contracts = t;
|
|
46
52
|
}
|
|
@@ -50,12 +56,16 @@ class cr {
|
|
|
50
56
|
* otherwise produce a mixed-epoch key set and a lock no counterparty agrees
|
|
51
57
|
* with.
|
|
52
58
|
*/
|
|
53
|
-
async readAll(e, t) {
|
|
54
|
-
const
|
|
59
|
+
async readAll(e, t, n, i) {
|
|
60
|
+
const s = await this.publicClient.multicall({
|
|
55
61
|
contracts: e,
|
|
56
62
|
allowFailure: !1
|
|
57
63
|
});
|
|
58
|
-
return
|
|
64
|
+
return te(
|
|
65
|
+
s.length,
|
|
66
|
+
1 + t + n,
|
|
67
|
+
i
|
|
68
|
+
), De(s, t);
|
|
59
69
|
}
|
|
60
70
|
async getCurrentOperationKeys(e) {
|
|
61
71
|
const t = [
|
|
@@ -78,7 +88,12 @@ class cr {
|
|
|
78
88
|
args: [n.ethAddress]
|
|
79
89
|
}))
|
|
80
90
|
];
|
|
81
|
-
return this.readAll(
|
|
91
|
+
return this.readAll(
|
|
92
|
+
t,
|
|
93
|
+
e.vaultKeepers.length,
|
|
94
|
+
e.universalChallengers.length,
|
|
95
|
+
"getCurrentOperationKeys"
|
|
96
|
+
);
|
|
82
97
|
}
|
|
83
98
|
async getOperationKeysAtEpochs(e, t) {
|
|
84
99
|
const n = [
|
|
@@ -114,7 +129,12 @@ class cr {
|
|
|
114
129
|
args: [i.ethAddress, t.ucKeyEpoch, i.btcPubKey]
|
|
115
130
|
}))
|
|
116
131
|
];
|
|
117
|
-
return this.readAll(
|
|
132
|
+
return this.readAll(
|
|
133
|
+
n,
|
|
134
|
+
e.vaultKeepers.length,
|
|
135
|
+
e.universalChallengers.length,
|
|
136
|
+
"getOperationKeysAtEpochs"
|
|
137
|
+
);
|
|
118
138
|
}
|
|
119
139
|
async getPayoutScriptsAtEpochs(e, t) {
|
|
120
140
|
const n = await this.publicClient.multicall({
|
|
@@ -138,13 +158,17 @@ class cr {
|
|
|
138
158
|
],
|
|
139
159
|
allowFailure: !1
|
|
140
160
|
});
|
|
141
|
-
return
|
|
161
|
+
return te(
|
|
162
|
+
n.length,
|
|
163
|
+
1 + e.vaultKeepers.length,
|
|
164
|
+
"getPayoutScriptsAtEpochs"
|
|
165
|
+
), {
|
|
142
166
|
vaultProvider: n[0],
|
|
143
167
|
vaultKeepers: [...n.slice(1)]
|
|
144
168
|
};
|
|
145
169
|
}
|
|
146
170
|
}
|
|
147
|
-
const
|
|
171
|
+
const re = 65535;
|
|
148
172
|
function G(r) {
|
|
149
173
|
return {
|
|
150
174
|
timelockAssert: r.timelockAssert,
|
|
@@ -162,7 +186,7 @@ function G(r) {
|
|
|
162
186
|
minPrepeginDepth: r.minPrepeginDepth
|
|
163
187
|
};
|
|
164
188
|
}
|
|
165
|
-
function
|
|
189
|
+
function ne(r) {
|
|
166
190
|
return {
|
|
167
191
|
minimumPegInAmount: r.minimumPegInAmount,
|
|
168
192
|
maxPegInAmount: r.maxPegInAmount,
|
|
@@ -172,14 +196,14 @@ function re(r) {
|
|
|
172
196
|
expiredPegInGraceBlocks: r.expiredPegInGraceBlocks
|
|
173
197
|
};
|
|
174
198
|
}
|
|
175
|
-
function
|
|
176
|
-
if (r > BigInt(
|
|
199
|
+
function se(r) {
|
|
200
|
+
if (r > BigInt(re))
|
|
177
201
|
throw new Error(
|
|
178
|
-
`timelockAssert value ${r} exceeds uint16 max (${
|
|
202
|
+
`timelockAssert value ${r} exceeds uint16 max (${re})`
|
|
179
203
|
);
|
|
180
204
|
return Number(r);
|
|
181
205
|
}
|
|
182
|
-
class
|
|
206
|
+
class ur {
|
|
183
207
|
constructor(e, t) {
|
|
184
208
|
this.publicClient = e, this.contractAddress = t;
|
|
185
209
|
}
|
|
@@ -188,8 +212,8 @@ class lr {
|
|
|
188
212
|
address: this.contractAddress,
|
|
189
213
|
abi: y,
|
|
190
214
|
functionName: "getTBVProtocolParams"
|
|
191
|
-
}), t =
|
|
192
|
-
return
|
|
215
|
+
}), t = ne(e);
|
|
216
|
+
return $e(t), t;
|
|
193
217
|
}
|
|
194
218
|
async getLatestOffchainParams() {
|
|
195
219
|
const e = await this.publicClient.readContract({
|
|
@@ -197,7 +221,7 @@ class lr {
|
|
|
197
221
|
abi: y,
|
|
198
222
|
functionName: "getLatestOffchainParams"
|
|
199
223
|
}), t = G(e);
|
|
200
|
-
return
|
|
224
|
+
return U(t), t;
|
|
201
225
|
}
|
|
202
226
|
async getOffchainParamsByVersion(e) {
|
|
203
227
|
const t = await this.publicClient.readContract({
|
|
@@ -206,7 +230,7 @@ class lr {
|
|
|
206
230
|
functionName: "getOffchainParamsByVersion",
|
|
207
231
|
args: [e]
|
|
208
232
|
}), n = G(t);
|
|
209
|
-
return
|
|
233
|
+
return U(n), n;
|
|
210
234
|
}
|
|
211
235
|
async getLatestOffchainParamsVersion() {
|
|
212
236
|
const e = await this.publicClient.readContract({
|
|
@@ -214,11 +238,11 @@ class lr {
|
|
|
214
238
|
abi: y,
|
|
215
239
|
functionName: "latestOffchainParamsVersion"
|
|
216
240
|
}), t = Number(e);
|
|
217
|
-
return
|
|
241
|
+
return Ve(t), t;
|
|
218
242
|
}
|
|
219
243
|
async getTimelockPeginByVersion(e) {
|
|
220
244
|
const t = await this.getOffchainParamsByVersion(e);
|
|
221
|
-
return
|
|
245
|
+
return se(t.timelockAssert);
|
|
222
246
|
}
|
|
223
247
|
/**
|
|
224
248
|
* Read TBV protocol params, latest offchain params, and the latest version
|
|
@@ -252,21 +276,21 @@ class lr {
|
|
|
252
276
|
}
|
|
253
277
|
],
|
|
254
278
|
allowFailure: !1
|
|
255
|
-
}), t =
|
|
279
|
+
}), t = ne(e[0]), n = G(e[1]), i = Number(e[2]), s = Number(e[3]), a = {
|
|
256
280
|
minimumPegInAmount: t.minimumPegInAmount,
|
|
257
281
|
maxPegInAmount: t.maxPegInAmount,
|
|
258
282
|
pegInAckTimeout: t.pegInAckTimeout,
|
|
259
283
|
pegInActivationTimeout: t.pegInActivationTimeout,
|
|
260
284
|
maxHtlcOutputCount: t.maxHtlcOutputCount,
|
|
261
285
|
expiredPegInGraceBlocks: t.expiredPegInGraceBlocks,
|
|
262
|
-
timelockPegin:
|
|
286
|
+
timelockPegin: se(n.timelockAssert),
|
|
263
287
|
timelockRefund: n.tRefund,
|
|
264
288
|
minVpCommissionBps: n.minVpCommissionBps,
|
|
265
289
|
offchainParams: n,
|
|
266
290
|
offchainParamsVersion: i,
|
|
267
291
|
activeVaultCoreVersion: s
|
|
268
292
|
};
|
|
269
|
-
return
|
|
293
|
+
return Ie(a), a;
|
|
270
294
|
}
|
|
271
295
|
/**
|
|
272
296
|
* Fetch every historical offchain params version in a single multicall.
|
|
@@ -294,7 +318,7 @@ class lr {
|
|
|
294
318
|
for (let c = 0; c < n.length; c++) {
|
|
295
319
|
const d = G(s[c]);
|
|
296
320
|
try {
|
|
297
|
-
|
|
321
|
+
U(d), a.set(n[c], d);
|
|
298
322
|
} catch (l) {
|
|
299
323
|
e == null || e(
|
|
300
324
|
n[c],
|
|
@@ -311,7 +335,7 @@ function H(r) {
|
|
|
311
335
|
btcPubKey: e.btcPubKey
|
|
312
336
|
}));
|
|
313
337
|
}
|
|
314
|
-
class
|
|
338
|
+
class dr {
|
|
315
339
|
constructor(e, t) {
|
|
316
340
|
this.publicClient = e, this.contractAddress = t;
|
|
317
341
|
}
|
|
@@ -342,7 +366,7 @@ class ur {
|
|
|
342
366
|
});
|
|
343
367
|
}
|
|
344
368
|
}
|
|
345
|
-
class
|
|
369
|
+
class pr {
|
|
346
370
|
constructor(e, t) {
|
|
347
371
|
this.publicClient = e, this.contractAddress = t;
|
|
348
372
|
}
|
|
@@ -371,16 +395,16 @@ class dr {
|
|
|
371
395
|
});
|
|
372
396
|
}
|
|
373
397
|
}
|
|
374
|
-
var
|
|
375
|
-
const
|
|
398
|
+
var Me = /* @__PURE__ */ ((r) => (r[r.PENDING = 0] = "PENDING", r[r.VERIFIED = 1] = "VERIFIED", r[r.ACTIVE = 2] = "ACTIVE", r[r.REDEEMED = 3] = "REDEEMED", r[r.EXPIRED = 4] = "EXPIRED", r))(Me || {});
|
|
399
|
+
const ie = new Set(Object.values(Ne)), je = 200;
|
|
376
400
|
function h(r) {
|
|
377
401
|
var e;
|
|
378
|
-
return ((e = JSON.stringify(r)) == null ? void 0 : e.slice(0,
|
|
402
|
+
return ((e = JSON.stringify(r)) == null ? void 0 : e.slice(0, je)) ?? "undefined";
|
|
379
403
|
}
|
|
380
|
-
const
|
|
404
|
+
const He = "The vault provider returned an unexpected response. Please try again or contact support.";
|
|
381
405
|
class o extends Error {
|
|
382
406
|
constructor(t) {
|
|
383
|
-
super(
|
|
407
|
+
super(He);
|
|
384
408
|
f(this, "detail");
|
|
385
409
|
this.name = "VpResponseValidationError", this.detail = t;
|
|
386
410
|
}
|
|
@@ -389,17 +413,17 @@ const N = 64;
|
|
|
389
413
|
function T(r) {
|
|
390
414
|
return typeof r == "string" && r.length > 0 && k.test(r);
|
|
391
415
|
}
|
|
392
|
-
function
|
|
416
|
+
function me(r) {
|
|
393
417
|
return typeof r == "string" && r.length > 0;
|
|
394
418
|
}
|
|
395
|
-
function
|
|
419
|
+
function ye(r, e) {
|
|
396
420
|
if (!T(r))
|
|
397
421
|
throw new o(
|
|
398
422
|
`VP response validation failed: "${e}" must be a non-empty hex string, got ${h(r)}`
|
|
399
423
|
);
|
|
400
424
|
}
|
|
401
425
|
function w(r, e) {
|
|
402
|
-
if (!
|
|
426
|
+
if (!me(r))
|
|
403
427
|
throw new o(
|
|
404
428
|
`VP response validation failed: "${e}" must be a non-empty string, got ${h(r)}`
|
|
405
429
|
);
|
|
@@ -410,7 +434,7 @@ function Q(r, e) {
|
|
|
410
434
|
`VP response validation failed: "${e}" must be a ${O} or ${j}-char hex string (BTC pubkey), got ${h(r)}`
|
|
411
435
|
);
|
|
412
436
|
}
|
|
413
|
-
function
|
|
437
|
+
function Le(r) {
|
|
414
438
|
const e = r.presigning;
|
|
415
439
|
if (e == null) return;
|
|
416
440
|
if (typeof e != "object" || Array.isArray(e))
|
|
@@ -431,7 +455,7 @@ function He(r) {
|
|
|
431
455
|
`VP response validation failed: "progress.presigning.vk_challenger_presigning_total" must be a number if present, got ${h(t.vk_challenger_presigning_total)}`
|
|
432
456
|
);
|
|
433
457
|
}
|
|
434
|
-
function
|
|
458
|
+
function be(r) {
|
|
435
459
|
if (r === null || typeof r != "object")
|
|
436
460
|
throw new o(
|
|
437
461
|
"VP response validation failed: getPeginStatus response is not an object"
|
|
@@ -445,15 +469,15 @@ function ye(r) {
|
|
|
445
469
|
throw new o(
|
|
446
470
|
'VP response validation failed: "status" must be a string'
|
|
447
471
|
);
|
|
448
|
-
if (!
|
|
472
|
+
if (!ie.has(e.status))
|
|
449
473
|
throw new o(
|
|
450
|
-
`VP response validation failed: unrecognized status "${e.status}". Expected one of: ${[...
|
|
474
|
+
`VP response validation failed: unrecognized status "${e.status}". Expected one of: ${[...ie].join(", ")}`
|
|
451
475
|
);
|
|
452
476
|
if (e.progress === null || typeof e.progress != "object" || Array.isArray(e.progress))
|
|
453
477
|
throw new o(
|
|
454
478
|
'VP response validation failed: "progress" must be an object'
|
|
455
479
|
);
|
|
456
|
-
if (
|
|
480
|
+
if (Le(e.progress), typeof e.health_info != "string")
|
|
457
481
|
throw new o(
|
|
458
482
|
'VP response validation failed: "health_info" must be a string'
|
|
459
483
|
);
|
|
@@ -462,7 +486,7 @@ function ye(r) {
|
|
|
462
486
|
`VP response validation failed: "last_error" must be a string if present, got ${h(e.last_error)}`
|
|
463
487
|
);
|
|
464
488
|
}
|
|
465
|
-
function
|
|
489
|
+
function Ke(r) {
|
|
466
490
|
if (r === null || typeof r != "object")
|
|
467
491
|
throw new o(
|
|
468
492
|
"VP response validation failed: requestDepositorPresignTransactions response is not an object"
|
|
@@ -478,7 +502,7 @@ function Le(r) {
|
|
|
478
502
|
throw new o(
|
|
479
503
|
'VP response validation failed: "depositor_graph" must be an object'
|
|
480
504
|
);
|
|
481
|
-
|
|
505
|
+
Qe(
|
|
482
506
|
e.depositor_graph
|
|
483
507
|
);
|
|
484
508
|
}
|
|
@@ -487,7 +511,7 @@ function A(r, e) {
|
|
|
487
511
|
throw new o(
|
|
488
512
|
`VP response validation failed: "${e}" must be an object`
|
|
489
513
|
);
|
|
490
|
-
|
|
514
|
+
ye(r.tx_hex, `${e}.tx_hex`);
|
|
491
515
|
}
|
|
492
516
|
function Ue(r, e) {
|
|
493
517
|
if (r === null || typeof r != "object")
|
|
@@ -497,7 +521,7 @@ function Ue(r, e) {
|
|
|
497
521
|
const t = r;
|
|
498
522
|
Q(t.claimer_pubkey, `${e}.claimer_pubkey`), A(t.claim_tx, `${e}.claim_tx`), A(t.assert_tx, `${e}.assert_tx`), A(t.payout_tx, `${e}.payout_tx`), w(t.payout_psbt, `${e}.payout_psbt`);
|
|
499
523
|
}
|
|
500
|
-
function
|
|
524
|
+
function Xe(r, e) {
|
|
501
525
|
if (r === null || typeof r != "object")
|
|
502
526
|
throw new o(
|
|
503
527
|
`VP response validation failed: "${e}" must be an object`
|
|
@@ -505,7 +529,7 @@ function Ke(r, e) {
|
|
|
505
529
|
const t = r;
|
|
506
530
|
w(t.wots_pks_json, `${e}.wots_pks_json`), w(t.gc_wots_keys_json, `${e}.gc_wots_keys_json`);
|
|
507
531
|
}
|
|
508
|
-
function
|
|
532
|
+
function Fe(r, e) {
|
|
509
533
|
if (r === null || typeof r != "object")
|
|
510
534
|
throw new o(
|
|
511
535
|
`VP response validation failed: "${e}" must be an object`
|
|
@@ -526,7 +550,7 @@ function Xe(r, e) {
|
|
|
526
550
|
`VP response validation failed: "${e}.challenge_assert_connectors" must have exactly ${ee} entries, got ${t.challenge_assert_connectors.length}`
|
|
527
551
|
);
|
|
528
552
|
for (let n = 0; n < t.challenge_assert_connectors.length; n++)
|
|
529
|
-
|
|
553
|
+
Xe(
|
|
530
554
|
t.challenge_assert_connectors[n],
|
|
531
555
|
`${e}.challenge_assert_connectors[${n}]`
|
|
532
556
|
);
|
|
@@ -535,18 +559,18 @@ function Xe(r, e) {
|
|
|
535
559
|
`VP response validation failed: "${e}.output_label_hashes" must be an array`
|
|
536
560
|
);
|
|
537
561
|
for (let n = 0; n < t.output_label_hashes.length; n++)
|
|
538
|
-
|
|
562
|
+
ye(
|
|
539
563
|
t.output_label_hashes[n],
|
|
540
564
|
`${e}.output_label_hashes[${n}]`
|
|
541
565
|
);
|
|
542
566
|
}
|
|
543
|
-
function
|
|
567
|
+
function Je(r) {
|
|
544
568
|
if (r === null || typeof r != "object")
|
|
545
569
|
throw new o(
|
|
546
570
|
"VP response validation failed: requestDepositorClaimerArtifacts response is not an object"
|
|
547
571
|
);
|
|
548
572
|
const e = r;
|
|
549
|
-
if (!
|
|
573
|
+
if (!me(e.tx_graph_json))
|
|
550
574
|
throw new o(
|
|
551
575
|
`VP response validation failed: "tx_graph_json" must be a non-empty string, got ${h(e.tx_graph_json)}`
|
|
552
576
|
);
|
|
@@ -577,7 +601,7 @@ function Fe(r) {
|
|
|
577
601
|
);
|
|
578
602
|
}
|
|
579
603
|
}
|
|
580
|
-
function
|
|
604
|
+
function We(r) {
|
|
581
605
|
if (r === null || typeof r != "object")
|
|
582
606
|
throw new o(
|
|
583
607
|
"VP response validation failed: pegout status payload is not an object"
|
|
@@ -596,16 +620,16 @@ function Je(r) {
|
|
|
596
620
|
throw new o(
|
|
597
621
|
`VP response validation failed: "claimer" must be an object or null, got ${h(e.claimer)}`
|
|
598
622
|
);
|
|
599
|
-
|
|
623
|
+
Ye(e.claimer);
|
|
600
624
|
}
|
|
601
625
|
if (!Array.isArray(e.challengers))
|
|
602
626
|
throw new o(
|
|
603
627
|
`VP response validation failed: "challengers" must be an array, got ${h(e.challengers)}`
|
|
604
628
|
);
|
|
605
629
|
for (let t = 0; t < e.challengers.length; t++)
|
|
606
|
-
|
|
630
|
+
ze(e.challengers[t], t);
|
|
607
631
|
}
|
|
608
|
-
function
|
|
632
|
+
function Ye(r) {
|
|
609
633
|
if (w(r.status, "claimer.status"), typeof r.failed != "boolean")
|
|
610
634
|
throw new o(
|
|
611
635
|
`VP response validation failed: "claimer.failed" must be a boolean, got ${h(r.failed)}`
|
|
@@ -619,7 +643,7 @@ function We(r) {
|
|
|
619
643
|
`VP response validation failed: "claimer.updated_at" must be a number, got ${h(r.updated_at)}`
|
|
620
644
|
);
|
|
621
645
|
}
|
|
622
|
-
function
|
|
646
|
+
function ze(r, e) {
|
|
623
647
|
if (r === null || typeof r != "object")
|
|
624
648
|
throw new o(
|
|
625
649
|
`VP response validation failed: "challengers[${e}]" must be an object, got ${h(r)}`
|
|
@@ -646,17 +670,17 @@ function D(r, e) {
|
|
|
646
670
|
`VP response validation failed: "${e}" must be a string or null, got ${h(r)}`
|
|
647
671
|
);
|
|
648
672
|
}
|
|
649
|
-
function
|
|
650
|
-
|
|
651
|
-
e.result !== null &&
|
|
673
|
+
function qe(r) {
|
|
674
|
+
we(r, "batchGetPeginStatus", (e) => {
|
|
675
|
+
e.result !== null && be(e.result);
|
|
652
676
|
});
|
|
653
677
|
}
|
|
654
|
-
function
|
|
655
|
-
|
|
656
|
-
e.result !== null &&
|
|
678
|
+
function Ze(r) {
|
|
679
|
+
we(r, "batchGetPegoutStatus", (e) => {
|
|
680
|
+
e.result !== null && We(e.result);
|
|
657
681
|
});
|
|
658
682
|
}
|
|
659
|
-
function
|
|
683
|
+
function we(r, e, t) {
|
|
660
684
|
if (r === null || typeof r != "object")
|
|
661
685
|
throw new o(
|
|
662
686
|
`VP response validation failed: ${e} response is not an object`
|
|
@@ -692,13 +716,13 @@ function be(r, e, t) {
|
|
|
692
716
|
t(a, i);
|
|
693
717
|
}
|
|
694
718
|
}
|
|
695
|
-
function
|
|
719
|
+
function Qe(r) {
|
|
696
720
|
if (A(r.claim_tx, "depositor_graph.claim_tx"), A(r.assert_tx, "depositor_graph.assert_tx"), A(r.payout_tx, "depositor_graph.payout_tx"), w(r.payout_psbt, "depositor_graph.payout_psbt"), !Array.isArray(r.challenger_presign_data))
|
|
697
721
|
throw new o(
|
|
698
722
|
'VP response validation failed: "depositor_graph.challenger_presign_data" must be an array'
|
|
699
723
|
);
|
|
700
724
|
for (let e = 0; e < r.challenger_presign_data.length; e++)
|
|
701
|
-
|
|
725
|
+
Fe(
|
|
702
726
|
r.challenger_presign_data[e],
|
|
703
727
|
`depositor_graph.challenger_presign_data[${e}]`
|
|
704
728
|
);
|
|
@@ -707,13 +731,13 @@ function Ze(r) {
|
|
|
707
731
|
'VP response validation failed: "depositor_graph.offchain_params_version" must be a number'
|
|
708
732
|
);
|
|
709
733
|
}
|
|
710
|
-
const
|
|
711
|
-
class
|
|
734
|
+
const et = 6e4;
|
|
735
|
+
class tt {
|
|
712
736
|
constructor(e, t) {
|
|
713
737
|
f(this, "client");
|
|
714
738
|
const n = {
|
|
715
739
|
baseUrl: e,
|
|
716
|
-
timeout: (t == null ? void 0 : t.timeout) ??
|
|
740
|
+
timeout: (t == null ? void 0 : t.timeout) ?? et,
|
|
717
741
|
retries: t == null ? void 0 : t.retries,
|
|
718
742
|
retryDelay: t == null ? void 0 : t.retryDelay,
|
|
719
743
|
retryableFor: t == null ? void 0 : t.retryableFor,
|
|
@@ -721,7 +745,7 @@ class et {
|
|
|
721
745
|
tokenProvider: t == null ? void 0 : t.tokenProvider,
|
|
722
746
|
maxResponseBytes: t == null ? void 0 : t.maxResponseBytes
|
|
723
747
|
};
|
|
724
|
-
this.client = new
|
|
748
|
+
this.client = new _e(n);
|
|
725
749
|
}
|
|
726
750
|
/**
|
|
727
751
|
* Request the payout/claim/assert transactions that the depositor
|
|
@@ -729,7 +753,7 @@ class et {
|
|
|
729
753
|
*/
|
|
730
754
|
async requestDepositorPresignTransactions(e, t) {
|
|
731
755
|
const n = await this.client.call("vaultProvider_requestDepositorPresignTransactions", e, t);
|
|
732
|
-
return
|
|
756
|
+
return Ke(n), n;
|
|
733
757
|
}
|
|
734
758
|
/**
|
|
735
759
|
* Submit the depositor's pre-signatures for the payout transactions
|
|
@@ -760,7 +784,7 @@ class et {
|
|
|
760
784
|
*/
|
|
761
785
|
async requestDepositorClaimerArtifacts(e, t) {
|
|
762
786
|
const n = await this.client.call("vaultProvider_requestDepositorClaimerArtifacts", e, t);
|
|
763
|
-
return
|
|
787
|
+
return Je(n), n;
|
|
764
788
|
}
|
|
765
789
|
/** Get the current pegin status from the vault provider daemon. */
|
|
766
790
|
async getPeginStatus(e, t) {
|
|
@@ -769,7 +793,7 @@ class et {
|
|
|
769
793
|
e,
|
|
770
794
|
t
|
|
771
795
|
);
|
|
772
|
-
return
|
|
796
|
+
return be(n), n;
|
|
773
797
|
}
|
|
774
798
|
/**
|
|
775
799
|
* Get pegin status for many txids in one round trip. Per-result envelope
|
|
@@ -778,7 +802,7 @@ class et {
|
|
|
778
802
|
*/
|
|
779
803
|
async batchGetPeginStatus(e, t) {
|
|
780
804
|
const n = await this.client.call("vaultProvider_batchGetPeginStatus", e, t);
|
|
781
|
-
return
|
|
805
|
+
return qe(n), n;
|
|
782
806
|
}
|
|
783
807
|
/**
|
|
784
808
|
* Get pegout status for many txids in one round trip. Same per-result
|
|
@@ -786,23 +810,23 @@ class et {
|
|
|
786
810
|
*/
|
|
787
811
|
async batchGetPegoutStatus(e, t) {
|
|
788
812
|
const n = await this.client.call("vaultProvider_batchGetPegoutStatus", e, t);
|
|
789
|
-
return
|
|
813
|
+
return Ze(n), n;
|
|
790
814
|
}
|
|
791
815
|
}
|
|
792
|
-
const
|
|
793
|
-
function
|
|
816
|
+
const rt = "BIP0322-signed-message", nt = "TapTweak", xe = 32, st = 64;
|
|
817
|
+
function Pe(r, e) {
|
|
794
818
|
const t = new TextEncoder().encode(r), n = Y(t), i = new Uint8Array(n.length * 2 + e.length);
|
|
795
819
|
return i.set(n, 0), i.set(n, n.length), i.set(e, n.length * 2), Y(i);
|
|
796
820
|
}
|
|
797
|
-
function
|
|
798
|
-
if (r.length !==
|
|
799
|
-
const e =
|
|
821
|
+
function it(r) {
|
|
822
|
+
if (r.length !== xe) return null;
|
|
823
|
+
const e = Pe(nt, r), t = K.xOnlyPointAddTweak(r, e);
|
|
800
824
|
return t ? t.xOnlyPubkey : null;
|
|
801
825
|
}
|
|
802
|
-
function
|
|
803
|
-
if (e.length !==
|
|
826
|
+
function at(r, e, t) {
|
|
827
|
+
if (e.length !== xe || t.length !== st) return !1;
|
|
804
828
|
try {
|
|
805
|
-
const n =
|
|
829
|
+
const n = Pe(rt, r), i = Ge.p2tr({
|
|
806
830
|
internalPubkey: V.from(e)
|
|
807
831
|
});
|
|
808
832
|
if (!i.output) return !1;
|
|
@@ -830,8 +854,8 @@ function it(r, e, t) {
|
|
|
830
854
|
[s],
|
|
831
855
|
[a],
|
|
832
856
|
X.SIGHASH_DEFAULT
|
|
833
|
-
), x =
|
|
834
|
-
return x ?
|
|
857
|
+
), x = it(e);
|
|
858
|
+
return x ? K.verifySchnorr(m, x, t) : !1;
|
|
835
859
|
} catch {
|
|
836
860
|
return !1;
|
|
837
861
|
}
|
|
@@ -861,30 +885,30 @@ function L(r, e) {
|
|
|
861
885
|
i[1 + s] = Number(n >> BigInt((7 - s) * 8)) & 255;
|
|
862
886
|
return i;
|
|
863
887
|
}
|
|
864
|
-
function
|
|
888
|
+
function ve(...r) {
|
|
865
889
|
const e = r.reduce((i, s) => i + s.length, 0), t = new Uint8Array(e);
|
|
866
890
|
let n = 0;
|
|
867
891
|
for (const i of r)
|
|
868
892
|
t.set(i, n), n += i.length;
|
|
869
893
|
return t;
|
|
870
894
|
}
|
|
871
|
-
function
|
|
895
|
+
function ae(r) {
|
|
872
896
|
const t = [L(4, r.length)];
|
|
873
897
|
for (const n of r)
|
|
874
898
|
t.push(L(0, n));
|
|
875
|
-
return
|
|
899
|
+
return ve(...t);
|
|
876
900
|
}
|
|
877
|
-
function
|
|
901
|
+
function ot(r, e, t) {
|
|
878
902
|
if (!Number.isSafeInteger(t) || t < 0)
|
|
879
903
|
throw new Error(
|
|
880
904
|
`encodeServerIdentityPayload: expires_at must be a non-negative safe integer, got ${t}`
|
|
881
905
|
);
|
|
882
|
-
const n = L(4, 3), i =
|
|
883
|
-
return
|
|
906
|
+
const n = L(4, 3), i = ae(r), s = ae(e), a = L(0, t);
|
|
907
|
+
return ve(n, i, s, a);
|
|
884
908
|
}
|
|
885
|
-
const
|
|
909
|
+
const ct = new TextEncoder().encode(
|
|
886
910
|
"btc-auth.server-identity.v1"
|
|
887
|
-
),
|
|
911
|
+
), lt = 2 * 3600;
|
|
888
912
|
class b extends Error {
|
|
889
913
|
constructor(e, t) {
|
|
890
914
|
super(e), this.reason = t, this.name = "ServerIdentityError";
|
|
@@ -896,8 +920,8 @@ function M(r) {
|
|
|
896
920
|
e[t] = parseInt(r.slice(t * 2, t * 2 + 2), 16);
|
|
897
921
|
return e;
|
|
898
922
|
}
|
|
899
|
-
function
|
|
900
|
-
const { proof: e, pinnedServerPubkey: t, now: n } = r, i = r.maxLifetimeSecs ??
|
|
923
|
+
function ut(r) {
|
|
924
|
+
const { proof: e, pinnedServerPubkey: t, now: n } = r, i = r.maxLifetimeSecs ?? lt, s = I(t).toLowerCase();
|
|
901
925
|
if (s.length !== O || !k.test(s))
|
|
902
926
|
throw new b(
|
|
903
927
|
`pinnedServerPubkey must be 32-byte hex; got ${s.length} chars`,
|
|
@@ -952,50 +976,50 @@ function lt(r) {
|
|
|
952
976
|
"invalid_ephemeral_pubkey"
|
|
953
977
|
);
|
|
954
978
|
const l = M(c);
|
|
955
|
-
if (!
|
|
979
|
+
if (!K.isPoint(l))
|
|
956
980
|
throw new b(
|
|
957
981
|
"ephemeral_pubkey is not a valid secp256k1 point",
|
|
958
982
|
"invalid_ephemeral_pubkey"
|
|
959
983
|
);
|
|
960
984
|
const g = I(e.signature).toLowerCase();
|
|
961
|
-
if (g.length !==
|
|
985
|
+
if (g.length !== Re || !k.test(g))
|
|
962
986
|
throw new b(
|
|
963
987
|
`signature must be 64-byte Schnorr hex; got ${g.length} chars`,
|
|
964
988
|
"invalid_signature_encoding"
|
|
965
989
|
);
|
|
966
|
-
const m =
|
|
967
|
-
|
|
990
|
+
const m = ot(
|
|
991
|
+
ct,
|
|
968
992
|
M(c),
|
|
969
993
|
e.expires_at
|
|
970
994
|
);
|
|
971
|
-
if (!
|
|
995
|
+
if (!at(m, M(a), M(g)))
|
|
972
996
|
throw new b(
|
|
973
997
|
"BIP-322 signature verification failed — ephemeral key is not attested by pinned server pubkey",
|
|
974
998
|
"signature_verification_failed"
|
|
975
999
|
);
|
|
976
1000
|
}
|
|
977
|
-
const
|
|
1001
|
+
const dt = /* @__PURE__ */ new Set([
|
|
978
1002
|
"vaultProvider_submitDepositorWotsKey",
|
|
979
1003
|
"vaultProvider_submitDepositorPresignatures",
|
|
980
1004
|
"vaultProvider_requestDepositorPresignTransactions"
|
|
981
|
-
]),
|
|
1005
|
+
]), pt = /* @__PURE__ */ new Set([
|
|
982
1006
|
"vaultProvider_requestDepositorClaimerArtifacts"
|
|
983
|
-
]),
|
|
984
|
-
function
|
|
985
|
-
return new
|
|
1007
|
+
]), ht = 6e4, z = "auth_createDepositorToken", q = "auth_createDepositorTokenGrpc";
|
|
1008
|
+
function Ae(r, e) {
|
|
1009
|
+
return new _e({
|
|
986
1010
|
baseUrl: r,
|
|
987
|
-
timeout:
|
|
1011
|
+
timeout: ht,
|
|
988
1012
|
headers: e,
|
|
989
1013
|
retryableFor: (t) => t === z || t === q
|
|
990
1014
|
});
|
|
991
1015
|
}
|
|
992
|
-
const
|
|
1016
|
+
const gt = 0, ft = 1, F = 2, _t = 3, mt = 4, yt = 5, bt = 6, wt = 7, oe = 24, xt = 28, Pt = 20, vt = 21, At = 22, ce = 256;
|
|
993
1017
|
class v extends Error {
|
|
994
1018
|
constructor(e) {
|
|
995
1019
|
super(`CBOR decode: ${e}`), this.name = "CborDecodeError";
|
|
996
1020
|
}
|
|
997
1021
|
}
|
|
998
|
-
class
|
|
1022
|
+
class Ee {
|
|
999
1023
|
constructor(e) {
|
|
1000
1024
|
f(this, "buf");
|
|
1001
1025
|
/** Current read offset. Public so callers can slice encoded sub-ranges. */
|
|
@@ -1015,13 +1039,13 @@ class Ae {
|
|
|
1015
1039
|
*/
|
|
1016
1040
|
readHead() {
|
|
1017
1041
|
const e = this.nextByte(), t = e >> 5, n = e & 31;
|
|
1018
|
-
if (n <
|
|
1042
|
+
if (n < oe)
|
|
1019
1043
|
return { major: t, arg: n };
|
|
1020
|
-
if (n >=
|
|
1044
|
+
if (n >= xt)
|
|
1021
1045
|
throw new v(
|
|
1022
1046
|
`unsupported additional info ${n} (indefinite-length or reserved)`
|
|
1023
1047
|
);
|
|
1024
|
-
const i = 1 << n -
|
|
1048
|
+
const i = 1 << n - oe;
|
|
1025
1049
|
let s = 0n;
|
|
1026
1050
|
for (let a = 0; a < i; a++)
|
|
1027
1051
|
s = s << 8n | BigInt(this.nextByte());
|
|
@@ -1056,29 +1080,29 @@ class Ae {
|
|
|
1056
1080
|
* native call stack (see {@link MAX_NESTING_DEPTH}).
|
|
1057
1081
|
*/
|
|
1058
1082
|
readValue(e = 0) {
|
|
1059
|
-
if (e >
|
|
1083
|
+
if (e > ce)
|
|
1060
1084
|
throw new v(
|
|
1061
|
-
`nesting exceeds maximum depth ${
|
|
1085
|
+
`nesting exceeds maximum depth ${ce}`
|
|
1062
1086
|
);
|
|
1063
1087
|
const t = this.readHead();
|
|
1064
1088
|
switch (t.major) {
|
|
1065
|
-
case ht:
|
|
1066
|
-
return t.arg;
|
|
1067
1089
|
case gt:
|
|
1090
|
+
return t.arg;
|
|
1091
|
+
case ft:
|
|
1068
1092
|
return -1 - t.arg;
|
|
1069
1093
|
case F:
|
|
1070
1094
|
return this.readBytes(t.arg);
|
|
1071
|
-
case
|
|
1095
|
+
case _t:
|
|
1072
1096
|
return new TextDecoder("utf-8", { fatal: !0 }).decode(
|
|
1073
1097
|
this.readBytes(t.arg)
|
|
1074
1098
|
);
|
|
1075
|
-
case
|
|
1099
|
+
case mt: {
|
|
1076
1100
|
const n = [];
|
|
1077
1101
|
for (let i = 0; i < t.arg; i++)
|
|
1078
1102
|
n.push(this.readValue(e + 1));
|
|
1079
1103
|
return n;
|
|
1080
1104
|
}
|
|
1081
|
-
case
|
|
1105
|
+
case yt: {
|
|
1082
1106
|
const n = /* @__PURE__ */ new Map();
|
|
1083
1107
|
for (let i = 0; i < t.arg; i++) {
|
|
1084
1108
|
const s = this.readValue(e + 1), a = this.readValue(e + 1);
|
|
@@ -1086,12 +1110,12 @@ class Ae {
|
|
|
1086
1110
|
}
|
|
1087
1111
|
return n;
|
|
1088
1112
|
}
|
|
1089
|
-
case yt:
|
|
1090
|
-
return { tag: t.arg, value: this.readValue(e + 1) };
|
|
1091
1113
|
case bt:
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
if (t.arg ===
|
|
1114
|
+
return { tag: t.arg, value: this.readValue(e + 1) };
|
|
1115
|
+
case wt:
|
|
1116
|
+
if (t.arg === Pt) return !1;
|
|
1117
|
+
if (t.arg === vt) return !0;
|
|
1118
|
+
if (t.arg === At) return null;
|
|
1095
1119
|
throw new v(
|
|
1096
1120
|
`unsupported simple/float value ${t.arg}`
|
|
1097
1121
|
);
|
|
@@ -1100,29 +1124,29 @@ class Ae {
|
|
|
1100
1124
|
}
|
|
1101
1125
|
}
|
|
1102
1126
|
}
|
|
1103
|
-
function
|
|
1104
|
-
const e = new
|
|
1127
|
+
function Se(r) {
|
|
1128
|
+
const e = new Ee(r), t = e.readValue();
|
|
1105
1129
|
if (e.pos !== r.length)
|
|
1106
1130
|
throw new v("trailing bytes after top-level item");
|
|
1107
1131
|
return t;
|
|
1108
1132
|
}
|
|
1109
|
-
const
|
|
1133
|
+
const Et = "vaultd-jsonrpc", St = "vaultd-grpc", le = 18, Z = 4, ue = -47, kt = 1, de = 64, Ct = 128, Tt = 96, $t = 64, Vt = 1, It = 2, Rt = 3, Ot = 4, Nt = 5, Bt = 6, Gt = 7, pe = new TextEncoder().encode("Signature1");
|
|
1110
1134
|
class p extends Error {
|
|
1111
1135
|
constructor(e, t) {
|
|
1112
1136
|
super(e), this.reason = t, this.name = "CwtVerificationError";
|
|
1113
1137
|
}
|
|
1114
1138
|
}
|
|
1115
|
-
function
|
|
1116
|
-
const e =
|
|
1139
|
+
function Dt(r) {
|
|
1140
|
+
const e = he(
|
|
1117
1141
|
r.expectedIssuerXOnlyPubkey,
|
|
1118
1142
|
"expectedIssuerXOnlyPubkey"
|
|
1119
|
-
), t =
|
|
1143
|
+
), t = he(
|
|
1120
1144
|
r.expectedAudienceXOnlyPubkey,
|
|
1121
1145
|
"expectedAudienceXOnlyPubkey"
|
|
1122
|
-
), n =
|
|
1123
|
-
if (a.major !== 6 || a.arg !==
|
|
1146
|
+
), n = Kt(r.ephemeralPubkeyHex), i = Xt(r.token), s = new Ee(i), a = s.readHead();
|
|
1147
|
+
if (a.major !== 6 || a.arg !== le)
|
|
1124
1148
|
throw new p(
|
|
1125
|
-
`token is not a COSE Sign1 tagged value (tag ${
|
|
1149
|
+
`token is not a COSE Sign1 tagged value (tag ${le})`,
|
|
1126
1150
|
"invalid_token_structure"
|
|
1127
1151
|
);
|
|
1128
1152
|
const c = s.readHead();
|
|
@@ -1134,9 +1158,9 @@ function Gt(r) {
|
|
|
1134
1158
|
const d = s.pos, l = s.readByteString(), g = i.subarray(d, s.pos);
|
|
1135
1159
|
s.readValue();
|
|
1136
1160
|
const m = s.pos, x = s.readByteString(), E = i.subarray(m, s.pos), C = s.readByteString();
|
|
1137
|
-
if (C.length !==
|
|
1161
|
+
if (C.length !== de)
|
|
1138
1162
|
throw new p(
|
|
1139
|
-
`COSE signature must be ${
|
|
1163
|
+
`COSE signature must be ${de} bytes, got ${C.length}`,
|
|
1140
1164
|
"invalid_token_structure"
|
|
1141
1165
|
);
|
|
1142
1166
|
if (s.pos !== i.length)
|
|
@@ -1144,19 +1168,19 @@ function Gt(r) {
|
|
|
1144
1168
|
"COSE Sign1 token has trailing bytes after the signature",
|
|
1145
1169
|
"invalid_token_structure"
|
|
1146
1170
|
);
|
|
1147
|
-
const P =
|
|
1148
|
-
if (P !==
|
|
1171
|
+
const P = Mt(l);
|
|
1172
|
+
if (P !== ue)
|
|
1149
1173
|
throw new p(
|
|
1150
|
-
`unexpected COSE algorithm ${P} (expected ES256K ${
|
|
1174
|
+
`unexpected COSE algorithm ${P} (expected ES256K ${ue})`,
|
|
1151
1175
|
"unexpected_algorithm"
|
|
1152
1176
|
);
|
|
1153
|
-
const $ =
|
|
1154
|
-
if (!
|
|
1177
|
+
const $ = jt(g, E), _ = Y($);
|
|
1178
|
+
if (!K.verify(_, n, C, !0))
|
|
1155
1179
|
throw new p(
|
|
1156
1180
|
"COSE signature does not verify against the server's ephemeral key",
|
|
1157
1181
|
"signature_verification_failed"
|
|
1158
1182
|
);
|
|
1159
|
-
const u =
|
|
1183
|
+
const u = Ht(x), S = u.audience.toLowerCase();
|
|
1160
1184
|
if (S.length !== O || !k.test(S))
|
|
1161
1185
|
throw new p(
|
|
1162
1186
|
"token `aud` is not a 32-byte x-only pubkey hex",
|
|
@@ -1206,19 +1230,19 @@ function Gt(r) {
|
|
|
1206
1230
|
issuedAt: u.issuedAt
|
|
1207
1231
|
};
|
|
1208
1232
|
}
|
|
1209
|
-
function
|
|
1233
|
+
function Mt(r) {
|
|
1210
1234
|
if (r.length === 0)
|
|
1211
1235
|
throw new p(
|
|
1212
1236
|
"empty COSE protected header (no algorithm)",
|
|
1213
1237
|
"unexpected_algorithm"
|
|
1214
1238
|
);
|
|
1215
|
-
const e =
|
|
1239
|
+
const e = Se(r);
|
|
1216
1240
|
if (!(e instanceof Map))
|
|
1217
1241
|
throw new p(
|
|
1218
1242
|
"COSE protected header is not a map",
|
|
1219
1243
|
"invalid_token_structure"
|
|
1220
1244
|
);
|
|
1221
|
-
const t = e.get(
|
|
1245
|
+
const t = e.get(kt);
|
|
1222
1246
|
if (typeof t != "number")
|
|
1223
1247
|
throw new p(
|
|
1224
1248
|
"COSE protected header missing integer algorithm label",
|
|
@@ -1226,32 +1250,32 @@ function Dt(r) {
|
|
|
1226
1250
|
);
|
|
1227
1251
|
return t;
|
|
1228
1252
|
}
|
|
1229
|
-
function
|
|
1230
|
-
return
|
|
1231
|
-
Uint8Array.of(
|
|
1232
|
-
Uint8Array.of(
|
|
1233
|
-
|
|
1253
|
+
function jt(r, e) {
|
|
1254
|
+
return Ft(
|
|
1255
|
+
Uint8Array.of(Ct | Z),
|
|
1256
|
+
Uint8Array.of(Tt | pe.length),
|
|
1257
|
+
pe,
|
|
1234
1258
|
r,
|
|
1235
|
-
Uint8Array.of(
|
|
1259
|
+
Uint8Array.of($t),
|
|
1236
1260
|
e
|
|
1237
1261
|
);
|
|
1238
1262
|
}
|
|
1239
|
-
function
|
|
1240
|
-
const e =
|
|
1263
|
+
function Ht(r) {
|
|
1264
|
+
const e = Se(r);
|
|
1241
1265
|
if (!(e instanceof Map))
|
|
1242
1266
|
throw new p(
|
|
1243
1267
|
"CWT claims root is not a map",
|
|
1244
1268
|
"invalid_claims"
|
|
1245
1269
|
);
|
|
1246
|
-
if (
|
|
1270
|
+
if (Lt(e, Gt, "cti").length === 0)
|
|
1247
1271
|
throw new p("token cti is empty", "invalid_claims");
|
|
1248
1272
|
return {
|
|
1249
|
-
issuer: J(e,
|
|
1250
|
-
subject: J(e,
|
|
1251
|
-
audience: J(e,
|
|
1252
|
-
expiresAt: W(e,
|
|
1253
|
-
notBefore: W(e,
|
|
1254
|
-
issuedAt: W(e,
|
|
1273
|
+
issuer: J(e, Vt, "iss"),
|
|
1274
|
+
subject: J(e, It, "sub"),
|
|
1275
|
+
audience: J(e, Rt, "aud"),
|
|
1276
|
+
expiresAt: W(e, Ot, "exp"),
|
|
1277
|
+
notBefore: W(e, Nt, "nbf"),
|
|
1278
|
+
issuedAt: W(e, Bt, "iat")
|
|
1255
1279
|
};
|
|
1256
1280
|
}
|
|
1257
1281
|
function J(r, e, t) {
|
|
@@ -1263,7 +1287,7 @@ function J(r, e, t) {
|
|
|
1263
1287
|
);
|
|
1264
1288
|
return n;
|
|
1265
1289
|
}
|
|
1266
|
-
function
|
|
1290
|
+
function Lt(r, e, t) {
|
|
1267
1291
|
const n = r.get(e);
|
|
1268
1292
|
if (!(n instanceof Uint8Array))
|
|
1269
1293
|
throw new p(
|
|
@@ -1281,7 +1305,7 @@ function W(r, e, t) {
|
|
|
1281
1305
|
);
|
|
1282
1306
|
return n;
|
|
1283
1307
|
}
|
|
1284
|
-
function
|
|
1308
|
+
function he(r, e) {
|
|
1285
1309
|
const t = I(r).toLowerCase();
|
|
1286
1310
|
if (t.length !== O || !k.test(t))
|
|
1287
1311
|
throw new p(
|
|
@@ -1290,14 +1314,14 @@ function pe(r, e) {
|
|
|
1290
1314
|
);
|
|
1291
1315
|
return t;
|
|
1292
1316
|
}
|
|
1293
|
-
function
|
|
1317
|
+
function Kt(r) {
|
|
1294
1318
|
const e = I(r).toLowerCase(), t = e.slice(0, 2);
|
|
1295
1319
|
if (e.length !== j || !k.test(e) || t !== "02" && t !== "03")
|
|
1296
1320
|
throw new p(
|
|
1297
1321
|
"ephemeralPubkeyHex must be 33-byte compressed pubkey hex (prefix 02/03)",
|
|
1298
1322
|
"invalid_input"
|
|
1299
1323
|
);
|
|
1300
|
-
return
|
|
1324
|
+
return Oe(e);
|
|
1301
1325
|
}
|
|
1302
1326
|
const Ut = (() => {
|
|
1303
1327
|
const r = new Int16Array(128).fill(-1), e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
@@ -1305,7 +1329,7 @@ const Ut = (() => {
|
|
|
1305
1329
|
r[e.charCodeAt(t)] = t;
|
|
1306
1330
|
return r;
|
|
1307
1331
|
})();
|
|
1308
|
-
function
|
|
1332
|
+
function Xt(r) {
|
|
1309
1333
|
const e = r.length, t = Math.floor(e / 4), n = e % 4;
|
|
1310
1334
|
if (n === 1)
|
|
1311
1335
|
throw new p(
|
|
@@ -1335,15 +1359,15 @@ function Kt(r) {
|
|
|
1335
1359
|
}
|
|
1336
1360
|
return s;
|
|
1337
1361
|
}
|
|
1338
|
-
function
|
|
1362
|
+
function Ft(...r) {
|
|
1339
1363
|
const e = r.reduce((i, s) => i + s.length, 0), t = new Uint8Array(e);
|
|
1340
1364
|
let n = 0;
|
|
1341
1365
|
for (const i of r)
|
|
1342
1366
|
t.set(i, n), n += i.length;
|
|
1343
1367
|
return t;
|
|
1344
1368
|
}
|
|
1345
|
-
const
|
|
1346
|
-
class
|
|
1369
|
+
const ge = 4102444800, Jt = 30;
|
|
1370
|
+
class Wt {
|
|
1347
1371
|
constructor(e) {
|
|
1348
1372
|
// `client` is the only mutable field — see `setClient`. The
|
|
1349
1373
|
// identity-bearing fields (peginTxid/authAnchorHex/pinnedServerPubkey)
|
|
@@ -1364,7 +1388,7 @@ class Jt {
|
|
|
1364
1388
|
/** Cached gRPC-subject bearer (auth_createDepositorTokenGrpc). */
|
|
1365
1389
|
f(this, "cachedGrpc", null);
|
|
1366
1390
|
f(this, "inFlightGrpc", null);
|
|
1367
|
-
this.client = e.client, this.peginTxid = e.peginTxid, this.authAnchorHex = e.authAnchorHex, this.pinnedServerPubkey = e.pinnedServerPubkey, this.expectedAudienceXOnlyPubkey = e.expectedAudienceXOnlyPubkey, this.authGatedMethods = e.authGatedMethods, this.grpcGatedMethods = e.grpcGatedMethods, this.refreshSkewSecs = e.refreshSkewSecs ??
|
|
1391
|
+
this.client = e.client, this.peginTxid = e.peginTxid, this.authAnchorHex = e.authAnchorHex, this.pinnedServerPubkey = e.pinnedServerPubkey, this.expectedAudienceXOnlyPubkey = e.expectedAudienceXOnlyPubkey, this.authGatedMethods = e.authGatedMethods, this.grpcGatedMethods = e.grpcGatedMethods, this.refreshSkewSecs = e.refreshSkewSecs ?? Jt, this.now = e.now ?? (() => Math.floor(Date.now() / 1e3));
|
|
1368
1392
|
}
|
|
1369
1393
|
/**
|
|
1370
1394
|
* Return a bearer token for `method`, or `null` if `method` is not
|
|
@@ -1423,7 +1447,7 @@ class Jt {
|
|
|
1423
1447
|
pegin_txid: this.peginTxid,
|
|
1424
1448
|
auth_anchor: this.authAnchorHex
|
|
1425
1449
|
});
|
|
1426
|
-
if (
|
|
1450
|
+
if (ut({
|
|
1427
1451
|
proof: s.server_identity,
|
|
1428
1452
|
pinnedServerPubkey: this.pinnedServerPubkey,
|
|
1429
1453
|
now: this.now()
|
|
@@ -1432,15 +1456,15 @@ class Jt {
|
|
|
1432
1456
|
`VpTokenProvider: invalid token in acquire response (expected non-empty string, got ${typeof s.token})`
|
|
1433
1457
|
);
|
|
1434
1458
|
const a = this.now();
|
|
1435
|
-
if (!Number.isSafeInteger(s.expires_at) || s.expires_at <= a || s.expires_at >
|
|
1459
|
+
if (!Number.isSafeInteger(s.expires_at) || s.expires_at <= a || s.expires_at > ge)
|
|
1436
1460
|
throw new Error(
|
|
1437
|
-
`VpTokenProvider: invalid expires_at in acquire response (got ${JSON.stringify(s.expires_at)}; must be a safe integer in (${a}, ${
|
|
1461
|
+
`VpTokenProvider: invalid expires_at in acquire response (got ${JSON.stringify(s.expires_at)}; must be a safe integer in (${a}, ${ge}])`
|
|
1438
1462
|
);
|
|
1439
|
-
|
|
1463
|
+
Dt({
|
|
1440
1464
|
token: s.token,
|
|
1441
1465
|
ephemeralPubkeyHex: s.server_identity.ephemeral_pubkey,
|
|
1442
1466
|
expectedIssuerXOnlyPubkey: this.pinnedServerPubkey,
|
|
1443
|
-
expectedSubject: e === "grpc" ?
|
|
1467
|
+
expectedSubject: e === "grpc" ? St : Et,
|
|
1444
1468
|
expectedAudienceXOnlyPubkey: this.expectedAudienceXOnlyPubkey,
|
|
1445
1469
|
responseExpiresAt: s.expires_at,
|
|
1446
1470
|
serverIdentityExpiresAt: s.server_identity.expires_at,
|
|
@@ -1458,7 +1482,7 @@ class Jt {
|
|
|
1458
1482
|
return e === "grpc" ? this.inFlightGrpc = i : this.inFlightJsonRpc = i, i;
|
|
1459
1483
|
}
|
|
1460
1484
|
}
|
|
1461
|
-
class
|
|
1485
|
+
class Yt {
|
|
1462
1486
|
constructor() {
|
|
1463
1487
|
f(this, "entries", /* @__PURE__ */ new Map());
|
|
1464
1488
|
}
|
|
@@ -1485,14 +1509,14 @@ class Wt {
|
|
|
1485
1509
|
);
|
|
1486
1510
|
return t.provider.setClient(e.client), t.provider;
|
|
1487
1511
|
}
|
|
1488
|
-
const n = new
|
|
1512
|
+
const n = new Wt({
|
|
1489
1513
|
client: e.client,
|
|
1490
1514
|
peginTxid: e.peginTxid,
|
|
1491
1515
|
authAnchorHex: e.authAnchorHex,
|
|
1492
1516
|
pinnedServerPubkey: e.pinnedServerPubkey,
|
|
1493
1517
|
expectedAudienceXOnlyPubkey: e.expectedAudienceXOnlyPubkey,
|
|
1494
|
-
authGatedMethods:
|
|
1495
|
-
grpcGatedMethods:
|
|
1518
|
+
authGatedMethods: dt,
|
|
1519
|
+
grpcGatedMethods: pt
|
|
1496
1520
|
});
|
|
1497
1521
|
return this.entries.set(e.peginTxid, {
|
|
1498
1522
|
provider: n,
|
|
@@ -1527,38 +1551,38 @@ class Wt {
|
|
|
1527
1551
|
return this.entries.size;
|
|
1528
1552
|
}
|
|
1529
1553
|
}
|
|
1530
|
-
const
|
|
1531
|
-
function
|
|
1554
|
+
const ke = new Yt();
|
|
1555
|
+
function hr(r) {
|
|
1532
1556
|
var n;
|
|
1533
|
-
const e =
|
|
1557
|
+
const e = Ae(
|
|
1534
1558
|
r.baseUrl,
|
|
1535
1559
|
(n = r.options) == null ? void 0 : n.headers
|
|
1536
|
-
), t =
|
|
1560
|
+
), t = ke.getOrCreate({
|
|
1537
1561
|
client: e,
|
|
1538
1562
|
peginTxid: r.peginTxid,
|
|
1539
1563
|
authAnchorHex: r.authAnchorHex,
|
|
1540
1564
|
pinnedServerPubkey: r.pinnedServerPubkey,
|
|
1541
|
-
expectedAudienceXOnlyPubkey:
|
|
1565
|
+
expectedAudienceXOnlyPubkey: fe(
|
|
1542
1566
|
r.depositorBtcPubkey
|
|
1543
1567
|
)
|
|
1544
1568
|
});
|
|
1545
|
-
return new
|
|
1569
|
+
return new tt(r.baseUrl, {
|
|
1546
1570
|
...r.options,
|
|
1547
1571
|
tokenProvider: t
|
|
1548
1572
|
});
|
|
1549
1573
|
}
|
|
1550
|
-
function
|
|
1551
|
-
|
|
1552
|
-
client:
|
|
1574
|
+
function gr(r) {
|
|
1575
|
+
ke.getOrCreate({
|
|
1576
|
+
client: Ae(r.baseUrl, r.headers),
|
|
1553
1577
|
peginTxid: r.peginTxid,
|
|
1554
1578
|
authAnchorHex: r.authAnchorHex,
|
|
1555
1579
|
pinnedServerPubkey: r.pinnedServerPubkey,
|
|
1556
|
-
expectedAudienceXOnlyPubkey:
|
|
1580
|
+
expectedAudienceXOnlyPubkey: fe(
|
|
1557
1581
|
r.depositorBtcPubkey
|
|
1558
1582
|
)
|
|
1559
1583
|
});
|
|
1560
1584
|
}
|
|
1561
|
-
function
|
|
1585
|
+
function zt(r, e) {
|
|
1562
1586
|
const t = /* @__PURE__ */ new Set();
|
|
1563
1587
|
for (const d of r)
|
|
1564
1588
|
t.add(d.toLowerCase());
|
|
@@ -1580,7 +1604,7 @@ function Yt(r, e) {
|
|
|
1580
1604
|
i.has(d) || c.push(d);
|
|
1581
1605
|
return { byTxid: n, missing: c, unexpected: a, duplicate: s };
|
|
1582
1606
|
}
|
|
1583
|
-
async function
|
|
1607
|
+
async function fr(r) {
|
|
1584
1608
|
const {
|
|
1585
1609
|
items: e,
|
|
1586
1610
|
getTxid: t,
|
|
@@ -1591,7 +1615,7 @@ async function gr(r) {
|
|
|
1591
1615
|
onDuplicateBatch: c,
|
|
1592
1616
|
onWholeBatchError: d,
|
|
1593
1617
|
onUnexpected: l,
|
|
1594
|
-
batchSize: g =
|
|
1618
|
+
batchSize: g = Be
|
|
1595
1619
|
} = r;
|
|
1596
1620
|
if (!Number.isInteger(g) || g <= 0)
|
|
1597
1621
|
throw new Error(
|
|
@@ -1606,7 +1630,7 @@ async function gr(r) {
|
|
|
1606
1630
|
let P;
|
|
1607
1631
|
try {
|
|
1608
1632
|
const _ = await n(C);
|
|
1609
|
-
P =
|
|
1633
|
+
P = zt(C, _.results);
|
|
1610
1634
|
} catch (_) {
|
|
1611
1635
|
d(x, _);
|
|
1612
1636
|
continue;
|
|
@@ -1634,21 +1658,21 @@ async function gr(r) {
|
|
|
1634
1658
|
}
|
|
1635
1659
|
}
|
|
1636
1660
|
export {
|
|
1637
|
-
|
|
1661
|
+
Me as O,
|
|
1638
1662
|
b as S,
|
|
1639
|
-
|
|
1663
|
+
tt as V,
|
|
1640
1664
|
o as a,
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1665
|
+
fr as b,
|
|
1666
|
+
ut as c,
|
|
1667
|
+
Yt as d,
|
|
1668
|
+
ke as e,
|
|
1669
|
+
hr as f,
|
|
1670
|
+
lr as g,
|
|
1671
|
+
ur as h,
|
|
1672
|
+
pr as i,
|
|
1673
|
+
dr as j,
|
|
1674
|
+
gr as p,
|
|
1675
|
+
cr as r,
|
|
1676
|
+
Je as v
|
|
1653
1677
|
};
|
|
1654
|
-
//# sourceMappingURL=batchPoll-
|
|
1678
|
+
//# sourceMappingURL=batchPoll-BotUFjtF.js.map
|