@babylonlabs-io/ts-sdk 0.56.1 → 0.57.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 (151) hide show
  1. package/dist/BTCVaultRegistry.abi-AUAyCHal.cjs +2 -0
  2. package/dist/BTCVaultRegistry.abi-AUAyCHal.cjs.map +1 -0
  3. package/dist/{BTCVaultRegistry.abi-Chs4AFBj.js → BTCVaultRegistry.abi-CixOlp3B.js} +73 -14
  4. package/dist/BTCVaultRegistry.abi-CixOlp3B.js.map +1 -0
  5. package/dist/BTCVaultRegistryKeyEpochs.abi-CXjhRZbm.js +111 -0
  6. package/dist/BTCVaultRegistryKeyEpochs.abi-CXjhRZbm.js.map +1 -0
  7. package/dist/BTCVaultRegistryKeyEpochs.abi-_NERAdc5.cjs +2 -0
  8. package/dist/BTCVaultRegistryKeyEpochs.abi-_NERAdc5.cjs.map +1 -0
  9. package/dist/{PeginManager-Ba7Cr51Z.js → PeginManager-CnX3uFb0.js} +5 -5
  10. package/dist/{PeginManager-Ba7Cr51Z.js.map → PeginManager-CnX3uFb0.js.map} +1 -1
  11. package/dist/PeginManager-iDbqXsKD.cjs +2 -0
  12. package/dist/{PeginManager-CcjGRo4O.cjs.map → PeginManager-iDbqXsKD.cjs.map} +1 -1
  13. package/dist/ProtocolParams.abi-C8U7BHCS.cjs +2 -0
  14. package/dist/ProtocolParams.abi-C8U7BHCS.cjs.map +1 -0
  15. package/dist/{ApplicationRegistry.abi-w5prf7Ig.js → ProtocolParams.abi-CV938AYZ.js} +150 -80
  16. package/dist/ProtocolParams.abi-CV938AYZ.js.map +1 -0
  17. package/dist/{buildAndBroadcastRefund-BtXUqBkb.js → buildAndBroadcastRefund-CCb1_z24.js} +627 -452
  18. package/dist/buildAndBroadcastRefund-CCb1_z24.js.map +1 -0
  19. package/dist/buildAndBroadcastRefund-CDzzTZ2U.cjs +2 -0
  20. package/dist/buildAndBroadcastRefund-CDzzTZ2U.cjs.map +1 -0
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.js +163 -153
  23. package/dist/index.js.map +1 -1
  24. package/dist/{types-CQDRQvV-.js → json-rpc-client-Ehjthcd7.js} +61 -61
  25. package/dist/json-rpc-client-Ehjthcd7.js.map +1 -0
  26. package/dist/{types-WA0LrDk1.cjs → json-rpc-client-fUoK-TzT.cjs} +2 -2
  27. package/dist/json-rpc-client-fUoK-TzT.cjs.map +1 -0
  28. package/dist/mempoolApi-C0olk43O.js +536 -0
  29. package/dist/mempoolApi-C0olk43O.js.map +1 -0
  30. package/dist/mempoolApi-Dsm2VPXp.cjs +2 -0
  31. package/dist/mempoolApi-Dsm2VPXp.cjs.map +1 -0
  32. package/dist/{noPayout-CihCk1HE.js → noPayout-CI4l1qu2.js} +2 -2
  33. package/dist/{noPayout-CihCk1HE.js.map → noPayout-CI4l1qu2.js.map} +1 -1
  34. package/dist/{noPayout-Cb8vFrkY.cjs → noPayout-Djrv31V5.cjs} +2 -2
  35. package/dist/{noPayout-Cb8vFrkY.cjs.map → noPayout-Djrv31V5.cjs.map} +1 -1
  36. package/dist/onChainBtcPubkey-Cd9kpz-S.cjs +2 -0
  37. package/dist/onChainBtcPubkey-Cd9kpz-S.cjs.map +1 -0
  38. package/dist/onChainBtcPubkey-aPY5ib3Q.js +19 -0
  39. package/dist/onChainBtcPubkey-aPY5ib3Q.js.map +1 -0
  40. package/dist/primeVpAuth-BlxUcdBf.cjs +2 -0
  41. package/dist/primeVpAuth-BlxUcdBf.cjs.map +1 -0
  42. package/dist/{primeVpAuth-Caa5J_uv.js → primeVpAuth-DkJbvywo.js} +479 -367
  43. package/dist/primeVpAuth-DkJbvywo.js.map +1 -0
  44. package/dist/signPsbtsWithFallback-C01N6Kdo.cjs +2 -0
  45. package/dist/signPsbtsWithFallback-C01N6Kdo.cjs.map +1 -0
  46. package/dist/{PayoutManager-BVgmuKuK.js → signPsbtsWithFallback-CzZFZf0I.js} +105 -101
  47. package/dist/signPsbtsWithFallback-CzZFZf0I.js.map +1 -0
  48. package/dist/tbv/core/clients/eth/index.d.ts +5 -3
  49. package/dist/tbv/core/clients/eth/index.d.ts.map +1 -1
  50. package/dist/tbv/core/clients/eth/onChainBtcPubkey.d.ts +16 -0
  51. package/dist/tbv/core/clients/eth/onChainBtcPubkey.d.ts.map +1 -0
  52. package/dist/tbv/core/clients/eth/operation-key-reader.d.ts +33 -0
  53. package/dist/tbv/core/clients/eth/operation-key-reader.d.ts.map +1 -0
  54. package/dist/tbv/core/clients/eth/types.d.ts +122 -3
  55. package/dist/tbv/core/clients/eth/types.d.ts.map +1 -1
  56. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts +25 -1
  57. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts.map +1 -1
  58. package/dist/tbv/core/clients/index.cjs +1 -1
  59. package/dist/tbv/core/clients/index.js +35 -32
  60. package/dist/tbv/core/clients/index.js.map +1 -1
  61. package/dist/tbv/core/contracts/__tests__/BTCVaultRegistryKeyEpochs.abi.test.d.ts +2 -0
  62. package/dist/tbv/core/contracts/__tests__/BTCVaultRegistryKeyEpochs.abi.test.d.ts.map +1 -0
  63. package/dist/tbv/core/contracts/abis/ApplicationRegistry.abi.d.ts +66 -0
  64. package/dist/tbv/core/contracts/abis/ApplicationRegistry.abi.d.ts.map +1 -1
  65. package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts +50 -0
  66. package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts.map +1 -1
  67. package/dist/tbv/core/contracts/abis/BTCVaultRegistryKeyEpochs.abi.d.ts +111 -0
  68. package/dist/tbv/core/contracts/abis/BTCVaultRegistryKeyEpochs.abi.d.ts.map +1 -0
  69. package/dist/tbv/core/contracts/abis/ProtocolParams.abi.d.ts +36 -0
  70. package/dist/tbv/core/contracts/abis/ProtocolParams.abi.d.ts.map +1 -1
  71. package/dist/tbv/core/contracts/index.cjs +1 -1
  72. package/dist/tbv/core/contracts/index.d.ts +2 -1
  73. package/dist/tbv/core/contracts/index.d.ts.map +1 -1
  74. package/dist/tbv/core/contracts/index.js +8 -6
  75. package/dist/tbv/core/contracts/index.js.map +1 -1
  76. package/dist/tbv/core/index.cjs +1 -1
  77. package/dist/tbv/core/index.js +163 -153
  78. package/dist/tbv/core/index.js.map +1 -1
  79. package/dist/tbv/core/managers/PayoutManager.d.ts +8 -0
  80. package/dist/tbv/core/managers/PayoutManager.d.ts.map +1 -1
  81. package/dist/tbv/core/managers/index.cjs +1 -1
  82. package/dist/tbv/core/managers/index.js +2 -2
  83. package/dist/tbv/core/primitives/index.cjs +1 -1
  84. package/dist/tbv/core/primitives/index.js +2 -2
  85. package/dist/tbv/core/primitives/psbt/__tests__/standardPayoutScript.test.d.ts +2 -0
  86. package/dist/tbv/core/primitives/psbt/__tests__/standardPayoutScript.test.d.ts.map +1 -0
  87. package/dist/tbv/core/primitives/psbt/assertPayoutFeeBand.d.ts +5 -5
  88. package/dist/tbv/core/primitives/psbt/assertPayoutFeeBand.d.ts.map +1 -1
  89. package/dist/tbv/core/primitives/psbt/payout.d.ts +23 -0
  90. package/dist/tbv/core/primitives/psbt/payout.d.ts.map +1 -1
  91. package/dist/tbv/core/primitives/psbt/standardPayoutScript.d.ts +41 -0
  92. package/dist/tbv/core/primitives/psbt/standardPayoutScript.d.ts.map +1 -0
  93. package/dist/tbv/core/services/deposit/__tests__/verifyRegisteredParticipantKeys.test.d.ts +2 -0
  94. package/dist/tbv/core/services/deposit/__tests__/verifyRegisteredParticipantKeys.test.d.ts.map +1 -0
  95. package/dist/tbv/core/services/deposit/index.d.ts +7 -6
  96. package/dist/tbv/core/services/deposit/index.d.ts.map +1 -1
  97. package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts +10 -0
  98. package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts.map +1 -1
  99. package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts +9 -0
  100. package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts.map +1 -1
  101. package/dist/tbv/core/services/deposit/validateOnChainParticipantKeys.d.ts +38 -1
  102. package/dist/tbv/core/services/deposit/validateOnChainParticipantKeys.d.ts.map +1 -1
  103. package/dist/tbv/core/services/deposit/verifyRegisteredParticipantKeys.d.ts +42 -0
  104. package/dist/tbv/core/services/deposit/verifyRegisteredParticipantKeys.d.ts.map +1 -0
  105. package/dist/tbv/core/services/index.cjs +1 -1
  106. package/dist/tbv/core/services/index.d.ts +1 -0
  107. package/dist/tbv/core/services/index.d.ts.map +1 -1
  108. package/dist/tbv/core/services/index.js +36 -31
  109. package/dist/tbv/core/services/participants/__tests__/fixtures/rotation.d.ts +55 -0
  110. package/dist/tbv/core/services/participants/__tests__/fixtures/rotation.d.ts.map +1 -0
  111. package/dist/tbv/core/services/participants/__tests__/resolveParticipantKeys.test.d.ts +2 -0
  112. package/dist/tbv/core/services/participants/__tests__/resolveParticipantKeys.test.d.ts.map +1 -0
  113. package/dist/tbv/core/services/participants/index.d.ts +8 -0
  114. package/dist/tbv/core/services/participants/index.d.ts.map +1 -0
  115. package/dist/tbv/core/services/participants/resolveParticipantKeys.d.ts +26 -0
  116. package/dist/tbv/core/services/participants/resolveParticipantKeys.d.ts.map +1 -0
  117. package/dist/tbv/core/services/participants/types.d.ts +62 -0
  118. package/dist/tbv/core/services/participants/types.d.ts.map +1 -0
  119. package/dist/tbv/index.cjs +1 -1
  120. package/dist/tbv/index.js +163 -153
  121. package/dist/tbv/index.js.map +1 -1
  122. package/dist/verifyScriptPathSchnorrSignature-C-84KJ6U.cjs +2 -0
  123. package/dist/verifyScriptPathSchnorrSignature-C-84KJ6U.cjs.map +1 -0
  124. package/dist/{verifyScriptPathSchnorrSignature-CgrnAjMW.js → verifyScriptPathSchnorrSignature-Xoo9DOHW.js} +359 -301
  125. package/dist/verifyScriptPathSchnorrSignature-Xoo9DOHW.js.map +1 -0
  126. package/package.json +1 -1
  127. package/dist/ApplicationRegistry.abi-CLaa6E99.cjs +0 -2
  128. package/dist/ApplicationRegistry.abi-CLaa6E99.cjs.map +0 -1
  129. package/dist/ApplicationRegistry.abi-w5prf7Ig.js.map +0 -1
  130. package/dist/BTCVaultRegistry.abi-Chs4AFBj.js.map +0 -1
  131. package/dist/BTCVaultRegistry.abi-JdeqLz4x.cjs +0 -2
  132. package/dist/BTCVaultRegistry.abi-JdeqLz4x.cjs.map +0 -1
  133. package/dist/PayoutManager-BVgmuKuK.js.map +0 -1
  134. package/dist/PayoutManager-Cu4_l-_Y.cjs +0 -2
  135. package/dist/PayoutManager-Cu4_l-_Y.cjs.map +0 -1
  136. package/dist/PeginManager-CcjGRo4O.cjs +0 -2
  137. package/dist/buildAndBroadcastRefund-BtXUqBkb.js.map +0 -1
  138. package/dist/buildAndBroadcastRefund-Cq01wyZX.cjs +0 -2
  139. package/dist/buildAndBroadcastRefund-Cq01wyZX.cjs.map +0 -1
  140. package/dist/mempoolApi-DkyKmmgI.cjs +0 -2
  141. package/dist/mempoolApi-DkyKmmgI.cjs.map +0 -1
  142. package/dist/mempoolApi-lpJdvPkK.js +0 -483
  143. package/dist/mempoolApi-lpJdvPkK.js.map +0 -1
  144. package/dist/primeVpAuth-Caa5J_uv.js.map +0 -1
  145. package/dist/primeVpAuth-y-4A88ah.cjs +0 -2
  146. package/dist/primeVpAuth-y-4A88ah.cjs.map +0 -1
  147. package/dist/types-CQDRQvV-.js.map +0 -1
  148. package/dist/types-WA0LrDk1.cjs.map +0 -1
  149. package/dist/verifyScriptPathSchnorrSignature-BZhX-SOd.cjs +0 -2
  150. package/dist/verifyScriptPathSchnorrSignature-BZhX-SOd.cjs.map +0 -1
  151. package/dist/verifyScriptPathSchnorrSignature-CgrnAjMW.js.map +0 -1
