@versini/auth-common 2.11.0 → 2.12.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/index.d.ts +3 -1
- package/dist/index.js +61 -62
- package/package.json +4 -3
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ declare const AUTH_TYPES: {
|
|
|
6
6
|
ID_AND_ACCESS_TOKEN: string;
|
|
7
7
|
CODE: string;
|
|
8
8
|
REFRESH_TOKEN: string;
|
|
9
|
+
PASSKEY: string;
|
|
9
10
|
};
|
|
10
11
|
declare const HEADERS: {
|
|
11
12
|
CLIENT_ID: string;
|
|
@@ -16,6 +17,7 @@ declare const JWT: {
|
|
|
16
17
|
TOKEN_ID_KEY: string;
|
|
17
18
|
NONCE_KEY: string;
|
|
18
19
|
USERNAME_KEY: string;
|
|
20
|
+
AUTH_TYPE_KEY: string;
|
|
19
21
|
ISSUER: string;
|
|
20
22
|
};
|
|
21
23
|
declare const JWT_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsF6i3Jd9fY/3COqCw/m7\nw5PKyTYLGAI2I6SIIdpe6i6DOCbEkmDz7LdVsBqwNtVi8gvWYIj+8ol6rU3qu1v5\ni1Jd45GSK4kzkVdgCmQZbM5ak0KI99q5wsrAIzUd+LRJ2HRvWtr5IYdsIiXaQjle\naMwPFOIcJH+rKfFgNcHLcaS5syp7zU1ANwZ+trgR+DifBr8TLVkBynmNeTyhDm2+\nl0haqjMk0UoNPPE8iYBWUHQJJE1Dqstj65d6Eh5g64Pao25y4cmYJbKjiblIGEkE\nsjqybA9mARAqh9k/eiIopecWSiffNQTwVQVd2I9ZH3BalhEXHlqFgrjz51kFqg81\nawIDAQAB\n-----END PUBLIC KEY-----";
|
|
@@ -73,4 +75,4 @@ type HeadersLike = Record<string, unknown> & {
|
|
|
73
75
|
*/
|
|
74
76
|
declare const getToken: (headers: HeadersLike, clientId: string) => string;
|
|
75
77
|
|
|
76
|
-
export { API_TYPE, AUTH_TYPES, HEADERS, JWT, JWT_PUBLIC_KEY, TOKEN_EXPIRATION, decodeToken, generateCodeChallenge, getToken, pkceChallengePair, verifyAndExtractToken, verifyChallenge };
|
|
78
|
+
export { API_TYPE, AUTH_TYPES, HEADERS, type HeadersLike, JWT, JWT_PUBLIC_KEY, TOKEN_EXPIRATION, decodeToken, generateCodeChallenge, getToken, pkceChallengePair, verifyAndExtractToken, verifyChallenge };
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
@versini/auth-common v2.
|
|
2
|
+
@versini/auth-common v2.12.1
|
|
3
3
|
© 2024 gizmette.com
|
|
4
4
|
*/
|
|
5
5
|
try {
|
|
6
6
|
window.__VERSINI_AUTH_COMMON__ || (window.__VERSINI_AUTH_COMMON__ = {
|
|
7
|
-
version: "2.
|
|
8
|
-
buildTime: "07/
|
|
7
|
+
version: "2.12.1",
|
|
8
|
+
buildTime: "07/15/2024 10:32 AM EDT",
|
|
9
9
|
homepage: "https://github.com/aversini/auth-client",
|
|
10
10
|
license: "MIT"
|
|
11
11
|
});
|
|
@@ -16,7 +16,8 @@ const Qe = {
|
|
|
16
16
|
ACCESS_TOKEN: "token",
|
|
17
17
|
ID_AND_ACCESS_TOKEN: "id_token token",
|
|
18
18
|
CODE: "code",
|
|
19
|
-
REFRESH_TOKEN: "refresh_token"
|
|
19
|
+
REFRESH_TOKEN: "refresh_token",
|
|
20
|
+
PASSKEY: "passkey"
|
|
20
21
|
}, Xe = {
|
|
21
22
|
CLIENT_ID: "X-Auth-ClientId"
|
|
22
23
|
}, N = {
|
|
@@ -25,6 +26,7 @@ const Qe = {
|
|
|
25
26
|
TOKEN_ID_KEY: "__raw",
|
|
26
27
|
NONCE_KEY: "_nonce",
|
|
27
28
|
USERNAME_KEY: "username",
|
|
29
|
+
AUTH_TYPE_KEY: "auth_type",
|
|
28
30
|
ISSUER: "gizmette.com"
|
|
29
31
|
}, ne = `-----BEGIN PUBLIC KEY-----
|
|
30
32
|
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsF6i3Jd9fY/3COqCw/m7
|
|
@@ -42,7 +44,7 @@ awIDAQAB
|
|
|
42
44
|
AUTHENTICATE: "authenticate",
|
|
43
45
|
CODE: "code",
|
|
44
46
|
LOGOUT: "logout"
|
|
45
|
-
},
|
|
47
|
+
}, K = crypto, q = (e) => e instanceof CryptoKey, v = new TextEncoder(), C = new TextDecoder();
|
|
46
48
|
function ae(...e) {
|
|
47
49
|
const t = e.reduce((a, { length: i }) => a + i, 0), r = new Uint8Array(t);
|
|
48
50
|
let n = 0;
|
|
@@ -156,8 +158,7 @@ function de(e, t) {
|
|
|
156
158
|
if (t.length > 2) {
|
|
157
159
|
const n = t.pop();
|
|
158
160
|
r += `one of ${t.join(", ")}, or ${n}.`;
|
|
159
|
-
} else
|
|
160
|
-
t.length === 2 ? r += `one of ${t[0]} or ${t[1]}.` : r += `${t[0]}.`;
|
|
161
|
+
} else t.length === 2 ? r += `one of ${t[0]} or ${t[1]}.` : r += `${t[0]}.`;
|
|
161
162
|
throw new TypeError(r);
|
|
162
163
|
}
|
|
163
164
|
}
|
|
@@ -213,20 +214,19 @@ function ue(e, t, ...r) {
|
|
|
213
214
|
}
|
|
214
215
|
de(e, r);
|
|
215
216
|
}
|
|
216
|
-
function
|
|
217
|
+
function z(e, t, ...r) {
|
|
217
218
|
var n;
|
|
218
219
|
if (r.length > 2) {
|
|
219
220
|
const a = r.pop();
|
|
220
221
|
e += `one of type ${r.join(", ")}, or ${a}.`;
|
|
221
|
-
} else
|
|
222
|
-
r.length === 2 ? e += `one of type ${r[0]} or ${r[1]}.` : e += `of type ${r[0]}.`;
|
|
222
|
+
} else r.length === 2 ? e += `one of type ${r[0]} or ${r[1]}.` : e += `of type ${r[0]}.`;
|
|
223
223
|
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;
|
|
224
224
|
}
|
|
225
|
-
const L = (e, ...t) =>
|
|
226
|
-
function
|
|
227
|
-
return
|
|
225
|
+
const L = (e, ...t) => z("Key must be ", e, ...t);
|
|
226
|
+
function G(e, t, ...r) {
|
|
227
|
+
return z(`Key for the ${e} algorithm must be `, t, ...r);
|
|
228
228
|
}
|
|
229
|
-
const Q = (e) =>
|
|
229
|
+
const Q = (e) => q(e) ? !0 : (e == null ? void 0 : e[Symbol.toStringTag]) === "KeyObject", R = ["CryptoKey"], le = (...e) => {
|
|
230
230
|
const t = e.filter(Boolean);
|
|
231
231
|
if (t.length === 0 || t.length === 1)
|
|
232
232
|
return !0;
|
|
@@ -345,7 +345,7 @@ const me = async (e) => {
|
|
|
345
345
|
e.ext ?? !1,
|
|
346
346
|
e.key_ops ?? r
|
|
347
347
|
], a = { ...e };
|
|
348
|
-
return delete a.alg, delete a.use,
|
|
348
|
+
return delete a.alg, delete a.use, K.subtle.importKey("jwk", a, ...n);
|
|
349
349
|
}, X = (e) => b(e);
|
|
350
350
|
let W, J;
|
|
351
351
|
const Z = (e) => (e == null ? void 0 : e[Symbol.toStringTag]) === "KeyObject", j = async (e, t, r, n) => {
|
|
@@ -438,29 +438,29 @@ const Z = (e) => (e == null ? void 0 : e[Symbol.toStringTag]) === "KeyObject", j
|
|
|
438
438
|
default:
|
|
439
439
|
throw new w('Invalid or unsupported "alg" (Algorithm) value');
|
|
440
440
|
}
|
|
441
|
-
return
|
|
441
|
+
return K.subtle.importKey(t, c, i, !1, o);
|
|
442
442
|
}, ge = (e, t, r) => we(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g, "spki", e, t);
|
|
443
443
|
async function Ae(e, t, r) {
|
|
444
444
|
if (e.indexOf("-----BEGIN PUBLIC KEY-----") !== 0)
|
|
445
445
|
throw new TypeError('"spki" must be SPKI formatted string');
|
|
446
446
|
return ge(e, t);
|
|
447
447
|
}
|
|
448
|
-
const
|
|
448
|
+
const I = (e) => e == null ? void 0 : e[Symbol.toStringTag], be = (e, t) => {
|
|
449
449
|
if (!(t instanceof Uint8Array)) {
|
|
450
450
|
if (!Q(t))
|
|
451
|
-
throw new TypeError(
|
|
451
|
+
throw new TypeError(G(e, t, ...R, "Uint8Array"));
|
|
452
452
|
if (t.type !== "secret")
|
|
453
|
-
throw new TypeError(`${
|
|
453
|
+
throw new TypeError(`${I(t)} instances for symmetric algorithms must be of type "secret"`);
|
|
454
454
|
}
|
|
455
455
|
}, Ce = (e, t, r) => {
|
|
456
456
|
if (!Q(t))
|
|
457
|
-
throw new TypeError(
|
|
457
|
+
throw new TypeError(G(e, t, ...R));
|
|
458
458
|
if (t.type === "secret")
|
|
459
|
-
throw new TypeError(`${
|
|
459
|
+
throw new TypeError(`${I(t)} instances for asymmetric algorithms must not be of type "secret"`);
|
|
460
460
|
if (t.algorithm && r === "verify" && t.type === "private")
|
|
461
|
-
throw new TypeError(`${
|
|
461
|
+
throw new TypeError(`${I(t)} instances for asymmetric algorithm verifying must be of type "public"`);
|
|
462
462
|
if (t.algorithm && r === "encrypt" && t.type === "private")
|
|
463
|
-
throw new TypeError(`${
|
|
463
|
+
throw new TypeError(`${I(t)} instances for asymmetric algorithm encryption must be of type "public"`);
|
|
464
464
|
}, ve = (e, t, r) => {
|
|
465
465
|
e.startsWith("HS") || e === "dir" || e.startsWith("PBES2") || /^A\d{3}(?:GCM)?KW$/.test(e) ? be(e, t) : Ce(e, t, r);
|
|
466
466
|
};
|
|
@@ -483,13 +483,13 @@ function Te(e, t, r, n, a) {
|
|
|
483
483
|
}
|
|
484
484
|
return new Set(n.crit);
|
|
485
485
|
}
|
|
486
|
-
const
|
|
486
|
+
const _e = (e, t) => {
|
|
487
487
|
if (t !== void 0 && (!Array.isArray(t) || t.some((r) => typeof r != "string")))
|
|
488
488
|
throw new TypeError(`"${e}" option must be an array of strings`);
|
|
489
489
|
if (t)
|
|
490
490
|
return new Set(t);
|
|
491
491
|
};
|
|
492
|
-
function
|
|
492
|
+
function Ie(e, t) {
|
|
493
493
|
const r = `SHA-${e.slice(-3)}`;
|
|
494
494
|
switch (e) {
|
|
495
495
|
case "HS256":
|
|
@@ -514,27 +514,27 @@ function Re(e, t) {
|
|
|
514
514
|
throw new w(`alg ${e} is not supported either by JOSE or your javascript runtime`);
|
|
515
515
|
}
|
|
516
516
|
}
|
|
517
|
-
async function
|
|
518
|
-
if (t = await Ee.normalizePublicKey(t, e),
|
|
517
|
+
async function Re(e, t, r) {
|
|
518
|
+
if (t = await Ee.normalizePublicKey(t, e), q(t))
|
|
519
519
|
return ue(t, e, r), t;
|
|
520
520
|
if (t instanceof Uint8Array) {
|
|
521
521
|
if (!e.startsWith("HS"))
|
|
522
|
-
throw new TypeError(L(t, ...
|
|
523
|
-
return
|
|
522
|
+
throw new TypeError(L(t, ...R));
|
|
523
|
+
return K.subtle.importKey("raw", t, { hash: `SHA-${e.slice(-3)}`, name: "HMAC" }, !1, [r]);
|
|
524
524
|
}
|
|
525
|
-
throw new TypeError(L(t, ...
|
|
525
|
+
throw new TypeError(L(t, ...R, "Uint8Array"));
|
|
526
526
|
}
|
|
527
527
|
const Pe = async (e, t, r, n) => {
|
|
528
|
-
const a = await
|
|
528
|
+
const a = await Re(e, t, "verify");
|
|
529
529
|
he(e, a);
|
|
530
|
-
const i =
|
|
530
|
+
const i = Ie(e, a.algorithm);
|
|
531
531
|
try {
|
|
532
|
-
return await
|
|
532
|
+
return await K.subtle.verify(i, a, r, n);
|
|
533
533
|
} catch {
|
|
534
534
|
return !1;
|
|
535
535
|
}
|
|
536
536
|
};
|
|
537
|
-
async function
|
|
537
|
+
async function Ke(e, t, r) {
|
|
538
538
|
if (!P(e))
|
|
539
539
|
throw new u("Flattened JWS must be an object");
|
|
540
540
|
if (e.protected === void 0 && e.header === void 0)
|
|
@@ -550,8 +550,8 @@ async function xe(e, t, r) {
|
|
|
550
550
|
let n = {};
|
|
551
551
|
if (e.protected)
|
|
552
552
|
try {
|
|
553
|
-
const
|
|
554
|
-
n = JSON.parse(C.decode(
|
|
553
|
+
const x = b(e.protected);
|
|
554
|
+
n = JSON.parse(C.decode(x));
|
|
555
555
|
} catch {
|
|
556
556
|
throw new u("JWS Protected Header is invalid");
|
|
557
557
|
}
|
|
@@ -567,7 +567,7 @@ async function xe(e, t, r) {
|
|
|
567
567
|
const { alg: c } = a;
|
|
568
568
|
if (typeof c != "string" || !c)
|
|
569
569
|
throw new u('JWS "alg" (Algorithm) Header Parameter missing or invalid');
|
|
570
|
-
const s = r &&
|
|
570
|
+
const s = r && _e("algorithms", r.algorithms);
|
|
571
571
|
if (s && !s.has(c))
|
|
572
572
|
throw new ie('"alg" (Algorithm) Header Parameter value not allowed');
|
|
573
573
|
if (o) {
|
|
@@ -593,22 +593,21 @@ async function xe(e, t, r) {
|
|
|
593
593
|
} catch {
|
|
594
594
|
throw new u("Failed to base64url decode the payload");
|
|
595
595
|
}
|
|
596
|
-
else
|
|
597
|
-
typeof e.payload == "string" ? y = v.encode(e.payload) : y = e.payload;
|
|
596
|
+
else typeof e.payload == "string" ? y = v.encode(e.payload) : y = e.payload;
|
|
598
597
|
const l = { payload: y };
|
|
599
598
|
return e.protected !== void 0 && (l.protectedHeader = n), e.header !== void 0 && (l.unprotectedHeader = e.header), p ? { ...l, key: t } : l;
|
|
600
599
|
}
|
|
601
|
-
async function
|
|
600
|
+
async function xe(e, t, r) {
|
|
602
601
|
if (e instanceof Uint8Array && (e = C.decode(e)), typeof e != "string")
|
|
603
602
|
throw new u("Compact JWS must be a string or Uint8Array");
|
|
604
603
|
const { 0: n, 1: a, 2: i, length: o } = e.split(".");
|
|
605
604
|
if (o !== 3)
|
|
606
605
|
throw new u("Invalid Compact JWS");
|
|
607
|
-
const c = await
|
|
606
|
+
const c = await Ke({ payload: a, protected: n, signature: i }, t, r), s = { payload: c.payload, protectedHeader: c.protectedHeader };
|
|
608
607
|
return typeof t == "function" ? { ...s, key: c.key } : s;
|
|
609
608
|
}
|
|
610
|
-
const Oe = (e) => Math.floor(e.getTime() / 1e3), ee = 60, te = ee * 60,
|
|
611
|
-
const t =
|
|
609
|
+
const Oe = (e) => Math.floor(e.getTime() / 1e3), ee = 60, te = ee * 60, D = te * 24, We = D * 7, Je = D * 365.25, He = /^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i, k = (e) => {
|
|
610
|
+
const t = He.exec(e);
|
|
612
611
|
if (!t || t[4] && t[1])
|
|
613
612
|
throw new TypeError("Invalid time period format");
|
|
614
613
|
const r = parseFloat(t[2]), n = t[3].toLowerCase();
|
|
@@ -638,7 +637,7 @@ const Oe = (e) => Math.floor(e.getTime() / 1e3), ee = 60, te = ee * 60, H = te *
|
|
|
638
637
|
case "day":
|
|
639
638
|
case "days":
|
|
640
639
|
case "d":
|
|
641
|
-
a = Math.round(r *
|
|
640
|
+
a = Math.round(r * D);
|
|
642
641
|
break;
|
|
643
642
|
case "week":
|
|
644
643
|
case "weeks":
|
|
@@ -650,7 +649,7 @@ const Oe = (e) => Math.floor(e.getTime() / 1e3), ee = 60, te = ee * 60, H = te *
|
|
|
650
649
|
break;
|
|
651
650
|
}
|
|
652
651
|
return t[1] === "-" || t[4] === "ago" ? -a : a;
|
|
653
|
-
}, V = (e) => e.toLowerCase().replace(/^application\//, ""),
|
|
652
|
+
}, V = (e) => e.toLowerCase().replace(/^application\//, ""), De = (e, t) => typeof e == "string" ? t.includes(e) : Array.isArray(e) ? t.some(Set.prototype.has.bind(new Set(e))) : !1, Ue = (e, t, r = {}) => {
|
|
654
653
|
let n;
|
|
655
654
|
try {
|
|
656
655
|
n = JSON.parse(C.decode(t));
|
|
@@ -670,7 +669,7 @@ const Oe = (e) => Math.floor(e.getTime() / 1e3), ee = 60, te = ee * 60, H = te *
|
|
|
670
669
|
throw new h('unexpected "iss" claim value', n, "iss", "check_failed");
|
|
671
670
|
if (c && n.sub !== c)
|
|
672
671
|
throw new h('unexpected "sub" claim value', n, "sub", "check_failed");
|
|
673
|
-
if (s && !
|
|
672
|
+
if (s && !De(n.aud, typeof s == "string" ? [s] : s))
|
|
674
673
|
throw new h('unexpected "aud" claim value', n, "aud", "check_failed");
|
|
675
674
|
let f;
|
|
676
675
|
switch (typeof r.clockTolerance) {
|
|
@@ -702,8 +701,8 @@ const Oe = (e) => Math.floor(e.getTime() / 1e3), ee = 60, te = ee * 60, H = te *
|
|
|
702
701
|
throw new $('"exp" claim timestamp check failed', n, "exp", "check_failed");
|
|
703
702
|
}
|
|
704
703
|
if (p) {
|
|
705
|
-
const l = y - n.iat,
|
|
706
|
-
if (l - f >
|
|
704
|
+
const l = y - n.iat, x = typeof p == "number" ? p : k(p);
|
|
705
|
+
if (l - f > x)
|
|
707
706
|
throw new $('"iat" claim timestamp check failed (too far in the past)', n, "iat", "check_failed");
|
|
708
707
|
if (l < 0 - f)
|
|
709
708
|
throw new h('"iat" claim timestamp check failed (it should be in the past)', n, "iat", "check_failed");
|
|
@@ -712,7 +711,7 @@ const Oe = (e) => Math.floor(e.getTime() / 1e3), ee = 60, te = ee * 60, H = te *
|
|
|
712
711
|
};
|
|
713
712
|
async function Ne(e, t, r) {
|
|
714
713
|
var o;
|
|
715
|
-
const n = await
|
|
714
|
+
const n = await xe(e, t, r);
|
|
716
715
|
if ((o = n.protectedHeader.crit) != null && o.includes("b64") && n.protectedHeader.b64 === !1)
|
|
717
716
|
throw new S("JWTs MUST NOT use unencoded payload");
|
|
718
717
|
const i = { payload: Ue(n.protectedHeader, n.payload, r), protectedHeader: n.protectedHeader };
|
|
@@ -762,16 +761,16 @@ const et = async (e) => {
|
|
|
762
761
|
}
|
|
763
762
|
};
|
|
764
763
|
var d = [];
|
|
765
|
-
for (var
|
|
766
|
-
d.push((
|
|
764
|
+
for (var H = 0; H < 256; ++H)
|
|
765
|
+
d.push((H + 256).toString(16).slice(1));
|
|
767
766
|
function Me(e, t = 0) {
|
|
768
767
|
return (d[e[t + 0]] + d[e[t + 1]] + d[e[t + 2]] + d[e[t + 3]] + "-" + d[e[t + 4]] + d[e[t + 5]] + "-" + d[e[t + 6]] + d[e[t + 7]] + "-" + d[e[t + 8]] + d[e[t + 9]] + "-" + d[e[t + 10]] + d[e[t + 11]] + d[e[t + 12]] + d[e[t + 13]] + d[e[t + 14]] + d[e[t + 15]]).toLowerCase();
|
|
769
768
|
}
|
|
770
|
-
var
|
|
769
|
+
var _, ke = new Uint8Array(16);
|
|
771
770
|
function Ve() {
|
|
772
|
-
if (!
|
|
771
|
+
if (!_ && (_ = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !_))
|
|
773
772
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
774
|
-
return
|
|
773
|
+
return _(ke);
|
|
775
774
|
}
|
|
776
775
|
var Be = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
777
776
|
const B = {
|
|
@@ -784,16 +783,16 @@ function F(e, t, r) {
|
|
|
784
783
|
var n = e.random || (e.rng || Ve)();
|
|
785
784
|
return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, Me(n);
|
|
786
785
|
}
|
|
787
|
-
const
|
|
786
|
+
const Y = globalThis.crypto, Fe = (e) => `${F()}${F()}`.slice(0, e), Ye = (e) => btoa(
|
|
788
787
|
[...new Uint8Array(e)].map((t) => String.fromCharCode(t)).join("")
|
|
789
788
|
);
|
|
790
789
|
async function re(e) {
|
|
791
|
-
if (!
|
|
790
|
+
if (!Y.subtle)
|
|
792
791
|
throw new Error(
|
|
793
792
|
"crypto.subtle is available only in secure contexts (HTTPS)."
|
|
794
793
|
);
|
|
795
|
-
const t = new TextEncoder().encode(e), r = await
|
|
796
|
-
return
|
|
794
|
+
const t = new TextEncoder().encode(e), r = await Y.subtle.digest("SHA-256", t);
|
|
795
|
+
return Ye(r).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
797
796
|
}
|
|
798
797
|
async function rt(e) {
|
|
799
798
|
const t = e || 43;
|
|
@@ -808,13 +807,13 @@ async function rt(e) {
|
|
|
808
807
|
async function nt(e, t) {
|
|
809
808
|
return t === await re(e);
|
|
810
809
|
}
|
|
811
|
-
const
|
|
810
|
+
const qe = /^Bearer (.+)$/i, ze = (e) => {
|
|
812
811
|
if (typeof e.authorization != "string")
|
|
813
812
|
return;
|
|
814
|
-
const t = e.authorization.match(
|
|
813
|
+
const t = e.authorization.match(qe);
|
|
815
814
|
if (t)
|
|
816
815
|
return t[1];
|
|
817
|
-
},
|
|
816
|
+
}, Ge = (e, t) => {
|
|
818
817
|
const r = e.cookie, n = new RegExp(`auth.${t}=(.+?)(?:;|$)`);
|
|
819
818
|
if (typeof r != "string")
|
|
820
819
|
return;
|
|
@@ -822,7 +821,7 @@ const ze = /^Bearer (.+)$/i, Ge = (e) => {
|
|
|
822
821
|
if (a)
|
|
823
822
|
return a[1];
|
|
824
823
|
}, at = (e, t) => {
|
|
825
|
-
const r =
|
|
824
|
+
const r = ze(e), n = Ge(e, t);
|
|
826
825
|
return !n && !r ? "" : n || r;
|
|
827
826
|
};
|
|
828
827
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versini/auth-common",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"publishConfig": {
|
|
@@ -29,11 +29,12 @@
|
|
|
29
29
|
"lint": "biome lint src",
|
|
30
30
|
"start": "static-server dist --port 5173",
|
|
31
31
|
"test:watch": "vitest",
|
|
32
|
-
"test": "vitest run"
|
|
32
|
+
"test": "vitest run",
|
|
33
|
+
"test:coverage": "vitest run --coverage"
|
|
33
34
|
},
|
|
34
35
|
"dependencies": {
|
|
35
36
|
"jose": "5.6.3",
|
|
36
37
|
"uuid": "10.0.0"
|
|
37
38
|
},
|
|
38
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "a85e00ff8943fae7d4160f582b030962fa68472d"
|
|
39
40
|
}
|