@babylonlabs-io/ts-sdk 0.70.0 → 0.71.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 (202) hide show
  1. package/dist/PeginManager-BIKAnZ-X.cjs +2 -0
  2. package/dist/PeginManager-BIKAnZ-X.cjs.map +1 -0
  3. package/dist/{PeginManager-erlaJqpN.js → PeginManager-Byvmccdd.js} +10 -10
  4. package/dist/PeginManager-Byvmccdd.js.map +1 -0
  5. package/dist/abortSignals-BPpAUL1Z.js +18 -0
  6. package/dist/abortSignals-BPpAUL1Z.js.map +1 -0
  7. package/dist/abortSignals-msbmbqFe.cjs +2 -0
  8. package/dist/abortSignals-msbmbqFe.cjs.map +1 -0
  9. package/dist/{bitcoin-Ch_jxnDa.js → bitcoin-C-TuHb-v.js} +21 -22
  10. package/dist/bitcoin-C-TuHb-v.js.map +1 -0
  11. package/dist/bitcoin-D-O2GjbC.cjs +2 -0
  12. package/dist/bitcoin-D-O2GjbC.cjs.map +1 -0
  13. package/dist/{buildAndBroadcastReclaim-CBPDgfj7.js → buildAndBroadcastReclaim-C0TdwO2M.js} +62 -61
  14. package/dist/buildAndBroadcastReclaim-C0TdwO2M.js.map +1 -0
  15. package/dist/buildAndBroadcastReclaim-kRx7-o2y.cjs +2 -0
  16. package/dist/buildAndBroadcastReclaim-kRx7-o2y.cjs.map +1 -0
  17. package/dist/{challengeAssert-BNQ8sToz.js → challengeAssert-Cp_GeRg8.js} +3 -3
  18. package/dist/challengeAssert-Cp_GeRg8.js.map +1 -0
  19. package/dist/challengeAssert-Z7_YULBb.cjs +2 -0
  20. package/dist/challengeAssert-Z7_YULBb.cjs.map +1 -0
  21. package/dist/constants-Bh38W9mq.cjs +2 -0
  22. package/dist/constants-Bh38W9mq.cjs.map +1 -0
  23. package/dist/constants-CPzppOdq.js +17 -0
  24. package/dist/constants-CPzppOdq.js.map +1 -0
  25. package/dist/index-Cs7_Evtk.cjs +2 -0
  26. package/dist/index-Cs7_Evtk.cjs.map +1 -0
  27. package/dist/index-LgmJhdEN.js +505 -0
  28. package/dist/index-LgmJhdEN.js.map +1 -0
  29. package/dist/index.cjs +1 -1
  30. package/dist/index.js +230 -226
  31. package/dist/index.js.map +1 -1
  32. package/dist/mempoolApi-BQllf-ji.cjs +2 -0
  33. package/dist/{mempoolApi-BJN9fGEd.cjs.map → mempoolApi-BQllf-ji.cjs.map} +1 -1
  34. package/dist/{mempoolApi-71R_CNZa.js → mempoolApi-CRNMOsbC.js} +36 -35
  35. package/dist/{mempoolApi-71R_CNZa.js.map → mempoolApi-CRNMOsbC.js.map} +1 -1
  36. package/dist/noPayout--lxo7qe4.js +300 -0
  37. package/dist/noPayout--lxo7qe4.js.map +1 -0
  38. package/dist/noPayout-CegnEwfp.cjs +2 -0
  39. package/dist/noPayout-CegnEwfp.cjs.map +1 -0
  40. package/dist/{onChainBtcPubkey-C_a2L3kL.cjs → onChainBtcPubkey-B5ZvWCCF.cjs} +2 -2
  41. package/dist/{onChainBtcPubkey-C_a2L3kL.cjs.map → onChainBtcPubkey-B5ZvWCCF.cjs.map} +1 -1
  42. package/dist/{onChainBtcPubkey-BAHZyKQL.js → onChainBtcPubkey-DATNfAAl.js} +2 -2
  43. package/dist/{onChainBtcPubkey-BAHZyKQL.js.map → onChainBtcPubkey-DATNfAAl.js.map} +1 -1
  44. package/dist/parseFundingOutpoints-BkgGihaY.cjs +2 -0
  45. package/dist/parseFundingOutpoints-BkgGihaY.cjs.map +1 -0
  46. package/dist/{parseFundingOutpoints-CO-f6IHK.js → parseFundingOutpoints-DlINgQ3X.js} +30 -29
  47. package/dist/parseFundingOutpoints-DlINgQ3X.js.map +1 -0
  48. package/dist/{batchPoll-Bc_UKaTz.js → primeVpAuth-D1qbOkhb.js} +311 -803
  49. package/dist/primeVpAuth-D1qbOkhb.js.map +1 -0
  50. package/dist/primeVpAuth-tEXx9TGx.cjs +2 -0
  51. package/dist/primeVpAuth-tEXx9TGx.cjs.map +1 -0
  52. package/dist/{reservation-CBAvoF3U.js → reservation-Cj9F0rP9.js} +2 -2
  53. package/dist/{reservation-CBAvoF3U.js.map → reservation-Cj9F0rP9.js.map} +1 -1
  54. package/dist/{reservation-CDbInVw0.cjs → reservation-Dr2HLCxx.cjs} +2 -2
  55. package/dist/{reservation-CDbInVw0.cjs.map → reservation-Dr2HLCxx.cjs.map} +1 -1
  56. package/dist/{signPsbtsWithFallback-DVyK-9A-.js → signPsbtsWithFallback-BjXdnI0X.js} +56 -48
  57. package/dist/signPsbtsWithFallback-BjXdnI0X.js.map +1 -0
  58. package/dist/signPsbtsWithFallback-zOQWokmk.cjs +2 -0
  59. package/dist/signPsbtsWithFallback-zOQWokmk.cjs.map +1 -0
  60. package/dist/tbv/core/clients/index.cjs +1 -1
  61. package/dist/tbv/core/clients/index.js +36 -35
  62. package/dist/tbv/core/clients/index.js.map +1 -1
  63. package/dist/tbv/core/clients/vault-provider/auth/serverIdentity.d.ts.map +1 -1
  64. package/dist/tbv/core/clients/vault-provider/auth/verifyDepositorCwt.d.ts.map +1 -1
  65. package/dist/tbv/core/clients/vault-provider/status/index.cjs +2 -0
  66. package/dist/tbv/core/clients/vault-provider/status/index.cjs.map +1 -0
  67. package/dist/tbv/core/clients/vault-provider/status/index.d.ts +18 -0
  68. package/dist/tbv/core/clients/vault-provider/status/index.d.ts.map +1 -0
  69. package/dist/tbv/core/clients/vault-provider/status/index.js +17 -0
  70. package/dist/tbv/core/clients/vault-provider/status/index.js.map +1 -0
  71. package/dist/tbv/core/clients/vault-provider/validators.d.ts.map +1 -1
  72. package/dist/tbv/core/deposit-terms/rebuildDepositTermsCore.d.ts +1 -1
  73. package/dist/tbv/core/deposit-terms/rebuildDepositTermsCore.d.ts.map +1 -1
  74. package/dist/tbv/core/index.cjs +1 -1
  75. package/dist/tbv/core/index.js +224 -220
  76. package/dist/tbv/core/index.js.map +1 -1
  77. package/dist/tbv/core/managers/PayoutManager.d.ts.map +1 -1
  78. package/dist/tbv/core/managers/index.cjs +1 -1
  79. package/dist/tbv/core/managers/index.js +2 -2
  80. package/dist/tbv/core/primitives/index.cjs +1 -1
  81. package/dist/tbv/core/primitives/index.d.ts +2 -2
  82. package/dist/tbv/core/primitives/index.d.ts.map +1 -1
  83. package/dist/tbv/core/primitives/index.js +7 -7
  84. package/dist/tbv/core/primitives/psbt/assertWasmPeginSizing.d.ts +1 -1
  85. package/dist/tbv/core/primitives/psbt/assertWasmPeginSizing.d.ts.map +1 -1
  86. package/dist/tbv/core/primitives/psbt/challengeAssert.d.ts +1 -1
  87. package/dist/tbv/core/primitives/psbt/challengeAssert.d.ts.map +1 -1
  88. package/dist/tbv/core/primitives/psbt/constants.d.ts +7 -0
  89. package/dist/tbv/core/primitives/psbt/constants.d.ts.map +1 -1
  90. package/dist/tbv/core/primitives/psbt/noPayout.d.ts +1 -1
  91. package/dist/tbv/core/primitives/psbt/noPayout.d.ts.map +1 -1
  92. package/dist/tbv/core/primitives/psbt/payout.d.ts +1 -1
  93. package/dist/tbv/core/primitives/psbt/payout.d.ts.map +1 -1
  94. package/dist/tbv/core/primitives/psbt/pegin.d.ts +1 -1
  95. package/dist/tbv/core/primitives/psbt/pegin.d.ts.map +1 -1
  96. package/dist/tbv/core/primitives/psbt/peginInput.d.ts +1 -1
  97. package/dist/tbv/core/primitives/psbt/peginInput.d.ts.map +1 -1
  98. package/dist/tbv/core/primitives/psbt/refund.d.ts.map +1 -1
  99. package/dist/tbv/core/primitives/scripts/payout.d.ts +1 -1
  100. package/dist/tbv/core/primitives/scripts/payout.d.ts.map +1 -1
  101. package/dist/tbv/core/primitives/utils/bitcoin.d.ts +0 -10
  102. package/dist/tbv/core/primitives/utils/bitcoin.d.ts.map +1 -1
  103. package/dist/tbv/core/recovery/reconstructPeginParams.d.ts.map +1 -1
  104. package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts.map +1 -1
  105. package/dist/tbv/core/services/index.cjs +1 -1
  106. package/dist/tbv/core/services/index.js +2 -2
  107. package/dist/tbv/core/utils/index.cjs +1 -1
  108. package/dist/tbv/core/utils/index.js +47 -44
  109. package/dist/tbv/core/utils/index.js.map +1 -1
  110. package/dist/tbv/core/utils/utxo/reservation.d.ts.map +1 -1
  111. package/dist/tbv/core/utils/validation.d.ts +4 -0
  112. package/dist/tbv/core/utils/validation.d.ts.map +1 -1
  113. package/dist/tbv/core/vault-secrets/deriveVaultRoot.d.ts.map +1 -1
  114. package/dist/tbv/core/vault-secrets/index.cjs +1 -1
  115. package/dist/tbv/core/vault-secrets/index.d.ts +1 -1
  116. package/dist/tbv/core/vault-secrets/index.d.ts.map +1 -1
  117. package/dist/tbv/core/vault-secrets/index.js +2 -2
  118. package/dist/tbv/core/wasm/__tests__/constants.test.d.ts +2 -0
  119. package/dist/tbv/core/wasm/__tests__/constants.test.d.ts.map +1 -0
  120. package/dist/tbv/core/wasm/__tests__/loader.test.d.ts +2 -0
  121. package/dist/tbv/core/wasm/__tests__/loader.test.d.ts.map +1 -0
  122. package/dist/tbv/core/wasm/__tests__/value-guards.test.d.ts +2 -0
  123. package/dist/tbv/core/wasm/__tests__/value-guards.test.d.ts.map +1 -0
  124. package/dist/tbv/core/wasm/constants.d.ts +11 -0
  125. package/dist/tbv/core/wasm/constants.d.ts.map +1 -0
  126. package/dist/tbv/core/wasm/index.cjs +2 -0
  127. package/dist/tbv/core/wasm/index.cjs.map +1 -0
  128. package/dist/tbv/core/wasm/index.d.ts +191 -0
  129. package/dist/tbv/core/wasm/index.d.ts.map +1 -0
  130. package/dist/tbv/core/wasm/index.js +144 -0
  131. package/dist/tbv/core/wasm/index.js.map +1 -0
  132. package/dist/tbv/core/wasm/value-guards.d.ts +30 -0
  133. package/dist/tbv/core/wasm/value-guards.d.ts.map +1 -0
  134. package/dist/tbv/index.cjs +1 -1
  135. package/dist/tbv/index.js +224 -220
  136. package/dist/tbv/index.js.map +1 -1
  137. package/dist/testing/index.cjs +1 -1
  138. package/dist/testing/index.js +1 -1
  139. package/dist/toRefundInputs-Bdtz8p27.cjs +2 -0
  140. package/dist/toRefundInputs-Bdtz8p27.cjs.map +1 -0
  141. package/dist/{toRefundInputs-ZkvoR5Df.js → toRefundInputs-CgXMcHrk.js} +7 -7
  142. package/dist/toRefundInputs-CgXMcHrk.js.map +1 -0
  143. package/dist/validation-C6XTfZak.cjs +2 -0
  144. package/dist/validation-C6XTfZak.cjs.map +1 -0
  145. package/dist/validation-OSC0xTHB.js +17 -0
  146. package/dist/validation-OSC0xTHB.js.map +1 -0
  147. package/dist/vaultCoreVersion-DYfw3qed.cjs +2 -0
  148. package/dist/vaultCoreVersion-DYfw3qed.cjs.map +1 -0
  149. package/dist/vaultCoreVersion-D_fP9P3C.js +10 -0
  150. package/dist/vaultCoreVersion-D_fP9P3C.js.map +1 -0
  151. package/dist/verifyKeyPathSchnorrSignature-BedSbH2D.cjs +2 -0
  152. package/dist/verifyKeyPathSchnorrSignature-BedSbH2D.cjs.map +1 -0
  153. package/dist/{verifyKeyPathSchnorrSignature-C6Cmk0R1.js → verifyKeyPathSchnorrSignature-BrgUJmV0.js} +3 -3
  154. package/dist/verifyKeyPathSchnorrSignature-BrgUJmV0.js.map +1 -0
  155. package/dist/{verifyScriptPathSchnorrSignature-B7MhJmhy.js → verifyScriptPathSchnorrSignature-ZAZfFJ6S.js} +35 -34
  156. package/dist/verifyScriptPathSchnorrSignature-ZAZfFJ6S.js.map +1 -0
  157. package/dist/verifyScriptPathSchnorrSignature-mzYCzaSy.cjs +2 -0
  158. package/dist/verifyScriptPathSchnorrSignature-mzYCzaSy.cjs.map +1 -0
  159. package/package.json +12 -2
  160. package/dist/PeginManager-BpouMHkS.cjs +0 -2
  161. package/dist/PeginManager-BpouMHkS.cjs.map +0 -1
  162. package/dist/PeginManager-erlaJqpN.js.map +0 -1
  163. package/dist/batchPoll-Bc_UKaTz.js.map +0 -1
  164. package/dist/batchPoll-C9cZ5usJ.cjs +0 -2
  165. package/dist/batchPoll-C9cZ5usJ.cjs.map +0 -1
  166. package/dist/bitcoin-Ch_jxnDa.js.map +0 -1
  167. package/dist/bitcoin-m84N5a8o.cjs +0 -2
  168. package/dist/bitcoin-m84N5a8o.cjs.map +0 -1
  169. package/dist/buildAndBroadcastReclaim-CBPDgfj7.js.map +0 -1
  170. package/dist/buildAndBroadcastReclaim-DsJ5CB_H.cjs +0 -2
  171. package/dist/buildAndBroadcastReclaim-DsJ5CB_H.cjs.map +0 -1
  172. package/dist/challengeAssert-BNQ8sToz.js.map +0 -1
  173. package/dist/challengeAssert-BrpC3-cQ.cjs +0 -2
  174. package/dist/challengeAssert-BrpC3-cQ.cjs.map +0 -1
  175. package/dist/constants-DU5CGcqO.cjs +0 -2
  176. package/dist/constants-DU5CGcqO.cjs.map +0 -1
  177. package/dist/constants-GjWXdaqV.js +0 -23
  178. package/dist/constants-GjWXdaqV.js.map +0 -1
  179. package/dist/mempoolApi-BJN9fGEd.cjs +0 -2
  180. package/dist/noPayout-CDi6f5-I.js +0 -280
  181. package/dist/noPayout-CDi6f5-I.js.map +0 -1
  182. package/dist/noPayout-Cbi9TCRz.cjs +0 -2
  183. package/dist/noPayout-Cbi9TCRz.cjs.map +0 -1
  184. package/dist/parseFundingOutpoints-CIO9Ok1L.cjs +0 -2
  185. package/dist/parseFundingOutpoints-CIO9Ok1L.cjs.map +0 -1
  186. package/dist/parseFundingOutpoints-CO-f6IHK.js.map +0 -1
  187. package/dist/signPsbtsWithFallback-DVyK-9A-.js.map +0 -1
  188. package/dist/signPsbtsWithFallback-DY2jBtNB.cjs +0 -2
  189. package/dist/signPsbtsWithFallback-DY2jBtNB.cjs.map +0 -1
  190. package/dist/toRefundInputs-Cn6z5_Ko.cjs +0 -2
  191. package/dist/toRefundInputs-Cn6z5_Ko.cjs.map +0 -1
  192. package/dist/toRefundInputs-ZkvoR5Df.js.map +0 -1
  193. package/dist/validation-CDbOaDj7.cjs +0 -2
  194. package/dist/validation-CDbOaDj7.cjs.map +0 -1
  195. package/dist/validation-Dj3dqYtl.js +0 -30
  196. package/dist/validation-Dj3dqYtl.js.map +0 -1
  197. package/dist/verifyKeyPathSchnorrSignature-C6Cmk0R1.js.map +0 -1
  198. package/dist/verifyKeyPathSchnorrSignature-Cr5T4Aym.cjs +0 -2
  199. package/dist/verifyKeyPathSchnorrSignature-Cr5T4Aym.cjs.map +0 -1
  200. package/dist/verifyScriptPathSchnorrSignature-B7MhJmhy.js.map +0 -1
  201. package/dist/verifyScriptPathSchnorrSignature-BBS9oCPO.cjs +0 -2
  202. package/dist/verifyScriptPathSchnorrSignature-BBS9oCPO.cjs.map +0 -1
