@babylonlabs-io/ts-sdk 0.57.0 → 0.57.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/{primeVpAuth-BlxUcdBf.cjs → batchPoll-BXIy3R7h.cjs} +2 -2
  2. package/dist/batchPoll-BXIy3R7h.cjs.map +1 -0
  3. package/dist/{primeVpAuth-DkJbvywo.js → batchPoll-DTYXoTEc.js} +161 -161
  4. package/dist/batchPoll-DTYXoTEc.js.map +1 -0
  5. package/dist/{buildAndBroadcastRefund-CDzzTZ2U.cjs → buildAndBroadcastRefund-4uAl7OIk.cjs} +2 -2
  6. package/dist/{buildAndBroadcastRefund-CDzzTZ2U.cjs.map → buildAndBroadcastRefund-4uAl7OIk.cjs.map} +1 -1
  7. package/dist/{buildAndBroadcastRefund-CCb1_z24.js → buildAndBroadcastRefund-Bo3AlqCk.js} +2 -2
  8. package/dist/{buildAndBroadcastRefund-CCb1_z24.js.map → buildAndBroadcastRefund-Bo3AlqCk.js.map} +1 -1
  9. package/dist/index.cjs +1 -1
  10. package/dist/index.js +101 -100
  11. package/dist/json-rpc-client-BiAmg_ho.cjs +2 -0
  12. package/dist/json-rpc-client-BiAmg_ho.cjs.map +1 -0
  13. package/dist/json-rpc-client-DuUARJvV.js +334 -0
  14. package/dist/json-rpc-client-DuUARJvV.js.map +1 -0
  15. package/dist/tbv/core/clients/index.cjs +1 -1
  16. package/dist/tbv/core/clients/index.js +28 -27
  17. package/dist/tbv/core/clients/vault-provider/index.d.ts +4 -4
  18. package/dist/tbv/core/clients/vault-provider/index.d.ts.map +1 -1
  19. package/dist/tbv/core/clients/vault-provider/json-rpc-client.d.ts +36 -14
  20. package/dist/tbv/core/clients/vault-provider/json-rpc-client.d.ts.map +1 -1
  21. package/dist/tbv/core/index.cjs +1 -1
  22. package/dist/tbv/core/index.js +93 -92
  23. package/dist/tbv/core/services/index.cjs +1 -1
  24. package/dist/tbv/core/services/index.js +1 -1
  25. package/dist/tbv/index.cjs +1 -1
  26. package/dist/tbv/index.js +93 -92
  27. package/package.json +1 -1
  28. package/dist/json-rpc-client-Ehjthcd7.js +0 -324
  29. package/dist/json-rpc-client-Ehjthcd7.js.map +0 -1
  30. package/dist/json-rpc-client-fUoK-TzT.cjs +0 -2
  31. package/dist/json-rpc-client-fUoK-TzT.cjs.map +0 -1
  32. package/dist/primeVpAuth-BlxUcdBf.cjs.map +0 -1
  33. package/dist/primeVpAuth-DkJbvywo.js.map +0 -1
