@babylonlabs-io/ts-sdk 0.45.0 → 0.47.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/{PeginManager-CL1Esl1c.cjs → PeginManager-CeloRUHV.cjs} +2 -2
- package/dist/{PeginManager-CL1Esl1c.cjs.map → PeginManager-CeloRUHV.cjs.map} +1 -1
- package/dist/{PeginManager-CFGjwYtC.js → PeginManager-CxSbzoYs.js} +2 -2
- package/dist/{PeginManager-CFGjwYtC.js.map → PeginManager-CxSbzoYs.js.map} +1 -1
- package/dist/{buildAndBroadcastRefund-CZj2z7PJ.js → buildAndBroadcastRefund-BssyvGWW.js} +2 -2
- package/dist/{buildAndBroadcastRefund-CZj2z7PJ.js.map → buildAndBroadcastRefund-BssyvGWW.js.map} +1 -1
- package/dist/{buildAndBroadcastRefund-Ux587SFf.cjs → buildAndBroadcastRefund-CgUJ7Mpf.cjs} +2 -2
- package/dist/{buildAndBroadcastRefund-Ux587SFf.cjs.map → buildAndBroadcastRefund-CgUJ7Mpf.cjs.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +5 -5
- package/dist/mempoolApi-BxT89SAq.js +471 -0
- package/dist/mempoolApi-BxT89SAq.js.map +1 -0
- package/dist/mempoolApi-C_9JhjCI.cjs +2 -0
- package/dist/mempoolApi-C_9JhjCI.cjs.map +1 -0
- package/dist/primeVpAuth-Br6RwE3r.cjs +2 -0
- package/dist/{primeVpAuth-BihAGyNf.cjs.map → primeVpAuth-Br6RwE3r.cjs.map} +1 -1
- package/dist/{primeVpAuth-DXl9wGBR.js → primeVpAuth-rbejoBPu.js} +208 -200
- package/dist/{primeVpAuth-DXl9wGBR.js.map → primeVpAuth-rbejoBPu.js.map} +1 -1
- package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts.map +1 -1
- package/dist/tbv/core/clients/index.cjs +1 -1
- package/dist/tbv/core/clients/index.js +3 -3
- package/dist/tbv/core/clients/vault-provider/auth/createAuthenticatedVpClient.d.ts +6 -0
- package/dist/tbv/core/clients/vault-provider/auth/createAuthenticatedVpClient.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/auth/primeVpAuth.d.ts +8 -0
- package/dist/tbv/core/clients/vault-provider/auth/primeVpAuth.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/auth/tokenRegistry.d.ts +14 -4
- package/dist/tbv/core/clients/vault-provider/auth/tokenRegistry.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/types.d.ts +3 -0
- package/dist/tbv/core/clients/vault-provider/types.d.ts.map +1 -1
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +5 -5
- package/dist/tbv/core/managers/index.cjs +1 -1
- package/dist/tbv/core/managers/index.js +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 +5 -5
- package/dist/tbv/integrations/aave/clients/index.d.ts +1 -1
- package/dist/tbv/integrations/aave/clients/index.d.ts.map +1 -1
- package/dist/tbv/integrations/aave/clients/oracle.d.ts +8 -1
- package/dist/tbv/integrations/aave/clients/oracle.d.ts.map +1 -1
- package/dist/tbv/integrations/aave/clients/spoke.d.ts +27 -0
- package/dist/tbv/integrations/aave/clients/spoke.d.ts.map +1 -1
- package/dist/tbv/integrations/aave/constants.d.ts +3 -3
- package/dist/tbv/integrations/aave/constants.d.ts.map +1 -1
- package/dist/tbv/integrations/aave/index.cjs +1 -1
- package/dist/tbv/integrations/aave/index.cjs.map +1 -1
- package/dist/tbv/integrations/aave/index.d.ts +1 -1
- package/dist/tbv/integrations/aave/index.d.ts.map +1 -1
- package/dist/tbv/integrations/aave/index.js +276 -212
- package/dist/tbv/integrations/aave/index.js.map +1 -1
- package/dist/{types-BqGAMOZM.js → types-CQDRQvV-.js} +11 -10
- package/dist/types-CQDRQvV-.js.map +1 -0
- package/dist/{types-eYlq0p1o.cjs → types-WA0LrDk1.cjs} +2 -2
- package/dist/types-WA0LrDk1.cjs.map +1 -0
- package/package.json +1 -1
- package/dist/mempoolApi-DcHws8jJ.cjs +0 -2
- package/dist/mempoolApi-DcHws8jJ.cjs.map +0 -1
- package/dist/mempoolApi-DnP7d084.js +0 -451
- package/dist/mempoolApi-DnP7d084.js.map +0 -1
- package/dist/primeVpAuth-BihAGyNf.cjs +0 -2
- package/dist/types-BqGAMOZM.js.map +0 -1
- package/dist/types-eYlq0p1o.cjs.map +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var p = (r, e, t) =>
|
|
1
|
+
var pe = Object.defineProperty;
|
|
2
|
+
var he = (r, e, t) => e in r ? pe(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var p = (r, e, t) => he(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import { B as X } from "./BTCVaultRegistry.abi-Chs4AFBj.js";
|
|
5
|
-
import { P as b, A as
|
|
6
|
-
import { j as
|
|
7
|
-
import { D as
|
|
8
|
-
import { X as R, C as j, s as V, S as
|
|
5
|
+
import { P as b, A as B } from "./ApplicationRegistry.abi-Dn2qk6JG.js";
|
|
6
|
+
import { j as ge, v as H, k as fe, i as _e } from "./mempoolApi-BxT89SAq.js";
|
|
7
|
+
import { D as me, J as re, e as be } from "./types-CQDRQvV-.js";
|
|
8
|
+
import { X as R, C as j, s as V, S as ye } from "./bitcoin-B5aNKtsk.js";
|
|
9
9
|
import { H as $ } from "./validation-CxqROCno.js";
|
|
10
10
|
import * as F from "@bitcoin-js/tiny-secp256k1-asmjs";
|
|
11
|
-
import { payments as
|
|
11
|
+
import { payments as we, Transaction as O } from "bitcoinjs-lib";
|
|
12
12
|
import { Buffer as A } from "buffer";
|
|
13
13
|
import { s as q } from "./sha2-BYVxyZzX.js";
|
|
14
14
|
async function ct(r, e) {
|
|
@@ -77,7 +77,7 @@ class lt {
|
|
|
77
77
|
abi: b,
|
|
78
78
|
functionName: "getTBVProtocolParams"
|
|
79
79
|
}), t = z(e);
|
|
80
|
-
return
|
|
80
|
+
return ge(t), t;
|
|
81
81
|
}
|
|
82
82
|
async getLatestOffchainParams() {
|
|
83
83
|
const e = await this.publicClient.readContract({
|
|
@@ -85,7 +85,7 @@ class lt {
|
|
|
85
85
|
abi: b,
|
|
86
86
|
functionName: "getLatestOffchainParams"
|
|
87
87
|
}), t = E(e);
|
|
88
|
-
return
|
|
88
|
+
return H(t), t;
|
|
89
89
|
}
|
|
90
90
|
async getOffchainParamsByVersion(e) {
|
|
91
91
|
const t = await this.publicClient.readContract({
|
|
@@ -94,7 +94,7 @@ class lt {
|
|
|
94
94
|
functionName: "getOffchainParamsByVersion",
|
|
95
95
|
args: [e]
|
|
96
96
|
}), n = E(t);
|
|
97
|
-
return
|
|
97
|
+
return H(n), n;
|
|
98
98
|
}
|
|
99
99
|
async getLatestOffchainParamsVersion() {
|
|
100
100
|
const e = await this.publicClient.readContract({
|
|
@@ -102,7 +102,7 @@ class lt {
|
|
|
102
102
|
abi: b,
|
|
103
103
|
functionName: "latestOffchainParamsVersion"
|
|
104
104
|
}), t = Number(e);
|
|
105
|
-
return
|
|
105
|
+
return fe(t), t;
|
|
106
106
|
}
|
|
107
107
|
async getTimelockPeginByVersion(e) {
|
|
108
108
|
const t = await this.getOffchainParamsByVersion(e);
|
|
@@ -135,7 +135,7 @@ class lt {
|
|
|
135
135
|
}
|
|
136
136
|
],
|
|
137
137
|
allowFailure: !1
|
|
138
|
-
}), t = z(e[0]), n = E(e[1]),
|
|
138
|
+
}), t = z(e[0]), n = E(e[1]), s = Number(e[2]), i = {
|
|
139
139
|
minimumPegInAmount: t.minimumPegInAmount,
|
|
140
140
|
maxPegInAmount: t.maxPegInAmount,
|
|
141
141
|
pegInAckTimeout: t.pegInAckTimeout,
|
|
@@ -146,9 +146,9 @@ class lt {
|
|
|
146
146
|
timelockRefund: n.tRefund,
|
|
147
147
|
minVpCommissionBps: n.minVpCommissionBps,
|
|
148
148
|
offchainParams: n,
|
|
149
|
-
offchainParamsVersion:
|
|
149
|
+
offchainParamsVersion: s
|
|
150
150
|
};
|
|
151
|
-
return
|
|
151
|
+
return _e(i), i;
|
|
152
152
|
}
|
|
153
153
|
/**
|
|
154
154
|
* Fetch every historical offchain params version in a single multicall.
|
|
@@ -164,19 +164,19 @@ class lt {
|
|
|
164
164
|
const t = await this.getLatestOffchainParamsVersion();
|
|
165
165
|
if (t === 0)
|
|
166
166
|
return { byVersion: /* @__PURE__ */ new Map(), latestVersion: 0 };
|
|
167
|
-
const n = Array.from({ length: t }, (c, u) => u + 1),
|
|
167
|
+
const n = Array.from({ length: t }, (c, u) => u + 1), s = n.map((c) => ({
|
|
168
168
|
address: this.contractAddress,
|
|
169
169
|
abi: b,
|
|
170
170
|
functionName: "getOffchainParamsByVersion",
|
|
171
171
|
args: [c]
|
|
172
|
-
})),
|
|
173
|
-
contracts:
|
|
172
|
+
})), i = await this.publicClient.multicall({
|
|
173
|
+
contracts: s,
|
|
174
174
|
allowFailure: !1
|
|
175
175
|
}), o = /* @__PURE__ */ new Map();
|
|
176
176
|
for (let c = 0; c < n.length; c++) {
|
|
177
|
-
const u = E(
|
|
177
|
+
const u = E(i[c]);
|
|
178
178
|
try {
|
|
179
|
-
|
|
179
|
+
H(u), o.set(n[c], u);
|
|
180
180
|
} catch (d) {
|
|
181
181
|
e == null || e(
|
|
182
182
|
n[c],
|
|
@@ -200,7 +200,7 @@ class ut {
|
|
|
200
200
|
async getVaultKeepersByVersion(e, t) {
|
|
201
201
|
const n = await this.publicClient.readContract({
|
|
202
202
|
address: this.contractAddress,
|
|
203
|
-
abi:
|
|
203
|
+
abi: B,
|
|
204
204
|
functionName: "getVaultKeepersByVersion",
|
|
205
205
|
args: [e, t]
|
|
206
206
|
});
|
|
@@ -209,7 +209,7 @@ class ut {
|
|
|
209
209
|
async getCurrentVaultKeepers(e) {
|
|
210
210
|
const t = await this.publicClient.readContract({
|
|
211
211
|
address: this.contractAddress,
|
|
212
|
-
abi:
|
|
212
|
+
abi: B,
|
|
213
213
|
functionName: "getCurrentVaultKeepers",
|
|
214
214
|
args: [e]
|
|
215
215
|
});
|
|
@@ -218,7 +218,7 @@ class ut {
|
|
|
218
218
|
async getCurrentVaultKeepersVersion(e) {
|
|
219
219
|
return await this.publicClient.readContract({
|
|
220
220
|
address: this.contractAddress,
|
|
221
|
-
abi:
|
|
221
|
+
abi: B,
|
|
222
222
|
functionName: "getCurrentVaultKeepersVersion",
|
|
223
223
|
args: [e]
|
|
224
224
|
});
|
|
@@ -253,16 +253,16 @@ class dt {
|
|
|
253
253
|
});
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
|
-
var
|
|
257
|
-
const Y = new Set(Object.values(
|
|
256
|
+
var Pe = /* @__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))(Pe || {});
|
|
257
|
+
const Y = new Set(Object.values(me)), xe = 200;
|
|
258
258
|
function l(r) {
|
|
259
259
|
var e;
|
|
260
|
-
return ((e = JSON.stringify(r)) == null ? void 0 : e.slice(0,
|
|
260
|
+
return ((e = JSON.stringify(r)) == null ? void 0 : e.slice(0, xe)) ?? "undefined";
|
|
261
261
|
}
|
|
262
|
-
const
|
|
262
|
+
const ve = "The vault provider returned an unexpected response. Please try again or contact support.";
|
|
263
263
|
class a extends Error {
|
|
264
264
|
constructor(t) {
|
|
265
|
-
super(
|
|
265
|
+
super(ve);
|
|
266
266
|
p(this, "detail");
|
|
267
267
|
this.name = "VpResponseValidationError", this.detail = t;
|
|
268
268
|
}
|
|
@@ -271,17 +271,17 @@ const k = 64;
|
|
|
271
271
|
function P(r) {
|
|
272
272
|
return typeof r == "string" && r.length > 0 && $.test(r);
|
|
273
273
|
}
|
|
274
|
-
function
|
|
274
|
+
function ne(r) {
|
|
275
275
|
return typeof r == "string" && r.length > 0;
|
|
276
276
|
}
|
|
277
|
-
function
|
|
277
|
+
function se(r, e) {
|
|
278
278
|
if (!P(r))
|
|
279
279
|
throw new a(
|
|
280
280
|
`VP response validation failed: "${e}" must be a non-empty hex string, got ${l(r)}`
|
|
281
281
|
);
|
|
282
282
|
}
|
|
283
283
|
function _(r, e) {
|
|
284
|
-
if (!
|
|
284
|
+
if (!ne(r))
|
|
285
285
|
throw new a(
|
|
286
286
|
`VP response validation failed: "${e}" must be a non-empty string, got ${l(r)}`
|
|
287
287
|
);
|
|
@@ -292,7 +292,7 @@ function L(r, e) {
|
|
|
292
292
|
`VP response validation failed: "${e}" must be a ${R} or ${j}-char hex string (BTC pubkey), got ${l(r)}`
|
|
293
293
|
);
|
|
294
294
|
}
|
|
295
|
-
function
|
|
295
|
+
function Ae(r) {
|
|
296
296
|
const e = r.presigning;
|
|
297
297
|
if (e == null) return;
|
|
298
298
|
if (typeof e != "object" || Array.isArray(e))
|
|
@@ -313,7 +313,7 @@ function xe(r) {
|
|
|
313
313
|
`VP response validation failed: "progress.presigning.vk_challenger_presigning_total" must be a number if present, got ${l(t.vk_challenger_presigning_total)}`
|
|
314
314
|
);
|
|
315
315
|
}
|
|
316
|
-
function
|
|
316
|
+
function ie(r) {
|
|
317
317
|
if (r === null || typeof r != "object")
|
|
318
318
|
throw new a(
|
|
319
319
|
"VP response validation failed: getPeginStatus response is not an object"
|
|
@@ -335,7 +335,7 @@ function ne(r) {
|
|
|
335
335
|
throw new a(
|
|
336
336
|
'VP response validation failed: "progress" must be an object'
|
|
337
337
|
);
|
|
338
|
-
if (
|
|
338
|
+
if (Ae(e.progress), typeof e.health_info != "string")
|
|
339
339
|
throw new a(
|
|
340
340
|
'VP response validation failed: "health_info" must be a string'
|
|
341
341
|
);
|
|
@@ -344,7 +344,7 @@ function ne(r) {
|
|
|
344
344
|
`VP response validation failed: "last_error" must be a string if present, got ${l(e.last_error)}`
|
|
345
345
|
);
|
|
346
346
|
}
|
|
347
|
-
function
|
|
347
|
+
function ke(r) {
|
|
348
348
|
if (r === null || typeof r != "object")
|
|
349
349
|
throw new a(
|
|
350
350
|
"VP response validation failed: requestDepositorPresignTransactions response is not an object"
|
|
@@ -355,12 +355,12 @@ function ve(r) {
|
|
|
355
355
|
'VP response validation failed: "txs" must be an array'
|
|
356
356
|
);
|
|
357
357
|
for (let t = 0; t < e.txs.length; t++)
|
|
358
|
-
|
|
358
|
+
$e(e.txs[t], `txs[${t}]`);
|
|
359
359
|
if (e.depositor_graph === null || typeof e.depositor_graph != "object")
|
|
360
360
|
throw new a(
|
|
361
361
|
'VP response validation failed: "depositor_graph" must be an object'
|
|
362
362
|
);
|
|
363
|
-
|
|
363
|
+
Ge(
|
|
364
364
|
e.depositor_graph
|
|
365
365
|
);
|
|
366
366
|
}
|
|
@@ -369,9 +369,9 @@ function y(r, e) {
|
|
|
369
369
|
throw new a(
|
|
370
370
|
`VP response validation failed: "${e}" must be an object`
|
|
371
371
|
);
|
|
372
|
-
|
|
372
|
+
se(r.tx_hex, `${e}.tx_hex`);
|
|
373
373
|
}
|
|
374
|
-
function
|
|
374
|
+
function $e(r, e) {
|
|
375
375
|
if (r === null || typeof r != "object")
|
|
376
376
|
throw new a(
|
|
377
377
|
`VP response validation failed: "${e}" must be an object`
|
|
@@ -379,7 +379,7 @@ function Ae(r, e) {
|
|
|
379
379
|
const t = r;
|
|
380
380
|
L(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`);
|
|
381
381
|
}
|
|
382
|
-
function
|
|
382
|
+
function Se(r, e) {
|
|
383
383
|
if (r === null || typeof r != "object")
|
|
384
384
|
throw new a(
|
|
385
385
|
`VP response validation failed: "${e}" must be an object`
|
|
@@ -387,7 +387,7 @@ function ke(r, e) {
|
|
|
387
387
|
const t = r;
|
|
388
388
|
_(t.wots_pks_json, `${e}.wots_pks_json`), _(t.gc_wots_keys_json, `${e}.gc_wots_keys_json`);
|
|
389
389
|
}
|
|
390
|
-
function
|
|
390
|
+
function Te(r, e) {
|
|
391
391
|
if (r === null || typeof r != "object")
|
|
392
392
|
throw new a(
|
|
393
393
|
`VP response validation failed: "${e}" must be an object`
|
|
@@ -404,7 +404,7 @@ function $e(r, e) {
|
|
|
404
404
|
`VP response validation failed: "${e}.challenge_assert_connectors" must be an array`
|
|
405
405
|
);
|
|
406
406
|
for (let n = 0; n < t.challenge_assert_connectors.length; n++)
|
|
407
|
-
|
|
407
|
+
Se(
|
|
408
408
|
t.challenge_assert_connectors[n],
|
|
409
409
|
`${e}.challenge_assert_connectors[${n}]`
|
|
410
410
|
);
|
|
@@ -413,18 +413,18 @@ function $e(r, e) {
|
|
|
413
413
|
`VP response validation failed: "${e}.output_label_hashes" must be an array`
|
|
414
414
|
);
|
|
415
415
|
for (let n = 0; n < t.output_label_hashes.length; n++)
|
|
416
|
-
|
|
416
|
+
se(
|
|
417
417
|
t.output_label_hashes[n],
|
|
418
418
|
`${e}.output_label_hashes[${n}]`
|
|
419
419
|
);
|
|
420
420
|
}
|
|
421
|
-
function
|
|
421
|
+
function Ve(r) {
|
|
422
422
|
if (r === null || typeof r != "object")
|
|
423
423
|
throw new a(
|
|
424
424
|
"VP response validation failed: requestDepositorClaimerArtifacts response is not an object"
|
|
425
425
|
);
|
|
426
426
|
const e = r;
|
|
427
|
-
if (!
|
|
427
|
+
if (!ne(e.tx_graph_json))
|
|
428
428
|
throw new a(
|
|
429
429
|
`VP response validation failed: "tx_graph_json" must be a non-empty string, got ${l(e.tx_graph_json)}`
|
|
430
430
|
);
|
|
@@ -443,19 +443,19 @@ function Se(r) {
|
|
|
443
443
|
throw new a(
|
|
444
444
|
'VP response validation failed: "babe_sessions" must contain at least one challenger entry'
|
|
445
445
|
);
|
|
446
|
-
for (const [n,
|
|
447
|
-
if (L(n, `babe_sessions["${n}"]`),
|
|
446
|
+
for (const [n, s] of t) {
|
|
447
|
+
if (L(n, `babe_sessions["${n}"]`), s === null || typeof s != "object")
|
|
448
448
|
throw new a(
|
|
449
449
|
`VP response validation failed: "babe_sessions.${n}" must be an object`
|
|
450
450
|
);
|
|
451
|
-
const
|
|
452
|
-
if (!P(
|
|
451
|
+
const i = s;
|
|
452
|
+
if (!P(i.decryptor_artifacts_hex))
|
|
453
453
|
throw new a(
|
|
454
|
-
`VP response validation failed: "babe_sessions.${n}.decryptor_artifacts_hex" must be a non-empty hex string, got ${l(
|
|
454
|
+
`VP response validation failed: "babe_sessions.${n}.decryptor_artifacts_hex" must be a non-empty hex string, got ${l(i.decryptor_artifacts_hex)}`
|
|
455
455
|
);
|
|
456
456
|
}
|
|
457
457
|
}
|
|
458
|
-
function
|
|
458
|
+
function Ee(r) {
|
|
459
459
|
if (r === null || typeof r != "object")
|
|
460
460
|
throw new a(
|
|
461
461
|
"VP response validation failed: pegout status payload is not an object"
|
|
@@ -474,16 +474,16 @@ function Te(r) {
|
|
|
474
474
|
throw new a(
|
|
475
475
|
`VP response validation failed: "claimer" must be an object or null, got ${l(e.claimer)}`
|
|
476
476
|
);
|
|
477
|
-
|
|
477
|
+
Ce(e.claimer);
|
|
478
478
|
}
|
|
479
479
|
if (!Array.isArray(e.challengers))
|
|
480
480
|
throw new a(
|
|
481
481
|
`VP response validation failed: "challengers" must be an array, got ${l(e.challengers)}`
|
|
482
482
|
);
|
|
483
483
|
for (let t = 0; t < e.challengers.length; t++)
|
|
484
|
-
|
|
484
|
+
Ie(e.challengers[t], t);
|
|
485
485
|
}
|
|
486
|
-
function
|
|
486
|
+
function Ce(r) {
|
|
487
487
|
if (_(r.status, "claimer.status"), typeof r.failed != "boolean")
|
|
488
488
|
throw new a(
|
|
489
489
|
`VP response validation failed: "claimer.failed" must be a boolean, got ${l(r.failed)}`
|
|
@@ -497,7 +497,7 @@ function Ve(r) {
|
|
|
497
497
|
`VP response validation failed: "claimer.updated_at" must be a number, got ${l(r.updated_at)}`
|
|
498
498
|
);
|
|
499
499
|
}
|
|
500
|
-
function
|
|
500
|
+
function Ie(r, e) {
|
|
501
501
|
if (r === null || typeof r != "object")
|
|
502
502
|
throw new a(
|
|
503
503
|
`VP response validation failed: "challengers[${e}]" must be an object, got ${l(r)}`
|
|
@@ -524,17 +524,17 @@ function C(r, e) {
|
|
|
524
524
|
`VP response validation failed: "${e}" must be a string or null, got ${l(r)}`
|
|
525
525
|
);
|
|
526
526
|
}
|
|
527
|
-
function
|
|
528
|
-
|
|
529
|
-
e.result !== null &&
|
|
527
|
+
function Re(r) {
|
|
528
|
+
ae(r, "batchGetPeginStatus", (e) => {
|
|
529
|
+
e.result !== null && ie(e.result);
|
|
530
530
|
});
|
|
531
531
|
}
|
|
532
|
-
function
|
|
533
|
-
|
|
534
|
-
e.result !== null &&
|
|
532
|
+
function De(r) {
|
|
533
|
+
ae(r, "batchGetPegoutStatus", (e) => {
|
|
534
|
+
e.result !== null && Ee(e.result);
|
|
535
535
|
});
|
|
536
536
|
}
|
|
537
|
-
function
|
|
537
|
+
function ae(r, e, t) {
|
|
538
538
|
if (r === null || typeof r != "object")
|
|
539
539
|
throw new a(
|
|
540
540
|
`VP response validation failed: ${e} response is not an object`
|
|
@@ -544,39 +544,39 @@ function se(r, e, t) {
|
|
|
544
544
|
throw new a(
|
|
545
545
|
`VP response validation failed: "${e}.results" must be an array, got ${l(n.results)}`
|
|
546
546
|
);
|
|
547
|
-
for (let
|
|
548
|
-
const
|
|
549
|
-
if (
|
|
547
|
+
for (let s = 0; s < n.results.length; s++) {
|
|
548
|
+
const i = n.results[s];
|
|
549
|
+
if (i === null || typeof i != "object")
|
|
550
550
|
throw new a(
|
|
551
|
-
`VP response validation failed: "${e}.results[${
|
|
551
|
+
`VP response validation failed: "${e}.results[${s}]" must be an object, got ${l(i)}`
|
|
552
552
|
);
|
|
553
|
-
const o =
|
|
553
|
+
const o = i;
|
|
554
554
|
if (!P(o.pegin_txid) || o.pegin_txid.length !== k)
|
|
555
555
|
throw new a(
|
|
556
|
-
`VP response validation failed: "${e}.results[${
|
|
556
|
+
`VP response validation failed: "${e}.results[${s}].pegin_txid" must be a ${k}-char hex string, got ${l(o.pegin_txid)}`
|
|
557
557
|
);
|
|
558
558
|
if (o.error !== null && typeof o.error != "string")
|
|
559
559
|
throw new a(
|
|
560
|
-
`VP response validation failed: "${e}.results[${
|
|
560
|
+
`VP response validation failed: "${e}.results[${s}].error" must be a string or null, got ${l(o.error)}`
|
|
561
561
|
);
|
|
562
562
|
if (o.result === null && o.error === null)
|
|
563
563
|
throw new a(
|
|
564
|
-
`VP response validation failed: "${e}.results[${
|
|
564
|
+
`VP response validation failed: "${e}.results[${s}]" has neither "result" nor "error" populated`
|
|
565
565
|
);
|
|
566
566
|
if (o.result !== null && o.error !== null)
|
|
567
567
|
throw new a(
|
|
568
|
-
`VP response validation failed: "${e}.results[${
|
|
568
|
+
`VP response validation failed: "${e}.results[${s}]" has both "result" and "error" populated`
|
|
569
569
|
);
|
|
570
|
-
t(o,
|
|
570
|
+
t(o, s);
|
|
571
571
|
}
|
|
572
572
|
}
|
|
573
|
-
function
|
|
573
|
+
function Ge(r) {
|
|
574
574
|
if (y(r.claim_tx, "depositor_graph.claim_tx"), y(r.assert_tx, "depositor_graph.assert_tx"), y(r.payout_tx, "depositor_graph.payout_tx"), _(r.payout_psbt, "depositor_graph.payout_psbt"), !Array.isArray(r.challenger_presign_data))
|
|
575
575
|
throw new a(
|
|
576
576
|
'VP response validation failed: "depositor_graph.challenger_presign_data" must be an array'
|
|
577
577
|
);
|
|
578
578
|
for (let e = 0; e < r.challenger_presign_data.length; e++)
|
|
579
|
-
|
|
579
|
+
Te(
|
|
580
580
|
r.challenger_presign_data[e],
|
|
581
581
|
`depositor_graph.challenger_presign_data[${e}]`
|
|
582
582
|
);
|
|
@@ -585,13 +585,13 @@ function Re(r) {
|
|
|
585
585
|
'VP response validation failed: "depositor_graph.offchain_params_version" must be a number'
|
|
586
586
|
);
|
|
587
587
|
}
|
|
588
|
-
const
|
|
589
|
-
class
|
|
588
|
+
const Ne = 6e4;
|
|
589
|
+
class Be {
|
|
590
590
|
constructor(e, t) {
|
|
591
591
|
p(this, "client");
|
|
592
592
|
const n = {
|
|
593
593
|
baseUrl: e,
|
|
594
|
-
timeout: (t == null ? void 0 : t.timeout) ??
|
|
594
|
+
timeout: (t == null ? void 0 : t.timeout) ?? Ne,
|
|
595
595
|
retries: t == null ? void 0 : t.retries,
|
|
596
596
|
retryDelay: t == null ? void 0 : t.retryDelay,
|
|
597
597
|
retryableFor: t == null ? void 0 : t.retryableFor,
|
|
@@ -599,7 +599,7 @@ class Ne {
|
|
|
599
599
|
tokenProvider: t == null ? void 0 : t.tokenProvider,
|
|
600
600
|
maxResponseBytes: t == null ? void 0 : t.maxResponseBytes
|
|
601
601
|
};
|
|
602
|
-
this.client = new
|
|
602
|
+
this.client = new re(n);
|
|
603
603
|
}
|
|
604
604
|
/**
|
|
605
605
|
* Request the payout/claim/assert transactions that the depositor
|
|
@@ -607,7 +607,7 @@ class Ne {
|
|
|
607
607
|
*/
|
|
608
608
|
async requestDepositorPresignTransactions(e, t) {
|
|
609
609
|
const n = await this.client.call("vaultProvider_requestDepositorPresignTransactions", e, t);
|
|
610
|
-
return
|
|
610
|
+
return ke(n), n;
|
|
611
611
|
}
|
|
612
612
|
/**
|
|
613
613
|
* Submit the depositor's pre-signatures for the payout transactions
|
|
@@ -638,7 +638,7 @@ class Ne {
|
|
|
638
638
|
*/
|
|
639
639
|
async requestDepositorClaimerArtifacts(e, t) {
|
|
640
640
|
const n = await this.client.call("vaultProvider_requestDepositorClaimerArtifacts", e, t);
|
|
641
|
-
return
|
|
641
|
+
return Ve(n), n;
|
|
642
642
|
}
|
|
643
643
|
/** Get the current pegin status from the vault provider daemon. */
|
|
644
644
|
async getPeginStatus(e, t) {
|
|
@@ -647,7 +647,7 @@ class Ne {
|
|
|
647
647
|
e,
|
|
648
648
|
t
|
|
649
649
|
);
|
|
650
|
-
return
|
|
650
|
+
return ie(n), n;
|
|
651
651
|
}
|
|
652
652
|
/**
|
|
653
653
|
* Get pegin status for many txids in one round trip. Per-result envelope
|
|
@@ -656,7 +656,7 @@ class Ne {
|
|
|
656
656
|
*/
|
|
657
657
|
async batchGetPeginStatus(e, t) {
|
|
658
658
|
const n = await this.client.call("vaultProvider_batchGetPeginStatus", e, t);
|
|
659
|
-
return
|
|
659
|
+
return Re(n), n;
|
|
660
660
|
}
|
|
661
661
|
/**
|
|
662
662
|
* Get pegout status for many txids in one round trip. Same per-result
|
|
@@ -664,58 +664,58 @@ class Ne {
|
|
|
664
664
|
*/
|
|
665
665
|
async batchGetPegoutStatus(e, t) {
|
|
666
666
|
const n = await this.client.call("vaultProvider_batchGetPegoutStatus", e, t);
|
|
667
|
-
return
|
|
667
|
+
return De(n), n;
|
|
668
668
|
}
|
|
669
669
|
}
|
|
670
|
-
function
|
|
670
|
+
function He(r, e) {
|
|
671
671
|
const t = /* @__PURE__ */ new Set();
|
|
672
672
|
for (const u of r)
|
|
673
673
|
t.add(u.toLowerCase());
|
|
674
|
-
const n = /* @__PURE__ */ new Map(),
|
|
674
|
+
const n = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Set(), i = [], o = [];
|
|
675
675
|
for (const u of e) {
|
|
676
676
|
const d = u.pegin_txid.toLowerCase();
|
|
677
677
|
if (!t.has(d)) {
|
|
678
678
|
o.push(d);
|
|
679
679
|
continue;
|
|
680
680
|
}
|
|
681
|
-
if (
|
|
682
|
-
|
|
681
|
+
if (s.has(d)) {
|
|
682
|
+
i.push(d);
|
|
683
683
|
continue;
|
|
684
684
|
}
|
|
685
|
-
|
|
685
|
+
s.add(d), n.set(d, { result: u.result, error: u.error });
|
|
686
686
|
}
|
|
687
687
|
const c = [];
|
|
688
688
|
for (const u of t)
|
|
689
|
-
|
|
690
|
-
return { byTxid: n, missing: c, unexpected: o, duplicate:
|
|
689
|
+
s.has(u) || c.push(u);
|
|
690
|
+
return { byTxid: n, missing: c, unexpected: o, duplicate: i };
|
|
691
691
|
}
|
|
692
692
|
async function pt(r) {
|
|
693
693
|
const {
|
|
694
694
|
items: e,
|
|
695
695
|
getTxid: t,
|
|
696
696
|
batchCall: n,
|
|
697
|
-
onItem:
|
|
698
|
-
onMissing:
|
|
697
|
+
onItem: s,
|
|
698
|
+
onMissing: i,
|
|
699
699
|
onDuplicate: o,
|
|
700
700
|
onDuplicateBatch: c,
|
|
701
701
|
onWholeBatchError: u,
|
|
702
702
|
onUnexpected: d,
|
|
703
|
-
batchSize: f =
|
|
703
|
+
batchSize: f = be
|
|
704
704
|
} = r;
|
|
705
705
|
if (!Number.isInteger(f) || f <= 0)
|
|
706
706
|
throw new Error(
|
|
707
707
|
`batchPollByProvider: batchSize must be a positive integer, got ${f}`
|
|
708
708
|
);
|
|
709
709
|
for (let w = 0; w < e.length; w += f) {
|
|
710
|
-
const x = e.slice(w, w + f), S = /* @__PURE__ */ new Map(),
|
|
710
|
+
const x = e.slice(w, w + f), S = /* @__PURE__ */ new Map(), N = [];
|
|
711
711
|
for (const h of x) {
|
|
712
712
|
const m = t(h).toLowerCase();
|
|
713
|
-
S.set(m, h),
|
|
713
|
+
S.set(m, h), N.push(m);
|
|
714
714
|
}
|
|
715
715
|
let v;
|
|
716
716
|
try {
|
|
717
|
-
const h = await n(
|
|
718
|
-
v =
|
|
717
|
+
const h = await n(N);
|
|
718
|
+
v = He(N, h.results);
|
|
719
719
|
} catch (h) {
|
|
720
720
|
u(x, h);
|
|
721
721
|
continue;
|
|
@@ -729,12 +729,12 @@ async function pt(r) {
|
|
|
729
729
|
c && T.size > 0 && c(T.size);
|
|
730
730
|
for (const h of v.missing) {
|
|
731
731
|
const m = S.get(h);
|
|
732
|
-
m &&
|
|
732
|
+
m && i(m);
|
|
733
733
|
}
|
|
734
734
|
for (const [h, m] of v.byTxid) {
|
|
735
735
|
if (T.has(h)) continue;
|
|
736
736
|
const K = S.get(h);
|
|
737
|
-
K &&
|
|
737
|
+
K && s(K, {
|
|
738
738
|
pegin_txid: h,
|
|
739
739
|
result: m.result,
|
|
740
740
|
error: m.error
|
|
@@ -742,24 +742,24 @@ async function pt(r) {
|
|
|
742
742
|
}
|
|
743
743
|
}
|
|
744
744
|
}
|
|
745
|
-
const
|
|
746
|
-
function
|
|
747
|
-
const t = new TextEncoder().encode(r), n = q(t),
|
|
748
|
-
return
|
|
745
|
+
const Oe = "BIP0322-signed-message", je = "TapTweak", oe = 32, Me = 64;
|
|
746
|
+
function ce(r, e) {
|
|
747
|
+
const t = new TextEncoder().encode(r), n = q(t), s = new Uint8Array(n.length * 2 + e.length);
|
|
748
|
+
return s.set(n, 0), s.set(n, n.length), s.set(e, n.length * 2), q(s);
|
|
749
749
|
}
|
|
750
|
-
function
|
|
751
|
-
if (r.length !==
|
|
752
|
-
const e =
|
|
750
|
+
function Ue(r) {
|
|
751
|
+
if (r.length !== oe) return null;
|
|
752
|
+
const e = ce(je, r), t = F.xOnlyPointAddTweak(r, e);
|
|
753
753
|
return t ? t.xOnlyPubkey : null;
|
|
754
754
|
}
|
|
755
|
-
function
|
|
756
|
-
if (e.length !==
|
|
755
|
+
function Fe(r, e, t) {
|
|
756
|
+
if (e.length !== oe || t.length !== Me) return !1;
|
|
757
757
|
try {
|
|
758
|
-
const n =
|
|
758
|
+
const n = ce(Oe, r), s = we.p2tr({
|
|
759
759
|
internalPubkey: A.from(e)
|
|
760
760
|
});
|
|
761
|
-
if (!
|
|
762
|
-
const
|
|
761
|
+
if (!s.output) return !1;
|
|
762
|
+
const i = s.output, o = 0, c = new O();
|
|
763
763
|
c.version = 0, c.locktime = 0;
|
|
764
764
|
const u = A.concat([
|
|
765
765
|
A.from([0, 32]),
|
|
@@ -773,71 +773,71 @@ function Me(r, e, t) {
|
|
|
773
773
|
0,
|
|
774
774
|
// sequence = 0
|
|
775
775
|
u
|
|
776
|
-
), c.addOutput(
|
|
776
|
+
), c.addOutput(i, o);
|
|
777
777
|
const d = new O();
|
|
778
778
|
d.version = 0, d.locktime = 0;
|
|
779
779
|
const f = c.getHash();
|
|
780
780
|
d.addInput(f, 0, 0), d.addOutput(A.from([106]), o);
|
|
781
781
|
const w = d.hashForWitnessV1(
|
|
782
782
|
0,
|
|
783
|
-
[
|
|
783
|
+
[i],
|
|
784
784
|
[o],
|
|
785
785
|
O.SIGHASH_DEFAULT
|
|
786
|
-
), x =
|
|
786
|
+
), x = Ue(e);
|
|
787
787
|
return x ? F.verifySchnorr(w, x, t) : !1;
|
|
788
788
|
} catch {
|
|
789
789
|
return !1;
|
|
790
790
|
}
|
|
791
791
|
}
|
|
792
|
-
function
|
|
792
|
+
function G(r, e) {
|
|
793
793
|
const t = (r & 7) << 5, n = typeof e == "bigint" ? e : BigInt(e);
|
|
794
794
|
if (n < 0n) throw new Error("cborHead: negative argument");
|
|
795
795
|
if (n < 24n) return new Uint8Array([t | Number(n)]);
|
|
796
796
|
if (n < 0x100n) return new Uint8Array([t | 24, Number(n)]);
|
|
797
797
|
if (n < 0x10000n) {
|
|
798
|
-
const
|
|
799
|
-
return new Uint8Array([t | 25,
|
|
798
|
+
const i = Number(n);
|
|
799
|
+
return new Uint8Array([t | 25, i >>> 8 & 255, i & 255]);
|
|
800
800
|
}
|
|
801
801
|
if (n < 0x100000000n) {
|
|
802
|
-
const
|
|
802
|
+
const i = Number(n);
|
|
803
803
|
return new Uint8Array([
|
|
804
804
|
t | 26,
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
805
|
+
i >>> 24 & 255,
|
|
806
|
+
i >>> 16 & 255,
|
|
807
|
+
i >>> 8 & 255,
|
|
808
|
+
i & 255
|
|
809
809
|
]);
|
|
810
810
|
}
|
|
811
|
-
const
|
|
812
|
-
|
|
813
|
-
for (let
|
|
814
|
-
|
|
815
|
-
return
|
|
811
|
+
const s = new Uint8Array(9);
|
|
812
|
+
s[0] = t | 27;
|
|
813
|
+
for (let i = 7; i >= 0; i--)
|
|
814
|
+
s[1 + i] = Number(n >> BigInt((7 - i) * 8)) & 255;
|
|
815
|
+
return s;
|
|
816
816
|
}
|
|
817
|
-
function
|
|
818
|
-
const e = r.reduce((
|
|
817
|
+
function le(...r) {
|
|
818
|
+
const e = r.reduce((s, i) => s + i.length, 0), t = new Uint8Array(e);
|
|
819
819
|
let n = 0;
|
|
820
|
-
for (const
|
|
821
|
-
t.set(
|
|
820
|
+
for (const s of r)
|
|
821
|
+
t.set(s, n), n += s.length;
|
|
822
822
|
return t;
|
|
823
823
|
}
|
|
824
824
|
function Z(r) {
|
|
825
|
-
const t = [
|
|
825
|
+
const t = [G(4, r.length)];
|
|
826
826
|
for (const n of r)
|
|
827
|
-
t.push(
|
|
828
|
-
return
|
|
827
|
+
t.push(G(0, n));
|
|
828
|
+
return le(...t);
|
|
829
829
|
}
|
|
830
|
-
function
|
|
830
|
+
function Le(r, e, t) {
|
|
831
831
|
if (!Number.isSafeInteger(t) || t < 0)
|
|
832
832
|
throw new Error(
|
|
833
833
|
`encodeServerIdentityPayload: expires_at must be a non-negative safe integer, got ${t}`
|
|
834
834
|
);
|
|
835
|
-
const n =
|
|
836
|
-
return
|
|
835
|
+
const n = G(4, 3), s = Z(r), i = Z(e), o = G(0, t);
|
|
836
|
+
return le(n, s, i, o);
|
|
837
837
|
}
|
|
838
|
-
const
|
|
838
|
+
const Ke = new TextEncoder().encode(
|
|
839
839
|
"btc-auth.server-identity.v1"
|
|
840
|
-
),
|
|
840
|
+
), Xe = 2 * 3600;
|
|
841
841
|
class g extends Error {
|
|
842
842
|
constructor(e, t) {
|
|
843
843
|
super(e), this.reason = t, this.name = "ServerIdentityError";
|
|
@@ -849,11 +849,11 @@ function I(r) {
|
|
|
849
849
|
e[t] = parseInt(r.slice(t * 2, t * 2 + 2), 16);
|
|
850
850
|
return e;
|
|
851
851
|
}
|
|
852
|
-
function
|
|
853
|
-
const { proof: e, pinnedServerPubkey: t, now: n } = r,
|
|
854
|
-
if (
|
|
852
|
+
function qe(r) {
|
|
853
|
+
const { proof: e, pinnedServerPubkey: t, now: n } = r, s = r.maxLifetimeSecs ?? Xe, i = V(t).toLowerCase();
|
|
854
|
+
if (i.length !== R || !$.test(i))
|
|
855
855
|
throw new g(
|
|
856
|
-
`pinnedServerPubkey must be 32-byte hex; got ${
|
|
856
|
+
`pinnedServerPubkey must be 32-byte hex; got ${i.length} chars`,
|
|
857
857
|
"invalid_pubkey_encoding"
|
|
858
858
|
);
|
|
859
859
|
const o = V(e.server_pubkey).toLowerCase();
|
|
@@ -862,9 +862,9 @@ function Ke(r) {
|
|
|
862
862
|
`server_pubkey must be 32-byte hex; got ${o.length} chars`,
|
|
863
863
|
"invalid_pubkey_encoding"
|
|
864
864
|
);
|
|
865
|
-
if (o !==
|
|
865
|
+
if (o !== i)
|
|
866
866
|
throw new g(
|
|
867
|
-
`server_pubkey does not match pinned value: expected ${
|
|
867
|
+
`server_pubkey does not match pinned value: expected ${i}, got ${o}`,
|
|
868
868
|
"pinned_pubkey_mismatch"
|
|
869
869
|
);
|
|
870
870
|
if (!Number.isSafeInteger(e.expires_at))
|
|
@@ -882,14 +882,14 @@ function Ke(r) {
|
|
|
882
882
|
`server identity proof expired at ${e.expires_at}, now ${n}`,
|
|
883
883
|
"expired"
|
|
884
884
|
);
|
|
885
|
-
if (!Number.isSafeInteger(
|
|
885
|
+
if (!Number.isSafeInteger(s) || s <= 0)
|
|
886
886
|
throw new g(
|
|
887
|
-
`maxLifetimeSecs must be a positive safe integer; got ${JSON.stringify(
|
|
887
|
+
`maxLifetimeSecs must be a positive safe integer; got ${JSON.stringify(s)}`,
|
|
888
888
|
"invalid_max_lifetime"
|
|
889
889
|
);
|
|
890
|
-
if (e.expires_at - n >
|
|
890
|
+
if (e.expires_at - n > s)
|
|
891
891
|
throw new g(
|
|
892
|
-
`server identity proof expires too far in the future: expires_at=${e.expires_at}, now=${n}, max lifetime=${
|
|
892
|
+
`server identity proof expires too far in the future: expires_at=${e.expires_at}, now=${n}, max lifetime=${s}s`,
|
|
893
893
|
"expires_too_far"
|
|
894
894
|
);
|
|
895
895
|
const c = V(e.ephemeral_pubkey).toLowerCase();
|
|
@@ -911,38 +911,38 @@ function Ke(r) {
|
|
|
911
911
|
"invalid_ephemeral_pubkey"
|
|
912
912
|
);
|
|
913
913
|
const f = V(e.signature).toLowerCase();
|
|
914
|
-
if (f.length !==
|
|
914
|
+
if (f.length !== ye || !$.test(f))
|
|
915
915
|
throw new g(
|
|
916
916
|
`signature must be 64-byte Schnorr hex; got ${f.length} chars`,
|
|
917
917
|
"invalid_signature_encoding"
|
|
918
918
|
);
|
|
919
|
-
const w =
|
|
920
|
-
|
|
919
|
+
const w = Le(
|
|
920
|
+
Ke,
|
|
921
921
|
I(c),
|
|
922
922
|
e.expires_at
|
|
923
923
|
);
|
|
924
|
-
if (!
|
|
924
|
+
if (!Fe(w, I(o), I(f)))
|
|
925
925
|
throw new g(
|
|
926
926
|
"BIP-322 signature verification failed — ephemeral key is not attested by pinned server pubkey",
|
|
927
927
|
"signature_verification_failed"
|
|
928
928
|
);
|
|
929
929
|
}
|
|
930
|
-
const
|
|
930
|
+
const Q = /* @__PURE__ */ new Set([
|
|
931
931
|
"vaultProvider_submitDepositorWotsKey",
|
|
932
932
|
"vaultProvider_submitDepositorPresignatures",
|
|
933
933
|
"vaultProvider_requestDepositorPresignTransactions"
|
|
934
|
-
]),
|
|
934
|
+
]), ee = /* @__PURE__ */ new Set([
|
|
935
935
|
"vaultProvider_requestDepositorClaimerArtifacts"
|
|
936
936
|
]), Je = 6e4, M = "auth_createDepositorToken", U = "auth_createDepositorTokenGrpc";
|
|
937
|
-
function
|
|
938
|
-
return new
|
|
937
|
+
function ue(r, e) {
|
|
938
|
+
return new re({
|
|
939
939
|
baseUrl: r,
|
|
940
940
|
timeout: Je,
|
|
941
941
|
headers: e,
|
|
942
942
|
retryableFor: (t) => t === M || t === U
|
|
943
943
|
});
|
|
944
944
|
}
|
|
945
|
-
const
|
|
945
|
+
const te = 4102444800, ze = 30;
|
|
946
946
|
class We {
|
|
947
947
|
constructor(e) {
|
|
948
948
|
// `client` is the only mutable field — see `setClient`. The
|
|
@@ -1016,35 +1016,35 @@ class We {
|
|
|
1016
1016
|
acquireSingleFlight(e) {
|
|
1017
1017
|
const t = e === "grpc" ? this.inFlightGrpc : this.inFlightJsonRpc;
|
|
1018
1018
|
if (t) return t;
|
|
1019
|
-
const n = e === "grpc" ? U : M,
|
|
1019
|
+
const n = e === "grpc" ? U : M, s = (async () => {
|
|
1020
1020
|
try {
|
|
1021
|
-
const
|
|
1021
|
+
const i = await this.client.call(n, {
|
|
1022
1022
|
pegin_txid: this.peginTxid,
|
|
1023
1023
|
auth_anchor: this.authAnchorHex
|
|
1024
1024
|
});
|
|
1025
|
-
if (
|
|
1026
|
-
proof:
|
|
1025
|
+
if (qe({
|
|
1026
|
+
proof: i.server_identity,
|
|
1027
1027
|
pinnedServerPubkey: this.pinnedServerPubkey,
|
|
1028
1028
|
now: this.now()
|
|
1029
|
-
}), typeof
|
|
1029
|
+
}), typeof i.token != "string" || i.token.length === 0)
|
|
1030
1030
|
throw new Error(
|
|
1031
|
-
`VpTokenProvider: invalid token in acquire response (expected non-empty string, got ${typeof
|
|
1031
|
+
`VpTokenProvider: invalid token in acquire response (expected non-empty string, got ${typeof i.token})`
|
|
1032
1032
|
);
|
|
1033
1033
|
const o = this.now();
|
|
1034
|
-
if (!Number.isSafeInteger(
|
|
1034
|
+
if (!Number.isSafeInteger(i.expires_at) || i.expires_at <= o || i.expires_at > te)
|
|
1035
1035
|
throw new Error(
|
|
1036
|
-
`VpTokenProvider: invalid expires_at in acquire response (got ${JSON.stringify(
|
|
1036
|
+
`VpTokenProvider: invalid expires_at in acquire response (got ${JSON.stringify(i.expires_at)}; must be a safe integer in (${o}, ${te}])`
|
|
1037
1037
|
);
|
|
1038
1038
|
const c = {
|
|
1039
|
-
token:
|
|
1040
|
-
expiresAt:
|
|
1039
|
+
token: i.token,
|
|
1040
|
+
expiresAt: i.expires_at
|
|
1041
1041
|
};
|
|
1042
1042
|
return e === "grpc" ? this.cachedGrpc = c : this.cachedJsonRpc = c, c;
|
|
1043
1043
|
} finally {
|
|
1044
1044
|
e === "grpc" ? this.inFlightGrpc = null : this.inFlightJsonRpc = null;
|
|
1045
1045
|
}
|
|
1046
1046
|
})();
|
|
1047
|
-
return e === "grpc" ? this.inFlightGrpc =
|
|
1047
|
+
return e === "grpc" ? this.inFlightGrpc = s : this.inFlightJsonRpc = s, s;
|
|
1048
1048
|
}
|
|
1049
1049
|
}
|
|
1050
1050
|
class Ye {
|
|
@@ -1053,37 +1053,43 @@ class Ye {
|
|
|
1053
1053
|
}
|
|
1054
1054
|
/**
|
|
1055
1055
|
* Return the cached `VpTokenProvider` for `peginTxid` if one exists
|
|
1056
|
-
* with matching `authAnchorHex
|
|
1057
|
-
* construct and cache a fresh
|
|
1058
|
-
* throws — silent overwrite would
|
|
1059
|
-
* pubkey rotation
|
|
1056
|
+
* with matching `authAnchorHex`, `pinnedServerPubkey`, and
|
|
1057
|
+
* `enableGrpcArtifactAuth`, otherwise construct and cache a fresh
|
|
1058
|
+
* provider. A mismatch on any of those throws — silent overwrite would
|
|
1059
|
+
* mask derivation drift, VP pubkey rotation, or a caller that disagrees
|
|
1060
|
+
* on the auth subject (which the cached provider can't switch).
|
|
1060
1061
|
*/
|
|
1061
1062
|
getOrCreate(e) {
|
|
1062
|
-
const t = this.entries.get(e.peginTxid);
|
|
1063
|
-
if (
|
|
1064
|
-
if (
|
|
1063
|
+
const t = e.enableGrpcArtifactAuth ?? !1, n = this.entries.get(e.peginTxid);
|
|
1064
|
+
if (n) {
|
|
1065
|
+
if (n.authAnchorHex !== e.authAnchorHex)
|
|
1065
1066
|
throw new Error(
|
|
1066
|
-
`VpTokenRegistry: peginTxid ${e.peginTxid} already bound to authAnchorHex ${
|
|
1067
|
+
`VpTokenRegistry: peginTxid ${e.peginTxid} already bound to authAnchorHex ${n.authAnchorHex.slice(0, 8)}…; got ${e.authAnchorHex.slice(0, 8)}…`
|
|
1067
1068
|
);
|
|
1068
|
-
if (
|
|
1069
|
+
if (n.pinnedServerPubkey !== e.pinnedServerPubkey)
|
|
1069
1070
|
throw new Error(
|
|
1070
|
-
`VpTokenRegistry: peginTxid ${e.peginTxid} already bound to pinnedServerPubkey ${
|
|
1071
|
+
`VpTokenRegistry: peginTxid ${e.peginTxid} already bound to pinnedServerPubkey ${n.pinnedServerPubkey.slice(0, 8)}…; got ${e.pinnedServerPubkey.slice(0, 8)}…`
|
|
1071
1072
|
);
|
|
1072
|
-
|
|
1073
|
+
if (n.enableGrpcArtifactAuth !== t)
|
|
1074
|
+
throw new Error(
|
|
1075
|
+
`VpTokenRegistry: peginTxid ${e.peginTxid} already bound to enableGrpcArtifactAuth=${n.enableGrpcArtifactAuth}; got ${t}`
|
|
1076
|
+
);
|
|
1077
|
+
return n.provider.setClient(e.client), n.provider;
|
|
1073
1078
|
}
|
|
1074
|
-
const
|
|
1079
|
+
const s = new We({
|
|
1075
1080
|
client: e.client,
|
|
1076
1081
|
peginTxid: e.peginTxid,
|
|
1077
1082
|
authAnchorHex: e.authAnchorHex,
|
|
1078
1083
|
pinnedServerPubkey: e.pinnedServerPubkey,
|
|
1079
|
-
authGatedMethods:
|
|
1080
|
-
grpcGatedMethods:
|
|
1084
|
+
authGatedMethods: t ? Q : /* @__PURE__ */ new Set([...Q, ...ee]),
|
|
1085
|
+
grpcGatedMethods: t ? ee : /* @__PURE__ */ new Set()
|
|
1081
1086
|
});
|
|
1082
1087
|
return this.entries.set(e.peginTxid, {
|
|
1083
|
-
provider:
|
|
1088
|
+
provider: s,
|
|
1084
1089
|
authAnchorHex: e.authAnchorHex,
|
|
1085
|
-
pinnedServerPubkey: e.pinnedServerPubkey
|
|
1086
|
-
|
|
1090
|
+
pinnedServerPubkey: e.pinnedServerPubkey,
|
|
1091
|
+
enableGrpcArtifactAuth: t
|
|
1092
|
+
}), s;
|
|
1087
1093
|
}
|
|
1088
1094
|
/** Return the cached provider, or `undefined` if none. */
|
|
1089
1095
|
peek(e) {
|
|
@@ -1111,46 +1117,48 @@ class Ye {
|
|
|
1111
1117
|
return this.entries.size;
|
|
1112
1118
|
}
|
|
1113
1119
|
}
|
|
1114
|
-
const
|
|
1120
|
+
const de = new Ye();
|
|
1115
1121
|
function ht(r) {
|
|
1116
1122
|
var n;
|
|
1117
|
-
const e =
|
|
1123
|
+
const e = ue(
|
|
1118
1124
|
r.baseUrl,
|
|
1119
1125
|
(n = r.options) == null ? void 0 : n.headers
|
|
1120
|
-
), t =
|
|
1126
|
+
), t = de.getOrCreate({
|
|
1121
1127
|
client: e,
|
|
1122
1128
|
peginTxid: r.peginTxid,
|
|
1123
1129
|
authAnchorHex: r.authAnchorHex,
|
|
1124
|
-
pinnedServerPubkey: r.pinnedServerPubkey
|
|
1130
|
+
pinnedServerPubkey: r.pinnedServerPubkey,
|
|
1131
|
+
enableGrpcArtifactAuth: r.enableGrpcArtifactAuth
|
|
1125
1132
|
});
|
|
1126
|
-
return new
|
|
1133
|
+
return new Be(r.baseUrl, {
|
|
1127
1134
|
...r.options,
|
|
1128
1135
|
tokenProvider: t
|
|
1129
1136
|
});
|
|
1130
1137
|
}
|
|
1131
1138
|
function gt(r) {
|
|
1132
|
-
|
|
1133
|
-
client:
|
|
1139
|
+
de.getOrCreate({
|
|
1140
|
+
client: ue(r.baseUrl, r.headers),
|
|
1134
1141
|
peginTxid: r.peginTxid,
|
|
1135
1142
|
authAnchorHex: r.authAnchorHex,
|
|
1136
|
-
pinnedServerPubkey: r.pinnedServerPubkey
|
|
1143
|
+
pinnedServerPubkey: r.pinnedServerPubkey,
|
|
1144
|
+
enableGrpcArtifactAuth: r.enableGrpcArtifactAuth
|
|
1137
1145
|
});
|
|
1138
1146
|
}
|
|
1139
1147
|
export {
|
|
1140
|
-
|
|
1148
|
+
Pe as O,
|
|
1141
1149
|
g as S,
|
|
1142
|
-
|
|
1150
|
+
Be as V,
|
|
1143
1151
|
a,
|
|
1144
1152
|
pt as b,
|
|
1145
|
-
|
|
1153
|
+
qe as c,
|
|
1146
1154
|
Ye as d,
|
|
1147
|
-
|
|
1155
|
+
de as e,
|
|
1148
1156
|
ht as f,
|
|
1149
1157
|
lt as g,
|
|
1150
1158
|
dt as h,
|
|
1151
1159
|
ut as i,
|
|
1152
1160
|
gt as p,
|
|
1153
1161
|
ct as r,
|
|
1154
|
-
|
|
1162
|
+
Ve as v
|
|
1155
1163
|
};
|
|
1156
|
-
//# sourceMappingURL=primeVpAuth-
|
|
1164
|
+
//# sourceMappingURL=primeVpAuth-rbejoBPu.js.map
|