@babylonlabs-io/ts-sdk 2.0.2 → 3.0.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.
- package/dist/{PeginManager-CKf7Bjmj.js → PeginManager-D8WGB8eN.js} +2 -2
- package/dist/PeginManager-D8WGB8eN.js.map +1 -0
- package/dist/{PeginManager-Dt2Z5ljw.cjs → PeginManager-IgDHy_eU.cjs} +2 -2
- package/dist/PeginManager-IgDHy_eU.cjs.map +1 -0
- package/dist/{buildAndBroadcastReclaim-B19cyK69.js → buildAndBroadcastReclaim-C55KaRJF.js} +783 -791
- package/dist/buildAndBroadcastReclaim-C55KaRJF.js.map +1 -0
- package/dist/buildAndBroadcastReclaim-CefzR6i_.cjs +2 -0
- package/dist/buildAndBroadcastReclaim-CefzR6i_.cjs.map +1 -0
- package/dist/index-D2mybjXD.js +522 -0
- package/dist/index-D2mybjXD.js.map +1 -0
- package/dist/index-MRdle0fs.cjs +2 -0
- package/dist/index-MRdle0fs.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +215 -214
- package/dist/pegin-registration-client-B0j6ugt9.cjs +2 -0
- package/dist/pegin-registration-client-B0j6ugt9.cjs.map +1 -0
- package/dist/{pegin-registration-client-C5Hktrja.js → pegin-registration-client-ilkV1mLP.js} +103 -88
- package/dist/pegin-registration-client-ilkV1mLP.js.map +1 -0
- package/dist/primeVpAuth-BDWBKYhv.cjs +2 -0
- package/dist/primeVpAuth-BDWBKYhv.cjs.map +1 -0
- package/dist/primeVpAuth-D0ZnsjRi.js +805 -0
- package/dist/primeVpAuth-D0ZnsjRi.js.map +1 -0
- package/dist/state-C4WoNCy1.cjs +2 -0
- package/dist/state-C4WoNCy1.cjs.map +1 -0
- package/dist/{json-rpc-client-CQLbpuKK.js → state-CFn1rT74.js} +136 -88
- package/dist/state-CFn1rT74.js.map +1 -0
- package/dist/tbv/core/clients/eth/index.cjs +1 -1
- package/dist/tbv/core/clients/eth/index.js +2 -2
- package/dist/tbv/core/clients/eth/types.d.ts +12 -5
- package/dist/tbv/core/clients/eth/types.d.ts.map +1 -1
- package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts +12 -3
- 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 +52 -51
- package/dist/tbv/core/clients/mempool/index.cjs +1 -1
- package/dist/tbv/core/clients/mempool/index.cjs.map +1 -1
- package/dist/tbv/core/clients/mempool/index.d.ts +1 -1
- package/dist/tbv/core/clients/mempool/index.d.ts.map +1 -1
- package/dist/tbv/core/clients/mempool/index.js +85 -71
- package/dist/tbv/core/clients/mempool/index.js.map +1 -1
- package/dist/tbv/core/clients/mempool/mempoolApi.d.ts +10 -0
- package/dist/tbv/core/clients/mempool/mempoolApi.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/api.d.ts +17 -13
- package/dist/tbv/core/clients/vault-provider/api.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/auth/createAuthenticatedVpClient.d.ts +8 -0
- package/dist/tbv/core/clients/vault-provider/auth/createAuthenticatedVpClient.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/auth/index.d.ts +1 -1
- package/dist/tbv/core/clients/vault-provider/auth/index.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/auth/primeVpAuth.d.ts +8 -0
- package/dist/tbv/core/clients/vault-provider/auth/primeVpAuth.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/auth/tokenProvider.d.ts +18 -2
- package/dist/tbv/core/clients/vault-provider/auth/tokenProvider.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/auth/tokenRegistry.d.ts +26 -6
- package/dist/tbv/core/clients/vault-provider/auth/tokenRegistry.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/batchAttribution.d.ts +17 -15
- package/dist/tbv/core/clients/vault-provider/batchAttribution.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/batchPoll.d.ts +15 -9
- package/dist/tbv/core/clients/vault-provider/batchPoll.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/json-rpc-client.d.ts +3 -2
- package/dist/tbv/core/clients/vault-provider/json-rpc-client.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/status/index.cjs +1 -1
- package/dist/tbv/core/clients/vault-provider/status/index.js +2 -2
- package/dist/tbv/core/clients/vault-provider/types.d.ts +36 -23
- package/dist/tbv/core/clients/vault-provider/types.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/validators.d.ts +12 -4
- package/dist/tbv/core/clients/vault-provider/validators.d.ts.map +1 -1
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +216 -215
- package/dist/tbv/core/managers/index.cjs +1 -1
- package/dist/tbv/core/managers/index.js +1 -1
- package/dist/tbv/core/services/deposit/interfaces.d.ts +2 -2
- package/dist/tbv/core/services/deposit/interfaces.d.ts.map +1 -1
- package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts +3 -1
- package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts.map +1 -1
- package/dist/tbv/core/services/deposit/submitWotsPublicKey.d.ts +3 -1
- package/dist/tbv/core/services/deposit/submitWotsPublicKey.d.ts.map +1 -1
- package/dist/tbv/core/services/deposit/waitForPeginStatus.d.ts +11 -2
- package/dist/tbv/core/services/deposit/waitForPeginStatus.d.ts.map +1 -1
- package/dist/tbv/core/services/index.cjs +1 -1
- package/dist/tbv/core/services/index.js +75 -74
- package/dist/tbv/core/services/index.js.map +1 -1
- package/dist/tbv/core/services/pegout/state.d.ts +10 -5
- package/dist/tbv/core/services/pegout/state.d.ts.map +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +216 -215
- package/dist/{toRefundInputs-DIIdhjvu.js → toRefundInputs-10RYIfh1.js} +2 -2
- package/dist/{toRefundInputs-DIIdhjvu.js.map → toRefundInputs-10RYIfh1.js.map} +1 -1
- package/dist/{toRefundInputs-B_GlIXjk.cjs → toRefundInputs-a-0HRyrl.cjs} +2 -2
- package/dist/{toRefundInputs-B_GlIXjk.cjs.map → toRefundInputs-a-0HRyrl.cjs.map} +1 -1
- package/dist/{types-DJxOEU3P.cjs → types-BueQoMjO.cjs} +2 -2
- package/dist/{types-DJxOEU3P.cjs.map → types-BueQoMjO.cjs.map} +1 -1
- package/dist/{types-Dz1kVqn6.js → types-DGkejGZH.js} +2 -2
- package/dist/{types-Dz1kVqn6.js.map → types-DGkejGZH.js.map} +1 -1
- package/package.json +1 -1
- package/dist/PeginManager-CKf7Bjmj.js.map +0 -1
- package/dist/PeginManager-Dt2Z5ljw.cjs.map +0 -1
- package/dist/buildAndBroadcastReclaim-B19cyK69.js.map +0 -1
- package/dist/buildAndBroadcastReclaim-DcbsjJdf.cjs +0 -2
- package/dist/buildAndBroadcastReclaim-DcbsjJdf.cjs.map +0 -1
- package/dist/index-Bnavi_r3.js +0 -521
- package/dist/index-Bnavi_r3.js.map +0 -1
- package/dist/index-CcdCNFLM.cjs +0 -2
- package/dist/index-CcdCNFLM.cjs.map +0 -1
- package/dist/json-rpc-client-CQLbpuKK.js.map +0 -1
- package/dist/json-rpc-client-DbpFfa_o.cjs +0 -2
- package/dist/json-rpc-client-DbpFfa_o.cjs.map +0 -1
- package/dist/pegin-registration-client-BdJ6c7si.cjs +0 -2
- package/dist/pegin-registration-client-BdJ6c7si.cjs.map +0 -1
- package/dist/pegin-registration-client-C5Hktrja.js.map +0 -1
- package/dist/primeVpAuth-D21PXgg2.cjs +0 -2
- package/dist/primeVpAuth-D21PXgg2.cjs.map +0 -1
- package/dist/primeVpAuth-PiUJksAq.js +0 -745
- package/dist/primeVpAuth-PiUJksAq.js.map +0 -1
|
@@ -1,745 +0,0 @@
|
|
|
1
|
-
var Q = Object.defineProperty;
|
|
2
|
-
var Z = (r, e, t) => e in r ? Q(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
-
var d = (r, e, t) => Z(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import { s as x, S as ee, h as te, p as D } from "./bitcoin-C-TuHb-v.js";
|
|
5
|
-
import { V as re } from "./index-Bnavi_r3.js";
|
|
6
|
-
import { a as ne } from "./json-rpc-client-CQLbpuKK.js";
|
|
7
|
-
import * as J from "@bitcoin-js/tiny-secp256k1-asmjs";
|
|
8
|
-
import { X as A, H as f, C as V } from "./validation-OSC0xTHB.js";
|
|
9
|
-
import { v as ie } from "./bip322Verify-BXYrHBh8.js";
|
|
10
|
-
import { s as se } from "./sha2-YqVHJiFj.js";
|
|
11
|
-
function S(r, e) {
|
|
12
|
-
const t = (r & 7) << 5, n = typeof e == "bigint" ? e : BigInt(e);
|
|
13
|
-
if (n < 0n) throw new Error("cborHead: negative argument");
|
|
14
|
-
if (n < 24n) return new Uint8Array([t | Number(n)]);
|
|
15
|
-
if (n < 0x100n) return new Uint8Array([t | 24, Number(n)]);
|
|
16
|
-
if (n < 0x10000n) {
|
|
17
|
-
const i = Number(n);
|
|
18
|
-
return new Uint8Array([t | 25, i >>> 8 & 255, i & 255]);
|
|
19
|
-
}
|
|
20
|
-
if (n < 0x100000000n) {
|
|
21
|
-
const i = Number(n);
|
|
22
|
-
return new Uint8Array([
|
|
23
|
-
t | 26,
|
|
24
|
-
i >>> 24 & 255,
|
|
25
|
-
i >>> 16 & 255,
|
|
26
|
-
i >>> 8 & 255,
|
|
27
|
-
i & 255
|
|
28
|
-
]);
|
|
29
|
-
}
|
|
30
|
-
const s = new Uint8Array(9);
|
|
31
|
-
s[0] = t | 27;
|
|
32
|
-
for (let i = 7; i >= 0; i--)
|
|
33
|
-
s[1 + i] = Number(n >> BigInt((7 - i) * 8)) & 255;
|
|
34
|
-
return s;
|
|
35
|
-
}
|
|
36
|
-
function F(...r) {
|
|
37
|
-
const e = r.reduce((s, i) => s + i.length, 0), t = new Uint8Array(e);
|
|
38
|
-
let n = 0;
|
|
39
|
-
for (const s of r)
|
|
40
|
-
t.set(s, n), n += s.length;
|
|
41
|
-
return t;
|
|
42
|
-
}
|
|
43
|
-
function $(r) {
|
|
44
|
-
const t = [S(4, r.length)];
|
|
45
|
-
for (const n of r)
|
|
46
|
-
t.push(S(0, n));
|
|
47
|
-
return F(...t);
|
|
48
|
-
}
|
|
49
|
-
function oe(r, e, t) {
|
|
50
|
-
if (!Number.isSafeInteger(t) || t < 0)
|
|
51
|
-
throw new Error(
|
|
52
|
-
`encodeServerIdentityPayload: expires_at must be a non-negative safe integer, got ${t}`
|
|
53
|
-
);
|
|
54
|
-
const n = S(4, 3), s = $(r), i = $(e), o = S(0, t);
|
|
55
|
-
return F(n, s, i, o);
|
|
56
|
-
}
|
|
57
|
-
const ae = new TextEncoder().encode(
|
|
58
|
-
"btc-auth.server-identity.v1"
|
|
59
|
-
), ce = 2 * 3600;
|
|
60
|
-
class p extends Error {
|
|
61
|
-
constructor(e, t) {
|
|
62
|
-
super(e), this.reason = t, this.name = "ServerIdentityError";
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
function m(r) {
|
|
66
|
-
const e = new Uint8Array(r.length / 2);
|
|
67
|
-
for (let t = 0; t < e.length; t++)
|
|
68
|
-
e[t] = parseInt(r.slice(t * 2, t * 2 + 2), 16);
|
|
69
|
-
return e;
|
|
70
|
-
}
|
|
71
|
-
function ue(r) {
|
|
72
|
-
const { proof: e, pinnedServerPubkey: t, now: n } = r, s = r.maxLifetimeSecs ?? ce, i = x(t).toLowerCase();
|
|
73
|
-
if (i.length !== A || !f.test(i))
|
|
74
|
-
throw new p(
|
|
75
|
-
`pinnedServerPubkey must be 32-byte hex; got ${i.length} chars`,
|
|
76
|
-
"invalid_pubkey_encoding"
|
|
77
|
-
);
|
|
78
|
-
const o = x(e.server_pubkey).toLowerCase();
|
|
79
|
-
if (o.length !== A || !f.test(o))
|
|
80
|
-
throw new p(
|
|
81
|
-
`server_pubkey must be 32-byte hex; got ${o.length} chars`,
|
|
82
|
-
"invalid_pubkey_encoding"
|
|
83
|
-
);
|
|
84
|
-
if (o !== i)
|
|
85
|
-
throw new p(
|
|
86
|
-
`server_pubkey does not match pinned value: expected ${i}, got ${o}`,
|
|
87
|
-
"pinned_pubkey_mismatch"
|
|
88
|
-
);
|
|
89
|
-
if (!Number.isSafeInteger(e.expires_at))
|
|
90
|
-
throw new p(
|
|
91
|
-
`expires_at must be a finite integer; got ${JSON.stringify(e.expires_at)}`,
|
|
92
|
-
"invalid_expires_at"
|
|
93
|
-
);
|
|
94
|
-
if (!Number.isSafeInteger(n))
|
|
95
|
-
throw new p(
|
|
96
|
-
`now must be a finite integer; got ${JSON.stringify(n)}`,
|
|
97
|
-
"invalid_expires_at"
|
|
98
|
-
);
|
|
99
|
-
if (e.expires_at <= n)
|
|
100
|
-
throw new p(
|
|
101
|
-
`server identity proof expired at ${e.expires_at}, now ${n}`,
|
|
102
|
-
"expired"
|
|
103
|
-
);
|
|
104
|
-
if (!Number.isSafeInteger(s) || s <= 0)
|
|
105
|
-
throw new p(
|
|
106
|
-
`maxLifetimeSecs must be a positive safe integer; got ${JSON.stringify(s)}`,
|
|
107
|
-
"invalid_max_lifetime"
|
|
108
|
-
);
|
|
109
|
-
if (e.expires_at - n > s)
|
|
110
|
-
throw new p(
|
|
111
|
-
`server identity proof expires too far in the future: expires_at=${e.expires_at}, now=${n}, max lifetime=${s}s`,
|
|
112
|
-
"expires_too_far"
|
|
113
|
-
);
|
|
114
|
-
const c = x(e.ephemeral_pubkey).toLowerCase();
|
|
115
|
-
if (c.length !== V || !f.test(c))
|
|
116
|
-
throw new p(
|
|
117
|
-
`ephemeral_pubkey must be 33-byte compressed hex; got ${c.length} chars`,
|
|
118
|
-
"invalid_ephemeral_pubkey"
|
|
119
|
-
);
|
|
120
|
-
const y = c.slice(0, 2);
|
|
121
|
-
if (y !== "02" && y !== "03")
|
|
122
|
-
throw new p(
|
|
123
|
-
`ephemeral_pubkey must be compressed (prefix 02/03); got ${y}`,
|
|
124
|
-
"invalid_ephemeral_pubkey"
|
|
125
|
-
);
|
|
126
|
-
const l = m(c);
|
|
127
|
-
if (!J.isPoint(l))
|
|
128
|
-
throw new p(
|
|
129
|
-
"ephemeral_pubkey is not a valid secp256k1 point",
|
|
130
|
-
"invalid_ephemeral_pubkey"
|
|
131
|
-
);
|
|
132
|
-
const h = x(e.signature).toLowerCase();
|
|
133
|
-
if (h.length !== ee || !f.test(h))
|
|
134
|
-
throw new p(
|
|
135
|
-
`signature must be 64-byte Schnorr hex; got ${h.length} chars`,
|
|
136
|
-
"invalid_signature_encoding"
|
|
137
|
-
);
|
|
138
|
-
const _ = oe(
|
|
139
|
-
ae,
|
|
140
|
-
m(c),
|
|
141
|
-
e.expires_at
|
|
142
|
-
);
|
|
143
|
-
if (!ie(
|
|
144
|
-
_,
|
|
145
|
-
m(o),
|
|
146
|
-
m(h)
|
|
147
|
-
))
|
|
148
|
-
throw new p(
|
|
149
|
-
"BIP-322 signature verification failed — ephemeral key is not attested by pinned server pubkey",
|
|
150
|
-
"signature_verification_failed"
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
const de = /* @__PURE__ */ new Set([
|
|
154
|
-
"vaultProvider_submitDepositorWotsKey",
|
|
155
|
-
"vaultProvider_submitDepositorPresignatures",
|
|
156
|
-
"vaultProvider_requestDepositorPresignTransactions"
|
|
157
|
-
]), he = /* @__PURE__ */ new Set([
|
|
158
|
-
"vaultProvider_requestDepositorClaimerArtifacts"
|
|
159
|
-
]), le = 6e4, P = "auth_createDepositorToken", O = "auth_createDepositorTokenGrpc";
|
|
160
|
-
function j(r, e) {
|
|
161
|
-
return new ne({
|
|
162
|
-
baseUrl: r,
|
|
163
|
-
timeout: le,
|
|
164
|
-
headers: e,
|
|
165
|
-
retryableFor: (t) => t === P || t === O
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
const pe = 0, ye = 1, E = 2, ge = 3, _e = 4, fe = 5, xe = 6, we = 7, M = 24, be = 28, me = 20, Ae = 21, Se = 22, N = 256;
|
|
169
|
-
class g extends Error {
|
|
170
|
-
constructor(e) {
|
|
171
|
-
super(`CBOR decode: ${e}`), this.name = "CborDecodeError";
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
class W {
|
|
175
|
-
constructor(e) {
|
|
176
|
-
d(this, "buf");
|
|
177
|
-
/** Current read offset. Public so callers can slice encoded sub-ranges. */
|
|
178
|
-
d(this, "pos", 0);
|
|
179
|
-
this.buf = e;
|
|
180
|
-
}
|
|
181
|
-
nextByte() {
|
|
182
|
-
if (this.pos >= this.buf.length)
|
|
183
|
-
throw new g("unexpected end of input");
|
|
184
|
-
return this.buf[this.pos++];
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Read an initial byte and its argument. Rejects indefinite-length
|
|
188
|
-
* and reserved additional-info encodings. Arguments wider than
|
|
189
|
-
* {@link Number.MAX_SAFE_INTEGER} are rejected — none of the token's
|
|
190
|
-
* lengths, tags, or timestamps approach that bound.
|
|
191
|
-
*/
|
|
192
|
-
readHead() {
|
|
193
|
-
const e = this.nextByte(), t = e >> 5, n = e & 31;
|
|
194
|
-
if (n < M)
|
|
195
|
-
return { major: t, arg: n };
|
|
196
|
-
if (n >= be)
|
|
197
|
-
throw new g(
|
|
198
|
-
`unsupported additional info ${n} (indefinite-length or reserved)`
|
|
199
|
-
);
|
|
200
|
-
const s = 1 << n - M;
|
|
201
|
-
let i = 0n;
|
|
202
|
-
for (let o = 0; o < s; o++)
|
|
203
|
-
i = i << 8n | BigInt(this.nextByte());
|
|
204
|
-
if (i > BigInt(Number.MAX_SAFE_INTEGER))
|
|
205
|
-
throw new g(`argument ${i} exceeds safe integer range`);
|
|
206
|
-
return { major: t, arg: Number(i) };
|
|
207
|
-
}
|
|
208
|
-
/** Read `length` raw bytes as a sub-array view into the backing buffer. */
|
|
209
|
-
readBytes(e) {
|
|
210
|
-
if (this.pos + e > this.buf.length)
|
|
211
|
-
throw new g("length overruns end of input");
|
|
212
|
-
const t = this.buf.subarray(this.pos, this.pos + e);
|
|
213
|
-
return this.pos += e, t;
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Read a byte string (major type 2), returning its content bytes.
|
|
217
|
-
* Throws if the next item is not a byte string.
|
|
218
|
-
*/
|
|
219
|
-
readByteString() {
|
|
220
|
-
const e = this.readHead();
|
|
221
|
-
if (e.major !== E)
|
|
222
|
-
throw new g(
|
|
223
|
-
`expected byte string (major ${E}), got major ${e.major}`
|
|
224
|
-
);
|
|
225
|
-
return this.readBytes(e.arg);
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Read the next complete data item as a decoded {@link CborValue}.
|
|
229
|
-
*
|
|
230
|
-
* `depth` tracks the current nesting level so a deeply-nested blob is
|
|
231
|
-
* rejected with a {@link CborDecodeError} rather than overflowing the
|
|
232
|
-
* native call stack (see {@link MAX_NESTING_DEPTH}).
|
|
233
|
-
*/
|
|
234
|
-
readValue(e = 0) {
|
|
235
|
-
if (e > N)
|
|
236
|
-
throw new g(
|
|
237
|
-
`nesting exceeds maximum depth ${N}`
|
|
238
|
-
);
|
|
239
|
-
const t = this.readHead();
|
|
240
|
-
switch (t.major) {
|
|
241
|
-
case pe:
|
|
242
|
-
return t.arg;
|
|
243
|
-
case ye:
|
|
244
|
-
return -1 - t.arg;
|
|
245
|
-
case E:
|
|
246
|
-
return this.readBytes(t.arg);
|
|
247
|
-
case ge:
|
|
248
|
-
return new TextDecoder("utf-8", { fatal: !0 }).decode(
|
|
249
|
-
this.readBytes(t.arg)
|
|
250
|
-
);
|
|
251
|
-
case _e: {
|
|
252
|
-
const n = [];
|
|
253
|
-
for (let s = 0; s < t.arg; s++)
|
|
254
|
-
n.push(this.readValue(e + 1));
|
|
255
|
-
return n;
|
|
256
|
-
}
|
|
257
|
-
case fe: {
|
|
258
|
-
const n = /* @__PURE__ */ new Map();
|
|
259
|
-
for (let s = 0; s < t.arg; s++) {
|
|
260
|
-
const i = this.readValue(e + 1), o = this.readValue(e + 1);
|
|
261
|
-
n.set(i, o);
|
|
262
|
-
}
|
|
263
|
-
return n;
|
|
264
|
-
}
|
|
265
|
-
case xe:
|
|
266
|
-
return { tag: t.arg, value: this.readValue(e + 1) };
|
|
267
|
-
case we:
|
|
268
|
-
if (t.arg === me) return !1;
|
|
269
|
-
if (t.arg === Ae) return !0;
|
|
270
|
-
if (t.arg === Se) return null;
|
|
271
|
-
throw new g(
|
|
272
|
-
`unsupported simple/float value ${t.arg}`
|
|
273
|
-
);
|
|
274
|
-
default:
|
|
275
|
-
throw new g(`unsupported major type ${t.major}`);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
function K(r) {
|
|
280
|
-
const e = new W(r), t = e.readValue();
|
|
281
|
-
if (e.pos !== r.length)
|
|
282
|
-
throw new g("trailing bytes after top-level item");
|
|
283
|
-
return t;
|
|
284
|
-
}
|
|
285
|
-
const ke = "vaultd-jsonrpc", ve = "vaultd-grpc", B = 18, I = 4, H = -47, Ee = 1, G = 64, Te = 128, Ce = 96, Pe = 64, Oe = 1, Ie = 2, Re = 3, $e = 4, Me = 5, Ne = 6, Be = 7, L = new TextEncoder().encode("Signature1");
|
|
286
|
-
class a extends Error {
|
|
287
|
-
constructor(e, t) {
|
|
288
|
-
super(e), this.reason = t, this.name = "CwtVerificationError";
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
function He(r) {
|
|
292
|
-
const e = U(
|
|
293
|
-
r.expectedIssuerXOnlyPubkey,
|
|
294
|
-
"expectedIssuerXOnlyPubkey"
|
|
295
|
-
), t = U(
|
|
296
|
-
r.expectedAudienceXOnlyPubkey,
|
|
297
|
-
"expectedAudienceXOnlyPubkey"
|
|
298
|
-
), n = De(r.ephemeralPubkeyHex), s = Ve(r.token), i = new W(s), o = i.readHead();
|
|
299
|
-
if (o.major !== 6 || o.arg !== B)
|
|
300
|
-
throw new a(
|
|
301
|
-
`token is not a COSE Sign1 tagged value (tag ${B})`,
|
|
302
|
-
"invalid_token_structure"
|
|
303
|
-
);
|
|
304
|
-
const c = i.readHead();
|
|
305
|
-
if (c.major !== 4 || c.arg !== I)
|
|
306
|
-
throw new a(
|
|
307
|
-
`COSE Sign1 must be a ${I}-element array`,
|
|
308
|
-
"invalid_token_structure"
|
|
309
|
-
);
|
|
310
|
-
const y = i.pos, l = i.readByteString(), h = s.subarray(y, i.pos);
|
|
311
|
-
i.readValue();
|
|
312
|
-
const _ = i.pos, w = i.readByteString(), k = s.subarray(_, i.pos), v = i.readByteString();
|
|
313
|
-
if (v.length !== G)
|
|
314
|
-
throw new a(
|
|
315
|
-
`COSE signature must be ${G} bytes, got ${v.length}`,
|
|
316
|
-
"invalid_token_structure"
|
|
317
|
-
);
|
|
318
|
-
if (i.pos !== s.length)
|
|
319
|
-
throw new a(
|
|
320
|
-
"COSE Sign1 token has trailing bytes after the signature",
|
|
321
|
-
"invalid_token_structure"
|
|
322
|
-
);
|
|
323
|
-
const R = Ge(l);
|
|
324
|
-
if (R !== H)
|
|
325
|
-
throw new a(
|
|
326
|
-
`unexpected COSE algorithm ${R} (expected ES256K ${H})`,
|
|
327
|
-
"unexpected_algorithm"
|
|
328
|
-
);
|
|
329
|
-
const q = Le(h, k), z = se(q);
|
|
330
|
-
if (!J.verify(z, n, v, !0))
|
|
331
|
-
throw new a(
|
|
332
|
-
"COSE signature does not verify against the server's ephemeral key",
|
|
333
|
-
"signature_verification_failed"
|
|
334
|
-
);
|
|
335
|
-
const u = Ue(w), b = u.audience.toLowerCase();
|
|
336
|
-
if (b.length !== A || !f.test(b))
|
|
337
|
-
throw new a(
|
|
338
|
-
"token `aud` is not a 32-byte x-only pubkey hex",
|
|
339
|
-
"invalid_claims"
|
|
340
|
-
);
|
|
341
|
-
if (u.issuedAt > u.expiresAt)
|
|
342
|
-
throw new a(
|
|
343
|
-
`token iat (${u.issuedAt}) is after exp (${u.expiresAt})`,
|
|
344
|
-
"invalid_claims"
|
|
345
|
-
);
|
|
346
|
-
if (u.issuer.toLowerCase() !== e)
|
|
347
|
-
throw new a(
|
|
348
|
-
`token issuer does not match pinned server pubkey: expected ${e}, got ${u.issuer.toLowerCase()}`,
|
|
349
|
-
"issuer_mismatch"
|
|
350
|
-
);
|
|
351
|
-
if (u.subject !== r.expectedSubject)
|
|
352
|
-
throw new a(
|
|
353
|
-
`token subject mismatch: expected ${r.expectedSubject}, got ${u.subject}`,
|
|
354
|
-
"subject_mismatch"
|
|
355
|
-
);
|
|
356
|
-
if (b !== t)
|
|
357
|
-
throw new a(
|
|
358
|
-
`token audience does not match depositor pubkey: expected ${t}, got ${b}`,
|
|
359
|
-
"audience_mismatch"
|
|
360
|
-
);
|
|
361
|
-
if (u.expiresAt <= r.now)
|
|
362
|
-
throw new a(
|
|
363
|
-
`token expired: exp ${u.expiresAt} <= now ${r.now}`,
|
|
364
|
-
"token_expired"
|
|
365
|
-
);
|
|
366
|
-
if (r.responseExpiresAt !== u.expiresAt)
|
|
367
|
-
throw new a(
|
|
368
|
-
`response expires_at (${r.responseExpiresAt}) does not equal token exp (${u.expiresAt})`,
|
|
369
|
-
"expiry_mismatch"
|
|
370
|
-
);
|
|
371
|
-
if (r.serverIdentityExpiresAt < u.expiresAt)
|
|
372
|
-
throw new a(
|
|
373
|
-
`server identity expires (${r.serverIdentityExpiresAt}) before token exp (${u.expiresAt})`,
|
|
374
|
-
"server_identity_expires_before_token"
|
|
375
|
-
);
|
|
376
|
-
return {
|
|
377
|
-
issuer: u.issuer,
|
|
378
|
-
subject: u.subject,
|
|
379
|
-
audience: b,
|
|
380
|
-
expiresAt: u.expiresAt,
|
|
381
|
-
notBefore: u.notBefore,
|
|
382
|
-
issuedAt: u.issuedAt
|
|
383
|
-
};
|
|
384
|
-
}
|
|
385
|
-
function Ge(r) {
|
|
386
|
-
if (r.length === 0)
|
|
387
|
-
throw new a(
|
|
388
|
-
"empty COSE protected header (no algorithm)",
|
|
389
|
-
"unexpected_algorithm"
|
|
390
|
-
);
|
|
391
|
-
const e = K(r);
|
|
392
|
-
if (!(e instanceof Map))
|
|
393
|
-
throw new a(
|
|
394
|
-
"COSE protected header is not a map",
|
|
395
|
-
"invalid_token_structure"
|
|
396
|
-
);
|
|
397
|
-
const t = e.get(Ee);
|
|
398
|
-
if (typeof t != "number")
|
|
399
|
-
throw new a(
|
|
400
|
-
"COSE protected header missing integer algorithm label",
|
|
401
|
-
"unexpected_algorithm"
|
|
402
|
-
);
|
|
403
|
-
return t;
|
|
404
|
-
}
|
|
405
|
-
function Le(r, e) {
|
|
406
|
-
return Fe(
|
|
407
|
-
Uint8Array.of(Te | I),
|
|
408
|
-
Uint8Array.of(Ce | L.length),
|
|
409
|
-
L,
|
|
410
|
-
r,
|
|
411
|
-
Uint8Array.of(Pe),
|
|
412
|
-
e
|
|
413
|
-
);
|
|
414
|
-
}
|
|
415
|
-
function Ue(r) {
|
|
416
|
-
const e = K(r);
|
|
417
|
-
if (!(e instanceof Map))
|
|
418
|
-
throw new a(
|
|
419
|
-
"CWT claims root is not a map",
|
|
420
|
-
"invalid_claims"
|
|
421
|
-
);
|
|
422
|
-
if (Xe(e, Be, "cti").length === 0)
|
|
423
|
-
throw new a("token cti is empty", "invalid_claims");
|
|
424
|
-
return {
|
|
425
|
-
issuer: T(e, Oe, "iss"),
|
|
426
|
-
subject: T(e, Ie, "sub"),
|
|
427
|
-
audience: T(e, Re, "aud"),
|
|
428
|
-
expiresAt: C(e, $e, "exp"),
|
|
429
|
-
notBefore: C(e, Me, "nbf"),
|
|
430
|
-
issuedAt: C(e, Ne, "iat")
|
|
431
|
-
};
|
|
432
|
-
}
|
|
433
|
-
function T(r, e, t) {
|
|
434
|
-
const n = r.get(e);
|
|
435
|
-
if (typeof n != "string")
|
|
436
|
-
throw new a(
|
|
437
|
-
`token claim ${t} is missing or not a text string`,
|
|
438
|
-
"invalid_claims"
|
|
439
|
-
);
|
|
440
|
-
return n;
|
|
441
|
-
}
|
|
442
|
-
function Xe(r, e, t) {
|
|
443
|
-
const n = r.get(e);
|
|
444
|
-
if (!(n instanceof Uint8Array))
|
|
445
|
-
throw new a(
|
|
446
|
-
`token claim ${t} is missing or not a byte string`,
|
|
447
|
-
"invalid_claims"
|
|
448
|
-
);
|
|
449
|
-
return n;
|
|
450
|
-
}
|
|
451
|
-
function C(r, e, t) {
|
|
452
|
-
const n = r.get(e);
|
|
453
|
-
if (typeof n != "number" || !Number.isSafeInteger(n) || n < 0)
|
|
454
|
-
throw new a(
|
|
455
|
-
`token claim ${t} is missing or not a non-negative integer timestamp`,
|
|
456
|
-
"invalid_claims"
|
|
457
|
-
);
|
|
458
|
-
return n;
|
|
459
|
-
}
|
|
460
|
-
function U(r, e) {
|
|
461
|
-
const t = x(r).toLowerCase();
|
|
462
|
-
if (t.length !== A || !f.test(t))
|
|
463
|
-
throw new a(
|
|
464
|
-
`${e} must be 32-byte x-only hex; got ${t.length} chars`,
|
|
465
|
-
"invalid_input"
|
|
466
|
-
);
|
|
467
|
-
return t;
|
|
468
|
-
}
|
|
469
|
-
function De(r) {
|
|
470
|
-
const e = x(r).toLowerCase(), t = e.slice(0, 2);
|
|
471
|
-
if (e.length !== V || !f.test(e) || t !== "02" && t !== "03")
|
|
472
|
-
throw new a(
|
|
473
|
-
"ephemeralPubkeyHex must be 33-byte compressed pubkey hex (prefix 02/03)",
|
|
474
|
-
"invalid_input"
|
|
475
|
-
);
|
|
476
|
-
return te(e);
|
|
477
|
-
}
|
|
478
|
-
const Je = (() => {
|
|
479
|
-
const r = new Int16Array(128).fill(-1), e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
480
|
-
for (let t = 0; t < e.length; t++)
|
|
481
|
-
r[e.charCodeAt(t)] = t;
|
|
482
|
-
return r;
|
|
483
|
-
})();
|
|
484
|
-
function Ve(r) {
|
|
485
|
-
const e = r.length, t = Math.floor(e / 4), n = e % 4;
|
|
486
|
-
if (n === 1)
|
|
487
|
-
throw new a(
|
|
488
|
-
"invalid base64url length",
|
|
489
|
-
"invalid_token_structure"
|
|
490
|
-
);
|
|
491
|
-
const s = t * 3 + (n === 0 ? 0 : n - 1), i = new Uint8Array(s), o = (l) => {
|
|
492
|
-
const h = l < 128 ? Je[l] : -1;
|
|
493
|
-
if (h < 0)
|
|
494
|
-
throw new a(
|
|
495
|
-
"invalid base64url character",
|
|
496
|
-
"invalid_token_structure"
|
|
497
|
-
);
|
|
498
|
-
return h;
|
|
499
|
-
};
|
|
500
|
-
let c = 0, y = 0;
|
|
501
|
-
for (let l = 0; l < t; l++) {
|
|
502
|
-
const h = o(r.charCodeAt(c++)), _ = o(r.charCodeAt(c++)), w = o(r.charCodeAt(c++)), k = o(r.charCodeAt(c++));
|
|
503
|
-
i[y++] = h << 2 | _ >> 4, i[y++] = (_ & 15) << 4 | w >> 2, i[y++] = (w & 3) << 6 | k;
|
|
504
|
-
}
|
|
505
|
-
if (n === 2) {
|
|
506
|
-
const l = o(r.charCodeAt(c++)), h = o(r.charCodeAt(c++));
|
|
507
|
-
i[y++] = l << 2 | h >> 4;
|
|
508
|
-
} else if (n === 3) {
|
|
509
|
-
const l = o(r.charCodeAt(c++)), h = o(r.charCodeAt(c++)), _ = o(r.charCodeAt(c++));
|
|
510
|
-
i[y++] = l << 2 | h >> 4, i[y++] = (h & 15) << 4 | _ >> 2;
|
|
511
|
-
}
|
|
512
|
-
return i;
|
|
513
|
-
}
|
|
514
|
-
function Fe(...r) {
|
|
515
|
-
const e = r.reduce((s, i) => s + i.length, 0), t = new Uint8Array(e);
|
|
516
|
-
let n = 0;
|
|
517
|
-
for (const s of r)
|
|
518
|
-
t.set(s, n), n += s.length;
|
|
519
|
-
return t;
|
|
520
|
-
}
|
|
521
|
-
const X = 4102444800, je = 30;
|
|
522
|
-
class We {
|
|
523
|
-
constructor(e) {
|
|
524
|
-
// `client` is the only mutable field — see `setClient`. The
|
|
525
|
-
// identity-bearing fields (peginTxid/authAnchorHex/pinnedServerPubkey)
|
|
526
|
-
// remain readonly and are checked against re-registration in the
|
|
527
|
-
// registry's `getOrCreate`.
|
|
528
|
-
d(this, "client");
|
|
529
|
-
d(this, "peginTxid");
|
|
530
|
-
d(this, "authAnchorHex");
|
|
531
|
-
d(this, "pinnedServerPubkey");
|
|
532
|
-
d(this, "expectedAudienceXOnlyPubkey");
|
|
533
|
-
d(this, "authGatedMethods");
|
|
534
|
-
d(this, "grpcGatedMethods");
|
|
535
|
-
d(this, "refreshSkewSecs");
|
|
536
|
-
d(this, "now");
|
|
537
|
-
/** Cached JSON-RPC-subject bearer (auth_createDepositorToken). */
|
|
538
|
-
d(this, "cachedJsonRpc", null);
|
|
539
|
-
d(this, "inFlightJsonRpc", null);
|
|
540
|
-
/** Cached gRPC-subject bearer (auth_createDepositorTokenGrpc). */
|
|
541
|
-
d(this, "cachedGrpc", null);
|
|
542
|
-
d(this, "inFlightGrpc", null);
|
|
543
|
-
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 ?? je, this.now = e.now ?? (() => Math.floor(Date.now() / 1e3));
|
|
544
|
-
}
|
|
545
|
-
/**
|
|
546
|
-
* Return a bearer token for `method`, or `null` if `method` is not
|
|
547
|
-
* auth-gated.
|
|
548
|
-
*
|
|
549
|
-
* Routes by subject: `authGatedMethods` → JSON-RPC bearer (issued via
|
|
550
|
-
* `auth_createDepositorToken`); `grpcGatedMethods` → gRPC bearer
|
|
551
|
-
* (`auth_createDepositorTokenGrpc`). Either path acquires lazily and
|
|
552
|
-
* single-flights concurrent callers; the two cache slots are
|
|
553
|
-
* independent.
|
|
554
|
-
*
|
|
555
|
-
* Both token-issuing methods are hard-exempted from the gate — if
|
|
556
|
-
* either were ever included in the gated sets (caller misconfiguration)
|
|
557
|
-
* the provider would recurse into `acquireSingleFlight` from inside the
|
|
558
|
-
* JSON-RPC header builder before `inFlight` is assigned, defeating the
|
|
559
|
-
* single-flight guard. Returning `null` here breaks that recursion
|
|
560
|
-
* deterministically.
|
|
561
|
-
*/
|
|
562
|
-
async getToken(e) {
|
|
563
|
-
return e === P || e === O ? null : this.grpcGatedMethods.has(e) ? this.getTokenForSubject("grpc") : this.authGatedMethods.has(e) ? this.getTokenForSubject("jsonrpc") : null;
|
|
564
|
-
}
|
|
565
|
-
/**
|
|
566
|
-
* Drop both cached tokens. Next `getToken` call re-acquires the slot
|
|
567
|
-
* that's actually needed. Called by `JsonRpcClient` on wire
|
|
568
|
-
* `auth_expired` responses; the client doesn't tell us which subject
|
|
569
|
-
* expired, so we evict both to stay correct under either.
|
|
570
|
-
*
|
|
571
|
-
* Worst case is one extra round-trip on the slot that was still fresh,
|
|
572
|
-
* which is cheaper than carrying a `Subject` argument through
|
|
573
|
-
* `BearerTokenProvider`.
|
|
574
|
-
*/
|
|
575
|
-
invalidate() {
|
|
576
|
-
this.cachedJsonRpc = null, this.cachedGrpc = null;
|
|
577
|
-
}
|
|
578
|
-
async getTokenForSubject(e) {
|
|
579
|
-
const t = e === "grpc" ? this.cachedGrpc : this.cachedJsonRpc;
|
|
580
|
-
return t && this.now() + this.refreshSkewSecs < t.expiresAt ? t.token : (await this.acquireSingleFlight(e)).token;
|
|
581
|
-
}
|
|
582
|
-
/**
|
|
583
|
-
* Swap in a different transport for subsequent token-issuing calls.
|
|
584
|
-
* Used by the registry when a later caller registers the same
|
|
585
|
-
* `peginTxid` against a different `baseUrl` — the cached token
|
|
586
|
-
* (bound to identity, not transport) stays valid, but future
|
|
587
|
-
* refreshes hit the new URL. An in-flight acquire keeps using the
|
|
588
|
-
* old client (it captured the reference); next call uses the new.
|
|
589
|
-
*/
|
|
590
|
-
setClient(e) {
|
|
591
|
-
this.client = e;
|
|
592
|
-
}
|
|
593
|
-
acquireSingleFlight(e) {
|
|
594
|
-
const t = e === "grpc" ? this.inFlightGrpc : this.inFlightJsonRpc;
|
|
595
|
-
if (t) return t;
|
|
596
|
-
const n = e === "grpc" ? O : P, s = (async () => {
|
|
597
|
-
try {
|
|
598
|
-
const i = await this.client.call(n, {
|
|
599
|
-
pegin_txid: this.peginTxid,
|
|
600
|
-
auth_anchor: this.authAnchorHex
|
|
601
|
-
});
|
|
602
|
-
if (ue({
|
|
603
|
-
proof: i.server_identity,
|
|
604
|
-
pinnedServerPubkey: this.pinnedServerPubkey,
|
|
605
|
-
now: this.now()
|
|
606
|
-
}), typeof i.token != "string" || i.token.length === 0)
|
|
607
|
-
throw new Error(
|
|
608
|
-
`VpTokenProvider: invalid token in acquire response (expected non-empty string, got ${typeof i.token})`
|
|
609
|
-
);
|
|
610
|
-
const o = this.now();
|
|
611
|
-
if (!Number.isSafeInteger(i.expires_at) || i.expires_at <= o || i.expires_at > X)
|
|
612
|
-
throw new Error(
|
|
613
|
-
`VpTokenProvider: invalid expires_at in acquire response (got ${JSON.stringify(i.expires_at)}; must be a safe integer in (${o}, ${X}])`
|
|
614
|
-
);
|
|
615
|
-
He({
|
|
616
|
-
token: i.token,
|
|
617
|
-
ephemeralPubkeyHex: i.server_identity.ephemeral_pubkey,
|
|
618
|
-
expectedIssuerXOnlyPubkey: this.pinnedServerPubkey,
|
|
619
|
-
expectedSubject: e === "grpc" ? ve : ke,
|
|
620
|
-
expectedAudienceXOnlyPubkey: this.expectedAudienceXOnlyPubkey,
|
|
621
|
-
responseExpiresAt: i.expires_at,
|
|
622
|
-
serverIdentityExpiresAt: i.server_identity.expires_at,
|
|
623
|
-
now: o
|
|
624
|
-
});
|
|
625
|
-
const c = {
|
|
626
|
-
token: i.token,
|
|
627
|
-
expiresAt: i.expires_at
|
|
628
|
-
};
|
|
629
|
-
return e === "grpc" ? this.cachedGrpc = c : this.cachedJsonRpc = c, c;
|
|
630
|
-
} finally {
|
|
631
|
-
e === "grpc" ? this.inFlightGrpc = null : this.inFlightJsonRpc = null;
|
|
632
|
-
}
|
|
633
|
-
})();
|
|
634
|
-
return e === "grpc" ? this.inFlightGrpc = s : this.inFlightJsonRpc = s, s;
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
class Ke {
|
|
638
|
-
constructor() {
|
|
639
|
-
d(this, "entries", /* @__PURE__ */ new Map());
|
|
640
|
-
}
|
|
641
|
-
/**
|
|
642
|
-
* Return the cached `VpTokenProvider` for `peginTxid` if one exists
|
|
643
|
-
* with matching `authAnchorHex` and `pinnedServerPubkey`, otherwise
|
|
644
|
-
* construct and cache a fresh provider. A mismatch on either throws —
|
|
645
|
-
* silent overwrite would mask derivation drift or VP pubkey rotation.
|
|
646
|
-
*/
|
|
647
|
-
getOrCreate(e) {
|
|
648
|
-
const t = this.entries.get(e.peginTxid);
|
|
649
|
-
if (t) {
|
|
650
|
-
if (t.authAnchorHex !== e.authAnchorHex)
|
|
651
|
-
throw new Error(
|
|
652
|
-
`VpTokenRegistry: peginTxid ${e.peginTxid} already bound to authAnchorHex ${t.authAnchorHex.slice(0, 8)}…; got ${e.authAnchorHex.slice(0, 8)}…`
|
|
653
|
-
);
|
|
654
|
-
if (t.pinnedServerPubkey !== e.pinnedServerPubkey)
|
|
655
|
-
throw new Error(
|
|
656
|
-
`VpTokenRegistry: peginTxid ${e.peginTxid} already bound to pinnedServerPubkey ${t.pinnedServerPubkey.slice(0, 8)}…; got ${e.pinnedServerPubkey.slice(0, 8)}…`
|
|
657
|
-
);
|
|
658
|
-
if (t.expectedAudienceXOnlyPubkey !== e.expectedAudienceXOnlyPubkey)
|
|
659
|
-
throw new Error(
|
|
660
|
-
`VpTokenRegistry: peginTxid ${e.peginTxid} already bound to expectedAudienceXOnlyPubkey ${t.expectedAudienceXOnlyPubkey.slice(0, 8)}…; got ${e.expectedAudienceXOnlyPubkey.slice(0, 8)}…`
|
|
661
|
-
);
|
|
662
|
-
return t.provider.setClient(e.client), t.provider;
|
|
663
|
-
}
|
|
664
|
-
const n = new We({
|
|
665
|
-
client: e.client,
|
|
666
|
-
peginTxid: e.peginTxid,
|
|
667
|
-
authAnchorHex: e.authAnchorHex,
|
|
668
|
-
pinnedServerPubkey: e.pinnedServerPubkey,
|
|
669
|
-
expectedAudienceXOnlyPubkey: e.expectedAudienceXOnlyPubkey,
|
|
670
|
-
authGatedMethods: de,
|
|
671
|
-
grpcGatedMethods: he
|
|
672
|
-
});
|
|
673
|
-
return this.entries.set(e.peginTxid, {
|
|
674
|
-
provider: n,
|
|
675
|
-
authAnchorHex: e.authAnchorHex,
|
|
676
|
-
pinnedServerPubkey: e.pinnedServerPubkey,
|
|
677
|
-
expectedAudienceXOnlyPubkey: e.expectedAudienceXOnlyPubkey
|
|
678
|
-
}), n;
|
|
679
|
-
}
|
|
680
|
-
/** Return the cached provider, or `undefined` if none. */
|
|
681
|
-
peek(e) {
|
|
682
|
-
var t;
|
|
683
|
-
return (t = this.entries.get(e)) == null ? void 0 : t.provider;
|
|
684
|
-
}
|
|
685
|
-
/**
|
|
686
|
-
* Evict the entry for `peginTxid`. Idempotent. Called on terminal
|
|
687
|
-
* paths — activation success, user-cancel, or component unmount —
|
|
688
|
-
* so `authAnchorHex` doesn't outlive the deposit session.
|
|
689
|
-
*/
|
|
690
|
-
release(e) {
|
|
691
|
-
this.entries.delete(e);
|
|
692
|
-
}
|
|
693
|
-
/**
|
|
694
|
-
* Wipe every cached entry. Test-only escape hatch — not exposed on
|
|
695
|
-
* the public {@link VpTokenRegistryPublic} singleton type.
|
|
696
|
-
*
|
|
697
|
-
* @internal
|
|
698
|
-
*/
|
|
699
|
-
clear() {
|
|
700
|
-
this.entries.clear();
|
|
701
|
-
}
|
|
702
|
-
get size() {
|
|
703
|
-
return this.entries.size;
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
const Y = new Ke();
|
|
707
|
-
function rt(r) {
|
|
708
|
-
var n;
|
|
709
|
-
const e = j(
|
|
710
|
-
r.baseUrl,
|
|
711
|
-
(n = r.options) == null ? void 0 : n.headers
|
|
712
|
-
), t = Y.getOrCreate({
|
|
713
|
-
client: e,
|
|
714
|
-
peginTxid: r.peginTxid,
|
|
715
|
-
authAnchorHex: r.authAnchorHex,
|
|
716
|
-
pinnedServerPubkey: r.pinnedServerPubkey,
|
|
717
|
-
expectedAudienceXOnlyPubkey: D(
|
|
718
|
-
r.depositorBtcPubkey
|
|
719
|
-
)
|
|
720
|
-
});
|
|
721
|
-
return new re(r.baseUrl, {
|
|
722
|
-
...r.options,
|
|
723
|
-
tokenProvider: t
|
|
724
|
-
});
|
|
725
|
-
}
|
|
726
|
-
function nt(r) {
|
|
727
|
-
Y.getOrCreate({
|
|
728
|
-
client: j(r.baseUrl, r.headers),
|
|
729
|
-
peginTxid: r.peginTxid,
|
|
730
|
-
authAnchorHex: r.authAnchorHex,
|
|
731
|
-
pinnedServerPubkey: r.pinnedServerPubkey,
|
|
732
|
-
expectedAudienceXOnlyPubkey: D(
|
|
733
|
-
r.depositorBtcPubkey
|
|
734
|
-
)
|
|
735
|
-
});
|
|
736
|
-
}
|
|
737
|
-
export {
|
|
738
|
-
p as S,
|
|
739
|
-
Ke as V,
|
|
740
|
-
Y as a,
|
|
741
|
-
rt as c,
|
|
742
|
-
nt as p,
|
|
743
|
-
ue as v
|
|
744
|
-
};
|
|
745
|
-
//# sourceMappingURL=primeVpAuth-PiUJksAq.js.map
|