@babylonlabs-io/ts-sdk 0.57.0 → 0.57.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{PeginManager-iDbqXsKD.cjs → PeginManager-DOmyNYT-.cjs} +2 -2
- package/dist/{PeginManager-iDbqXsKD.cjs.map → PeginManager-DOmyNYT-.cjs.map} +1 -1
- package/dist/{PeginManager-CnX3uFb0.js → PeginManager-DbMFLh-1.js} +7 -7
- package/dist/{PeginManager-CnX3uFb0.js.map → PeginManager-DbMFLh-1.js.map} +1 -1
- package/dist/{primeVpAuth-BlxUcdBf.cjs → batchPoll-D2OuUee1.cjs} +2 -2
- package/dist/batchPoll-D2OuUee1.cjs.map +1 -0
- package/dist/{primeVpAuth-DkJbvywo.js → batchPoll-X7D7OIcu.js} +162 -162
- package/dist/batchPoll-X7D7OIcu.js.map +1 -0
- package/dist/{bitcoin-B5aNKtsk.js → bitcoin-CHzNE-rS.js} +39 -35
- package/dist/bitcoin-CHzNE-rS.js.map +1 -0
- package/dist/bitcoin-Dpcfff7b.cjs +2 -0
- package/dist/bitcoin-Dpcfff7b.cjs.map +1 -0
- package/dist/buildAndBroadcastRefund-COinY4dk.cjs +2 -0
- package/dist/buildAndBroadcastRefund-COinY4dk.cjs.map +1 -0
- package/dist/{buildAndBroadcastRefund-CCb1_z24.js → buildAndBroadcastRefund-D_l93Gln.js} +491 -448
- package/dist/buildAndBroadcastRefund-D_l93Gln.js.map +1 -0
- package/dist/{challengeAssert-Cu-PtJ1g.cjs → challengeAssert-CIHykYs3.cjs} +2 -2
- package/dist/{challengeAssert-Cu-PtJ1g.cjs.map → challengeAssert-CIHykYs3.cjs.map} +1 -1
- package/dist/{challengeAssert-BVQq50su.js → challengeAssert-XeAql2fF.js} +2 -2
- package/dist/{challengeAssert-BVQq50su.js.map → challengeAssert-XeAql2fF.js.map} +1 -1
- package/dist/{deriveVaultRoot-B_gEOTD6.js → deriveVaultRoot-B5G8y6HJ.js} +2 -2
- package/dist/{deriveVaultRoot-B_gEOTD6.js.map → deriveVaultRoot-B5G8y6HJ.js.map} +1 -1
- package/dist/{deriveVaultRoot-CebLadyJ.cjs → deriveVaultRoot-DH0kEyaS.cjs} +2 -2
- package/dist/{deriveVaultRoot-CebLadyJ.cjs.map → deriveVaultRoot-DH0kEyaS.cjs.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +187 -181
- package/dist/json-rpc-client-BiAmg_ho.cjs +2 -0
- package/dist/json-rpc-client-BiAmg_ho.cjs.map +1 -0
- package/dist/json-rpc-client-DuUARJvV.js +334 -0
- package/dist/json-rpc-client-DuUARJvV.js.map +1 -0
- package/dist/{mempoolApi-C0olk43O.js → mempoolApi-4T6J5oxg.js} +2 -2
- package/dist/{mempoolApi-C0olk43O.js.map → mempoolApi-4T6J5oxg.js.map} +1 -1
- package/dist/{mempoolApi-Dsm2VPXp.cjs → mempoolApi-BtIABIAQ.cjs} +2 -2
- package/dist/{mempoolApi-Dsm2VPXp.cjs.map → mempoolApi-BtIABIAQ.cjs.map} +1 -1
- package/dist/{noPayout-Djrv31V5.cjs → noPayout-BkXzkhU1.cjs} +2 -2
- package/dist/{noPayout-Djrv31V5.cjs.map → noPayout-BkXzkhU1.cjs.map} +1 -1
- package/dist/{noPayout-CI4l1qu2.js → noPayout-DCf1xoJn.js} +5 -5
- package/dist/{noPayout-CI4l1qu2.js.map → noPayout-DCf1xoJn.js.map} +1 -1
- package/dist/{onChainBtcPubkey-Cd9kpz-S.cjs → onChainBtcPubkey-DqYufM7j.cjs} +2 -2
- package/dist/{onChainBtcPubkey-Cd9kpz-S.cjs.map → onChainBtcPubkey-DqYufM7j.cjs.map} +1 -1
- package/dist/{onChainBtcPubkey-aPY5ib3Q.js → onChainBtcPubkey-mP95j21Z.js} +2 -2
- package/dist/{onChainBtcPubkey-aPY5ib3Q.js.map → onChainBtcPubkey-mP95j21Z.js.map} +1 -1
- package/dist/{peginInput-CAiiDZeO.cjs → peginInput-CAYuE_5F.cjs} +2 -2
- package/dist/{peginInput-CAiiDZeO.cjs.map → peginInput-CAYuE_5F.cjs.map} +1 -1
- package/dist/{peginInput-BKD_b3gq.js → peginInput-DRUm164W.js} +2 -2
- package/dist/{peginInput-BKD_b3gq.js.map → peginInput-DRUm164W.js.map} +1 -1
- package/dist/{reservation-cHDRn4DA.js → reservation-4F9XCk0v.js} +2 -2
- package/dist/{reservation-cHDRn4DA.js.map → reservation-4F9XCk0v.js.map} +1 -1
- package/dist/{reservation-ClEs2X0H.cjs → reservation-B_7tzSwY.cjs} +2 -2
- package/dist/{reservation-ClEs2X0H.cjs.map → reservation-B_7tzSwY.cjs.map} +1 -1
- package/dist/{signPsbtsWithFallback-CzZFZf0I.js → signPsbtsWithFallback-DxG_APbS.js} +3 -3
- package/dist/{signPsbtsWithFallback-CzZFZf0I.js.map → signPsbtsWithFallback-DxG_APbS.js.map} +1 -1
- package/dist/{signPsbtsWithFallback-C01N6Kdo.cjs → signPsbtsWithFallback-r3bC-CfM.cjs} +2 -2
- package/dist/{signPsbtsWithFallback-C01N6Kdo.cjs.map → signPsbtsWithFallback-r3bC-CfM.cjs.map} +1 -1
- package/dist/tbv/core/clients/index.cjs +1 -1
- package/dist/tbv/core/clients/index.js +28 -27
- package/dist/tbv/core/clients/vault-provider/index.d.ts +4 -4
- package/dist/tbv/core/clients/vault-provider/index.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/json-rpc-client.d.ts +36 -14
- package/dist/tbv/core/clients/vault-provider/json-rpc-client.d.ts.map +1 -1
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +183 -177
- 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.d.ts +1 -1
- package/dist/tbv/core/primitives/index.d.ts.map +1 -1
- package/dist/tbv/core/primitives/index.js +15 -14
- package/dist/tbv/core/primitives/utils/bitcoin.d.ts +14 -0
- package/dist/tbv/core/primitives/utils/bitcoin.d.ts.map +1 -1
- package/dist/tbv/core/services/deposit/validateOnChainParticipantKeys.d.ts.map +1 -1
- package/dist/tbv/core/services/index.cjs +1 -1
- package/dist/tbv/core/services/index.js +35 -31
- package/dist/tbv/core/services/participants/__tests__/indexerKeyHint.test.d.ts +9 -0
- package/dist/tbv/core/services/participants/__tests__/indexerKeyHint.test.d.ts.map +1 -0
- package/dist/tbv/core/services/participants/index.d.ts +2 -0
- package/dist/tbv/core/services/participants/index.d.ts.map +1 -1
- package/dist/tbv/core/services/participants/indexerKeyHint.d.ts +61 -0
- package/dist/tbv/core/services/participants/indexerKeyHint.d.ts.map +1 -0
- package/dist/tbv/core/utils/index.cjs +1 -1
- package/dist/tbv/core/utils/index.js +3 -3
- package/dist/tbv/core/vault-secrets/index.cjs +1 -1
- package/dist/tbv/core/vault-secrets/index.js +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +183 -177
- package/dist/testing/index.cjs +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/{verifyScriptPathSchnorrSignature-C-84KJ6U.cjs → verifyScriptPathSchnorrSignature-fhjfNoHK.cjs} +2 -2
- package/dist/{verifyScriptPathSchnorrSignature-C-84KJ6U.cjs.map → verifyScriptPathSchnorrSignature-fhjfNoHK.cjs.map} +1 -1
- package/dist/{verifyScriptPathSchnorrSignature-Xoo9DOHW.js → verifyScriptPathSchnorrSignature-wwa1JhiB.js} +2 -2
- package/dist/{verifyScriptPathSchnorrSignature-Xoo9DOHW.js.map → verifyScriptPathSchnorrSignature-wwa1JhiB.js.map} +1 -1
- package/package.json +1 -1
- package/dist/bitcoin-B5aNKtsk.js.map +0 -1
- package/dist/bitcoin-CHfKAhcI.cjs +0 -2
- package/dist/bitcoin-CHfKAhcI.cjs.map +0 -1
- package/dist/buildAndBroadcastRefund-CCb1_z24.js.map +0 -1
- package/dist/buildAndBroadcastRefund-CDzzTZ2U.cjs +0 -2
- package/dist/buildAndBroadcastRefund-CDzzTZ2U.cjs.map +0 -1
- package/dist/json-rpc-client-Ehjthcd7.js +0 -324
- package/dist/json-rpc-client-Ehjthcd7.js.map +0 -1
- package/dist/json-rpc-client-fUoK-TzT.cjs +0 -2
- package/dist/json-rpc-client-fUoK-TzT.cjs.map +0 -1
- package/dist/primeVpAuth-BlxUcdBf.cjs.map +0 -1
- package/dist/primeVpAuth-DkJbvywo.js.map +0 -1
|
@@ -3,9 +3,9 @@ var Ce = (r, e, t) => e in r ? ke(r, e, { enumerable: !0, configurable: !0, writ
|
|
|
3
3
|
var f = (r, e, t) => Ce(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import { B } from "./BTCVaultRegistry.abi-CixOlp3B.js";
|
|
5
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-
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { k as Te, v as K, l as $e, j as Ve } from "./mempoolApi-4T6J5oxg.js";
|
|
7
|
+
import { X as O, C as j, s as I, S as Ie, h as Re, p as ge } from "./bitcoin-CHzNE-rS.js";
|
|
8
|
+
import { D as Oe, a as fe, e as Ne } from "./json-rpc-client-DuUARJvV.js";
|
|
9
9
|
import { C as ee } from "./constants-CDQE812z.js";
|
|
10
10
|
import { H as k } from "./validation-Dj3dqYtl.js";
|
|
11
11
|
import * as U from "@bitcoin-js/tiny-secp256k1-asmjs";
|
|
@@ -372,7 +372,7 @@ class dr {
|
|
|
372
372
|
}
|
|
373
373
|
}
|
|
374
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 || {});
|
|
375
|
-
const se = new Set(Object.values(
|
|
375
|
+
const se = new Set(Object.values(Oe)), Me = 200;
|
|
376
376
|
function h(r) {
|
|
377
377
|
var e;
|
|
378
378
|
return ((e = JSON.stringify(r)) == null ? void 0 : e.slice(0, Me)) ?? "undefined";
|
|
@@ -721,7 +721,7 @@ class et {
|
|
|
721
721
|
tokenProvider: t == null ? void 0 : t.tokenProvider,
|
|
722
722
|
maxResponseBytes: t == null ? void 0 : t.maxResponseBytes
|
|
723
723
|
};
|
|
724
|
-
this.client = new
|
|
724
|
+
this.client = new fe(n);
|
|
725
725
|
}
|
|
726
726
|
/**
|
|
727
727
|
* Request the payout/claim/assert transactions that the depositor
|
|
@@ -789,95 +789,20 @@ class et {
|
|
|
789
789
|
return qe(n), n;
|
|
790
790
|
}
|
|
791
791
|
}
|
|
792
|
-
|
|
793
|
-
const t = /* @__PURE__ */ new Set();
|
|
794
|
-
for (const d of r)
|
|
795
|
-
t.add(d.toLowerCase());
|
|
796
|
-
const n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), s = [], a = [];
|
|
797
|
-
for (const d of e) {
|
|
798
|
-
const l = d.pegin_txid.toLowerCase();
|
|
799
|
-
if (!t.has(l)) {
|
|
800
|
-
a.push(l);
|
|
801
|
-
continue;
|
|
802
|
-
}
|
|
803
|
-
if (i.has(l)) {
|
|
804
|
-
s.push(l);
|
|
805
|
-
continue;
|
|
806
|
-
}
|
|
807
|
-
i.add(l), n.set(l, { result: d.result, error: d.error });
|
|
808
|
-
}
|
|
809
|
-
const c = [];
|
|
810
|
-
for (const d of t)
|
|
811
|
-
i.has(d) || c.push(d);
|
|
812
|
-
return { byTxid: n, missing: c, unexpected: a, duplicate: s };
|
|
813
|
-
}
|
|
814
|
-
async function pr(r) {
|
|
815
|
-
const {
|
|
816
|
-
items: e,
|
|
817
|
-
getTxid: t,
|
|
818
|
-
batchCall: n,
|
|
819
|
-
onItem: i,
|
|
820
|
-
onMissing: s,
|
|
821
|
-
onDuplicate: a,
|
|
822
|
-
onDuplicateBatch: c,
|
|
823
|
-
onWholeBatchError: d,
|
|
824
|
-
onUnexpected: l,
|
|
825
|
-
batchSize: g = Re
|
|
826
|
-
} = r;
|
|
827
|
-
if (!Number.isInteger(g) || g <= 0)
|
|
828
|
-
throw new Error(
|
|
829
|
-
`batchPollByProvider: batchSize must be a positive integer, got ${g}`
|
|
830
|
-
);
|
|
831
|
-
for (let m = 0; m < e.length; m += g) {
|
|
832
|
-
const x = e.slice(m, m + g), E = /* @__PURE__ */ new Map(), C = [];
|
|
833
|
-
for (const _ of x) {
|
|
834
|
-
const u = t(_).toLowerCase();
|
|
835
|
-
E.set(u, _), C.push(u);
|
|
836
|
-
}
|
|
837
|
-
let P;
|
|
838
|
-
try {
|
|
839
|
-
const _ = await n(C);
|
|
840
|
-
P = tt(C, _.results);
|
|
841
|
-
} catch (_) {
|
|
842
|
-
d(x, _);
|
|
843
|
-
continue;
|
|
844
|
-
}
|
|
845
|
-
l && P.unexpected.length > 0 && l(P.unexpected);
|
|
846
|
-
const $ = new Set(P.duplicate);
|
|
847
|
-
for (const _ of $) {
|
|
848
|
-
const u = E.get(_);
|
|
849
|
-
u && a(u);
|
|
850
|
-
}
|
|
851
|
-
c && $.size > 0 && c($.size);
|
|
852
|
-
for (const _ of P.missing) {
|
|
853
|
-
const u = E.get(_);
|
|
854
|
-
u && s(u);
|
|
855
|
-
}
|
|
856
|
-
for (const [_, u] of P.byTxid) {
|
|
857
|
-
if ($.has(_)) continue;
|
|
858
|
-
const S = E.get(_);
|
|
859
|
-
S && i(S, {
|
|
860
|
-
pegin_txid: _,
|
|
861
|
-
result: u.result,
|
|
862
|
-
error: u.error
|
|
863
|
-
});
|
|
864
|
-
}
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
const rt = "BIP0322-signed-message", nt = "TapTweak", we = 32, st = 64;
|
|
792
|
+
const tt = "BIP0322-signed-message", rt = "TapTweak", we = 32, nt = 64;
|
|
868
793
|
function xe(r, e) {
|
|
869
794
|
const t = new TextEncoder().encode(r), n = Y(t), i = new Uint8Array(n.length * 2 + e.length);
|
|
870
795
|
return i.set(n, 0), i.set(n, n.length), i.set(e, n.length * 2), Y(i);
|
|
871
796
|
}
|
|
872
|
-
function
|
|
797
|
+
function st(r) {
|
|
873
798
|
if (r.length !== we) return null;
|
|
874
|
-
const e = xe(
|
|
799
|
+
const e = xe(rt, r), t = U.xOnlyPointAddTweak(r, e);
|
|
875
800
|
return t ? t.xOnlyPubkey : null;
|
|
876
801
|
}
|
|
877
|
-
function
|
|
878
|
-
if (e.length !== we || t.length !==
|
|
802
|
+
function it(r, e, t) {
|
|
803
|
+
if (e.length !== we || t.length !== nt) return !1;
|
|
879
804
|
try {
|
|
880
|
-
const n = xe(
|
|
805
|
+
const n = xe(tt, r), i = Be.p2tr({
|
|
881
806
|
internalPubkey: V.from(e)
|
|
882
807
|
});
|
|
883
808
|
if (!i.output) return !1;
|
|
@@ -905,7 +830,7 @@ function at(r, e, t) {
|
|
|
905
830
|
[s],
|
|
906
831
|
[a],
|
|
907
832
|
X.SIGHASH_DEFAULT
|
|
908
|
-
), x =
|
|
833
|
+
), x = st(e);
|
|
909
834
|
return x ? U.verifySchnorr(m, x, t) : !1;
|
|
910
835
|
} catch {
|
|
911
836
|
return !1;
|
|
@@ -949,7 +874,7 @@ function ie(r) {
|
|
|
949
874
|
t.push(L(0, n));
|
|
950
875
|
return Pe(...t);
|
|
951
876
|
}
|
|
952
|
-
function
|
|
877
|
+
function at(r, e, t) {
|
|
953
878
|
if (!Number.isSafeInteger(t) || t < 0)
|
|
954
879
|
throw new Error(
|
|
955
880
|
`encodeServerIdentityPayload: expires_at must be a non-negative safe integer, got ${t}`
|
|
@@ -957,9 +882,9 @@ function ot(r, e, t) {
|
|
|
957
882
|
const n = L(4, 3), i = ie(r), s = ie(e), a = L(0, t);
|
|
958
883
|
return Pe(n, i, s, a);
|
|
959
884
|
}
|
|
960
|
-
const
|
|
885
|
+
const ot = new TextEncoder().encode(
|
|
961
886
|
"btc-auth.server-identity.v1"
|
|
962
|
-
),
|
|
887
|
+
), ct = 2 * 3600;
|
|
963
888
|
class b extends Error {
|
|
964
889
|
constructor(e, t) {
|
|
965
890
|
super(e), this.reason = t, this.name = "ServerIdentityError";
|
|
@@ -971,8 +896,8 @@ function M(r) {
|
|
|
971
896
|
e[t] = parseInt(r.slice(t * 2, t * 2 + 2), 16);
|
|
972
897
|
return e;
|
|
973
898
|
}
|
|
974
|
-
function
|
|
975
|
-
const { proof: e, pinnedServerPubkey: t, now: n } = r, i = r.maxLifetimeSecs ??
|
|
899
|
+
function lt(r) {
|
|
900
|
+
const { proof: e, pinnedServerPubkey: t, now: n } = r, i = r.maxLifetimeSecs ?? ct, s = I(t).toLowerCase();
|
|
976
901
|
if (s.length !== O || !k.test(s))
|
|
977
902
|
throw new b(
|
|
978
903
|
`pinnedServerPubkey must be 32-byte hex; got ${s.length} chars`,
|
|
@@ -1033,38 +958,38 @@ function ut(r) {
|
|
|
1033
958
|
"invalid_ephemeral_pubkey"
|
|
1034
959
|
);
|
|
1035
960
|
const g = I(e.signature).toLowerCase();
|
|
1036
|
-
if (g.length !==
|
|
961
|
+
if (g.length !== Ie || !k.test(g))
|
|
1037
962
|
throw new b(
|
|
1038
963
|
`signature must be 64-byte Schnorr hex; got ${g.length} chars`,
|
|
1039
964
|
"invalid_signature_encoding"
|
|
1040
965
|
);
|
|
1041
|
-
const m =
|
|
1042
|
-
|
|
966
|
+
const m = at(
|
|
967
|
+
ot,
|
|
1043
968
|
M(c),
|
|
1044
969
|
e.expires_at
|
|
1045
970
|
);
|
|
1046
|
-
if (!
|
|
971
|
+
if (!it(m, M(a), M(g)))
|
|
1047
972
|
throw new b(
|
|
1048
973
|
"BIP-322 signature verification failed — ephemeral key is not attested by pinned server pubkey",
|
|
1049
974
|
"signature_verification_failed"
|
|
1050
975
|
);
|
|
1051
976
|
}
|
|
1052
|
-
const
|
|
977
|
+
const ut = /* @__PURE__ */ new Set([
|
|
1053
978
|
"vaultProvider_submitDepositorWotsKey",
|
|
1054
979
|
"vaultProvider_submitDepositorPresignatures",
|
|
1055
980
|
"vaultProvider_requestDepositorPresignTransactions"
|
|
1056
|
-
]),
|
|
981
|
+
]), dt = /* @__PURE__ */ new Set([
|
|
1057
982
|
"vaultProvider_requestDepositorClaimerArtifacts"
|
|
1058
|
-
]),
|
|
983
|
+
]), pt = 6e4, z = "auth_createDepositorToken", q = "auth_createDepositorTokenGrpc";
|
|
1059
984
|
function ve(r, e) {
|
|
1060
|
-
return new
|
|
985
|
+
return new fe({
|
|
1061
986
|
baseUrl: r,
|
|
1062
|
-
timeout:
|
|
987
|
+
timeout: pt,
|
|
1063
988
|
headers: e,
|
|
1064
989
|
retryableFor: (t) => t === z || t === q
|
|
1065
990
|
});
|
|
1066
991
|
}
|
|
1067
|
-
const
|
|
992
|
+
const ht = 0, gt = 1, F = 2, ft = 3, _t = 4, mt = 5, yt = 6, bt = 7, ae = 24, wt = 28, xt = 20, Pt = 21, vt = 22, oe = 256;
|
|
1068
993
|
class v extends Error {
|
|
1069
994
|
constructor(e) {
|
|
1070
995
|
super(`CBOR decode: ${e}`), this.name = "CborDecodeError";
|
|
@@ -1092,7 +1017,7 @@ class Ae {
|
|
|
1092
1017
|
const e = this.nextByte(), t = e >> 5, n = e & 31;
|
|
1093
1018
|
if (n < ae)
|
|
1094
1019
|
return { major: t, arg: n };
|
|
1095
|
-
if (n >=
|
|
1020
|
+
if (n >= wt)
|
|
1096
1021
|
throw new v(
|
|
1097
1022
|
`unsupported additional info ${n} (indefinite-length or reserved)`
|
|
1098
1023
|
);
|
|
@@ -1137,23 +1062,23 @@ class Ae {
|
|
|
1137
1062
|
);
|
|
1138
1063
|
const t = this.readHead();
|
|
1139
1064
|
switch (t.major) {
|
|
1140
|
-
case
|
|
1065
|
+
case ht:
|
|
1141
1066
|
return t.arg;
|
|
1142
|
-
case
|
|
1067
|
+
case gt:
|
|
1143
1068
|
return -1 - t.arg;
|
|
1144
1069
|
case F:
|
|
1145
1070
|
return this.readBytes(t.arg);
|
|
1146
|
-
case
|
|
1071
|
+
case ft:
|
|
1147
1072
|
return new TextDecoder("utf-8", { fatal: !0 }).decode(
|
|
1148
1073
|
this.readBytes(t.arg)
|
|
1149
1074
|
);
|
|
1150
|
-
case
|
|
1075
|
+
case _t: {
|
|
1151
1076
|
const n = [];
|
|
1152
1077
|
for (let i = 0; i < t.arg; i++)
|
|
1153
1078
|
n.push(this.readValue(e + 1));
|
|
1154
1079
|
return n;
|
|
1155
1080
|
}
|
|
1156
|
-
case
|
|
1081
|
+
case mt: {
|
|
1157
1082
|
const n = /* @__PURE__ */ new Map();
|
|
1158
1083
|
for (let i = 0; i < t.arg; i++) {
|
|
1159
1084
|
const s = this.readValue(e + 1), a = this.readValue(e + 1);
|
|
@@ -1161,12 +1086,12 @@ class Ae {
|
|
|
1161
1086
|
}
|
|
1162
1087
|
return n;
|
|
1163
1088
|
}
|
|
1164
|
-
case
|
|
1089
|
+
case yt:
|
|
1165
1090
|
return { tag: t.arg, value: this.readValue(e + 1) };
|
|
1166
|
-
case
|
|
1167
|
-
if (t.arg ===
|
|
1168
|
-
if (t.arg ===
|
|
1169
|
-
if (t.arg ===
|
|
1091
|
+
case bt:
|
|
1092
|
+
if (t.arg === xt) return !1;
|
|
1093
|
+
if (t.arg === Pt) return !0;
|
|
1094
|
+
if (t.arg === vt) return null;
|
|
1170
1095
|
throw new v(
|
|
1171
1096
|
`unsupported simple/float value ${t.arg}`
|
|
1172
1097
|
);
|
|
@@ -1181,20 +1106,20 @@ function Ee(r) {
|
|
|
1181
1106
|
throw new v("trailing bytes after top-level item");
|
|
1182
1107
|
return t;
|
|
1183
1108
|
}
|
|
1184
|
-
const
|
|
1109
|
+
const At = "vaultd-jsonrpc", Et = "vaultd-grpc", ce = 18, Z = 4, le = -47, St = 1, ue = 64, kt = 128, Ct = 96, Tt = 64, $t = 1, Vt = 2, It = 3, Rt = 4, Ot = 5, Nt = 6, Bt = 7, de = new TextEncoder().encode("Signature1");
|
|
1185
1110
|
class p extends Error {
|
|
1186
1111
|
constructor(e, t) {
|
|
1187
1112
|
super(e), this.reason = t, this.name = "CwtVerificationError";
|
|
1188
1113
|
}
|
|
1189
1114
|
}
|
|
1190
|
-
function
|
|
1115
|
+
function Gt(r) {
|
|
1191
1116
|
const e = pe(
|
|
1192
1117
|
r.expectedIssuerXOnlyPubkey,
|
|
1193
1118
|
"expectedIssuerXOnlyPubkey"
|
|
1194
1119
|
), t = pe(
|
|
1195
1120
|
r.expectedAudienceXOnlyPubkey,
|
|
1196
1121
|
"expectedAudienceXOnlyPubkey"
|
|
1197
|
-
), n =
|
|
1122
|
+
), n = Lt(r.ephemeralPubkeyHex), i = Kt(r.token), s = new Ae(i), a = s.readHead();
|
|
1198
1123
|
if (a.major !== 6 || a.arg !== ce)
|
|
1199
1124
|
throw new p(
|
|
1200
1125
|
`token is not a COSE Sign1 tagged value (tag ${ce})`,
|
|
@@ -1219,19 +1144,19 @@ function Dt(r) {
|
|
|
1219
1144
|
"COSE Sign1 token has trailing bytes after the signature",
|
|
1220
1145
|
"invalid_token_structure"
|
|
1221
1146
|
);
|
|
1222
|
-
const P =
|
|
1147
|
+
const P = Dt(l);
|
|
1223
1148
|
if (P !== le)
|
|
1224
1149
|
throw new p(
|
|
1225
1150
|
`unexpected COSE algorithm ${P} (expected ES256K ${le})`,
|
|
1226
1151
|
"unexpected_algorithm"
|
|
1227
1152
|
);
|
|
1228
|
-
const $ =
|
|
1153
|
+
const $ = Mt(g, E), _ = Y($);
|
|
1229
1154
|
if (!U.verify(_, n, C, !0))
|
|
1230
1155
|
throw new p(
|
|
1231
1156
|
"COSE signature does not verify against the server's ephemeral key",
|
|
1232
1157
|
"signature_verification_failed"
|
|
1233
1158
|
);
|
|
1234
|
-
const u =
|
|
1159
|
+
const u = jt(x), S = u.audience.toLowerCase();
|
|
1235
1160
|
if (S.length !== O || !k.test(S))
|
|
1236
1161
|
throw new p(
|
|
1237
1162
|
"token `aud` is not a 32-byte x-only pubkey hex",
|
|
@@ -1281,7 +1206,7 @@ function Dt(r) {
|
|
|
1281
1206
|
issuedAt: u.issuedAt
|
|
1282
1207
|
};
|
|
1283
1208
|
}
|
|
1284
|
-
function
|
|
1209
|
+
function Dt(r) {
|
|
1285
1210
|
if (r.length === 0)
|
|
1286
1211
|
throw new p(
|
|
1287
1212
|
"empty COSE protected header (no algorithm)",
|
|
@@ -1293,7 +1218,7 @@ function Mt(r) {
|
|
|
1293
1218
|
"COSE protected header is not a map",
|
|
1294
1219
|
"invalid_token_structure"
|
|
1295
1220
|
);
|
|
1296
|
-
const t = e.get(
|
|
1221
|
+
const t = e.get(St);
|
|
1297
1222
|
if (typeof t != "number")
|
|
1298
1223
|
throw new p(
|
|
1299
1224
|
"COSE protected header missing integer algorithm label",
|
|
@@ -1301,32 +1226,32 @@ function Mt(r) {
|
|
|
1301
1226
|
);
|
|
1302
1227
|
return t;
|
|
1303
1228
|
}
|
|
1304
|
-
function
|
|
1305
|
-
return
|
|
1306
|
-
Uint8Array.of(
|
|
1307
|
-
Uint8Array.of(
|
|
1229
|
+
function Mt(r, e) {
|
|
1230
|
+
return Xt(
|
|
1231
|
+
Uint8Array.of(kt | Z),
|
|
1232
|
+
Uint8Array.of(Ct | de.length),
|
|
1308
1233
|
de,
|
|
1309
1234
|
r,
|
|
1310
|
-
Uint8Array.of(
|
|
1235
|
+
Uint8Array.of(Tt),
|
|
1311
1236
|
e
|
|
1312
1237
|
);
|
|
1313
1238
|
}
|
|
1314
|
-
function
|
|
1239
|
+
function jt(r) {
|
|
1315
1240
|
const e = Ee(r);
|
|
1316
1241
|
if (!(e instanceof Map))
|
|
1317
1242
|
throw new p(
|
|
1318
1243
|
"CWT claims root is not a map",
|
|
1319
1244
|
"invalid_claims"
|
|
1320
1245
|
);
|
|
1321
|
-
if (
|
|
1246
|
+
if (Ht(e, Bt, "cti").length === 0)
|
|
1322
1247
|
throw new p("token cti is empty", "invalid_claims");
|
|
1323
1248
|
return {
|
|
1324
|
-
issuer: J(e,
|
|
1325
|
-
subject: J(e,
|
|
1326
|
-
audience: J(e,
|
|
1327
|
-
expiresAt: W(e,
|
|
1328
|
-
notBefore: W(e,
|
|
1329
|
-
issuedAt: W(e,
|
|
1249
|
+
issuer: J(e, $t, "iss"),
|
|
1250
|
+
subject: J(e, Vt, "sub"),
|
|
1251
|
+
audience: J(e, It, "aud"),
|
|
1252
|
+
expiresAt: W(e, Rt, "exp"),
|
|
1253
|
+
notBefore: W(e, Ot, "nbf"),
|
|
1254
|
+
issuedAt: W(e, Nt, "iat")
|
|
1330
1255
|
};
|
|
1331
1256
|
}
|
|
1332
1257
|
function J(r, e, t) {
|
|
@@ -1338,7 +1263,7 @@ function J(r, e, t) {
|
|
|
1338
1263
|
);
|
|
1339
1264
|
return n;
|
|
1340
1265
|
}
|
|
1341
|
-
function
|
|
1266
|
+
function Ht(r, e, t) {
|
|
1342
1267
|
const n = r.get(e);
|
|
1343
1268
|
if (!(n instanceof Uint8Array))
|
|
1344
1269
|
throw new p(
|
|
@@ -1365,22 +1290,22 @@ function pe(r, e) {
|
|
|
1365
1290
|
);
|
|
1366
1291
|
return t;
|
|
1367
1292
|
}
|
|
1368
|
-
function
|
|
1293
|
+
function Lt(r) {
|
|
1369
1294
|
const e = I(r).toLowerCase(), t = e.slice(0, 2);
|
|
1370
1295
|
if (e.length !== j || !k.test(e) || t !== "02" && t !== "03")
|
|
1371
1296
|
throw new p(
|
|
1372
1297
|
"ephemeralPubkeyHex must be 33-byte compressed pubkey hex (prefix 02/03)",
|
|
1373
1298
|
"invalid_input"
|
|
1374
1299
|
);
|
|
1375
|
-
return
|
|
1300
|
+
return Re(e);
|
|
1376
1301
|
}
|
|
1377
|
-
const
|
|
1302
|
+
const Ut = (() => {
|
|
1378
1303
|
const r = new Int16Array(128).fill(-1), e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
1379
1304
|
for (let t = 0; t < e.length; t++)
|
|
1380
1305
|
r[e.charCodeAt(t)] = t;
|
|
1381
1306
|
return r;
|
|
1382
1307
|
})();
|
|
1383
|
-
function
|
|
1308
|
+
function Kt(r) {
|
|
1384
1309
|
const e = r.length, t = Math.floor(e / 4), n = e % 4;
|
|
1385
1310
|
if (n === 1)
|
|
1386
1311
|
throw new p(
|
|
@@ -1388,7 +1313,7 @@ function Xt(r) {
|
|
|
1388
1313
|
"invalid_token_structure"
|
|
1389
1314
|
);
|
|
1390
1315
|
const i = t * 3 + (n === 0 ? 0 : n - 1), s = new Uint8Array(i), a = (l) => {
|
|
1391
|
-
const g = l < 128 ?
|
|
1316
|
+
const g = l < 128 ? Ut[l] : -1;
|
|
1392
1317
|
if (g < 0)
|
|
1393
1318
|
throw new p(
|
|
1394
1319
|
"invalid base64url character",
|
|
@@ -1410,15 +1335,15 @@ function Xt(r) {
|
|
|
1410
1335
|
}
|
|
1411
1336
|
return s;
|
|
1412
1337
|
}
|
|
1413
|
-
function
|
|
1338
|
+
function Xt(...r) {
|
|
1414
1339
|
const e = r.reduce((i, s) => i + s.length, 0), t = new Uint8Array(e);
|
|
1415
1340
|
let n = 0;
|
|
1416
1341
|
for (const i of r)
|
|
1417
1342
|
t.set(i, n), n += i.length;
|
|
1418
1343
|
return t;
|
|
1419
1344
|
}
|
|
1420
|
-
const he = 4102444800,
|
|
1421
|
-
class
|
|
1345
|
+
const he = 4102444800, Ft = 30;
|
|
1346
|
+
class Jt {
|
|
1422
1347
|
constructor(e) {
|
|
1423
1348
|
// `client` is the only mutable field — see `setClient`. The
|
|
1424
1349
|
// identity-bearing fields (peginTxid/authAnchorHex/pinnedServerPubkey)
|
|
@@ -1439,7 +1364,7 @@ class Wt {
|
|
|
1439
1364
|
/** Cached gRPC-subject bearer (auth_createDepositorTokenGrpc). */
|
|
1440
1365
|
f(this, "cachedGrpc", null);
|
|
1441
1366
|
f(this, "inFlightGrpc", null);
|
|
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 ??
|
|
1367
|
+
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 ?? Ft, this.now = e.now ?? (() => Math.floor(Date.now() / 1e3));
|
|
1443
1368
|
}
|
|
1444
1369
|
/**
|
|
1445
1370
|
* Return a bearer token for `method`, or `null` if `method` is not
|
|
@@ -1498,7 +1423,7 @@ class Wt {
|
|
|
1498
1423
|
pegin_txid: this.peginTxid,
|
|
1499
1424
|
auth_anchor: this.authAnchorHex
|
|
1500
1425
|
});
|
|
1501
|
-
if (
|
|
1426
|
+
if (lt({
|
|
1502
1427
|
proof: s.server_identity,
|
|
1503
1428
|
pinnedServerPubkey: this.pinnedServerPubkey,
|
|
1504
1429
|
now: this.now()
|
|
@@ -1511,11 +1436,11 @@ class Wt {
|
|
|
1511
1436
|
throw new Error(
|
|
1512
1437
|
`VpTokenProvider: invalid expires_at in acquire response (got ${JSON.stringify(s.expires_at)}; must be a safe integer in (${a}, ${he}])`
|
|
1513
1438
|
);
|
|
1514
|
-
|
|
1439
|
+
Gt({
|
|
1515
1440
|
token: s.token,
|
|
1516
1441
|
ephemeralPubkeyHex: s.server_identity.ephemeral_pubkey,
|
|
1517
1442
|
expectedIssuerXOnlyPubkey: this.pinnedServerPubkey,
|
|
1518
|
-
expectedSubject: e === "grpc" ?
|
|
1443
|
+
expectedSubject: e === "grpc" ? Et : At,
|
|
1519
1444
|
expectedAudienceXOnlyPubkey: this.expectedAudienceXOnlyPubkey,
|
|
1520
1445
|
responseExpiresAt: s.expires_at,
|
|
1521
1446
|
serverIdentityExpiresAt: s.server_identity.expires_at,
|
|
@@ -1533,7 +1458,7 @@ class Wt {
|
|
|
1533
1458
|
return e === "grpc" ? this.inFlightGrpc = i : this.inFlightJsonRpc = i, i;
|
|
1534
1459
|
}
|
|
1535
1460
|
}
|
|
1536
|
-
class
|
|
1461
|
+
class Wt {
|
|
1537
1462
|
constructor() {
|
|
1538
1463
|
f(this, "entries", /* @__PURE__ */ new Map());
|
|
1539
1464
|
}
|
|
@@ -1560,14 +1485,14 @@ class Yt {
|
|
|
1560
1485
|
);
|
|
1561
1486
|
return t.provider.setClient(e.client), t.provider;
|
|
1562
1487
|
}
|
|
1563
|
-
const n = new
|
|
1488
|
+
const n = new Jt({
|
|
1564
1489
|
client: e.client,
|
|
1565
1490
|
peginTxid: e.peginTxid,
|
|
1566
1491
|
authAnchorHex: e.authAnchorHex,
|
|
1567
1492
|
pinnedServerPubkey: e.pinnedServerPubkey,
|
|
1568
1493
|
expectedAudienceXOnlyPubkey: e.expectedAudienceXOnlyPubkey,
|
|
1569
|
-
authGatedMethods:
|
|
1570
|
-
grpcGatedMethods:
|
|
1494
|
+
authGatedMethods: ut,
|
|
1495
|
+
grpcGatedMethods: dt
|
|
1571
1496
|
});
|
|
1572
1497
|
return this.entries.set(e.peginTxid, {
|
|
1573
1498
|
provider: n,
|
|
@@ -1602,8 +1527,8 @@ class Yt {
|
|
|
1602
1527
|
return this.entries.size;
|
|
1603
1528
|
}
|
|
1604
1529
|
}
|
|
1605
|
-
const Se = new
|
|
1606
|
-
function
|
|
1530
|
+
const Se = new Wt();
|
|
1531
|
+
function pr(r) {
|
|
1607
1532
|
var n;
|
|
1608
1533
|
const e = ve(
|
|
1609
1534
|
r.baseUrl,
|
|
@@ -1613,7 +1538,7 @@ function hr(r) {
|
|
|
1613
1538
|
peginTxid: r.peginTxid,
|
|
1614
1539
|
authAnchorHex: r.authAnchorHex,
|
|
1615
1540
|
pinnedServerPubkey: r.pinnedServerPubkey,
|
|
1616
|
-
expectedAudienceXOnlyPubkey:
|
|
1541
|
+
expectedAudienceXOnlyPubkey: ge(
|
|
1617
1542
|
r.depositorBtcPubkey
|
|
1618
1543
|
)
|
|
1619
1544
|
});
|
|
@@ -1622,33 +1547,108 @@ function hr(r) {
|
|
|
1622
1547
|
tokenProvider: t
|
|
1623
1548
|
});
|
|
1624
1549
|
}
|
|
1625
|
-
function
|
|
1550
|
+
function hr(r) {
|
|
1626
1551
|
Se.getOrCreate({
|
|
1627
1552
|
client: ve(r.baseUrl, r.headers),
|
|
1628
1553
|
peginTxid: r.peginTxid,
|
|
1629
1554
|
authAnchorHex: r.authAnchorHex,
|
|
1630
1555
|
pinnedServerPubkey: r.pinnedServerPubkey,
|
|
1631
|
-
expectedAudienceXOnlyPubkey:
|
|
1556
|
+
expectedAudienceXOnlyPubkey: ge(
|
|
1632
1557
|
r.depositorBtcPubkey
|
|
1633
1558
|
)
|
|
1634
1559
|
});
|
|
1635
1560
|
}
|
|
1561
|
+
function Yt(r, e) {
|
|
1562
|
+
const t = /* @__PURE__ */ new Set();
|
|
1563
|
+
for (const d of r)
|
|
1564
|
+
t.add(d.toLowerCase());
|
|
1565
|
+
const n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), s = [], a = [];
|
|
1566
|
+
for (const d of e) {
|
|
1567
|
+
const l = d.pegin_txid.toLowerCase();
|
|
1568
|
+
if (!t.has(l)) {
|
|
1569
|
+
a.push(l);
|
|
1570
|
+
continue;
|
|
1571
|
+
}
|
|
1572
|
+
if (i.has(l)) {
|
|
1573
|
+
s.push(l);
|
|
1574
|
+
continue;
|
|
1575
|
+
}
|
|
1576
|
+
i.add(l), n.set(l, { result: d.result, error: d.error });
|
|
1577
|
+
}
|
|
1578
|
+
const c = [];
|
|
1579
|
+
for (const d of t)
|
|
1580
|
+
i.has(d) || c.push(d);
|
|
1581
|
+
return { byTxid: n, missing: c, unexpected: a, duplicate: s };
|
|
1582
|
+
}
|
|
1583
|
+
async function gr(r) {
|
|
1584
|
+
const {
|
|
1585
|
+
items: e,
|
|
1586
|
+
getTxid: t,
|
|
1587
|
+
batchCall: n,
|
|
1588
|
+
onItem: i,
|
|
1589
|
+
onMissing: s,
|
|
1590
|
+
onDuplicate: a,
|
|
1591
|
+
onDuplicateBatch: c,
|
|
1592
|
+
onWholeBatchError: d,
|
|
1593
|
+
onUnexpected: l,
|
|
1594
|
+
batchSize: g = Ne
|
|
1595
|
+
} = r;
|
|
1596
|
+
if (!Number.isInteger(g) || g <= 0)
|
|
1597
|
+
throw new Error(
|
|
1598
|
+
`batchPollByProvider: batchSize must be a positive integer, got ${g}`
|
|
1599
|
+
);
|
|
1600
|
+
for (let m = 0; m < e.length; m += g) {
|
|
1601
|
+
const x = e.slice(m, m + g), E = /* @__PURE__ */ new Map(), C = [];
|
|
1602
|
+
for (const _ of x) {
|
|
1603
|
+
const u = t(_).toLowerCase();
|
|
1604
|
+
E.set(u, _), C.push(u);
|
|
1605
|
+
}
|
|
1606
|
+
let P;
|
|
1607
|
+
try {
|
|
1608
|
+
const _ = await n(C);
|
|
1609
|
+
P = Yt(C, _.results);
|
|
1610
|
+
} catch (_) {
|
|
1611
|
+
d(x, _);
|
|
1612
|
+
continue;
|
|
1613
|
+
}
|
|
1614
|
+
l && P.unexpected.length > 0 && l(P.unexpected);
|
|
1615
|
+
const $ = new Set(P.duplicate);
|
|
1616
|
+
for (const _ of $) {
|
|
1617
|
+
const u = E.get(_);
|
|
1618
|
+
u && a(u);
|
|
1619
|
+
}
|
|
1620
|
+
c && $.size > 0 && c($.size);
|
|
1621
|
+
for (const _ of P.missing) {
|
|
1622
|
+
const u = E.get(_);
|
|
1623
|
+
u && s(u);
|
|
1624
|
+
}
|
|
1625
|
+
for (const [_, u] of P.byTxid) {
|
|
1626
|
+
if ($.has(_)) continue;
|
|
1627
|
+
const S = E.get(_);
|
|
1628
|
+
S && i(S, {
|
|
1629
|
+
pegin_txid: _,
|
|
1630
|
+
result: u.result,
|
|
1631
|
+
error: u.error
|
|
1632
|
+
});
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
1636
|
export {
|
|
1637
1637
|
De as O,
|
|
1638
1638
|
b as S,
|
|
1639
1639
|
et as V,
|
|
1640
1640
|
o as a,
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1641
|
+
gr as b,
|
|
1642
|
+
lt as c,
|
|
1643
|
+
Wt as d,
|
|
1644
1644
|
Se as e,
|
|
1645
|
-
|
|
1645
|
+
pr as f,
|
|
1646
1646
|
cr as g,
|
|
1647
1647
|
lr as h,
|
|
1648
1648
|
dr as i,
|
|
1649
1649
|
ur as j,
|
|
1650
|
-
|
|
1650
|
+
hr as p,
|
|
1651
1651
|
or as r,
|
|
1652
1652
|
Fe as v
|
|
1653
1653
|
};
|
|
1654
|
-
//# sourceMappingURL=
|
|
1654
|
+
//# sourceMappingURL=batchPoll-X7D7OIcu.js.map
|