@babylonlabs-io/ts-sdk 0.43.0 → 0.45.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.
Files changed (87) hide show
  1. package/README.md +0 -1
  2. package/dist/{BTCVaultRegistry.abi-Cq9-JlqT.js → BTCVaultRegistry.abi-Chs4AFBj.js} +125 -2
  3. package/dist/BTCVaultRegistry.abi-Chs4AFBj.js.map +1 -0
  4. package/dist/{BTCVaultRegistry.abi-CHFGevwa.cjs → BTCVaultRegistry.abi-JdeqLz4x.cjs} +2 -2
  5. package/dist/BTCVaultRegistry.abi-JdeqLz4x.cjs.map +1 -0
  6. package/dist/{PeginManager-BezsAEDe.js → PeginManager-CFGjwYtC.js} +4 -4
  7. package/dist/{PeginManager-BezsAEDe.js.map → PeginManager-CFGjwYtC.js.map} +1 -1
  8. package/dist/{PeginManager-D-8vmqzq.cjs → PeginManager-CL1Esl1c.cjs} +2 -2
  9. package/dist/{PeginManager-D-8vmqzq.cjs.map → PeginManager-CL1Esl1c.cjs.map} +1 -1
  10. package/dist/{buildAndBroadcastRefund-37Bs7-V1.js → buildAndBroadcastRefund-CZj2z7PJ.js} +2 -2
  11. package/dist/{buildAndBroadcastRefund-37Bs7-V1.js.map → buildAndBroadcastRefund-CZj2z7PJ.js.map} +1 -1
  12. package/dist/{buildAndBroadcastRefund-DbcNEsOv.cjs → buildAndBroadcastRefund-Ux587SFf.cjs} +2 -2
  13. package/dist/{buildAndBroadcastRefund-DbcNEsOv.cjs.map → buildAndBroadcastRefund-Ux587SFf.cjs.map} +1 -1
  14. package/dist/{errors-CznAK5NB.js → errors-Blc-JWnI.js} +71 -46
  15. package/dist/errors-Blc-JWnI.js.map +1 -0
  16. package/dist/errors-CGcNP0rV.cjs +2 -0
  17. package/dist/errors-CGcNP0rV.cjs.map +1 -0
  18. package/dist/index.cjs +1 -1
  19. package/dist/index.js +106 -107
  20. package/dist/{mempoolApi-CknccHKg.cjs → mempoolApi-DcHws8jJ.cjs} +2 -2
  21. package/dist/{mempoolApi-CknccHKg.cjs.map → mempoolApi-DcHws8jJ.cjs.map} +1 -1
  22. package/dist/{mempoolApi-DI9HISqi.js → mempoolApi-DnP7d084.js} +2 -2
  23. package/dist/{mempoolApi-DI9HISqi.js.map → mempoolApi-DnP7d084.js.map} +1 -1
  24. package/dist/primeVpAuth-BihAGyNf.cjs +2 -0
  25. package/dist/{primeVpAuth-Duds3vAO.cjs.map → primeVpAuth-BihAGyNf.cjs.map} +1 -1
  26. package/dist/{primeVpAuth-qEC9TTO_.js → primeVpAuth-DXl9wGBR.js} +361 -341
  27. package/dist/{primeVpAuth-qEC9TTO_.js.map → primeVpAuth-DXl9wGBR.js.map} +1 -1
  28. package/dist/reservation-BxvKbQH2.js +107 -0
  29. package/dist/reservation-BxvKbQH2.js.map +1 -0
  30. package/dist/reservation-xTL2a9Q-.cjs +2 -0
  31. package/dist/reservation-xTL2a9Q-.cjs.map +1 -0
  32. package/dist/tbv/core/clients/index.cjs +1 -1
  33. package/dist/tbv/core/clients/index.js +2 -2
  34. package/dist/tbv/core/clients/vault-provider/auth/gatedMethods.d.ts +12 -0
  35. package/dist/tbv/core/clients/vault-provider/auth/gatedMethods.d.ts.map +1 -1
  36. package/dist/tbv/core/clients/vault-provider/auth/innerTokenClient.d.ts +8 -0
  37. package/dist/tbv/core/clients/vault-provider/auth/innerTokenClient.d.ts.map +1 -1
  38. package/dist/tbv/core/clients/vault-provider/auth/tokenProvider.d.ts +42 -13
  39. package/dist/tbv/core/clients/vault-provider/auth/tokenProvider.d.ts.map +1 -1
  40. package/dist/tbv/core/clients/vault-provider/auth/tokenRegistry.d.ts.map +1 -1
  41. package/dist/tbv/core/contracts/__tests__/errors.test.d.ts +2 -0
  42. package/dist/tbv/core/contracts/__tests__/errors.test.d.ts.map +1 -0
  43. package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts +292 -0
  44. package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts.map +1 -1
  45. package/dist/tbv/core/contracts/errors.d.ts.map +1 -1
  46. package/dist/tbv/core/contracts/index.cjs +1 -1
  47. package/dist/tbv/core/contracts/index.js +2 -2
  48. package/dist/tbv/core/index.cjs +1 -1
  49. package/dist/tbv/core/index.js +102 -103
  50. package/dist/tbv/core/managers/index.cjs +1 -1
  51. package/dist/tbv/core/managers/index.js +1 -1
  52. package/dist/tbv/core/services/index.cjs +1 -1
  53. package/dist/tbv/core/services/index.js +1 -1
  54. package/dist/tbv/core/utils/index.cjs +1 -1
  55. package/dist/tbv/core/utils/index.js +32 -33
  56. package/dist/tbv/core/utils/utxo/__tests__/reservation.test.d.ts +0 -1
  57. package/dist/tbv/core/utils/utxo/__tests__/reservation.test.d.ts.map +1 -1
  58. package/dist/tbv/core/utils/utxo/availability.d.ts +22 -1
  59. package/dist/tbv/core/utils/utxo/availability.d.ts.map +1 -1
  60. package/dist/tbv/core/utils/utxo/reservation.d.ts +11 -86
  61. package/dist/tbv/core/utils/utxo/reservation.d.ts.map +1 -1
  62. package/dist/tbv/index.cjs +1 -1
  63. package/dist/tbv/index.js +102 -103
  64. package/dist/tbv/integrations/aave/clients/__tests__/oracle.test.d.ts +2 -0
  65. package/dist/tbv/integrations/aave/clients/__tests__/oracle.test.d.ts.map +1 -0
  66. package/dist/tbv/integrations/aave/clients/abis/AaveOracle.abi.json.d.ts +36 -0
  67. package/dist/tbv/integrations/aave/clients/index.d.ts +1 -0
  68. package/dist/tbv/integrations/aave/clients/index.d.ts.map +1 -1
  69. package/dist/tbv/integrations/aave/clients/oracle.d.ts +14 -0
  70. package/dist/tbv/integrations/aave/clients/oracle.d.ts.map +1 -0
  71. package/dist/tbv/integrations/aave/index.cjs +1 -1
  72. package/dist/tbv/integrations/aave/index.cjs.map +1 -1
  73. package/dist/tbv/integrations/aave/index.d.ts +1 -1
  74. package/dist/tbv/integrations/aave/index.d.ts.map +1 -1
  75. package/dist/tbv/integrations/aave/index.js +249 -141
  76. package/dist/tbv/integrations/aave/index.js.map +1 -1
  77. package/package.json +1 -1
  78. package/dist/BTCVaultRegistry.abi-CHFGevwa.cjs.map +0 -1
  79. package/dist/BTCVaultRegistry.abi-Cq9-JlqT.js.map +0 -1
  80. package/dist/errors-BP73_stm.cjs +0 -2
  81. package/dist/errors-BP73_stm.cjs.map +0 -1
  82. package/dist/errors-CznAK5NB.js.map +0 -1
  83. package/dist/primeVpAuth-Duds3vAO.cjs +0 -2
  84. package/dist/reservation-Cwf2u4vu.cjs +0 -2
  85. package/dist/reservation-Cwf2u4vu.cjs.map +0 -1
  86. package/dist/reservation-DNOGLBt4.js +0 -143
  87. package/dist/reservation-DNOGLBt4.js.map +0 -1