@@ -4,8 +4,8 @@ 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
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";
7
+ import { X as O, C as j, s as I, S as Ie, h as Re, p as ge } from "./bitcoin-B5aNKtsk.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(Ie)), Me = 200;
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 ge(n);
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
- function tt(r, e) {
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 it(r) {
797
+ function st(r) {
873
798
  if (r.length !== we) return null;
874
- const e = xe(nt, r), t = U.xOnlyPointAddTweak(r, e);
799
+ const e = xe(rt, r), t = U.xOnlyPointAddTweak(r, e);
875
800
  return t ? t.xOnlyPubkey : null;
876
801
  }
877
- function at(r, e, t) {
878
- if (e.length !== we || t.length !== st) return !1;
802
+ function it(r, e, t) {
803
+ if (e.length !== we || t.length !== nt) return !1;
879
804
  try {
880
- const n = xe(rt, r), i = Be.p2tr({
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 = it(e);
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 ot(r, e, t) {
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 ct = new TextEncoder().encode(
885
+ const ot = new TextEncoder().encode(
961
886
  "btc-auth.server-identity.v1"
962
- ), lt = 2 * 3600;
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 ut(r) {
975
- const { proof: e, pinnedServerPubkey: t, now: n } = r, i = r.maxLifetimeSecs ?? lt, s = I(t).toLowerCase();
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 !== Oe || !k.test(g))
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 = ot(
1042
- ct,
966
+ const m = at(
967
+ ot,
1043
968
  M(c),
1044
969
  e.expires_at
1045
970
  );
1046
- if (!at(m, M(a), M(g)))
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 dt = /* @__PURE__ */ new Set([
977
+ const ut = /* @__PURE__ */ new Set([
1053
978
  "vaultProvider_submitDepositorWotsKey",
1054
979
  "vaultProvider_submitDepositorPresignatures",
1055
980
  "vaultProvider_requestDepositorPresignTransactions"
1056
- ]), pt = /* @__PURE__ */ new Set([
981
+ ]), dt = /* @__PURE__ */ new Set([
1057
982
  "vaultProvider_requestDepositorClaimerArtifacts"
1058
- ]), ht = 6e4, z = "auth_createDepositorToken", q = "auth_createDepositorTokenGrpc";
983
+ ]), pt = 6e4, z = "auth_createDepositorToken", q = "auth_createDepositorTokenGrpc";
1059
984
  function ve(r, e) {
1060
- return new ge({
985
+ return new fe({
1061
986
  baseUrl: r,
1062
- timeout: ht,
987
+ timeout: pt,
1063
988
  headers: e,
1064
989
  retryableFor: (t) => t === z || t === q
1065
990
  });
1066
991
  }
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;
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 >= xt)
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 gt:
1065
+ case ht:
1141
1066
  return t.arg;
1142
- case ft:
1067
+ case gt:
1143
1068
  return -1 - t.arg;
1144
1069
  case F:
1145
1070
  return this.readBytes(t.arg);
1146
- case _t:
1071
+ case ft:
1147
1072
  return new TextDecoder("utf-8", { fatal: !0 }).decode(
1148
1073
  this.readBytes(t.arg)
1149
1074
  );
1150
- case mt: {
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 yt: {
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 bt:
1089
+ case yt:
1165
1090
  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;
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 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");
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 Dt(r) {
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 = Ut(r.ephemeralPubkeyHex), i = Xt(r.token), s = new Ae(i), a = s.readHead();
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 = Mt(l);
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 $ = jt(g, E), _ = Y($);
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 = Ht(x), S = u.audience.toLowerCase();
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 Mt(r) {
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(kt);
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 jt(r, e) {
1305
- return Ft(
1306
- Uint8Array.of(Ct | Z),
1307
- Uint8Array.of(Tt | de.length),
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($t),
1235
+ Uint8Array.of(Tt),
1311
1236
  e
1312
1237
  );
1313
1238
  }
1314
- function Ht(r) {
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 (Lt(e, Gt, "cti").length === 0)
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, 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")
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 Lt(r, e, t) {
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 Ut(r) {
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 Ne(e);
1300
+ return Re(e);
1376
1301
  }
1377
- const Kt = (() => {
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 Xt(r) {
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 ? Kt[l] : -1;
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 Ft(...r) {
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, Jt = 30;
1421
- class Wt {
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 ?? Jt, this.now = e.now ?? (() => Math.floor(Date.now() / 1e3));
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 (ut({
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
- Dt({
1439
+ Gt({
1515
1440
  token: s.token,
1516
1441
  ephemeralPubkeyHex: s.server_identity.ephemeral_pubkey,
1517
1442
  expectedIssuerXOnlyPubkey: this.pinnedServerPubkey,
1518
- expectedSubject: e === "grpc" ? St : Et,
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 Yt {
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 Wt({
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: dt,
1570
- grpcGatedMethods: pt
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 Yt();
1606
- function hr(r) {
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: fe(
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 gr(r) {
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: fe(
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
- pr as b,
1642
- ut as c,
1643
- Yt as d,
1641
+ gr as b,
1642
+ lt as c,
1643
+ Wt as d,
1644
1644
  Se as e,
1645
- hr as f,
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
- gr as p,
1650
+ hr as p,
1651
1651
  or as r,
1652
1652
  Fe as v
1653
1653
  };
1654
- //# sourceMappingURL=primeVpAuth-DkJbvywo.js.map
1654
+ //# sourceMappingURL=batchPoll-DTYXoTEc.js.map