@@ -1,28 +1,28 @@
1
- var Se = Object.defineProperty;
2
- var Ce = (r, e, t) => e in r ? Se(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
1
+ var ke = Object.defineProperty;
2
+ var Ce = (r, e, t) => e in r ? ke(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
3
  var f = (r, e, t) => Ce(r, typeof e != "symbol" ? e + "" : e, t);
4
- import { B as Q } from "./BTCVaultRegistry.abi-Chs4AFBj.js";
5
- import { P as b, A as L } from "./ApplicationRegistry.abi-w5prf7Ig.js";
6
- import { k as Te, v as U, l as $e, j as Ve } from "./mempoolApi-lpJdvPkK.js";
7
- import { D as Ie, J as ge, e as Re } from "./types-CQDRQvV-.js";
8
- import { X as R, C as G, s as I, S as Oe, h as Ne, p as fe } from "./bitcoin-B5aNKtsk.js";
4
+ import { B } from "./BTCVaultRegistry.abi-CixOlp3B.js";
5
+ import { A as R, P as y } from "./ProtocolParams.abi-CV938AYZ.js";
6
+ import { k as Te, v as K, l as $e, j as Ve } from "./mempoolApi-C0olk43O.js";
7
+ import { D as Ie, J as ge, e as Re } from "./json-rpc-client-Ehjthcd7.js";
8
+ import { X as O, C as j, s as I, S as Oe, h as Ne, p as fe } from "./bitcoin-B5aNKtsk.js";
9
9
  import { C as ee } from "./constants-CDQE812z.js";
10
- import { H as S } from "./validation-Dj3dqYtl.js";
11
- import * as H from "@bitcoin-js/tiny-secp256k1-asmjs";
10
+ import { H as k } from "./validation-Dj3dqYtl.js";
11
+ import * as U from "@bitcoin-js/tiny-secp256k1-asmjs";
12
12
  import { payments as Be, Transaction as X } from "bitcoinjs-lib";
13
13
  import { Buffer as V } from "buffer";
14
- import { s as q } from "./sha2-BYVxyZzX.js";
14
+ import { s as Y } from "./sha2-BYVxyZzX.js";
15
15
  async function or(r, e) {
16
16
  const [t, n] = await r.multicall({
17
17
  contracts: [
18
18
  {
19
19
  address: e,
20
- abi: Q,
20
+ abi: B,
21
21
  functionName: "protocolParams"
22
22
  },
23
23
  {
24
24
  address: e,
25
- abi: Q,
25
+ abi: B,
26
26
  functionName: "applicationRegistry"
27
27
  }
28
28
  ],
@@ -33,8 +33,119 @@ async function or(r, e) {
33
33
  applicationRegistry: n
34
34
  };
35
35
  }
36
+ function Ge(r, e) {
37
+ return {
38
+ vaultProvider: r[0],
39
+ vaultKeepers: r.slice(1, 1 + e),
40
+ universalChallengers: r.slice(1 + e)
41
+ };
42
+ }
43
+ class cr {
44
+ constructor(e, t) {
45
+ this.publicClient = e, this.contracts = t;
46
+ }
47
+ /**
48
+ * One multicall, `allowFailure: false`, so every key in the set is read at
49
+ * the same block. A rotation landing between two separate `eth_call`s would
50
+ * otherwise produce a mixed-epoch key set and a lock no counterparty agrees
51
+ * with.
52
+ */
53
+ async readAll(e, t) {
54
+ const n = await this.publicClient.multicall({
55
+ contracts: e,
56
+ allowFailure: !1
57
+ });
58
+ return Ge(n, t);
59
+ }
60
+ async getCurrentOperationKeys(e) {
61
+ const t = [
62
+ {
63
+ address: this.contracts.btcVaultRegistry,
64
+ abi: B,
65
+ functionName: "getCurrentOperationBtcKey",
66
+ args: [e.vaultProviderEthAddress]
67
+ },
68
+ ...e.vaultKeepers.map((n) => ({
69
+ address: this.contracts.applicationRegistry,
70
+ abi: R,
71
+ functionName: "getCurrentOperationBtcKey",
72
+ args: [e.applicationEntryPoint, n.ethAddress]
73
+ })),
74
+ ...e.universalChallengers.map((n) => ({
75
+ address: this.contracts.protocolParams,
76
+ abi: y,
77
+ functionName: "getCurrentOperationBtcKey",
78
+ args: [n.ethAddress]
79
+ }))
80
+ ];
81
+ return this.readAll(t, e.vaultKeepers.length);
82
+ }
83
+ async getOperationKeysAtEpochs(e, t) {
84
+ const n = [
85
+ // The VP takes the plain `AtEpoch` variant: it has no membership
86
+ // version, so its genesis (the registration key at version 0) is
87
+ // unambiguous and the contract resolves it internally.
88
+ {
89
+ address: this.contracts.btcVaultRegistry,
90
+ abi: B,
91
+ functionName: "getOperationBtcKeyAtEpoch",
92
+ args: [e.vaultProviderEthAddress, t.vpKeyEpoch]
93
+ },
94
+ // Keepers and challengers take `...OrGenesis` with their roster key
95
+ // passed explicitly, because the correct genesis for them is their key
96
+ // in *this vault's frozen membership version*. An operator dropped from
97
+ // the current roster, or listed under a different key in an older
98
+ // version, would otherwise resolve against the wrong genesis.
99
+ ...e.vaultKeepers.map((i) => ({
100
+ address: this.contracts.applicationRegistry,
101
+ abi: R,
102
+ functionName: "getOperationBtcKeyAtEpochOrGenesis",
103
+ args: [
104
+ e.applicationEntryPoint,
105
+ i.ethAddress,
106
+ t.appKeeperKeyEpoch,
107
+ i.btcPubKey
108
+ ]
109
+ })),
110
+ ...e.universalChallengers.map((i) => ({
111
+ address: this.contracts.protocolParams,
112
+ abi: y,
113
+ functionName: "getOperationBtcKeyAtEpochOrGenesis",
114
+ args: [i.ethAddress, t.ucKeyEpoch, i.btcPubKey]
115
+ }))
116
+ ];
117
+ return this.readAll(n, e.vaultKeepers.length);
118
+ }
119
+ async getPayoutScriptsAtEpochs(e, t) {
120
+ const n = await this.publicClient.multicall({
121
+ contracts: [
122
+ {
123
+ address: this.contracts.btcVaultRegistry,
124
+ abi: B,
125
+ functionName: "getPayoutScriptAtEpoch",
126
+ args: [e.vaultProviderEthAddress, t.vpKeyEpoch]
127
+ },
128
+ ...e.vaultKeepers.map((i) => ({
129
+ address: this.contracts.applicationRegistry,
130
+ abi: R,
131
+ functionName: "getPayoutScriptAtEpoch",
132
+ args: [
133
+ e.applicationEntryPoint,
134
+ i.ethAddress,
135
+ t.appKeeperKeyEpoch
136
+ ]
137
+ }))
138
+ ],
139
+ allowFailure: !1
140
+ });
141
+ return {
142
+ vaultProvider: n[0],
143
+ vaultKeepers: [...n.slice(1)]
144
+ };
145
+ }
146
+ }
36
147
  const te = 65535;
37
- function N(r) {
148
+ function G(r) {
38
149
  return {
39
150
  timelockAssert: r.timelockAssert,
40
151
  timelockChallengeAssert: r.timelockChallengeAssert,
@@ -68,14 +179,14 @@ function ne(r) {
68
179
  );
69
180
  return Number(r);
70
181
  }
71
- class ar {
182
+ class lr {
72
183
  constructor(e, t) {
73
184
  this.publicClient = e, this.contractAddress = t;
74
185
  }
75
186
  async getTBVProtocolParams() {
76
187
  const e = await this.publicClient.readContract({
77
188
  address: this.contractAddress,
78
- abi: b,
189
+ abi: y,
79
190
  functionName: "getTBVProtocolParams"
80
191
  }), t = re(e);
81
192
  return Te(t), t;
@@ -83,24 +194,24 @@ class ar {
83
194
  async getLatestOffchainParams() {
84
195
  const e = await this.publicClient.readContract({
85
196
  address: this.contractAddress,
86
- abi: b,
197
+ abi: y,
87
198
  functionName: "getLatestOffchainParams"
88
- }), t = N(e);
89
- return U(t), t;
199
+ }), t = G(e);
200
+ return K(t), t;
90
201
  }
91
202
  async getOffchainParamsByVersion(e) {
92
203
  const t = await this.publicClient.readContract({
93
204
  address: this.contractAddress,
94
- abi: b,
205
+ abi: y,
95
206
  functionName: "getOffchainParamsByVersion",
96
207
  args: [e]
97
- }), n = N(t);
98
- return U(n), n;
208
+ }), n = G(t);
209
+ return K(n), n;
99
210
  }
100
211
  async getLatestOffchainParamsVersion() {
101
212
  const e = await this.publicClient.readContract({
102
213
  address: this.contractAddress,
103
- abi: b,
214
+ abi: y,
104
215
  functionName: "latestOffchainParamsVersion"
105
216
  }), t = Number(e);
106
217
  return $e(t), t;
@@ -121,27 +232,27 @@ class ar {
121
232
  contracts: [
122
233
  {
123
234
  address: this.contractAddress,
124
- abi: b,
235
+ abi: y,
125
236
  functionName: "getTBVProtocolParams"
126
237
  },
127
238
  {
128
239
  address: this.contractAddress,
129
- abi: b,
240
+ abi: y,
130
241
  functionName: "getLatestOffchainParams"
131
242
  },
132
243
  {
133
244
  address: this.contractAddress,
134
- abi: b,
245
+ abi: y,
135
246
  functionName: "latestOffchainParamsVersion"
136
247
  },
137
248
  {
138
249
  address: this.contractAddress,
139
- abi: b,
250
+ abi: y,
140
251
  functionName: "activeVaultCoreVersion"
141
252
  }
142
253
  ],
143
254
  allowFailure: !1
144
- }), t = re(e[0]), n = N(e[1]), i = Number(e[2]), s = Number(e[3]), o = {
255
+ }), t = re(e[0]), n = G(e[1]), i = Number(e[2]), s = Number(e[3]), a = {
145
256
  minimumPegInAmount: t.minimumPegInAmount,
146
257
  maxPegInAmount: t.maxPegInAmount,
147
258
  pegInAckTimeout: t.pegInAckTimeout,
@@ -155,7 +266,7 @@ class ar {
155
266
  offchainParamsVersion: i,
156
267
  activeVaultCoreVersion: s
157
268
  };
158
- return Ve(o), o;
269
+ return Ve(a), a;
159
270
  }
160
271
  /**
161
272
  * Fetch every historical offchain params version in a single multicall.
@@ -173,17 +284,17 @@ class ar {
173
284
  return { byVersion: /* @__PURE__ */ new Map(), latestVersion: 0 };
174
285
  const n = Array.from({ length: t }, (c, d) => d + 1), i = n.map((c) => ({
175
286
  address: this.contractAddress,
176
- abi: b,
287
+ abi: y,
177
288
  functionName: "getOffchainParamsByVersion",
178
289
  args: [c]
179
290
  })), s = await this.publicClient.multicall({
180
291
  contracts: i,
181
292
  allowFailure: !1
182
- }), o = /* @__PURE__ */ new Map();
293
+ }), a = /* @__PURE__ */ new Map();
183
294
  for (let c = 0; c < n.length; c++) {
184
- const d = N(s[c]);
295
+ const d = G(s[c]);
185
296
  try {
186
- U(d), o.set(n[c], d);
297
+ K(d), a.set(n[c], d);
187
298
  } catch (l) {
188
299
  e == null || e(
189
300
  n[c],
@@ -191,204 +302,204 @@ class ar {
191
302
  );
192
303
  }
193
304
  }
194
- return { byVersion: o, latestVersion: t };
305
+ return { byVersion: a, latestVersion: t };
195
306
  }
196
307
  }
197
- function M(r) {
308
+ function H(r) {
198
309
  return r.map((e) => ({
199
310
  ethAddress: e.ethAddress,
200
311
  btcPubKey: e.btcPubKey
201
312
  }));
202
313
  }
203
- class cr {
314
+ class ur {
204
315
  constructor(e, t) {
205
316
  this.publicClient = e, this.contractAddress = t;
206
317
  }
207
318
  async getVaultKeepersByVersion(e, t) {
208
319
  const n = await this.publicClient.readContract({
209
320
  address: this.contractAddress,
210
- abi: L,
321
+ abi: R,
211
322
  functionName: "getVaultKeepersByVersion",
212
323
  args: [e, t]
213
324
  });
214
- return M(n);
325
+ return H(n);
215
326
  }
216
327
  async getCurrentVaultKeepers(e) {
217
328
  const t = await this.publicClient.readContract({
218
329
  address: this.contractAddress,
219
- abi: L,
330
+ abi: R,
220
331
  functionName: "getCurrentVaultKeepers",
221
332
  args: [e]
222
333
  });
223
- return M(t);
334
+ return H(t);
224
335
  }
225
336
  async getCurrentVaultKeepersVersion(e) {
226
337
  return await this.publicClient.readContract({
227
338
  address: this.contractAddress,
228
- abi: L,
339
+ abi: R,
229
340
  functionName: "getCurrentVaultKeepersVersion",
230
341
  args: [e]
231
342
  });
232
343
  }
233
344
  }
234
- class lr {
345
+ class dr {
235
346
  constructor(e, t) {
236
347
  this.publicClient = e, this.contractAddress = t;
237
348
  }
238
349
  async getUniversalChallengersByVersion(e) {
239
350
  const t = await this.publicClient.readContract({
240
351
  address: this.contractAddress,
241
- abi: b,
352
+ abi: y,
242
353
  functionName: "getUniversalChallengersByVersion",
243
354
  args: [e]
244
355
  });
245
- return M(t);
356
+ return H(t);
246
357
  }
247
358
  async getCurrentUniversalChallengers() {
248
359
  const e = await this.publicClient.readContract({
249
360
  address: this.contractAddress,
250
- abi: b,
361
+ abi: y,
251
362
  functionName: "getCurrentUniversalChallengers"
252
363
  });
253
- return M(e);
364
+ return H(e);
254
365
  }
255
366
  async getLatestUniversalChallengersVersion() {
256
367
  return await this.publicClient.readContract({
257
368
  address: this.contractAddress,
258
- abi: b,
369
+ abi: y,
259
370
  functionName: "latestUniversalChallengersVersion"
260
371
  });
261
372
  }
262
373
  }
263
374
  var De = /* @__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))(De || {});
264
- const se = new Set(Object.values(Ie)), Ge = 200;
265
- function p(r) {
375
+ const se = new Set(Object.values(Ie)), Me = 200;
376
+ function h(r) {
266
377
  var e;
267
- return ((e = JSON.stringify(r)) == null ? void 0 : e.slice(0, Ge)) ?? "undefined";
378
+ return ((e = JSON.stringify(r)) == null ? void 0 : e.slice(0, Me)) ?? "undefined";
268
379
  }
269
- const Me = "The vault provider returned an unexpected response. Please try again or contact support.";
270
- class a extends Error {
380
+ const je = "The vault provider returned an unexpected response. Please try again or contact support.";
381
+ class o extends Error {
271
382
  constructor(t) {
272
- super(Me);
383
+ super(je);
273
384
  f(this, "detail");
274
385
  this.name = "VpResponseValidationError", this.detail = t;
275
386
  }
276
387
  }
277
- const O = 64;
388
+ const N = 64;
278
389
  function T(r) {
279
- return typeof r == "string" && r.length > 0 && S.test(r);
390
+ return typeof r == "string" && r.length > 0 && k.test(r);
280
391
  }
281
392
  function _e(r) {
282
393
  return typeof r == "string" && r.length > 0;
283
394
  }
284
395
  function me(r, e) {
285
396
  if (!T(r))
286
- throw new a(
287
- `VP response validation failed: "${e}" must be a non-empty hex string, got ${p(r)}`
397
+ throw new o(
398
+ `VP response validation failed: "${e}" must be a non-empty hex string, got ${h(r)}`
288
399
  );
289
400
  }
290
401
  function w(r, e) {
291
402
  if (!_e(r))
292
- throw new a(
293
- `VP response validation failed: "${e}" must be a non-empty string, got ${p(r)}`
403
+ throw new o(
404
+ `VP response validation failed: "${e}" must be a non-empty string, got ${h(r)}`
294
405
  );
295
406
  }
296
- function Z(r, e) {
297
- if (!T(r) || r.length !== R && r.length !== G)
298
- throw new a(
299
- `VP response validation failed: "${e}" must be a ${R} or ${G}-char hex string (BTC pubkey), got ${p(r)}`
407
+ function Q(r, e) {
408
+ if (!T(r) || r.length !== O && r.length !== j)
409
+ throw new o(
410
+ `VP response validation failed: "${e}" must be a ${O} or ${j}-char hex string (BTC pubkey), got ${h(r)}`
300
411
  );
301
412
  }
302
- function je(r) {
413
+ function He(r) {
303
414
  const e = r.presigning;
304
415
  if (e == null) return;
305
416
  if (typeof e != "object" || Array.isArray(e))
306
- throw new a(
417
+ throw new o(
307
418
  'VP response validation failed: "progress.presigning" must be an object if present'
308
419
  );
309
420
  const t = e;
310
421
  if (t.depositor_graph_created !== void 0 && typeof t.depositor_graph_created != "boolean")
311
- throw new a(
312
- `VP response validation failed: "progress.presigning.depositor_graph_created" must be a boolean if present, got ${p(t.depositor_graph_created)}`
422
+ throw new o(
423
+ `VP response validation failed: "progress.presigning.depositor_graph_created" must be a boolean if present, got ${h(t.depositor_graph_created)}`
313
424
  );
314
425
  if (t.vk_challenger_presigning_completed !== void 0 && typeof t.vk_challenger_presigning_completed != "number")
315
- throw new a(
316
- `VP response validation failed: "progress.presigning.vk_challenger_presigning_completed" must be a number if present, got ${p(t.vk_challenger_presigning_completed)}`
426
+ throw new o(
427
+ `VP response validation failed: "progress.presigning.vk_challenger_presigning_completed" must be a number if present, got ${h(t.vk_challenger_presigning_completed)}`
317
428
  );
318
429
  if (t.vk_challenger_presigning_total !== void 0 && typeof t.vk_challenger_presigning_total != "number")
319
- throw new a(
320
- `VP response validation failed: "progress.presigning.vk_challenger_presigning_total" must be a number if present, got ${p(t.vk_challenger_presigning_total)}`
430
+ throw new o(
431
+ `VP response validation failed: "progress.presigning.vk_challenger_presigning_total" must be a number if present, got ${h(t.vk_challenger_presigning_total)}`
321
432
  );
322
433
  }
323
434
  function ye(r) {
324
435
  if (r === null || typeof r != "object")
325
- throw new a(
436
+ throw new o(
326
437
  "VP response validation failed: getPeginStatus response is not an object"
327
438
  );
328
439
  const e = r;
329
- if (!T(e.pegin_txid) || e.pegin_txid.length !== O)
330
- throw new a(
331
- `VP response validation failed: "pegin_txid" must be a ${O}-char hex string (txid), got ${p(e.pegin_txid)}`
440
+ if (!T(e.pegin_txid) || e.pegin_txid.length !== N)
441
+ throw new o(
442
+ `VP response validation failed: "pegin_txid" must be a ${N}-char hex string (txid), got ${h(e.pegin_txid)}`
332
443
  );
333
444
  if (typeof e.status != "string")
334
- throw new a(
445
+ throw new o(
335
446
  'VP response validation failed: "status" must be a string'
336
447
  );
337
448
  if (!se.has(e.status))
338
- throw new a(
449
+ throw new o(
339
450
  `VP response validation failed: unrecognized status "${e.status}". Expected one of: ${[...se].join(", ")}`
340
451
  );
341
452
  if (e.progress === null || typeof e.progress != "object" || Array.isArray(e.progress))
342
- throw new a(
453
+ throw new o(
343
454
  'VP response validation failed: "progress" must be an object'
344
455
  );
345
- if (je(e.progress), typeof e.health_info != "string")
346
- throw new a(
456
+ if (He(e.progress), typeof e.health_info != "string")
457
+ throw new o(
347
458
  'VP response validation failed: "health_info" must be a string'
348
459
  );
349
460
  if (e.last_error !== void 0 && typeof e.last_error != "string")
350
- throw new a(
351
- `VP response validation failed: "last_error" must be a string if present, got ${p(e.last_error)}`
461
+ throw new o(
462
+ `VP response validation failed: "last_error" must be a string if present, got ${h(e.last_error)}`
352
463
  );
353
464
  }
354
- function He(r) {
465
+ function Le(r) {
355
466
  if (r === null || typeof r != "object")
356
- throw new a(
467
+ throw new o(
357
468
  "VP response validation failed: requestDepositorPresignTransactions response is not an object"
358
469
  );
359
470
  const e = r;
360
471
  if (!Array.isArray(e.txs))
361
- throw new a(
472
+ throw new o(
362
473
  'VP response validation failed: "txs" must be an array'
363
474
  );
364
475
  for (let t = 0; t < e.txs.length; t++)
365
- Le(e.txs[t], `txs[${t}]`);
476
+ Ue(e.txs[t], `txs[${t}]`);
366
477
  if (e.depositor_graph === null || typeof e.depositor_graph != "object")
367
- throw new a(
478
+ throw new o(
368
479
  'VP response validation failed: "depositor_graph" must be an object'
369
480
  );
370
- ze(
481
+ Ze(
371
482
  e.depositor_graph
372
483
  );
373
484
  }
374
485
  function A(r, e) {
375
486
  if (r === null || typeof r != "object")
376
- throw new a(
487
+ throw new o(
377
488
  `VP response validation failed: "${e}" must be an object`
378
489
  );
379
490
  me(r.tx_hex, `${e}.tx_hex`);
380
491
  }
381
- function Le(r, e) {
492
+ function Ue(r, e) {
382
493
  if (r === null || typeof r != "object")
383
- throw new a(
494
+ throw new o(
384
495
  `VP response validation failed: "${e}" must be an object`
385
496
  );
386
497
  const t = r;
387
- Z(t.claimer_pubkey, `${e}.claimer_pubkey`), A(t.claim_tx, `${e}.claim_tx`), A(t.assert_tx, `${e}.assert_tx`), A(t.payout_tx, `${e}.payout_tx`), w(t.payout_psbt, `${e}.payout_psbt`);
498
+ Q(t.claimer_pubkey, `${e}.claimer_pubkey`), A(t.claim_tx, `${e}.claim_tx`), A(t.assert_tx, `${e}.assert_tx`), A(t.payout_tx, `${e}.payout_tx`), w(t.payout_psbt, `${e}.payout_psbt`);
388
499
  }
389
- function Ue(r, e) {
500
+ function Ke(r, e) {
390
501
  if (r === null || typeof r != "object")
391
- throw new a(
502
+ throw new o(
392
503
  `VP response validation failed: "${e}" must be an object`
393
504
  );
394
505
  const t = r;
@@ -396,31 +507,31 @@ function Ue(r, e) {
396
507
  }
397
508
  function Xe(r, e) {
398
509
  if (r === null || typeof r != "object")
399
- throw new a(
510
+ throw new o(
400
511
  `VP response validation failed: "${e}" must be an object`
401
512
  );
402
513
  const t = r;
403
- if (Z(t.challenger_pubkey, `${e}.challenger_pubkey`), A(
514
+ if (Q(t.challenger_pubkey, `${e}.challenger_pubkey`), A(
404
515
  t.challenge_assert_x_tx,
405
516
  `${e}.challenge_assert_x_tx`
406
517
  ), A(
407
518
  t.challenge_assert_y_tx,
408
519
  `${e}.challenge_assert_y_tx`
409
520
  ), A(t.nopayout_tx, `${e}.nopayout_tx`), w(t.nopayout_psbt, `${e}.nopayout_psbt`), !Array.isArray(t.challenge_assert_connectors))
410
- throw new a(
521
+ throw new o(
411
522
  `VP response validation failed: "${e}.challenge_assert_connectors" must be an array`
412
523
  );
413
524
  if (t.challenge_assert_connectors.length !== ee)
414
- throw new a(
525
+ throw new o(
415
526
  `VP response validation failed: "${e}.challenge_assert_connectors" must have exactly ${ee} entries, got ${t.challenge_assert_connectors.length}`
416
527
  );
417
528
  for (let n = 0; n < t.challenge_assert_connectors.length; n++)
418
- Ue(
529
+ Ke(
419
530
  t.challenge_assert_connectors[n],
420
531
  `${e}.challenge_assert_connectors[${n}]`
421
532
  );
422
533
  if (!Array.isArray(t.output_label_hashes))
423
- throw new a(
534
+ throw new o(
424
535
  `VP response validation failed: "${e}.output_label_hashes" must be an array`
425
536
  );
426
537
  for (let n = 0; n < t.output_label_hashes.length; n++)
@@ -431,159 +542,159 @@ function Xe(r, e) {
431
542
  }
432
543
  function Fe(r) {
433
544
  if (r === null || typeof r != "object")
434
- throw new a(
545
+ throw new o(
435
546
  "VP response validation failed: requestDepositorClaimerArtifacts response is not an object"
436
547
  );
437
548
  const e = r;
438
549
  if (!_e(e.tx_graph_json))
439
- throw new a(
440
- `VP response validation failed: "tx_graph_json" must be a non-empty string, got ${p(e.tx_graph_json)}`
550
+ throw new o(
551
+ `VP response validation failed: "tx_graph_json" must be a non-empty string, got ${h(e.tx_graph_json)}`
441
552
  );
442
553
  if (!T(e.verifying_key_hex))
443
- throw new a(
444
- `VP response validation failed: "verifying_key_hex" must be a non-empty hex string, got ${p(e.verifying_key_hex)}`
554
+ throw new o(
555
+ `VP response validation failed: "verifying_key_hex" must be a non-empty hex string, got ${h(e.verifying_key_hex)}`
445
556
  );
446
557
  if (e.babe_sessions === null || typeof e.babe_sessions != "object" || Array.isArray(e.babe_sessions))
447
- throw new a(
558
+ throw new o(
448
559
  'VP response validation failed: "babe_sessions" must be an object'
449
560
  );
450
561
  const t = Object.entries(
451
562
  e.babe_sessions
452
563
  );
453
564
  if (t.length === 0)
454
- throw new a(
565
+ throw new o(
455
566
  'VP response validation failed: "babe_sessions" must contain at least one challenger entry'
456
567
  );
457
568
  for (const [n, i] of t) {
458
- if (Z(n, `babe_sessions["${n}"]`), i === null || typeof i != "object")
459
- throw new a(
569
+ if (Q(n, `babe_sessions["${n}"]`), i === null || typeof i != "object")
570
+ throw new o(
460
571
  `VP response validation failed: "babe_sessions.${n}" must be an object`
461
572
  );
462
573
  const s = i;
463
574
  if (!T(s.decryptor_artifacts_hex))
464
- throw new a(
465
- `VP response validation failed: "babe_sessions.${n}.decryptor_artifacts_hex" must be a non-empty hex string, got ${p(s.decryptor_artifacts_hex)}`
575
+ throw new o(
576
+ `VP response validation failed: "babe_sessions.${n}.decryptor_artifacts_hex" must be a non-empty hex string, got ${h(s.decryptor_artifacts_hex)}`
466
577
  );
467
578
  }
468
579
  }
469
- function Ke(r) {
580
+ function Je(r) {
470
581
  if (r === null || typeof r != "object")
471
- throw new a(
582
+ throw new o(
472
583
  "VP response validation failed: pegout status payload is not an object"
473
584
  );
474
585
  const e = r;
475
- if (!T(e.pegin_txid) || e.pegin_txid.length !== O)
476
- throw new a(
477
- `VP response validation failed: "pegin_txid" must be a ${O}-char hex string (txid), got ${p(e.pegin_txid)}`
586
+ if (!T(e.pegin_txid) || e.pegin_txid.length !== N)
587
+ throw new o(
588
+ `VP response validation failed: "pegin_txid" must be a ${N}-char hex string (txid), got ${h(e.pegin_txid)}`
478
589
  );
479
590
  if (typeof e.found != "boolean")
480
- throw new a(
481
- `VP response validation failed: "found" must be a boolean, got ${p(e.found)}`
591
+ throw new o(
592
+ `VP response validation failed: "found" must be a boolean, got ${h(e.found)}`
482
593
  );
483
594
  if (e.claimer !== null) {
484
595
  if (typeof e.claimer != "object")
485
- throw new a(
486
- `VP response validation failed: "claimer" must be an object or null, got ${p(e.claimer)}`
596
+ throw new o(
597
+ `VP response validation failed: "claimer" must be an object or null, got ${h(e.claimer)}`
487
598
  );
488
- Je(e.claimer);
599
+ We(e.claimer);
489
600
  }
490
601
  if (!Array.isArray(e.challengers))
491
- throw new a(
492
- `VP response validation failed: "challengers" must be an array, got ${p(e.challengers)}`
602
+ throw new o(
603
+ `VP response validation failed: "challengers" must be an array, got ${h(e.challengers)}`
493
604
  );
494
605
  for (let t = 0; t < e.challengers.length; t++)
495
- qe(e.challengers[t], t);
606
+ Ye(e.challengers[t], t);
496
607
  }
497
- function Je(r) {
608
+ function We(r) {
498
609
  if (w(r.status, "claimer.status"), typeof r.failed != "boolean")
499
- throw new a(
500
- `VP response validation failed: "claimer.failed" must be a boolean, got ${p(r.failed)}`
610
+ throw new o(
611
+ `VP response validation failed: "claimer.failed" must be a boolean, got ${h(r.failed)}`
501
612
  );
502
613
  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")
503
- throw new a(
504
- `VP response validation failed: "claimer.created_at" must be a number, got ${p(r.created_at)}`
614
+ throw new o(
615
+ `VP response validation failed: "claimer.created_at" must be a number, got ${h(r.created_at)}`
505
616
  );
506
617
  if (typeof r.updated_at != "number")
507
- throw new a(
508
- `VP response validation failed: "claimer.updated_at" must be a number, got ${p(r.updated_at)}`
618
+ throw new o(
619
+ `VP response validation failed: "claimer.updated_at" must be a number, got ${h(r.updated_at)}`
509
620
  );
510
621
  }
511
- function qe(r, e) {
622
+ function Ye(r, e) {
512
623
  if (r === null || typeof r != "object")
513
- throw new a(
514
- `VP response validation failed: "challengers[${e}]" must be an object, got ${p(r)}`
624
+ throw new o(
625
+ `VP response validation failed: "challengers[${e}]" must be an object, got ${h(r)}`
515
626
  );
516
627
  const t = r;
517
- if (w(t.status, `challengers[${e}].status`), w(t.claim_txid, `challengers[${e}].claim_txid`), w(t.claimer_pubkey, `challengers[${e}].claimer_pubkey`), B(t.assert_txid, `challengers[${e}].assert_txid`), B(
628
+ 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(
518
629
  t.challenge_assert_x_txid,
519
630
  `challengers[${e}].challenge_assert_x_txid`
520
- ), B(
631
+ ), D(
521
632
  t.challenge_assert_y_txid,
522
633
  `challengers[${e}].challenge_assert_y_txid`
523
- ), B(t.nopayout_txid, `challengers[${e}].nopayout_txid`), typeof t.created_at != "number")
524
- throw new a(
525
- `VP response validation failed: "challengers[${e}].created_at" must be a number, got ${p(t.created_at)}`
634
+ ), D(t.nopayout_txid, `challengers[${e}].nopayout_txid`), typeof t.created_at != "number")
635
+ throw new o(
636
+ `VP response validation failed: "challengers[${e}].created_at" must be a number, got ${h(t.created_at)}`
526
637
  );
527
638
  if (typeof t.updated_at != "number")
528
- throw new a(
529
- `VP response validation failed: "challengers[${e}].updated_at" must be a number, got ${p(t.updated_at)}`
639
+ throw new o(
640
+ `VP response validation failed: "challengers[${e}].updated_at" must be a number, got ${h(t.updated_at)}`
530
641
  );
531
642
  }
532
- function B(r, e) {
643
+ function D(r, e) {
533
644
  if (r !== null && typeof r != "string")
534
- throw new a(
535
- `VP response validation failed: "${e}" must be a string or null, got ${p(r)}`
645
+ throw new o(
646
+ `VP response validation failed: "${e}" must be a string or null, got ${h(r)}`
536
647
  );
537
648
  }
538
- function We(r) {
649
+ function ze(r) {
539
650
  be(r, "batchGetPeginStatus", (e) => {
540
651
  e.result !== null && ye(e.result);
541
652
  });
542
653
  }
543
- function Ye(r) {
654
+ function qe(r) {
544
655
  be(r, "batchGetPegoutStatus", (e) => {
545
- e.result !== null && Ke(e.result);
656
+ e.result !== null && Je(e.result);
546
657
  });
547
658
  }
548
659
  function be(r, e, t) {
549
660
  if (r === null || typeof r != "object")
550
- throw new a(
661
+ throw new o(
551
662
  `VP response validation failed: ${e} response is not an object`
552
663
  );
553
664
  const n = r;
554
665
  if (!Array.isArray(n.results))
555
- throw new a(
556
- `VP response validation failed: "${e}.results" must be an array, got ${p(n.results)}`
666
+ throw new o(
667
+ `VP response validation failed: "${e}.results" must be an array, got ${h(n.results)}`
557
668
  );
558
669
  for (let i = 0; i < n.results.length; i++) {
559
670
  const s = n.results[i];
560
671
  if (s === null || typeof s != "object")
561
- throw new a(
562
- `VP response validation failed: "${e}.results[${i}]" must be an object, got ${p(s)}`
672
+ throw new o(
673
+ `VP response validation failed: "${e}.results[${i}]" must be an object, got ${h(s)}`
563
674
  );
564
- const o = s;
565
- if (!T(o.pegin_txid) || o.pegin_txid.length !== O)
566
- throw new a(
567
- `VP response validation failed: "${e}.results[${i}].pegin_txid" must be a ${O}-char hex string, got ${p(o.pegin_txid)}`
675
+ const a = s;
676
+ if (!T(a.pegin_txid) || a.pegin_txid.length !== N)
677
+ throw new o(
678
+ `VP response validation failed: "${e}.results[${i}].pegin_txid" must be a ${N}-char hex string, got ${h(a.pegin_txid)}`
568
679
  );
569
- if (o.error !== null && typeof o.error != "string")
570
- throw new a(
571
- `VP response validation failed: "${e}.results[${i}].error" must be a string or null, got ${p(o.error)}`
680
+ if (a.error !== null && typeof a.error != "string")
681
+ throw new o(
682
+ `VP response validation failed: "${e}.results[${i}].error" must be a string or null, got ${h(a.error)}`
572
683
  );
573
- if (o.result === null && o.error === null)
574
- throw new a(
684
+ if (a.result === null && a.error === null)
685
+ throw new o(
575
686
  `VP response validation failed: "${e}.results[${i}]" has neither "result" nor "error" populated`
576
687
  );
577
- if (o.result !== null && o.error !== null)
578
- throw new a(
688
+ if (a.result !== null && a.error !== null)
689
+ throw new o(
579
690
  `VP response validation failed: "${e}.results[${i}]" has both "result" and "error" populated`
580
691
  );
581
- t(o, i);
692
+ t(a, i);
582
693
  }
583
694
  }
584
- function ze(r) {
695
+ function Ze(r) {
585
696
  if (A(r.claim_tx, "depositor_graph.claim_tx"), A(r.assert_tx, "depositor_graph.assert_tx"), A(r.payout_tx, "depositor_graph.payout_tx"), w(r.payout_psbt, "depositor_graph.payout_psbt"), !Array.isArray(r.challenger_presign_data))
586
- throw new a(
697
+ throw new o(
587
698
  'VP response validation failed: "depositor_graph.challenger_presign_data" must be an array'
588
699
  );
589
700
  for (let e = 0; e < r.challenger_presign_data.length; e++)
@@ -592,17 +703,17 @@ function ze(r) {
592
703
  `depositor_graph.challenger_presign_data[${e}]`
593
704
  );
594
705
  if (typeof r.offchain_params_version != "number")
595
- throw new a(
706
+ throw new o(
596
707
  'VP response validation failed: "depositor_graph.offchain_params_version" must be a number'
597
708
  );
598
709
  }
599
- const Ze = 6e4;
600
- class Qe {
710
+ const Qe = 6e4;
711
+ class et {
601
712
  constructor(e, t) {
602
713
  f(this, "client");
603
714
  const n = {
604
715
  baseUrl: e,
605
- timeout: (t == null ? void 0 : t.timeout) ?? Ze,
716
+ timeout: (t == null ? void 0 : t.timeout) ?? Qe,
606
717
  retries: t == null ? void 0 : t.retries,
607
718
  retryDelay: t == null ? void 0 : t.retryDelay,
608
719
  retryableFor: t == null ? void 0 : t.retryableFor,
@@ -618,7 +729,7 @@ class Qe {
618
729
  */
619
730
  async requestDepositorPresignTransactions(e, t) {
620
731
  const n = await this.client.call("vaultProvider_requestDepositorPresignTransactions", e, t);
621
- return He(n), n;
732
+ return Le(n), n;
622
733
  }
623
734
  /**
624
735
  * Submit the depositor's pre-signatures for the payout transactions
@@ -667,7 +778,7 @@ class Qe {
667
778
  */
668
779
  async batchGetPeginStatus(e, t) {
669
780
  const n = await this.client.call("vaultProvider_batchGetPeginStatus", e, t);
670
- return We(n), n;
781
+ return ze(n), n;
671
782
  }
672
783
  /**
673
784
  * Get pegout status for many txids in one round trip. Same per-result
@@ -675,18 +786,18 @@ class Qe {
675
786
  */
676
787
  async batchGetPegoutStatus(e, t) {
677
788
  const n = await this.client.call("vaultProvider_batchGetPegoutStatus", e, t);
678
- return Ye(n), n;
789
+ return qe(n), n;
679
790
  }
680
791
  }
681
- function et(r, e) {
792
+ function tt(r, e) {
682
793
  const t = /* @__PURE__ */ new Set();
683
794
  for (const d of r)
684
795
  t.add(d.toLowerCase());
685
- const n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), s = [], o = [];
796
+ const n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), s = [], a = [];
686
797
  for (const d of e) {
687
798
  const l = d.pegin_txid.toLowerCase();
688
799
  if (!t.has(l)) {
689
- o.push(l);
800
+ a.push(l);
690
801
  continue;
691
802
  }
692
803
  if (i.has(l)) {
@@ -698,16 +809,16 @@ function et(r, e) {
698
809
  const c = [];
699
810
  for (const d of t)
700
811
  i.has(d) || c.push(d);
701
- return { byTxid: n, missing: c, unexpected: o, duplicate: s };
812
+ return { byTxid: n, missing: c, unexpected: a, duplicate: s };
702
813
  }
703
- async function ur(r) {
814
+ async function pr(r) {
704
815
  const {
705
816
  items: e,
706
817
  getTxid: t,
707
818
  batchCall: n,
708
819
  onItem: i,
709
820
  onMissing: s,
710
- onDuplicate: o,
821
+ onDuplicate: a,
711
822
  onDuplicateBatch: c,
712
823
  onWholeBatchError: d,
713
824
  onUnexpected: l,
@@ -718,15 +829,15 @@ async function ur(r) {
718
829
  `batchPollByProvider: batchSize must be a positive integer, got ${g}`
719
830
  );
720
831
  for (let m = 0; m < e.length; m += g) {
721
- const x = e.slice(m, m + g), k = /* @__PURE__ */ new Map(), C = [];
832
+ const x = e.slice(m, m + g), E = /* @__PURE__ */ new Map(), C = [];
722
833
  for (const _ of x) {
723
834
  const u = t(_).toLowerCase();
724
- k.set(u, _), C.push(u);
835
+ E.set(u, _), C.push(u);
725
836
  }
726
837
  let P;
727
838
  try {
728
839
  const _ = await n(C);
729
- P = et(C, _.results);
840
+ P = tt(C, _.results);
730
841
  } catch (_) {
731
842
  d(x, _);
732
843
  continue;
@@ -734,18 +845,18 @@ async function ur(r) {
734
845
  l && P.unexpected.length > 0 && l(P.unexpected);
735
846
  const $ = new Set(P.duplicate);
736
847
  for (const _ of $) {
737
- const u = k.get(_);
738
- u && o(u);
848
+ const u = E.get(_);
849
+ u && a(u);
739
850
  }
740
851
  c && $.size > 0 && c($.size);
741
852
  for (const _ of P.missing) {
742
- const u = k.get(_);
853
+ const u = E.get(_);
743
854
  u && s(u);
744
855
  }
745
856
  for (const [_, u] of P.byTxid) {
746
857
  if ($.has(_)) continue;
747
- const E = k.get(_);
748
- E && i(E, {
858
+ const S = E.get(_);
859
+ S && i(S, {
749
860
  pegin_txid: _,
750
861
  result: u.result,
751
862
  error: u.error
@@ -753,24 +864,24 @@ async function ur(r) {
753
864
  }
754
865
  }
755
866
  }
756
- const tt = "BIP0322-signed-message", rt = "TapTweak", we = 32, nt = 64;
867
+ const rt = "BIP0322-signed-message", nt = "TapTweak", we = 32, st = 64;
757
868
  function xe(r, e) {
758
- const t = new TextEncoder().encode(r), n = q(t), i = new Uint8Array(n.length * 2 + e.length);
759
- return i.set(n, 0), i.set(n, n.length), i.set(e, n.length * 2), q(i);
869
+ const t = new TextEncoder().encode(r), n = Y(t), i = new Uint8Array(n.length * 2 + e.length);
870
+ return i.set(n, 0), i.set(n, n.length), i.set(e, n.length * 2), Y(i);
760
871
  }
761
- function st(r) {
872
+ function it(r) {
762
873
  if (r.length !== we) return null;
763
- const e = xe(rt, r), t = H.xOnlyPointAddTweak(r, e);
874
+ const e = xe(nt, r), t = U.xOnlyPointAddTweak(r, e);
764
875
  return t ? t.xOnlyPubkey : null;
765
876
  }
766
- function it(r, e, t) {
767
- if (e.length !== we || t.length !== nt) return !1;
877
+ function at(r, e, t) {
878
+ if (e.length !== we || t.length !== st) return !1;
768
879
  try {
769
- const n = xe(tt, r), i = Be.p2tr({
880
+ const n = xe(rt, r), i = Be.p2tr({
770
881
  internalPubkey: V.from(e)
771
882
  });
772
883
  if (!i.output) return !1;
773
- const s = i.output, o = 0, c = new X();
884
+ const s = i.output, a = 0, c = new X();
774
885
  c.version = 0, c.locktime = 0;
775
886
  const d = V.concat([
776
887
  V.from([0, 32]),
@@ -784,23 +895,23 @@ function it(r, e, t) {
784
895
  0,
785
896
  // sequence = 0
786
897
  d
787
- ), c.addOutput(s, o);
898
+ ), c.addOutput(s, a);
788
899
  const l = new X();
789
900
  l.version = 0, l.locktime = 0;
790
901
  const g = c.getHash();
791
- l.addInput(g, 0, 0), l.addOutput(V.from([106]), o);
902
+ l.addInput(g, 0, 0), l.addOutput(V.from([106]), a);
792
903
  const m = l.hashForWitnessV1(
793
904
  0,
794
905
  [s],
795
- [o],
906
+ [a],
796
907
  X.SIGHASH_DEFAULT
797
- ), x = st(e);
798
- return x ? H.verifySchnorr(m, x, t) : !1;
908
+ ), x = it(e);
909
+ return x ? U.verifySchnorr(m, x, t) : !1;
799
910
  } catch {
800
911
  return !1;
801
912
  }
802
913
  }
803
- function j(r, e) {
914
+ function L(r, e) {
804
915
  const t = (r & 7) << 5, n = typeof e == "bigint" ? e : BigInt(e);
805
916
  if (n < 0n) throw new Error("cborHead: negative argument");
806
917
  if (n < 24n) return new Uint8Array([t | Number(n)]);
@@ -833,9 +944,9 @@ function Pe(...r) {
833
944
  return t;
834
945
  }
835
946
  function ie(r) {
836
- const t = [j(4, r.length)];
947
+ const t = [L(4, r.length)];
837
948
  for (const n of r)
838
- t.push(j(0, n));
949
+ t.push(L(0, n));
839
950
  return Pe(...t);
840
951
  }
841
952
  function ot(r, e, t) {
@@ -843,117 +954,117 @@ function ot(r, e, t) {
843
954
  throw new Error(
844
955
  `encodeServerIdentityPayload: expires_at must be a non-negative safe integer, got ${t}`
845
956
  );
846
- const n = j(4, 3), i = ie(r), s = ie(e), o = j(0, t);
847
- return Pe(n, i, s, o);
957
+ const n = L(4, 3), i = ie(r), s = ie(e), a = L(0, t);
958
+ return Pe(n, i, s, a);
848
959
  }
849
- const at = new TextEncoder().encode(
960
+ const ct = new TextEncoder().encode(
850
961
  "btc-auth.server-identity.v1"
851
- ), ct = 2 * 3600;
852
- class y extends Error {
962
+ ), lt = 2 * 3600;
963
+ class b extends Error {
853
964
  constructor(e, t) {
854
965
  super(e), this.reason = t, this.name = "ServerIdentityError";
855
966
  }
856
967
  }
857
- function D(r) {
968
+ function M(r) {
858
969
  const e = new Uint8Array(r.length / 2);
859
970
  for (let t = 0; t < e.length; t++)
860
971
  e[t] = parseInt(r.slice(t * 2, t * 2 + 2), 16);
861
972
  return e;
862
973
  }
863
- function lt(r) {
864
- const { proof: e, pinnedServerPubkey: t, now: n } = r, i = r.maxLifetimeSecs ?? ct, s = I(t).toLowerCase();
865
- if (s.length !== R || !S.test(s))
866
- throw new y(
974
+ function ut(r) {
975
+ const { proof: e, pinnedServerPubkey: t, now: n } = r, i = r.maxLifetimeSecs ?? lt, s = I(t).toLowerCase();
976
+ if (s.length !== O || !k.test(s))
977
+ throw new b(
867
978
  `pinnedServerPubkey must be 32-byte hex; got ${s.length} chars`,
868
979
  "invalid_pubkey_encoding"
869
980
  );
870
- const o = I(e.server_pubkey).toLowerCase();
871
- if (o.length !== R || !S.test(o))
872
- throw new y(
873
- `server_pubkey must be 32-byte hex; got ${o.length} chars`,
981
+ const a = I(e.server_pubkey).toLowerCase();
982
+ if (a.length !== O || !k.test(a))
983
+ throw new b(
984
+ `server_pubkey must be 32-byte hex; got ${a.length} chars`,
874
985
  "invalid_pubkey_encoding"
875
986
  );
876
- if (o !== s)
877
- throw new y(
878
- `server_pubkey does not match pinned value: expected ${s}, got ${o}`,
987
+ if (a !== s)
988
+ throw new b(
989
+ `server_pubkey does not match pinned value: expected ${s}, got ${a}`,
879
990
  "pinned_pubkey_mismatch"
880
991
  );
881
992
  if (!Number.isSafeInteger(e.expires_at))
882
- throw new y(
993
+ throw new b(
883
994
  `expires_at must be a finite integer; got ${JSON.stringify(e.expires_at)}`,
884
995
  "invalid_expires_at"
885
996
  );
886
997
  if (!Number.isSafeInteger(n))
887
- throw new y(
998
+ throw new b(
888
999
  `now must be a finite integer; got ${JSON.stringify(n)}`,
889
1000
  "invalid_expires_at"
890
1001
  );
891
1002
  if (e.expires_at <= n)
892
- throw new y(
1003
+ throw new b(
893
1004
  `server identity proof expired at ${e.expires_at}, now ${n}`,
894
1005
  "expired"
895
1006
  );
896
1007
  if (!Number.isSafeInteger(i) || i <= 0)
897
- throw new y(
1008
+ throw new b(
898
1009
  `maxLifetimeSecs must be a positive safe integer; got ${JSON.stringify(i)}`,
899
1010
  "invalid_max_lifetime"
900
1011
  );
901
1012
  if (e.expires_at - n > i)
902
- throw new y(
1013
+ throw new b(
903
1014
  `server identity proof expires too far in the future: expires_at=${e.expires_at}, now=${n}, max lifetime=${i}s`,
904
1015
  "expires_too_far"
905
1016
  );
906
1017
  const c = I(e.ephemeral_pubkey).toLowerCase();
907
- if (c.length !== G || !S.test(c))
908
- throw new y(
1018
+ if (c.length !== j || !k.test(c))
1019
+ throw new b(
909
1020
  `ephemeral_pubkey must be 33-byte compressed hex; got ${c.length} chars`,
910
1021
  "invalid_ephemeral_pubkey"
911
1022
  );
912
1023
  const d = c.slice(0, 2);
913
1024
  if (d !== "02" && d !== "03")
914
- throw new y(
1025
+ throw new b(
915
1026
  `ephemeral_pubkey must be compressed (prefix 02/03); got ${d}`,
916
1027
  "invalid_ephemeral_pubkey"
917
1028
  );
918
- const l = D(c);
919
- if (!H.isPoint(l))
920
- throw new y(
1029
+ const l = M(c);
1030
+ if (!U.isPoint(l))
1031
+ throw new b(
921
1032
  "ephemeral_pubkey is not a valid secp256k1 point",
922
1033
  "invalid_ephemeral_pubkey"
923
1034
  );
924
1035
  const g = I(e.signature).toLowerCase();
925
- if (g.length !== Oe || !S.test(g))
926
- throw new y(
1036
+ if (g.length !== Oe || !k.test(g))
1037
+ throw new b(
927
1038
  `signature must be 64-byte Schnorr hex; got ${g.length} chars`,
928
1039
  "invalid_signature_encoding"
929
1040
  );
930
1041
  const m = ot(
931
- at,
932
- D(c),
1042
+ ct,
1043
+ M(c),
933
1044
  e.expires_at
934
1045
  );
935
- if (!it(m, D(o), D(g)))
936
- throw new y(
1046
+ if (!at(m, M(a), M(g)))
1047
+ throw new b(
937
1048
  "BIP-322 signature verification failed — ephemeral key is not attested by pinned server pubkey",
938
1049
  "signature_verification_failed"
939
1050
  );
940
1051
  }
941
- const ut = /* @__PURE__ */ new Set([
1052
+ const dt = /* @__PURE__ */ new Set([
942
1053
  "vaultProvider_submitDepositorWotsKey",
943
1054
  "vaultProvider_submitDepositorPresignatures",
944
1055
  "vaultProvider_requestDepositorPresignTransactions"
945
- ]), dt = /* @__PURE__ */ new Set([
1056
+ ]), pt = /* @__PURE__ */ new Set([
946
1057
  "vaultProvider_requestDepositorClaimerArtifacts"
947
- ]), ht = 6e4, W = "auth_createDepositorToken", Y = "auth_createDepositorTokenGrpc";
1058
+ ]), ht = 6e4, z = "auth_createDepositorToken", q = "auth_createDepositorTokenGrpc";
948
1059
  function ve(r, e) {
949
1060
  return new ge({
950
1061
  baseUrl: r,
951
1062
  timeout: ht,
952
1063
  headers: e,
953
- retryableFor: (t) => t === W || t === Y
1064
+ retryableFor: (t) => t === z || t === q
954
1065
  });
955
1066
  }
956
- const pt = 0, gt = 1, F = 2, ft = 3, _t = 4, mt = 5, yt = 6, bt = 7, oe = 24, wt = 28, xt = 20, Pt = 21, vt = 22, ae = 256;
1067
+ const gt = 0, ft = 1, F = 2, _t = 3, mt = 4, yt = 5, bt = 6, wt = 7, ae = 24, xt = 28, Pt = 20, vt = 21, At = 22, oe = 256;
957
1068
  class v extends Error {
958
1069
  constructor(e) {
959
1070
  super(`CBOR decode: ${e}`), this.name = "CborDecodeError";
@@ -979,15 +1090,15 @@ class Ae {
979
1090
  */
980
1091
  readHead() {
981
1092
  const e = this.nextByte(), t = e >> 5, n = e & 31;
982
- if (n < oe)
1093
+ if (n < ae)
983
1094
  return { major: t, arg: n };
984
- if (n >= wt)
1095
+ if (n >= xt)
985
1096
  throw new v(
986
1097
  `unsupported additional info ${n} (indefinite-length or reserved)`
987
1098
  );
988
- const i = 1 << n - oe;
1099
+ const i = 1 << n - ae;
989
1100
  let s = 0n;
990
- for (let o = 0; o < i; o++)
1101
+ for (let a = 0; a < i; a++)
991
1102
  s = s << 8n | BigInt(this.nextByte());
992
1103
  if (s > BigInt(Number.MAX_SAFE_INTEGER))
993
1104
  throw new v(`argument ${s} exceeds safe integer range`);
@@ -1020,42 +1131,42 @@ class Ae {
1020
1131
  * native call stack (see {@link MAX_NESTING_DEPTH}).
1021
1132
  */
1022
1133
  readValue(e = 0) {
1023
- if (e > ae)
1134
+ if (e > oe)
1024
1135
  throw new v(
1025
- `nesting exceeds maximum depth ${ae}`
1136
+ `nesting exceeds maximum depth ${oe}`
1026
1137
  );
1027
1138
  const t = this.readHead();
1028
1139
  switch (t.major) {
1029
- case pt:
1030
- return t.arg;
1031
1140
  case gt:
1141
+ return t.arg;
1142
+ case ft:
1032
1143
  return -1 - t.arg;
1033
1144
  case F:
1034
1145
  return this.readBytes(t.arg);
1035
- case ft:
1146
+ case _t:
1036
1147
  return new TextDecoder("utf-8", { fatal: !0 }).decode(
1037
1148
  this.readBytes(t.arg)
1038
1149
  );
1039
- case _t: {
1150
+ case mt: {
1040
1151
  const n = [];
1041
1152
  for (let i = 0; i < t.arg; i++)
1042
1153
  n.push(this.readValue(e + 1));
1043
1154
  return n;
1044
1155
  }
1045
- case mt: {
1156
+ case yt: {
1046
1157
  const n = /* @__PURE__ */ new Map();
1047
1158
  for (let i = 0; i < t.arg; i++) {
1048
- const s = this.readValue(e + 1), o = this.readValue(e + 1);
1049
- n.set(s, o);
1159
+ const s = this.readValue(e + 1), a = this.readValue(e + 1);
1160
+ n.set(s, a);
1050
1161
  }
1051
1162
  return n;
1052
1163
  }
1053
- case yt:
1054
- return { tag: t.arg, value: this.readValue(e + 1) };
1055
1164
  case bt:
1056
- if (t.arg === xt) return !1;
1057
- if (t.arg === Pt) return !0;
1058
- if (t.arg === vt) return null;
1165
+ return { tag: t.arg, value: this.readValue(e + 1) };
1166
+ case wt:
1167
+ if (t.arg === Pt) return !1;
1168
+ if (t.arg === vt) return !0;
1169
+ if (t.arg === At) return null;
1059
1170
  throw new v(
1060
1171
  `unsupported simple/float value ${t.arg}`
1061
1172
  );
@@ -1064,206 +1175,206 @@ class Ae {
1064
1175
  }
1065
1176
  }
1066
1177
  }
1067
- function ke(r) {
1178
+ function Ee(r) {
1068
1179
  const e = new Ae(r), t = e.readValue();
1069
1180
  if (e.pos !== r.length)
1070
1181
  throw new v("trailing bytes after top-level item");
1071
1182
  return t;
1072
1183
  }
1073
- const At = "vaultd-jsonrpc", kt = "vaultd-grpc", ce = 18, z = 4, le = -47, Et = 1, ue = 64, St = 128, Ct = 96, Tt = 64, $t = 1, Vt = 2, It = 3, Rt = 4, Ot = 5, Nt = 6, Bt = 7, de = new TextEncoder().encode("Signature1");
1074
- class h extends Error {
1184
+ const Et = "vaultd-jsonrpc", St = "vaultd-grpc", ce = 18, Z = 4, le = -47, kt = 1, ue = 64, Ct = 128, Tt = 96, $t = 64, Vt = 1, It = 2, Rt = 3, Ot = 4, Nt = 5, Bt = 6, Gt = 7, de = new TextEncoder().encode("Signature1");
1185
+ class p extends Error {
1075
1186
  constructor(e, t) {
1076
1187
  super(e), this.reason = t, this.name = "CwtVerificationError";
1077
1188
  }
1078
1189
  }
1079
1190
  function Dt(r) {
1080
- const e = he(
1191
+ const e = pe(
1081
1192
  r.expectedIssuerXOnlyPubkey,
1082
1193
  "expectedIssuerXOnlyPubkey"
1083
- ), t = he(
1194
+ ), t = pe(
1084
1195
  r.expectedAudienceXOnlyPubkey,
1085
1196
  "expectedAudienceXOnlyPubkey"
1086
- ), n = Lt(r.ephemeralPubkeyHex), i = Xt(r.token), s = new Ae(i), o = s.readHead();
1087
- if (o.major !== 6 || o.arg !== ce)
1088
- throw new h(
1197
+ ), n = Ut(r.ephemeralPubkeyHex), i = Xt(r.token), s = new Ae(i), a = s.readHead();
1198
+ if (a.major !== 6 || a.arg !== ce)
1199
+ throw new p(
1089
1200
  `token is not a COSE Sign1 tagged value (tag ${ce})`,
1090
1201
  "invalid_token_structure"
1091
1202
  );
1092
1203
  const c = s.readHead();
1093
- if (c.major !== 4 || c.arg !== z)
1094
- throw new h(
1095
- `COSE Sign1 must be a ${z}-element array`,
1204
+ if (c.major !== 4 || c.arg !== Z)
1205
+ throw new p(
1206
+ `COSE Sign1 must be a ${Z}-element array`,
1096
1207
  "invalid_token_structure"
1097
1208
  );
1098
1209
  const d = s.pos, l = s.readByteString(), g = i.subarray(d, s.pos);
1099
1210
  s.readValue();
1100
- const m = s.pos, x = s.readByteString(), k = i.subarray(m, s.pos), C = s.readByteString();
1211
+ const m = s.pos, x = s.readByteString(), E = i.subarray(m, s.pos), C = s.readByteString();
1101
1212
  if (C.length !== ue)
1102
- throw new h(
1213
+ throw new p(
1103
1214
  `COSE signature must be ${ue} bytes, got ${C.length}`,
1104
1215
  "invalid_token_structure"
1105
1216
  );
1106
1217
  if (s.pos !== i.length)
1107
- throw new h(
1218
+ throw new p(
1108
1219
  "COSE Sign1 token has trailing bytes after the signature",
1109
1220
  "invalid_token_structure"
1110
1221
  );
1111
- const P = Gt(l);
1222
+ const P = Mt(l);
1112
1223
  if (P !== le)
1113
- throw new h(
1224
+ throw new p(
1114
1225
  `unexpected COSE algorithm ${P} (expected ES256K ${le})`,
1115
1226
  "unexpected_algorithm"
1116
1227
  );
1117
- const $ = Mt(g, k), _ = q($);
1118
- if (!H.verify(_, n, C, !0))
1119
- throw new h(
1228
+ const $ = jt(g, E), _ = Y($);
1229
+ if (!U.verify(_, n, C, !0))
1230
+ throw new p(
1120
1231
  "COSE signature does not verify against the server's ephemeral key",
1121
1232
  "signature_verification_failed"
1122
1233
  );
1123
- const u = jt(x), E = u.audience.toLowerCase();
1124
- if (E.length !== R || !S.test(E))
1125
- throw new h(
1234
+ const u = Ht(x), S = u.audience.toLowerCase();
1235
+ if (S.length !== O || !k.test(S))
1236
+ throw new p(
1126
1237
  "token `aud` is not a 32-byte x-only pubkey hex",
1127
1238
  "invalid_claims"
1128
1239
  );
1129
1240
  if (u.issuedAt > u.expiresAt)
1130
- throw new h(
1241
+ throw new p(
1131
1242
  `token iat (${u.issuedAt}) is after exp (${u.expiresAt})`,
1132
1243
  "invalid_claims"
1133
1244
  );
1134
1245
  if (u.issuer.toLowerCase() !== e)
1135
- throw new h(
1246
+ throw new p(
1136
1247
  `token issuer does not match pinned server pubkey: expected ${e}, got ${u.issuer.toLowerCase()}`,
1137
1248
  "issuer_mismatch"
1138
1249
  );
1139
1250
  if (u.subject !== r.expectedSubject)
1140
- throw new h(
1251
+ throw new p(
1141
1252
  `token subject mismatch: expected ${r.expectedSubject}, got ${u.subject}`,
1142
1253
  "subject_mismatch"
1143
1254
  );
1144
- if (E !== t)
1145
- throw new h(
1146
- `token audience does not match depositor pubkey: expected ${t}, got ${E}`,
1255
+ if (S !== t)
1256
+ throw new p(
1257
+ `token audience does not match depositor pubkey: expected ${t}, got ${S}`,
1147
1258
  "audience_mismatch"
1148
1259
  );
1149
1260
  if (u.expiresAt <= r.now)
1150
- throw new h(
1261
+ throw new p(
1151
1262
  `token expired: exp ${u.expiresAt} <= now ${r.now}`,
1152
1263
  "token_expired"
1153
1264
  );
1154
1265
  if (r.responseExpiresAt !== u.expiresAt)
1155
- throw new h(
1266
+ throw new p(
1156
1267
  `response expires_at (${r.responseExpiresAt}) does not equal token exp (${u.expiresAt})`,
1157
1268
  "expiry_mismatch"
1158
1269
  );
1159
1270
  if (r.serverIdentityExpiresAt < u.expiresAt)
1160
- throw new h(
1271
+ throw new p(
1161
1272
  `server identity expires (${r.serverIdentityExpiresAt}) before token exp (${u.expiresAt})`,
1162
1273
  "server_identity_expires_before_token"
1163
1274
  );
1164
1275
  return {
1165
1276
  issuer: u.issuer,
1166
1277
  subject: u.subject,
1167
- audience: E,
1278
+ audience: S,
1168
1279
  expiresAt: u.expiresAt,
1169
1280
  notBefore: u.notBefore,
1170
1281
  issuedAt: u.issuedAt
1171
1282
  };
1172
1283
  }
1173
- function Gt(r) {
1284
+ function Mt(r) {
1174
1285
  if (r.length === 0)
1175
- throw new h(
1286
+ throw new p(
1176
1287
  "empty COSE protected header (no algorithm)",
1177
1288
  "unexpected_algorithm"
1178
1289
  );
1179
- const e = ke(r);
1290
+ const e = Ee(r);
1180
1291
  if (!(e instanceof Map))
1181
- throw new h(
1292
+ throw new p(
1182
1293
  "COSE protected header is not a map",
1183
1294
  "invalid_token_structure"
1184
1295
  );
1185
- const t = e.get(Et);
1296
+ const t = e.get(kt);
1186
1297
  if (typeof t != "number")
1187
- throw new h(
1298
+ throw new p(
1188
1299
  "COSE protected header missing integer algorithm label",
1189
1300
  "unexpected_algorithm"
1190
1301
  );
1191
1302
  return t;
1192
1303
  }
1193
- function Mt(r, e) {
1304
+ function jt(r, e) {
1194
1305
  return Ft(
1195
- Uint8Array.of(St | z),
1196
- Uint8Array.of(Ct | de.length),
1306
+ Uint8Array.of(Ct | Z),
1307
+ Uint8Array.of(Tt | de.length),
1197
1308
  de,
1198
1309
  r,
1199
- Uint8Array.of(Tt),
1310
+ Uint8Array.of($t),
1200
1311
  e
1201
1312
  );
1202
1313
  }
1203
- function jt(r) {
1204
- const e = ke(r);
1314
+ function Ht(r) {
1315
+ const e = Ee(r);
1205
1316
  if (!(e instanceof Map))
1206
- throw new h(
1317
+ throw new p(
1207
1318
  "CWT claims root is not a map",
1208
1319
  "invalid_claims"
1209
1320
  );
1210
- if (Ht(e, Bt, "cti").length === 0)
1211
- throw new h("token cti is empty", "invalid_claims");
1321
+ if (Lt(e, Gt, "cti").length === 0)
1322
+ throw new p("token cti is empty", "invalid_claims");
1212
1323
  return {
1213
- issuer: K(e, $t, "iss"),
1214
- subject: K(e, Vt, "sub"),
1215
- audience: K(e, It, "aud"),
1216
- expiresAt: J(e, Rt, "exp"),
1217
- notBefore: J(e, Ot, "nbf"),
1218
- issuedAt: J(e, Nt, "iat")
1324
+ issuer: J(e, Vt, "iss"),
1325
+ subject: J(e, It, "sub"),
1326
+ audience: J(e, Rt, "aud"),
1327
+ expiresAt: W(e, Ot, "exp"),
1328
+ notBefore: W(e, Nt, "nbf"),
1329
+ issuedAt: W(e, Bt, "iat")
1219
1330
  };
1220
1331
  }
1221
- function K(r, e, t) {
1332
+ function J(r, e, t) {
1222
1333
  const n = r.get(e);
1223
1334
  if (typeof n != "string")
1224
- throw new h(
1335
+ throw new p(
1225
1336
  `token claim ${t} is missing or not a text string`,
1226
1337
  "invalid_claims"
1227
1338
  );
1228
1339
  return n;
1229
1340
  }
1230
- function Ht(r, e, t) {
1341
+ function Lt(r, e, t) {
1231
1342
  const n = r.get(e);
1232
1343
  if (!(n instanceof Uint8Array))
1233
- throw new h(
1344
+ throw new p(
1234
1345
  `token claim ${t} is missing or not a byte string`,
1235
1346
  "invalid_claims"
1236
1347
  );
1237
1348
  return n;
1238
1349
  }
1239
- function J(r, e, t) {
1350
+ function W(r, e, t) {
1240
1351
  const n = r.get(e);
1241
1352
  if (typeof n != "number" || !Number.isSafeInteger(n) || n < 0)
1242
- throw new h(
1353
+ throw new p(
1243
1354
  `token claim ${t} is missing or not a non-negative integer timestamp`,
1244
1355
  "invalid_claims"
1245
1356
  );
1246
1357
  return n;
1247
1358
  }
1248
- function he(r, e) {
1359
+ function pe(r, e) {
1249
1360
  const t = I(r).toLowerCase();
1250
- if (t.length !== R || !S.test(t))
1251
- throw new h(
1361
+ if (t.length !== O || !k.test(t))
1362
+ throw new p(
1252
1363
  `${e} must be 32-byte x-only hex; got ${t.length} chars`,
1253
1364
  "invalid_input"
1254
1365
  );
1255
1366
  return t;
1256
1367
  }
1257
- function Lt(r) {
1368
+ function Ut(r) {
1258
1369
  const e = I(r).toLowerCase(), t = e.slice(0, 2);
1259
- if (e.length !== G || !S.test(e) || t !== "02" && t !== "03")
1260
- throw new h(
1370
+ if (e.length !== j || !k.test(e) || t !== "02" && t !== "03")
1371
+ throw new p(
1261
1372
  "ephemeralPubkeyHex must be 33-byte compressed pubkey hex (prefix 02/03)",
1262
1373
  "invalid_input"
1263
1374
  );
1264
1375
  return Ne(e);
1265
1376
  }
1266
- const Ut = (() => {
1377
+ const Kt = (() => {
1267
1378
  const r = new Int16Array(128).fill(-1), e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
1268
1379
  for (let t = 0; t < e.length; t++)
1269
1380
  r[e.charCodeAt(t)] = t;
@@ -1272,14 +1383,14 @@ const Ut = (() => {
1272
1383
  function Xt(r) {
1273
1384
  const e = r.length, t = Math.floor(e / 4), n = e % 4;
1274
1385
  if (n === 1)
1275
- throw new h(
1386
+ throw new p(
1276
1387
  "invalid base64url length",
1277
1388
  "invalid_token_structure"
1278
1389
  );
1279
- const i = t * 3 + (n === 0 ? 0 : n - 1), s = new Uint8Array(i), o = (l) => {
1280
- const g = l < 128 ? Ut[l] : -1;
1390
+ const i = t * 3 + (n === 0 ? 0 : n - 1), s = new Uint8Array(i), a = (l) => {
1391
+ const g = l < 128 ? Kt[l] : -1;
1281
1392
  if (g < 0)
1282
- throw new h(
1393
+ throw new p(
1283
1394
  "invalid base64url character",
1284
1395
  "invalid_token_structure"
1285
1396
  );
@@ -1287,14 +1398,14 @@ function Xt(r) {
1287
1398
  };
1288
1399
  let c = 0, d = 0;
1289
1400
  for (let l = 0; l < t; l++) {
1290
- const g = o(r.charCodeAt(c++)), m = o(r.charCodeAt(c++)), x = o(r.charCodeAt(c++)), k = o(r.charCodeAt(c++));
1291
- s[d++] = g << 2 | m >> 4, s[d++] = (m & 15) << 4 | x >> 2, s[d++] = (x & 3) << 6 | k;
1401
+ const g = a(r.charCodeAt(c++)), m = a(r.charCodeAt(c++)), x = a(r.charCodeAt(c++)), E = a(r.charCodeAt(c++));
1402
+ s[d++] = g << 2 | m >> 4, s[d++] = (m & 15) << 4 | x >> 2, s[d++] = (x & 3) << 6 | E;
1292
1403
  }
1293
1404
  if (n === 2) {
1294
- const l = o(r.charCodeAt(c++)), g = o(r.charCodeAt(c++));
1405
+ const l = a(r.charCodeAt(c++)), g = a(r.charCodeAt(c++));
1295
1406
  s[d++] = l << 2 | g >> 4;
1296
1407
  } else if (n === 3) {
1297
- const l = o(r.charCodeAt(c++)), g = o(r.charCodeAt(c++)), m = o(r.charCodeAt(c++));
1408
+ const l = a(r.charCodeAt(c++)), g = a(r.charCodeAt(c++)), m = a(r.charCodeAt(c++));
1298
1409
  s[d++] = l << 2 | g >> 4, s[d++] = (g & 15) << 4 | m >> 2;
1299
1410
  }
1300
1411
  return s;
@@ -1306,8 +1417,8 @@ function Ft(...r) {
1306
1417
  t.set(i, n), n += i.length;
1307
1418
  return t;
1308
1419
  }
1309
- const pe = 4102444800, Kt = 30;
1310
- class Jt {
1420
+ const he = 4102444800, Jt = 30;
1421
+ class Wt {
1311
1422
  constructor(e) {
1312
1423
  // `client` is the only mutable field — see `setClient`. The
1313
1424
  // identity-bearing fields (peginTxid/authAnchorHex/pinnedServerPubkey)
@@ -1328,7 +1439,7 @@ class Jt {
1328
1439
  /** Cached gRPC-subject bearer (auth_createDepositorTokenGrpc). */
1329
1440
  f(this, "cachedGrpc", null);
1330
1441
  f(this, "inFlightGrpc", null);
1331
- 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 ?? Kt, this.now = e.now ?? (() => Math.floor(Date.now() / 1e3));
1442
+ this.client = e.client, this.peginTxid = e.peginTxid, this.authAnchorHex = e.authAnchorHex, this.pinnedServerPubkey = e.pinnedServerPubkey, this.expectedAudienceXOnlyPubkey = e.expectedAudienceXOnlyPubkey, this.authGatedMethods = e.authGatedMethods, this.grpcGatedMethods = e.grpcGatedMethods, this.refreshSkewSecs = e.refreshSkewSecs ?? Jt, this.now = e.now ?? (() => Math.floor(Date.now() / 1e3));
1332
1443
  }
1333
1444
  /**
1334
1445
  * Return a bearer token for `method`, or `null` if `method` is not
@@ -1348,7 +1459,7 @@ class Jt {
1348
1459
  * deterministically.
1349
1460
  */
1350
1461
  async getToken(e) {
1351
- return e === W || e === Y ? null : this.grpcGatedMethods.has(e) ? this.getTokenForSubject("grpc") : this.authGatedMethods.has(e) ? this.getTokenForSubject("jsonrpc") : null;
1462
+ return e === z || e === q ? null : this.grpcGatedMethods.has(e) ? this.getTokenForSubject("grpc") : this.authGatedMethods.has(e) ? this.getTokenForSubject("jsonrpc") : null;
1352
1463
  }
1353
1464
  /**
1354
1465
  * Drop both cached tokens. Next `getToken` call re-acquires the slot
@@ -1381,13 +1492,13 @@ class Jt {
1381
1492
  acquireSingleFlight(e) {
1382
1493
  const t = e === "grpc" ? this.inFlightGrpc : this.inFlightJsonRpc;
1383
1494
  if (t) return t;
1384
- const n = e === "grpc" ? Y : W, i = (async () => {
1495
+ const n = e === "grpc" ? q : z, i = (async () => {
1385
1496
  try {
1386
1497
  const s = await this.client.call(n, {
1387
1498
  pegin_txid: this.peginTxid,
1388
1499
  auth_anchor: this.authAnchorHex
1389
1500
  });
1390
- if (lt({
1501
+ if (ut({
1391
1502
  proof: s.server_identity,
1392
1503
  pinnedServerPubkey: this.pinnedServerPubkey,
1393
1504
  now: this.now()
@@ -1395,20 +1506,20 @@ class Jt {
1395
1506
  throw new Error(
1396
1507
  `VpTokenProvider: invalid token in acquire response (expected non-empty string, got ${typeof s.token})`
1397
1508
  );
1398
- const o = this.now();
1399
- if (!Number.isSafeInteger(s.expires_at) || s.expires_at <= o || s.expires_at > pe)
1509
+ const a = this.now();
1510
+ if (!Number.isSafeInteger(s.expires_at) || s.expires_at <= a || s.expires_at > he)
1400
1511
  throw new Error(
1401
- `VpTokenProvider: invalid expires_at in acquire response (got ${JSON.stringify(s.expires_at)}; must be a safe integer in (${o}, ${pe}])`
1512
+ `VpTokenProvider: invalid expires_at in acquire response (got ${JSON.stringify(s.expires_at)}; must be a safe integer in (${a}, ${he}])`
1402
1513
  );
1403
1514
  Dt({
1404
1515
  token: s.token,
1405
1516
  ephemeralPubkeyHex: s.server_identity.ephemeral_pubkey,
1406
1517
  expectedIssuerXOnlyPubkey: this.pinnedServerPubkey,
1407
- expectedSubject: e === "grpc" ? kt : At,
1518
+ expectedSubject: e === "grpc" ? St : Et,
1408
1519
  expectedAudienceXOnlyPubkey: this.expectedAudienceXOnlyPubkey,
1409
1520
  responseExpiresAt: s.expires_at,
1410
1521
  serverIdentityExpiresAt: s.server_identity.expires_at,
1411
- now: o
1522
+ now: a
1412
1523
  });
1413
1524
  const c = {
1414
1525
  token: s.token,
@@ -1422,7 +1533,7 @@ class Jt {
1422
1533
  return e === "grpc" ? this.inFlightGrpc = i : this.inFlightJsonRpc = i, i;
1423
1534
  }
1424
1535
  }
1425
- class qt {
1536
+ class Yt {
1426
1537
  constructor() {
1427
1538
  f(this, "entries", /* @__PURE__ */ new Map());
1428
1539
  }
@@ -1449,14 +1560,14 @@ class qt {
1449
1560
  );
1450
1561
  return t.provider.setClient(e.client), t.provider;
1451
1562
  }
1452
- const n = new Jt({
1563
+ const n = new Wt({
1453
1564
  client: e.client,
1454
1565
  peginTxid: e.peginTxid,
1455
1566
  authAnchorHex: e.authAnchorHex,
1456
1567
  pinnedServerPubkey: e.pinnedServerPubkey,
1457
1568
  expectedAudienceXOnlyPubkey: e.expectedAudienceXOnlyPubkey,
1458
- authGatedMethods: ut,
1459
- grpcGatedMethods: dt
1569
+ authGatedMethods: dt,
1570
+ grpcGatedMethods: pt
1460
1571
  });
1461
1572
  return this.entries.set(e.peginTxid, {
1462
1573
  provider: n,
@@ -1491,13 +1602,13 @@ class qt {
1491
1602
  return this.entries.size;
1492
1603
  }
1493
1604
  }
1494
- const Ee = new qt();
1495
- function dr(r) {
1605
+ const Se = new Yt();
1606
+ function hr(r) {
1496
1607
  var n;
1497
1608
  const e = ve(
1498
1609
  r.baseUrl,
1499
1610
  (n = r.options) == null ? void 0 : n.headers
1500
- ), t = Ee.getOrCreate({
1611
+ ), t = Se.getOrCreate({
1501
1612
  client: e,
1502
1613
  peginTxid: r.peginTxid,
1503
1614
  authAnchorHex: r.authAnchorHex,
@@ -1506,13 +1617,13 @@ function dr(r) {
1506
1617
  r.depositorBtcPubkey
1507
1618
  )
1508
1619
  });
1509
- return new Qe(r.baseUrl, {
1620
+ return new et(r.baseUrl, {
1510
1621
  ...r.options,
1511
1622
  tokenProvider: t
1512
1623
  });
1513
1624
  }
1514
- function hr(r) {
1515
- Ee.getOrCreate({
1625
+ function gr(r) {
1626
+ Se.getOrCreate({
1516
1627
  client: ve(r.baseUrl, r.headers),
1517
1628
  peginTxid: r.peginTxid,
1518
1629
  authAnchorHex: r.authAnchorHex,
@@ -1524,19 +1635,20 @@ function hr(r) {
1524
1635
  }
1525
1636
  export {
1526
1637
  De as O,
1527
- y as S,
1528
- Qe as V,
1529
- a,
1530
- ur as b,
1531
- lt as c,
1532
- qt as d,
1533
- Ee as e,
1534
- dr as f,
1535
- ar as g,
1638
+ b as S,
1639
+ et as V,
1640
+ o as a,
1641
+ pr as b,
1642
+ ut as c,
1643
+ Yt as d,
1644
+ Se as e,
1645
+ hr as f,
1646
+ cr as g,
1536
1647
  lr as h,
1537
- cr as i,
1538
- hr as p,
1648
+ dr as i,
1649
+ ur as j,
1650
+ gr as p,
1539
1651
  or as r,
1540
1652
  Fe as v
1541
1653
  };
1542
- //# sourceMappingURL=primeVpAuth-Caa5J_uv.js.map
1654
+ //# sourceMappingURL=primeVpAuth-DkJbvywo.js.map