@babylonlabs-io/ts-sdk 0.33.5 → 0.33.7
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/{buildAndBroadcastRefund-CPjXNaMi.js → buildAndBroadcastRefund-B6fGRmvo.js} +221 -218
- package/dist/buildAndBroadcastRefund-B6fGRmvo.js.map +1 -0
- package/dist/buildAndBroadcastRefund-C7hnNWbj.cjs +2 -0
- package/dist/buildAndBroadcastRefund-C7hnNWbj.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/tbv/core/clients/index.cjs +1 -1
- package/dist/tbv/core/clients/index.js +1 -1
- package/dist/tbv/core/clients/vault-provider/auth/serverIdentity.d.ts +12 -3
- package/dist/tbv/core/clients/vault-provider/auth/serverIdentity.d.ts.map +1 -1
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +2 -2
- package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts.map +1 -1
- package/dist/tbv/core/services/index.cjs +1 -1
- package/dist/tbv/core/services/index.js +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +2 -2
- package/dist/vault-registry-reader-DNiXOSYM.cjs +2 -0
- package/dist/vault-registry-reader-DNiXOSYM.cjs.map +1 -0
- package/dist/{vault-registry-reader-BDFpXeH7.js → vault-registry-reader-PsSxB0JZ.js} +166 -156
- package/dist/vault-registry-reader-PsSxB0JZ.js.map +1 -0
- package/package.json +1 -1
- package/dist/buildAndBroadcastRefund-B332dykQ.cjs +0 -2
- package/dist/buildAndBroadcastRefund-B332dykQ.cjs.map +0 -1
- package/dist/buildAndBroadcastRefund-CPjXNaMi.js.map +0 -1
- package/dist/vault-registry-reader-BDFpXeH7.js.map +0 -1
- package/dist/vault-registry-reader-ejm2UYzk.cjs +0 -2
- package/dist/vault-registry-reader-ejm2UYzk.cjs.map +0 -1
|
@@ -3,14 +3,14 @@ var le = (n, e, t) => e in n ? ce(n, e, { enumerable: !0, configurable: !0, writ
|
|
|
3
3
|
var h = (n, e, t) => le(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import { D as ue, J as Y, e as de } from "./types-TiIjyo2b.js";
|
|
5
5
|
import { X as B, C as K, s as C, S as pe, h as he } from "./bitcoin-B0S8SHCX.js";
|
|
6
|
-
import { H as
|
|
6
|
+
import { H as S } from "./validation-CxqROCno.js";
|
|
7
7
|
import * as N from "@bitcoin-js/tiny-secp256k1-asmjs";
|
|
8
|
-
import { payments as ge, Transaction as
|
|
9
|
-
import { Buffer as
|
|
10
|
-
import { s as
|
|
11
|
-
import { B as
|
|
12
|
-
import { P as b, A as
|
|
13
|
-
const
|
|
8
|
+
import { payments as ge, Transaction as O } from "bitcoinjs-lib";
|
|
9
|
+
import { Buffer as V } from "buffer";
|
|
10
|
+
import { s as F } from "./sha2-6wN58S6R.js";
|
|
11
|
+
import { B as k } from "./BTCVaultRegistry.abi-DbJ5lsFJ.js";
|
|
12
|
+
import { P as b, A as D } from "./ProtocolParams.abi-DXu8L0Fn.js";
|
|
13
|
+
const G = new Set(Object.values(ue)), fe = 200;
|
|
14
14
|
function c(n) {
|
|
15
15
|
var e;
|
|
16
16
|
return ((e = JSON.stringify(n)) == null ? void 0 : e.slice(0, fe)) ?? "undefined";
|
|
@@ -23,9 +23,9 @@ class s extends Error {
|
|
|
23
23
|
this.name = "VpResponseValidationError", this.detail = t;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
const
|
|
26
|
+
const A = 64;
|
|
27
27
|
function P(n) {
|
|
28
|
-
return typeof n == "string" && n.length > 0 &&
|
|
28
|
+
return typeof n == "string" && n.length > 0 && S.test(n);
|
|
29
29
|
}
|
|
30
30
|
function Z(n) {
|
|
31
31
|
return typeof n == "string" && n.length > 0;
|
|
@@ -36,7 +36,7 @@ function Q(n, e) {
|
|
|
36
36
|
`VP response validation failed: "${e}" must be a non-empty hex string, got ${c(n)}`
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function _(n, e) {
|
|
40
40
|
if (!Z(n))
|
|
41
41
|
throw new s(
|
|
42
42
|
`VP response validation failed: "${e}" must be a non-empty string, got ${c(n)}`
|
|
@@ -75,17 +75,17 @@ function te(n) {
|
|
|
75
75
|
"VP response validation failed: getPeginStatus response is not an object"
|
|
76
76
|
);
|
|
77
77
|
const e = n;
|
|
78
|
-
if (!P(e.pegin_txid) || e.pegin_txid.length !==
|
|
78
|
+
if (!P(e.pegin_txid) || e.pegin_txid.length !== A)
|
|
79
79
|
throw new s(
|
|
80
|
-
`VP response validation failed: "pegin_txid" must be a ${
|
|
80
|
+
`VP response validation failed: "pegin_txid" must be a ${A}-char hex string (txid), got ${c(e.pegin_txid)}`
|
|
81
81
|
);
|
|
82
82
|
if (typeof e.status != "string")
|
|
83
83
|
throw new s(
|
|
84
84
|
'VP response validation failed: "status" must be a string'
|
|
85
85
|
);
|
|
86
|
-
if (!
|
|
86
|
+
if (!G.has(e.status))
|
|
87
87
|
throw new s(
|
|
88
|
-
`VP response validation failed: unrecognized status "${e.status}". Expected one of: ${[...
|
|
88
|
+
`VP response validation failed: unrecognized status "${e.status}". Expected one of: ${[...G].join(", ")}`
|
|
89
89
|
);
|
|
90
90
|
if (e.progress === null || typeof e.progress != "object" || Array.isArray(e.progress))
|
|
91
91
|
throw new s(
|
|
@@ -133,7 +133,7 @@ function ye(n, e) {
|
|
|
133
133
|
`VP response validation failed: "${e}" must be an object`
|
|
134
134
|
);
|
|
135
135
|
const t = n;
|
|
136
|
-
ee(t.claimer_pubkey, `${e}.claimer_pubkey`), y(t.claim_tx, `${e}.claim_tx`), y(t.assert_tx, `${e}.assert_tx`), y(t.payout_tx, `${e}.payout_tx`),
|
|
136
|
+
ee(t.claimer_pubkey, `${e}.claimer_pubkey`), y(t.claim_tx, `${e}.claim_tx`), y(t.assert_tx, `${e}.assert_tx`), y(t.payout_tx, `${e}.payout_tx`), _(t.payout_psbt, `${e}.payout_psbt`);
|
|
137
137
|
}
|
|
138
138
|
function we(n, e) {
|
|
139
139
|
if (n === null || typeof n != "object")
|
|
@@ -141,7 +141,7 @@ function we(n, e) {
|
|
|
141
141
|
`VP response validation failed: "${e}" must be an object`
|
|
142
142
|
);
|
|
143
143
|
const t = n;
|
|
144
|
-
|
|
144
|
+
_(t.wots_pks_json, `${e}.wots_pks_json`), _(t.gc_wots_keys_json, `${e}.gc_wots_keys_json`);
|
|
145
145
|
}
|
|
146
146
|
function Pe(n, e) {
|
|
147
147
|
if (n === null || typeof n != "object")
|
|
@@ -155,7 +155,7 @@ function Pe(n, e) {
|
|
|
155
155
|
), y(
|
|
156
156
|
t.challenge_assert_y_tx,
|
|
157
157
|
`${e}.challenge_assert_y_tx`
|
|
158
|
-
), y(t.nopayout_tx, `${e}.nopayout_tx`),
|
|
158
|
+
), y(t.nopayout_tx, `${e}.nopayout_tx`), _(t.nopayout_psbt, `${e}.nopayout_psbt`), !Array.isArray(t.challenge_assert_connectors))
|
|
159
159
|
throw new s(
|
|
160
160
|
`VP response validation failed: "${e}.challenge_assert_connectors" must be an array`
|
|
161
161
|
);
|
|
@@ -174,7 +174,7 @@ function Pe(n, e) {
|
|
|
174
174
|
`${e}.output_label_hashes[${r}]`
|
|
175
175
|
);
|
|
176
176
|
}
|
|
177
|
-
function
|
|
177
|
+
function xe(n) {
|
|
178
178
|
if (n === null || typeof n != "object")
|
|
179
179
|
throw new s(
|
|
180
180
|
"VP response validation failed: requestDepositorClaimerArtifacts response is not an object"
|
|
@@ -206,15 +206,15 @@ function ve(n) {
|
|
|
206
206
|
);
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
|
-
function
|
|
209
|
+
function ve(n) {
|
|
210
210
|
if (n === null || typeof n != "object")
|
|
211
211
|
throw new s(
|
|
212
212
|
"VP response validation failed: pegout status payload is not an object"
|
|
213
213
|
);
|
|
214
214
|
const e = n;
|
|
215
|
-
if (!P(e.pegin_txid) || e.pegin_txid.length !==
|
|
215
|
+
if (!P(e.pegin_txid) || e.pegin_txid.length !== A)
|
|
216
216
|
throw new s(
|
|
217
|
-
`VP response validation failed: "pegin_txid" must be a ${
|
|
217
|
+
`VP response validation failed: "pegin_txid" must be a ${A}-char hex string (txid), got ${c(e.pegin_txid)}`
|
|
218
218
|
);
|
|
219
219
|
if (typeof e.found != "boolean")
|
|
220
220
|
throw new s(
|
|
@@ -235,11 +235,11 @@ function xe(n) {
|
|
|
235
235
|
Ae(e.challengers[t], t);
|
|
236
236
|
}
|
|
237
237
|
function Ve(n) {
|
|
238
|
-
if (
|
|
238
|
+
if (_(n.status, "claimer.status"), typeof n.failed != "boolean")
|
|
239
239
|
throw new s(
|
|
240
240
|
`VP response validation failed: "claimer.failed" must be a boolean, got ${c(n.failed)}`
|
|
241
241
|
);
|
|
242
|
-
if (
|
|
242
|
+
if (_(n.claim_txid, "claimer.claim_txid"), _(n.claimer_pubkey, "claimer.claimer_pubkey"), _(n.assert_txid, "claimer.assert_txid"), n.challenger_pubkey !== null && typeof n.challenger_pubkey != "string")
|
|
243
243
|
throw new s(
|
|
244
244
|
`VP response validation failed: "claimer.challenger_pubkey" must be a string or null, got ${c(n.challenger_pubkey)}`
|
|
245
245
|
);
|
|
@@ -258,7 +258,7 @@ function Ae(n, e) {
|
|
|
258
258
|
`VP response validation failed: "challengers[${e}]" must be an object, got ${c(n)}`
|
|
259
259
|
);
|
|
260
260
|
const t = n;
|
|
261
|
-
if (
|
|
261
|
+
if (_(t.status, `challengers[${e}].status`), _(t.claim_txid, `challengers[${e}].claim_txid`), _(t.claimer_pubkey, `challengers[${e}].claimer_pubkey`), E(t.assert_txid, `challengers[${e}].assert_txid`), E(
|
|
262
262
|
t.challenge_assert_x_txid,
|
|
263
263
|
`challengers[${e}].challenge_assert_x_txid`
|
|
264
264
|
), E(
|
|
@@ -279,14 +279,14 @@ function E(n, e) {
|
|
|
279
279
|
`VP response validation failed: "${e}" must be a string or null, got ${c(n)}`
|
|
280
280
|
);
|
|
281
281
|
}
|
|
282
|
-
function
|
|
282
|
+
function Se(n) {
|
|
283
283
|
ne(n, "batchGetPeginStatus", (e) => {
|
|
284
284
|
e.result !== null && te(e.result);
|
|
285
285
|
});
|
|
286
286
|
}
|
|
287
|
-
function
|
|
287
|
+
function ke(n) {
|
|
288
288
|
ne(n, "batchGetPegoutStatus", (e) => {
|
|
289
|
-
e.result !== null &&
|
|
289
|
+
e.result !== null && ve(e.result);
|
|
290
290
|
});
|
|
291
291
|
}
|
|
292
292
|
function ne(n, e, t) {
|
|
@@ -306,9 +306,9 @@ function ne(n, e, t) {
|
|
|
306
306
|
`VP response validation failed: "${e}.results[${i}]" must be an object, got ${c(a)}`
|
|
307
307
|
);
|
|
308
308
|
const o = a;
|
|
309
|
-
if (!P(o.pegin_txid) || o.pegin_txid.length !==
|
|
309
|
+
if (!P(o.pegin_txid) || o.pegin_txid.length !== A)
|
|
310
310
|
throw new s(
|
|
311
|
-
`VP response validation failed: "${e}.results[${i}].pegin_txid" must be a ${
|
|
311
|
+
`VP response validation failed: "${e}.results[${i}].pegin_txid" must be a ${A}-char hex string, got ${c(o.pegin_txid)}`
|
|
312
312
|
);
|
|
313
313
|
if (o.error !== null && typeof o.error != "string")
|
|
314
314
|
throw new s(
|
|
@@ -326,7 +326,7 @@ function ne(n, e, t) {
|
|
|
326
326
|
}
|
|
327
327
|
}
|
|
328
328
|
function $e(n) {
|
|
329
|
-
if (y(n.claim_tx, "depositor_graph.claim_tx"), y(n.assert_tx, "depositor_graph.assert_tx"), y(n.payout_tx, "depositor_graph.payout_tx"),
|
|
329
|
+
if (y(n.claim_tx, "depositor_graph.claim_tx"), y(n.assert_tx, "depositor_graph.assert_tx"), y(n.payout_tx, "depositor_graph.payout_tx"), _(n.payout_psbt, "depositor_graph.payout_psbt"), !Array.isArray(n.challenger_presign_data))
|
|
330
330
|
throw new s(
|
|
331
331
|
'VP response validation failed: "depositor_graph.challenger_presign_data" must be an array'
|
|
332
332
|
);
|
|
@@ -393,7 +393,7 @@ class Ce {
|
|
|
393
393
|
*/
|
|
394
394
|
async requestDepositorClaimerArtifacts(e, t) {
|
|
395
395
|
const r = await this.client.call("vaultProvider_requestDepositorClaimerArtifacts", e, t);
|
|
396
|
-
return
|
|
396
|
+
return xe(r), r;
|
|
397
397
|
}
|
|
398
398
|
/** Get the current pegin status from the vault provider daemon. */
|
|
399
399
|
async getPeginStatus(e, t) {
|
|
@@ -411,7 +411,7 @@ class Ce {
|
|
|
411
411
|
*/
|
|
412
412
|
async batchGetPeginStatus(e, t) {
|
|
413
413
|
const r = await this.client.call("vaultProvider_batchGetPeginStatus", e, t);
|
|
414
|
-
return
|
|
414
|
+
return Se(r), r;
|
|
415
415
|
}
|
|
416
416
|
/**
|
|
417
417
|
* Get pegout status for many txids in one round trip. Same per-result
|
|
@@ -419,7 +419,7 @@ class Ce {
|
|
|
419
419
|
*/
|
|
420
420
|
async batchGetPegoutStatus(e, t) {
|
|
421
421
|
const r = await this.client.call("vaultProvider_batchGetPegoutStatus", e, t);
|
|
422
|
-
return
|
|
422
|
+
return ke(r), r;
|
|
423
423
|
}
|
|
424
424
|
}
|
|
425
425
|
function Ee(n, e) {
|
|
@@ -428,23 +428,23 @@ function Ee(n, e) {
|
|
|
428
428
|
t.add(d.toLowerCase());
|
|
429
429
|
const r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), a = [], o = [];
|
|
430
430
|
for (const d of e) {
|
|
431
|
-
const
|
|
432
|
-
if (!t.has(
|
|
433
|
-
o.push(
|
|
431
|
+
const u = d.pegin_txid.toLowerCase();
|
|
432
|
+
if (!t.has(u)) {
|
|
433
|
+
o.push(u);
|
|
434
434
|
continue;
|
|
435
435
|
}
|
|
436
|
-
if (i.has(
|
|
437
|
-
a.push(
|
|
436
|
+
if (i.has(u)) {
|
|
437
|
+
a.push(u);
|
|
438
438
|
continue;
|
|
439
439
|
}
|
|
440
|
-
i.add(
|
|
440
|
+
i.add(u), r.set(u, { result: d.result, error: d.error });
|
|
441
441
|
}
|
|
442
|
-
const
|
|
442
|
+
const l = [];
|
|
443
443
|
for (const d of t)
|
|
444
|
-
i.has(d) ||
|
|
445
|
-
return { byTxid: r, missing:
|
|
444
|
+
i.has(d) || l.push(d);
|
|
445
|
+
return { byTxid: r, missing: l, unexpected: o, duplicate: a };
|
|
446
446
|
}
|
|
447
|
-
async function
|
|
447
|
+
async function tt(n) {
|
|
448
448
|
const {
|
|
449
449
|
items: e,
|
|
450
450
|
getTxid: t,
|
|
@@ -452,55 +452,55 @@ async function et(n) {
|
|
|
452
452
|
onItem: i,
|
|
453
453
|
onMissing: a,
|
|
454
454
|
onDuplicate: o,
|
|
455
|
-
onDuplicateBatch:
|
|
455
|
+
onDuplicateBatch: l,
|
|
456
456
|
onWholeBatchError: d,
|
|
457
|
-
onUnexpected:
|
|
458
|
-
batchSize:
|
|
457
|
+
onUnexpected: u,
|
|
458
|
+
batchSize: f = de
|
|
459
459
|
} = n;
|
|
460
|
-
if (!Number.isInteger(
|
|
460
|
+
if (!Number.isInteger(f) || f <= 0)
|
|
461
461
|
throw new Error(
|
|
462
|
-
`batchPollByProvider: batchSize must be a positive integer, got ${
|
|
462
|
+
`batchPollByProvider: batchSize must be a positive integer, got ${f}`
|
|
463
463
|
);
|
|
464
|
-
for (let w = 0; w < e.length; w +=
|
|
465
|
-
const
|
|
466
|
-
for (const p of
|
|
467
|
-
const
|
|
468
|
-
$.set(
|
|
464
|
+
for (let w = 0; w < e.length; w += f) {
|
|
465
|
+
const x = e.slice(w, w + f), $ = /* @__PURE__ */ new Map(), j = [];
|
|
466
|
+
for (const p of x) {
|
|
467
|
+
const m = t(p).toLowerCase();
|
|
468
|
+
$.set(m, p), j.push(m);
|
|
469
469
|
}
|
|
470
470
|
let v;
|
|
471
471
|
try {
|
|
472
472
|
const p = await r(j);
|
|
473
473
|
v = Ee(j, p.results);
|
|
474
474
|
} catch (p) {
|
|
475
|
-
d(
|
|
475
|
+
d(x, p);
|
|
476
476
|
continue;
|
|
477
477
|
}
|
|
478
|
-
|
|
478
|
+
u && v.unexpected.length > 0 && u(v.unexpected);
|
|
479
479
|
const T = new Set(v.duplicate);
|
|
480
480
|
for (const p of T) {
|
|
481
|
-
const
|
|
482
|
-
|
|
481
|
+
const m = $.get(p);
|
|
482
|
+
m && o(m);
|
|
483
483
|
}
|
|
484
|
-
|
|
484
|
+
l && T.size > 0 && l(T.size);
|
|
485
485
|
for (const p of v.missing) {
|
|
486
|
-
const
|
|
487
|
-
|
|
486
|
+
const m = $.get(p);
|
|
487
|
+
m && a(m);
|
|
488
488
|
}
|
|
489
|
-
for (const [p,
|
|
489
|
+
for (const [p, m] of v.byTxid) {
|
|
490
490
|
if (T.has(p)) continue;
|
|
491
491
|
const M = $.get(p);
|
|
492
492
|
M && i(M, {
|
|
493
493
|
pegin_txid: p,
|
|
494
|
-
result:
|
|
495
|
-
error:
|
|
494
|
+
result: m.result,
|
|
495
|
+
error: m.error
|
|
496
496
|
});
|
|
497
497
|
}
|
|
498
498
|
}
|
|
499
499
|
}
|
|
500
500
|
const Ie = "BIP0322-signed-message", Be = "TapTweak", re = 32, Re = 64;
|
|
501
501
|
function se(n, e) {
|
|
502
|
-
const t = new TextEncoder().encode(n), r =
|
|
503
|
-
return i.set(r, 0), i.set(r, r.length), i.set(e, r.length * 2),
|
|
502
|
+
const t = new TextEncoder().encode(n), r = F(t), i = new Uint8Array(r.length * 2 + e.length);
|
|
503
|
+
return i.set(r, 0), i.set(r, r.length), i.set(e, r.length * 2), F(i);
|
|
504
504
|
}
|
|
505
505
|
function He(n) {
|
|
506
506
|
if (n.length !== re) return null;
|
|
@@ -511,35 +511,35 @@ function Ne(n, e, t) {
|
|
|
511
511
|
if (e.length !== re || t.length !== Re) return !1;
|
|
512
512
|
try {
|
|
513
513
|
const r = se(Ie, n), i = ge.p2tr({
|
|
514
|
-
internalPubkey:
|
|
514
|
+
internalPubkey: V.from(e)
|
|
515
515
|
});
|
|
516
516
|
if (!i.output) return !1;
|
|
517
|
-
const a = i.output, o = 0,
|
|
518
|
-
|
|
519
|
-
const d =
|
|
520
|
-
|
|
521
|
-
|
|
517
|
+
const a = i.output, o = 0, l = new O();
|
|
518
|
+
l.version = 0, l.locktime = 0;
|
|
519
|
+
const d = V.concat([
|
|
520
|
+
V.from([0, 32]),
|
|
521
|
+
V.from(r)
|
|
522
522
|
]);
|
|
523
|
-
|
|
524
|
-
|
|
523
|
+
l.addInput(
|
|
524
|
+
V.alloc(32, 0),
|
|
525
525
|
// prev_txid = 0x0000...0000
|
|
526
526
|
4294967295,
|
|
527
527
|
// prev_vout = 0xFFFFFFFF
|
|
528
528
|
0,
|
|
529
529
|
// sequence = 0
|
|
530
530
|
d
|
|
531
|
-
),
|
|
532
|
-
const
|
|
533
|
-
|
|
534
|
-
const
|
|
535
|
-
|
|
536
|
-
const w =
|
|
531
|
+
), l.addOutput(a, o);
|
|
532
|
+
const u = new O();
|
|
533
|
+
u.version = 0, u.locktime = 0;
|
|
534
|
+
const f = l.getHash();
|
|
535
|
+
u.addInput(f, 0, 0), u.addOutput(V.from([106]), o);
|
|
536
|
+
const w = u.hashForWitnessV1(
|
|
537
537
|
0,
|
|
538
538
|
[a],
|
|
539
539
|
[o],
|
|
540
|
-
|
|
541
|
-
),
|
|
542
|
-
return
|
|
540
|
+
O.SIGHASH_DEFAULT
|
|
541
|
+
), x = He(e);
|
|
542
|
+
return x ? N.verifySchnorr(w, x, t) : !1;
|
|
543
543
|
} catch {
|
|
544
544
|
return !1;
|
|
545
545
|
}
|
|
@@ -590,10 +590,10 @@ function je(n, e, t) {
|
|
|
590
590
|
const r = R(4, 3), i = X(n), a = X(e), o = R(0, t);
|
|
591
591
|
return ie(r, i, a, o);
|
|
592
592
|
}
|
|
593
|
-
const
|
|
593
|
+
const Oe = new TextEncoder().encode(
|
|
594
594
|
"btc-auth.server-identity.v1"
|
|
595
|
-
);
|
|
596
|
-
class
|
|
595
|
+
), De = 2 * 3600;
|
|
596
|
+
class g extends Error {
|
|
597
597
|
constructor(e, t) {
|
|
598
598
|
super(e), this.reason = t, this.name = "ServerIdentityError";
|
|
599
599
|
}
|
|
@@ -604,89 +604,99 @@ function I(n) {
|
|
|
604
604
|
e[t] = parseInt(n.slice(t * 2, t * 2 + 2), 16);
|
|
605
605
|
return e;
|
|
606
606
|
}
|
|
607
|
-
function
|
|
608
|
-
const { proof: e, pinnedServerPubkey: t, now: r } = n, i = C(t).toLowerCase();
|
|
609
|
-
if (
|
|
610
|
-
throw new
|
|
611
|
-
`pinnedServerPubkey must be 32-byte hex; got ${
|
|
607
|
+
function Ue(n) {
|
|
608
|
+
const { proof: e, pinnedServerPubkey: t, now: r } = n, i = n.maxLifetimeSecs ?? De, a = C(t).toLowerCase();
|
|
609
|
+
if (a.length !== B || !S.test(a))
|
|
610
|
+
throw new g(
|
|
611
|
+
`pinnedServerPubkey must be 32-byte hex; got ${a.length} chars`,
|
|
612
612
|
"invalid_pubkey_encoding"
|
|
613
613
|
);
|
|
614
|
-
const
|
|
615
|
-
if (
|
|
616
|
-
throw new
|
|
617
|
-
`server_pubkey must be 32-byte hex; got ${
|
|
614
|
+
const o = C(e.server_pubkey).toLowerCase();
|
|
615
|
+
if (o.length !== B || !S.test(o))
|
|
616
|
+
throw new g(
|
|
617
|
+
`server_pubkey must be 32-byte hex; got ${o.length} chars`,
|
|
618
618
|
"invalid_pubkey_encoding"
|
|
619
619
|
);
|
|
620
|
-
if (
|
|
621
|
-
throw new
|
|
622
|
-
`server_pubkey does not match pinned value: expected ${
|
|
620
|
+
if (o !== a)
|
|
621
|
+
throw new g(
|
|
622
|
+
`server_pubkey does not match pinned value: expected ${a}, got ${o}`,
|
|
623
623
|
"pinned_pubkey_mismatch"
|
|
624
624
|
);
|
|
625
625
|
if (!Number.isSafeInteger(e.expires_at))
|
|
626
|
-
throw new
|
|
626
|
+
throw new g(
|
|
627
627
|
`expires_at must be a finite integer; got ${JSON.stringify(e.expires_at)}`,
|
|
628
628
|
"invalid_expires_at"
|
|
629
629
|
);
|
|
630
630
|
if (!Number.isSafeInteger(r))
|
|
631
|
-
throw new
|
|
631
|
+
throw new g(
|
|
632
632
|
`now must be a finite integer; got ${JSON.stringify(r)}`,
|
|
633
633
|
"invalid_expires_at"
|
|
634
634
|
);
|
|
635
635
|
if (e.expires_at <= r)
|
|
636
|
-
throw new
|
|
636
|
+
throw new g(
|
|
637
637
|
`server identity proof expired at ${e.expires_at}, now ${r}`,
|
|
638
638
|
"expired"
|
|
639
639
|
);
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
640
|
+
if (!Number.isSafeInteger(i) || i <= 0)
|
|
641
|
+
throw new g(
|
|
642
|
+
`maxLifetimeSecs must be a positive safe integer; got ${JSON.stringify(i)}`,
|
|
643
|
+
"invalid_max_lifetime"
|
|
644
|
+
);
|
|
645
|
+
if (e.expires_at - r > i)
|
|
646
|
+
throw new g(
|
|
647
|
+
`server identity proof expires too far in the future: expires_at=${e.expires_at}, now=${r}, max lifetime=${i}s`,
|
|
648
|
+
"expires_too_far"
|
|
649
|
+
);
|
|
650
|
+
const l = C(e.ephemeral_pubkey).toLowerCase();
|
|
651
|
+
if (l.length !== K || !S.test(l))
|
|
652
|
+
throw new g(
|
|
653
|
+
`ephemeral_pubkey must be 33-byte compressed hex; got ${l.length} chars`,
|
|
644
654
|
"invalid_ephemeral_pubkey"
|
|
645
655
|
);
|
|
646
|
-
const
|
|
647
|
-
if (
|
|
648
|
-
throw new
|
|
649
|
-
`ephemeral_pubkey must be compressed (prefix 02/03); got ${
|
|
656
|
+
const d = l.slice(0, 2);
|
|
657
|
+
if (d !== "02" && d !== "03")
|
|
658
|
+
throw new g(
|
|
659
|
+
`ephemeral_pubkey must be compressed (prefix 02/03); got ${d}`,
|
|
650
660
|
"invalid_ephemeral_pubkey"
|
|
651
661
|
);
|
|
652
|
-
const
|
|
653
|
-
if (!N.isPoint(
|
|
654
|
-
throw new
|
|
662
|
+
const u = I(l);
|
|
663
|
+
if (!N.isPoint(u))
|
|
664
|
+
throw new g(
|
|
655
665
|
"ephemeral_pubkey is not a valid secp256k1 point",
|
|
656
666
|
"invalid_ephemeral_pubkey"
|
|
657
667
|
);
|
|
658
|
-
const
|
|
659
|
-
if (
|
|
660
|
-
throw new
|
|
661
|
-
`signature must be 64-byte Schnorr hex; got ${
|
|
668
|
+
const f = C(e.signature).toLowerCase();
|
|
669
|
+
if (f.length !== pe || !S.test(f))
|
|
670
|
+
throw new g(
|
|
671
|
+
`signature must be 64-byte Schnorr hex; got ${f.length} chars`,
|
|
662
672
|
"invalid_signature_encoding"
|
|
663
673
|
);
|
|
664
|
-
const
|
|
665
|
-
|
|
666
|
-
I(
|
|
674
|
+
const w = je(
|
|
675
|
+
Oe,
|
|
676
|
+
I(l),
|
|
667
677
|
e.expires_at
|
|
668
678
|
);
|
|
669
|
-
if (!Ne(
|
|
670
|
-
throw new
|
|
679
|
+
if (!Ne(w, I(o), I(f)))
|
|
680
|
+
throw new g(
|
|
671
681
|
"BIP-322 signature verification failed — ephemeral key is not attested by pinned server pubkey",
|
|
672
682
|
"signature_verification_failed"
|
|
673
683
|
);
|
|
674
684
|
}
|
|
675
|
-
const
|
|
685
|
+
const Ke = /* @__PURE__ */ new Set([
|
|
676
686
|
"vaultProvider_submitDepositorWotsKey",
|
|
677
687
|
"vaultProvider_submitDepositorPresignatures",
|
|
678
688
|
"vaultProvider_requestDepositorPresignTransactions"
|
|
679
|
-
]),
|
|
689
|
+
]), Le = 6e4, L = "auth_createDepositorToken";
|
|
680
690
|
function ae(n, e) {
|
|
681
691
|
return new Y({
|
|
682
692
|
baseUrl: n,
|
|
683
|
-
timeout:
|
|
693
|
+
timeout: Le,
|
|
684
694
|
headers: e,
|
|
685
695
|
retryableFor: (t) => t === L
|
|
686
696
|
});
|
|
687
697
|
}
|
|
688
|
-
const q = 4102444800,
|
|
689
|
-
class
|
|
698
|
+
const q = 4102444800, Me = 30;
|
|
699
|
+
class Fe {
|
|
690
700
|
constructor(e) {
|
|
691
701
|
// `client` is the only mutable field — see `setClient`. The
|
|
692
702
|
// identity-bearing fields (peginTxid/authAnchorHex/pinnedServerPubkey)
|
|
@@ -701,7 +711,7 @@ class Me {
|
|
|
701
711
|
h(this, "now");
|
|
702
712
|
h(this, "cached", null);
|
|
703
713
|
h(this, "inFlight", null);
|
|
704
|
-
this.client = e.client, this.peginTxid = e.peginTxid, this.authAnchorHex = e.authAnchorHex, this.pinnedServerPubkey = e.pinnedServerPubkey, this.authGatedMethods = e.authGatedMethods, this.refreshSkewSecs = e.refreshSkewSecs ??
|
|
714
|
+
this.client = e.client, this.peginTxid = e.peginTxid, this.authAnchorHex = e.authAnchorHex, this.pinnedServerPubkey = e.pinnedServerPubkey, this.authGatedMethods = e.authGatedMethods, this.refreshSkewSecs = e.refreshSkewSecs ?? Me, this.now = e.now ?? (() => Math.floor(Date.now() / 1e3));
|
|
705
715
|
}
|
|
706
716
|
/**
|
|
707
717
|
* Return a bearer token for `method`, or `null` if `method` is not
|
|
@@ -747,7 +757,7 @@ class Me {
|
|
|
747
757
|
pegin_txid: this.peginTxid,
|
|
748
758
|
auth_anchor: this.authAnchorHex
|
|
749
759
|
});
|
|
750
|
-
if (
|
|
760
|
+
if (Ue({
|
|
751
761
|
proof: r.server_identity,
|
|
752
762
|
pinnedServerPubkey: this.pinnedServerPubkey,
|
|
753
763
|
now: this.now()
|
|
@@ -796,12 +806,12 @@ class Ge {
|
|
|
796
806
|
);
|
|
797
807
|
return t.provider.setClient(e.client), t.provider;
|
|
798
808
|
}
|
|
799
|
-
const r = new
|
|
809
|
+
const r = new Fe({
|
|
800
810
|
client: e.client,
|
|
801
811
|
peginTxid: e.peginTxid,
|
|
802
812
|
authAnchorHex: e.authAnchorHex,
|
|
803
813
|
pinnedServerPubkey: e.pinnedServerPubkey,
|
|
804
|
-
authGatedMethods:
|
|
814
|
+
authGatedMethods: Ke
|
|
805
815
|
});
|
|
806
816
|
return this.entries.set(e.peginTxid, {
|
|
807
817
|
provider: r,
|
|
@@ -836,7 +846,7 @@ class Ge {
|
|
|
836
846
|
}
|
|
837
847
|
}
|
|
838
848
|
const oe = new Ge();
|
|
839
|
-
function
|
|
849
|
+
function nt(n) {
|
|
840
850
|
var r;
|
|
841
851
|
const e = ae(
|
|
842
852
|
n.baseUrl,
|
|
@@ -852,7 +862,7 @@ function tt(n) {
|
|
|
852
862
|
tokenProvider: t
|
|
853
863
|
});
|
|
854
864
|
}
|
|
855
|
-
function
|
|
865
|
+
function rt(n) {
|
|
856
866
|
oe.getOrCreate({
|
|
857
867
|
client: ae(n.baseUrl, n.headers),
|
|
858
868
|
peginTxid: n.peginTxid,
|
|
@@ -860,17 +870,17 @@ function nt(n) {
|
|
|
860
870
|
pinnedServerPubkey: n.pinnedServerPubkey
|
|
861
871
|
});
|
|
862
872
|
}
|
|
863
|
-
async function
|
|
873
|
+
async function st(n, e) {
|
|
864
874
|
const [t, r] = await n.multicall({
|
|
865
875
|
contracts: [
|
|
866
876
|
{
|
|
867
877
|
address: e,
|
|
868
|
-
abi:
|
|
878
|
+
abi: k,
|
|
869
879
|
functionName: "protocolParams"
|
|
870
880
|
},
|
|
871
881
|
{
|
|
872
882
|
address: e,
|
|
873
|
-
abi:
|
|
883
|
+
abi: k,
|
|
874
884
|
functionName: "applicationRegistry"
|
|
875
885
|
}
|
|
876
886
|
],
|
|
@@ -915,7 +925,7 @@ function J(n) {
|
|
|
915
925
|
);
|
|
916
926
|
return Number(n);
|
|
917
927
|
}
|
|
918
|
-
class
|
|
928
|
+
class it {
|
|
919
929
|
constructor(e, t) {
|
|
920
930
|
this.publicClient = e, this.contractAddress = t;
|
|
921
931
|
}
|
|
@@ -994,14 +1004,14 @@ function H(n) {
|
|
|
994
1004
|
btcPubKey: e.btcPubKey
|
|
995
1005
|
}));
|
|
996
1006
|
}
|
|
997
|
-
class
|
|
1007
|
+
class at {
|
|
998
1008
|
constructor(e, t) {
|
|
999
1009
|
this.publicClient = e, this.contractAddress = t;
|
|
1000
1010
|
}
|
|
1001
1011
|
async getVaultKeepersByVersion(e, t) {
|
|
1002
1012
|
const r = await this.publicClient.readContract({
|
|
1003
1013
|
address: this.contractAddress,
|
|
1004
|
-
abi:
|
|
1014
|
+
abi: D,
|
|
1005
1015
|
functionName: "getVaultKeepersByVersion",
|
|
1006
1016
|
args: [e, t]
|
|
1007
1017
|
});
|
|
@@ -1010,7 +1020,7 @@ class it {
|
|
|
1010
1020
|
async getCurrentVaultKeepers(e) {
|
|
1011
1021
|
const t = await this.publicClient.readContract({
|
|
1012
1022
|
address: this.contractAddress,
|
|
1013
|
-
abi:
|
|
1023
|
+
abi: D,
|
|
1014
1024
|
functionName: "getCurrentVaultKeepers",
|
|
1015
1025
|
args: [e]
|
|
1016
1026
|
});
|
|
@@ -1019,13 +1029,13 @@ class it {
|
|
|
1019
1029
|
async getCurrentVaultKeepersVersion(e) {
|
|
1020
1030
|
return await this.publicClient.readContract({
|
|
1021
1031
|
address: this.contractAddress,
|
|
1022
|
-
abi:
|
|
1032
|
+
abi: D,
|
|
1023
1033
|
functionName: "getCurrentVaultKeepersVersion",
|
|
1024
1034
|
args: [e]
|
|
1025
1035
|
});
|
|
1026
1036
|
}
|
|
1027
1037
|
}
|
|
1028
|
-
class
|
|
1038
|
+
class ot {
|
|
1029
1039
|
constructor(e, t) {
|
|
1030
1040
|
this.publicClient = e, this.contractAddress = t;
|
|
1031
1041
|
}
|
|
@@ -1054,7 +1064,7 @@ class at {
|
|
|
1054
1064
|
});
|
|
1055
1065
|
}
|
|
1056
1066
|
}
|
|
1057
|
-
class
|
|
1067
|
+
class ct {
|
|
1058
1068
|
constructor(e, t) {
|
|
1059
1069
|
this.publicClient = e, this.contractAddress = t;
|
|
1060
1070
|
}
|
|
@@ -1067,7 +1077,7 @@ class ot {
|
|
|
1067
1077
|
async getVaultProviderBtcPubKey(e) {
|
|
1068
1078
|
const r = (await this.publicClient.readContract({
|
|
1069
1079
|
address: this.contractAddress,
|
|
1070
|
-
abi:
|
|
1080
|
+
abi: k,
|
|
1071
1081
|
functionName: "getVaultProviderBTCKey",
|
|
1072
1082
|
args: [e]
|
|
1073
1083
|
})).toLowerCase();
|
|
@@ -1085,7 +1095,7 @@ class ot {
|
|
|
1085
1095
|
async getVaultBasicInfo(e) {
|
|
1086
1096
|
const t = await this.publicClient.readContract({
|
|
1087
1097
|
address: this.contractAddress,
|
|
1088
|
-
abi:
|
|
1098
|
+
abi: k,
|
|
1089
1099
|
functionName: "getBtcVaultBasicInfo",
|
|
1090
1100
|
args: [e]
|
|
1091
1101
|
});
|
|
@@ -1102,7 +1112,7 @@ class ot {
|
|
|
1102
1112
|
async getVaultProtocolInfo(e) {
|
|
1103
1113
|
const t = await this.publicClient.readContract({
|
|
1104
1114
|
address: this.contractAddress,
|
|
1105
|
-
abi:
|
|
1115
|
+
abi: k,
|
|
1106
1116
|
functionName: "getBtcVaultProtocolInfo",
|
|
1107
1117
|
args: [e]
|
|
1108
1118
|
});
|
|
@@ -1133,20 +1143,20 @@ class ot {
|
|
|
1133
1143
|
}
|
|
1134
1144
|
}
|
|
1135
1145
|
export {
|
|
1136
|
-
|
|
1146
|
+
g as S,
|
|
1137
1147
|
Ce as V,
|
|
1138
1148
|
s as a,
|
|
1139
|
-
|
|
1140
|
-
|
|
1149
|
+
tt as b,
|
|
1150
|
+
Ue as c,
|
|
1141
1151
|
Ge as d,
|
|
1142
1152
|
oe as e,
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1153
|
+
nt as f,
|
|
1154
|
+
it as g,
|
|
1155
|
+
ot as h,
|
|
1156
|
+
at as i,
|
|
1157
|
+
ct as j,
|
|
1158
|
+
rt as p,
|
|
1159
|
+
st as r,
|
|
1160
|
+
xe as v
|
|
1151
1161
|
};
|
|
1152
|
-
//# sourceMappingURL=vault-registry-reader-
|
|
1162
|
+
//# sourceMappingURL=vault-registry-reader-PsSxB0JZ.js.map
|