@versini/auth-common 4.3.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +35 -2
- package/dist/index.js +188 -175
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -103,7 +103,7 @@ type ScopesGrants = {
|
|
|
103
103
|
[key: string]: string[];
|
|
104
104
|
} | string[];
|
|
105
105
|
/**
|
|
106
|
-
* Checks if the given token grants the required scopes.
|
|
106
|
+
* Checks if the given encoded access token grants the required scopes.
|
|
107
107
|
*
|
|
108
108
|
* This function verifies the provided token and extracts its payload.
|
|
109
109
|
* It then checks if the token contains the required scopes. The scopes can be provided
|
|
@@ -137,6 +137,39 @@ type ScopesGrants = {
|
|
|
137
137
|
* console.log(res); // true if the token has either "read" and "write" scopes or "read" scope
|
|
138
138
|
*/
|
|
139
139
|
declare const isGranted: (token: string, scopes: ScopesGrants) => Promise<boolean>;
|
|
140
|
+
/**
|
|
141
|
+
* Checks if the given non-encoded id token grants the required scopes.
|
|
142
|
+
*
|
|
143
|
+
* This function does not verify the token, it simply extracts its payload.
|
|
144
|
+
* It then checks if the token contains the required scopes. The scopes can be provided
|
|
145
|
+
* either as an array of strings or as a map of string arrays. When the scopes are provided
|
|
146
|
+
* as a map, the function checks if the token contains at least one of the scopes in each
|
|
147
|
+
* of the map's values (OR operation).
|
|
148
|
+
*
|
|
149
|
+
*
|
|
150
|
+
* @function isGrantedSync
|
|
151
|
+
* @param {string} token - The token to be checked for scopes.
|
|
152
|
+
* @param {ScopesGrants} scopes - The required scopes. This can be an array of strings
|
|
153
|
+
* representing the scopes or a map where the keys are strings
|
|
154
|
+
* and the values are arrays of strings representing the scopes.
|
|
155
|
+
* @returns {boolean} - A boolean indicating whether the token grants the required scopes.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* Example with an array of scopes (AND operation)
|
|
159
|
+
* const scopesArray = ["read", "write"];
|
|
160
|
+
* const res = isGranted(token, scopesArray);
|
|
161
|
+
* console.log(res); // true only if the token has both "read" and "write" scopes
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* Example with a map of scopes (OR operation)
|
|
165
|
+
* const scopesMap = {
|
|
166
|
+
* "admin": ["read", "write"],
|
|
167
|
+
* "user": ["read"]
|
|
168
|
+
* };
|
|
169
|
+
* const res = isGranted(token, scopesMap);
|
|
170
|
+
* console.log(res); // true if the token has either "read" and "write" scopes or "read" scope
|
|
171
|
+
*/
|
|
172
|
+
declare const isGrantedSync: (token: string, scopes: ScopesGrants) => boolean;
|
|
140
173
|
|
|
141
174
|
/**
|
|
142
175
|
* Get a Session Id from a request.
|
|
@@ -151,4 +184,4 @@ type GetSessionProps = {
|
|
|
151
184
|
};
|
|
152
185
|
declare const getSession: ({ headers, clientId }: GetSessionProps) => string;
|
|
153
186
|
|
|
154
|
-
export { API_TYPE, AUTH_TYPES, BODY, type BodyLike, HEADERS, type HeadersLike, JWT, JWT_PUBLIC_KEY, type ScopesGrants, TOKEN_EXPIRATION, decodeToken, generateCodeChallenge, getSession, getToken, isGranted, pkceChallengePair, verifyAndExtractToken, verifyChallenge };
|
|
187
|
+
export { API_TYPE, AUTH_TYPES, BODY, type BodyLike, HEADERS, type HeadersLike, JWT, JWT_PUBLIC_KEY, type ScopesGrants, TOKEN_EXPIRATION, decodeToken, generateCodeChallenge, getSession, getToken, isGranted, isGrantedSync, pkceChallengePair, verifyAndExtractToken, verifyChallenge };
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var ne = Object.defineProperty;
|
|
2
|
+
var ae = (e, t, r) => t in e ? ne(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var u = (e, t, r) => ae(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
4
|
/*!
|
|
5
|
-
@versini/auth-common v4.
|
|
5
|
+
@versini/auth-common v4.4.0
|
|
6
6
|
© 2025 gizmette.com
|
|
7
7
|
*/
|
|
8
8
|
try {
|
|
9
9
|
window.__VERSINI_AUTH_COMMON__ || (window.__VERSINI_AUTH_COMMON__ = {
|
|
10
|
-
version: "4.
|
|
11
|
-
buildTime: "
|
|
10
|
+
version: "4.4.0",
|
|
11
|
+
buildTime: "06/02/2025 05:45 PM EDT",
|
|
12
12
|
homepage: "https://github.com/aversini/auth-client",
|
|
13
13
|
license: "MIT"
|
|
14
14
|
});
|
|
@@ -25,9 +25,9 @@ const nt = {
|
|
|
25
25
|
}, at = {
|
|
26
26
|
CLIENT_ID: "X-Auth-ClientId",
|
|
27
27
|
AUTH_TYPE: "X-Auth-Type"
|
|
28
|
-
},
|
|
28
|
+
}, ie = {
|
|
29
29
|
ACCESS_TOKEN: "access_token"
|
|
30
|
-
},
|
|
30
|
+
}, K = {
|
|
31
31
|
ALG: "RS256",
|
|
32
32
|
USER_ID_KEY: "sub",
|
|
33
33
|
USERNAME_KEY: "username",
|
|
@@ -40,7 +40,7 @@ const nt = {
|
|
|
40
40
|
SCOPES_KEY: "scopes",
|
|
41
41
|
CLIENT_ID_KEY: "aud",
|
|
42
42
|
ISSUER: "gizmette.com"
|
|
43
|
-
},
|
|
43
|
+
}, oe = `-----BEGIN PUBLIC KEY-----
|
|
44
44
|
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsF6i3Jd9fY/3COqCw/m7
|
|
45
45
|
w5PKyTYLGAI2I6SIIdpe6i6DOCbEkmDz7LdVsBqwNtVi8gvWYIj+8ol6rU3qu1v5
|
|
46
46
|
i1Jd45GSK4kzkVdgCmQZbM5ak0KI99q5wsrAIzUd+LRJ2HRvWtr5IYdsIiXaQjle
|
|
@@ -57,15 +57,15 @@ awIDAQAB
|
|
|
57
57
|
LOGOUT: "logout",
|
|
58
58
|
LOGIN: "login",
|
|
59
59
|
REFRESH: "refresh"
|
|
60
|
-
},
|
|
61
|
-
function
|
|
60
|
+
}, O = new TextEncoder(), T = new TextDecoder();
|
|
61
|
+
function se(...e) {
|
|
62
62
|
const t = e.reduce((a, { length: i }) => a + i, 0), r = new Uint8Array(t);
|
|
63
63
|
let n = 0;
|
|
64
64
|
for (const a of e)
|
|
65
65
|
r.set(a, n), n += a.length;
|
|
66
66
|
return r;
|
|
67
67
|
}
|
|
68
|
-
function
|
|
68
|
+
function ce(e) {
|
|
69
69
|
if (Uint8Array.fromBase64)
|
|
70
70
|
return Uint8Array.fromBase64(e);
|
|
71
71
|
const t = atob(e), r = new Uint8Array(t.length);
|
|
@@ -73,15 +73,15 @@ function se(e) {
|
|
|
73
73
|
r[n] = t.charCodeAt(n);
|
|
74
74
|
return r;
|
|
75
75
|
}
|
|
76
|
-
function
|
|
76
|
+
function P(e) {
|
|
77
77
|
if (Uint8Array.fromBase64)
|
|
78
|
-
return Uint8Array.fromBase64(typeof e == "string" ? e :
|
|
78
|
+
return Uint8Array.fromBase64(typeof e == "string" ? e : T.decode(e), {
|
|
79
79
|
alphabet: "base64url"
|
|
80
80
|
});
|
|
81
81
|
let t = e;
|
|
82
|
-
t instanceof Uint8Array && (t =
|
|
82
|
+
t instanceof Uint8Array && (t = T.decode(t)), t = t.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "");
|
|
83
83
|
try {
|
|
84
|
-
return
|
|
84
|
+
return ce(t);
|
|
85
85
|
} catch {
|
|
86
86
|
throw new TypeError("The input to be decoded is not correctly encoded.");
|
|
87
87
|
}
|
|
@@ -90,78 +90,78 @@ class w extends Error {
|
|
|
90
90
|
constructor(r, n) {
|
|
91
91
|
var a;
|
|
92
92
|
super(r, n);
|
|
93
|
-
|
|
93
|
+
u(this, "code", "ERR_JOSE_GENERIC");
|
|
94
94
|
this.name = this.constructor.name, (a = Error.captureStackTrace) == null || a.call(Error, this, this.constructor);
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
|
|
98
|
-
class
|
|
97
|
+
u(w, "code", "ERR_JOSE_GENERIC");
|
|
98
|
+
class h extends w {
|
|
99
99
|
constructor(r, n, a = "unspecified", i = "unspecified") {
|
|
100
100
|
super(r, { cause: { claim: a, reason: i, payload: n } });
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
u(this, "code", "ERR_JWT_CLAIM_VALIDATION_FAILED");
|
|
102
|
+
u(this, "claim");
|
|
103
|
+
u(this, "reason");
|
|
104
|
+
u(this, "payload");
|
|
105
105
|
this.claim = a, this.reason = i, this.payload = n;
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
|
|
108
|
+
u(h, "code", "ERR_JWT_CLAIM_VALIDATION_FAILED");
|
|
109
109
|
class J extends w {
|
|
110
110
|
constructor(r, n, a = "unspecified", i = "unspecified") {
|
|
111
111
|
super(r, { cause: { claim: a, reason: i, payload: n } });
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
u(this, "code", "ERR_JWT_EXPIRED");
|
|
113
|
+
u(this, "claim");
|
|
114
|
+
u(this, "reason");
|
|
115
|
+
u(this, "payload");
|
|
116
116
|
this.claim = a, this.reason = i, this.payload = n;
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
|
|
119
|
+
u(J, "code", "ERR_JWT_EXPIRED");
|
|
120
120
|
class F extends w {
|
|
121
121
|
constructor() {
|
|
122
122
|
super(...arguments);
|
|
123
|
-
|
|
123
|
+
u(this, "code", "ERR_JOSE_ALG_NOT_ALLOWED");
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
|
|
126
|
+
u(F, "code", "ERR_JOSE_ALG_NOT_ALLOWED");
|
|
127
127
|
class E extends w {
|
|
128
128
|
constructor() {
|
|
129
129
|
super(...arguments);
|
|
130
|
-
|
|
130
|
+
u(this, "code", "ERR_JOSE_NOT_SUPPORTED");
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
|
|
134
|
-
class
|
|
133
|
+
u(E, "code", "ERR_JOSE_NOT_SUPPORTED");
|
|
134
|
+
class d extends w {
|
|
135
135
|
constructor() {
|
|
136
136
|
super(...arguments);
|
|
137
|
-
|
|
137
|
+
u(this, "code", "ERR_JWS_INVALID");
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
|
-
d
|
|
140
|
+
u(d, "code", "ERR_JWS_INVALID");
|
|
141
141
|
class y extends w {
|
|
142
142
|
constructor() {
|
|
143
143
|
super(...arguments);
|
|
144
|
-
|
|
144
|
+
u(this, "code", "ERR_JWT_INVALID");
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
|
-
|
|
147
|
+
u(y, "code", "ERR_JWT_INVALID");
|
|
148
148
|
class V extends w {
|
|
149
149
|
constructor(r = "signature verification failed", n) {
|
|
150
150
|
super(r, n);
|
|
151
|
-
|
|
151
|
+
u(this, "code", "ERR_JWS_SIGNATURE_VERIFICATION_FAILED");
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
|
-
|
|
154
|
+
u(V, "code", "ERR_JWS_SIGNATURE_VERIFICATION_FAILED");
|
|
155
155
|
function S(e, t = "algorithm.name") {
|
|
156
156
|
return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`);
|
|
157
157
|
}
|
|
158
|
-
function
|
|
158
|
+
function v(e, t) {
|
|
159
159
|
return e.name === t;
|
|
160
160
|
}
|
|
161
161
|
function D(e) {
|
|
162
162
|
return parseInt(e.name.slice(4), 10);
|
|
163
163
|
}
|
|
164
|
-
function
|
|
164
|
+
function ue(e) {
|
|
165
165
|
switch (e) {
|
|
166
166
|
case "ES256":
|
|
167
167
|
return "P-256";
|
|
@@ -177,12 +177,12 @@ function de(e, t) {
|
|
|
177
177
|
if (!e.usages.includes(t))
|
|
178
178
|
throw new TypeError(`CryptoKey does not support this operation, its usages must include ${t}.`);
|
|
179
179
|
}
|
|
180
|
-
function
|
|
180
|
+
function fe(e, t, r) {
|
|
181
181
|
switch (t) {
|
|
182
182
|
case "HS256":
|
|
183
183
|
case "HS384":
|
|
184
184
|
case "HS512": {
|
|
185
|
-
if (!
|
|
185
|
+
if (!v(e.algorithm, "HMAC"))
|
|
186
186
|
throw S("HMAC");
|
|
187
187
|
const n = parseInt(t.slice(2), 10);
|
|
188
188
|
if (D(e.algorithm.hash) !== n)
|
|
@@ -192,7 +192,7 @@ function ue(e, t, r) {
|
|
|
192
192
|
case "RS256":
|
|
193
193
|
case "RS384":
|
|
194
194
|
case "RS512": {
|
|
195
|
-
if (!
|
|
195
|
+
if (!v(e.algorithm, "RSASSA-PKCS1-v1_5"))
|
|
196
196
|
throw S("RSASSA-PKCS1-v1_5");
|
|
197
197
|
const n = parseInt(t.slice(2), 10);
|
|
198
198
|
if (D(e.algorithm.hash) !== n)
|
|
@@ -202,7 +202,7 @@ function ue(e, t, r) {
|
|
|
202
202
|
case "PS256":
|
|
203
203
|
case "PS384":
|
|
204
204
|
case "PS512": {
|
|
205
|
-
if (!
|
|
205
|
+
if (!v(e.algorithm, "RSA-PSS"))
|
|
206
206
|
throw S("RSA-PSS");
|
|
207
207
|
const n = parseInt(t.slice(2), 10);
|
|
208
208
|
if (D(e.algorithm.hash) !== n)
|
|
@@ -211,16 +211,16 @@ function ue(e, t, r) {
|
|
|
211
211
|
}
|
|
212
212
|
case "Ed25519":
|
|
213
213
|
case "EdDSA": {
|
|
214
|
-
if (!
|
|
214
|
+
if (!v(e.algorithm, "Ed25519"))
|
|
215
215
|
throw S("Ed25519");
|
|
216
216
|
break;
|
|
217
217
|
}
|
|
218
218
|
case "ES256":
|
|
219
219
|
case "ES384":
|
|
220
220
|
case "ES512": {
|
|
221
|
-
if (!
|
|
221
|
+
if (!v(e.algorithm, "ECDSA"))
|
|
222
222
|
throw S("ECDSA");
|
|
223
|
-
const n =
|
|
223
|
+
const n = ue(t);
|
|
224
224
|
if (e.algorithm.namedCurve !== n)
|
|
225
225
|
throw S(n, "algorithm.namedCurve");
|
|
226
226
|
break;
|
|
@@ -238,7 +238,7 @@ function G(e, t, ...r) {
|
|
|
238
238
|
} else r.length === 2 ? e += `one of type ${r[0]} or ${r[1]}.` : e += `of type ${r[0]}.`;
|
|
239
239
|
return t == null ? e += ` Received ${t}` : typeof t == "function" && t.name ? e += ` Received function ${t.name}` : typeof t == "object" && t != null && (n = t.constructor) != null && n.name && (e += ` Received an instance of ${t.constructor.name}`), e;
|
|
240
240
|
}
|
|
241
|
-
const
|
|
241
|
+
const le = (e, ...t) => G("Key must be ", e, ...t);
|
|
242
242
|
function q(e, t, ...r) {
|
|
243
243
|
return G(`Key for the ${e} algorithm must be `, t, ...r);
|
|
244
244
|
}
|
|
@@ -267,11 +267,11 @@ const Q = (e) => z(e) || X(e), he = (...e) => {
|
|
|
267
267
|
}
|
|
268
268
|
return !0;
|
|
269
269
|
};
|
|
270
|
-
function
|
|
270
|
+
function pe(e) {
|
|
271
271
|
return typeof e == "object" && e !== null;
|
|
272
272
|
}
|
|
273
|
-
const
|
|
274
|
-
if (!
|
|
273
|
+
const _ = (e) => {
|
|
274
|
+
if (!pe(e) || Object.prototype.toString.call(e) !== "[object Object]")
|
|
275
275
|
return !1;
|
|
276
276
|
if (Object.getPrototypeOf(e) === null)
|
|
277
277
|
return !0;
|
|
@@ -279,7 +279,7 @@ const P = (e) => {
|
|
|
279
279
|
for (; Object.getPrototypeOf(t) !== null; )
|
|
280
280
|
t = Object.getPrototypeOf(t);
|
|
281
281
|
return Object.getPrototypeOf(e) === t;
|
|
282
|
-
},
|
|
282
|
+
}, ye = (e, t) => {
|
|
283
283
|
if (e.startsWith("RS") || e.startsWith("PS")) {
|
|
284
284
|
const { modulusLength: r } = t.algorithm;
|
|
285
285
|
if (typeof r != "number" || r < 2048)
|
|
@@ -292,7 +292,7 @@ const P = (e) => {
|
|
|
292
292
|
return !1;
|
|
293
293
|
const a = e.subarray(n, n + t.length);
|
|
294
294
|
return a.length !== t.length ? !1 : a.every((i, o) => i === t[o]) || W(e, t, n + 1);
|
|
295
|
-
},
|
|
295
|
+
}, me = (e) => {
|
|
296
296
|
switch (!0) {
|
|
297
297
|
case W(e, [42, 134, 72, 206, 61, 3, 1, 7]):
|
|
298
298
|
return "P-256";
|
|
@@ -303,7 +303,7 @@ const P = (e) => {
|
|
|
303
303
|
default:
|
|
304
304
|
return;
|
|
305
305
|
}
|
|
306
|
-
},
|
|
306
|
+
}, Se = async (e, t, r, n, a) => {
|
|
307
307
|
let i, o;
|
|
308
308
|
const c = new Uint8Array(atob(r.replace(e, "")).split("").map((s) => s.charCodeAt(0)));
|
|
309
309
|
switch (n) {
|
|
@@ -339,7 +339,7 @@ const P = (e) => {
|
|
|
339
339
|
case "ECDH-ES+A128KW":
|
|
340
340
|
case "ECDH-ES+A192KW":
|
|
341
341
|
case "ECDH-ES+A256KW": {
|
|
342
|
-
const s =
|
|
342
|
+
const s = me(c);
|
|
343
343
|
i = s != null && s.startsWith("P-") ? { name: "ECDH", namedCurve: s } : { name: "X25519" }, o = [];
|
|
344
344
|
break;
|
|
345
345
|
}
|
|
@@ -351,8 +351,8 @@ const P = (e) => {
|
|
|
351
351
|
throw new E('Invalid or unsupported "alg" (Algorithm) value');
|
|
352
352
|
}
|
|
353
353
|
return crypto.subtle.importKey(t, c, i, !0, o);
|
|
354
|
-
},
|
|
355
|
-
function
|
|
354
|
+
}, Ee = (e, t, r) => Se(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g, "spki", e, t);
|
|
355
|
+
function we(e) {
|
|
356
356
|
let t, r;
|
|
357
357
|
switch (e.kty) {
|
|
358
358
|
case "RSA": {
|
|
@@ -425,18 +425,18 @@ function Ee(e) {
|
|
|
425
425
|
}
|
|
426
426
|
return { algorithm: t, keyUsages: r };
|
|
427
427
|
}
|
|
428
|
-
const
|
|
428
|
+
const Ae = async (e) => {
|
|
429
429
|
if (!e.alg)
|
|
430
430
|
throw new TypeError('"alg" argument is required when "jwk.alg" is not present');
|
|
431
|
-
const { algorithm: t, keyUsages: r } =
|
|
431
|
+
const { algorithm: t, keyUsages: r } = we(e), n = { ...e };
|
|
432
432
|
return delete n.alg, delete n.use, crypto.subtle.importKey("jwk", n, t, e.ext ?? !e.d, e.key_ops ?? r);
|
|
433
433
|
};
|
|
434
|
-
async function
|
|
434
|
+
async function be(e, t, r) {
|
|
435
435
|
if (e.indexOf("-----BEGIN PUBLIC KEY-----") !== 0)
|
|
436
436
|
throw new TypeError('"spki" must be SPKI formatted string');
|
|
437
|
-
return
|
|
437
|
+
return Ee(e, t);
|
|
438
438
|
}
|
|
439
|
-
const
|
|
439
|
+
const ge = (e, t, r, n, a) => {
|
|
440
440
|
if (a.crit !== void 0 && (n == null ? void 0 : n.crit) === void 0)
|
|
441
441
|
throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');
|
|
442
442
|
if (!n || n.crit === void 0)
|
|
@@ -454,22 +454,22 @@ const be = (e, t, r, n, a) => {
|
|
|
454
454
|
throw new e(`Extension Header Parameter "${o}" MUST be integrity protected`);
|
|
455
455
|
}
|
|
456
456
|
return new Set(n.crit);
|
|
457
|
-
},
|
|
457
|
+
}, Ce = (e, t) => {
|
|
458
458
|
if (t !== void 0 && (!Array.isArray(t) || t.some((r) => typeof r != "string")))
|
|
459
459
|
throw new TypeError(`"${e}" option must be an array of strings`);
|
|
460
460
|
if (t)
|
|
461
461
|
return new Set(t);
|
|
462
462
|
};
|
|
463
463
|
function N(e) {
|
|
464
|
-
return
|
|
464
|
+
return _(e) && typeof e.kty == "string";
|
|
465
465
|
}
|
|
466
|
-
function
|
|
466
|
+
function Ke(e) {
|
|
467
467
|
return e.kty !== "oct" && typeof e.d == "string";
|
|
468
468
|
}
|
|
469
|
-
function
|
|
469
|
+
function Te(e) {
|
|
470
470
|
return e.kty !== "oct" && typeof e.d > "u";
|
|
471
471
|
}
|
|
472
|
-
function
|
|
472
|
+
function ve(e) {
|
|
473
473
|
return e.kty === "oct" && typeof e.k == "string";
|
|
474
474
|
}
|
|
475
475
|
let C;
|
|
@@ -478,9 +478,9 @@ const $ = async (e, t, r, n = !1) => {
|
|
|
478
478
|
let a = C.get(e);
|
|
479
479
|
if (a != null && a[r])
|
|
480
480
|
return a[r];
|
|
481
|
-
const i = await
|
|
481
|
+
const i = await Ae({ ...t, alg: r });
|
|
482
482
|
return n && Object.freeze(e), a ? a[r] = i : C.set(e, { [r]: i }), i;
|
|
483
|
-
},
|
|
483
|
+
}, Pe = (e, t) => {
|
|
484
484
|
var o;
|
|
485
485
|
C || (C = /* @__PURE__ */ new WeakMap());
|
|
486
486
|
let r = C.get(e);
|
|
@@ -566,7 +566,7 @@ const $ = async (e, t, r, n = !1) => {
|
|
|
566
566
|
if (!i)
|
|
567
567
|
throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
568
568
|
return r ? r[t] = i : C.set(e, { [t]: i }), i;
|
|
569
|
-
},
|
|
569
|
+
}, _e = async (e, t) => {
|
|
570
570
|
if (e instanceof Uint8Array || z(e))
|
|
571
571
|
return e;
|
|
572
572
|
if (X(e)) {
|
|
@@ -574,7 +574,7 @@ const $ = async (e, t, r, n = !1) => {
|
|
|
574
574
|
return e.export();
|
|
575
575
|
if ("toCryptoKey" in e && typeof e.toCryptoKey == "function")
|
|
576
576
|
try {
|
|
577
|
-
return
|
|
577
|
+
return Pe(e, t);
|
|
578
578
|
} catch (n) {
|
|
579
579
|
if (n instanceof TypeError)
|
|
580
580
|
throw n;
|
|
@@ -583,7 +583,7 @@ const $ = async (e, t, r, n = !1) => {
|
|
|
583
583
|
return $(e, r, t);
|
|
584
584
|
}
|
|
585
585
|
if (N(e))
|
|
586
|
-
return e.k ?
|
|
586
|
+
return e.k ? P(e.k) : $(e, e, t, !0);
|
|
587
587
|
throw new Error("unreachable");
|
|
588
588
|
}, g = (e) => e == null ? void 0 : e[Symbol.toStringTag], x = (e, t, r) => {
|
|
589
589
|
var n, a;
|
|
@@ -629,10 +629,10 @@ const $ = async (e, t, r, n = !1) => {
|
|
|
629
629
|
throw new TypeError(`Invalid key for this operation, its "key_ops" must include "${i}" when present`);
|
|
630
630
|
}
|
|
631
631
|
return !0;
|
|
632
|
-
},
|
|
632
|
+
}, Re = (e, t, r) => {
|
|
633
633
|
if (!(t instanceof Uint8Array)) {
|
|
634
634
|
if (N(t)) {
|
|
635
|
-
if (
|
|
635
|
+
if (ve(t) && x(e, t, r))
|
|
636
636
|
return;
|
|
637
637
|
throw new TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present');
|
|
638
638
|
}
|
|
@@ -641,17 +641,17 @@ const $ = async (e, t, r, n = !1) => {
|
|
|
641
641
|
if (t.type !== "secret")
|
|
642
642
|
throw new TypeError(`${g(t)} instances for symmetric algorithms must be of type "secret"`);
|
|
643
643
|
}
|
|
644
|
-
},
|
|
644
|
+
}, Ie = (e, t, r) => {
|
|
645
645
|
if (N(t))
|
|
646
646
|
switch (r) {
|
|
647
647
|
case "decrypt":
|
|
648
648
|
case "sign":
|
|
649
|
-
if (
|
|
649
|
+
if (Ke(t) && x(e, t, r))
|
|
650
650
|
return;
|
|
651
651
|
throw new TypeError("JSON Web Key for this operation be a private JWK");
|
|
652
652
|
case "encrypt":
|
|
653
653
|
case "verify":
|
|
654
|
-
if (
|
|
654
|
+
if (Te(t) && x(e, t, r))
|
|
655
655
|
return;
|
|
656
656
|
throw new TypeError("JSON Web Key for this operation be a public JWK");
|
|
657
657
|
}
|
|
@@ -673,8 +673,8 @@ const $ = async (e, t, r, n = !1) => {
|
|
|
673
673
|
case "encrypt":
|
|
674
674
|
throw new TypeError(`${g(t)} instances for asymmetric algorithm encryption must be of type "public"`);
|
|
675
675
|
}
|
|
676
|
-
},
|
|
677
|
-
e.startsWith("HS") || e === "dir" || e.startsWith("PBES2") || /^A(?:128|192|256)(?:GCM)?(?:KW)?$/.test(e) || /^A(?:128|192|256)CBC-HS(?:256|384|512)$/.test(e) ?
|
|
676
|
+
}, Oe = (e, t, r) => {
|
|
677
|
+
e.startsWith("HS") || e === "dir" || e.startsWith("PBES2") || /^A(?:128|192|256)(?:GCM)?(?:KW)?$/.test(e) || /^A(?:128|192|256)CBC-HS(?:256|384|512)$/.test(e) ? Re(e, t, r) : Ie(e, t, r);
|
|
678
678
|
}, We = (e, t) => {
|
|
679
679
|
const r = `SHA-${e.slice(-3)}`;
|
|
680
680
|
switch (e) {
|
|
@@ -700,16 +700,16 @@ const $ = async (e, t, r, n = !1) => {
|
|
|
700
700
|
default:
|
|
701
701
|
throw new E(`alg ${e} is not supported either by JOSE or your javascript runtime`);
|
|
702
702
|
}
|
|
703
|
-
},
|
|
703
|
+
}, De = async (e, t, r) => {
|
|
704
704
|
if (t instanceof Uint8Array) {
|
|
705
705
|
if (!e.startsWith("HS"))
|
|
706
|
-
throw new TypeError(
|
|
706
|
+
throw new TypeError(le(t, "CryptoKey", "KeyObject", "JSON Web Key"));
|
|
707
707
|
return crypto.subtle.importKey("raw", t, { hash: `SHA-${e.slice(-3)}`, name: "HMAC" }, !1, [r]);
|
|
708
708
|
}
|
|
709
|
-
return
|
|
710
|
-
},
|
|
711
|
-
const a = await
|
|
712
|
-
|
|
709
|
+
return fe(t, e, r), t;
|
|
710
|
+
}, He = async (e, t, r, n) => {
|
|
711
|
+
const a = await De(e, t, "verify");
|
|
712
|
+
ye(e, a);
|
|
713
713
|
const i = We(e, a.algorithm);
|
|
714
714
|
try {
|
|
715
715
|
return await crypto.subtle.verify(i, a, r, n);
|
|
@@ -717,81 +717,81 @@ const $ = async (e, t, r, n = !1) => {
|
|
|
717
717
|
return !1;
|
|
718
718
|
}
|
|
719
719
|
};
|
|
720
|
-
async function
|
|
721
|
-
if (!
|
|
722
|
-
throw new
|
|
720
|
+
async function Je(e, t, r) {
|
|
721
|
+
if (!_(e))
|
|
722
|
+
throw new d("Flattened JWS must be an object");
|
|
723
723
|
if (e.protected === void 0 && e.header === void 0)
|
|
724
|
-
throw new
|
|
724
|
+
throw new d('Flattened JWS must have either of the "protected" or "header" members');
|
|
725
725
|
if (e.protected !== void 0 && typeof e.protected != "string")
|
|
726
|
-
throw new
|
|
726
|
+
throw new d("JWS Protected Header incorrect type");
|
|
727
727
|
if (e.payload === void 0)
|
|
728
|
-
throw new
|
|
728
|
+
throw new d("JWS Payload missing");
|
|
729
729
|
if (typeof e.signature != "string")
|
|
730
|
-
throw new
|
|
731
|
-
if (e.header !== void 0 && !
|
|
732
|
-
throw new
|
|
730
|
+
throw new d("JWS Signature missing or incorrect type");
|
|
731
|
+
if (e.header !== void 0 && !_(e.header))
|
|
732
|
+
throw new d("JWS Unprotected Header incorrect type");
|
|
733
733
|
let n = {};
|
|
734
734
|
if (e.protected)
|
|
735
735
|
try {
|
|
736
|
-
const
|
|
737
|
-
n = JSON.parse(
|
|
736
|
+
const re = P(e.protected);
|
|
737
|
+
n = JSON.parse(T.decode(re));
|
|
738
738
|
} catch {
|
|
739
|
-
throw new
|
|
739
|
+
throw new d("JWS Protected Header is invalid");
|
|
740
740
|
}
|
|
741
741
|
if (!he(n, e.header))
|
|
742
|
-
throw new
|
|
742
|
+
throw new d("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
|
|
743
743
|
const a = {
|
|
744
744
|
...n,
|
|
745
745
|
...e.header
|
|
746
|
-
}, i =
|
|
746
|
+
}, i = ge(d, /* @__PURE__ */ new Map([["b64", !0]]), r == null ? void 0 : r.crit, n, a);
|
|
747
747
|
let o = !0;
|
|
748
748
|
if (i.has("b64") && (o = n.b64, typeof o != "boolean"))
|
|
749
|
-
throw new
|
|
749
|
+
throw new d('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
|
|
750
750
|
const { alg: c } = a;
|
|
751
751
|
if (typeof c != "string" || !c)
|
|
752
|
-
throw new
|
|
753
|
-
const s = r &&
|
|
752
|
+
throw new d('JWS "alg" (Algorithm) Header Parameter missing or invalid');
|
|
753
|
+
const s = r && Ce("algorithms", r.algorithms);
|
|
754
754
|
if (s && !s.has(c))
|
|
755
755
|
throw new F('"alg" (Algorithm) Header Parameter value not allowed');
|
|
756
756
|
if (o) {
|
|
757
757
|
if (typeof e.payload != "string")
|
|
758
|
-
throw new
|
|
758
|
+
throw new d("JWS Payload must be a string");
|
|
759
759
|
} else if (typeof e.payload != "string" && !(e.payload instanceof Uint8Array))
|
|
760
|
-
throw new
|
|
760
|
+
throw new d("JWS Payload must be a string or an Uint8Array instance");
|
|
761
761
|
let m = !1;
|
|
762
|
-
typeof t == "function" && (t = await t(n, e), m = !0),
|
|
763
|
-
const A =
|
|
762
|
+
typeof t == "function" && (t = await t(n, e), m = !0), Oe(c, t, "verify");
|
|
763
|
+
const A = se(O.encode(e.protected ?? ""), O.encode("."), typeof e.payload == "string" ? O.encode(e.payload) : e.payload);
|
|
764
764
|
let p;
|
|
765
765
|
try {
|
|
766
|
-
p =
|
|
766
|
+
p = P(e.signature);
|
|
767
767
|
} catch {
|
|
768
|
-
throw new
|
|
768
|
+
throw new d("Failed to base64url decode the signature");
|
|
769
769
|
}
|
|
770
|
-
const
|
|
771
|
-
if (!await
|
|
770
|
+
const R = await _e(t, c);
|
|
771
|
+
if (!await He(c, R, p, A))
|
|
772
772
|
throw new V();
|
|
773
|
-
let
|
|
773
|
+
let l;
|
|
774
774
|
if (o)
|
|
775
775
|
try {
|
|
776
|
-
|
|
776
|
+
l = P(e.payload);
|
|
777
777
|
} catch {
|
|
778
|
-
throw new
|
|
778
|
+
throw new d("Failed to base64url decode the payload");
|
|
779
779
|
}
|
|
780
|
-
else typeof e.payload == "string" ?
|
|
781
|
-
const b = { payload:
|
|
782
|
-
return e.protected !== void 0 && (b.protectedHeader = n), e.header !== void 0 && (b.unprotectedHeader = e.header), m ? { ...b, key:
|
|
780
|
+
else typeof e.payload == "string" ? l = O.encode(e.payload) : l = e.payload;
|
|
781
|
+
const b = { payload: l };
|
|
782
|
+
return e.protected !== void 0 && (b.protectedHeader = n), e.header !== void 0 && (b.unprotectedHeader = e.header), m ? { ...b, key: R } : b;
|
|
783
783
|
}
|
|
784
|
-
async function
|
|
785
|
-
if (e instanceof Uint8Array && (e =
|
|
786
|
-
throw new
|
|
784
|
+
async function xe(e, t, r) {
|
|
785
|
+
if (e instanceof Uint8Array && (e = T.decode(e)), typeof e != "string")
|
|
786
|
+
throw new d("Compact JWS must be a string or Uint8Array");
|
|
787
787
|
const { 0: n, 1: a, 2: i, length: o } = e.split(".");
|
|
788
788
|
if (o !== 3)
|
|
789
|
-
throw new
|
|
790
|
-
const c = await
|
|
789
|
+
throw new d("Invalid Compact JWS");
|
|
790
|
+
const c = await Je({ payload: a, protected: n, signature: i }, t, r), s = { payload: c.payload, protectedHeader: c.protectedHeader };
|
|
791
791
|
return typeof t == "function" ? { ...s, key: c.key } : s;
|
|
792
792
|
}
|
|
793
|
-
const
|
|
794
|
-
const t =
|
|
793
|
+
const Ne = (e) => Math.floor(e.getTime() / 1e3), Z = 60, j = Z * 60, U = j * 24, Ue = U * 7, $e = U * 365.25, Le = /^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i, L = (e) => {
|
|
794
|
+
const t = Le.exec(e);
|
|
795
795
|
if (!t || t[4] && t[1])
|
|
796
796
|
throw new TypeError("Invalid time period format");
|
|
797
797
|
const r = parseFloat(t[2]), n = t[3].toLowerCase();
|
|
@@ -826,36 +826,36 @@ const xe = (e) => Math.floor(e.getTime() / 1e3), Z = 60, j = Z * 60, U = j * 24,
|
|
|
826
826
|
case "week":
|
|
827
827
|
case "weeks":
|
|
828
828
|
case "w":
|
|
829
|
-
a = Math.round(r *
|
|
829
|
+
a = Math.round(r * Ue);
|
|
830
830
|
break;
|
|
831
831
|
default:
|
|
832
|
-
a = Math.round(r *
|
|
832
|
+
a = Math.round(r * $e);
|
|
833
833
|
break;
|
|
834
834
|
}
|
|
835
835
|
return t[1] === "-" || t[4] === "ago" ? -a : a;
|
|
836
|
-
}, B = (e) => e.toLowerCase().replace(/^application\//, ""),
|
|
837
|
-
function
|
|
836
|
+
}, B = (e) => e.toLowerCase().replace(/^application\//, ""), Be = (e, t) => typeof e == "string" ? t.includes(e) : Array.isArray(e) ? t.some(Set.prototype.has.bind(new Set(e))) : !1;
|
|
837
|
+
function Me(e, t, r = {}) {
|
|
838
838
|
let n;
|
|
839
839
|
try {
|
|
840
|
-
n = JSON.parse(
|
|
840
|
+
n = JSON.parse(T.decode(t));
|
|
841
841
|
} catch {
|
|
842
842
|
}
|
|
843
|
-
if (!
|
|
843
|
+
if (!_(n))
|
|
844
844
|
throw new y("JWT Claims Set must be a top-level JSON object");
|
|
845
845
|
const { typ: a } = r;
|
|
846
846
|
if (a && (typeof e.typ != "string" || B(e.typ) !== B(a)))
|
|
847
|
-
throw new
|
|
847
|
+
throw new h('unexpected "typ" JWT header value', n, "typ", "check_failed");
|
|
848
848
|
const { requiredClaims: i = [], issuer: o, subject: c, audience: s, maxTokenAge: m } = r, A = [...i];
|
|
849
849
|
m !== void 0 && A.push("iat"), s !== void 0 && A.push("aud"), c !== void 0 && A.push("sub"), o !== void 0 && A.push("iss");
|
|
850
|
-
for (const
|
|
851
|
-
if (!(
|
|
852
|
-
throw new
|
|
850
|
+
for (const l of new Set(A.reverse()))
|
|
851
|
+
if (!(l in n))
|
|
852
|
+
throw new h(`missing required "${l}" claim`, n, l, "missing");
|
|
853
853
|
if (o && !(Array.isArray(o) ? o : [o]).includes(n.iss))
|
|
854
|
-
throw new
|
|
854
|
+
throw new h('unexpected "iss" claim value', n, "iss", "check_failed");
|
|
855
855
|
if (c && n.sub !== c)
|
|
856
|
-
throw new
|
|
857
|
-
if (s && !
|
|
858
|
-
throw new
|
|
856
|
+
throw new h('unexpected "sub" claim value', n, "sub", "check_failed");
|
|
857
|
+
if (s && !Be(n.aud, typeof s == "string" ? [s] : s))
|
|
858
|
+
throw new h('unexpected "aud" claim value', n, "aud", "check_failed");
|
|
859
859
|
let p;
|
|
860
860
|
switch (typeof r.clockTolerance) {
|
|
861
861
|
case "string":
|
|
@@ -870,39 +870,39 @@ function Be(e, t, r = {}) {
|
|
|
870
870
|
default:
|
|
871
871
|
throw new TypeError("Invalid clockTolerance option type");
|
|
872
872
|
}
|
|
873
|
-
const { currentDate:
|
|
873
|
+
const { currentDate: R } = r, I = Ne(R || /* @__PURE__ */ new Date());
|
|
874
874
|
if ((n.iat !== void 0 || m) && typeof n.iat != "number")
|
|
875
|
-
throw new
|
|
875
|
+
throw new h('"iat" claim must be a number', n, "iat", "invalid");
|
|
876
876
|
if (n.nbf !== void 0) {
|
|
877
877
|
if (typeof n.nbf != "number")
|
|
878
|
-
throw new
|
|
879
|
-
if (n.nbf >
|
|
880
|
-
throw new
|
|
878
|
+
throw new h('"nbf" claim must be a number', n, "nbf", "invalid");
|
|
879
|
+
if (n.nbf > I + p)
|
|
880
|
+
throw new h('"nbf" claim timestamp check failed', n, "nbf", "check_failed");
|
|
881
881
|
}
|
|
882
882
|
if (n.exp !== void 0) {
|
|
883
883
|
if (typeof n.exp != "number")
|
|
884
|
-
throw new
|
|
885
|
-
if (n.exp <=
|
|
884
|
+
throw new h('"exp" claim must be a number', n, "exp", "invalid");
|
|
885
|
+
if (n.exp <= I - p)
|
|
886
886
|
throw new J('"exp" claim timestamp check failed', n, "exp", "check_failed");
|
|
887
887
|
}
|
|
888
888
|
if (m) {
|
|
889
|
-
const
|
|
890
|
-
if (
|
|
889
|
+
const l = I - n.iat, b = typeof m == "number" ? m : L(m);
|
|
890
|
+
if (l - p > b)
|
|
891
891
|
throw new J('"iat" claim timestamp check failed (too far in the past)', n, "iat", "check_failed");
|
|
892
|
-
if (
|
|
893
|
-
throw new
|
|
892
|
+
if (l < 0 - p)
|
|
893
|
+
throw new h('"iat" claim timestamp check failed (it should be in the past)', n, "iat", "check_failed");
|
|
894
894
|
}
|
|
895
895
|
return n;
|
|
896
896
|
}
|
|
897
|
-
async function
|
|
897
|
+
async function ke(e, t, r) {
|
|
898
898
|
var o;
|
|
899
|
-
const n = await
|
|
899
|
+
const n = await xe(e, t, r);
|
|
900
900
|
if ((o = n.protectedHeader.crit) != null && o.includes("b64") && n.protectedHeader.b64 === !1)
|
|
901
901
|
throw new y("JWTs MUST NOT use unencoded payload");
|
|
902
|
-
const i = { payload:
|
|
902
|
+
const i = { payload: Me(n.protectedHeader, n.payload, r), protectedHeader: n.protectedHeader };
|
|
903
903
|
return typeof t == "function" ? { ...i, key: n.key } : i;
|
|
904
904
|
}
|
|
905
|
-
function
|
|
905
|
+
function ee(e) {
|
|
906
906
|
if (typeof e != "string")
|
|
907
907
|
throw new y("JWTs must use Compact JWS serialization, JWT must be a string");
|
|
908
908
|
const { 1: t, length: r } = e.split(".");
|
|
@@ -914,32 +914,32 @@ function ke(e) {
|
|
|
914
914
|
throw new y("JWTs must contain a payload");
|
|
915
915
|
let n;
|
|
916
916
|
try {
|
|
917
|
-
n =
|
|
917
|
+
n = P(t);
|
|
918
918
|
} catch {
|
|
919
919
|
throw new y("Failed to base64url decode the payload");
|
|
920
920
|
}
|
|
921
921
|
let a;
|
|
922
922
|
try {
|
|
923
|
-
a = JSON.parse(
|
|
923
|
+
a = JSON.parse(T.decode(n));
|
|
924
924
|
} catch {
|
|
925
925
|
throw new y("Failed to parse the decoded payload as JSON");
|
|
926
926
|
}
|
|
927
|
-
if (!
|
|
927
|
+
if (!_(a))
|
|
928
928
|
throw new y("Invalid JWT Claims Set");
|
|
929
929
|
return a;
|
|
930
930
|
}
|
|
931
931
|
const Ye = async (e) => {
|
|
932
932
|
try {
|
|
933
|
-
const t =
|
|
934
|
-
return await
|
|
935
|
-
issuer:
|
|
933
|
+
const t = K.ALG, n = await be(oe, t);
|
|
934
|
+
return await ke(e, n, {
|
|
935
|
+
issuer: K.ISSUER
|
|
936
936
|
});
|
|
937
937
|
} catch {
|
|
938
938
|
return;
|
|
939
939
|
}
|
|
940
940
|
}, st = (e) => {
|
|
941
941
|
try {
|
|
942
|
-
return
|
|
942
|
+
return ee(e);
|
|
943
943
|
} catch {
|
|
944
944
|
return;
|
|
945
945
|
}
|
|
@@ -973,7 +973,7 @@ function k(e, t, r) {
|
|
|
973
973
|
const Y = globalThis.crypto, ze = (e) => `${k()}${k()}`.slice(0, e), Xe = (e) => btoa(
|
|
974
974
|
[...new Uint8Array(e)].map((t) => String.fromCharCode(t)).join("")
|
|
975
975
|
);
|
|
976
|
-
async function
|
|
976
|
+
async function te(e) {
|
|
977
977
|
if (!Y.subtle)
|
|
978
978
|
throw new Error(
|
|
979
979
|
"crypto.subtle is available only in secure contexts (HTTPS)."
|
|
@@ -985,14 +985,14 @@ async function ct(e) {
|
|
|
985
985
|
const t = e || 43;
|
|
986
986
|
if (t < 43 || t > 128)
|
|
987
987
|
throw `Expected a length between 43 and 128. Received ${e}.`;
|
|
988
|
-
const r = ze(t), n = await
|
|
988
|
+
const r = ze(t), n = await te(r);
|
|
989
989
|
return {
|
|
990
990
|
code_verifier: r,
|
|
991
991
|
code_challenge: n
|
|
992
992
|
};
|
|
993
993
|
}
|
|
994
|
-
async function
|
|
995
|
-
return t === await
|
|
994
|
+
async function ut(e, t) {
|
|
995
|
+
return t === await te(e);
|
|
996
996
|
}
|
|
997
997
|
const Qe = /^Bearer (.+)$/i, Ze = (e) => {
|
|
998
998
|
if (typeof (e == null ? void 0 : e.authorization) != "string")
|
|
@@ -1008,21 +1008,33 @@ const Qe = /^Bearer (.+)$/i, Ze = (e) => {
|
|
|
1008
1008
|
if (a)
|
|
1009
1009
|
return a[1];
|
|
1010
1010
|
}, et = (e) => {
|
|
1011
|
-
const t = e == null ? void 0 : e[
|
|
1011
|
+
const t = e == null ? void 0 : e[ie.ACCESS_TOKEN];
|
|
1012
1012
|
if (typeof t == "string")
|
|
1013
1013
|
return t;
|
|
1014
|
-
},
|
|
1014
|
+
}, dt = ({ headers: e, body: t, clientId: r }) => {
|
|
1015
1015
|
const n = Ze(e), a = je(e, r);
|
|
1016
1016
|
return et(t) || a || n || "";
|
|
1017
1017
|
}, ft = async (e, t) => {
|
|
1018
1018
|
var a;
|
|
1019
1019
|
const r = await Ye(e);
|
|
1020
|
-
if (!r || !Array.isArray((a = r.payload) == null ? void 0 : a[
|
|
1020
|
+
if (!r || !Array.isArray((a = r.payload) == null ? void 0 : a[K.SCOPES_KEY]))
|
|
1021
1021
|
return !1;
|
|
1022
|
-
const n = r.payload[
|
|
1022
|
+
const n = r.payload[K.SCOPES_KEY];
|
|
1023
1023
|
return Array.isArray(t) ? t.every((i) => n.includes(i)) : Object.keys(t).some(
|
|
1024
1024
|
(i) => t[i].every((o) => n.includes(o))
|
|
1025
1025
|
);
|
|
1026
|
+
}, lt = (e, t) => {
|
|
1027
|
+
try {
|
|
1028
|
+
const r = ee(e);
|
|
1029
|
+
if (!r || !Array.isArray(r[K.SCOPES_KEY]))
|
|
1030
|
+
return !1;
|
|
1031
|
+
const n = r[K.SCOPES_KEY];
|
|
1032
|
+
return Array.isArray(t) ? t.every((a) => n.includes(a)) : Object.keys(t).some(
|
|
1033
|
+
(a) => t[a].every((i) => n.includes(i))
|
|
1034
|
+
);
|
|
1035
|
+
} catch {
|
|
1036
|
+
return !1;
|
|
1037
|
+
}
|
|
1026
1038
|
}, tt = (e, t) => {
|
|
1027
1039
|
const r = e == null ? void 0 : e.cookie;
|
|
1028
1040
|
if (typeof r != "string")
|
|
@@ -1034,17 +1046,18 @@ const Qe = /^Bearer (.+)$/i, Ze = (e) => {
|
|
|
1034
1046
|
export {
|
|
1035
1047
|
ot as API_TYPE,
|
|
1036
1048
|
nt as AUTH_TYPES,
|
|
1037
|
-
|
|
1049
|
+
ie as BODY,
|
|
1038
1050
|
at as HEADERS,
|
|
1039
|
-
|
|
1040
|
-
|
|
1051
|
+
K as JWT,
|
|
1052
|
+
oe as JWT_PUBLIC_KEY,
|
|
1041
1053
|
it as TOKEN_EXPIRATION,
|
|
1042
1054
|
st as decodeToken,
|
|
1043
|
-
|
|
1055
|
+
te as generateCodeChallenge,
|
|
1044
1056
|
ht as getSession,
|
|
1045
|
-
|
|
1057
|
+
dt as getToken,
|
|
1046
1058
|
ft as isGranted,
|
|
1059
|
+
lt as isGrantedSync,
|
|
1047
1060
|
ct as pkceChallengePair,
|
|
1048
1061
|
Ye as verifyAndExtractToken,
|
|
1049
|
-
|
|
1062
|
+
ut as verifyChallenge
|
|
1050
1063
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versini/auth-common",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"publishConfig": {
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"jose": "6.0.10",
|
|
37
37
|
"uuid": "11.1.0"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "3109c57783f179b3d0f2fee8cecf16cc8ba333e1"
|
|
40
40
|
}
|