@versini/auth-common 4.0.0 → 4.1.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 +2 -1
- package/dist/index.js +20 -19
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -17,9 +17,10 @@ declare const BODY: {
|
|
|
17
17
|
declare const JWT: {
|
|
18
18
|
ALG: string;
|
|
19
19
|
USER_ID_KEY: string;
|
|
20
|
+
USERNAME_KEY: string;
|
|
21
|
+
EMAIL_KEY: string;
|
|
20
22
|
TOKEN_ID_KEY: string;
|
|
21
23
|
NONCE_KEY: string;
|
|
22
|
-
USERNAME_KEY: string;
|
|
23
24
|
AUTH_TYPE_KEY: string;
|
|
24
25
|
EXPIRES_AT_KEY: string;
|
|
25
26
|
CREATED_AT_KEY: string;
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
@versini/auth-common v4.
|
|
2
|
+
@versini/auth-common v4.1.0
|
|
3
3
|
© 2024 gizmette.com
|
|
4
4
|
*/
|
|
5
5
|
try {
|
|
6
6
|
window.__VERSINI_AUTH_COMMON__ || (window.__VERSINI_AUTH_COMMON__ = {
|
|
7
|
-
version: "4.
|
|
8
|
-
buildTime: "
|
|
7
|
+
version: "4.1.0",
|
|
8
|
+
buildTime: "09/01/2024 04:15 PM EDT",
|
|
9
9
|
homepage: "https://github.com/aversini/auth-client",
|
|
10
10
|
license: "MIT"
|
|
11
11
|
});
|
|
@@ -22,12 +22,13 @@ const et = {
|
|
|
22
22
|
CLIENT_ID: "X-Auth-ClientId"
|
|
23
23
|
}, ne = {
|
|
24
24
|
ACCESS_TOKEN: "access_token"
|
|
25
|
-
},
|
|
25
|
+
}, R = {
|
|
26
26
|
ALG: "RS256",
|
|
27
27
|
USER_ID_KEY: "sub",
|
|
28
|
+
USERNAME_KEY: "username",
|
|
29
|
+
EMAIL_KEY: "email",
|
|
28
30
|
TOKEN_ID_KEY: "__raw",
|
|
29
31
|
NONCE_KEY: "_nonce",
|
|
30
|
-
USERNAME_KEY: "username",
|
|
31
32
|
AUTH_TYPE_KEY: "auth_type",
|
|
32
33
|
EXPIRES_AT_KEY: "exp",
|
|
33
34
|
CREATED_AT_KEY: "iat",
|
|
@@ -452,22 +453,22 @@ async function be(e, t, r) {
|
|
|
452
453
|
throw new TypeError('"spki" must be SPKI formatted string');
|
|
453
454
|
return Ae(e, t);
|
|
454
455
|
}
|
|
455
|
-
const
|
|
456
|
+
const I = (e) => e == null ? void 0 : e[Symbol.toStringTag], Ce = (e, t) => {
|
|
456
457
|
if (!(t instanceof Uint8Array)) {
|
|
457
458
|
if (!X(t))
|
|
458
459
|
throw new TypeError(z(e, t, ...P, "Uint8Array"));
|
|
459
460
|
if (t.type !== "secret")
|
|
460
|
-
throw new TypeError(`${
|
|
461
|
+
throw new TypeError(`${I(t)} instances for symmetric algorithms must be of type "secret"`);
|
|
461
462
|
}
|
|
462
463
|
}, _e = (e, t, r) => {
|
|
463
464
|
if (!X(t))
|
|
464
465
|
throw new TypeError(z(e, t, ...P));
|
|
465
466
|
if (t.type === "secret")
|
|
466
|
-
throw new TypeError(`${
|
|
467
|
+
throw new TypeError(`${I(t)} instances for asymmetric algorithms must not be of type "secret"`);
|
|
467
468
|
if (t.algorithm && r === "verify" && t.type === "private")
|
|
468
|
-
throw new TypeError(`${
|
|
469
|
+
throw new TypeError(`${I(t)} instances for asymmetric algorithm verifying must be of type "public"`);
|
|
469
470
|
if (t.algorithm && r === "encrypt" && t.type === "private")
|
|
470
|
-
throw new TypeError(`${
|
|
471
|
+
throw new TypeError(`${I(t)} instances for asymmetric algorithm encryption must be of type "public"`);
|
|
471
472
|
}, ve = (e, t, r) => {
|
|
472
473
|
e.startsWith("HS") || e === "dir" || e.startsWith("PBES2") || /^A\d{3}(?:GCM)?KW$/.test(e) ? Ce(e, t) : _e(e, t, r);
|
|
473
474
|
};
|
|
@@ -490,13 +491,13 @@ function Te(e, t, r, n, a) {
|
|
|
490
491
|
}
|
|
491
492
|
return new Set(n.crit);
|
|
492
493
|
}
|
|
493
|
-
const
|
|
494
|
+
const Ie = (e, t) => {
|
|
494
495
|
if (t !== void 0 && (!Array.isArray(t) || t.some((r) => typeof r != "string")))
|
|
495
496
|
throw new TypeError(`"${e}" option must be an array of strings`);
|
|
496
497
|
if (t)
|
|
497
498
|
return new Set(t);
|
|
498
499
|
};
|
|
499
|
-
function
|
|
500
|
+
function Re(e, t) {
|
|
500
501
|
const r = `SHA-${e.slice(-3)}`;
|
|
501
502
|
switch (e) {
|
|
502
503
|
case "HS256":
|
|
@@ -534,7 +535,7 @@ async function Pe(e, t, r) {
|
|
|
534
535
|
const Ke = async (e, t, r, n) => {
|
|
535
536
|
const a = await Pe(e, t, "verify");
|
|
536
537
|
pe(e, a);
|
|
537
|
-
const o =
|
|
538
|
+
const o = Re(e, a.algorithm);
|
|
538
539
|
try {
|
|
539
540
|
return await O.subtle.verify(o, a, r, n);
|
|
540
541
|
} catch {
|
|
@@ -574,7 +575,7 @@ async function Oe(e, t, r) {
|
|
|
574
575
|
const { alg: c } = a;
|
|
575
576
|
if (typeof c != "string" || !c)
|
|
576
577
|
throw new u('JWS "alg" (Algorithm) Header Parameter missing or invalid');
|
|
577
|
-
const s = r &&
|
|
578
|
+
const s = r && Ie("algorithms", r.algorithms);
|
|
578
579
|
if (s && !s.has(c))
|
|
579
580
|
throw new ce('"alg" (Algorithm) Header Parameter value not allowed');
|
|
580
581
|
if (i) {
|
|
@@ -753,9 +754,9 @@ function ke(e) {
|
|
|
753
754
|
}
|
|
754
755
|
const Me = async (e) => {
|
|
755
756
|
try {
|
|
756
|
-
const t =
|
|
757
|
+
const t = R.ALG, n = await be(ae, t);
|
|
757
758
|
return await $e(e, n, {
|
|
758
|
-
issuer:
|
|
759
|
+
issuer: R.ISSUER
|
|
759
760
|
});
|
|
760
761
|
} catch {
|
|
761
762
|
return;
|
|
@@ -837,9 +838,9 @@ const ze = /^Bearer (.+)$/i, Xe = (e) => {
|
|
|
837
838
|
}, st = async (e, t) => {
|
|
838
839
|
var a;
|
|
839
840
|
const r = await Me(e);
|
|
840
|
-
if (!r || !Array.isArray((a = r.payload) == null ? void 0 : a[
|
|
841
|
+
if (!r || !Array.isArray((a = r.payload) == null ? void 0 : a[R.SCOPES_KEY]))
|
|
841
842
|
return !1;
|
|
842
|
-
const n = r.payload[
|
|
843
|
+
const n = r.payload[R.SCOPES_KEY];
|
|
843
844
|
return Array.isArray(t) ? t.every((o) => n.includes(o)) : Object.keys(t).some(
|
|
844
845
|
(o) => t[o].every((i) => n.includes(i))
|
|
845
846
|
);
|
|
@@ -856,7 +857,7 @@ export {
|
|
|
856
857
|
et as AUTH_TYPES,
|
|
857
858
|
ne as BODY,
|
|
858
859
|
tt as HEADERS,
|
|
859
|
-
|
|
860
|
+
R as JWT,
|
|
860
861
|
ae as JWT_PUBLIC_KEY,
|
|
861
862
|
rt as TOKEN_EXPIRATION,
|
|
862
863
|
at as decodeToken,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versini/auth-common",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"publishConfig": {
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"jose": "5.7.0",
|
|
37
37
|
"uuid": "10.0.0"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "74132e69a7def29f79c3d6a089611972dbfdfb63"
|
|
40
40
|
}
|