@sourceregistry/node-jwt 1.5.9 → 1.5.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -5
- package/dist/{index-Cp1eA1Xq.js → index-BJnjMyHr.js} +345 -272
- package/dist/index-BJnjMyHr.js.map +1 -0
- package/dist/index-BzmHAEeR.cjs +2 -0
- package/dist/index-BzmHAEeR.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/promises.cjs +1 -1
- package/dist/promises.cjs.map +1 -1
- package/dist/promises.js +2 -2
- package/dist/promises.js.map +1 -1
- package/package.json +1 -1
- package/dist/index-CaEvPIqc.cjs +0 -2
- package/dist/index-CaEvPIqc.cjs.map +0 -1
- package/dist/index-Cp1eA1Xq.js.map +0 -1
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import
|
|
2
|
-
const
|
|
1
|
+
import B, { verify as Y, sign as Z, createVerify as V, createSign as U, createHmac as R, createPrivateKey as C, createPublicKey as N, createSecretKey as w, timingSafeEqual as Q, createHash as H } from "crypto";
|
|
2
|
+
const O = {
|
|
3
3
|
encode: (e) => Buffer.from(e).toString("base64url"),
|
|
4
4
|
decode: (e) => Buffer.from(e, "base64url").toString()
|
|
5
|
-
},
|
|
6
|
-
function
|
|
5
|
+
}, ee = (e, t) => e.length !== t.length ? !1 : Q(Buffer.from(e), Buffer.from(t)), K = /^[A-Za-z0-9_-]+$/;
|
|
6
|
+
function W(e) {
|
|
7
7
|
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
8
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function x(e) {
|
|
10
10
|
return typeof e == "number" && Number.isFinite(e);
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function D(e) {
|
|
13
13
|
return Array.isArray(e) && e.every((t) => typeof t == "string");
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function re(e) {
|
|
16
16
|
const t = [
|
|
17
17
|
{ claim: "iss", valid: e.iss === void 0 || typeof e.iss == "string", expected: "string" },
|
|
18
18
|
{ claim: "sub", valid: e.sub === void 0 || typeof e.sub == "string", expected: "string" },
|
|
19
19
|
{ claim: "jti", valid: e.jti === void 0 || typeof e.jti == "string", expected: "string" },
|
|
20
20
|
{ claim: "sid", valid: e.sid === void 0 || typeof e.sid == "string", expected: "string" },
|
|
21
|
-
{ claim: "iat", valid: e.iat === void 0 ||
|
|
22
|
-
{ claim: "exp", valid: e.exp === void 0 ||
|
|
23
|
-
{ claim: "nbf", valid: e.nbf === void 0 ||
|
|
21
|
+
{ claim: "iat", valid: e.iat === void 0 || x(e.iat), expected: "number" },
|
|
22
|
+
{ claim: "exp", valid: e.exp === void 0 || x(e.exp), expected: "number" },
|
|
23
|
+
{ claim: "nbf", valid: e.nbf === void 0 || x(e.nbf), expected: "number" }
|
|
24
24
|
];
|
|
25
25
|
for (const r of t)
|
|
26
26
|
if (!r.valid)
|
|
@@ -28,27 +28,32 @@ function Q(e) {
|
|
|
28
28
|
reason: `Invalid "${r.claim}" claim: expected ${r.expected}`,
|
|
29
29
|
code: "INVALID_CLAIM"
|
|
30
30
|
};
|
|
31
|
-
return e.aud !== void 0 && !(typeof e.aud == "string" ||
|
|
31
|
+
return e.aud !== void 0 && !(typeof e.aud == "string" || D(e.aud)) ? {
|
|
32
32
|
reason: 'Invalid "aud" claim: expected string or string[]',
|
|
33
33
|
code: "INVALID_CLAIM"
|
|
34
34
|
} : null;
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function te(e) {
|
|
37
37
|
if (e.signatureFormat !== void 0 && e.signatureFormat !== "der" && e.signatureFormat !== "jose")
|
|
38
38
|
return {
|
|
39
39
|
reason: 'Invalid signatureFormat option: expected "der" or "jose"',
|
|
40
40
|
code: "INVALID_OPTIONS"
|
|
41
41
|
};
|
|
42
|
-
if (e.clockSkew !== void 0 && (!
|
|
42
|
+
if (e.clockSkew !== void 0 && (!x(e.clockSkew) || e.clockSkew < 0))
|
|
43
43
|
return {
|
|
44
44
|
reason: "Invalid clockSkew option: expected a non-negative finite number",
|
|
45
45
|
code: "INVALID_OPTIONS"
|
|
46
46
|
};
|
|
47
|
-
if (e.maxTokenAge !== void 0 && (!
|
|
47
|
+
if (e.maxTokenAge !== void 0 && (!x(e.maxTokenAge) || e.maxTokenAge < 0))
|
|
48
48
|
return {
|
|
49
49
|
reason: "Invalid maxTokenAge option: expected a non-negative finite number",
|
|
50
50
|
code: "INVALID_OPTIONS"
|
|
51
51
|
};
|
|
52
|
+
if (e.ignoreExpiration !== void 0 && typeof e.ignoreExpiration != "boolean")
|
|
53
|
+
return {
|
|
54
|
+
reason: "Invalid ignoreExpiration option: expected boolean",
|
|
55
|
+
code: "INVALID_OPTIONS"
|
|
56
|
+
};
|
|
52
57
|
if (e.issuer !== void 0 && typeof e.issuer != "string")
|
|
53
58
|
return {
|
|
54
59
|
reason: "Invalid issuer option: expected string",
|
|
@@ -64,18 +69,18 @@ function ee(e) {
|
|
|
64
69
|
reason: "Invalid jwtId option: expected string",
|
|
65
70
|
code: "INVALID_OPTIONS"
|
|
66
71
|
};
|
|
67
|
-
if (e.audience !== void 0 && !(typeof e.audience == "string" ||
|
|
72
|
+
if (e.audience !== void 0 && !(typeof e.audience == "string" || D(e.audience)))
|
|
68
73
|
return {
|
|
69
74
|
reason: "Invalid audience option: expected string or string[]",
|
|
70
75
|
code: "INVALID_OPTIONS"
|
|
71
76
|
};
|
|
72
77
|
if (e.algorithms !== void 0) {
|
|
73
|
-
if (!Array.isArray(e.algorithms))
|
|
78
|
+
if (!Array.isArray(e.algorithms) || e.algorithms.length === 0)
|
|
74
79
|
return {
|
|
75
|
-
reason: "Invalid algorithms option: expected
|
|
80
|
+
reason: "Invalid algorithms option: expected a non-empty array",
|
|
76
81
|
code: "INVALID_OPTIONS"
|
|
77
82
|
};
|
|
78
|
-
const t = e.algorithms.find((r) => !(r in
|
|
83
|
+
const t = e.algorithms.find((r) => !(r in p));
|
|
79
84
|
if (t)
|
|
80
85
|
return {
|
|
81
86
|
reason: `Invalid algorithms option: unsupported algorithm "${t}"`,
|
|
@@ -84,8 +89,8 @@ function ee(e) {
|
|
|
84
89
|
}
|
|
85
90
|
return null;
|
|
86
91
|
}
|
|
87
|
-
function
|
|
88
|
-
return e.crit !== void 0 ? !
|
|
92
|
+
function ne(e) {
|
|
93
|
+
return e.crit !== void 0 ? !D(e.crit) || e.crit.length === 0 ? {
|
|
89
94
|
reason: 'Invalid "crit" header: expected non-empty string[]',
|
|
90
95
|
code: "INVALID_HEADER"
|
|
91
96
|
} : {
|
|
@@ -93,7 +98,7 @@ function re(e) {
|
|
|
93
98
|
code: "UNSUPPORTED_CRITICAL_HEADER"
|
|
94
99
|
} : null;
|
|
95
100
|
}
|
|
96
|
-
function
|
|
101
|
+
function j(e) {
|
|
97
102
|
switch (e) {
|
|
98
103
|
case "ES256":
|
|
99
104
|
case "ES256K":
|
|
@@ -110,87 +115,87 @@ function C(e) {
|
|
|
110
115
|
throw new Error(`Unsupported ECDSA alg for JOSE conversion: ${e}`);
|
|
111
116
|
}
|
|
112
117
|
}
|
|
113
|
-
function
|
|
118
|
+
function ie(e, t) {
|
|
114
119
|
let r = 0;
|
|
115
120
|
if (e[r++] !== 48) throw new Error("Invalid DER ECDSA signature");
|
|
116
121
|
let n = e[r++];
|
|
117
122
|
if (n & 128) {
|
|
118
123
|
const d = n & 127;
|
|
119
124
|
n = 0;
|
|
120
|
-
for (let
|
|
125
|
+
for (let g = 0; g < d; g++) n = n << 8 | e[r++];
|
|
121
126
|
}
|
|
122
127
|
if (e[r++] !== 2) throw new Error("Invalid DER ECDSA signature (r)");
|
|
123
128
|
const a = e[r++];
|
|
124
|
-
let
|
|
129
|
+
let o = e.subarray(r, r + a);
|
|
125
130
|
if (r += a, e[r++] !== 2) throw new Error("Invalid DER ECDSA signature (s)");
|
|
126
|
-
const
|
|
127
|
-
let
|
|
128
|
-
for (;
|
|
129
|
-
for (;
|
|
130
|
-
const
|
|
131
|
-
return Buffer.concat([
|
|
131
|
+
const i = e[r++];
|
|
132
|
+
let s = e.subarray(r, r + i);
|
|
133
|
+
for (; o.length > t / 2 && o[0] === 0; ) o = o.subarray(1);
|
|
134
|
+
for (; s.length > t / 2 && s[0] === 0; ) s = s.subarray(1);
|
|
135
|
+
const y = Buffer.concat([Buffer.alloc(t / 2 - o.length, 0), o]), f = Buffer.concat([Buffer.alloc(t / 2 - s.length, 0), s]);
|
|
136
|
+
return Buffer.concat([y, f]);
|
|
132
137
|
}
|
|
133
|
-
function
|
|
138
|
+
function L(e) {
|
|
134
139
|
const t = e.length / 2;
|
|
135
140
|
let r = e.subarray(0, t), n = e.subarray(t);
|
|
136
141
|
for (; r.length > 1 && r[0] === 0 && (r[1] & 128) === 0; ) r = r.subarray(1);
|
|
137
142
|
for (; n.length > 1 && n[0] === 0 && (n[1] & 128) === 0; ) n = n.subarray(1);
|
|
138
143
|
r[0] & 128 && (r = Buffer.concat([Buffer.from([0]), r])), n[0] & 128 && (n = Buffer.concat([Buffer.from([0]), n]));
|
|
139
|
-
const a = Buffer.concat([Buffer.from([2, r.length]), r]),
|
|
140
|
-
let
|
|
141
|
-
if (
|
|
142
|
-
|
|
144
|
+
const a = Buffer.concat([Buffer.from([2, r.length]), r]), o = Buffer.concat([Buffer.from([2, n.length]), n]), i = a.length + o.length;
|
|
145
|
+
let s;
|
|
146
|
+
if (i < 128)
|
|
147
|
+
s = Buffer.from([i]);
|
|
143
148
|
else {
|
|
144
|
-
const
|
|
145
|
-
let
|
|
146
|
-
for (;
|
|
147
|
-
|
|
148
|
-
|
|
149
|
+
const y = [];
|
|
150
|
+
let f = i;
|
|
151
|
+
for (; f > 0; )
|
|
152
|
+
y.unshift(f & 255), f >>= 8;
|
|
153
|
+
s = Buffer.from([128 | y.length, ...y]);
|
|
149
154
|
}
|
|
150
|
-
return Buffer.concat([Buffer.from([48]),
|
|
155
|
+
return Buffer.concat([Buffer.from([48]), s, a, o]);
|
|
151
156
|
}
|
|
152
|
-
function
|
|
157
|
+
function k(e) {
|
|
153
158
|
return e === "ES256" || e === "ES384" || e === "ES512" || e === "ES256K";
|
|
154
159
|
}
|
|
155
|
-
const
|
|
156
|
-
sign: (t, r) =>
|
|
160
|
+
const P = (e) => ({
|
|
161
|
+
sign: (t, r) => R(e, r).update(t).digest("base64url"),
|
|
157
162
|
verify: (t, r, n) => {
|
|
158
|
-
const a =
|
|
159
|
-
return
|
|
163
|
+
const a = R(e, r).update(t).digest("base64url");
|
|
164
|
+
return ee(a, n);
|
|
160
165
|
}
|
|
161
|
-
}),
|
|
162
|
-
sign: (t, r) =>
|
|
166
|
+
}), E = (e) => ({
|
|
167
|
+
sign: (t, r) => U(e).update(t).end().sign(r).toString("base64url"),
|
|
163
168
|
verify: (t, r, n) => {
|
|
164
169
|
try {
|
|
165
|
-
return
|
|
170
|
+
return V(e).update(t).end().verify(r, Buffer.from(n, "base64url"));
|
|
166
171
|
} catch {
|
|
167
172
|
return !1;
|
|
168
173
|
}
|
|
169
174
|
}
|
|
170
|
-
}),
|
|
171
|
-
sign: (r, n) =>
|
|
175
|
+
}), _ = (e, t) => ({
|
|
176
|
+
sign: (r, n) => U(e).update(r).end().sign({
|
|
172
177
|
//@ts-ignore
|
|
173
178
|
key: n,
|
|
174
|
-
padding:
|
|
179
|
+
padding: B.constants.RSA_PKCS1_PSS_PADDING,
|
|
175
180
|
saltLength: t
|
|
176
181
|
}).toString("base64url"),
|
|
177
182
|
verify: (r, n, a) => {
|
|
178
183
|
try {
|
|
179
|
-
return
|
|
184
|
+
return V(e).update(r).end().verify({
|
|
180
185
|
//@ts-ignore
|
|
181
186
|
key: n,
|
|
182
|
-
padding:
|
|
187
|
+
padding: B.constants.RSA_PKCS1_PSS_PADDING,
|
|
183
188
|
saltLength: t
|
|
184
189
|
}, Buffer.from(a, "base64url"));
|
|
185
190
|
} catch {
|
|
186
191
|
return !1;
|
|
187
192
|
}
|
|
188
193
|
}
|
|
189
|
-
}),
|
|
190
|
-
sign: (e, t) =>
|
|
194
|
+
}), ae = {
|
|
195
|
+
sign: (e, t) => Z(null, typeof e == "string" ? Buffer.from(e, "utf8") : e, t).toString("base64url"),
|
|
191
196
|
verify: (e, t, r) => {
|
|
192
197
|
try {
|
|
193
|
-
return
|
|
198
|
+
return Y(
|
|
194
199
|
null,
|
|
195
200
|
typeof e == "string" ? Buffer.from(e, "utf8") : e,
|
|
196
201
|
t,
|
|
@@ -200,26 +205,26 @@ const D = (e) => ({
|
|
|
200
205
|
return !1;
|
|
201
206
|
}
|
|
202
207
|
}
|
|
203
|
-
},
|
|
208
|
+
}, p = {
|
|
204
209
|
// HMAC
|
|
205
|
-
HS256:
|
|
206
|
-
HS384:
|
|
207
|
-
HS512:
|
|
210
|
+
HS256: P("sha256"),
|
|
211
|
+
HS384: P("sha384"),
|
|
212
|
+
HS512: P("sha512"),
|
|
208
213
|
// RSA (DER-encoded signatures, base64url)
|
|
209
|
-
RS256:
|
|
210
|
-
RS384:
|
|
211
|
-
RS512:
|
|
214
|
+
RS256: E("RSA-SHA256"),
|
|
215
|
+
RS384: E("RSA-SHA384"),
|
|
216
|
+
RS512: E("RSA-SHA512"),
|
|
212
217
|
// ECDSA (Node/OpenSSL emits DER; sign() converts to JOSE by default for JWTs)
|
|
213
|
-
ES256:
|
|
214
|
-
ES384:
|
|
215
|
-
ES512:
|
|
216
|
-
ES256K:
|
|
217
|
-
PS256:
|
|
218
|
-
PS384:
|
|
219
|
-
PS512:
|
|
220
|
-
EdDSA:
|
|
221
|
-
},
|
|
222
|
-
function
|
|
218
|
+
ES256: E("SHA256"),
|
|
219
|
+
ES384: E("SHA384"),
|
|
220
|
+
ES512: E("SHA512"),
|
|
221
|
+
ES256K: E("SHA256"),
|
|
222
|
+
PS256: _("RSA-SHA256", 32),
|
|
223
|
+
PS384: _("RSA-SHA384", 48),
|
|
224
|
+
PS512: _("RSA-SHA512", 64),
|
|
225
|
+
EdDSA: ae
|
|
226
|
+
}, ge = Object.keys(p);
|
|
227
|
+
function se(e) {
|
|
223
228
|
if (e.type === "secret") return "HS256";
|
|
224
229
|
if (e.type !== "private") throw new Error("Only private or symmetric keys can be used to sign JWTs");
|
|
225
230
|
const t = e.asymmetricKeyType, r = e.asymmetricKeyDetails;
|
|
@@ -263,57 +268,105 @@ function ie(e) {
|
|
|
263
268
|
throw new Error(`Unsupported asymmetric key type: ${t}`);
|
|
264
269
|
}
|
|
265
270
|
}
|
|
266
|
-
function
|
|
271
|
+
function M(e, t) {
|
|
267
272
|
if (typeof e == "object" && "type" in e) return e;
|
|
268
273
|
try {
|
|
269
|
-
return
|
|
274
|
+
return t === "sign" ? C(e) : N(e);
|
|
270
275
|
} catch {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
276
|
+
if (t === "sign") {
|
|
277
|
+
try {
|
|
278
|
+
N(e);
|
|
279
|
+
} catch {
|
|
280
|
+
if (typeof e == "string") return w(Buffer.from(e, "utf8"));
|
|
281
|
+
if (Buffer.isBuffer(e)) return w(e);
|
|
282
|
+
throw new Error("Unsupported key type");
|
|
283
|
+
}
|
|
284
|
+
throw new Error("A public key cannot be used to sign JWTs");
|
|
285
|
+
}
|
|
286
|
+
if (typeof e == "string") return w(Buffer.from(e, "utf8"));
|
|
287
|
+
if (Buffer.isBuffer(e)) return w(e);
|
|
288
|
+
throw new Error("Unsupported key type");
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
function q(e, t, r) {
|
|
292
|
+
var a;
|
|
293
|
+
if (t.startsWith("HS")) {
|
|
294
|
+
if (e.type !== "secret") throw new Error(`${t} requires a symmetric secret key`);
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
if (r === "sign" && e.type !== "private")
|
|
298
|
+
throw new Error(`${t} requires a private key for signing`);
|
|
299
|
+
if (r === "verify" && e.type !== "public" && e.type !== "private")
|
|
300
|
+
throw new Error(`${t} requires a public or private key for verification`);
|
|
301
|
+
const n = e.asymmetricKeyType;
|
|
302
|
+
if (t.startsWith("RS") && n !== "rsa")
|
|
303
|
+
throw new Error(`${t} requires an RSA key`);
|
|
304
|
+
if (t.startsWith("PS") && n !== "rsa" && n !== "rsa-pss")
|
|
305
|
+
throw new Error(`${t} requires an RSA or RSA-PSS key`);
|
|
306
|
+
if (t === "EdDSA" && n !== "ed25519")
|
|
307
|
+
throw new Error("EdDSA requires an Ed25519 key");
|
|
308
|
+
if (k(t)) {
|
|
309
|
+
const o = (a = e.asymmetricKeyDetails) == null ? void 0 : a.namedCurve;
|
|
310
|
+
let i = [];
|
|
311
|
+
switch (t) {
|
|
312
|
+
case "ES256":
|
|
313
|
+
i = ["P-256", "prime256v1"];
|
|
314
|
+
break;
|
|
315
|
+
case "ES384":
|
|
316
|
+
i = ["P-384", "secp384r1"];
|
|
317
|
+
break;
|
|
318
|
+
case "ES512":
|
|
319
|
+
i = ["P-521", "secp521r1"];
|
|
320
|
+
break;
|
|
321
|
+
case "ES256K":
|
|
322
|
+
i = ["secp256k1"];
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
if (n !== "ec" || !i.includes(o ?? ""))
|
|
326
|
+
throw new Error(`${t} requires its matching EC curve`);
|
|
275
327
|
}
|
|
276
328
|
}
|
|
277
|
-
const
|
|
329
|
+
const F = (e) => {
|
|
278
330
|
const t = e.split(".");
|
|
279
331
|
if (t.length !== 3)
|
|
280
332
|
throw new Error('Invalid JWT: must contain exactly 3 parts separated by "."');
|
|
281
333
|
const [r, n, a] = t;
|
|
282
334
|
if (!r || !n || !a)
|
|
283
335
|
throw new Error("Invalid JWT: empty part detected");
|
|
284
|
-
if (!
|
|
336
|
+
if (!K.test(r) || !K.test(n) || !K.test(a))
|
|
285
337
|
throw new Error("Invalid JWT: non-base64url characters detected");
|
|
286
338
|
try {
|
|
287
|
-
const
|
|
288
|
-
if (
|
|
339
|
+
const o = JSON.parse(O.decode(r)), i = JSON.parse(O.decode(n));
|
|
340
|
+
if (!W(o) || !W(i))
|
|
289
341
|
throw new Error("header and payload must be JSON objects");
|
|
290
|
-
const
|
|
291
|
-
if (typeof
|
|
342
|
+
const s = o, y = i;
|
|
343
|
+
if (typeof s.alg != "string" || s.alg.length === 0)
|
|
292
344
|
throw new Error("header.alg must be a non-empty string");
|
|
293
|
-
if (
|
|
345
|
+
if (s.typ !== void 0 && typeof s.typ != "string")
|
|
294
346
|
throw new Error("header.typ must be a string");
|
|
295
|
-
if (
|
|
347
|
+
if (s.kid !== void 0 && typeof s.kid != "string")
|
|
296
348
|
throw new Error("header.kid must be a string");
|
|
297
|
-
if (
|
|
349
|
+
if (s.crit !== void 0 && (!D(s.crit) || s.crit.length === 0))
|
|
298
350
|
throw new Error("header.crit must be a non-empty string[]");
|
|
299
|
-
return { header:
|
|
300
|
-
} catch (
|
|
301
|
-
throw new Error(`Invalid JWT: malformed header or payload (${
|
|
302
|
-
}
|
|
303
|
-
}, se = (e, t, r = {}) => {
|
|
304
|
-
const n = ae(t), a = r.alg ?? ie(n), c = r.signatureFormat ?? (K(a) ? "jose" : "der"), s = r.typ ?? "JWT";
|
|
305
|
-
if (!(a in v)) throw new Error(`Unsupported algorithm: ${a}`);
|
|
306
|
-
const i = { alg: a, typ: s };
|
|
307
|
-
r.kid && (i.kid = r.kid);
|
|
308
|
-
const g = x.encode(JSON.stringify(i)), u = x.encode(JSON.stringify(e)), d = `${g}.${u}`;
|
|
309
|
-
let y = v[a].sign(d, t);
|
|
310
|
-
if (c === "jose" && K(a)) {
|
|
311
|
-
const b = Buffer.from(y, "base64url");
|
|
312
|
-
y = te(b, C(a)).toString("base64url");
|
|
351
|
+
return { header: s, payload: y, signature: a };
|
|
352
|
+
} catch (o) {
|
|
353
|
+
throw new Error(`Invalid JWT: malformed header or payload (${o.message})`);
|
|
313
354
|
}
|
|
314
|
-
return `${g}.${u}.${y}`;
|
|
315
355
|
}, oe = (e, t, r = {}) => {
|
|
316
|
-
const n =
|
|
356
|
+
const n = M(t, "sign"), a = r.alg ?? se(n), o = r.signatureFormat ?? (k(a) ? "jose" : "der"), i = r.typ ?? "JWT";
|
|
357
|
+
if (!(a in p)) throw new Error(`Unsupported algorithm: ${a}`);
|
|
358
|
+
q(n, a, "sign");
|
|
359
|
+
const s = { alg: a, typ: i };
|
|
360
|
+
r.kid && (s.kid = r.kid);
|
|
361
|
+
const y = O.encode(JSON.stringify(s)), f = O.encode(JSON.stringify(e)), d = `${y}.${f}`;
|
|
362
|
+
let g = p[a].sign(d, n);
|
|
363
|
+
if (o === "jose" && k(a)) {
|
|
364
|
+
const A = Buffer.from(g, "base64url");
|
|
365
|
+
g = ie(A, j(a)).toString("base64url");
|
|
366
|
+
}
|
|
367
|
+
return `${y}.${f}.${g}`;
|
|
368
|
+
}, ce = (e, t, r = {}) => {
|
|
369
|
+
const n = te(r);
|
|
317
370
|
if (n)
|
|
318
371
|
return {
|
|
319
372
|
valid: !1,
|
|
@@ -321,34 +374,34 @@ const M = (e) => {
|
|
|
321
374
|
};
|
|
322
375
|
let a;
|
|
323
376
|
try {
|
|
324
|
-
a =
|
|
325
|
-
} catch (
|
|
377
|
+
a = F(e);
|
|
378
|
+
} catch (c) {
|
|
326
379
|
return {
|
|
327
380
|
valid: !1,
|
|
328
381
|
error: {
|
|
329
|
-
reason:
|
|
382
|
+
reason: c.message,
|
|
330
383
|
code: "INVALID_TOKEN"
|
|
331
384
|
}
|
|
332
385
|
};
|
|
333
386
|
}
|
|
334
|
-
const { header:
|
|
335
|
-
if (
|
|
387
|
+
const { header: o, payload: i, signature: s } = a, y = ne(o);
|
|
388
|
+
if (y)
|
|
336
389
|
return {
|
|
337
390
|
valid: !1,
|
|
338
|
-
error:
|
|
391
|
+
error: y
|
|
339
392
|
};
|
|
340
|
-
const
|
|
341
|
-
if (
|
|
393
|
+
const f = re(i);
|
|
394
|
+
if (f)
|
|
342
395
|
return {
|
|
343
396
|
valid: !1,
|
|
344
|
-
error:
|
|
397
|
+
error: f
|
|
345
398
|
};
|
|
346
|
-
const d =
|
|
347
|
-
if (!(d in
|
|
399
|
+
const d = o.alg;
|
|
400
|
+
if (!(d in p))
|
|
348
401
|
return {
|
|
349
402
|
valid: !1,
|
|
350
403
|
error: {
|
|
351
|
-
reason: `Unsupported or unknown algorithm: ${
|
|
404
|
+
reason: `Unsupported or unknown algorithm: ${o.alg}`,
|
|
352
405
|
code: "INVALID_ALGORITHM"
|
|
353
406
|
}
|
|
354
407
|
};
|
|
@@ -360,50 +413,62 @@ const M = (e) => {
|
|
|
360
413
|
code: "ALGORITHM_NOT_ALLOWED"
|
|
361
414
|
}
|
|
362
415
|
};
|
|
363
|
-
if (
|
|
416
|
+
if (o.typ !== void 0 && o.typ !== "JWT")
|
|
364
417
|
return {
|
|
365
418
|
valid: !1,
|
|
366
419
|
error: {
|
|
367
|
-
reason: `Invalid token type: expected 'JWT', got '${
|
|
420
|
+
reason: `Invalid token type: expected 'JWT', got '${o.typ}'`,
|
|
368
421
|
code: "INVALID_TYPE"
|
|
369
422
|
}
|
|
370
423
|
};
|
|
371
|
-
const [
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
424
|
+
const [g, A] = e.split("."), I = `${g}.${A}`;
|
|
425
|
+
let m;
|
|
426
|
+
try {
|
|
427
|
+
m = M(t, "verify"), q(m, d, "verify");
|
|
428
|
+
} catch (c) {
|
|
429
|
+
return {
|
|
430
|
+
valid: !1,
|
|
431
|
+
error: {
|
|
432
|
+
reason: c.message,
|
|
433
|
+
code: "KEY_ALGORITHM_MISMATCH"
|
|
434
|
+
}
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
if (k(d)) {
|
|
438
|
+
const c = r.signatureFormat;
|
|
439
|
+
let l;
|
|
440
|
+
if (c === "jose")
|
|
376
441
|
try {
|
|
377
|
-
const
|
|
378
|
-
|
|
442
|
+
const v = Buffer.from(s, "base64url"), S = L(v).toString("base64url");
|
|
443
|
+
l = p[d].verify(I, m, S);
|
|
379
444
|
} catch {
|
|
380
|
-
|
|
445
|
+
l = !1;
|
|
381
446
|
}
|
|
382
|
-
else if (
|
|
383
|
-
|
|
384
|
-
else if (
|
|
447
|
+
else if (c === "der")
|
|
448
|
+
l = p[d].verify(I, m, s);
|
|
449
|
+
else if (l = p[d].verify(I, m, s), !l)
|
|
385
450
|
try {
|
|
386
|
-
const
|
|
387
|
-
if (
|
|
388
|
-
const
|
|
389
|
-
|
|
451
|
+
const v = Buffer.from(s, "base64url");
|
|
452
|
+
if (v.length === j(d)) {
|
|
453
|
+
const S = L(v).toString("base64url");
|
|
454
|
+
l = p[d].verify(I, m, S);
|
|
390
455
|
}
|
|
391
456
|
} catch {
|
|
392
457
|
}
|
|
393
|
-
if (!
|
|
458
|
+
if (!l)
|
|
394
459
|
return { valid: !1, error: { reason: "Signature verification failed", code: "INVALID_SIGNATURE" } };
|
|
395
460
|
} else {
|
|
396
|
-
let
|
|
461
|
+
let c = !1;
|
|
397
462
|
try {
|
|
398
|
-
|
|
463
|
+
c = p[d].verify(I, m, s);
|
|
399
464
|
} catch {
|
|
400
|
-
|
|
465
|
+
c = !1;
|
|
401
466
|
}
|
|
402
|
-
if (!
|
|
467
|
+
if (!c)
|
|
403
468
|
return { valid: !1, error: { reason: "Signature verification failed", code: "INVALID_SIGNATURE" } };
|
|
404
469
|
}
|
|
405
|
-
const
|
|
406
|
-
if (!r.ignoreExpiration &&
|
|
470
|
+
const h = Math.floor(Date.now() / 1e3), u = r.clockSkew ?? 0;
|
|
471
|
+
if (!r.ignoreExpiration && i.exp !== void 0 && h > i.exp + u)
|
|
407
472
|
return {
|
|
408
473
|
valid: !1,
|
|
409
474
|
error: {
|
|
@@ -411,7 +476,7 @@ const M = (e) => {
|
|
|
411
476
|
code: "TOKEN_EXPIRED"
|
|
412
477
|
}
|
|
413
478
|
};
|
|
414
|
-
if (
|
|
479
|
+
if (i.nbf !== void 0 && h + u < i.nbf)
|
|
415
480
|
return {
|
|
416
481
|
valid: !1,
|
|
417
482
|
error: {
|
|
@@ -419,7 +484,7 @@ const M = (e) => {
|
|
|
419
484
|
code: "TOKEN_NOT_ACTIVE"
|
|
420
485
|
}
|
|
421
486
|
};
|
|
422
|
-
if (
|
|
487
|
+
if (i.iat !== void 0 && h + u < i.iat)
|
|
423
488
|
return {
|
|
424
489
|
valid: !1,
|
|
425
490
|
error: {
|
|
@@ -427,19 +492,27 @@ const M = (e) => {
|
|
|
427
492
|
code: "TOKEN_FUTURE_ISSUED"
|
|
428
493
|
}
|
|
429
494
|
};
|
|
430
|
-
if (r.maxTokenAge !== void 0 &&
|
|
431
|
-
|
|
432
|
-
|
|
495
|
+
if (r.maxTokenAge !== void 0 && i.iat === void 0)
|
|
496
|
+
return {
|
|
497
|
+
valid: !1,
|
|
498
|
+
error: {
|
|
499
|
+
reason: 'Token missing required issued-at claim ("iat")',
|
|
500
|
+
code: "MISSING_IAT"
|
|
501
|
+
}
|
|
502
|
+
};
|
|
503
|
+
if (r.maxTokenAge !== void 0 && i.iat !== void 0) {
|
|
504
|
+
const c = h - i.iat;
|
|
505
|
+
if (c > r.maxTokenAge)
|
|
433
506
|
return {
|
|
434
507
|
valid: !1,
|
|
435
508
|
error: {
|
|
436
|
-
reason: `Token age (${
|
|
509
|
+
reason: `Token age (${c}s) exceeds maximum allowed age (${r.maxTokenAge}s)`,
|
|
437
510
|
code: "TOKEN_TOO_OLD"
|
|
438
511
|
}
|
|
439
512
|
};
|
|
440
513
|
}
|
|
441
514
|
if (r.issuer !== void 0) {
|
|
442
|
-
if (
|
|
515
|
+
if (i.iss === void 0)
|
|
443
516
|
return {
|
|
444
517
|
valid: !1,
|
|
445
518
|
error: {
|
|
@@ -447,17 +520,17 @@ const M = (e) => {
|
|
|
447
520
|
code: "MISSING_ISSUER"
|
|
448
521
|
}
|
|
449
522
|
};
|
|
450
|
-
if (r.issuer !==
|
|
523
|
+
if (r.issuer !== i.iss)
|
|
451
524
|
return {
|
|
452
525
|
valid: !1,
|
|
453
526
|
error: {
|
|
454
|
-
reason: `Invalid token issuer: expected "${r.issuer}", got "${
|
|
527
|
+
reason: `Invalid token issuer: expected "${r.issuer}", got "${i.iss}"`,
|
|
455
528
|
code: "INVALID_ISSUER"
|
|
456
529
|
}
|
|
457
530
|
};
|
|
458
531
|
}
|
|
459
532
|
if (r.subject !== void 0) {
|
|
460
|
-
if (
|
|
533
|
+
if (i.sub === void 0)
|
|
461
534
|
return {
|
|
462
535
|
valid: !1,
|
|
463
536
|
error: {
|
|
@@ -465,18 +538,18 @@ const M = (e) => {
|
|
|
465
538
|
code: "MISSING_SUBJECT"
|
|
466
539
|
}
|
|
467
540
|
};
|
|
468
|
-
if (r.subject !==
|
|
541
|
+
if (r.subject !== i.sub)
|
|
469
542
|
return {
|
|
470
543
|
valid: !1,
|
|
471
544
|
error: {
|
|
472
|
-
reason: `Invalid token subject: expected "${r.subject}", got "${
|
|
545
|
+
reason: `Invalid token subject: expected "${r.subject}", got "${i.sub}"`,
|
|
473
546
|
code: "INVALID_SUBJECT"
|
|
474
547
|
}
|
|
475
548
|
};
|
|
476
549
|
}
|
|
477
550
|
if (r.audience !== void 0) {
|
|
478
|
-
const
|
|
479
|
-
if (
|
|
551
|
+
const c = i.aud;
|
|
552
|
+
if (c === void 0)
|
|
480
553
|
return {
|
|
481
554
|
valid: !1,
|
|
482
555
|
error: {
|
|
@@ -484,8 +557,8 @@ const M = (e) => {
|
|
|
484
557
|
code: "MISSING_AUDIENCE"
|
|
485
558
|
}
|
|
486
559
|
};
|
|
487
|
-
const
|
|
488
|
-
if (!
|
|
560
|
+
const l = Array.isArray(r.audience) ? r.audience : [r.audience], v = Array.isArray(c) ? c : [c];
|
|
561
|
+
if (!l.some((b) => v.includes(b)))
|
|
489
562
|
return {
|
|
490
563
|
valid: !1,
|
|
491
564
|
error: {
|
|
@@ -495,7 +568,7 @@ const M = (e) => {
|
|
|
495
568
|
};
|
|
496
569
|
}
|
|
497
570
|
if (r.jwtId !== void 0) {
|
|
498
|
-
if (
|
|
571
|
+
if (i.jti === void 0)
|
|
499
572
|
return {
|
|
500
573
|
valid: !1,
|
|
501
574
|
error: {
|
|
@@ -503,49 +576,49 @@ const M = (e) => {
|
|
|
503
576
|
code: "MISSING_JTI"
|
|
504
577
|
}
|
|
505
578
|
};
|
|
506
|
-
if (r.jwtId !==
|
|
579
|
+
if (r.jwtId !== i.jti)
|
|
507
580
|
return {
|
|
508
581
|
valid: !1,
|
|
509
582
|
error: {
|
|
510
|
-
reason: `Invalid JWT ID: expected "${r.jwtId}", got "${
|
|
583
|
+
reason: `Invalid JWT ID: expected "${r.jwtId}", got "${i.jti}"`,
|
|
511
584
|
code: "INVALID_JTI"
|
|
512
585
|
}
|
|
513
586
|
};
|
|
514
587
|
}
|
|
515
|
-
return { valid: !0, header:
|
|
516
|
-
},
|
|
517
|
-
sign:
|
|
518
|
-
verify:
|
|
519
|
-
decode:
|
|
520
|
-
algorithms:
|
|
588
|
+
return { valid: !0, header: o, payload: i, signature: s };
|
|
589
|
+
}, me = {
|
|
590
|
+
sign: oe,
|
|
591
|
+
verify: ce,
|
|
592
|
+
decode: F,
|
|
593
|
+
algorithms: p
|
|
521
594
|
};
|
|
522
|
-
function
|
|
595
|
+
function fe(e) {
|
|
523
596
|
if (!e || typeof e != "object") throw new Error("Invalid KeyObject");
|
|
524
597
|
return e.export({ format: "jwk" });
|
|
525
598
|
}
|
|
526
|
-
function
|
|
599
|
+
function $(e) {
|
|
527
600
|
if (!e || typeof e != "object") throw new Error("Invalid JWK");
|
|
528
601
|
switch (e.kty) {
|
|
529
602
|
case "oct": {
|
|
530
603
|
if (!("k" in e) || typeof e.k != "string")
|
|
531
604
|
throw new Error('Invalid oct JWK: missing "k"');
|
|
532
|
-
return
|
|
605
|
+
return w(Buffer.from(e.k, "base64url"));
|
|
533
606
|
}
|
|
534
607
|
case "RSA":
|
|
535
608
|
case "EC":
|
|
536
609
|
case "OKP":
|
|
537
|
-
return "d" in e && typeof e.d == "string" ?
|
|
610
|
+
return "d" in e && typeof e.d == "string" ? C({ format: "jwk", key: e }) : N({ format: "jwk", key: e });
|
|
538
611
|
default:
|
|
539
612
|
throw new Error(`Unsupported JWK key type: ${e.kty}`);
|
|
540
613
|
}
|
|
541
614
|
}
|
|
542
|
-
function
|
|
615
|
+
function ue(e) {
|
|
543
616
|
if (!e || typeof e != "object")
|
|
544
617
|
throw new Error("Invalid KeyObject");
|
|
545
|
-
const r = (e.type === "private" ?
|
|
618
|
+
const r = (e.type === "private" ? N(e) : e).export({ format: "jwk" });
|
|
546
619
|
return delete r.d, delete r.p, delete r.q, delete r.dp, delete r.dq, delete r.qi, r;
|
|
547
620
|
}
|
|
548
|
-
function
|
|
621
|
+
function G(e, t = "sha256") {
|
|
549
622
|
if (!e || typeof e != "object")
|
|
550
623
|
throw new Error("Invalid JWK");
|
|
551
624
|
let r;
|
|
@@ -566,165 +639,165 @@ function F(e, t = "sha256") {
|
|
|
566
639
|
throw new Error(`Unsupported JWK key type: ${e.kty}`);
|
|
567
640
|
}
|
|
568
641
|
const n = JSON.stringify(
|
|
569
|
-
Object.keys(r).sort().reduce((a,
|
|
642
|
+
Object.keys(r).sort().reduce((a, o) => (a[o] = r[o], a), {})
|
|
570
643
|
);
|
|
571
|
-
return
|
|
644
|
+
return H(t).update(n).digest("base64url");
|
|
572
645
|
}
|
|
573
|
-
function
|
|
646
|
+
function de(e) {
|
|
574
647
|
var t;
|
|
575
648
|
if ((t = e.x5c) != null && t.length)
|
|
576
|
-
return
|
|
649
|
+
return H("sha1").update(Buffer.from(e.x5c[0], "base64")).digest("base64url");
|
|
577
650
|
}
|
|
578
|
-
const
|
|
579
|
-
export:
|
|
580
|
-
import:
|
|
581
|
-
toPublic:
|
|
582
|
-
thumbprint:
|
|
651
|
+
const ve = {
|
|
652
|
+
export: fe,
|
|
653
|
+
import: $,
|
|
654
|
+
toPublic: ue,
|
|
655
|
+
thumbprint: G
|
|
583
656
|
};
|
|
584
|
-
function
|
|
657
|
+
function le(e, t) {
|
|
585
658
|
if (!e || !Array.isArray(e.keys)) throw new Error("Invalid JWKS");
|
|
586
659
|
let r;
|
|
587
660
|
if (t && (r = e.keys.find((n) => n.kid === t)), !r && e.keys.length === 1 && (r = e.keys[0]), !r) throw new Error("Key not found in JWKS");
|
|
588
|
-
return
|
|
661
|
+
return $(r);
|
|
589
662
|
}
|
|
590
|
-
function
|
|
663
|
+
function J(e) {
|
|
591
664
|
return {
|
|
592
|
-
keys:
|
|
665
|
+
keys: T(...e.keys)
|
|
593
666
|
};
|
|
594
667
|
}
|
|
595
|
-
function
|
|
668
|
+
function T(...e) {
|
|
596
669
|
return e.map((t) => {
|
|
597
670
|
const r = {
|
|
598
671
|
...t,
|
|
599
|
-
kid: t.kid ??
|
|
600
|
-
x5t: t.x5t ??
|
|
672
|
+
kid: t.kid ?? G(t),
|
|
673
|
+
x5t: t.x5t ?? de(t)
|
|
601
674
|
};
|
|
602
675
|
return Object.defineProperty(r, "toKeyObject", {
|
|
603
676
|
enumerable: !1,
|
|
604
677
|
configurable: !1,
|
|
605
678
|
writable: !1,
|
|
606
|
-
value: () =>
|
|
679
|
+
value: () => $(r)
|
|
607
680
|
}), r;
|
|
608
681
|
});
|
|
609
682
|
}
|
|
610
|
-
const
|
|
611
|
-
const r = typeof e == "string" ? e : e.toString(), n = t.fetch ?? globalThis.fetch, a = Math.max(0, t.ttl ?? 5 * 6e4),
|
|
683
|
+
const he = async (e, t = {}) => {
|
|
684
|
+
const r = typeof e == "string" ? e : e.toString(), n = t.fetch ?? globalThis.fetch, a = Math.max(0, t.ttl ?? 5 * 6e4), o = Math.max(0, t.timeoutMs ?? 5e3), i = "/.well-known/jwks.json";
|
|
612
685
|
if (!n)
|
|
613
686
|
throw new Error("No fetch implementation available");
|
|
614
|
-
const
|
|
687
|
+
const s = (() => {
|
|
615
688
|
if (t.endpointOverride) {
|
|
616
|
-
const
|
|
689
|
+
const h = t.endpointOverride;
|
|
617
690
|
try {
|
|
618
|
-
return new URL(
|
|
691
|
+
return new URL(h, r).toString();
|
|
619
692
|
} catch {
|
|
620
|
-
return
|
|
693
|
+
return h;
|
|
621
694
|
}
|
|
622
695
|
}
|
|
623
|
-
return t.overrideEndpointCheck || r.endsWith(
|
|
624
|
-
})(),
|
|
696
|
+
return t.overrideEndpointCheck || r.endsWith(i) ? r : `${r.replace(/\/+$/, "")}${i}`;
|
|
697
|
+
})(), y = (() => {
|
|
625
698
|
if (t.cache) return t.cache;
|
|
626
|
-
let
|
|
699
|
+
let h;
|
|
627
700
|
return {
|
|
628
|
-
get: () =>
|
|
629
|
-
set: (
|
|
630
|
-
|
|
701
|
+
get: () => h,
|
|
702
|
+
set: (u, c) => {
|
|
703
|
+
h = c;
|
|
631
704
|
}
|
|
632
705
|
};
|
|
633
706
|
})();
|
|
634
|
-
let
|
|
635
|
-
const
|
|
636
|
-
if (
|
|
637
|
-
|
|
638
|
-
const
|
|
639
|
-
let
|
|
640
|
-
|
|
641
|
-
let
|
|
707
|
+
let f, d = 0, g, A = 0;
|
|
708
|
+
const I = async (h) => {
|
|
709
|
+
if (g) return g;
|
|
710
|
+
g = (async () => {
|
|
711
|
+
const u = new AbortController();
|
|
712
|
+
let c;
|
|
713
|
+
o > 0 && (c = setTimeout(() => u.abort(), o));
|
|
714
|
+
let l;
|
|
642
715
|
try {
|
|
643
|
-
|
|
644
|
-
} catch (
|
|
645
|
-
throw
|
|
716
|
+
l = await n(s, { signal: u.signal });
|
|
717
|
+
} catch (S) {
|
|
718
|
+
throw u.signal.aborted ? new Error(`JWKS fetch timed out after ${o}ms`) : S;
|
|
646
719
|
} finally {
|
|
647
|
-
|
|
720
|
+
c && clearTimeout(c);
|
|
648
721
|
}
|
|
649
|
-
if (!
|
|
650
|
-
throw new Error(`Failed to fetch JWKS: ${
|
|
651
|
-
const
|
|
652
|
-
if (!
|
|
722
|
+
if (!l.ok)
|
|
723
|
+
throw new Error(`Failed to fetch JWKS: ${l.status} ${l.statusText}`);
|
|
724
|
+
const v = await l.json();
|
|
725
|
+
if (!v || typeof v != "object" || !Array.isArray(v.keys))
|
|
653
726
|
throw new Error("Invalid JWKS");
|
|
654
|
-
return
|
|
727
|
+
return J(v);
|
|
655
728
|
})();
|
|
656
729
|
try {
|
|
657
|
-
const
|
|
658
|
-
return
|
|
659
|
-
} catch (
|
|
660
|
-
if (!
|
|
661
|
-
throw
|
|
662
|
-
if (
|
|
663
|
-
const
|
|
664
|
-
Math.max(a, 3e4) * Math.pow(2,
|
|
730
|
+
const u = await g;
|
|
731
|
+
return f = u, await y.set(s, u), A = 0, a > 0 && (d = Date.now() + a), u;
|
|
732
|
+
} catch (u) {
|
|
733
|
+
if (!h || !f)
|
|
734
|
+
throw u;
|
|
735
|
+
if (A += 1, a > 0) {
|
|
736
|
+
const c = Math.min(
|
|
737
|
+
Math.max(a, 3e4) * Math.pow(2, A - 1),
|
|
665
738
|
9e5
|
|
666
739
|
);
|
|
667
|
-
d = Date.now() +
|
|
740
|
+
d = Date.now() + c;
|
|
668
741
|
}
|
|
669
|
-
return console.warn(`JWKS refresh failed for "${
|
|
742
|
+
return console.warn(`JWKS refresh failed for "${s}", using stale cache.`, u), f;
|
|
670
743
|
} finally {
|
|
671
|
-
|
|
744
|
+
g = void 0;
|
|
672
745
|
}
|
|
673
746
|
};
|
|
674
|
-
|
|
675
|
-
const
|
|
747
|
+
f = await y.get(s), f ? (f = J(f), a > 0 && (d = Date.now() + a)) : f = await I(!1);
|
|
748
|
+
const m = {
|
|
676
749
|
async list() {
|
|
677
|
-
return a > 0 && Date.now() >= d && await
|
|
750
|
+
return a > 0 && Date.now() >= d && await I(!0), T(...f.keys);
|
|
678
751
|
},
|
|
679
752
|
async refresh() {
|
|
680
|
-
return await
|
|
753
|
+
return await I(!1), m;
|
|
681
754
|
},
|
|
682
|
-
async key(
|
|
683
|
-
const
|
|
684
|
-
if (
|
|
685
|
-
return
|
|
755
|
+
async key(h) {
|
|
756
|
+
const c = (await m.list()).find((l) => l.kid === h);
|
|
757
|
+
if (c)
|
|
758
|
+
return T(c)[0];
|
|
686
759
|
},
|
|
687
|
-
async find(
|
|
688
|
-
const
|
|
689
|
-
return
|
|
690
|
-
(
|
|
691
|
-
const
|
|
692
|
-
return Array.isArray(
|
|
760
|
+
async find(h) {
|
|
761
|
+
const u = await m.list(), c = Object.entries(h);
|
|
762
|
+
return c.length === 0 ? T(...u) : T(...u.filter(
|
|
763
|
+
(l) => c.every(([v, S]) => {
|
|
764
|
+
const b = l[v];
|
|
765
|
+
return Array.isArray(S) ? Array.isArray(b) && b.length === S.length && b.every((z, X) => z === S[X]) : b === S;
|
|
693
766
|
})
|
|
694
767
|
));
|
|
695
768
|
},
|
|
696
|
-
async findFirst(
|
|
697
|
-
return
|
|
769
|
+
async findFirst(h) {
|
|
770
|
+
return m.find(h).then(([u]) => u);
|
|
698
771
|
},
|
|
699
772
|
export() {
|
|
700
|
-
return
|
|
773
|
+
return f;
|
|
701
774
|
}
|
|
702
775
|
};
|
|
703
|
-
return
|
|
704
|
-
},
|
|
705
|
-
toKeyObject:
|
|
706
|
-
normalize:
|
|
707
|
-
fromWeb:
|
|
776
|
+
return m;
|
|
777
|
+
}, Se = {
|
|
778
|
+
toKeyObject: le,
|
|
779
|
+
normalize: J,
|
|
780
|
+
fromWeb: he
|
|
708
781
|
};
|
|
709
782
|
export {
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
783
|
+
se as A,
|
|
784
|
+
ve as J,
|
|
785
|
+
p as S,
|
|
786
|
+
Se as a,
|
|
787
|
+
le as b,
|
|
788
|
+
me as c,
|
|
789
|
+
ge as d,
|
|
790
|
+
O as e,
|
|
791
|
+
de as f,
|
|
792
|
+
F as g,
|
|
793
|
+
fe as h,
|
|
794
|
+
he as i,
|
|
795
|
+
G as j,
|
|
796
|
+
$ as k,
|
|
797
|
+
J as l,
|
|
798
|
+
T as n,
|
|
799
|
+
oe as s,
|
|
800
|
+
ue as t,
|
|
801
|
+
ce as v
|
|
729
802
|
};
|
|
730
|
-
//# sourceMappingURL=index-
|
|
803
|
+
//# sourceMappingURL=index-BJnjMyHr.js.map
|