@@ -1,27 +1,27 @@
1
- var le = Object.defineProperty;
2
- var ue = (r, e, t) => e in r ? le(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var h = (r, e, t) => ue(r, typeof e != "symbol" ? e + "" : e, t);
4
- import { B as K } from "./BTCVaultRegistry.abi-Cq9-JlqT.js";
1
+ var ue = Object.defineProperty;
2
+ var de = (r, e, t) => e in r ? ue(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var p = (r, e, t) => de(r, typeof e != "symbol" ? e + "" : e, t);
4
+ import { B as X } from "./BTCVaultRegistry.abi-Chs4AFBj.js";
5
5
  import { P as b, A as H } from "./ApplicationRegistry.abi-Dn2qk6JG.js";
6
- import { j as de, v as j, k as pe, i as he } from "./mempoolApi-DI9HISqi.js";
7
- import { D as ge, J as Q, e as fe } from "./types-BqGAMOZM.js";
8
- import { X as R, C as U, s as T, S as me } from "./bitcoin-B5aNKtsk.js";
9
- import { H as k } from "./validation-CxqROCno.js";
10
- import * as M from "@bitcoin-js/tiny-secp256k1-asmjs";
11
- import { payments as _e, Transaction as O } from "bitcoinjs-lib";
6
+ import { j as pe, v as G, k as he, i as ge } from "./mempoolApi-DnP7d084.js";
7
+ import { D as fe, J as ee, e as _e } from "./types-BqGAMOZM.js";
8
+ import { X as R, C as j, s as V, S as me } from "./bitcoin-B5aNKtsk.js";
9
+ import { H as $ } from "./validation-CxqROCno.js";
10
+ import * as F from "@bitcoin-js/tiny-secp256k1-asmjs";
11
+ import { payments as be, Transaction as O } from "bitcoinjs-lib";
12
12
  import { Buffer as A } from "buffer";
13
- import { s as X } from "./sha2-BYVxyZzX.js";
14
- async function at(r, e) {
13
+ import { s as q } from "./sha2-BYVxyZzX.js";
14
+ async function ct(r, e) {
15
15
  const [t, n] = await r.multicall({
16
16
  contracts: [
17
17
  {
18
18
  address: e,
19
- abi: K,
19
+ abi: X,
20
20
  functionName: "protocolParams"
21
21
  },
22
22
  {
23
23
  address: e,
24
- abi: K,
24
+ abi: X,
25
25
  functionName: "applicationRegistry"
26
26
  }
27
27
  ],
@@ -32,7 +32,7 @@ async function at(r, e) {
32
32
  applicationRegistry: n
33
33
  };
34
34
  }
35
- const q = 65535;
35
+ const J = 65535;
36
36
  function E(r) {
37
37
  return {
38
38
  timelockAssert: r.timelockAssert,
@@ -61,13 +61,13 @@ function z(r) {
61
61
  };
62
62
  }
63
63
  function W(r) {
64
- if (r > BigInt(q))
64
+ if (r > BigInt(J))
65
65
  throw new Error(
66
- `timelockAssert value ${r} exceeds uint16 max (${q})`
66
+ `timelockAssert value ${r} exceeds uint16 max (${J})`
67
67
  );
68
68
  return Number(r);
69
69
  }
70
- class ot {
70
+ class lt {
71
71
  constructor(e, t) {
72
72
  this.publicClient = e, this.contractAddress = t;
73
73
  }
@@ -77,7 +77,7 @@ class ot {
77
77
  abi: b,
78
78
  functionName: "getTBVProtocolParams"
79
79
  }), t = z(e);
80
- return de(t), t;
80
+ return pe(t), t;
81
81
  }
82
82
  async getLatestOffchainParams() {
83
83
  const e = await this.publicClient.readContract({
@@ -85,7 +85,7 @@ class ot {
85
85
  abi: b,
86
86
  functionName: "getLatestOffchainParams"
87
87
  }), t = E(e);
88
- return j(t), t;
88
+ return G(t), t;
89
89
  }
90
90
  async getOffchainParamsByVersion(e) {
91
91
  const t = await this.publicClient.readContract({
@@ -94,7 +94,7 @@ class ot {
94
94
  functionName: "getOffchainParamsByVersion",
95
95
  args: [e]
96
96
  }), n = E(t);
97
- return j(n), n;
97
+ return G(n), n;
98
98
  }
99
99
  async getLatestOffchainParamsVersion() {
100
100
  const e = await this.publicClient.readContract({
@@ -102,7 +102,7 @@ class ot {
102
102
  abi: b,
103
103
  functionName: "latestOffchainParamsVersion"
104
104
  }), t = Number(e);
105
- return pe(t), t;
105
+ return he(t), t;
106
106
  }
107
107
  async getTimelockPeginByVersion(e) {
108
108
  const t = await this.getOffchainParamsByVersion(e);
@@ -135,7 +135,7 @@ class ot {
135
135
  }
136
136
  ],
137
137
  allowFailure: !1
138
- }), t = z(e[0]), n = E(e[1]), s = Number(e[2]), a = {
138
+ }), t = z(e[0]), n = E(e[1]), i = Number(e[2]), s = {
139
139
  minimumPegInAmount: t.minimumPegInAmount,
140
140
  maxPegInAmount: t.maxPegInAmount,
141
141
  pegInAckTimeout: t.pegInAckTimeout,
@@ -146,9 +146,9 @@ class ot {
146
146
  timelockRefund: n.tRefund,
147
147
  minVpCommissionBps: n.minVpCommissionBps,
148
148
  offchainParams: n,
149
- offchainParamsVersion: s
149
+ offchainParamsVersion: i
150
150
  };
151
- return he(a), a;
151
+ return ge(s), s;
152
152
  }
153
153
  /**
154
154
  * Fetch every historical offchain params version in a single multicall.
@@ -164,19 +164,19 @@ class ot {
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), s = n.map((c) => ({
167
+ const n = Array.from({ length: t }, (c, u) => u + 1), i = n.map((c) => ({
168
168
  address: this.contractAddress,
169
169
  abi: b,
170
170
  functionName: "getOffchainParamsByVersion",
171
171
  args: [c]
172
- })), a = await this.publicClient.multicall({
173
- contracts: s,
172
+ })), s = await this.publicClient.multicall({
173
+ contracts: i,
174
174
  allowFailure: !1
175
175
  }), o = /* @__PURE__ */ new Map();
176
176
  for (let c = 0; c < n.length; c++) {
177
- const u = E(a[c]);
177
+ const u = E(s[c]);
178
178
  try {
179
- j(u), o.set(n[c], u);
179
+ G(u), o.set(n[c], u);
180
180
  } catch (d) {
181
181
  e == null || e(
182
182
  n[c],
@@ -187,13 +187,13 @@ class ot {
187
187
  return { byVersion: o, latestVersion: t };
188
188
  }
189
189
  }
190
- function N(r) {
190
+ function D(r) {
191
191
  return r.map((e) => ({
192
192
  ethAddress: e.ethAddress,
193
193
  btcPubKey: e.btcPubKey
194
194
  }));
195
195
  }
196
- class ct {
196
+ class ut {
197
197
  constructor(e, t) {
198
198
  this.publicClient = e, this.contractAddress = t;
199
199
  }
@@ -204,7 +204,7 @@ class ct {
204
204
  functionName: "getVaultKeepersByVersion",
205
205
  args: [e, t]
206
206
  });
207
- return N(n);
207
+ return D(n);
208
208
  }
209
209
  async getCurrentVaultKeepers(e) {
210
210
  const t = await this.publicClient.readContract({
@@ -213,7 +213,7 @@ class ct {
213
213
  functionName: "getCurrentVaultKeepers",
214
214
  args: [e]
215
215
  });
216
- return N(t);
216
+ return D(t);
217
217
  }
218
218
  async getCurrentVaultKeepersVersion(e) {
219
219
  return await this.publicClient.readContract({
@@ -224,7 +224,7 @@ class ct {
224
224
  });
225
225
  }
226
226
  }
227
- class lt {
227
+ class dt {
228
228
  constructor(e, t) {
229
229
  this.publicClient = e, this.contractAddress = t;
230
230
  }
@@ -235,7 +235,7 @@ class lt {
235
235
  functionName: "getUniversalChallengersByVersion",
236
236
  args: [e]
237
237
  });
238
- return N(t);
238
+ return D(t);
239
239
  }
240
240
  async getCurrentUniversalChallengers() {
241
241
  const e = await this.publicClient.readContract({
@@ -243,7 +243,7 @@ class lt {
243
243
  abi: b,
244
244
  functionName: "getCurrentUniversalChallengers"
245
245
  });
246
- return N(e);
246
+ return D(e);
247
247
  }
248
248
  async getLatestUniversalChallengersVersion() {
249
249
  return await this.publicClient.readContract({
@@ -253,326 +253,326 @@ class lt {
253
253
  });
254
254
  }
255
255
  }
256
- var be = /* @__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))(be || {});
257
- const J = new Set(Object.values(ge)), ye = 200;
256
+ var ye = /* @__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))(ye || {});
257
+ const Y = new Set(Object.values(fe)), we = 200;
258
258
  function l(r) {
259
259
  var e;
260
- return ((e = JSON.stringify(r)) == null ? void 0 : e.slice(0, ye)) ?? "undefined";
260
+ return ((e = JSON.stringify(r)) == null ? void 0 : e.slice(0, we)) ?? "undefined";
261
261
  }
262
- const we = "The vault provider returned an unexpected response. Please try again or contact support.";
263
- class i extends Error {
262
+ const Pe = "The vault provider returned an unexpected response. Please try again or contact support.";
263
+ class a extends Error {
264
264
  constructor(t) {
265
- super(we);
266
- h(this, "detail");
265
+ super(Pe);
266
+ p(this, "detail");
267
267
  this.name = "VpResponseValidationError", this.detail = t;
268
268
  }
269
269
  }
270
- const $ = 64;
270
+ const k = 64;
271
271
  function P(r) {
272
- return typeof r == "string" && r.length > 0 && k.test(r);
272
+ return typeof r == "string" && r.length > 0 && $.test(r);
273
273
  }
274
- function ee(r) {
274
+ function te(r) {
275
275
  return typeof r == "string" && r.length > 0;
276
276
  }
277
- function te(r, e) {
277
+ function re(r, e) {
278
278
  if (!P(r))
279
- throw new i(
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
- function m(r, e) {
284
- if (!ee(r))
285
- throw new i(
283
+ function _(r, e) {
284
+ if (!te(r))
285
+ throw new a(
286
286
  `VP response validation failed: "${e}" must be a non-empty string, got ${l(r)}`
287
287
  );
288
288
  }
289
- function G(r, e) {
290
- if (!P(r) || r.length !== R && r.length !== U)
291
- throw new i(
292
- `VP response validation failed: "${e}" must be a ${R} or ${U}-char hex string (BTC pubkey), got ${l(r)}`
289
+ function L(r, e) {
290
+ if (!P(r) || r.length !== R && r.length !== j)
291
+ throw new a(
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 Pe(r) {
295
+ function xe(r) {
296
296
  const e = r.presigning;
297
297
  if (e == null) return;
298
298
  if (typeof e != "object" || Array.isArray(e))
299
- throw new i(
299
+ throw new a(
300
300
  'VP response validation failed: "progress.presigning" must be an object if present'
301
301
  );
302
302
  const t = e;
303
303
  if (t.depositor_graph_created !== void 0 && typeof t.depositor_graph_created != "boolean")
304
- throw new i(
304
+ throw new a(
305
305
  `VP response validation failed: "progress.presigning.depositor_graph_created" must be a boolean if present, got ${l(t.depositor_graph_created)}`
306
306
  );
307
307
  if (t.vk_challenger_presigning_completed !== void 0 && typeof t.vk_challenger_presigning_completed != "number")
308
- throw new i(
308
+ throw new a(
309
309
  `VP response validation failed: "progress.presigning.vk_challenger_presigning_completed" must be a number if present, got ${l(t.vk_challenger_presigning_completed)}`
310
310
  );
311
311
  if (t.vk_challenger_presigning_total !== void 0 && typeof t.vk_challenger_presigning_total != "number")
312
- throw new i(
312
+ throw new a(
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 re(r) {
316
+ function ne(r) {
317
317
  if (r === null || typeof r != "object")
318
- throw new i(
318
+ throw new a(
319
319
  "VP response validation failed: getPeginStatus response is not an object"
320
320
  );
321
321
  const e = r;
322
- if (!P(e.pegin_txid) || e.pegin_txid.length !== $)
323
- throw new i(
324
- `VP response validation failed: "pegin_txid" must be a ${$}-char hex string (txid), got ${l(e.pegin_txid)}`
322
+ if (!P(e.pegin_txid) || e.pegin_txid.length !== k)
323
+ throw new a(
324
+ `VP response validation failed: "pegin_txid" must be a ${k}-char hex string (txid), got ${l(e.pegin_txid)}`
325
325
  );
326
326
  if (typeof e.status != "string")
327
- throw new i(
327
+ throw new a(
328
328
  'VP response validation failed: "status" must be a string'
329
329
  );
330
- if (!J.has(e.status))
331
- throw new i(
332
- `VP response validation failed: unrecognized status "${e.status}". Expected one of: ${[...J].join(", ")}`
330
+ if (!Y.has(e.status))
331
+ throw new a(
332
+ `VP response validation failed: unrecognized status "${e.status}". Expected one of: ${[...Y].join(", ")}`
333
333
  );
334
334
  if (e.progress === null || typeof e.progress != "object" || Array.isArray(e.progress))
335
- throw new i(
335
+ throw new a(
336
336
  'VP response validation failed: "progress" must be an object'
337
337
  );
338
- if (Pe(e.progress), typeof e.health_info != "string")
339
- throw new i(
338
+ if (xe(e.progress), typeof e.health_info != "string")
339
+ throw new a(
340
340
  'VP response validation failed: "health_info" must be a string'
341
341
  );
342
342
  if (e.last_error !== void 0 && typeof e.last_error != "string")
343
- throw new i(
343
+ throw new a(
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 xe(r) {
347
+ function ve(r) {
348
348
  if (r === null || typeof r != "object")
349
- throw new i(
349
+ throw new a(
350
350
  "VP response validation failed: requestDepositorPresignTransactions response is not an object"
351
351
  );
352
352
  const e = r;
353
353
  if (!Array.isArray(e.txs))
354
- throw new i(
354
+ throw new a(
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
- ve(e.txs[t], `txs[${t}]`);
358
+ Ae(e.txs[t], `txs[${t}]`);
359
359
  if (e.depositor_graph === null || typeof e.depositor_graph != "object")
360
- throw new i(
360
+ throw new a(
361
361
  'VP response validation failed: "depositor_graph" must be an object'
362
362
  );
363
- Ie(
363
+ Re(
364
364
  e.depositor_graph
365
365
  );
366
366
  }
367
367
  function y(r, e) {
368
368
  if (r === null || typeof r != "object")
369
- throw new i(
369
+ throw new a(
370
370
  `VP response validation failed: "${e}" must be an object`
371
371
  );
372
- te(r.tx_hex, `${e}.tx_hex`);
372
+ re(r.tx_hex, `${e}.tx_hex`);
373
373
  }
374
- function ve(r, e) {
374
+ function Ae(r, e) {
375
375
  if (r === null || typeof r != "object")
376
- throw new i(
376
+ throw new a(
377
377
  `VP response validation failed: "${e}" must be an object`
378
378
  );
379
379
  const t = r;
380
- G(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`), m(t.payout_psbt, `${e}.payout_psbt`);
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 Ae(r, e) {
382
+ function ke(r, e) {
383
383
  if (r === null || typeof r != "object")
384
- throw new i(
384
+ throw new a(
385
385
  `VP response validation failed: "${e}" must be an object`
386
386
  );
387
387
  const t = r;
388
- m(t.wots_pks_json, `${e}.wots_pks_json`), m(t.gc_wots_keys_json, `${e}.gc_wots_keys_json`);
388
+ _(t.wots_pks_json, `${e}.wots_pks_json`), _(t.gc_wots_keys_json, `${e}.gc_wots_keys_json`);
389
389
  }
390
390
  function $e(r, e) {
391
391
  if (r === null || typeof r != "object")
392
- throw new i(
392
+ throw new a(
393
393
  `VP response validation failed: "${e}" must be an object`
394
394
  );
395
395
  const t = r;
396
- if (G(t.challenger_pubkey, `${e}.challenger_pubkey`), y(
396
+ if (L(t.challenger_pubkey, `${e}.challenger_pubkey`), y(
397
397
  t.challenge_assert_x_tx,
398
398
  `${e}.challenge_assert_x_tx`
399
399
  ), y(
400
400
  t.challenge_assert_y_tx,
401
401
  `${e}.challenge_assert_y_tx`
402
- ), y(t.nopayout_tx, `${e}.nopayout_tx`), m(t.nopayout_psbt, `${e}.nopayout_psbt`), !Array.isArray(t.challenge_assert_connectors))
403
- throw new i(
402
+ ), y(t.nopayout_tx, `${e}.nopayout_tx`), _(t.nopayout_psbt, `${e}.nopayout_psbt`), !Array.isArray(t.challenge_assert_connectors))
403
+ throw new a(
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
- Ae(
407
+ ke(
408
408
  t.challenge_assert_connectors[n],
409
409
  `${e}.challenge_assert_connectors[${n}]`
410
410
  );
411
411
  if (!Array.isArray(t.output_label_hashes))
412
- throw new i(
412
+ throw new a(
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
- te(
416
+ re(
417
417
  t.output_label_hashes[n],
418
418
  `${e}.output_label_hashes[${n}]`
419
419
  );
420
420
  }
421
- function ke(r) {
421
+ function Se(r) {
422
422
  if (r === null || typeof r != "object")
423
- throw new i(
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 (!ee(e.tx_graph_json))
428
- throw new i(
427
+ if (!te(e.tx_graph_json))
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
  );
431
431
  if (!P(e.verifying_key_hex))
432
- throw new i(
432
+ throw new a(
433
433
  `VP response validation failed: "verifying_key_hex" must be a non-empty hex string, got ${l(e.verifying_key_hex)}`
434
434
  );
435
435
  if (e.babe_sessions === null || typeof e.babe_sessions != "object" || Array.isArray(e.babe_sessions))
436
- throw new i(
436
+ throw new a(
437
437
  'VP response validation failed: "babe_sessions" must be an object'
438
438
  );
439
439
  const t = Object.entries(
440
440
  e.babe_sessions
441
441
  );
442
442
  if (t.length === 0)
443
- throw new i(
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, s] of t) {
447
- if (G(n, `babe_sessions["${n}"]`), s === null || typeof s != "object")
448
- throw new i(
446
+ for (const [n, i] of t) {
447
+ if (L(n, `babe_sessions["${n}"]`), i === null || typeof i != "object")
448
+ throw new a(
449
449
  `VP response validation failed: "babe_sessions.${n}" must be an object`
450
450
  );
451
- const a = s;
452
- if (!P(a.decryptor_artifacts_hex))
453
- throw new i(
454
- `VP response validation failed: "babe_sessions.${n}.decryptor_artifacts_hex" must be a non-empty hex string, got ${l(a.decryptor_artifacts_hex)}`
451
+ const s = i;
452
+ if (!P(s.decryptor_artifacts_hex))
453
+ throw new a(
454
+ `VP response validation failed: "babe_sessions.${n}.decryptor_artifacts_hex" must be a non-empty hex string, got ${l(s.decryptor_artifacts_hex)}`
455
455
  );
456
456
  }
457
457
  }
458
- function Ve(r) {
458
+ function Te(r) {
459
459
  if (r === null || typeof r != "object")
460
- throw new i(
460
+ throw new a(
461
461
  "VP response validation failed: pegout status payload is not an object"
462
462
  );
463
463
  const e = r;
464
- if (!P(e.pegin_txid) || e.pegin_txid.length !== $)
465
- throw new i(
466
- `VP response validation failed: "pegin_txid" must be a ${$}-char hex string (txid), got ${l(e.pegin_txid)}`
464
+ if (!P(e.pegin_txid) || e.pegin_txid.length !== k)
465
+ throw new a(
466
+ `VP response validation failed: "pegin_txid" must be a ${k}-char hex string (txid), got ${l(e.pegin_txid)}`
467
467
  );
468
468
  if (typeof e.found != "boolean")
469
- throw new i(
469
+ throw new a(
470
470
  `VP response validation failed: "found" must be a boolean, got ${l(e.found)}`
471
471
  );
472
472
  if (e.claimer !== null) {
473
473
  if (typeof e.claimer != "object")
474
- throw new i(
474
+ throw new a(
475
475
  `VP response validation failed: "claimer" must be an object or null, got ${l(e.claimer)}`
476
476
  );
477
- Se(e.claimer);
477
+ Ve(e.claimer);
478
478
  }
479
479
  if (!Array.isArray(e.challengers))
480
- throw new i(
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
- Te(e.challengers[t], t);
484
+ Ee(e.challengers[t], t);
485
485
  }
486
- function Se(r) {
487
- if (m(r.status, "claimer.status"), typeof r.failed != "boolean")
488
- throw new i(
486
+ function Ve(r) {
487
+ if (_(r.status, "claimer.status"), typeof r.failed != "boolean")
488
+ throw new a(
489
489
  `VP response validation failed: "claimer.failed" must be a boolean, got ${l(r.failed)}`
490
490
  );
491
- if (m(r.claim_txid, "claimer.claim_txid"), m(r.claimer_pubkey, "claimer.claimer_pubkey"), m(r.assert_txid, "claimer.assert_txid"), typeof r.created_at != "number")
492
- throw new i(
491
+ if (_(r.claim_txid, "claimer.claim_txid"), _(r.claimer_pubkey, "claimer.claimer_pubkey"), _(r.assert_txid, "claimer.assert_txid"), typeof r.created_at != "number")
492
+ throw new a(
493
493
  `VP response validation failed: "claimer.created_at" must be a number, got ${l(r.created_at)}`
494
494
  );
495
495
  if (typeof r.updated_at != "number")
496
- throw new i(
496
+ throw new a(
497
497
  `VP response validation failed: "claimer.updated_at" must be a number, got ${l(r.updated_at)}`
498
498
  );
499
499
  }
500
- function Te(r, e) {
500
+ function Ee(r, e) {
501
501
  if (r === null || typeof r != "object")
502
- throw new i(
502
+ throw new a(
503
503
  `VP response validation failed: "challengers[${e}]" must be an object, got ${l(r)}`
504
504
  );
505
505
  const t = r;
506
- if (m(t.status, `challengers[${e}].status`), m(t.claim_txid, `challengers[${e}].claim_txid`), m(t.claimer_pubkey, `challengers[${e}].claimer_pubkey`), C(t.assert_txid, `challengers[${e}].assert_txid`), C(
506
+ if (_(t.status, `challengers[${e}].status`), _(t.claim_txid, `challengers[${e}].claim_txid`), _(t.claimer_pubkey, `challengers[${e}].claimer_pubkey`), C(t.assert_txid, `challengers[${e}].assert_txid`), C(
507
507
  t.challenge_assert_x_txid,
508
508
  `challengers[${e}].challenge_assert_x_txid`
509
509
  ), C(
510
510
  t.challenge_assert_y_txid,
511
511
  `challengers[${e}].challenge_assert_y_txid`
512
512
  ), C(t.nopayout_txid, `challengers[${e}].nopayout_txid`), typeof t.created_at != "number")
513
- throw new i(
513
+ throw new a(
514
514
  `VP response validation failed: "challengers[${e}].created_at" must be a number, got ${l(t.created_at)}`
515
515
  );
516
516
  if (typeof t.updated_at != "number")
517
- throw new i(
517
+ throw new a(
518
518
  `VP response validation failed: "challengers[${e}].updated_at" must be a number, got ${l(t.updated_at)}`
519
519
  );
520
520
  }
521
521
  function C(r, e) {
522
522
  if (r !== null && typeof r != "string")
523
- throw new i(
523
+ throw new a(
524
524
  `VP response validation failed: "${e}" must be a string or null, got ${l(r)}`
525
525
  );
526
526
  }
527
- function Ee(r) {
528
- ne(r, "batchGetPeginStatus", (e) => {
529
- e.result !== null && re(e.result);
527
+ function Ce(r) {
528
+ se(r, "batchGetPeginStatus", (e) => {
529
+ e.result !== null && ne(e.result);
530
530
  });
531
531
  }
532
- function Ce(r) {
533
- ne(r, "batchGetPegoutStatus", (e) => {
534
- e.result !== null && Ve(e.result);
532
+ function Ie(r) {
533
+ se(r, "batchGetPegoutStatus", (e) => {
534
+ e.result !== null && Te(e.result);
535
535
  });
536
536
  }
537
- function ne(r, e, t) {
537
+ function se(r, e, t) {
538
538
  if (r === null || typeof r != "object")
539
- throw new i(
539
+ throw new a(
540
540
  `VP response validation failed: ${e} response is not an object`
541
541
  );
542
542
  const n = r;
543
543
  if (!Array.isArray(n.results))
544
- throw new i(
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 s = 0; s < n.results.length; s++) {
548
- const a = n.results[s];
549
- if (a === null || typeof a != "object")
550
- throw new i(
551
- `VP response validation failed: "${e}.results[${s}]" must be an object, got ${l(a)}`
547
+ for (let i = 0; i < n.results.length; i++) {
548
+ const s = n.results[i];
549
+ if (s === null || typeof s != "object")
550
+ throw new a(
551
+ `VP response validation failed: "${e}.results[${i}]" must be an object, got ${l(s)}`
552
552
  );
553
- const o = a;
554
- if (!P(o.pegin_txid) || o.pegin_txid.length !== $)
555
- throw new i(
556
- `VP response validation failed: "${e}.results[${s}].pegin_txid" must be a ${$}-char hex string, got ${l(o.pegin_txid)}`
553
+ const o = s;
554
+ if (!P(o.pegin_txid) || o.pegin_txid.length !== k)
555
+ throw new a(
556
+ `VP response validation failed: "${e}.results[${i}].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
- throw new i(
560
- `VP response validation failed: "${e}.results[${s}].error" must be a string or null, got ${l(o.error)}`
559
+ throw new a(
560
+ `VP response validation failed: "${e}.results[${i}].error" must be a string or null, got ${l(o.error)}`
561
561
  );
562
562
  if (o.result === null && o.error === null)
563
- throw new i(
564
- `VP response validation failed: "${e}.results[${s}]" has neither "result" nor "error" populated`
563
+ throw new a(
564
+ `VP response validation failed: "${e}.results[${i}]" has neither "result" nor "error" populated`
565
565
  );
566
566
  if (o.result !== null && o.error !== null)
567
- throw new i(
568
- `VP response validation failed: "${e}.results[${s}]" has both "result" and "error" populated`
567
+ throw new a(
568
+ `VP response validation failed: "${e}.results[${i}]" has both "result" and "error" populated`
569
569
  );
570
- t(o, s);
570
+ t(o, i);
571
571
  }
572
572
  }
573
- function Ie(r) {
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"), m(r.payout_psbt, "depositor_graph.payout_psbt"), !Array.isArray(r.challenger_presign_data))
575
- throw new i(
573
+ function Re(r) {
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
+ 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++)
@@ -581,17 +581,17 @@ function Ie(r) {
581
581
  `depositor_graph.challenger_presign_data[${e}]`
582
582
  );
583
583
  if (typeof r.offchain_params_version != "number")
584
- throw new i(
584
+ throw new a(
585
585
  'VP response validation failed: "depositor_graph.offchain_params_version" must be a number'
586
586
  );
587
587
  }
588
- const Re = 6e4;
588
+ const De = 6e4;
589
589
  class Ne {
590
590
  constructor(e, t) {
591
- h(this, "client");
591
+ p(this, "client");
592
592
  const n = {
593
593
  baseUrl: e,
594
- timeout: (t == null ? void 0 : t.timeout) ?? Re,
594
+ timeout: (t == null ? void 0 : t.timeout) ?? De,
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 Q(n);
602
+ this.client = new ee(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 xe(n), n;
610
+ return ve(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 ke(n), n;
641
+ return Se(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 re(n), n;
650
+ return ne(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 Ee(n), n;
659
+ return Ce(n), n;
660
660
  }
661
661
  /**
662
662
  * Get pegout status for many txids in one round trip. Same per-result
@@ -664,102 +664,102 @@ class Ne {
664
664
  */
665
665
  async batchGetPegoutStatus(e, t) {
666
666
  const n = await this.client.call("vaultProvider_batchGetPegoutStatus", e, t);
667
- return Ce(n), n;
667
+ return Ie(n), n;
668
668
  }
669
669
  }
670
- function De(r, e) {
670
+ function Be(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(), s = /* @__PURE__ */ new Set(), a = [], o = [];
674
+ const n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), s = [], 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 (s.has(d)) {
682
- a.push(d);
681
+ if (i.has(d)) {
682
+ s.push(d);
683
683
  continue;
684
684
  }
685
- s.add(d), n.set(d, { result: u.result, error: u.error });
685
+ i.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
- s.has(u) || c.push(u);
690
- return { byTxid: n, missing: c, unexpected: o, duplicate: a };
689
+ i.has(u) || c.push(u);
690
+ return { byTxid: n, missing: c, unexpected: o, duplicate: s };
691
691
  }
692
- async function ut(r) {
692
+ async function pt(r) {
693
693
  const {
694
694
  items: e,
695
695
  getTxid: t,
696
696
  batchCall: n,
697
- onItem: s,
698
- onMissing: a,
697
+ onItem: i,
698
+ onMissing: s,
699
699
  onDuplicate: o,
700
700
  onDuplicateBatch: c,
701
701
  onWholeBatchError: u,
702
702
  onUnexpected: d,
703
- batchSize: f = fe
703
+ batchSize: f = _e
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), V = /* @__PURE__ */ new Map(), B = [];
711
- for (const p of x) {
712
- const _ = t(p).toLowerCase();
713
- V.set(_, p), B.push(_);
710
+ const x = e.slice(w, w + f), S = /* @__PURE__ */ new Map(), B = [];
711
+ for (const h of x) {
712
+ const m = t(h).toLowerCase();
713
+ S.set(m, h), B.push(m);
714
714
  }
715
715
  let v;
716
716
  try {
717
- const p = await n(B);
718
- v = De(B, p.results);
719
- } catch (p) {
720
- u(x, p);
717
+ const h = await n(B);
718
+ v = Be(B, h.results);
719
+ } catch (h) {
720
+ u(x, h);
721
721
  continue;
722
722
  }
723
723
  d && v.unexpected.length > 0 && d(v.unexpected);
724
- const S = new Set(v.duplicate);
725
- for (const p of S) {
726
- const _ = V.get(p);
727
- _ && o(_);
724
+ const T = new Set(v.duplicate);
725
+ for (const h of T) {
726
+ const m = S.get(h);
727
+ m && o(m);
728
728
  }
729
- c && S.size > 0 && c(S.size);
730
- for (const p of v.missing) {
731
- const _ = V.get(p);
732
- _ && a(_);
729
+ c && T.size > 0 && c(T.size);
730
+ for (const h of v.missing) {
731
+ const m = S.get(h);
732
+ m && s(m);
733
733
  }
734
- for (const [p, _] of v.byTxid) {
735
- if (S.has(p)) continue;
736
- const F = V.get(p);
737
- F && s(F, {
738
- pegin_txid: p,
739
- result: _.result,
740
- error: _.error
734
+ for (const [h, m] of v.byTxid) {
735
+ if (T.has(h)) continue;
736
+ const K = S.get(h);
737
+ K && i(K, {
738
+ pegin_txid: h,
739
+ result: m.result,
740
+ error: m.error
741
741
  });
742
742
  }
743
743
  }
744
744
  }
745
- const Be = "BIP0322-signed-message", He = "TapTweak", se = 32, je = 64;
746
- function ie(r, e) {
747
- const t = new TextEncoder().encode(r), n = X(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), X(s);
745
+ const He = "BIP0322-signed-message", Ge = "TapTweak", ie = 32, Oe = 64;
746
+ function ae(r, e) {
747
+ const t = new TextEncoder().encode(r), n = q(t), i = new Uint8Array(n.length * 2 + e.length);
748
+ return i.set(n, 0), i.set(n, n.length), i.set(e, n.length * 2), q(i);
749
749
  }
750
- function Oe(r) {
751
- if (r.length !== se) return null;
752
- const e = ie(He, r), t = M.xOnlyPointAddTweak(r, e);
750
+ function je(r) {
751
+ if (r.length !== ie) return null;
752
+ const e = ae(Ge, r), t = F.xOnlyPointAddTweak(r, e);
753
753
  return t ? t.xOnlyPubkey : null;
754
754
  }
755
- function Ue(r, e, t) {
756
- if (e.length !== se || t.length !== je) return !1;
755
+ function Me(r, e, t) {
756
+ if (e.length !== ie || t.length !== Oe) return !1;
757
757
  try {
758
- const n = ie(Be, r), s = _e.p2tr({
758
+ const n = ae(He, r), i = be.p2tr({
759
759
  internalPubkey: A.from(e)
760
760
  });
761
- if (!s.output) return !1;
762
- const a = s.output, o = 0, c = new O();
761
+ if (!i.output) return !1;
762
+ const s = i.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 Ue(r, e, t) {
773
773
  0,
774
774
  // sequence = 0
775
775
  u
776
- ), c.addOutput(a, o);
776
+ ), c.addOutput(s, 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
- [a],
783
+ [s],
784
784
  [o],
785
785
  O.SIGHASH_DEFAULT
786
- ), x = Oe(e);
787
- return x ? M.verifySchnorr(w, x, t) : !1;
786
+ ), x = je(e);
787
+ return x ? F.verifySchnorr(w, x, t) : !1;
788
788
  } catch {
789
789
  return !1;
790
790
  }
791
791
  }
792
- function D(r, e) {
792
+ function N(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 a = Number(n);
799
- return new Uint8Array([t | 25, a >>> 8 & 255, a & 255]);
798
+ const s = Number(n);
799
+ return new Uint8Array([t | 25, s >>> 8 & 255, s & 255]);
800
800
  }
801
801
  if (n < 0x100000000n) {
802
- const a = Number(n);
802
+ const s = Number(n);
803
803
  return new Uint8Array([
804
804
  t | 26,
805
- a >>> 24 & 255,
806
- a >>> 16 & 255,
807
- a >>> 8 & 255,
808
- a & 255
805
+ s >>> 24 & 255,
806
+ s >>> 16 & 255,
807
+ s >>> 8 & 255,
808
+ s & 255
809
809
  ]);
810
810
  }
811
- const s = new Uint8Array(9);
812
- s[0] = t | 27;
813
- for (let a = 7; a >= 0; a--)
814
- s[1 + a] = Number(n >> BigInt((7 - a) * 8)) & 255;
815
- return s;
811
+ const i = new Uint8Array(9);
812
+ i[0] = t | 27;
813
+ for (let s = 7; s >= 0; s--)
814
+ i[1 + s] = Number(n >> BigInt((7 - s) * 8)) & 255;
815
+ return i;
816
816
  }
817
- function ae(...r) {
818
- const e = r.reduce((s, a) => s + a.length, 0), t = new Uint8Array(e);
817
+ function oe(...r) {
818
+ const e = r.reduce((i, s) => i + s.length, 0), t = new Uint8Array(e);
819
819
  let n = 0;
820
- for (const s of r)
821
- t.set(s, n), n += s.length;
820
+ for (const i of r)
821
+ t.set(i, n), n += i.length;
822
822
  return t;
823
823
  }
824
- function Y(r) {
825
- const t = [D(4, r.length)];
824
+ function Z(r) {
825
+ const t = [N(4, r.length)];
826
826
  for (const n of r)
827
- t.push(D(0, n));
828
- return ae(...t);
827
+ t.push(N(0, n));
828
+ return oe(...t);
829
829
  }
830
- function Le(r, e, t) {
830
+ function Ue(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 = D(4, 3), s = Y(r), a = Y(e), o = D(0, t);
836
- return ae(n, s, a, o);
835
+ const n = N(4, 3), i = Z(r), s = Z(e), o = N(0, t);
836
+ return oe(n, i, s, o);
837
837
  }
838
- const Me = new TextEncoder().encode(
838
+ const Fe = new TextEncoder().encode(
839
839
  "btc-auth.server-identity.v1"
840
- ), Ge = 2 * 3600;
840
+ ), Le = 2 * 3600;
841
841
  class g extends Error {
842
842
  constructor(e, t) {
843
843
  super(e), this.reason = t, this.name = "ServerIdentityError";
@@ -849,22 +849,22 @@ function I(r) {
849
849
  e[t] = parseInt(r.slice(t * 2, t * 2 + 2), 16);
850
850
  return e;
851
851
  }
852
- function Fe(r) {
853
- const { proof: e, pinnedServerPubkey: t, now: n } = r, s = r.maxLifetimeSecs ?? Ge, a = T(t).toLowerCase();
854
- if (a.length !== R || !k.test(a))
852
+ function Ke(r) {
853
+ const { proof: e, pinnedServerPubkey: t, now: n } = r, i = r.maxLifetimeSecs ?? Le, s = V(t).toLowerCase();
854
+ if (s.length !== R || !$.test(s))
855
855
  throw new g(
856
- `pinnedServerPubkey must be 32-byte hex; got ${a.length} chars`,
856
+ `pinnedServerPubkey must be 32-byte hex; got ${s.length} chars`,
857
857
  "invalid_pubkey_encoding"
858
858
  );
859
- const o = T(e.server_pubkey).toLowerCase();
860
- if (o.length !== R || !k.test(o))
859
+ const o = V(e.server_pubkey).toLowerCase();
860
+ if (o.length !== R || !$.test(o))
861
861
  throw new g(
862
862
  `server_pubkey must be 32-byte hex; got ${o.length} chars`,
863
863
  "invalid_pubkey_encoding"
864
864
  );
865
- if (o !== a)
865
+ if (o !== s)
866
866
  throw new g(
867
- `server_pubkey does not match pinned value: expected ${a}, got ${o}`,
867
+ `server_pubkey does not match pinned value: expected ${s}, got ${o}`,
868
868
  "pinned_pubkey_mismatch"
869
869
  );
870
870
  if (!Number.isSafeInteger(e.expires_at))
@@ -882,18 +882,18 @@ function Fe(r) {
882
882
  `server identity proof expired at ${e.expires_at}, now ${n}`,
883
883
  "expired"
884
884
  );
885
- if (!Number.isSafeInteger(s) || s <= 0)
885
+ if (!Number.isSafeInteger(i) || i <= 0)
886
886
  throw new g(
887
- `maxLifetimeSecs must be a positive safe integer; got ${JSON.stringify(s)}`,
887
+ `maxLifetimeSecs must be a positive safe integer; got ${JSON.stringify(i)}`,
888
888
  "invalid_max_lifetime"
889
889
  );
890
- if (e.expires_at - n > s)
890
+ if (e.expires_at - n > i)
891
891
  throw new g(
892
- `server identity proof expires too far in the future: expires_at=${e.expires_at}, now=${n}, max lifetime=${s}s`,
892
+ `server identity proof expires too far in the future: expires_at=${e.expires_at}, now=${n}, max lifetime=${i}s`,
893
893
  "expires_too_far"
894
894
  );
895
- const c = T(e.ephemeral_pubkey).toLowerCase();
896
- if (c.length !== U || !k.test(c))
895
+ const c = V(e.ephemeral_pubkey).toLowerCase();
896
+ if (c.length !== j || !$.test(c))
897
897
  throw new g(
898
898
  `ephemeral_pubkey must be 33-byte compressed hex; got ${c.length} chars`,
899
899
  "invalid_ephemeral_pubkey"
@@ -905,83 +905,102 @@ function Fe(r) {
905
905
  "invalid_ephemeral_pubkey"
906
906
  );
907
907
  const d = I(c);
908
- if (!M.isPoint(d))
908
+ if (!F.isPoint(d))
909
909
  throw new g(
910
910
  "ephemeral_pubkey is not a valid secp256k1 point",
911
911
  "invalid_ephemeral_pubkey"
912
912
  );
913
- const f = T(e.signature).toLowerCase();
914
- if (f.length !== me || !k.test(f))
913
+ const f = V(e.signature).toLowerCase();
914
+ if (f.length !== me || !$.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 = Le(
920
- Me,
919
+ const w = Ue(
920
+ Fe,
921
921
  I(c),
922
922
  e.expires_at
923
923
  );
924
- if (!Ue(w, I(o), I(f)))
924
+ if (!Me(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 Ke = /* @__PURE__ */ new Set([
930
+ const Xe = /* @__PURE__ */ new Set([
931
931
  "vaultProvider_submitDepositorWotsKey",
932
932
  "vaultProvider_submitDepositorPresignatures",
933
- "vaultProvider_requestDepositorPresignTransactions",
933
+ "vaultProvider_requestDepositorPresignTransactions"
934
+ ]), qe = /* @__PURE__ */ new Set([
934
935
  "vaultProvider_requestDepositorClaimerArtifacts"
935
- ]), Xe = 6e4, L = "auth_createDepositorToken";
936
- function oe(r, e) {
937
- return new Q({
936
+ ]), Je = 6e4, M = "auth_createDepositorToken", U = "auth_createDepositorTokenGrpc";
937
+ function ce(r, e) {
938
+ return new ee({
938
939
  baseUrl: r,
939
- timeout: Xe,
940
+ timeout: Je,
940
941
  headers: e,
941
- retryableFor: (t) => t === L
942
+ retryableFor: (t) => t === M || t === U
942
943
  });
943
944
  }
944
- const Z = 4102444800, qe = 30;
945
- class ze {
945
+ const Q = 4102444800, ze = 30;
946
+ class We {
946
947
  constructor(e) {
947
948
  // `client` is the only mutable field — see `setClient`. The
948
949
  // identity-bearing fields (peginTxid/authAnchorHex/pinnedServerPubkey)
949
950
  // remain readonly and are checked against re-registration in the
950
951
  // registry's `getOrCreate`.
951
- h(this, "client");
952
- h(this, "peginTxid");
953
- h(this, "authAnchorHex");
954
- h(this, "pinnedServerPubkey");
955
- h(this, "authGatedMethods");
956
- h(this, "refreshSkewSecs");
957
- h(this, "now");
958
- h(this, "cached", null);
959
- h(this, "inFlight", null);
960
- this.client = e.client, this.peginTxid = e.peginTxid, this.authAnchorHex = e.authAnchorHex, this.pinnedServerPubkey = e.pinnedServerPubkey, this.authGatedMethods = e.authGatedMethods, this.refreshSkewSecs = e.refreshSkewSecs ?? qe, this.now = e.now ?? (() => Math.floor(Date.now() / 1e3));
952
+ p(this, "client");
953
+ p(this, "peginTxid");
954
+ p(this, "authAnchorHex");
955
+ p(this, "pinnedServerPubkey");
956
+ p(this, "authGatedMethods");
957
+ p(this, "grpcGatedMethods");
958
+ p(this, "refreshSkewSecs");
959
+ p(this, "now");
960
+ /** Cached JSON-RPC-subject bearer (auth_createDepositorToken). */
961
+ p(this, "cachedJsonRpc", null);
962
+ p(this, "inFlightJsonRpc", null);
963
+ /** Cached gRPC-subject bearer (auth_createDepositorTokenGrpc). */
964
+ p(this, "cachedGrpc", null);
965
+ p(this, "inFlightGrpc", null);
966
+ this.client = e.client, this.peginTxid = e.peginTxid, this.authAnchorHex = e.authAnchorHex, this.pinnedServerPubkey = e.pinnedServerPubkey, this.authGatedMethods = e.authGatedMethods, this.grpcGatedMethods = e.grpcGatedMethods, this.refreshSkewSecs = e.refreshSkewSecs ?? ze, this.now = e.now ?? (() => Math.floor(Date.now() / 1e3));
961
967
  }
962
968
  /**
963
969
  * Return a bearer token for `method`, or `null` if `method` is not
964
- * auth-gated. Triggers a token acquisition if no token is cached or
965
- * the cached token is within {@link refreshSkewSecs} of expiry.
970
+ * auth-gated.
971
+ *
972
+ * Routes by subject: `authGatedMethods` → JSON-RPC bearer (issued via
973
+ * `auth_createDepositorToken`); `grpcGatedMethods` → gRPC bearer
974
+ * (`auth_createDepositorTokenGrpc`). Either path acquires lazily and
975
+ * single-flights concurrent callers; the two cache slots are
976
+ * independent.
966
977
  *
967
- * The token-issuing method itself is hard-exempted from the gate —
968
- * if `auth_createDepositorToken` were ever included in
969
- * `authGatedMethods` (caller misconfiguration) the provider would
970
- * recurse into `acquireSingleFlight` from inside the JSON-RPC header
971
- * builder before `inFlight` is assigned, defeating the single-flight
972
- * guard. Returning `null` here breaks that recursion deterministically.
978
+ * Both token-issuing methods are hard-exempted from the gate — if
979
+ * either were ever included in the gated sets (caller misconfiguration)
980
+ * the provider would recurse into `acquireSingleFlight` from inside the
981
+ * JSON-RPC header builder before `inFlight` is assigned, defeating the
982
+ * single-flight guard. Returning `null` here breaks that recursion
983
+ * deterministically.
973
984
  */
974
985
  async getToken(e) {
975
- if (e === L || !this.authGatedMethods.has(e)) return null;
976
- const t = this.cached;
977
- return t && this.now() + this.refreshSkewSecs < t.expiresAt ? t.token : (await this.acquireSingleFlight()).token;
986
+ return e === M || e === U ? null : this.grpcGatedMethods.has(e) ? this.getTokenForSubject("grpc") : this.authGatedMethods.has(e) ? this.getTokenForSubject("jsonrpc") : null;
978
987
  }
979
988
  /**
980
- * Drop the cached token. Next `getToken` call re-acquires.
981
- * Called by `JsonRpcClient` on wire `auth_expired` responses.
989
+ * Drop both cached tokens. Next `getToken` call re-acquires the slot
990
+ * that's actually needed. Called by `JsonRpcClient` on wire
991
+ * `auth_expired` responses; the client doesn't tell us which subject
992
+ * expired, so we evict both to stay correct under either.
993
+ *
994
+ * Worst case is one extra round-trip on the slot that was still fresh,
995
+ * which is cheaper than carrying a `Subject` argument through
996
+ * `BearerTokenProvider`.
982
997
  */
983
998
  invalidate() {
984
- this.cached = null;
999
+ this.cachedJsonRpc = null, this.cachedGrpc = null;
1000
+ }
1001
+ async getTokenForSubject(e) {
1002
+ const t = e === "grpc" ? this.cachedGrpc : this.cachedJsonRpc;
1003
+ return t && this.now() + this.refreshSkewSecs < t.expiresAt ? t.token : (await this.acquireSingleFlight(e)).token;
985
1004
  }
986
1005
  /**
987
1006
  * Swap in a different transport for subsequent token-issuing calls.
@@ -994,43 +1013,43 @@ class ze {
994
1013
  setClient(e) {
995
1014
  this.client = e;
996
1015
  }
997
- acquireSingleFlight() {
998
- const e = this.inFlight;
999
- if (e) return e;
1000
- const t = (async () => {
1016
+ acquireSingleFlight(e) {
1017
+ const t = e === "grpc" ? this.inFlightGrpc : this.inFlightJsonRpc;
1018
+ if (t) return t;
1019
+ const n = e === "grpc" ? U : M, i = (async () => {
1001
1020
  try {
1002
- const n = await this.client.call(L, {
1021
+ const s = await this.client.call(n, {
1003
1022
  pegin_txid: this.peginTxid,
1004
1023
  auth_anchor: this.authAnchorHex
1005
1024
  });
1006
- if (Fe({
1007
- proof: n.server_identity,
1025
+ if (Ke({
1026
+ proof: s.server_identity,
1008
1027
  pinnedServerPubkey: this.pinnedServerPubkey,
1009
1028
  now: this.now()
1010
- }), typeof n.token != "string" || n.token.length === 0)
1029
+ }), typeof s.token != "string" || s.token.length === 0)
1011
1030
  throw new Error(
1012
- `VpTokenProvider: invalid token in acquire response (expected non-empty string, got ${typeof n.token})`
1031
+ `VpTokenProvider: invalid token in acquire response (expected non-empty string, got ${typeof s.token})`
1013
1032
  );
1014
- const s = this.now();
1015
- if (!Number.isSafeInteger(n.expires_at) || n.expires_at <= s || n.expires_at > Z)
1033
+ const o = this.now();
1034
+ if (!Number.isSafeInteger(s.expires_at) || s.expires_at <= o || s.expires_at > Q)
1016
1035
  throw new Error(
1017
- `VpTokenProvider: invalid expires_at in acquire response (got ${JSON.stringify(n.expires_at)}; must be a safe integer in (${s}, ${Z}])`
1036
+ `VpTokenProvider: invalid expires_at in acquire response (got ${JSON.stringify(s.expires_at)}; must be a safe integer in (${o}, ${Q}])`
1018
1037
  );
1019
- const a = {
1020
- token: n.token,
1021
- expiresAt: n.expires_at
1038
+ const c = {
1039
+ token: s.token,
1040
+ expiresAt: s.expires_at
1022
1041
  };
1023
- return this.cached = a, a;
1042
+ return e === "grpc" ? this.cachedGrpc = c : this.cachedJsonRpc = c, c;
1024
1043
  } finally {
1025
- this.inFlight = null;
1044
+ e === "grpc" ? this.inFlightGrpc = null : this.inFlightJsonRpc = null;
1026
1045
  }
1027
1046
  })();
1028
- return this.inFlight = t, t;
1047
+ return e === "grpc" ? this.inFlightGrpc = i : this.inFlightJsonRpc = i, i;
1029
1048
  }
1030
1049
  }
1031
- class We {
1050
+ class Ye {
1032
1051
  constructor() {
1033
- h(this, "entries", /* @__PURE__ */ new Map());
1052
+ p(this, "entries", /* @__PURE__ */ new Map());
1034
1053
  }
1035
1054
  /**
1036
1055
  * Return the cached `VpTokenProvider` for `peginTxid` if one exists
@@ -1052,12 +1071,13 @@ class We {
1052
1071
  );
1053
1072
  return t.provider.setClient(e.client), t.provider;
1054
1073
  }
1055
- const n = new ze({
1074
+ const n = new We({
1056
1075
  client: e.client,
1057
1076
  peginTxid: e.peginTxid,
1058
1077
  authAnchorHex: e.authAnchorHex,
1059
1078
  pinnedServerPubkey: e.pinnedServerPubkey,
1060
- authGatedMethods: Ke
1079
+ authGatedMethods: Xe,
1080
+ grpcGatedMethods: qe
1061
1081
  });
1062
1082
  return this.entries.set(e.peginTxid, {
1063
1083
  provider: n,
@@ -1091,13 +1111,13 @@ class We {
1091
1111
  return this.entries.size;
1092
1112
  }
1093
1113
  }
1094
- const ce = new We();
1095
- function dt(r) {
1114
+ const le = new Ye();
1115
+ function ht(r) {
1096
1116
  var n;
1097
- const e = oe(
1117
+ const e = ce(
1098
1118
  r.baseUrl,
1099
1119
  (n = r.options) == null ? void 0 : n.headers
1100
- ), t = ce.getOrCreate({
1120
+ ), t = le.getOrCreate({
1101
1121
  client: e,
1102
1122
  peginTxid: r.peginTxid,
1103
1123
  authAnchorHex: r.authAnchorHex,
@@ -1108,29 +1128,29 @@ function dt(r) {
1108
1128
  tokenProvider: t
1109
1129
  });
1110
1130
  }
1111
- function pt(r) {
1112
- ce.getOrCreate({
1113
- client: oe(r.baseUrl, r.headers),
1131
+ function gt(r) {
1132
+ le.getOrCreate({
1133
+ client: ce(r.baseUrl, r.headers),
1114
1134
  peginTxid: r.peginTxid,
1115
1135
  authAnchorHex: r.authAnchorHex,
1116
1136
  pinnedServerPubkey: r.pinnedServerPubkey
1117
1137
  });
1118
1138
  }
1119
1139
  export {
1120
- be as O,
1140
+ ye as O,
1121
1141
  g as S,
1122
1142
  Ne as V,
1123
- i as a,
1124
- ut as b,
1125
- Fe as c,
1126
- We as d,
1127
- ce as e,
1128
- dt as f,
1129
- ot as g,
1130
- lt as h,
1131
- ct as i,
1132
- pt as p,
1133
- at as r,
1134
- ke as v
1143
+ a,
1144
+ pt as b,
1145
+ Ke as c,
1146
+ Ye as d,
1147
+ le as e,
1148
+ ht as f,
1149
+ lt as g,
1150
+ dt as h,
1151
+ ut as i,
1152
+ gt as p,
1153
+ ct as r,
1154
+ Se as v
1135
1155
  };
1136
- //# sourceMappingURL=primeVpAuth-qEC9TTO_.js.map
1156
+ //# sourceMappingURL=primeVpAuth-DXl9wGBR.js.map