@versini/auth-common 2.10.0 → 2.10.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 +1 -0
- package/dist/index.js +61 -60
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ declare const JWT: {
|
|
|
15
15
|
USER_ID_KEY: string;
|
|
16
16
|
TOKEN_ID_KEY: string;
|
|
17
17
|
NONCE_KEY: string;
|
|
18
|
+
USERNAME_KEY: string;
|
|
18
19
|
ISSUER: string;
|
|
19
20
|
};
|
|
20
21
|
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-----";
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
@versini/auth-common v2.10.
|
|
2
|
+
@versini/auth-common v2.10.1
|
|
3
3
|
© 2024 gizmette.com
|
|
4
4
|
*/
|
|
5
5
|
try {
|
|
6
6
|
window.__VERSINI_AUTH_COMMON__ || (window.__VERSINI_AUTH_COMMON__ = {
|
|
7
|
-
version: "2.10.
|
|
8
|
-
buildTime: "06/29/2024
|
|
7
|
+
version: "2.10.1",
|
|
8
|
+
buildTime: "06/29/2024 01:31 PM EDT",
|
|
9
9
|
homepage: "https://github.com/aversini/auth-client",
|
|
10
10
|
license: "MIT"
|
|
11
11
|
});
|
|
@@ -17,13 +17,14 @@ const Ge = {
|
|
|
17
17
|
ID_AND_ACCESS_TOKEN: "id_token token",
|
|
18
18
|
CODE: "code",
|
|
19
19
|
REFRESH_TOKEN: "refresh_token"
|
|
20
|
-
},
|
|
20
|
+
}, Ye = {
|
|
21
21
|
CLIENT_ID: "X-Auth-ClientId"
|
|
22
22
|
}, N = {
|
|
23
23
|
ALG: "RS256",
|
|
24
24
|
USER_ID_KEY: "sub",
|
|
25
25
|
TOKEN_ID_KEY: "__raw",
|
|
26
26
|
NONCE_KEY: "_nonce",
|
|
27
|
+
USERNAME_KEY: "username",
|
|
27
28
|
ISSUER: "gizmette.com"
|
|
28
29
|
}, ne = `-----BEGIN PUBLIC KEY-----
|
|
29
30
|
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsF6i3Jd9fY/3COqCw/m7
|
|
@@ -33,7 +34,7 @@ aMwPFOIcJH+rKfFgNcHLcaS5syp7zU1ANwZ+trgR+DifBr8TLVkBynmNeTyhDm2+
|
|
|
33
34
|
l0haqjMk0UoNPPE8iYBWUHQJJE1Dqstj65d6Eh5g64Pao25y4cmYJbKjiblIGEkE
|
|
34
35
|
sjqybA9mARAqh9k/eiIopecWSiffNQTwVQVd2I9ZH3BalhEXHlqFgrjz51kFqg81
|
|
35
36
|
awIDAQAB
|
|
36
|
-
-----END PUBLIC KEY-----`,
|
|
37
|
+
-----END PUBLIC KEY-----`, ze = {
|
|
37
38
|
ACCESS: "5m",
|
|
38
39
|
ID: "90d",
|
|
39
40
|
REFRESH: "90d"
|
|
@@ -54,7 +55,7 @@ const oe = (e) => {
|
|
|
54
55
|
for (let n = 0; n < t.length; n++)
|
|
55
56
|
r[n] = t.charCodeAt(n);
|
|
56
57
|
return r;
|
|
57
|
-
},
|
|
58
|
+
}, b = (e) => {
|
|
58
59
|
let t = e;
|
|
59
60
|
t instanceof Uint8Array && (t = C.decode(t)), t = t.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "");
|
|
60
61
|
try {
|
|
@@ -63,7 +64,7 @@ const oe = (e) => {
|
|
|
63
64
|
throw new TypeError("The input to be decoded is not correctly encoded.");
|
|
64
65
|
}
|
|
65
66
|
};
|
|
66
|
-
class
|
|
67
|
+
class A extends Error {
|
|
67
68
|
static get code() {
|
|
68
69
|
return "ERR_JOSE_GENERIC";
|
|
69
70
|
}
|
|
@@ -72,7 +73,7 @@ class b extends Error {
|
|
|
72
73
|
super(t), this.code = "ERR_JOSE_GENERIC", this.name = this.constructor.name, (r = Error.captureStackTrace) == null || r.call(Error, this, this.constructor);
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
|
-
class f extends
|
|
76
|
+
class f extends A {
|
|
76
77
|
static get code() {
|
|
77
78
|
return "ERR_JWT_CLAIM_VALIDATION_FAILED";
|
|
78
79
|
}
|
|
@@ -80,7 +81,7 @@ class f extends b {
|
|
|
80
81
|
super(t), this.code = "ERR_JWT_CLAIM_VALIDATION_FAILED", this.claim = n, this.reason = a, this.payload = r;
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
|
-
class $ extends
|
|
84
|
+
class $ extends A {
|
|
84
85
|
static get code() {
|
|
85
86
|
return "ERR_JWT_EXPIRED";
|
|
86
87
|
}
|
|
@@ -88,7 +89,7 @@ class $ extends b {
|
|
|
88
89
|
super(t), this.code = "ERR_JWT_EXPIRED", this.claim = n, this.reason = a, this.payload = r;
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
|
-
class ie extends
|
|
92
|
+
class ie extends A {
|
|
92
93
|
constructor() {
|
|
93
94
|
super(...arguments), this.code = "ERR_JOSE_ALG_NOT_ALLOWED";
|
|
94
95
|
}
|
|
@@ -96,7 +97,7 @@ class ie extends b {
|
|
|
96
97
|
return "ERR_JOSE_ALG_NOT_ALLOWED";
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
|
-
class w extends
|
|
100
|
+
class w extends A {
|
|
100
101
|
constructor() {
|
|
101
102
|
super(...arguments), this.code = "ERR_JOSE_NOT_SUPPORTED";
|
|
102
103
|
}
|
|
@@ -104,7 +105,7 @@ class w extends b {
|
|
|
104
105
|
return "ERR_JOSE_NOT_SUPPORTED";
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
|
-
class u extends
|
|
108
|
+
class u extends A {
|
|
108
109
|
constructor() {
|
|
109
110
|
super(...arguments), this.code = "ERR_JWS_INVALID";
|
|
110
111
|
}
|
|
@@ -112,7 +113,7 @@ class u extends b {
|
|
|
112
113
|
return "ERR_JWS_INVALID";
|
|
113
114
|
}
|
|
114
115
|
}
|
|
115
|
-
class S extends
|
|
116
|
+
class S extends A {
|
|
116
117
|
constructor() {
|
|
117
118
|
super(...arguments), this.code = "ERR_JWT_INVALID";
|
|
118
119
|
}
|
|
@@ -120,7 +121,7 @@ class S extends b {
|
|
|
120
121
|
return "ERR_JWT_INVALID";
|
|
121
122
|
}
|
|
122
123
|
}
|
|
123
|
-
class ce extends
|
|
124
|
+
class ce extends A {
|
|
124
125
|
constructor() {
|
|
125
126
|
super(...arguments), this.code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED", this.message = "signature verification failed";
|
|
126
127
|
}
|
|
@@ -134,7 +135,7 @@ function m(e, t = "algorithm.name") {
|
|
|
134
135
|
function T(e, t) {
|
|
135
136
|
return e.name === t;
|
|
136
137
|
}
|
|
137
|
-
function
|
|
138
|
+
function O(e) {
|
|
138
139
|
return parseInt(e.name.slice(4), 10);
|
|
139
140
|
}
|
|
140
141
|
function se(e) {
|
|
@@ -168,7 +169,7 @@ function ue(e, t, ...r) {
|
|
|
168
169
|
if (!T(e.algorithm, "HMAC"))
|
|
169
170
|
throw m("HMAC");
|
|
170
171
|
const n = parseInt(t.slice(2), 10);
|
|
171
|
-
if (
|
|
172
|
+
if (O(e.algorithm.hash) !== n)
|
|
172
173
|
throw m(`SHA-${n}`, "algorithm.hash");
|
|
173
174
|
break;
|
|
174
175
|
}
|
|
@@ -178,7 +179,7 @@ function ue(e, t, ...r) {
|
|
|
178
179
|
if (!T(e.algorithm, "RSASSA-PKCS1-v1_5"))
|
|
179
180
|
throw m("RSASSA-PKCS1-v1_5");
|
|
180
181
|
const n = parseInt(t.slice(2), 10);
|
|
181
|
-
if (
|
|
182
|
+
if (O(e.algorithm.hash) !== n)
|
|
182
183
|
throw m(`SHA-${n}`, "algorithm.hash");
|
|
183
184
|
break;
|
|
184
185
|
}
|
|
@@ -188,7 +189,7 @@ function ue(e, t, ...r) {
|
|
|
188
189
|
if (!T(e.algorithm, "RSA-PSS"))
|
|
189
190
|
throw m("RSA-PSS");
|
|
190
191
|
const n = parseInt(t.slice(2), 10);
|
|
191
|
-
if (
|
|
192
|
+
if (O(e.algorithm.hash) !== n)
|
|
192
193
|
throw m(`SHA-${n}`, "algorithm.hash");
|
|
193
194
|
break;
|
|
194
195
|
}
|
|
@@ -212,7 +213,7 @@ function ue(e, t, ...r) {
|
|
|
212
213
|
}
|
|
213
214
|
de(e, r);
|
|
214
215
|
}
|
|
215
|
-
function
|
|
216
|
+
function Y(e, t, ...r) {
|
|
216
217
|
var n;
|
|
217
218
|
if (r.length > 2) {
|
|
218
219
|
const a = r.pop();
|
|
@@ -221,11 +222,11 @@ function z(e, t, ...r) {
|
|
|
221
222
|
r.length === 2 ? e += `one of type ${r[0]} or ${r[1]}.` : e += `of type ${r[0]}.`;
|
|
222
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;
|
|
223
224
|
}
|
|
224
|
-
const L = (e, ...t) =>
|
|
225
|
-
function
|
|
226
|
-
return
|
|
225
|
+
const L = (e, ...t) => Y("Key must be ", e, ...t);
|
|
226
|
+
function z(e, t, ...r) {
|
|
227
|
+
return Y(`Key for the ${e} algorithm must be `, t, ...r);
|
|
227
228
|
}
|
|
228
|
-
const Q = (e) => G(e) ? !0 : (e == null ? void 0 : e[Symbol.toStringTag]) === "KeyObject",
|
|
229
|
+
const Q = (e) => G(e) ? !0 : (e == null ? void 0 : e[Symbol.toStringTag]) === "KeyObject", _ = ["CryptoKey"], le = (...e) => {
|
|
229
230
|
const t = e.filter(Boolean);
|
|
230
231
|
if (t.length === 0 || t.length === 1)
|
|
231
232
|
return !0;
|
|
@@ -247,7 +248,7 @@ const Q = (e) => G(e) ? !0 : (e == null ? void 0 : e[Symbol.toStringTag]) === "K
|
|
|
247
248
|
function he(e) {
|
|
248
249
|
return typeof e == "object" && e !== null;
|
|
249
250
|
}
|
|
250
|
-
function
|
|
251
|
+
function P(e) {
|
|
251
252
|
if (!he(e) || Object.prototype.toString.call(e) !== "[object Object]")
|
|
252
253
|
return !1;
|
|
253
254
|
if (Object.getPrototypeOf(e) === null)
|
|
@@ -345,7 +346,7 @@ const me = async (e) => {
|
|
|
345
346
|
e.key_ops ?? r
|
|
346
347
|
], a = { ...e };
|
|
347
348
|
return delete a.alg, delete a.use, x.subtle.importKey("jwk", a, ...n);
|
|
348
|
-
}, X = (e) =>
|
|
349
|
+
}, X = (e) => b(e);
|
|
349
350
|
let W, J;
|
|
350
351
|
const Z = (e) => (e == null ? void 0 : e[Symbol.toStringTag]) === "KeyObject", j = async (e, t, r, n) => {
|
|
351
352
|
let a = e.get(t);
|
|
@@ -439,29 +440,29 @@ const Z = (e) => (e == null ? void 0 : e[Symbol.toStringTag]) === "KeyObject", j
|
|
|
439
440
|
}
|
|
440
441
|
return x.subtle.importKey(t, c, i, !1, o);
|
|
441
442
|
}, ge = (e, t, r) => we(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g, "spki", e, t);
|
|
442
|
-
async function
|
|
443
|
+
async function Ae(e, t, r) {
|
|
443
444
|
if (e.indexOf("-----BEGIN PUBLIC KEY-----") !== 0)
|
|
444
445
|
throw new TypeError('"spki" must be SPKI formatted string');
|
|
445
446
|
return ge(e, t);
|
|
446
447
|
}
|
|
447
|
-
const
|
|
448
|
+
const R = (e) => e == null ? void 0 : e[Symbol.toStringTag], be = (e, t) => {
|
|
448
449
|
if (!(t instanceof Uint8Array)) {
|
|
449
450
|
if (!Q(t))
|
|
450
|
-
throw new TypeError(
|
|
451
|
+
throw new TypeError(z(e, t, ..._, "Uint8Array"));
|
|
451
452
|
if (t.type !== "secret")
|
|
452
|
-
throw new TypeError(`${
|
|
453
|
+
throw new TypeError(`${R(t)} instances for symmetric algorithms must be of type "secret"`);
|
|
453
454
|
}
|
|
454
455
|
}, Ce = (e, t, r) => {
|
|
455
456
|
if (!Q(t))
|
|
456
|
-
throw new TypeError(
|
|
457
|
+
throw new TypeError(z(e, t, ..._));
|
|
457
458
|
if (t.type === "secret")
|
|
458
|
-
throw new TypeError(`${
|
|
459
|
+
throw new TypeError(`${R(t)} instances for asymmetric algorithms must not be of type "secret"`);
|
|
459
460
|
if (t.algorithm && r === "verify" && t.type === "private")
|
|
460
|
-
throw new TypeError(`${
|
|
461
|
+
throw new TypeError(`${R(t)} instances for asymmetric algorithm verifying must be of type "public"`);
|
|
461
462
|
if (t.algorithm && r === "encrypt" && t.type === "private")
|
|
462
|
-
throw new TypeError(`${
|
|
463
|
+
throw new TypeError(`${R(t)} instances for asymmetric algorithm encryption must be of type "public"`);
|
|
463
464
|
}, ve = (e, t, r) => {
|
|
464
|
-
e.startsWith("HS") || e === "dir" || e.startsWith("PBES2") || /^A\d{3}(?:GCM)?KW$/.test(e) ?
|
|
465
|
+
e.startsWith("HS") || e === "dir" || e.startsWith("PBES2") || /^A\d{3}(?:GCM)?KW$/.test(e) ? be(e, t) : Ce(e, t, r);
|
|
465
466
|
};
|
|
466
467
|
function Te(e, t, r, n, a) {
|
|
467
468
|
if (a.crit !== void 0 && (n == null ? void 0 : n.crit) === void 0)
|
|
@@ -488,7 +489,7 @@ const Ie = (e, t) => {
|
|
|
488
489
|
if (t)
|
|
489
490
|
return new Set(t);
|
|
490
491
|
};
|
|
491
|
-
function
|
|
492
|
+
function Re(e, t) {
|
|
492
493
|
const r = `SHA-${e.slice(-3)}`;
|
|
493
494
|
switch (e) {
|
|
494
495
|
case "HS256":
|
|
@@ -513,20 +514,20 @@ function Pe(e, t) {
|
|
|
513
514
|
throw new w(`alg ${e} is not supported either by JOSE or your javascript runtime`);
|
|
514
515
|
}
|
|
515
516
|
}
|
|
516
|
-
async function
|
|
517
|
+
async function _e(e, t, r) {
|
|
517
518
|
if (t = await Ee.normalizePublicKey(t, e), G(t))
|
|
518
519
|
return ue(t, e, r), t;
|
|
519
520
|
if (t instanceof Uint8Array) {
|
|
520
521
|
if (!e.startsWith("HS"))
|
|
521
|
-
throw new TypeError(L(t, ...
|
|
522
|
+
throw new TypeError(L(t, ..._));
|
|
522
523
|
return x.subtle.importKey("raw", t, { hash: `SHA-${e.slice(-3)}`, name: "HMAC" }, !1, [r]);
|
|
523
524
|
}
|
|
524
|
-
throw new TypeError(L(t, ...
|
|
525
|
+
throw new TypeError(L(t, ..._, "Uint8Array"));
|
|
525
526
|
}
|
|
526
|
-
const
|
|
527
|
-
const a = await
|
|
527
|
+
const Pe = async (e, t, r, n) => {
|
|
528
|
+
const a = await _e(e, t, "verify");
|
|
528
529
|
fe(e, a);
|
|
529
|
-
const i =
|
|
530
|
+
const i = Re(e, a.algorithm);
|
|
530
531
|
try {
|
|
531
532
|
return await x.subtle.verify(i, a, r, n);
|
|
532
533
|
} catch {
|
|
@@ -534,7 +535,7 @@ const _e = async (e, t, r, n) => {
|
|
|
534
535
|
}
|
|
535
536
|
};
|
|
536
537
|
async function xe(e, t, r) {
|
|
537
|
-
if (!
|
|
538
|
+
if (!P(e))
|
|
538
539
|
throw new u("Flattened JWS must be an object");
|
|
539
540
|
if (e.protected === void 0 && e.header === void 0)
|
|
540
541
|
throw new u('Flattened JWS must have either of the "protected" or "header" members');
|
|
@@ -544,13 +545,13 @@ async function xe(e, t, r) {
|
|
|
544
545
|
throw new u("JWS Payload missing");
|
|
545
546
|
if (typeof e.signature != "string")
|
|
546
547
|
throw new u("JWS Signature missing or incorrect type");
|
|
547
|
-
if (e.header !== void 0 && !
|
|
548
|
+
if (e.header !== void 0 && !P(e.header))
|
|
548
549
|
throw new u("JWS Unprotected Header incorrect type");
|
|
549
550
|
let n = {};
|
|
550
551
|
if (e.protected)
|
|
551
552
|
try {
|
|
552
|
-
const
|
|
553
|
-
n = JSON.parse(C.decode(
|
|
553
|
+
const K = b(e.protected);
|
|
554
|
+
n = JSON.parse(C.decode(K));
|
|
554
555
|
} catch {
|
|
555
556
|
throw new u("JWS Protected Header is invalid");
|
|
556
557
|
}
|
|
@@ -579,16 +580,16 @@ async function xe(e, t, r) {
|
|
|
579
580
|
const g = ae(v.encode(e.protected ?? ""), v.encode("."), typeof e.payload == "string" ? v.encode(e.payload) : e.payload);
|
|
580
581
|
let h;
|
|
581
582
|
try {
|
|
582
|
-
h =
|
|
583
|
+
h = b(e.signature);
|
|
583
584
|
} catch {
|
|
584
585
|
throw new u("Failed to base64url decode the signature");
|
|
585
586
|
}
|
|
586
|
-
if (!await
|
|
587
|
+
if (!await Pe(c, t, h, g))
|
|
587
588
|
throw new ce();
|
|
588
589
|
let y;
|
|
589
590
|
if (o)
|
|
590
591
|
try {
|
|
591
|
-
y =
|
|
592
|
+
y = b(e.payload);
|
|
592
593
|
} catch {
|
|
593
594
|
throw new u("Failed to base64url decode the payload");
|
|
594
595
|
}
|
|
@@ -597,7 +598,7 @@ async function xe(e, t, r) {
|
|
|
597
598
|
const l = { payload: y };
|
|
598
599
|
return e.protected !== void 0 && (l.protectedHeader = n), e.header !== void 0 && (l.unprotectedHeader = e.header), p ? { ...l, key: t } : l;
|
|
599
600
|
}
|
|
600
|
-
async function
|
|
601
|
+
async function Ke(e, t, r) {
|
|
601
602
|
if (e instanceof Uint8Array && (e = C.decode(e)), typeof e != "string")
|
|
602
603
|
throw new u("Compact JWS must be a string or Uint8Array");
|
|
603
604
|
const { 0: n, 1: a, 2: i, length: o } = e.split(".");
|
|
@@ -606,7 +607,7 @@ async function Oe(e, t, r) {
|
|
|
606
607
|
const c = await xe({ payload: a, protected: n, signature: i }, t, r), s = { payload: c.payload, protectedHeader: c.protectedHeader };
|
|
607
608
|
return typeof t == "function" ? { ...s, key: c.key } : s;
|
|
608
609
|
}
|
|
609
|
-
const
|
|
610
|
+
const Oe = (e) => Math.floor(e.getTime() / 1e3), ee = 60, te = ee * 60, H = te * 24, We = H * 7, Je = H * 365.25, De = /^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i, V = (e) => {
|
|
610
611
|
const t = De.exec(e);
|
|
611
612
|
if (!t || t[4] && t[1])
|
|
612
613
|
throw new TypeError("Invalid time period format");
|
|
@@ -655,7 +656,7 @@ const Ke = (e) => Math.floor(e.getTime() / 1e3), ee = 60, te = ee * 60, H = te *
|
|
|
655
656
|
n = JSON.parse(C.decode(t));
|
|
656
657
|
} catch {
|
|
657
658
|
}
|
|
658
|
-
if (!
|
|
659
|
+
if (!P(n))
|
|
659
660
|
throw new S("JWT Claims Set must be a top-level JSON object");
|
|
660
661
|
const { typ: a } = r;
|
|
661
662
|
if (a && (typeof e.typ != "string" || k(e.typ) !== k(a)))
|
|
@@ -685,7 +686,7 @@ const Ke = (e) => Math.floor(e.getTime() / 1e3), ee = 60, te = ee * 60, H = te *
|
|
|
685
686
|
default:
|
|
686
687
|
throw new TypeError("Invalid clockTolerance option type");
|
|
687
688
|
}
|
|
688
|
-
const { currentDate: U } = r, y =
|
|
689
|
+
const { currentDate: U } = r, y = Oe(U || /* @__PURE__ */ new Date());
|
|
689
690
|
if ((n.iat !== void 0 || p) && typeof n.iat != "number")
|
|
690
691
|
throw new f('"iat" claim must be a number', n, "iat", "invalid");
|
|
691
692
|
if (n.nbf !== void 0) {
|
|
@@ -701,8 +702,8 @@ const Ke = (e) => Math.floor(e.getTime() / 1e3), ee = 60, te = ee * 60, H = te *
|
|
|
701
702
|
throw new $('"exp" claim timestamp check failed', n, "exp", "check_failed");
|
|
702
703
|
}
|
|
703
704
|
if (p) {
|
|
704
|
-
const l = y - n.iat,
|
|
705
|
-
if (l - h >
|
|
705
|
+
const l = y - n.iat, K = typeof p == "number" ? p : V(p);
|
|
706
|
+
if (l - h > K)
|
|
706
707
|
throw new $('"iat" claim timestamp check failed (too far in the past)', n, "iat", "check_failed");
|
|
707
708
|
if (l < 0 - h)
|
|
708
709
|
throw new f('"iat" claim timestamp check failed (it should be in the past)', n, "iat", "check_failed");
|
|
@@ -711,13 +712,13 @@ const Ke = (e) => Math.floor(e.getTime() / 1e3), ee = 60, te = ee * 60, H = te *
|
|
|
711
712
|
};
|
|
712
713
|
async function Ne(e, t, r) {
|
|
713
714
|
var o;
|
|
714
|
-
const n = await
|
|
715
|
+
const n = await Ke(e, t, r);
|
|
715
716
|
if ((o = n.protectedHeader.crit) != null && o.includes("b64") && n.protectedHeader.b64 === !1)
|
|
716
717
|
throw new S("JWTs MUST NOT use unencoded payload");
|
|
717
718
|
const i = { payload: Ue(n.protectedHeader, n.payload, r), protectedHeader: n.protectedHeader };
|
|
718
719
|
return typeof t == "function" ? { ...i, key: n.key } : i;
|
|
719
720
|
}
|
|
720
|
-
const $e =
|
|
721
|
+
const $e = b;
|
|
721
722
|
function Le(e) {
|
|
722
723
|
if (typeof e != "string")
|
|
723
724
|
throw new S("JWTs must use Compact JWS serialization, JWT must be a string");
|
|
@@ -740,13 +741,13 @@ function Le(e) {
|
|
|
740
741
|
} catch {
|
|
741
742
|
throw new S("Failed to parse the decoded payload as JSON");
|
|
742
743
|
}
|
|
743
|
-
if (!
|
|
744
|
+
if (!P(a))
|
|
744
745
|
throw new S("Invalid JWT Claims Set");
|
|
745
746
|
return a;
|
|
746
747
|
}
|
|
747
748
|
const Xe = async (e) => {
|
|
748
749
|
try {
|
|
749
|
-
const t = N.ALG, n = await
|
|
750
|
+
const t = N.ALG, n = await Ae(ne, t);
|
|
750
751
|
return await Ne(e, n, {
|
|
751
752
|
issuer: N.ISSUER
|
|
752
753
|
});
|
|
@@ -810,10 +811,10 @@ async function et(e, t) {
|
|
|
810
811
|
export {
|
|
811
812
|
Qe as API_TYPE,
|
|
812
813
|
Ge as AUTH_TYPES,
|
|
813
|
-
|
|
814
|
+
Ye as HEADERS,
|
|
814
815
|
N as JWT,
|
|
815
816
|
ne as JWT_PUBLIC_KEY,
|
|
816
|
-
|
|
817
|
+
ze as TOKEN_EXPIRATION,
|
|
817
818
|
Ze as decodeToken,
|
|
818
819
|
re as generateCodeChallenge,
|
|
819
820
|
je as pkceChallengePair,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versini/auth-common",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"publishConfig": {
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"jose": "5.6.2",
|
|
36
36
|
"uuid": "10.0.0"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "b1190439a142ac9c34d7744273ed3cebbccabc15"
|
|
39
39
|
}
|