@babylonlabs-io/ts-sdk 0.56.0 → 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.
- package/README.md +1 -1
- package/dist/BTCVaultRegistry.abi-AUAyCHal.cjs +2 -0
- package/dist/BTCVaultRegistry.abi-AUAyCHal.cjs.map +1 -0
- package/dist/{BTCVaultRegistry.abi-Chs4AFBj.js → BTCVaultRegistry.abi-CixOlp3B.js} +73 -14
- package/dist/BTCVaultRegistry.abi-CixOlp3B.js.map +1 -0
- package/dist/BTCVaultRegistryKeyEpochs.abi-CXjhRZbm.js +111 -0
- package/dist/BTCVaultRegistryKeyEpochs.abi-CXjhRZbm.js.map +1 -0
- package/dist/BTCVaultRegistryKeyEpochs.abi-_NERAdc5.cjs +2 -0
- package/dist/BTCVaultRegistryKeyEpochs.abi-_NERAdc5.cjs.map +1 -0
- package/dist/{PeginManager-aYBkb-Qx.js → PeginManager-CnX3uFb0.js} +6 -6
- package/dist/{PeginManager-aYBkb-Qx.js.map → PeginManager-CnX3uFb0.js.map} +1 -1
- package/dist/PeginManager-iDbqXsKD.cjs +2 -0
- package/dist/{PeginManager-BkWdZI7P.cjs.map → PeginManager-iDbqXsKD.cjs.map} +1 -1
- package/dist/ProtocolParams.abi-C8U7BHCS.cjs +2 -0
- package/dist/ProtocolParams.abi-C8U7BHCS.cjs.map +1 -0
- package/dist/{ApplicationRegistry.abi-w5prf7Ig.js → ProtocolParams.abi-CV938AYZ.js} +150 -80
- package/dist/ProtocolParams.abi-CV938AYZ.js.map +1 -0
- package/dist/{buildAndBroadcastRefund-BtXUqBkb.js → buildAndBroadcastRefund-CCb1_z24.js} +627 -452
- package/dist/buildAndBroadcastRefund-CCb1_z24.js.map +1 -0
- package/dist/buildAndBroadcastRefund-CDzzTZ2U.cjs +2 -0
- package/dist/buildAndBroadcastRefund-CDzzTZ2U.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +186 -175
- package/dist/index.js.map +1 -1
- package/dist/{types-CQDRQvV-.js → json-rpc-client-Ehjthcd7.js} +61 -61
- package/dist/json-rpc-client-Ehjthcd7.js.map +1 -0
- package/dist/{types-WA0LrDk1.cjs → json-rpc-client-fUoK-TzT.cjs} +2 -2
- package/dist/json-rpc-client-fUoK-TzT.cjs.map +1 -0
- package/dist/mempoolApi-C0olk43O.js +536 -0
- package/dist/mempoolApi-C0olk43O.js.map +1 -0
- package/dist/mempoolApi-Dsm2VPXp.cjs +2 -0
- package/dist/mempoolApi-Dsm2VPXp.cjs.map +1 -0
- package/dist/{noPayout-CihCk1HE.js → noPayout-CI4l1qu2.js} +2 -2
- package/dist/{noPayout-CihCk1HE.js.map → noPayout-CI4l1qu2.js.map} +1 -1
- package/dist/{noPayout-Cb8vFrkY.cjs → noPayout-Djrv31V5.cjs} +2 -2
- package/dist/{noPayout-Cb8vFrkY.cjs.map → noPayout-Djrv31V5.cjs.map} +1 -1
- package/dist/onChainBtcPubkey-Cd9kpz-S.cjs +2 -0
- package/dist/onChainBtcPubkey-Cd9kpz-S.cjs.map +1 -0
- package/dist/onChainBtcPubkey-aPY5ib3Q.js +19 -0
- package/dist/onChainBtcPubkey-aPY5ib3Q.js.map +1 -0
- package/dist/primeVpAuth-BlxUcdBf.cjs +2 -0
- package/dist/primeVpAuth-BlxUcdBf.cjs.map +1 -0
- package/dist/{primeVpAuth-DZOaC_Ui.js → primeVpAuth-DkJbvywo.js} +479 -367
- package/dist/primeVpAuth-DkJbvywo.js.map +1 -0
- package/dist/signPsbtsWithFallback-C01N6Kdo.cjs +2 -0
- package/dist/signPsbtsWithFallback-C01N6Kdo.cjs.map +1 -0
- package/dist/{PayoutManager-BVgmuKuK.js → signPsbtsWithFallback-CzZFZf0I.js} +105 -101
- package/dist/signPsbtsWithFallback-CzZFZf0I.js.map +1 -0
- package/dist/tbv/core/clients/eth/index.d.ts +5 -3
- package/dist/tbv/core/clients/eth/index.d.ts.map +1 -1
- package/dist/tbv/core/clients/eth/onChainBtcPubkey.d.ts +16 -0
- package/dist/tbv/core/clients/eth/onChainBtcPubkey.d.ts.map +1 -0
- package/dist/tbv/core/clients/eth/operation-key-reader.d.ts +33 -0
- package/dist/tbv/core/clients/eth/operation-key-reader.d.ts.map +1 -0
- package/dist/tbv/core/clients/eth/types.d.ts +122 -3
- package/dist/tbv/core/clients/eth/types.d.ts.map +1 -1
- package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts +25 -1
- package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts.map +1 -1
- package/dist/tbv/core/clients/index.cjs +1 -1
- package/dist/tbv/core/clients/index.js +35 -32
- package/dist/tbv/core/clients/index.js.map +1 -1
- package/dist/tbv/core/clients/mempool/mempoolApi.d.ts.map +1 -1
- package/dist/tbv/core/contracts/__tests__/BTCVaultRegistryKeyEpochs.abi.test.d.ts +2 -0
- package/dist/tbv/core/contracts/__tests__/BTCVaultRegistryKeyEpochs.abi.test.d.ts.map +1 -0
- package/dist/tbv/core/contracts/abis/ApplicationRegistry.abi.d.ts +66 -0
- package/dist/tbv/core/contracts/abis/ApplicationRegistry.abi.d.ts.map +1 -1
- package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts +50 -0
- package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts.map +1 -1
- package/dist/tbv/core/contracts/abis/BTCVaultRegistryKeyEpochs.abi.d.ts +111 -0
- package/dist/tbv/core/contracts/abis/BTCVaultRegistryKeyEpochs.abi.d.ts.map +1 -0
- package/dist/tbv/core/contracts/abis/ProtocolParams.abi.d.ts +36 -0
- package/dist/tbv/core/contracts/abis/ProtocolParams.abi.d.ts.map +1 -1
- package/dist/tbv/core/contracts/index.cjs +1 -1
- package/dist/tbv/core/contracts/index.d.ts +2 -1
- package/dist/tbv/core/contracts/index.d.ts.map +1 -1
- package/dist/tbv/core/contracts/index.js +8 -6
- package/dist/tbv/core/contracts/index.js.map +1 -1
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +183 -172
- package/dist/tbv/core/index.js.map +1 -1
- package/dist/tbv/core/managers/PayoutManager.d.ts +8 -0
- package/dist/tbv/core/managers/PayoutManager.d.ts.map +1 -1
- package/dist/tbv/core/managers/index.cjs +1 -1
- package/dist/tbv/core/managers/index.js +2 -2
- package/dist/tbv/core/primitives/index.cjs +1 -1
- package/dist/tbv/core/primitives/index.js +2 -2
- package/dist/tbv/core/primitives/psbt/__tests__/standardPayoutScript.test.d.ts +2 -0
- package/dist/tbv/core/primitives/psbt/__tests__/standardPayoutScript.test.d.ts.map +1 -0
- package/dist/tbv/core/primitives/psbt/assertPayoutFeeBand.d.ts +5 -5
- package/dist/tbv/core/primitives/psbt/assertPayoutFeeBand.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/payout.d.ts +23 -0
- package/dist/tbv/core/primitives/psbt/payout.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/standardPayoutScript.d.ts +41 -0
- package/dist/tbv/core/primitives/psbt/standardPayoutScript.d.ts.map +1 -0
- package/dist/tbv/core/services/deposit/__tests__/verifyRegisteredParticipantKeys.test.d.ts +2 -0
- package/dist/tbv/core/services/deposit/__tests__/verifyRegisteredParticipantKeys.test.d.ts.map +1 -0
- package/dist/tbv/core/services/deposit/index.d.ts +7 -6
- package/dist/tbv/core/services/deposit/index.d.ts.map +1 -1
- package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts +10 -0
- package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts.map +1 -1
- package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts +9 -0
- package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts.map +1 -1
- package/dist/tbv/core/services/deposit/validateOnChainParticipantKeys.d.ts +38 -1
- package/dist/tbv/core/services/deposit/validateOnChainParticipantKeys.d.ts.map +1 -1
- package/dist/tbv/core/services/deposit/verifyRegisteredParticipantKeys.d.ts +42 -0
- package/dist/tbv/core/services/deposit/verifyRegisteredParticipantKeys.d.ts.map +1 -0
- package/dist/tbv/core/services/index.cjs +1 -1
- package/dist/tbv/core/services/index.d.ts +1 -0
- package/dist/tbv/core/services/index.d.ts.map +1 -1
- package/dist/tbv/core/services/index.js +36 -31
- package/dist/tbv/core/services/participants/__tests__/fixtures/rotation.d.ts +55 -0
- package/dist/tbv/core/services/participants/__tests__/fixtures/rotation.d.ts.map +1 -0
- package/dist/tbv/core/services/participants/__tests__/resolveParticipantKeys.test.d.ts +2 -0
- package/dist/tbv/core/services/participants/__tests__/resolveParticipantKeys.test.d.ts.map +1 -0
- package/dist/tbv/core/services/participants/index.d.ts +8 -0
- package/dist/tbv/core/services/participants/index.d.ts.map +1 -0
- package/dist/tbv/core/services/participants/resolveParticipantKeys.d.ts +26 -0
- package/dist/tbv/core/services/participants/resolveParticipantKeys.d.ts.map +1 -0
- package/dist/tbv/core/services/participants/types.d.ts +62 -0
- package/dist/tbv/core/services/participants/types.d.ts.map +1 -0
- package/dist/tbv/core/utils/__tests__/abortSignals.test.d.ts +11 -0
- package/dist/tbv/core/utils/__tests__/abortSignals.test.d.ts.map +1 -0
- package/dist/tbv/core/utils/abortSignals.d.ts +23 -0
- package/dist/tbv/core/utils/abortSignals.d.ts.map +1 -0
- package/dist/tbv/core/utils/index.cjs +1 -1
- package/dist/tbv/core/utils/index.d.ts +1 -0
- package/dist/tbv/core/utils/index.d.ts.map +1 -1
- package/dist/tbv/core/utils/index.js +44 -43
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +183 -172
- package/dist/tbv/index.js.map +1 -1
- package/dist/validation-CDbOaDj7.cjs +2 -0
- package/dist/validation-CDbOaDj7.cjs.map +1 -0
- package/dist/validation-Dj3dqYtl.js +30 -0
- package/dist/validation-Dj3dqYtl.js.map +1 -0
- package/dist/verifyScriptPathSchnorrSignature-C-84KJ6U.cjs +2 -0
- package/dist/verifyScriptPathSchnorrSignature-C-84KJ6U.cjs.map +1 -0
- package/dist/{verifyScriptPathSchnorrSignature-CgrnAjMW.js → verifyScriptPathSchnorrSignature-Xoo9DOHW.js} +359 -301
- package/dist/verifyScriptPathSchnorrSignature-Xoo9DOHW.js.map +1 -0
- package/package.json +3 -3
- package/dist/ApplicationRegistry.abi-CLaa6E99.cjs +0 -2
- package/dist/ApplicationRegistry.abi-CLaa6E99.cjs.map +0 -1
- package/dist/ApplicationRegistry.abi-w5prf7Ig.js.map +0 -1
- package/dist/BTCVaultRegistry.abi-Chs4AFBj.js.map +0 -1
- package/dist/BTCVaultRegistry.abi-JdeqLz4x.cjs +0 -2
- package/dist/BTCVaultRegistry.abi-JdeqLz4x.cjs.map +0 -1
- package/dist/PayoutManager-BVgmuKuK.js.map +0 -1
- package/dist/PayoutManager-Cu4_l-_Y.cjs +0 -2
- package/dist/PayoutManager-Cu4_l-_Y.cjs.map +0 -1
- package/dist/PeginManager-BkWdZI7P.cjs +0 -2
- package/dist/buildAndBroadcastRefund-BtXUqBkb.js.map +0 -1
- package/dist/buildAndBroadcastRefund-Cq01wyZX.cjs +0 -2
- package/dist/buildAndBroadcastRefund-Cq01wyZX.cjs.map +0 -1
- package/dist/mempoolApi-P_ApODLd.js +0 -483
- package/dist/mempoolApi-P_ApODLd.js.map +0 -1
- package/dist/mempoolApi-emec8bHK.cjs +0 -2
- package/dist/mempoolApi-emec8bHK.cjs.map +0 -1
- package/dist/primeVpAuth-DZOaC_Ui.js.map +0 -1
- package/dist/primeVpAuth-j2getl3f.cjs +0 -2
- package/dist/primeVpAuth-j2getl3f.cjs.map +0 -1
- package/dist/types-CQDRQvV-.js.map +0 -1
- package/dist/types-WA0LrDk1.cjs.map +0 -1
- package/dist/validation-CxqROCno.js +0 -15
- package/dist/validation-CxqROCno.js.map +0 -1
- package/dist/validation-u8W7Lp2x.cjs +0 -2
- package/dist/validation-u8W7Lp2x.cjs.map +0 -1
- package/dist/verifyScriptPathSchnorrSignature-BZhX-SOd.cjs +0 -2
- package/dist/verifyScriptPathSchnorrSignature-BZhX-SOd.cjs.map +0 -1
- package/dist/verifyScriptPathSchnorrSignature-CgrnAjMW.js.map +0 -1
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
var
|
|
2
|
-
var Ce = (r, e, t) => e in r ?
|
|
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
|
|
5
|
-
import {
|
|
6
|
-
import { k as Te, v as
|
|
7
|
-
import { D as Ie, J as ge, e as Re } from "./
|
|
8
|
-
import { X as
|
|
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
|
|
11
|
-
import * as
|
|
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
|
|
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:
|
|
20
|
+
abi: B,
|
|
21
21
|
functionName: "protocolParams"
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
24
|
address: e,
|
|
25
|
-
abi:
|
|
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
|
|
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
|
|
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:
|
|
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:
|
|
197
|
+
abi: y,
|
|
87
198
|
functionName: "getLatestOffchainParams"
|
|
88
|
-
}), t =
|
|
89
|
-
return
|
|
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:
|
|
205
|
+
abi: y,
|
|
95
206
|
functionName: "getOffchainParamsByVersion",
|
|
96
207
|
args: [e]
|
|
97
|
-
}), n =
|
|
98
|
-
return
|
|
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:
|
|
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:
|
|
235
|
+
abi: y,
|
|
125
236
|
functionName: "getTBVProtocolParams"
|
|
126
237
|
},
|
|
127
238
|
{
|
|
128
239
|
address: this.contractAddress,
|
|
129
|
-
abi:
|
|
240
|
+
abi: y,
|
|
130
241
|
functionName: "getLatestOffchainParams"
|
|
131
242
|
},
|
|
132
243
|
{
|
|
133
244
|
address: this.contractAddress,
|
|
134
|
-
abi:
|
|
245
|
+
abi: y,
|
|
135
246
|
functionName: "latestOffchainParamsVersion"
|
|
136
247
|
},
|
|
137
248
|
{
|
|
138
249
|
address: this.contractAddress,
|
|
139
|
-
abi:
|
|
250
|
+
abi: y,
|
|
140
251
|
functionName: "activeVaultCoreVersion"
|
|
141
252
|
}
|
|
142
253
|
],
|
|
143
254
|
allowFailure: !1
|
|
144
|
-
}), t = re(e[0]), n =
|
|
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(
|
|
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:
|
|
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
|
-
}),
|
|
293
|
+
}), a = /* @__PURE__ */ new Map();
|
|
183
294
|
for (let c = 0; c < n.length; c++) {
|
|
184
|
-
const d =
|
|
295
|
+
const d = G(s[c]);
|
|
185
296
|
try {
|
|
186
|
-
|
|
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:
|
|
305
|
+
return { byVersion: a, latestVersion: t };
|
|
195
306
|
}
|
|
196
307
|
}
|
|
197
|
-
function
|
|
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
|
|
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:
|
|
321
|
+
abi: R,
|
|
211
322
|
functionName: "getVaultKeepersByVersion",
|
|
212
323
|
args: [e, t]
|
|
213
324
|
});
|
|
214
|
-
return
|
|
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:
|
|
330
|
+
abi: R,
|
|
220
331
|
functionName: "getCurrentVaultKeepers",
|
|
221
332
|
args: [e]
|
|
222
333
|
});
|
|
223
|
-
return
|
|
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:
|
|
339
|
+
abi: R,
|
|
229
340
|
functionName: "getCurrentVaultKeepersVersion",
|
|
230
341
|
args: [e]
|
|
231
342
|
});
|
|
232
343
|
}
|
|
233
344
|
}
|
|
234
|
-
class
|
|
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:
|
|
352
|
+
abi: y,
|
|
242
353
|
functionName: "getUniversalChallengersByVersion",
|
|
243
354
|
args: [e]
|
|
244
355
|
});
|
|
245
|
-
return
|
|
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:
|
|
361
|
+
abi: y,
|
|
251
362
|
functionName: "getCurrentUniversalChallengers"
|
|
252
363
|
});
|
|
253
|
-
return
|
|
364
|
+
return H(e);
|
|
254
365
|
}
|
|
255
366
|
async getLatestUniversalChallengersVersion() {
|
|
256
367
|
return await this.publicClient.readContract({
|
|
257
368
|
address: this.contractAddress,
|
|
258
|
-
abi:
|
|
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)),
|
|
265
|
-
function
|
|
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,
|
|
378
|
+
return ((e = JSON.stringify(r)) == null ? void 0 : e.slice(0, Me)) ?? "undefined";
|
|
268
379
|
}
|
|
269
|
-
const
|
|
270
|
-
class
|
|
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(
|
|
383
|
+
super(je);
|
|
273
384
|
f(this, "detail");
|
|
274
385
|
this.name = "VpResponseValidationError", this.detail = t;
|
|
275
386
|
}
|
|
276
387
|
}
|
|
277
|
-
const
|
|
388
|
+
const N = 64;
|
|
278
389
|
function T(r) {
|
|
279
|
-
return typeof r == "string" && r.length > 0 &&
|
|
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
|
|
287
|
-
`VP response validation failed: "${e}" must be a non-empty hex string, got ${
|
|
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
|
|
293
|
-
`VP response validation failed: "${e}" must be a non-empty string, got ${
|
|
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
|
|
297
|
-
if (!T(r) || r.length !==
|
|
298
|
-
throw new
|
|
299
|
-
`VP response validation failed: "${e}" must be a ${
|
|
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
|
|
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
|
|
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
|
|
312
|
-
`VP response validation failed: "progress.presigning.depositor_graph_created" must be a boolean if present, got ${
|
|
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
|
|
316
|
-
`VP response validation failed: "progress.presigning.vk_challenger_presigning_completed" must be a number if present, got ${
|
|
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
|
|
320
|
-
`VP response validation failed: "progress.presigning.vk_challenger_presigning_total" must be a number if present, got ${
|
|
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
|
|
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 !==
|
|
330
|
-
throw new
|
|
331
|
-
`VP response validation failed: "pegin_txid" must be a ${
|
|
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
|
|
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
|
|
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
|
|
453
|
+
throw new o(
|
|
343
454
|
'VP response validation failed: "progress" must be an object'
|
|
344
455
|
);
|
|
345
|
-
if (
|
|
346
|
-
throw new
|
|
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
|
|
351
|
-
`VP response validation failed: "last_error" must be a string if present, got ${
|
|
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
|
|
465
|
+
function Le(r) {
|
|
355
466
|
if (r === null || typeof r != "object")
|
|
356
|
-
throw new
|
|
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
|
|
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
|
-
|
|
476
|
+
Ue(e.txs[t], `txs[${t}]`);
|
|
366
477
|
if (e.depositor_graph === null || typeof e.depositor_graph != "object")
|
|
367
|
-
throw new
|
|
478
|
+
throw new o(
|
|
368
479
|
'VP response validation failed: "depositor_graph" must be an object'
|
|
369
480
|
);
|
|
370
|
-
|
|
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
|
|
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
|
|
492
|
+
function Ue(r, e) {
|
|
382
493
|
if (r === null || typeof r != "object")
|
|
383
|
-
throw new
|
|
494
|
+
throw new o(
|
|
384
495
|
`VP response validation failed: "${e}" must be an object`
|
|
385
496
|
);
|
|
386
497
|
const t = r;
|
|
387
|
-
|
|
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
|
|
500
|
+
function Ke(r, e) {
|
|
390
501
|
if (r === null || typeof r != "object")
|
|
391
|
-
throw new
|
|
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
|
|
510
|
+
throw new o(
|
|
400
511
|
`VP response validation failed: "${e}" must be an object`
|
|
401
512
|
);
|
|
402
513
|
const t = r;
|
|
403
|
-
if (
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
440
|
-
`VP response validation failed: "tx_graph_json" must be a non-empty string, got ${
|
|
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
|
|
444
|
-
`VP response validation failed: "verifying_key_hex" must be a non-empty hex string, got ${
|
|
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
|
|
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
|
|
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 (
|
|
459
|
-
throw new
|
|
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
|
|
465
|
-
`VP response validation failed: "babe_sessions.${n}.decryptor_artifacts_hex" must be a non-empty hex string, got ${
|
|
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
|
|
580
|
+
function Je(r) {
|
|
470
581
|
if (r === null || typeof r != "object")
|
|
471
|
-
throw new
|
|
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 !==
|
|
476
|
-
throw new
|
|
477
|
-
`VP response validation failed: "pegin_txid" must be a ${
|
|
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
|
|
481
|
-
`VP response validation failed: "found" must be a boolean, got ${
|
|
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
|
|
486
|
-
`VP response validation failed: "claimer" must be an object or null, got ${
|
|
596
|
+
throw new o(
|
|
597
|
+
`VP response validation failed: "claimer" must be an object or null, got ${h(e.claimer)}`
|
|
487
598
|
);
|
|
488
|
-
|
|
599
|
+
We(e.claimer);
|
|
489
600
|
}
|
|
490
601
|
if (!Array.isArray(e.challengers))
|
|
491
|
-
throw new
|
|
492
|
-
`VP response validation failed: "challengers" must be an array, got ${
|
|
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
|
-
|
|
606
|
+
Ye(e.challengers[t], t);
|
|
496
607
|
}
|
|
497
|
-
function
|
|
608
|
+
function We(r) {
|
|
498
609
|
if (w(r.status, "claimer.status"), typeof r.failed != "boolean")
|
|
499
|
-
throw new
|
|
500
|
-
`VP response validation failed: "claimer.failed" must be a boolean, got ${
|
|
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
|
|
504
|
-
`VP response validation failed: "claimer.created_at" must be a number, got ${
|
|
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
|
|
508
|
-
`VP response validation failed: "claimer.updated_at" must be a number, got ${
|
|
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
|
|
622
|
+
function Ye(r, e) {
|
|
512
623
|
if (r === null || typeof r != "object")
|
|
513
|
-
throw new
|
|
514
|
-
`VP response validation failed: "challengers[${e}]" must be an object, got ${
|
|
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`),
|
|
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
|
-
),
|
|
631
|
+
), D(
|
|
521
632
|
t.challenge_assert_y_txid,
|
|
522
633
|
`challengers[${e}].challenge_assert_y_txid`
|
|
523
|
-
),
|
|
524
|
-
throw new
|
|
525
|
-
`VP response validation failed: "challengers[${e}].created_at" must be a number, got ${
|
|
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
|
|
529
|
-
`VP response validation failed: "challengers[${e}].updated_at" must be a number, got ${
|
|
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
|
|
643
|
+
function D(r, e) {
|
|
533
644
|
if (r !== null && typeof r != "string")
|
|
534
|
-
throw new
|
|
535
|
-
`VP response validation failed: "${e}" must be a string or null, got ${
|
|
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
|
|
649
|
+
function ze(r) {
|
|
539
650
|
be(r, "batchGetPeginStatus", (e) => {
|
|
540
651
|
e.result !== null && ye(e.result);
|
|
541
652
|
});
|
|
542
653
|
}
|
|
543
|
-
function
|
|
654
|
+
function qe(r) {
|
|
544
655
|
be(r, "batchGetPegoutStatus", (e) => {
|
|
545
|
-
e.result !== null &&
|
|
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
|
|
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
|
|
556
|
-
`VP response validation failed: "${e}.results" must be an array, got ${
|
|
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
|
|
562
|
-
`VP response validation failed: "${e}.results[${i}]" must be an object, got ${
|
|
672
|
+
throw new o(
|
|
673
|
+
`VP response validation failed: "${e}.results[${i}]" must be an object, got ${h(s)}`
|
|
563
674
|
);
|
|
564
|
-
const
|
|
565
|
-
if (!T(
|
|
566
|
-
throw new
|
|
567
|
-
`VP response validation failed: "${e}.results[${i}].pegin_txid" must be a ${
|
|
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 (
|
|
570
|
-
throw new
|
|
571
|
-
`VP response validation failed: "${e}.results[${i}].error" must be a string or null, got ${
|
|
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 (
|
|
574
|
-
throw new
|
|
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 (
|
|
578
|
-
throw new
|
|
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(
|
|
692
|
+
t(a, i);
|
|
582
693
|
}
|
|
583
694
|
}
|
|
584
|
-
function
|
|
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
|
|
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
|
|
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
|
|
600
|
-
class
|
|
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) ??
|
|
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
|
|
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
|
|
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
|
|
789
|
+
return qe(n), n;
|
|
679
790
|
}
|
|
680
791
|
}
|
|
681
|
-
function
|
|
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 = [],
|
|
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
|
-
|
|
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:
|
|
812
|
+
return { byTxid: n, missing: c, unexpected: a, duplicate: s };
|
|
702
813
|
}
|
|
703
|
-
async function
|
|
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:
|
|
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),
|
|
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
|
-
|
|
835
|
+
E.set(u, _), C.push(u);
|
|
725
836
|
}
|
|
726
837
|
let P;
|
|
727
838
|
try {
|
|
728
839
|
const _ = await n(C);
|
|
729
|
-
P =
|
|
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 =
|
|
738
|
-
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 =
|
|
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
|
|
748
|
-
|
|
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
|
|
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 =
|
|
759
|
-
return i.set(n, 0), i.set(n, n.length), i.set(e, n.length * 2),
|
|
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
|
|
872
|
+
function it(r) {
|
|
762
873
|
if (r.length !== we) return null;
|
|
763
|
-
const e = xe(
|
|
874
|
+
const e = xe(nt, r), t = U.xOnlyPointAddTweak(r, e);
|
|
764
875
|
return t ? t.xOnlyPubkey : null;
|
|
765
876
|
}
|
|
766
|
-
function
|
|
767
|
-
if (e.length !== we || t.length !==
|
|
877
|
+
function at(r, e, t) {
|
|
878
|
+
if (e.length !== we || t.length !== st) return !1;
|
|
768
879
|
try {
|
|
769
|
-
const n = xe(
|
|
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,
|
|
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,
|
|
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]),
|
|
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
|
-
[
|
|
906
|
+
[a],
|
|
796
907
|
X.SIGHASH_DEFAULT
|
|
797
|
-
), x =
|
|
798
|
-
return x ?
|
|
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
|
|
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 = [
|
|
947
|
+
const t = [L(4, r.length)];
|
|
837
948
|
for (const n of r)
|
|
838
|
-
t.push(
|
|
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 =
|
|
847
|
-
return Pe(n, i, s,
|
|
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
|
|
960
|
+
const ct = new TextEncoder().encode(
|
|
850
961
|
"btc-auth.server-identity.v1"
|
|
851
|
-
),
|
|
852
|
-
class
|
|
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
|
|
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
|
|
864
|
-
const { proof: e, pinnedServerPubkey: t, now: n } = r, i = r.maxLifetimeSecs ??
|
|
865
|
-
if (s.length !==
|
|
866
|
-
throw new
|
|
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
|
|
871
|
-
if (
|
|
872
|
-
throw new
|
|
873
|
-
`server_pubkey must be 32-byte hex; got ${
|
|
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 (
|
|
877
|
-
throw new
|
|
878
|
-
`server_pubkey does not match pinned value: expected ${s}, got ${
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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 !==
|
|
908
|
-
throw new
|
|
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
|
|
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 =
|
|
919
|
-
if (!
|
|
920
|
-
throw new
|
|
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 || !
|
|
926
|
-
throw new
|
|
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
|
-
|
|
932
|
-
|
|
1042
|
+
ct,
|
|
1043
|
+
M(c),
|
|
933
1044
|
e.expires_at
|
|
934
1045
|
);
|
|
935
|
-
if (!
|
|
936
|
-
throw new
|
|
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
|
|
1052
|
+
const dt = /* @__PURE__ */ new Set([
|
|
942
1053
|
"vaultProvider_submitDepositorWotsKey",
|
|
943
1054
|
"vaultProvider_submitDepositorPresignatures",
|
|
944
1055
|
"vaultProvider_requestDepositorPresignTransactions"
|
|
945
|
-
]),
|
|
1056
|
+
]), pt = /* @__PURE__ */ new Set([
|
|
946
1057
|
"vaultProvider_requestDepositorClaimerArtifacts"
|
|
947
|
-
]), ht = 6e4,
|
|
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 ===
|
|
1064
|
+
retryableFor: (t) => t === z || t === q
|
|
954
1065
|
});
|
|
955
1066
|
}
|
|
956
|
-
const
|
|
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 <
|
|
1093
|
+
if (n < ae)
|
|
983
1094
|
return { major: t, arg: n };
|
|
984
|
-
if (n >=
|
|
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 -
|
|
1099
|
+
const i = 1 << n - ae;
|
|
989
1100
|
let s = 0n;
|
|
990
|
-
for (let
|
|
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 >
|
|
1134
|
+
if (e > oe)
|
|
1024
1135
|
throw new v(
|
|
1025
|
-
`nesting exceeds maximum depth ${
|
|
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
|
|
1146
|
+
case _t:
|
|
1036
1147
|
return new TextDecoder("utf-8", { fatal: !0 }).decode(
|
|
1037
1148
|
this.readBytes(t.arg)
|
|
1038
1149
|
);
|
|
1039
|
-
case
|
|
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
|
|
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),
|
|
1049
|
-
n.set(s,
|
|
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
|
-
|
|
1057
|
-
|
|
1058
|
-
if (t.arg ===
|
|
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
|
|
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
|
|
1074
|
-
class
|
|
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 =
|
|
1191
|
+
const e = pe(
|
|
1081
1192
|
r.expectedIssuerXOnlyPubkey,
|
|
1082
1193
|
"expectedIssuerXOnlyPubkey"
|
|
1083
|
-
), t =
|
|
1194
|
+
), t = pe(
|
|
1084
1195
|
r.expectedAudienceXOnlyPubkey,
|
|
1085
1196
|
"expectedAudienceXOnlyPubkey"
|
|
1086
|
-
), n =
|
|
1087
|
-
if (
|
|
1088
|
-
throw new
|
|
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 !==
|
|
1094
|
-
throw new
|
|
1095
|
-
`COSE Sign1 must be a ${
|
|
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(),
|
|
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
|
|
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
|
|
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 =
|
|
1222
|
+
const P = Mt(l);
|
|
1112
1223
|
if (P !== le)
|
|
1113
|
-
throw new
|
|
1224
|
+
throw new p(
|
|
1114
1225
|
`unexpected COSE algorithm ${P} (expected ES256K ${le})`,
|
|
1115
1226
|
"unexpected_algorithm"
|
|
1116
1227
|
);
|
|
1117
|
-
const $ =
|
|
1118
|
-
if (!
|
|
1119
|
-
throw new
|
|
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 =
|
|
1124
|
-
if (
|
|
1125
|
-
throw new
|
|
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
|
|
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
|
|
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
|
|
1251
|
+
throw new p(
|
|
1141
1252
|
`token subject mismatch: expected ${r.expectedSubject}, got ${u.subject}`,
|
|
1142
1253
|
"subject_mismatch"
|
|
1143
1254
|
);
|
|
1144
|
-
if (
|
|
1145
|
-
throw new
|
|
1146
|
-
`token audience does not match depositor pubkey: expected ${t}, got ${
|
|
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
|
|
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
|
|
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
|
|
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:
|
|
1278
|
+
audience: S,
|
|
1168
1279
|
expiresAt: u.expiresAt,
|
|
1169
1280
|
notBefore: u.notBefore,
|
|
1170
1281
|
issuedAt: u.issuedAt
|
|
1171
1282
|
};
|
|
1172
1283
|
}
|
|
1173
|
-
function
|
|
1284
|
+
function Mt(r) {
|
|
1174
1285
|
if (r.length === 0)
|
|
1175
|
-
throw new
|
|
1286
|
+
throw new p(
|
|
1176
1287
|
"empty COSE protected header (no algorithm)",
|
|
1177
1288
|
"unexpected_algorithm"
|
|
1178
1289
|
);
|
|
1179
|
-
const e =
|
|
1290
|
+
const e = Ee(r);
|
|
1180
1291
|
if (!(e instanceof Map))
|
|
1181
|
-
throw new
|
|
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(
|
|
1296
|
+
const t = e.get(kt);
|
|
1186
1297
|
if (typeof t != "number")
|
|
1187
|
-
throw new
|
|
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
|
|
1304
|
+
function jt(r, e) {
|
|
1194
1305
|
return Ft(
|
|
1195
|
-
Uint8Array.of(
|
|
1196
|
-
Uint8Array.of(
|
|
1306
|
+
Uint8Array.of(Ct | Z),
|
|
1307
|
+
Uint8Array.of(Tt | de.length),
|
|
1197
1308
|
de,
|
|
1198
1309
|
r,
|
|
1199
|
-
Uint8Array.of(
|
|
1310
|
+
Uint8Array.of($t),
|
|
1200
1311
|
e
|
|
1201
1312
|
);
|
|
1202
1313
|
}
|
|
1203
|
-
function
|
|
1204
|
-
const e =
|
|
1314
|
+
function Ht(r) {
|
|
1315
|
+
const e = Ee(r);
|
|
1205
1316
|
if (!(e instanceof Map))
|
|
1206
|
-
throw new
|
|
1317
|
+
throw new p(
|
|
1207
1318
|
"CWT claims root is not a map",
|
|
1208
1319
|
"invalid_claims"
|
|
1209
1320
|
);
|
|
1210
|
-
if (
|
|
1211
|
-
throw new
|
|
1321
|
+
if (Lt(e, Gt, "cti").length === 0)
|
|
1322
|
+
throw new p("token cti is empty", "invalid_claims");
|
|
1212
1323
|
return {
|
|
1213
|
-
issuer:
|
|
1214
|
-
subject:
|
|
1215
|
-
audience:
|
|
1216
|
-
expiresAt:
|
|
1217
|
-
notBefore:
|
|
1218
|
-
issuedAt:
|
|
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
|
|
1332
|
+
function J(r, e, t) {
|
|
1222
1333
|
const n = r.get(e);
|
|
1223
1334
|
if (typeof n != "string")
|
|
1224
|
-
throw new
|
|
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
|
|
1341
|
+
function Lt(r, e, t) {
|
|
1231
1342
|
const n = r.get(e);
|
|
1232
1343
|
if (!(n instanceof Uint8Array))
|
|
1233
|
-
throw new
|
|
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
|
|
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
|
|
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
|
|
1359
|
+
function pe(r, e) {
|
|
1249
1360
|
const t = I(r).toLowerCase();
|
|
1250
|
-
if (t.length !==
|
|
1251
|
-
throw new
|
|
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
|
|
1368
|
+
function Ut(r) {
|
|
1258
1369
|
const e = I(r).toLowerCase(), t = e.slice(0, 2);
|
|
1259
|
-
if (e.length !==
|
|
1260
|
-
throw new
|
|
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
|
|
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
|
|
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),
|
|
1280
|
-
const g = l < 128 ?
|
|
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
|
|
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 =
|
|
1291
|
-
s[d++] = g << 2 | m >> 4, s[d++] = (m & 15) << 4 | x >> 2, s[d++] = (x & 3) << 6 |
|
|
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 =
|
|
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 =
|
|
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
|
|
1310
|
-
class
|
|
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 ??
|
|
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 ===
|
|
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" ?
|
|
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 (
|
|
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
|
|
1399
|
-
if (!Number.isSafeInteger(s.expires_at) || s.expires_at <=
|
|
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 (${
|
|
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" ?
|
|
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:
|
|
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
|
|
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
|
|
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:
|
|
1459
|
-
grpcGatedMethods:
|
|
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
|
|
1495
|
-
function
|
|
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 =
|
|
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
|
|
1620
|
+
return new et(r.baseUrl, {
|
|
1510
1621
|
...r.options,
|
|
1511
1622
|
tokenProvider: t
|
|
1512
1623
|
});
|
|
1513
1624
|
}
|
|
1514
|
-
function
|
|
1515
|
-
|
|
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
|
-
|
|
1528
|
-
|
|
1529
|
-
a,
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
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
|
-
|
|
1538
|
-
|
|
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-
|
|
1654
|
+
//# sourceMappingURL=primeVpAuth-DkJbvywo.js.map
|