@@ -1,26 +1,26 @@
1
- var ve = Object.defineProperty;
2
- var Ae = (r, e, t) => e in r ? ve(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var f = (r, e, t) => Ae(r, typeof e != "symbol" ? e + "" : e, t);
4
- import { B as N } from "./BTCVaultRegistry.abi-CJwWI2EO.js";
5
- import { A as I, P as m } from "./ProtocolParams.abi-C0TSRaHV.js";
6
- import { k as Ee, v as H, o as Ce, j as ke, l as Se } from "./mempoolApi-71R_CNZa.js";
7
- import { X as R, C as G, s as V, S as $e, h as Te, p as de } from "./bitcoin-Ch_jxnDa.js";
8
- import { D as Ve, a as pe, e as Ie } from "./json-rpc-client-DuUARJvV.js";
9
- import { C as Y } from "./constants-GjWXdaqV.js";
10
- import { H as k } from "./validation-Dj3dqYtl.js";
11
- import * as he from "@bitcoin-js/tiny-secp256k1-asmjs";
12
- import { s as Re } from "./sha2-BYVxyZzX.js";
13
- async function qt(r, e) {
1
+ var ce = Object.defineProperty;
2
+ var le = (r, e, t) => e in r ? ce(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var h = (r, e, t) => le(r, typeof e != "symbol" ? e + "" : e, t);
4
+ import { B as v } from "./BTCVaultRegistry.abi-CJwWI2EO.js";
5
+ import { A as _, P as g } from "./ProtocolParams.abi-C0TSRaHV.js";
6
+ import { k as ue, v as O, o as de, j as he, l as pe } from "./mempoolApi-CRNMOsbC.js";
7
+ import { s as A, S as ge, h as me, p as Z } from "./bitcoin-C-TuHb-v.js";
8
+ import { V as fe } from "./index-LgmJhdEN.js";
9
+ import { a as ye } from "./json-rpc-client-DuUARJvV.js";
10
+ import * as q from "@bitcoin-js/tiny-secp256k1-asmjs";
11
+ import { X as C, H as b, C as ee } from "./validation-OSC0xTHB.js";
12
+ import { s as be } from "./sha2-BYVxyZzX.js";
13
+ async function At(r, e) {
14
14
  const [t, n] = await r.multicall({
15
15
  contracts: [
16
16
  {
17
17
  address: e,
18
- abi: N,
18
+ abi: v,
19
19
  functionName: "protocolParams"
20
20
  },
21
21
  {
22
22
  address: e,
23
- abi: N,
23
+ abi: v,
24
24
  functionName: "applicationRegistry"
25
25
  }
26
26
  ],
@@ -31,20 +31,20 @@ async function qt(r, e) {
31
31
  applicationRegistry: n
32
32
  };
33
33
  }
34
- function q(r, e, t) {
34
+ function K(r, e, t) {
35
35
  if (r !== e)
36
36
  throw new Error(
37
37
  `${t}: multicall returned ${r} results for ${e} calls, so the results are not roster-aligned; refusing to use them`
38
38
  );
39
39
  }
40
- function Oe(r, e) {
40
+ function Ae(r, e) {
41
41
  return {
42
42
  vaultProvider: r[0],
43
43
  vaultKeepers: r.slice(1, 1 + e),
44
44
  universalChallengers: r.slice(1 + e)
45
45
  };
46
46
  }
47
- class Qt {
47
+ class _t {
48
48
  constructor(e, t) {
49
49
  this.publicClient = e, this.contracts = t;
50
50
  }
@@ -59,29 +59,29 @@ class Qt {
59
59
  contracts: e,
60
60
  allowFailure: !1
61
61
  });
62
- return q(
62
+ return K(
63
63
  s.length,
64
64
  1 + t + n,
65
65
  i
66
- ), Oe(s, t);
66
+ ), Ae(s, t);
67
67
  }
68
68
  async getCurrentOperationKeys(e) {
69
69
  const t = [
70
70
  {
71
71
  address: this.contracts.btcVaultRegistry,
72
- abi: N,
72
+ abi: v,
73
73
  functionName: "getCurrentOperationBtcKey",
74
74
  args: [e.vaultProviderEthAddress]
75
75
  },
76
76
  ...e.vaultKeepers.map((n) => ({
77
77
  address: this.contracts.applicationRegistry,
78
- abi: I,
78
+ abi: _,
79
79
  functionName: "getCurrentOperationBtcKey",
80
80
  args: [e.applicationEntryPoint, n.ethAddress]
81
81
  })),
82
82
  ...e.universalChallengers.map((n) => ({
83
83
  address: this.contracts.protocolParams,
84
- abi: m,
84
+ abi: g,
85
85
  functionName: "getCurrentOperationBtcKey",
86
86
  args: [n.ethAddress]
87
87
  }))
@@ -100,7 +100,7 @@ class Qt {
100
100
  // unambiguous and the contract resolves it internally.
101
101
  {
102
102
  address: this.contracts.btcVaultRegistry,
103
- abi: N,
103
+ abi: v,
104
104
  functionName: "getOperationBtcKeyAtEpoch",
105
105
  args: [e.vaultProviderEthAddress, t.vpKeyEpoch]
106
106
  },
@@ -111,7 +111,7 @@ class Qt {
111
111
  // version, would otherwise resolve against the wrong genesis.
112
112
  ...e.vaultKeepers.map((i) => ({
113
113
  address: this.contracts.applicationRegistry,
114
- abi: I,
114
+ abi: _,
115
115
  functionName: "getOperationBtcKeyAtEpochOrGenesis",
116
116
  args: [
117
117
  e.applicationEntryPoint,
@@ -122,7 +122,7 @@ class Qt {
122
122
  })),
123
123
  ...e.universalChallengers.map((i) => ({
124
124
  address: this.contracts.protocolParams,
125
- abi: m,
125
+ abi: g,
126
126
  functionName: "getOperationBtcKeyAtEpochOrGenesis",
127
127
  args: [i.ethAddress, t.ucKeyEpoch, i.btcPubKey]
128
128
  }))
@@ -139,13 +139,13 @@ class Qt {
139
139
  contracts: [
140
140
  {
141
141
  address: this.contracts.btcVaultRegistry,
142
- abi: N,
142
+ abi: v,
143
143
  functionName: "getPayoutScriptAtEpoch",
144
144
  args: [e.vaultProviderEthAddress, t.vpKeyEpoch]
145
145
  },
146
146
  ...e.vaultKeepers.map((i) => ({
147
147
  address: this.contracts.applicationRegistry,
148
- abi: I,
148
+ abi: _,
149
149
  functionName: "getPayoutScriptAtEpoch",
150
150
  args: [
151
151
  e.applicationEntryPoint,
@@ -156,7 +156,7 @@ class Qt {
156
156
  ],
157
157
  allowFailure: !1
158
158
  });
159
- return q(
159
+ return K(
160
160
  n.length,
161
161
  1 + e.vaultKeepers.length,
162
162
  "getPayoutScriptsAtEpochs"
@@ -166,8 +166,8 @@ class Qt {
166
166
  };
167
167
  }
168
168
  }
169
- const Q = 65535;
170
- function B(r) {
169
+ const H = 65535;
170
+ function P(r) {
171
171
  return {
172
172
  timelockAssert: r.timelockAssert,
173
173
  timelockChallengeAssert: r.timelockChallengeAssert,
@@ -184,7 +184,7 @@ function B(r) {
184
184
  minPrepeginDepth: r.minPrepeginDepth
185
185
  };
186
186
  }
187
- function Z(r) {
187
+ function L(r) {
188
188
  return {
189
189
  minimumPegInAmount: r.minimumPegInAmount,
190
190
  maxPegInAmount: r.maxPegInAmount,
@@ -194,53 +194,53 @@ function Z(r) {
194
194
  expiredPegInGraceBlocks: r.expiredPegInGraceBlocks
195
195
  };
196
196
  }
197
- function ee(r) {
198
- if (r > BigInt(Q))
197
+ function U(r) {
198
+ if (r > BigInt(H))
199
199
  throw new Error(
200
- `timelockAssert value ${r} exceeds uint16 max (${Q})`
200
+ `timelockAssert value ${r} exceeds uint16 max (${H})`
201
201
  );
202
202
  return Number(r);
203
203
  }
204
- class Zt {
204
+ class wt {
205
205
  constructor(e, t) {
206
206
  this.publicClient = e, this.contractAddress = t;
207
207
  }
208
208
  async getTBVProtocolParams() {
209
209
  const e = await this.publicClient.readContract({
210
210
  address: this.contractAddress,
211
- abi: m,
211
+ abi: g,
212
212
  functionName: "getTBVProtocolParams"
213
- }), t = Z(e);
214
- return Ee(t), t;
213
+ }), t = L(e);
214
+ return ue(t), t;
215
215
  }
216
216
  async getLatestOffchainParams() {
217
217
  const e = await this.publicClient.readContract({
218
218
  address: this.contractAddress,
219
- abi: m,
219
+ abi: g,
220
220
  functionName: "getLatestOffchainParams"
221
- }), t = B(e);
222
- return H(t), t;
221
+ }), t = P(e);
222
+ return O(t), t;
223
223
  }
224
224
  async getOffchainParamsByVersion(e) {
225
225
  const t = await this.publicClient.readContract({
226
226
  address: this.contractAddress,
227
- abi: m,
227
+ abi: g,
228
228
  functionName: "getOffchainParamsByVersion",
229
229
  args: [e]
230
- }), n = B(t);
231
- return H(n), n;
230
+ }), n = P(t);
231
+ return O(n), n;
232
232
  }
233
233
  async getLatestOffchainParamsVersion() {
234
234
  const e = await this.publicClient.readContract({
235
235
  address: this.contractAddress,
236
- abi: m,
236
+ abi: g,
237
237
  functionName: "latestOffchainParamsVersion"
238
238
  }), t = Number(e);
239
- return Ce(t), t;
239
+ return de(t), t;
240
240
  }
241
241
  async getTimelockPeginByVersion(e) {
242
242
  const t = await this.getOffchainParamsByVersion(e);
243
- return ee(t.timelockAssert);
243
+ return U(t.timelockAssert);
244
244
  }
245
245
  /**
246
246
  * Returned as `bigint` with no `Number` narrowing: the registry compares it
@@ -255,7 +255,7 @@ class Zt {
255
255
  async getPeginActivationDelay() {
256
256
  const e = await this.publicClient.readContract({
257
257
  address: this.contractAddress,
258
- abi: m,
258
+ abi: g,
259
259
  functionName: "peginActivationDelay"
260
260
  });
261
261
  if (typeof e != "bigint")
@@ -276,41 +276,41 @@ class Zt {
276
276
  contracts: [
277
277
  {
278
278
  address: this.contractAddress,
279
- abi: m,
279
+ abi: g,
280
280
  functionName: "getTBVProtocolParams"
281
281
  },
282
282
  {
283
283
  address: this.contractAddress,
284
- abi: m,
284
+ abi: g,
285
285
  functionName: "getLatestOffchainParams"
286
286
  },
287
287
  {
288
288
  address: this.contractAddress,
289
- abi: m,
289
+ abi: g,
290
290
  functionName: "latestOffchainParamsVersion"
291
291
  },
292
292
  {
293
293
  address: this.contractAddress,
294
- abi: m,
294
+ abi: g,
295
295
  functionName: "activeVaultCoreVersion"
296
296
  }
297
297
  ],
298
298
  allowFailure: !1
299
- }), t = Z(e[0]), n = B(e[1]), i = Number(e[2]), s = Number(e[3]), a = {
299
+ }), t = L(e[0]), n = P(e[1]), i = Number(e[2]), s = Number(e[3]), a = {
300
300
  minimumPegInAmount: t.minimumPegInAmount,
301
301
  maxPegInAmount: t.maxPegInAmount,
302
302
  pegInAckTimeout: t.pegInAckTimeout,
303
303
  pegInActivationTimeout: t.pegInActivationTimeout,
304
304
  maxHtlcOutputCount: t.maxHtlcOutputCount,
305
305
  expiredPegInGraceBlocks: t.expiredPegInGraceBlocks,
306
- timelockPegin: ee(n.timelockAssert),
306
+ timelockPegin: U(n.timelockAssert),
307
307
  timelockRefund: n.tRefund,
308
308
  minVpCommissionBps: n.minVpCommissionBps,
309
309
  offchainParams: n,
310
310
  offchainParamsVersion: i,
311
311
  activeVaultCoreVersion: s
312
312
  };
313
- return ke(a), a;
313
+ return he(a), a;
314
314
  }
315
315
  /**
316
316
  * Fetch every historical offchain params version in a single multicall.
@@ -326,22 +326,22 @@ class Zt {
326
326
  const t = await this.getLatestOffchainParamsVersion();
327
327
  if (t === 0)
328
328
  return { byVersion: /* @__PURE__ */ new Map(), latestVersion: 0 };
329
- const n = Array.from({ length: t }, (c, u) => u + 1), i = n.map((c) => ({
329
+ const n = Array.from({ length: t }, (o, u) => u + 1), i = n.map((o) => ({
330
330
  address: this.contractAddress,
331
- abi: m,
331
+ abi: g,
332
332
  functionName: "getOffchainParamsByVersion",
333
- args: [c]
333
+ args: [o]
334
334
  })), s = await this.publicClient.multicall({
335
335
  contracts: i,
336
336
  allowFailure: !1
337
337
  }), a = /* @__PURE__ */ new Map();
338
- for (let c = 0; c < n.length; c++) {
339
- const u = B(s[c]);
338
+ for (let o = 0; o < n.length; o++) {
339
+ const u = P(s[o]);
340
340
  try {
341
- H(u), a.set(n[c], u);
341
+ O(u), a.set(n[o], u);
342
342
  } catch (d) {
343
343
  e == null || e(
344
- n[c],
344
+ n[o],
345
345
  d instanceof Error ? d : new Error(String(d))
346
346
  );
347
347
  }
@@ -349,491 +349,74 @@ class Zt {
349
349
  return { byVersion: a, latestVersion: t };
350
350
  }
351
351
  }
352
- function j(r) {
352
+ function k(r) {
353
353
  return r.map((e) => ({
354
354
  ethAddress: e.ethAddress,
355
355
  btcPubKey: e.btcPubKey
356
356
  }));
357
357
  }
358
- class er {
358
+ class xt {
359
359
  constructor(e, t) {
360
360
  this.publicClient = e, this.contractAddress = t;
361
361
  }
362
362
  async getVaultKeepersByVersion(e, t) {
363
363
  const n = await this.publicClient.readContract({
364
364
  address: this.contractAddress,
365
- abi: I,
365
+ abi: _,
366
366
  functionName: "getVaultKeepersByVersion",
367
367
  args: [e, t]
368
368
  });
369
- return j(n);
369
+ return k(n);
370
370
  }
371
371
  async getCurrentVaultKeepers(e) {
372
372
  const t = await this.publicClient.readContract({
373
373
  address: this.contractAddress,
374
- abi: I,
374
+ abi: _,
375
375
  functionName: "getCurrentVaultKeepers",
376
376
  args: [e]
377
377
  });
378
- return j(t);
378
+ return k(t);
379
379
  }
380
380
  async getCurrentVaultKeepersVersion(e) {
381
381
  return await this.publicClient.readContract({
382
382
  address: this.contractAddress,
383
- abi: I,
383
+ abi: _,
384
384
  functionName: "getCurrentVaultKeepersVersion",
385
385
  args: [e]
386
386
  });
387
387
  }
388
388
  }
389
- class tr {
389
+ class vt {
390
390
  constructor(e, t) {
391
391
  this.publicClient = e, this.contractAddress = t;
392
392
  }
393
393
  async getUniversalChallengersByVersion(e) {
394
394
  const t = await this.publicClient.readContract({
395
395
  address: this.contractAddress,
396
- abi: m,
396
+ abi: g,
397
397
  functionName: "getUniversalChallengersByVersion",
398
398
  args: [e]
399
399
  });
400
- return j(t);
400
+ return k(t);
401
401
  }
402
402
  async getCurrentUniversalChallengers() {
403
403
  const e = await this.publicClient.readContract({
404
404
  address: this.contractAddress,
405
- abi: m,
405
+ abi: g,
406
406
  functionName: "getCurrentUniversalChallengers"
407
407
  });
408
- return j(e);
408
+ return k(e);
409
409
  }
410
410
  async getLatestUniversalChallengersVersion() {
411
411
  return await this.publicClient.readContract({
412
412
  address: this.contractAddress,
413
- abi: m,
413
+ abi: g,
414
414
  functionName: "latestUniversalChallengersVersion"
415
415
  });
416
416
  }
417
417
  }
418
- var Ne = /* @__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))(Ne || {});
419
- const te = new Set(Object.values(Ve)), Be = 200;
420
- function h(r) {
421
- var e;
422
- return ((e = JSON.stringify(r)) == null ? void 0 : e.slice(0, Be)) ?? "undefined";
423
- }
424
- const De = "The vault provider returned an unexpected response. Please try again or contact support.";
425
- class o extends Error {
426
- constructor(t) {
427
- super(De);
428
- f(this, "detail");
429
- this.name = "VpResponseValidationError", this.detail = t;
430
- }
431
- }
432
- const O = 64;
433
- function $(r) {
434
- return typeof r == "string" && r.length > 0 && k.test(r);
435
- }
436
- function ge(r) {
437
- return typeof r == "string" && r.length > 0;
438
- }
439
- function fe(r, e) {
440
- if (!$(r))
441
- throw new o(
442
- `VP response validation failed: "${e}" must be a non-empty hex string, got ${h(r)}`
443
- );
444
- }
445
- function w(r, e) {
446
- if (!ge(r))
447
- throw new o(
448
- `VP response validation failed: "${e}" must be a non-empty string, got ${h(r)}`
449
- );
450
- }
451
- function z(r, e) {
452
- if (!$(r) || r.length !== R && r.length !== G)
453
- throw new o(
454
- `VP response validation failed: "${e}" must be a ${R} or ${G}-char hex string (BTC pubkey), got ${h(r)}`
455
- );
456
- }
457
- function Me(r) {
458
- const e = r.presigning;
459
- if (e == null) return;
460
- if (typeof e != "object" || Array.isArray(e))
461
- throw new o(
462
- 'VP response validation failed: "progress.presigning" must be an object if present'
463
- );
464
- const t = e;
465
- if (t.depositor_graph_created !== void 0 && typeof t.depositor_graph_created != "boolean")
466
- throw new o(
467
- `VP response validation failed: "progress.presigning.depositor_graph_created" must be a boolean if present, got ${h(t.depositor_graph_created)}`
468
- );
469
- if (t.vk_challenger_presigning_completed !== void 0 && typeof t.vk_challenger_presigning_completed != "number")
470
- throw new o(
471
- `VP response validation failed: "progress.presigning.vk_challenger_presigning_completed" must be a number if present, got ${h(t.vk_challenger_presigning_completed)}`
472
- );
473
- if (t.vk_challenger_presigning_total !== void 0 && typeof t.vk_challenger_presigning_total != "number")
474
- throw new o(
475
- `VP response validation failed: "progress.presigning.vk_challenger_presigning_total" must be a number if present, got ${h(t.vk_challenger_presigning_total)}`
476
- );
477
- }
478
- function _e(r) {
479
- if (r === null || typeof r != "object")
480
- throw new o(
481
- "VP response validation failed: getPeginStatus response is not an object"
482
- );
483
- const e = r;
484
- if (!$(e.pegin_txid) || e.pegin_txid.length !== O)
485
- throw new o(
486
- `VP response validation failed: "pegin_txid" must be a ${O}-char hex string (txid), got ${h(e.pegin_txid)}`
487
- );
488
- if (typeof e.status != "string")
489
- throw new o(
490
- 'VP response validation failed: "status" must be a string'
491
- );
492
- if (!te.has(e.status))
493
- throw new o(
494
- `VP response validation failed: unrecognized status "${e.status}". Expected one of: ${[...te].join(", ")}`
495
- );
496
- if (e.progress === null || typeof e.progress != "object" || Array.isArray(e.progress))
497
- throw new o(
498
- 'VP response validation failed: "progress" must be an object'
499
- );
500
- if (Me(e.progress), typeof e.health_info != "string")
501
- throw new o(
502
- 'VP response validation failed: "health_info" must be a string'
503
- );
504
- if (e.last_error !== void 0 && typeof e.last_error != "string")
505
- throw new o(
506
- `VP response validation failed: "last_error" must be a string if present, got ${h(e.last_error)}`
507
- );
508
- }
509
- function Ge(r) {
510
- if (r === null || typeof r != "object")
511
- throw new o(
512
- "VP response validation failed: requestDepositorPresignTransactions response is not an object"
513
- );
514
- const e = r;
515
- if (!Array.isArray(e.txs))
516
- throw new o(
517
- 'VP response validation failed: "txs" must be an array'
518
- );
519
- for (let t = 0; t < e.txs.length; t++)
520
- je(e.txs[t], `txs[${t}]`);
521
- if (e.depositor_graph === null || typeof e.depositor_graph != "object")
522
- throw new o(
523
- 'VP response validation failed: "depositor_graph" must be an object'
524
- );
525
- ze(
526
- e.depositor_graph
527
- );
528
- }
529
- function v(r, e) {
530
- if (r === null || typeof r != "object")
531
- throw new o(
532
- `VP response validation failed: "${e}" must be an object`
533
- );
534
- fe(r.tx_hex, `${e}.tx_hex`);
535
- }
536
- function je(r, e) {
537
- if (r === null || typeof r != "object")
538
- throw new o(
539
- `VP response validation failed: "${e}" must be an object`
540
- );
541
- const t = r;
542
- z(t.claimer_pubkey, `${e}.claimer_pubkey`), v(t.claim_tx, `${e}.claim_tx`), v(t.assert_tx, `${e}.assert_tx`), v(t.payout_tx, `${e}.payout_tx`), w(t.payout_psbt, `${e}.payout_psbt`);
543
- }
544
- function Le(r, e) {
545
- if (r === null || typeof r != "object")
546
- throw new o(
547
- `VP response validation failed: "${e}" must be an object`
548
- );
549
- const t = r;
550
- w(t.wots_pks_json, `${e}.wots_pks_json`), w(t.gc_wots_keys_json, `${e}.gc_wots_keys_json`);
551
- }
552
- function He(r, e) {
553
- if (r === null || typeof r != "object")
554
- throw new o(
555
- `VP response validation failed: "${e}" must be an object`
556
- );
557
- const t = r;
558
- if (z(t.challenger_pubkey, `${e}.challenger_pubkey`), v(
559
- t.challenge_assert_x_tx,
560
- `${e}.challenge_assert_x_tx`
561
- ), v(
562
- t.challenge_assert_y_tx,
563
- `${e}.challenge_assert_y_tx`
564
- ), v(t.nopayout_tx, `${e}.nopayout_tx`), w(t.nopayout_psbt, `${e}.nopayout_psbt`), !Array.isArray(t.challenge_assert_connectors))
565
- throw new o(
566
- `VP response validation failed: "${e}.challenge_assert_connectors" must be an array`
567
- );
568
- if (t.challenge_assert_connectors.length !== Y)
569
- throw new o(
570
- `VP response validation failed: "${e}.challenge_assert_connectors" must have exactly ${Y} entries, got ${t.challenge_assert_connectors.length}`
571
- );
572
- for (let n = 0; n < t.challenge_assert_connectors.length; n++)
573
- Le(
574
- t.challenge_assert_connectors[n],
575
- `${e}.challenge_assert_connectors[${n}]`
576
- );
577
- if (!Array.isArray(t.output_label_hashes))
578
- throw new o(
579
- `VP response validation failed: "${e}.output_label_hashes" must be an array`
580
- );
581
- for (let n = 0; n < t.output_label_hashes.length; n++)
582
- fe(
583
- t.output_label_hashes[n],
584
- `${e}.output_label_hashes[${n}]`
585
- );
586
- }
587
- function Ke(r) {
588
- if (r === null || typeof r != "object")
589
- throw new o(
590
- "VP response validation failed: requestDepositorClaimerArtifacts response is not an object"
591
- );
592
- const e = r;
593
- if (!ge(e.tx_graph_json))
594
- throw new o(
595
- `VP response validation failed: "tx_graph_json" must be a non-empty string, got ${h(e.tx_graph_json)}`
596
- );
597
- if (!$(e.verifying_key_hex))
598
- throw new o(
599
- `VP response validation failed: "verifying_key_hex" must be a non-empty hex string, got ${h(e.verifying_key_hex)}`
600
- );
601
- if (e.babe_sessions === null || typeof e.babe_sessions != "object" || Array.isArray(e.babe_sessions))
602
- throw new o(
603
- 'VP response validation failed: "babe_sessions" must be an object'
604
- );
605
- const t = Object.entries(
606
- e.babe_sessions
607
- );
608
- if (t.length === 0)
609
- throw new o(
610
- 'VP response validation failed: "babe_sessions" must contain at least one challenger entry'
611
- );
612
- for (const [n, i] of t) {
613
- if (z(n, `babe_sessions["${n}"]`), i === null || typeof i != "object")
614
- throw new o(
615
- `VP response validation failed: "babe_sessions.${n}" must be an object`
616
- );
617
- const s = i;
618
- if (!$(s.decryptor_artifacts_hex))
619
- throw new o(
620
- `VP response validation failed: "babe_sessions.${n}.decryptor_artifacts_hex" must be a non-empty hex string, got ${h(s.decryptor_artifacts_hex)}`
621
- );
622
- }
623
- }
624
- function Ue(r) {
625
- if (r === null || typeof r != "object")
626
- throw new o(
627
- "VP response validation failed: pegout status payload is not an object"
628
- );
629
- const e = r;
630
- if (!$(e.pegin_txid) || e.pegin_txid.length !== O)
631
- throw new o(
632
- `VP response validation failed: "pegin_txid" must be a ${O}-char hex string (txid), got ${h(e.pegin_txid)}`
633
- );
634
- if (typeof e.found != "boolean")
635
- throw new o(
636
- `VP response validation failed: "found" must be a boolean, got ${h(e.found)}`
637
- );
638
- if (e.claimer !== null) {
639
- if (typeof e.claimer != "object")
640
- throw new o(
641
- `VP response validation failed: "claimer" must be an object or null, got ${h(e.claimer)}`
642
- );
643
- Xe(e.claimer);
644
- }
645
- if (!Array.isArray(e.challengers))
646
- throw new o(
647
- `VP response validation failed: "challengers" must be an array, got ${h(e.challengers)}`
648
- );
649
- for (let t = 0; t < e.challengers.length; t++)
650
- Fe(e.challengers[t], t);
651
- }
652
- function Xe(r) {
653
- if (w(r.status, "claimer.status"), typeof r.failed != "boolean")
654
- throw new o(
655
- `VP response validation failed: "claimer.failed" must be a boolean, got ${h(r.failed)}`
656
- );
657
- if (w(r.claim_txid, "claimer.claim_txid"), w(r.claimer_pubkey, "claimer.claimer_pubkey"), w(r.assert_txid, "claimer.assert_txid"), typeof r.created_at != "number")
658
- throw new o(
659
- `VP response validation failed: "claimer.created_at" must be a number, got ${h(r.created_at)}`
660
- );
661
- if (typeof r.updated_at != "number")
662
- throw new o(
663
- `VP response validation failed: "claimer.updated_at" must be a number, got ${h(r.updated_at)}`
664
- );
665
- }
666
- function Fe(r, e) {
667
- if (r === null || typeof r != "object")
668
- throw new o(
669
- `VP response validation failed: "challengers[${e}]" must be an object, got ${h(r)}`
670
- );
671
- const t = r;
672
- if (w(t.status, `challengers[${e}].status`), w(t.claim_txid, `challengers[${e}].claim_txid`), w(t.claimer_pubkey, `challengers[${e}].claimer_pubkey`), D(t.assert_txid, `challengers[${e}].assert_txid`), D(
673
- t.challenge_assert_x_txid,
674
- `challengers[${e}].challenge_assert_x_txid`
675
- ), D(
676
- t.challenge_assert_y_txid,
677
- `challengers[${e}].challenge_assert_y_txid`
678
- ), D(t.nopayout_txid, `challengers[${e}].nopayout_txid`), typeof t.created_at != "number")
679
- throw new o(
680
- `VP response validation failed: "challengers[${e}].created_at" must be a number, got ${h(t.created_at)}`
681
- );
682
- if (typeof t.updated_at != "number")
683
- throw new o(
684
- `VP response validation failed: "challengers[${e}].updated_at" must be a number, got ${h(t.updated_at)}`
685
- );
686
- }
687
- function D(r, e) {
688
- if (r !== null && typeof r != "string")
689
- throw new o(
690
- `VP response validation failed: "${e}" must be a string or null, got ${h(r)}`
691
- );
692
- }
693
- function Je(r) {
694
- me(r, "batchGetPeginStatus", (e) => {
695
- e.result !== null && _e(e.result);
696
- });
697
- }
698
- function We(r) {
699
- me(r, "batchGetPegoutStatus", (e) => {
700
- e.result !== null && Ue(e.result);
701
- });
702
- }
703
- function me(r, e, t) {
704
- if (r === null || typeof r != "object")
705
- throw new o(
706
- `VP response validation failed: ${e} response is not an object`
707
- );
708
- const n = r;
709
- if (!Array.isArray(n.results))
710
- throw new o(
711
- `VP response validation failed: "${e}.results" must be an array, got ${h(n.results)}`
712
- );
713
- for (let i = 0; i < n.results.length; i++) {
714
- const s = n.results[i];
715
- if (s === null || typeof s != "object")
716
- throw new o(
717
- `VP response validation failed: "${e}.results[${i}]" must be an object, got ${h(s)}`
718
- );
719
- const a = s;
720
- if (!$(a.pegin_txid) || a.pegin_txid.length !== O)
721
- throw new o(
722
- `VP response validation failed: "${e}.results[${i}].pegin_txid" must be a ${O}-char hex string, got ${h(a.pegin_txid)}`
723
- );
724
- if (a.error !== null && typeof a.error != "string")
725
- throw new o(
726
- `VP response validation failed: "${e}.results[${i}].error" must be a string or null, got ${h(a.error)}`
727
- );
728
- if (a.result === null && a.error === null)
729
- throw new o(
730
- `VP response validation failed: "${e}.results[${i}]" has neither "result" nor "error" populated`
731
- );
732
- if (a.result !== null && a.error !== null)
733
- throw new o(
734
- `VP response validation failed: "${e}.results[${i}]" has both "result" and "error" populated`
735
- );
736
- t(a, i);
737
- }
738
- }
739
- function ze(r) {
740
- if (v(r.claim_tx, "depositor_graph.claim_tx"), v(r.assert_tx, "depositor_graph.assert_tx"), v(r.payout_tx, "depositor_graph.payout_tx"), w(r.payout_psbt, "depositor_graph.payout_psbt"), !Array.isArray(r.challenger_presign_data))
741
- throw new o(
742
- 'VP response validation failed: "depositor_graph.challenger_presign_data" must be an array'
743
- );
744
- for (let e = 0; e < r.challenger_presign_data.length; e++)
745
- He(
746
- r.challenger_presign_data[e],
747
- `depositor_graph.challenger_presign_data[${e}]`
748
- );
749
- if (typeof r.offchain_params_version != "number")
750
- throw new o(
751
- 'VP response validation failed: "depositor_graph.offchain_params_version" must be a number'
752
- );
753
- }
754
- const Ye = 6e4;
755
- class qe {
756
- constructor(e, t) {
757
- f(this, "client");
758
- const n = {
759
- baseUrl: e,
760
- timeout: (t == null ? void 0 : t.timeout) ?? Ye,
761
- retries: t == null ? void 0 : t.retries,
762
- retryDelay: t == null ? void 0 : t.retryDelay,
763
- retryableFor: t == null ? void 0 : t.retryableFor,
764
- headers: t == null ? void 0 : t.headers,
765
- tokenProvider: t == null ? void 0 : t.tokenProvider,
766
- maxResponseBytes: t == null ? void 0 : t.maxResponseBytes
767
- };
768
- this.client = new pe(n);
769
- }
770
- /**
771
- * Request the payout/claim/assert transactions that the depositor
772
- * needs to pre-sign before the vault can be activated on Bitcoin.
773
- */
774
- async requestDepositorPresignTransactions(e, t) {
775
- const n = await this.client.call("vaultProvider_requestDepositorPresignTransactions", e, t);
776
- return Ge(n), n;
777
- }
778
- /**
779
- * Submit the depositor's pre-signatures for the payout transactions
780
- * and the depositor-as-claimer graph.
781
- */
782
- async submitDepositorPresignatures(e, t) {
783
- return this.client.call(
784
- "vaultProvider_submitDepositorPresignatures",
785
- e,
786
- t
787
- );
788
- }
789
- /**
790
- * Submit the depositor's WOTS public key to the vault provider.
791
- * Called after the pegin is finalized on Ethereum, when the VP is in
792
- * `PendingDepositorWotsPK` status.
793
- */
794
- async submitDepositorWotsKey(e, t) {
795
- return this.client.call(
796
- "vaultProvider_submitDepositorWotsKey",
797
- e,
798
- t
799
- );
800
- }
801
- /**
802
- * Request the BaBe DecryptorArtifacts needed for the depositor to
803
- * independently evaluate garbled circuits during a challenge.
804
- */
805
- async requestDepositorClaimerArtifacts(e, t) {
806
- const n = await this.client.call("vaultProvider_requestDepositorClaimerArtifacts", e, t);
807
- return Ke(n), n;
808
- }
809
- /** Get the current pegin status from the vault provider daemon. */
810
- async getPeginStatus(e, t) {
811
- const n = await this.client.call(
812
- "vaultProvider_getPeginStatus",
813
- e,
814
- t
815
- );
816
- return _e(n), n;
817
- }
818
- /**
819
- * Get pegin status for many txids in one round trip. Per-result envelope
820
- * isolates per-pegin failures from the overall RPC. Caller must chunk
821
- * inputs at `VP_BATCH_MAX_SIZE`.
822
- */
823
- async batchGetPeginStatus(e, t) {
824
- const n = await this.client.call("vaultProvider_batchGetPeginStatus", e, t);
825
- return Je(n), n;
826
- }
827
- /**
828
- * Get pegout status for many txids in one round trip. Same per-result
829
- * envelope semantics as `batchGetPeginStatus`.
830
- */
831
- async batchGetPegoutStatus(e, t) {
832
- const n = await this.client.call("vaultProvider_batchGetPegoutStatus", e, t);
833
- return We(n), n;
834
- }
835
- }
836
- function L(r, e) {
418
+ var _e = /* @__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))(_e || {});
419
+ function S(r, e) {
837
420
  const t = (r & 7) << 5, n = typeof e == "bigint" ? e : BigInt(e);
838
421
  if (n < 0n) throw new Error("cborHead: negative argument");
839
422
  if (n < 24n) return new Uint8Array([t | Number(n)]);
@@ -858,150 +441,154 @@ function L(r, e) {
858
441
  i[1 + s] = Number(n >> BigInt((7 - s) * 8)) & 255;
859
442
  return i;
860
443
  }
861
- function ye(...r) {
444
+ function te(...r) {
862
445
  const e = r.reduce((i, s) => i + s.length, 0), t = new Uint8Array(e);
863
446
  let n = 0;
864
447
  for (const i of r)
865
448
  t.set(i, n), n += i.length;
866
449
  return t;
867
450
  }
868
- function re(r) {
869
- const t = [L(4, r.length)];
451
+ function D(r) {
452
+ const t = [S(4, r.length)];
870
453
  for (const n of r)
871
- t.push(L(0, n));
872
- return ye(...t);
454
+ t.push(S(0, n));
455
+ return te(...t);
873
456
  }
874
- function Qe(r, e, t) {
457
+ function we(r, e, t) {
875
458
  if (!Number.isSafeInteger(t) || t < 0)
876
459
  throw new Error(
877
460
  `encodeServerIdentityPayload: expires_at must be a non-negative safe integer, got ${t}`
878
461
  );
879
- const n = L(4, 3), i = re(r), s = re(e), a = L(0, t);
880
- return ye(n, i, s, a);
462
+ const n = S(4, 3), i = D(r), s = D(e), a = S(0, t);
463
+ return te(n, i, s, a);
881
464
  }
882
- const Ze = new TextEncoder().encode(
465
+ const xe = new TextEncoder().encode(
883
466
  "btc-auth.server-identity.v1"
884
- ), et = 2 * 3600;
885
- class b extends Error {
467
+ ), ve = 2 * 3600;
468
+ class m extends Error {
886
469
  constructor(e, t) {
887
470
  super(e), this.reason = t, this.name = "ServerIdentityError";
888
471
  }
889
472
  }
890
- function M(r) {
473
+ function E(r) {
891
474
  const e = new Uint8Array(r.length / 2);
892
475
  for (let t = 0; t < e.length; t++)
893
476
  e[t] = parseInt(r.slice(t * 2, t * 2 + 2), 16);
894
477
  return e;
895
478
  }
896
- function tt(r) {
897
- const { proof: e, pinnedServerPubkey: t, now: n } = r, i = r.maxLifetimeSecs ?? et, s = V(t).toLowerCase();
898
- if (s.length !== R || !k.test(s))
899
- throw new b(
479
+ function Pe(r) {
480
+ const { proof: e, pinnedServerPubkey: t, now: n } = r, i = r.maxLifetimeSecs ?? ve, s = A(t).toLowerCase();
481
+ if (s.length !== C || !b.test(s))
482
+ throw new m(
900
483
  `pinnedServerPubkey must be 32-byte hex; got ${s.length} chars`,
901
484
  "invalid_pubkey_encoding"
902
485
  );
903
- const a = V(e.server_pubkey).toLowerCase();
904
- if (a.length !== R || !k.test(a))
905
- throw new b(
486
+ const a = A(e.server_pubkey).toLowerCase();
487
+ if (a.length !== C || !b.test(a))
488
+ throw new m(
906
489
  `server_pubkey must be 32-byte hex; got ${a.length} chars`,
907
490
  "invalid_pubkey_encoding"
908
491
  );
909
492
  if (a !== s)
910
- throw new b(
493
+ throw new m(
911
494
  `server_pubkey does not match pinned value: expected ${s}, got ${a}`,
912
495
  "pinned_pubkey_mismatch"
913
496
  );
914
497
  if (!Number.isSafeInteger(e.expires_at))
915
- throw new b(
498
+ throw new m(
916
499
  `expires_at must be a finite integer; got ${JSON.stringify(e.expires_at)}`,
917
500
  "invalid_expires_at"
918
501
  );
919
502
  if (!Number.isSafeInteger(n))
920
- throw new b(
503
+ throw new m(
921
504
  `now must be a finite integer; got ${JSON.stringify(n)}`,
922
505
  "invalid_expires_at"
923
506
  );
924
507
  if (e.expires_at <= n)
925
- throw new b(
508
+ throw new m(
926
509
  `server identity proof expired at ${e.expires_at}, now ${n}`,
927
510
  "expired"
928
511
  );
929
512
  if (!Number.isSafeInteger(i) || i <= 0)
930
- throw new b(
513
+ throw new m(
931
514
  `maxLifetimeSecs must be a positive safe integer; got ${JSON.stringify(i)}`,
932
515
  "invalid_max_lifetime"
933
516
  );
934
517
  if (e.expires_at - n > i)
935
- throw new b(
518
+ throw new m(
936
519
  `server identity proof expires too far in the future: expires_at=${e.expires_at}, now=${n}, max lifetime=${i}s`,
937
520
  "expires_too_far"
938
521
  );
939
- const c = V(e.ephemeral_pubkey).toLowerCase();
940
- if (c.length !== G || !k.test(c))
941
- throw new b(
942
- `ephemeral_pubkey must be 33-byte compressed hex; got ${c.length} chars`,
522
+ const o = A(e.ephemeral_pubkey).toLowerCase();
523
+ if (o.length !== ee || !b.test(o))
524
+ throw new m(
525
+ `ephemeral_pubkey must be 33-byte compressed hex; got ${o.length} chars`,
943
526
  "invalid_ephemeral_pubkey"
944
527
  );
945
- const u = c.slice(0, 2);
528
+ const u = o.slice(0, 2);
946
529
  if (u !== "02" && u !== "03")
947
- throw new b(
530
+ throw new m(
948
531
  `ephemeral_pubkey must be compressed (prefix 02/03); got ${u}`,
949
532
  "invalid_ephemeral_pubkey"
950
533
  );
951
- const d = M(c);
952
- if (!he.isPoint(d))
953
- throw new b(
534
+ const d = E(o);
535
+ if (!q.isPoint(d))
536
+ throw new m(
954
537
  "ephemeral_pubkey is not a valid secp256k1 point",
955
538
  "invalid_ephemeral_pubkey"
956
539
  );
957
- const g = V(e.signature).toLowerCase();
958
- if (g.length !== $e || !k.test(g))
959
- throw new b(
960
- `signature must be 64-byte Schnorr hex; got ${g.length} chars`,
540
+ const p = A(e.signature).toLowerCase();
541
+ if (p.length !== ge || !b.test(p))
542
+ throw new m(
543
+ `signature must be 64-byte Schnorr hex; got ${p.length} chars`,
961
544
  "invalid_signature_encoding"
962
545
  );
963
- const y = Qe(
964
- Ze,
965
- M(c),
546
+ const y = we(
547
+ xe,
548
+ E(o),
966
549
  e.expires_at
967
550
  );
968
- if (!Se(y, M(a), M(g)))
969
- throw new b(
551
+ if (!pe(
552
+ y,
553
+ E(a),
554
+ E(p)
555
+ ))
556
+ throw new m(
970
557
  "BIP-322 signature verification failed — ephemeral key is not attested by pinned server pubkey",
971
558
  "signature_verification_failed"
972
559
  );
973
560
  }
974
- const rt = /* @__PURE__ */ new Set([
561
+ const Ee = /* @__PURE__ */ new Set([
975
562
  "vaultProvider_submitDepositorWotsKey",
976
563
  "vaultProvider_submitDepositorPresignatures",
977
564
  "vaultProvider_requestDepositorPresignTransactions"
978
- ]), nt = /* @__PURE__ */ new Set([
565
+ ]), Ce = /* @__PURE__ */ new Set([
979
566
  "vaultProvider_requestDepositorClaimerArtifacts"
980
- ]), st = 6e4, F = "auth_createDepositorToken", J = "auth_createDepositorTokenGrpc";
981
- function be(r, e) {
982
- return new pe({
567
+ ]), ke = 6e4, V = "auth_createDepositorToken", $ = "auth_createDepositorTokenGrpc";
568
+ function re(r, e) {
569
+ return new ye({
983
570
  baseUrl: r,
984
- timeout: st,
571
+ timeout: ke,
985
572
  headers: e,
986
- retryableFor: (t) => t === F || t === J
573
+ retryableFor: (t) => t === V || t === $
987
574
  });
988
575
  }
989
- const it = 0, at = 1, K = 2, ot = 3, ct = 4, lt = 5, ut = 6, dt = 7, ne = 24, pt = 28, ht = 20, gt = 21, ft = 22, se = 256;
990
- class P extends Error {
576
+ const Se = 0, Te = 1, R = 2, Ie = 3, Oe = 4, Re = 5, Ne = 6, Be = 7, X = 24, Ve = 28, $e = 20, Me = 21, Ge = 22, F = 256;
577
+ class f extends Error {
991
578
  constructor(e) {
992
579
  super(`CBOR decode: ${e}`), this.name = "CborDecodeError";
993
580
  }
994
581
  }
995
- class we {
582
+ class ne {
996
583
  constructor(e) {
997
- f(this, "buf");
584
+ h(this, "buf");
998
585
  /** Current read offset. Public so callers can slice encoded sub-ranges. */
999
- f(this, "pos", 0);
586
+ h(this, "pos", 0);
1000
587
  this.buf = e;
1001
588
  }
1002
589
  nextByte() {
1003
590
  if (this.pos >= this.buf.length)
1004
- throw new P("unexpected end of input");
591
+ throw new f("unexpected end of input");
1005
592
  return this.buf[this.pos++];
1006
593
  }
1007
594
  /**
@@ -1012,24 +599,24 @@ class we {
1012
599
  */
1013
600
  readHead() {
1014
601
  const e = this.nextByte(), t = e >> 5, n = e & 31;
1015
- if (n < ne)
602
+ if (n < X)
1016
603
  return { major: t, arg: n };
1017
- if (n >= pt)
1018
- throw new P(
604
+ if (n >= Ve)
605
+ throw new f(
1019
606
  `unsupported additional info ${n} (indefinite-length or reserved)`
1020
607
  );
1021
- const i = 1 << n - ne;
608
+ const i = 1 << n - X;
1022
609
  let s = 0n;
1023
610
  for (let a = 0; a < i; a++)
1024
611
  s = s << 8n | BigInt(this.nextByte());
1025
612
  if (s > BigInt(Number.MAX_SAFE_INTEGER))
1026
- throw new P(`argument ${s} exceeds safe integer range`);
613
+ throw new f(`argument ${s} exceeds safe integer range`);
1027
614
  return { major: t, arg: Number(s) };
1028
615
  }
1029
616
  /** Read `length` raw bytes as a sub-array view into the backing buffer. */
1030
617
  readBytes(e) {
1031
618
  if (this.pos + e > this.buf.length)
1032
- throw new P("length overruns end of input");
619
+ throw new f("length overruns end of input");
1033
620
  const t = this.buf.subarray(this.pos, this.pos + e);
1034
621
  return this.pos += e, t;
1035
622
  }
@@ -1039,9 +626,9 @@ class we {
1039
626
  */
1040
627
  readByteString() {
1041
628
  const e = this.readHead();
1042
- if (e.major !== K)
1043
- throw new P(
1044
- `expected byte string (major ${K}), got major ${e.major}`
629
+ if (e.major !== R)
630
+ throw new f(
631
+ `expected byte string (major ${R}), got major ${e.major}`
1045
632
  );
1046
633
  return this.readBytes(e.arg);
1047
634
  }
@@ -1053,29 +640,29 @@ class we {
1053
640
  * native call stack (see {@link MAX_NESTING_DEPTH}).
1054
641
  */
1055
642
  readValue(e = 0) {
1056
- if (e > se)
1057
- throw new P(
1058
- `nesting exceeds maximum depth ${se}`
643
+ if (e > F)
644
+ throw new f(
645
+ `nesting exceeds maximum depth ${F}`
1059
646
  );
1060
647
  const t = this.readHead();
1061
648
  switch (t.major) {
1062
- case it:
649
+ case Se:
1063
650
  return t.arg;
1064
- case at:
651
+ case Te:
1065
652
  return -1 - t.arg;
1066
- case K:
653
+ case R:
1067
654
  return this.readBytes(t.arg);
1068
- case ot:
655
+ case Ie:
1069
656
  return new TextDecoder("utf-8", { fatal: !0 }).decode(
1070
657
  this.readBytes(t.arg)
1071
658
  );
1072
- case ct: {
659
+ case Oe: {
1073
660
  const n = [];
1074
661
  for (let i = 0; i < t.arg; i++)
1075
662
  n.push(this.readValue(e + 1));
1076
663
  return n;
1077
664
  }
1078
- case lt: {
665
+ case Re: {
1079
666
  const n = /* @__PURE__ */ new Map();
1080
667
  for (let i = 0; i < t.arg; i++) {
1081
668
  const s = this.readValue(e + 1), a = this.readValue(e + 1);
@@ -1083,285 +670,285 @@ class we {
1083
670
  }
1084
671
  return n;
1085
672
  }
1086
- case ut:
673
+ case Ne:
1087
674
  return { tag: t.arg, value: this.readValue(e + 1) };
1088
- case dt:
1089
- if (t.arg === ht) return !1;
1090
- if (t.arg === gt) return !0;
1091
- if (t.arg === ft) return null;
1092
- throw new P(
675
+ case Be:
676
+ if (t.arg === $e) return !1;
677
+ if (t.arg === Me) return !0;
678
+ if (t.arg === Ge) return null;
679
+ throw new f(
1093
680
  `unsupported simple/float value ${t.arg}`
1094
681
  );
1095
682
  default:
1096
- throw new P(`unsupported major type ${t.major}`);
683
+ throw new f(`unsupported major type ${t.major}`);
1097
684
  }
1098
685
  }
1099
686
  }
1100
- function xe(r) {
1101
- const e = new we(r), t = e.readValue();
687
+ function se(r) {
688
+ const e = new ne(r), t = e.readValue();
1102
689
  if (e.pos !== r.length)
1103
- throw new P("trailing bytes after top-level item");
690
+ throw new f("trailing bytes after top-level item");
1104
691
  return t;
1105
692
  }
1106
- const _t = "vaultd-jsonrpc", mt = "vaultd-grpc", ie = 18, W = 4, ae = -47, yt = 1, oe = 64, bt = 128, wt = 96, xt = 64, Pt = 1, vt = 2, At = 3, Et = 4, Ct = 5, kt = 6, St = 7, ce = new TextEncoder().encode("Signature1");
1107
- class p extends Error {
693
+ const Ke = "vaultd-jsonrpc", He = "vaultd-grpc", J = 18, M = 4, j = -47, Le = 1, W = 64, Ue = 128, De = 96, Xe = 64, Fe = 1, Je = 2, je = 3, We = 4, Ye = 5, ze = 6, Qe = 7, Y = new TextEncoder().encode("Signature1");
694
+ class c extends Error {
1108
695
  constructor(e, t) {
1109
696
  super(e), this.reason = t, this.name = "CwtVerificationError";
1110
697
  }
1111
698
  }
1112
- function $t(r) {
1113
- const e = le(
699
+ function Ze(r) {
700
+ const e = z(
1114
701
  r.expectedIssuerXOnlyPubkey,
1115
702
  "expectedIssuerXOnlyPubkey"
1116
- ), t = le(
703
+ ), t = z(
1117
704
  r.expectedAudienceXOnlyPubkey,
1118
705
  "expectedAudienceXOnlyPubkey"
1119
- ), n = Ot(r.ephemeralPubkeyHex), i = Bt(r.token), s = new we(i), a = s.readHead();
1120
- if (a.major !== 6 || a.arg !== ie)
1121
- throw new p(
1122
- `token is not a COSE Sign1 tagged value (tag ${ie})`,
706
+ ), n = nt(r.ephemeralPubkeyHex), i = it(r.token), s = new ne(i), a = s.readHead();
707
+ if (a.major !== 6 || a.arg !== J)
708
+ throw new c(
709
+ `token is not a COSE Sign1 tagged value (tag ${J})`,
1123
710
  "invalid_token_structure"
1124
711
  );
1125
- const c = s.readHead();
1126
- if (c.major !== 4 || c.arg !== W)
1127
- throw new p(
1128
- `COSE Sign1 must be a ${W}-element array`,
712
+ const o = s.readHead();
713
+ if (o.major !== 4 || o.arg !== M)
714
+ throw new c(
715
+ `COSE Sign1 must be a ${M}-element array`,
1129
716
  "invalid_token_structure"
1130
717
  );
1131
- const u = s.pos, d = s.readByteString(), g = i.subarray(u, s.pos);
718
+ const u = s.pos, d = s.readByteString(), p = i.subarray(u, s.pos);
1132
719
  s.readValue();
1133
- const y = s.pos, A = s.readByteString(), E = i.subarray(y, s.pos), S = s.readByteString();
1134
- if (S.length !== oe)
1135
- throw new p(
1136
- `COSE signature must be ${oe} bytes, got ${S.length}`,
720
+ const y = s.pos, w = s.readByteString(), T = i.subarray(y, s.pos), I = s.readByteString();
721
+ if (I.length !== W)
722
+ throw new c(
723
+ `COSE signature must be ${W} bytes, got ${I.length}`,
1137
724
  "invalid_token_structure"
1138
725
  );
1139
726
  if (s.pos !== i.length)
1140
- throw new p(
727
+ throw new c(
1141
728
  "COSE Sign1 token has trailing bytes after the signature",
1142
729
  "invalid_token_structure"
1143
730
  );
1144
- const x = Tt(d);
1145
- if (x !== ae)
1146
- throw new p(
1147
- `unexpected COSE algorithm ${x} (expected ES256K ${ae})`,
731
+ const G = qe(d);
732
+ if (G !== j)
733
+ throw new c(
734
+ `unexpected COSE algorithm ${G} (expected ES256K ${j})`,
1148
735
  "unexpected_algorithm"
1149
736
  );
1150
- const T = Vt(g, E), _ = Re(T);
1151
- if (!he.verify(_, n, S, !0))
1152
- throw new p(
737
+ const ae = et(p, T), oe = be(ae);
738
+ if (!q.verify(oe, n, I, !0))
739
+ throw new c(
1153
740
  "COSE signature does not verify against the server's ephemeral key",
1154
741
  "signature_verification_failed"
1155
742
  );
1156
- const l = It(A), C = l.audience.toLowerCase();
1157
- if (C.length !== R || !k.test(C))
1158
- throw new p(
743
+ const l = tt(w), x = l.audience.toLowerCase();
744
+ if (x.length !== C || !b.test(x))
745
+ throw new c(
1159
746
  "token `aud` is not a 32-byte x-only pubkey hex",
1160
747
  "invalid_claims"
1161
748
  );
1162
749
  if (l.issuedAt > l.expiresAt)
1163
- throw new p(
750
+ throw new c(
1164
751
  `token iat (${l.issuedAt}) is after exp (${l.expiresAt})`,
1165
752
  "invalid_claims"
1166
753
  );
1167
754
  if (l.issuer.toLowerCase() !== e)
1168
- throw new p(
755
+ throw new c(
1169
756
  `token issuer does not match pinned server pubkey: expected ${e}, got ${l.issuer.toLowerCase()}`,
1170
757
  "issuer_mismatch"
1171
758
  );
1172
759
  if (l.subject !== r.expectedSubject)
1173
- throw new p(
760
+ throw new c(
1174
761
  `token subject mismatch: expected ${r.expectedSubject}, got ${l.subject}`,
1175
762
  "subject_mismatch"
1176
763
  );
1177
- if (C !== t)
1178
- throw new p(
1179
- `token audience does not match depositor pubkey: expected ${t}, got ${C}`,
764
+ if (x !== t)
765
+ throw new c(
766
+ `token audience does not match depositor pubkey: expected ${t}, got ${x}`,
1180
767
  "audience_mismatch"
1181
768
  );
1182
769
  if (l.expiresAt <= r.now)
1183
- throw new p(
770
+ throw new c(
1184
771
  `token expired: exp ${l.expiresAt} <= now ${r.now}`,
1185
772
  "token_expired"
1186
773
  );
1187
774
  if (r.responseExpiresAt !== l.expiresAt)
1188
- throw new p(
775
+ throw new c(
1189
776
  `response expires_at (${r.responseExpiresAt}) does not equal token exp (${l.expiresAt})`,
1190
777
  "expiry_mismatch"
1191
778
  );
1192
779
  if (r.serverIdentityExpiresAt < l.expiresAt)
1193
- throw new p(
780
+ throw new c(
1194
781
  `server identity expires (${r.serverIdentityExpiresAt}) before token exp (${l.expiresAt})`,
1195
782
  "server_identity_expires_before_token"
1196
783
  );
1197
784
  return {
1198
785
  issuer: l.issuer,
1199
786
  subject: l.subject,
1200
- audience: C,
787
+ audience: x,
1201
788
  expiresAt: l.expiresAt,
1202
789
  notBefore: l.notBefore,
1203
790
  issuedAt: l.issuedAt
1204
791
  };
1205
792
  }
1206
- function Tt(r) {
793
+ function qe(r) {
1207
794
  if (r.length === 0)
1208
- throw new p(
795
+ throw new c(
1209
796
  "empty COSE protected header (no algorithm)",
1210
797
  "unexpected_algorithm"
1211
798
  );
1212
- const e = xe(r);
799
+ const e = se(r);
1213
800
  if (!(e instanceof Map))
1214
- throw new p(
801
+ throw new c(
1215
802
  "COSE protected header is not a map",
1216
803
  "invalid_token_structure"
1217
804
  );
1218
- const t = e.get(yt);
805
+ const t = e.get(Le);
1219
806
  if (typeof t != "number")
1220
- throw new p(
807
+ throw new c(
1221
808
  "COSE protected header missing integer algorithm label",
1222
809
  "unexpected_algorithm"
1223
810
  );
1224
811
  return t;
1225
812
  }
1226
- function Vt(r, e) {
1227
- return Dt(
1228
- Uint8Array.of(bt | W),
1229
- Uint8Array.of(wt | ce.length),
1230
- ce,
813
+ function et(r, e) {
814
+ return at(
815
+ Uint8Array.of(Ue | M),
816
+ Uint8Array.of(De | Y.length),
817
+ Y,
1231
818
  r,
1232
- Uint8Array.of(xt),
819
+ Uint8Array.of(Xe),
1233
820
  e
1234
821
  );
1235
822
  }
1236
- function It(r) {
1237
- const e = xe(r);
823
+ function tt(r) {
824
+ const e = se(r);
1238
825
  if (!(e instanceof Map))
1239
- throw new p(
826
+ throw new c(
1240
827
  "CWT claims root is not a map",
1241
828
  "invalid_claims"
1242
829
  );
1243
- if (Rt(e, St, "cti").length === 0)
1244
- throw new p("token cti is empty", "invalid_claims");
830
+ if (rt(e, Qe, "cti").length === 0)
831
+ throw new c("token cti is empty", "invalid_claims");
1245
832
  return {
1246
- issuer: U(e, Pt, "iss"),
1247
- subject: U(e, vt, "sub"),
1248
- audience: U(e, At, "aud"),
1249
- expiresAt: X(e, Et, "exp"),
1250
- notBefore: X(e, Ct, "nbf"),
1251
- issuedAt: X(e, kt, "iat")
833
+ issuer: N(e, Fe, "iss"),
834
+ subject: N(e, Je, "sub"),
835
+ audience: N(e, je, "aud"),
836
+ expiresAt: B(e, We, "exp"),
837
+ notBefore: B(e, Ye, "nbf"),
838
+ issuedAt: B(e, ze, "iat")
1252
839
  };
1253
840
  }
1254
- function U(r, e, t) {
841
+ function N(r, e, t) {
1255
842
  const n = r.get(e);
1256
843
  if (typeof n != "string")
1257
- throw new p(
844
+ throw new c(
1258
845
  `token claim ${t} is missing or not a text string`,
1259
846
  "invalid_claims"
1260
847
  );
1261
848
  return n;
1262
849
  }
1263
- function Rt(r, e, t) {
850
+ function rt(r, e, t) {
1264
851
  const n = r.get(e);
1265
852
  if (!(n instanceof Uint8Array))
1266
- throw new p(
853
+ throw new c(
1267
854
  `token claim ${t} is missing or not a byte string`,
1268
855
  "invalid_claims"
1269
856
  );
1270
857
  return n;
1271
858
  }
1272
- function X(r, e, t) {
859
+ function B(r, e, t) {
1273
860
  const n = r.get(e);
1274
861
  if (typeof n != "number" || !Number.isSafeInteger(n) || n < 0)
1275
- throw new p(
862
+ throw new c(
1276
863
  `token claim ${t} is missing or not a non-negative integer timestamp`,
1277
864
  "invalid_claims"
1278
865
  );
1279
866
  return n;
1280
867
  }
1281
- function le(r, e) {
1282
- const t = V(r).toLowerCase();
1283
- if (t.length !== R || !k.test(t))
1284
- throw new p(
868
+ function z(r, e) {
869
+ const t = A(r).toLowerCase();
870
+ if (t.length !== C || !b.test(t))
871
+ throw new c(
1285
872
  `${e} must be 32-byte x-only hex; got ${t.length} chars`,
1286
873
  "invalid_input"
1287
874
  );
1288
875
  return t;
1289
876
  }
1290
- function Ot(r) {
1291
- const e = V(r).toLowerCase(), t = e.slice(0, 2);
1292
- if (e.length !== G || !k.test(e) || t !== "02" && t !== "03")
1293
- throw new p(
877
+ function nt(r) {
878
+ const e = A(r).toLowerCase(), t = e.slice(0, 2);
879
+ if (e.length !== ee || !b.test(e) || t !== "02" && t !== "03")
880
+ throw new c(
1294
881
  "ephemeralPubkeyHex must be 33-byte compressed pubkey hex (prefix 02/03)",
1295
882
  "invalid_input"
1296
883
  );
1297
- return Te(e);
884
+ return me(e);
1298
885
  }
1299
- const Nt = (() => {
886
+ const st = (() => {
1300
887
  const r = new Int16Array(128).fill(-1), e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
1301
888
  for (let t = 0; t < e.length; t++)
1302
889
  r[e.charCodeAt(t)] = t;
1303
890
  return r;
1304
891
  })();
1305
- function Bt(r) {
892
+ function it(r) {
1306
893
  const e = r.length, t = Math.floor(e / 4), n = e % 4;
1307
894
  if (n === 1)
1308
- throw new p(
895
+ throw new c(
1309
896
  "invalid base64url length",
1310
897
  "invalid_token_structure"
1311
898
  );
1312
899
  const i = t * 3 + (n === 0 ? 0 : n - 1), s = new Uint8Array(i), a = (d) => {
1313
- const g = d < 128 ? Nt[d] : -1;
1314
- if (g < 0)
1315
- throw new p(
900
+ const p = d < 128 ? st[d] : -1;
901
+ if (p < 0)
902
+ throw new c(
1316
903
  "invalid base64url character",
1317
904
  "invalid_token_structure"
1318
905
  );
1319
- return g;
906
+ return p;
1320
907
  };
1321
- let c = 0, u = 0;
908
+ let o = 0, u = 0;
1322
909
  for (let d = 0; d < t; d++) {
1323
- const g = a(r.charCodeAt(c++)), y = a(r.charCodeAt(c++)), A = a(r.charCodeAt(c++)), E = a(r.charCodeAt(c++));
1324
- s[u++] = g << 2 | y >> 4, s[u++] = (y & 15) << 4 | A >> 2, s[u++] = (A & 3) << 6 | E;
910
+ const p = a(r.charCodeAt(o++)), y = a(r.charCodeAt(o++)), w = a(r.charCodeAt(o++)), T = a(r.charCodeAt(o++));
911
+ s[u++] = p << 2 | y >> 4, s[u++] = (y & 15) << 4 | w >> 2, s[u++] = (w & 3) << 6 | T;
1325
912
  }
1326
913
  if (n === 2) {
1327
- const d = a(r.charCodeAt(c++)), g = a(r.charCodeAt(c++));
1328
- s[u++] = d << 2 | g >> 4;
914
+ const d = a(r.charCodeAt(o++)), p = a(r.charCodeAt(o++));
915
+ s[u++] = d << 2 | p >> 4;
1329
916
  } else if (n === 3) {
1330
- const d = a(r.charCodeAt(c++)), g = a(r.charCodeAt(c++)), y = a(r.charCodeAt(c++));
1331
- s[u++] = d << 2 | g >> 4, s[u++] = (g & 15) << 4 | y >> 2;
917
+ const d = a(r.charCodeAt(o++)), p = a(r.charCodeAt(o++)), y = a(r.charCodeAt(o++));
918
+ s[u++] = d << 2 | p >> 4, s[u++] = (p & 15) << 4 | y >> 2;
1332
919
  }
1333
920
  return s;
1334
921
  }
1335
- function Dt(...r) {
922
+ function at(...r) {
1336
923
  const e = r.reduce((i, s) => i + s.length, 0), t = new Uint8Array(e);
1337
924
  let n = 0;
1338
925
  for (const i of r)
1339
926
  t.set(i, n), n += i.length;
1340
927
  return t;
1341
928
  }
1342
- const ue = 4102444800, Mt = 30;
1343
- class Gt {
929
+ const Q = 4102444800, ot = 30;
930
+ class ct {
1344
931
  constructor(e) {
1345
932
  // `client` is the only mutable field — see `setClient`. The
1346
933
  // identity-bearing fields (peginTxid/authAnchorHex/pinnedServerPubkey)
1347
934
  // remain readonly and are checked against re-registration in the
1348
935
  // registry's `getOrCreate`.
1349
- f(this, "client");
1350
- f(this, "peginTxid");
1351
- f(this, "authAnchorHex");
1352
- f(this, "pinnedServerPubkey");
1353
- f(this, "expectedAudienceXOnlyPubkey");
1354
- f(this, "authGatedMethods");
1355
- f(this, "grpcGatedMethods");
1356
- f(this, "refreshSkewSecs");
1357
- f(this, "now");
936
+ h(this, "client");
937
+ h(this, "peginTxid");
938
+ h(this, "authAnchorHex");
939
+ h(this, "pinnedServerPubkey");
940
+ h(this, "expectedAudienceXOnlyPubkey");
941
+ h(this, "authGatedMethods");
942
+ h(this, "grpcGatedMethods");
943
+ h(this, "refreshSkewSecs");
944
+ h(this, "now");
1358
945
  /** Cached JSON-RPC-subject bearer (auth_createDepositorToken). */
1359
- f(this, "cachedJsonRpc", null);
1360
- f(this, "inFlightJsonRpc", null);
946
+ h(this, "cachedJsonRpc", null);
947
+ h(this, "inFlightJsonRpc", null);
1361
948
  /** Cached gRPC-subject bearer (auth_createDepositorTokenGrpc). */
1362
- f(this, "cachedGrpc", null);
1363
- f(this, "inFlightGrpc", null);
1364
- this.client = e.client, this.peginTxid = e.peginTxid, this.authAnchorHex = e.authAnchorHex, this.pinnedServerPubkey = e.pinnedServerPubkey, this.expectedAudienceXOnlyPubkey = e.expectedAudienceXOnlyPubkey, this.authGatedMethods = e.authGatedMethods, this.grpcGatedMethods = e.grpcGatedMethods, this.refreshSkewSecs = e.refreshSkewSecs ?? Mt, this.now = e.now ?? (() => Math.floor(Date.now() / 1e3));
949
+ h(this, "cachedGrpc", null);
950
+ h(this, "inFlightGrpc", null);
951
+ this.client = e.client, this.peginTxid = e.peginTxid, this.authAnchorHex = e.authAnchorHex, this.pinnedServerPubkey = e.pinnedServerPubkey, this.expectedAudienceXOnlyPubkey = e.expectedAudienceXOnlyPubkey, this.authGatedMethods = e.authGatedMethods, this.grpcGatedMethods = e.grpcGatedMethods, this.refreshSkewSecs = e.refreshSkewSecs ?? ot, this.now = e.now ?? (() => Math.floor(Date.now() / 1e3));
1365
952
  }
1366
953
  /**
1367
954
  * Return a bearer token for `method`, or `null` if `method` is not
@@ -1381,7 +968,7 @@ class Gt {
1381
968
  * deterministically.
1382
969
  */
1383
970
  async getToken(e) {
1384
- return e === F || e === J ? null : this.grpcGatedMethods.has(e) ? this.getTokenForSubject("grpc") : this.authGatedMethods.has(e) ? this.getTokenForSubject("jsonrpc") : null;
971
+ return e === V || e === $ ? null : this.grpcGatedMethods.has(e) ? this.getTokenForSubject("grpc") : this.authGatedMethods.has(e) ? this.getTokenForSubject("jsonrpc") : null;
1385
972
  }
1386
973
  /**
1387
974
  * Drop both cached tokens. Next `getToken` call re-acquires the slot
@@ -1414,13 +1001,13 @@ class Gt {
1414
1001
  acquireSingleFlight(e) {
1415
1002
  const t = e === "grpc" ? this.inFlightGrpc : this.inFlightJsonRpc;
1416
1003
  if (t) return t;
1417
- const n = e === "grpc" ? J : F, i = (async () => {
1004
+ const n = e === "grpc" ? $ : V, i = (async () => {
1418
1005
  try {
1419
1006
  const s = await this.client.call(n, {
1420
1007
  pegin_txid: this.peginTxid,
1421
1008
  auth_anchor: this.authAnchorHex
1422
1009
  });
1423
- if (tt({
1010
+ if (Pe({
1424
1011
  proof: s.server_identity,
1425
1012
  pinnedServerPubkey: this.pinnedServerPubkey,
1426
1013
  now: this.now()
@@ -1429,25 +1016,25 @@ class Gt {
1429
1016
  `VpTokenProvider: invalid token in acquire response (expected non-empty string, got ${typeof s.token})`
1430
1017
  );
1431
1018
  const a = this.now();
1432
- if (!Number.isSafeInteger(s.expires_at) || s.expires_at <= a || s.expires_at > ue)
1019
+ if (!Number.isSafeInteger(s.expires_at) || s.expires_at <= a || s.expires_at > Q)
1433
1020
  throw new Error(
1434
- `VpTokenProvider: invalid expires_at in acquire response (got ${JSON.stringify(s.expires_at)}; must be a safe integer in (${a}, ${ue}])`
1021
+ `VpTokenProvider: invalid expires_at in acquire response (got ${JSON.stringify(s.expires_at)}; must be a safe integer in (${a}, ${Q}])`
1435
1022
  );
1436
- $t({
1023
+ Ze({
1437
1024
  token: s.token,
1438
1025
  ephemeralPubkeyHex: s.server_identity.ephemeral_pubkey,
1439
1026
  expectedIssuerXOnlyPubkey: this.pinnedServerPubkey,
1440
- expectedSubject: e === "grpc" ? mt : _t,
1027
+ expectedSubject: e === "grpc" ? He : Ke,
1441
1028
  expectedAudienceXOnlyPubkey: this.expectedAudienceXOnlyPubkey,
1442
1029
  responseExpiresAt: s.expires_at,
1443
1030
  serverIdentityExpiresAt: s.server_identity.expires_at,
1444
1031
  now: a
1445
1032
  });
1446
- const c = {
1033
+ const o = {
1447
1034
  token: s.token,
1448
1035
  expiresAt: s.expires_at
1449
1036
  };
1450
- return e === "grpc" ? this.cachedGrpc = c : this.cachedJsonRpc = c, c;
1037
+ return e === "grpc" ? this.cachedGrpc = o : this.cachedJsonRpc = o, o;
1451
1038
  } finally {
1452
1039
  e === "grpc" ? this.inFlightGrpc = null : this.inFlightJsonRpc = null;
1453
1040
  }
@@ -1455,9 +1042,9 @@ class Gt {
1455
1042
  return e === "grpc" ? this.inFlightGrpc = i : this.inFlightJsonRpc = i, i;
1456
1043
  }
1457
1044
  }
1458
- class jt {
1045
+ class lt {
1459
1046
  constructor() {
1460
- f(this, "entries", /* @__PURE__ */ new Map());
1047
+ h(this, "entries", /* @__PURE__ */ new Map());
1461
1048
  }
1462
1049
  /**
1463
1050
  * Return the cached `VpTokenProvider` for `peginTxid` if one exists
@@ -1482,14 +1069,14 @@ class jt {
1482
1069
  );
1483
1070
  return t.provider.setClient(e.client), t.provider;
1484
1071
  }
1485
- const n = new Gt({
1072
+ const n = new ct({
1486
1073
  client: e.client,
1487
1074
  peginTxid: e.peginTxid,
1488
1075
  authAnchorHex: e.authAnchorHex,
1489
1076
  pinnedServerPubkey: e.pinnedServerPubkey,
1490
1077
  expectedAudienceXOnlyPubkey: e.expectedAudienceXOnlyPubkey,
1491
- authGatedMethods: rt,
1492
- grpcGatedMethods: nt
1078
+ authGatedMethods: Ee,
1079
+ grpcGatedMethods: Ce
1493
1080
  });
1494
1081
  return this.entries.set(e.peginTxid, {
1495
1082
  provider: n,
@@ -1524,128 +1111,49 @@ class jt {
1524
1111
  return this.entries.size;
1525
1112
  }
1526
1113
  }
1527
- const Pe = new jt();
1528
- function rr(r) {
1114
+ const ie = new lt();
1115
+ function Pt(r) {
1529
1116
  var n;
1530
- const e = be(
1117
+ const e = re(
1531
1118
  r.baseUrl,
1532
1119
  (n = r.options) == null ? void 0 : n.headers
1533
- ), t = Pe.getOrCreate({
1120
+ ), t = ie.getOrCreate({
1534
1121
  client: e,
1535
1122
  peginTxid: r.peginTxid,
1536
1123
  authAnchorHex: r.authAnchorHex,
1537
1124
  pinnedServerPubkey: r.pinnedServerPubkey,
1538
- expectedAudienceXOnlyPubkey: de(
1125
+ expectedAudienceXOnlyPubkey: Z(
1539
1126
  r.depositorBtcPubkey
1540
1127
  )
1541
1128
  });
1542
- return new qe(r.baseUrl, {
1129
+ return new fe(r.baseUrl, {
1543
1130
  ...r.options,
1544
1131
  tokenProvider: t
1545
1132
  });
1546
1133
  }
1547
- function nr(r) {
1548
- Pe.getOrCreate({
1549
- client: be(r.baseUrl, r.headers),
1134
+ function Et(r) {
1135
+ ie.getOrCreate({
1136
+ client: re(r.baseUrl, r.headers),
1550
1137
  peginTxid: r.peginTxid,
1551
1138
  authAnchorHex: r.authAnchorHex,
1552
1139
  pinnedServerPubkey: r.pinnedServerPubkey,
1553
- expectedAudienceXOnlyPubkey: de(
1140
+ expectedAudienceXOnlyPubkey: Z(
1554
1141
  r.depositorBtcPubkey
1555
1142
  )
1556
1143
  });
1557
1144
  }
1558
- function Lt(r, e) {
1559
- const t = /* @__PURE__ */ new Set();
1560
- for (const u of r)
1561
- t.add(u.toLowerCase());
1562
- const n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), s = [], a = [];
1563
- for (const u of e) {
1564
- const d = u.pegin_txid.toLowerCase();
1565
- if (!t.has(d)) {
1566
- a.push(d);
1567
- continue;
1568
- }
1569
- if (i.has(d)) {
1570
- s.push(d);
1571
- continue;
1572
- }
1573
- i.add(d), n.set(d, { result: u.result, error: u.error });
1574
- }
1575
- const c = [];
1576
- for (const u of t)
1577
- i.has(u) || c.push(u);
1578
- return { byTxid: n, missing: c, unexpected: a, duplicate: s };
1579
- }
1580
- async function sr(r) {
1581
- const {
1582
- items: e,
1583
- getTxid: t,
1584
- batchCall: n,
1585
- onItem: i,
1586
- onMissing: s,
1587
- onDuplicate: a,
1588
- onDuplicateBatch: c,
1589
- onWholeBatchError: u,
1590
- onUnexpected: d,
1591
- batchSize: g = Ie
1592
- } = r;
1593
- if (!Number.isInteger(g) || g <= 0)
1594
- throw new Error(
1595
- `batchPollByProvider: batchSize must be a positive integer, got ${g}`
1596
- );
1597
- for (let y = 0; y < e.length; y += g) {
1598
- const A = e.slice(y, y + g), E = /* @__PURE__ */ new Map(), S = [];
1599
- for (const _ of A) {
1600
- const l = t(_).toLowerCase();
1601
- E.set(l, _), S.push(l);
1602
- }
1603
- let x;
1604
- try {
1605
- const _ = await n(S);
1606
- x = Lt(S, _.results);
1607
- } catch (_) {
1608
- u(A, _);
1609
- continue;
1610
- }
1611
- d && x.unexpected.length > 0 && d(x.unexpected);
1612
- const T = new Set(x.duplicate);
1613
- for (const _ of T) {
1614
- const l = E.get(_);
1615
- l && a(l);
1616
- }
1617
- c && T.size > 0 && c(T.size);
1618
- for (const _ of x.missing) {
1619
- const l = E.get(_);
1620
- l && s(l);
1621
- }
1622
- for (const [_, l] of x.byTxid) {
1623
- if (T.has(_)) continue;
1624
- const C = E.get(_);
1625
- C && i(C, {
1626
- pegin_txid: _,
1627
- result: l.result,
1628
- error: l.error
1629
- });
1630
- }
1631
- }
1632
- }
1633
1145
  export {
1634
- Ne as O,
1635
- b as S,
1636
- qe as V,
1637
- o as a,
1638
- sr as b,
1639
- tt as c,
1640
- jt as d,
1641
- Pe as e,
1642
- rr as f,
1643
- Qt as g,
1644
- Zt as h,
1645
- tr as i,
1646
- er as j,
1647
- nr as p,
1648
- qt as r,
1649
- Ke as v
1146
+ _e as O,
1147
+ m as S,
1148
+ lt as V,
1149
+ ie as a,
1150
+ _t as b,
1151
+ Pt as c,
1152
+ wt as d,
1153
+ vt as e,
1154
+ xt as f,
1155
+ Et as p,
1156
+ At as r,
1157
+ Pe as v
1650
1158
  };
1651
- //# sourceMappingURL=batchPoll-Bc_UKaTz.js.map
1159
+ //# sourceMappingURL=primeVpAuth-D1qbOkhb.js.map