@versini/auth-provider 5.3.0 → 6.0.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 +9 -0
- package/dist/index.js +180 -169
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,14 @@ import { AUTH_TYPES } from '@versini/auth-common';
|
|
|
3
3
|
export { AUTH_TYPES } from '@versini/auth-common';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
|
|
6
|
+
type AuthenticationTypes =
|
|
7
|
+
| typeof AUTH_TYPES.PASSKEY
|
|
8
|
+
| typeof AUTH_TYPES.CODE
|
|
9
|
+
| typeof AUTH_TYPES.ID_TOKEN
|
|
10
|
+
| typeof AUTH_TYPES.ACCESS_TOKEN
|
|
11
|
+
| typeof AUTH_TYPES.ID_AND_ACCESS_TOKEN
|
|
12
|
+
| null;
|
|
13
|
+
|
|
6
14
|
type AuthProviderProps = {
|
|
7
15
|
children: React.ReactNode;
|
|
8
16
|
sessionExpiration?: string;
|
|
@@ -15,6 +23,7 @@ type AuthState = {
|
|
|
15
23
|
isLoading: boolean;
|
|
16
24
|
isAuthenticated: boolean;
|
|
17
25
|
logoutReason?: string;
|
|
26
|
+
authenticationType: AuthenticationTypes;
|
|
18
27
|
user?: {
|
|
19
28
|
userId?: string;
|
|
20
29
|
username?: string;
|
package/dist/index.js
CHANGED
|
@@ -4,26 +4,26 @@ var M = (e, t, r) => ht(e, typeof t != "symbol" ? t + "" : t, r);
|
|
|
4
4
|
import { jsx as Te } from "react/jsx-runtime";
|
|
5
5
|
import pt, { useSyncExternalStore as ft, useCallback as x, useEffect as Ke, createContext as yt, useReducer as mt, useRef as Et, useContext as wt } from "react";
|
|
6
6
|
/*!
|
|
7
|
-
@versini/auth-provider
|
|
7
|
+
@versini/auth-provider v6.0.0
|
|
8
8
|
© 2024 gizmette.com
|
|
9
9
|
*/
|
|
10
10
|
try {
|
|
11
11
|
window.__VERSINI_AUTH_CLIENT__ || (window.__VERSINI_AUTH_CLIENT__ = {
|
|
12
|
-
version: "
|
|
13
|
-
buildTime: "07/
|
|
12
|
+
version: "6.0.0",
|
|
13
|
+
buildTime: "07/15/2024 12:46 PM EDT",
|
|
14
14
|
homepage: "https://github.com/aversini/auth-client",
|
|
15
15
|
license: "MIT"
|
|
16
16
|
});
|
|
17
17
|
} catch {
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function _(e) {
|
|
20
20
|
const t = new Uint8Array(e);
|
|
21
21
|
let r = "";
|
|
22
22
|
for (const a of t)
|
|
23
23
|
r += String.fromCharCode(a);
|
|
24
24
|
return btoa(r).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function te(e) {
|
|
27
27
|
const t = e.replace(/-/g, "+").replace(/_/g, "/"), r = (4 - t.length % 4) % 4, n = t.padEnd(t.length + r, "="), a = atob(n), o = new ArrayBuffer(a.length), s = new Uint8Array(o);
|
|
28
28
|
for (let i = 0; i < a.length; i++)
|
|
29
29
|
s[i] = a.charCodeAt(i);
|
|
@@ -36,7 +36,7 @@ function He(e) {
|
|
|
36
36
|
const { id: t } = e;
|
|
37
37
|
return {
|
|
38
38
|
...e,
|
|
39
|
-
id:
|
|
39
|
+
id: te(t),
|
|
40
40
|
transports: e.transports
|
|
41
41
|
};
|
|
42
42
|
}
|
|
@@ -153,10 +153,10 @@ async function Tt(e) {
|
|
|
153
153
|
throw new Error("WebAuthn is not supported in this browser");
|
|
154
154
|
const r = { publicKey: {
|
|
155
155
|
...e,
|
|
156
|
-
challenge:
|
|
156
|
+
challenge: te(e.challenge),
|
|
157
157
|
user: {
|
|
158
158
|
...e.user,
|
|
159
|
-
id:
|
|
159
|
+
id: te(e.user.id)
|
|
160
160
|
},
|
|
161
161
|
excludeCredentials: (m = e.excludeCredentials) == null ? void 0 : m.map(He)
|
|
162
162
|
} };
|
|
@@ -183,23 +183,23 @@ async function Tt(e) {
|
|
|
183
183
|
if (typeof s.getPublicKey == "function")
|
|
184
184
|
try {
|
|
185
185
|
const d = s.getPublicKey();
|
|
186
|
-
d !== null && (l =
|
|
186
|
+
d !== null && (l = _(d));
|
|
187
187
|
} catch (d) {
|
|
188
188
|
ce("getPublicKey()", d);
|
|
189
189
|
}
|
|
190
190
|
let f;
|
|
191
191
|
if (typeof s.getAuthenticatorData == "function")
|
|
192
192
|
try {
|
|
193
|
-
f =
|
|
193
|
+
f = _(s.getAuthenticatorData());
|
|
194
194
|
} catch (d) {
|
|
195
195
|
ce("getAuthenticatorData()", d);
|
|
196
196
|
}
|
|
197
197
|
return {
|
|
198
198
|
id: a,
|
|
199
|
-
rawId:
|
|
199
|
+
rawId: _(o),
|
|
200
200
|
response: {
|
|
201
|
-
attestationObject:
|
|
202
|
-
clientDataJSON:
|
|
201
|
+
attestationObject: _(s.attestationObject),
|
|
202
|
+
clientDataJSON: _(s.clientDataJSON),
|
|
203
203
|
transports: u,
|
|
204
204
|
publicKeyAlgorithm: h,
|
|
205
205
|
publicKey: l,
|
|
@@ -261,7 +261,7 @@ function It({ error: e, options: t }) {
|
|
|
261
261
|
}
|
|
262
262
|
return e;
|
|
263
263
|
}
|
|
264
|
-
async function
|
|
264
|
+
async function _t(e, t = !1) {
|
|
265
265
|
var f, m;
|
|
266
266
|
if (!Ee())
|
|
267
267
|
throw new Error("WebAuthn is not supported in this browser");
|
|
@@ -269,7 +269,7 @@ async function bt(e, t = !1) {
|
|
|
269
269
|
((f = e.allowCredentials) == null ? void 0 : f.length) !== 0 && (r = (m = e.allowCredentials) == null ? void 0 : m.map(He));
|
|
270
270
|
const n = {
|
|
271
271
|
...e,
|
|
272
|
-
challenge:
|
|
272
|
+
challenge: te(e.challenge),
|
|
273
273
|
allowCredentials: r
|
|
274
274
|
}, a = {};
|
|
275
275
|
if (t) {
|
|
@@ -290,13 +290,13 @@ async function bt(e, t = !1) {
|
|
|
290
290
|
throw new Error("Authentication was not completed");
|
|
291
291
|
const { id: s, rawId: i, response: u, type: h } = o;
|
|
292
292
|
let l;
|
|
293
|
-
return u.userHandle && (l =
|
|
293
|
+
return u.userHandle && (l = _(u.userHandle)), {
|
|
294
294
|
id: s,
|
|
295
|
-
rawId:
|
|
295
|
+
rawId: _(i),
|
|
296
296
|
response: {
|
|
297
|
-
authenticatorData:
|
|
298
|
-
clientDataJSON:
|
|
299
|
-
signature:
|
|
297
|
+
authenticatorData: _(u.authenticatorData),
|
|
298
|
+
clientDataJSON: _(u.clientDataJSON),
|
|
299
|
+
signature: _(u.signature),
|
|
300
300
|
userHandle: l
|
|
301
301
|
},
|
|
302
302
|
type: h,
|
|
@@ -305,34 +305,36 @@ async function bt(e, t = !1) {
|
|
|
305
305
|
};
|
|
306
306
|
}
|
|
307
307
|
/*!
|
|
308
|
-
@versini/auth-common v2.
|
|
308
|
+
@versini/auth-common v2.12.1
|
|
309
309
|
© 2024 gizmette.com
|
|
310
310
|
*/
|
|
311
311
|
try {
|
|
312
312
|
window.__VERSINI_AUTH_COMMON__ || (window.__VERSINI_AUTH_COMMON__ = {
|
|
313
|
-
version: "2.
|
|
314
|
-
buildTime: "07/
|
|
313
|
+
version: "2.12.1",
|
|
314
|
+
buildTime: "07/15/2024 12:46 PM EDT",
|
|
315
315
|
homepage: "https://github.com/aversini/auth-client",
|
|
316
316
|
license: "MIT"
|
|
317
317
|
});
|
|
318
318
|
} catch {
|
|
319
319
|
}
|
|
320
|
-
const
|
|
320
|
+
const Y = {
|
|
321
321
|
ID_TOKEN: "id_token",
|
|
322
322
|
ACCESS_TOKEN: "token",
|
|
323
323
|
ID_AND_ACCESS_TOKEN: "id_token token",
|
|
324
324
|
CODE: "code",
|
|
325
|
-
REFRESH_TOKEN: "refresh_token"
|
|
325
|
+
REFRESH_TOKEN: "refresh_token",
|
|
326
|
+
PASSKEY: "passkey"
|
|
326
327
|
}, xe = {
|
|
327
328
|
CLIENT_ID: "X-Auth-ClientId"
|
|
328
|
-
},
|
|
329
|
+
}, S = {
|
|
329
330
|
ALG: "RS256",
|
|
330
331
|
USER_ID_KEY: "sub",
|
|
331
332
|
TOKEN_ID_KEY: "__raw",
|
|
332
333
|
NONCE_KEY: "_nonce",
|
|
333
334
|
USERNAME_KEY: "username",
|
|
335
|
+
AUTH_TYPE_KEY: "auth_type",
|
|
334
336
|
ISSUER: "gizmette.com"
|
|
335
|
-
},
|
|
337
|
+
}, bt = `-----BEGIN PUBLIC KEY-----
|
|
336
338
|
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsF6i3Jd9fY/3COqCw/m7
|
|
337
339
|
w5PKyTYLGAI2I6SIIdpe6i6DOCbEkmDz7LdVsBqwNtVi8gvWYIj+8ol6rU3qu1v5
|
|
338
340
|
i1Jd45GSK4kzkVdgCmQZbM5ak0KI99q5wsrAIzUd+LRJ2HRvWtr5IYdsIiXaQjle
|
|
@@ -344,24 +346,24 @@ awIDAQAB
|
|
|
344
346
|
AUTHENTICATE: "authenticate",
|
|
345
347
|
CODE: "code",
|
|
346
348
|
LOGOUT: "logout"
|
|
347
|
-
}, se = crypto,
|
|
348
|
-
function
|
|
349
|
+
}, se = crypto, Ye = (e) => e instanceof CryptoKey, V = new TextEncoder(), oe = new TextDecoder();
|
|
350
|
+
function kt(...e) {
|
|
349
351
|
const t = e.reduce((a, { length: o }) => a + o, 0), r = new Uint8Array(t);
|
|
350
352
|
let n = 0;
|
|
351
353
|
for (const a of e)
|
|
352
354
|
r.set(a, n), n += a.length;
|
|
353
355
|
return r;
|
|
354
356
|
}
|
|
355
|
-
const
|
|
357
|
+
const Ot = (e) => {
|
|
356
358
|
const t = atob(e), r = new Uint8Array(t.length);
|
|
357
359
|
for (let n = 0; n < t.length; n++)
|
|
358
360
|
r[n] = t.charCodeAt(n);
|
|
359
361
|
return r;
|
|
360
|
-
},
|
|
362
|
+
}, Z = (e) => {
|
|
361
363
|
let t = e;
|
|
362
364
|
t instanceof Uint8Array && (t = oe.decode(t)), t = t.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "");
|
|
363
365
|
try {
|
|
364
|
-
return
|
|
366
|
+
return Ot(t);
|
|
365
367
|
} catch {
|
|
366
368
|
throw new TypeError("The input to be decoded is not correctly encoded.");
|
|
367
369
|
}
|
|
@@ -399,7 +401,7 @@ class Pt extends v {
|
|
|
399
401
|
return "ERR_JOSE_ALG_NOT_ALLOWED";
|
|
400
402
|
}
|
|
401
403
|
}
|
|
402
|
-
class
|
|
404
|
+
class O extends v {
|
|
403
405
|
constructor() {
|
|
404
406
|
super(...arguments), this.code = "ERR_JOSE_NOT_SUPPORTED";
|
|
405
407
|
}
|
|
@@ -415,7 +417,7 @@ class g extends v {
|
|
|
415
417
|
return "ERR_JWS_INVALID";
|
|
416
418
|
}
|
|
417
419
|
}
|
|
418
|
-
let
|
|
420
|
+
let Ge = class extends v {
|
|
419
421
|
constructor() {
|
|
420
422
|
super(...arguments), this.code = "ERR_JWT_INVALID";
|
|
421
423
|
}
|
|
@@ -431,7 +433,7 @@ class vt extends v {
|
|
|
431
433
|
return "ERR_JWS_SIGNATURE_VERIFICATION_FAILED";
|
|
432
434
|
}
|
|
433
435
|
}
|
|
434
|
-
function
|
|
436
|
+
function b(e, t = "algorithm.name") {
|
|
435
437
|
return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`);
|
|
436
438
|
}
|
|
437
439
|
function J(e, t) {
|
|
@@ -468,45 +470,45 @@ function Dt(e, t, ...r) {
|
|
|
468
470
|
case "HS384":
|
|
469
471
|
case "HS512": {
|
|
470
472
|
if (!J(e.algorithm, "HMAC"))
|
|
471
|
-
throw
|
|
473
|
+
throw b("HMAC");
|
|
472
474
|
const n = parseInt(t.slice(2), 10);
|
|
473
475
|
if (ue(e.algorithm.hash) !== n)
|
|
474
|
-
throw
|
|
476
|
+
throw b(`SHA-${n}`, "algorithm.hash");
|
|
475
477
|
break;
|
|
476
478
|
}
|
|
477
479
|
case "RS256":
|
|
478
480
|
case "RS384":
|
|
479
481
|
case "RS512": {
|
|
480
482
|
if (!J(e.algorithm, "RSASSA-PKCS1-v1_5"))
|
|
481
|
-
throw
|
|
483
|
+
throw b("RSASSA-PKCS1-v1_5");
|
|
482
484
|
const n = parseInt(t.slice(2), 10);
|
|
483
485
|
if (ue(e.algorithm.hash) !== n)
|
|
484
|
-
throw
|
|
486
|
+
throw b(`SHA-${n}`, "algorithm.hash");
|
|
485
487
|
break;
|
|
486
488
|
}
|
|
487
489
|
case "PS256":
|
|
488
490
|
case "PS384":
|
|
489
491
|
case "PS512": {
|
|
490
492
|
if (!J(e.algorithm, "RSA-PSS"))
|
|
491
|
-
throw
|
|
493
|
+
throw b("RSA-PSS");
|
|
492
494
|
const n = parseInt(t.slice(2), 10);
|
|
493
495
|
if (ue(e.algorithm.hash) !== n)
|
|
494
|
-
throw
|
|
496
|
+
throw b(`SHA-${n}`, "algorithm.hash");
|
|
495
497
|
break;
|
|
496
498
|
}
|
|
497
499
|
case "EdDSA": {
|
|
498
500
|
if (e.algorithm.name !== "Ed25519" && e.algorithm.name !== "Ed448")
|
|
499
|
-
throw
|
|
501
|
+
throw b("Ed25519 or Ed448");
|
|
500
502
|
break;
|
|
501
503
|
}
|
|
502
504
|
case "ES256":
|
|
503
505
|
case "ES384":
|
|
504
506
|
case "ES512": {
|
|
505
507
|
if (!J(e.algorithm, "ECDSA"))
|
|
506
|
-
throw
|
|
508
|
+
throw b("ECDSA");
|
|
507
509
|
const n = Ct(t);
|
|
508
510
|
if (e.algorithm.namedCurve !== n)
|
|
509
|
-
throw
|
|
511
|
+
throw b(n, "algorithm.namedCurve");
|
|
510
512
|
break;
|
|
511
513
|
}
|
|
512
514
|
default:
|
|
@@ -514,7 +516,7 @@ function Dt(e, t, ...r) {
|
|
|
514
516
|
}
|
|
515
517
|
Nt(e, r);
|
|
516
518
|
}
|
|
517
|
-
function
|
|
519
|
+
function Me(e, t, ...r) {
|
|
518
520
|
var n;
|
|
519
521
|
if (r.length > 2) {
|
|
520
522
|
const a = r.pop();
|
|
@@ -522,11 +524,11 @@ function Ve(e, t, ...r) {
|
|
|
522
524
|
} else r.length === 2 ? e += `one of type ${r[0]} or ${r[1]}.` : e += `of type ${r[0]}.`;
|
|
523
525
|
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;
|
|
524
526
|
}
|
|
525
|
-
const Ie = (e, ...t) =>
|
|
526
|
-
function
|
|
527
|
-
return
|
|
527
|
+
const Ie = (e, ...t) => Me("Key must be ", e, ...t);
|
|
528
|
+
function Ve(e, t, ...r) {
|
|
529
|
+
return Me(`Key for the ${e} algorithm must be `, t, ...r);
|
|
528
530
|
}
|
|
529
|
-
const
|
|
531
|
+
const Je = (e) => Ye(e) ? !0 : (e == null ? void 0 : e[Symbol.toStringTag]) === "KeyObject", re = ["CryptoKey"], Ut = (...e) => {
|
|
530
532
|
const t = e.filter(Boolean);
|
|
531
533
|
if (t.length === 0 || t.length === 1)
|
|
532
534
|
return !0;
|
|
@@ -590,7 +592,7 @@ function $t(e) {
|
|
|
590
592
|
}, r = e.d ? ["decrypt", "unwrapKey"] : ["encrypt", "wrapKey"];
|
|
591
593
|
break;
|
|
592
594
|
default:
|
|
593
|
-
throw new
|
|
595
|
+
throw new O('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
594
596
|
}
|
|
595
597
|
break;
|
|
596
598
|
}
|
|
@@ -612,7 +614,7 @@ function $t(e) {
|
|
|
612
614
|
t = { name: "ECDH", namedCurve: e.crv }, r = e.d ? ["deriveBits"] : [];
|
|
613
615
|
break;
|
|
614
616
|
default:
|
|
615
|
-
throw new
|
|
617
|
+
throw new O('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
616
618
|
}
|
|
617
619
|
break;
|
|
618
620
|
}
|
|
@@ -628,12 +630,12 @@ function $t(e) {
|
|
|
628
630
|
t = { name: e.crv }, r = e.d ? ["deriveBits"] : [];
|
|
629
631
|
break;
|
|
630
632
|
default:
|
|
631
|
-
throw new
|
|
633
|
+
throw new O('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
632
634
|
}
|
|
633
635
|
break;
|
|
634
636
|
}
|
|
635
637
|
default:
|
|
636
|
-
throw new
|
|
638
|
+
throw new O('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
|
|
637
639
|
}
|
|
638
640
|
return { algorithm: t, keyUsages: r };
|
|
639
641
|
}
|
|
@@ -646,7 +648,7 @@ const Lt = async (e) => {
|
|
|
646
648
|
e.key_ops ?? r
|
|
647
649
|
], a = { ...e };
|
|
648
650
|
return delete a.alg, delete a.use, se.subtle.importKey("jwk", a, ...n);
|
|
649
|
-
}, je = (e) =>
|
|
651
|
+
}, je = (e) => Z(e);
|
|
650
652
|
let le, de;
|
|
651
653
|
const Fe = (e) => (e == null ? void 0 : e[Symbol.toStringTag]) === "KeyObject", Be = async (e, t, r, n) => {
|
|
652
654
|
let a = e.get(t);
|
|
@@ -666,33 +668,33 @@ const Fe = (e) => (e == null ? void 0 : e[Symbol.toStringTag]) === "KeyObject",
|
|
|
666
668
|
return r.k ? je(r.k) : (le || (le = /* @__PURE__ */ new WeakMap()), Be(le, e, r, t));
|
|
667
669
|
}
|
|
668
670
|
return e;
|
|
669
|
-
},
|
|
671
|
+
}, Yt = { normalizePublicKey: Wt, normalizePrivateKey: xt }, k = (e, t, r = 0) => {
|
|
670
672
|
r === 0 && (t.unshift(t.length), t.unshift(6));
|
|
671
673
|
const n = e.indexOf(t[0], r);
|
|
672
674
|
if (n === -1)
|
|
673
675
|
return !1;
|
|
674
676
|
const a = e.subarray(n, n + t.length);
|
|
675
|
-
return a.length !== t.length ? !1 : a.every((o, s) => o === t[s]) ||
|
|
676
|
-
},
|
|
677
|
+
return a.length !== t.length ? !1 : a.every((o, s) => o === t[s]) || k(e, t, n + 1);
|
|
678
|
+
}, _e = (e) => {
|
|
677
679
|
switch (!0) {
|
|
678
|
-
case
|
|
680
|
+
case k(e, [42, 134, 72, 206, 61, 3, 1, 7]):
|
|
679
681
|
return "P-256";
|
|
680
|
-
case
|
|
682
|
+
case k(e, [43, 129, 4, 0, 34]):
|
|
681
683
|
return "P-384";
|
|
682
|
-
case
|
|
684
|
+
case k(e, [43, 129, 4, 0, 35]):
|
|
683
685
|
return "P-521";
|
|
684
|
-
case
|
|
686
|
+
case k(e, [43, 101, 110]):
|
|
685
687
|
return "X25519";
|
|
686
|
-
case
|
|
688
|
+
case k(e, [43, 101, 111]):
|
|
687
689
|
return "X448";
|
|
688
|
-
case
|
|
690
|
+
case k(e, [43, 101, 112]):
|
|
689
691
|
return "Ed25519";
|
|
690
|
-
case
|
|
692
|
+
case k(e, [43, 101, 113]):
|
|
691
693
|
return "Ed448";
|
|
692
694
|
default:
|
|
693
|
-
throw new
|
|
695
|
+
throw new O("Invalid or unsupported EC Key Curve or OKP Key Sub Type");
|
|
694
696
|
}
|
|
695
|
-
},
|
|
697
|
+
}, Gt = async (e, t, r, n, a) => {
|
|
696
698
|
let o, s;
|
|
697
699
|
const i = new Uint8Array(atob(r.replace(e, "")).split("").map((u) => u.charCodeAt(0)));
|
|
698
700
|
switch (n) {
|
|
@@ -728,41 +730,41 @@ const Fe = (e) => (e == null ? void 0 : e[Symbol.toStringTag]) === "KeyObject",
|
|
|
728
730
|
case "ECDH-ES+A128KW":
|
|
729
731
|
case "ECDH-ES+A192KW":
|
|
730
732
|
case "ECDH-ES+A256KW": {
|
|
731
|
-
const u =
|
|
733
|
+
const u = _e(i);
|
|
732
734
|
o = u.startsWith("P-") ? { name: "ECDH", namedCurve: u } : { name: u }, s = [];
|
|
733
735
|
break;
|
|
734
736
|
}
|
|
735
737
|
case "EdDSA":
|
|
736
|
-
o = { name:
|
|
738
|
+
o = { name: _e(i) }, s = ["verify"];
|
|
737
739
|
break;
|
|
738
740
|
default:
|
|
739
|
-
throw new
|
|
741
|
+
throw new O('Invalid or unsupported "alg" (Algorithm) value');
|
|
740
742
|
}
|
|
741
743
|
return se.subtle.importKey(t, i, o, !1, s);
|
|
742
|
-
},
|
|
743
|
-
async function
|
|
744
|
+
}, Mt = (e, t, r) => Gt(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g, "spki", e, t);
|
|
745
|
+
async function Vt(e, t, r) {
|
|
744
746
|
if (e.indexOf("-----BEGIN PUBLIC KEY-----") !== 0)
|
|
745
747
|
throw new TypeError('"spki" must be SPKI formatted string');
|
|
746
|
-
return
|
|
748
|
+
return Mt(e, t);
|
|
747
749
|
}
|
|
748
|
-
const
|
|
750
|
+
const ee = (e) => e == null ? void 0 : e[Symbol.toStringTag], Jt = (e, t) => {
|
|
749
751
|
if (!(t instanceof Uint8Array)) {
|
|
750
|
-
if (!
|
|
751
|
-
throw new TypeError(
|
|
752
|
+
if (!Je(t))
|
|
753
|
+
throw new TypeError(Ve(e, t, ...re, "Uint8Array"));
|
|
752
754
|
if (t.type !== "secret")
|
|
753
|
-
throw new TypeError(`${
|
|
755
|
+
throw new TypeError(`${ee(t)} instances for symmetric algorithms must be of type "secret"`);
|
|
754
756
|
}
|
|
755
757
|
}, jt = (e, t, r) => {
|
|
756
|
-
if (!
|
|
757
|
-
throw new TypeError(
|
|
758
|
+
if (!Je(t))
|
|
759
|
+
throw new TypeError(Ve(e, t, ...re));
|
|
758
760
|
if (t.type === "secret")
|
|
759
|
-
throw new TypeError(`${
|
|
761
|
+
throw new TypeError(`${ee(t)} instances for asymmetric algorithms must not be of type "secret"`);
|
|
760
762
|
if (t.algorithm && r === "verify" && t.type === "private")
|
|
761
|
-
throw new TypeError(`${
|
|
763
|
+
throw new TypeError(`${ee(t)} instances for asymmetric algorithm verifying must be of type "public"`);
|
|
762
764
|
if (t.algorithm && r === "encrypt" && t.type === "private")
|
|
763
|
-
throw new TypeError(`${
|
|
765
|
+
throw new TypeError(`${ee(t)} instances for asymmetric algorithm encryption must be of type "public"`);
|
|
764
766
|
}, Ft = (e, t, r) => {
|
|
765
|
-
e.startsWith("HS") || e === "dir" || e.startsWith("PBES2") || /^A\d{3}(?:GCM)?KW$/.test(e) ?
|
|
767
|
+
e.startsWith("HS") || e === "dir" || e.startsWith("PBES2") || /^A\d{3}(?:GCM)?KW$/.test(e) ? Jt(e, t) : jt(e, t, r);
|
|
766
768
|
};
|
|
767
769
|
function Bt(e, t, r, n, a) {
|
|
768
770
|
if (a.crit !== void 0 && (n == null ? void 0 : n.crit) === void 0)
|
|
@@ -775,7 +777,7 @@ function Bt(e, t, r, n, a) {
|
|
|
775
777
|
r !== void 0 ? o = new Map([...Object.entries(r), ...t.entries()]) : o = t;
|
|
776
778
|
for (const s of n.crit) {
|
|
777
779
|
if (!o.has(s))
|
|
778
|
-
throw new
|
|
780
|
+
throw new O(`Extension Header Parameter "${s}" is not recognized`);
|
|
779
781
|
if (a[s] === void 0)
|
|
780
782
|
throw new e(`Extension Header Parameter "${s}" is missing`);
|
|
781
783
|
if (o.get(s) && n[s] === void 0)
|
|
@@ -811,18 +813,18 @@ function zt(e, t) {
|
|
|
811
813
|
case "EdDSA":
|
|
812
814
|
return { name: t.name };
|
|
813
815
|
default:
|
|
814
|
-
throw new
|
|
816
|
+
throw new O(`alg ${e} is not supported either by JOSE or your javascript runtime`);
|
|
815
817
|
}
|
|
816
818
|
}
|
|
817
819
|
async function Qt(e, t, r) {
|
|
818
|
-
if (t = await
|
|
820
|
+
if (t = await Yt.normalizePublicKey(t, e), Ye(t))
|
|
819
821
|
return Dt(t, e, r), t;
|
|
820
822
|
if (t instanceof Uint8Array) {
|
|
821
823
|
if (!e.startsWith("HS"))
|
|
822
|
-
throw new TypeError(Ie(t, ...
|
|
824
|
+
throw new TypeError(Ie(t, ...re));
|
|
823
825
|
return se.subtle.importKey("raw", t, { hash: `SHA-${e.slice(-3)}`, name: "HMAC" }, !1, [r]);
|
|
824
826
|
}
|
|
825
|
-
throw new TypeError(Ie(t, ...
|
|
827
|
+
throw new TypeError(Ie(t, ...re, "Uint8Array"));
|
|
826
828
|
}
|
|
827
829
|
const Xt = async (e, t, r, n) => {
|
|
828
830
|
const a = await Qt(e, t, "verify");
|
|
@@ -850,8 +852,8 @@ async function Zt(e, t, r) {
|
|
|
850
852
|
let n = {};
|
|
851
853
|
if (e.protected)
|
|
852
854
|
try {
|
|
853
|
-
const
|
|
854
|
-
n = JSON.parse(oe.decode(
|
|
855
|
+
const T = Z(e.protected);
|
|
856
|
+
n = JSON.parse(oe.decode(T));
|
|
855
857
|
} catch {
|
|
856
858
|
throw new g("JWS Protected Header is invalid");
|
|
857
859
|
}
|
|
@@ -877,10 +879,10 @@ async function Zt(e, t, r) {
|
|
|
877
879
|
throw new g("JWS Payload must be a string or an Uint8Array instance");
|
|
878
880
|
let h = !1;
|
|
879
881
|
typeof t == "function" && (t = await t(n, e), h = !0), Ft(i, t, "verify");
|
|
880
|
-
const l =
|
|
882
|
+
const l = kt(V.encode(e.protected ?? ""), V.encode("."), typeof e.payload == "string" ? V.encode(e.payload) : e.payload);
|
|
881
883
|
let f;
|
|
882
884
|
try {
|
|
883
|
-
f =
|
|
885
|
+
f = Z(e.signature);
|
|
884
886
|
} catch {
|
|
885
887
|
throw new g("Failed to base64url decode the signature");
|
|
886
888
|
}
|
|
@@ -889,7 +891,7 @@ async function Zt(e, t, r) {
|
|
|
889
891
|
let m;
|
|
890
892
|
if (s)
|
|
891
893
|
try {
|
|
892
|
-
m =
|
|
894
|
+
m = Z(e.payload);
|
|
893
895
|
} catch {
|
|
894
896
|
throw new g("Failed to base64url decode the payload");
|
|
895
897
|
}
|
|
@@ -906,7 +908,7 @@ async function er(e, t, r) {
|
|
|
906
908
|
const i = await Zt({ payload: a, protected: n, signature: o }, t, r), u = { payload: i.payload, protectedHeader: i.protectedHeader };
|
|
907
909
|
return typeof t == "function" ? { ...u, key: i.key } : u;
|
|
908
910
|
}
|
|
909
|
-
const tr = (e) => Math.floor(e.getTime() / 1e3), qe = 60, ze = qe * 60, we = ze * 24, rr = we * 7, nr = we * 365.25, ar = /^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i,
|
|
911
|
+
const tr = (e) => Math.floor(e.getTime() / 1e3), qe = 60, ze = qe * 60, we = ze * 24, rr = we * 7, nr = we * 365.25, ar = /^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i, be = (e) => {
|
|
910
912
|
const t = ar.exec(e);
|
|
911
913
|
if (!t || t[4] && t[1])
|
|
912
914
|
throw new TypeError("Invalid time period format");
|
|
@@ -949,22 +951,22 @@ const tr = (e) => Math.floor(e.getTime() / 1e3), qe = 60, ze = qe * 60, we = ze
|
|
|
949
951
|
break;
|
|
950
952
|
}
|
|
951
953
|
return t[1] === "-" || t[4] === "ago" ? -a : a;
|
|
952
|
-
},
|
|
954
|
+
}, ke = (e) => e.toLowerCase().replace(/^application\//, ""), sr = (e, t) => typeof e == "string" ? t.includes(e) : Array.isArray(e) ? t.some(Set.prototype.has.bind(new Set(e))) : !1, or = (e, t, r = {}) => {
|
|
953
955
|
let n;
|
|
954
956
|
try {
|
|
955
957
|
n = JSON.parse(oe.decode(t));
|
|
956
958
|
} catch {
|
|
957
959
|
}
|
|
958
960
|
if (!me(n))
|
|
959
|
-
throw new
|
|
961
|
+
throw new Ge("JWT Claims Set must be a top-level JSON object");
|
|
960
962
|
const { typ: a } = r;
|
|
961
|
-
if (a && (typeof e.typ != "string" ||
|
|
963
|
+
if (a && (typeof e.typ != "string" || ke(e.typ) !== ke(a)))
|
|
962
964
|
throw new I('unexpected "typ" JWT header value', n, "typ", "check_failed");
|
|
963
965
|
const { requiredClaims: o = [], issuer: s, subject: i, audience: u, maxTokenAge: h } = r, l = [...o];
|
|
964
966
|
h !== void 0 && l.push("iat"), u !== void 0 && l.push("aud"), i !== void 0 && l.push("sub"), s !== void 0 && l.push("iss");
|
|
965
|
-
for (const
|
|
966
|
-
if (!(
|
|
967
|
-
throw new I(`missing required "${
|
|
967
|
+
for (const T of new Set(l.reverse()))
|
|
968
|
+
if (!(T in n))
|
|
969
|
+
throw new I(`missing required "${T}" claim`, n, T, "missing");
|
|
968
970
|
if (s && !(Array.isArray(s) ? s : [s]).includes(n.iss))
|
|
969
971
|
throw new I('unexpected "iss" claim value', n, "iss", "check_failed");
|
|
970
972
|
if (i && n.sub !== i)
|
|
@@ -974,7 +976,7 @@ const tr = (e) => Math.floor(e.getTime() / 1e3), qe = 60, ze = qe * 60, we = ze
|
|
|
974
976
|
let f;
|
|
975
977
|
switch (typeof r.clockTolerance) {
|
|
976
978
|
case "string":
|
|
977
|
-
f =
|
|
979
|
+
f = be(r.clockTolerance);
|
|
978
980
|
break;
|
|
979
981
|
case "number":
|
|
980
982
|
f = r.clockTolerance;
|
|
@@ -1001,10 +1003,10 @@ const tr = (e) => Math.floor(e.getTime() / 1e3), qe = 60, ze = qe * 60, we = ze
|
|
|
1001
1003
|
throw new Re('"exp" claim timestamp check failed', n, "exp", "check_failed");
|
|
1002
1004
|
}
|
|
1003
1005
|
if (h) {
|
|
1004
|
-
const
|
|
1005
|
-
if (
|
|
1006
|
+
const T = d - n.iat, C = typeof h == "number" ? h : be(h);
|
|
1007
|
+
if (T - f > C)
|
|
1006
1008
|
throw new Re('"iat" claim timestamp check failed (too far in the past)', n, "iat", "check_failed");
|
|
1007
|
-
if (
|
|
1009
|
+
if (T < 0 - f)
|
|
1008
1010
|
throw new I('"iat" claim timestamp check failed (it should be in the past)', n, "iat", "check_failed");
|
|
1009
1011
|
}
|
|
1010
1012
|
return n;
|
|
@@ -1013,15 +1015,15 @@ async function ir(e, t, r) {
|
|
|
1013
1015
|
var n;
|
|
1014
1016
|
const a = await er(e, t, r);
|
|
1015
1017
|
if ((n = a.protectedHeader.crit) != null && n.includes("b64") && a.protectedHeader.b64 === !1)
|
|
1016
|
-
throw new
|
|
1018
|
+
throw new Ge("JWTs MUST NOT use unencoded payload");
|
|
1017
1019
|
const o = { payload: or(a.protectedHeader, a.payload, r), protectedHeader: a.protectedHeader };
|
|
1018
1020
|
return typeof t == "function" ? { ...o, key: a.key } : o;
|
|
1019
1021
|
}
|
|
1020
1022
|
const G = async (e) => {
|
|
1021
1023
|
try {
|
|
1022
|
-
const t =
|
|
1024
|
+
const t = S.ALG, r = await Vt(bt, t);
|
|
1023
1025
|
return await ir(e, r, {
|
|
1024
|
-
issuer:
|
|
1026
|
+
issuer: S.ISSUER
|
|
1025
1027
|
});
|
|
1026
1028
|
} catch {
|
|
1027
1029
|
return;
|
|
@@ -1033,19 +1035,19 @@ for (var he = 0; he < 256; ++he)
|
|
|
1033
1035
|
function cr(e, t = 0) {
|
|
1034
1036
|
return (E[e[t + 0]] + E[e[t + 1]] + E[e[t + 2]] + E[e[t + 3]] + "-" + E[e[t + 4]] + E[e[t + 5]] + "-" + E[e[t + 6]] + E[e[t + 7]] + "-" + E[e[t + 8]] + E[e[t + 9]] + "-" + E[e[t + 10]] + E[e[t + 11]] + E[e[t + 12]] + E[e[t + 13]] + E[e[t + 14]] + E[e[t + 15]]).toLowerCase();
|
|
1035
1037
|
}
|
|
1036
|
-
var
|
|
1038
|
+
var j, ur = new Uint8Array(16);
|
|
1037
1039
|
function lr() {
|
|
1038
|
-
if (!
|
|
1040
|
+
if (!j && (j = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !j))
|
|
1039
1041
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
1040
|
-
return
|
|
1042
|
+
return j(ur);
|
|
1041
1043
|
}
|
|
1042
1044
|
var dr = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
1043
|
-
const
|
|
1045
|
+
const Oe = {
|
|
1044
1046
|
randomUUID: dr
|
|
1045
1047
|
};
|
|
1046
1048
|
function Pe(e, t, r) {
|
|
1047
|
-
if (
|
|
1048
|
-
return
|
|
1049
|
+
if (Oe.randomUUID && !t && !e)
|
|
1050
|
+
return Oe.randomUUID();
|
|
1049
1051
|
e = e || {};
|
|
1050
1052
|
var n = e.random || (e.rng || lr)();
|
|
1051
1053
|
return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, cr(n);
|
|
@@ -1079,7 +1081,7 @@ const Ce = (e, t) => {
|
|
|
1079
1081
|
}, mr = (e) => {
|
|
1080
1082
|
window.localStorage.removeItem(e), Qe(e, null);
|
|
1081
1083
|
}, Ne = (e) => window.localStorage.getItem(e), Er = (e) => (window.addEventListener("storage", e), () => window.removeEventListener("storage", e));
|
|
1082
|
-
function
|
|
1084
|
+
function F({
|
|
1083
1085
|
key: e,
|
|
1084
1086
|
initialValue: t
|
|
1085
1087
|
}) {
|
|
@@ -1112,11 +1114,11 @@ for (var pe = 0; pe < 256; ++pe)
|
|
|
1112
1114
|
function wr(e, t = 0) {
|
|
1113
1115
|
return (w[e[t + 0]] + w[e[t + 1]] + w[e[t + 2]] + w[e[t + 3]] + "-" + w[e[t + 4]] + w[e[t + 5]] + "-" + w[e[t + 6]] + w[e[t + 7]] + "-" + w[e[t + 8]] + w[e[t + 9]] + "-" + w[e[t + 10]] + w[e[t + 11]] + w[e[t + 12]] + w[e[t + 13]] + w[e[t + 14]] + w[e[t + 15]]).toLowerCase();
|
|
1114
1116
|
}
|
|
1115
|
-
var
|
|
1117
|
+
var B, gr = new Uint8Array(16);
|
|
1116
1118
|
function Ar() {
|
|
1117
|
-
if (!
|
|
1119
|
+
if (!B && (B = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !B))
|
|
1118
1120
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
1119
|
-
return
|
|
1121
|
+
return B(gr);
|
|
1120
1122
|
}
|
|
1121
1123
|
var Sr = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
1122
1124
|
const De = {
|
|
@@ -1129,17 +1131,17 @@ function fe(e, t, r) {
|
|
|
1129
1131
|
var n = e.random || (e.rng || Ar)();
|
|
1130
1132
|
return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, wr(n);
|
|
1131
1133
|
}
|
|
1132
|
-
const
|
|
1134
|
+
const q = "Oops! It looks like your session has expired. For your security, please log in again to continue.", Tr = "Your session has been successfully terminated.", z = "Login failed. Please try again.", ye = "Error getting access token, please re-authenticate.", Rr = "You forgot to wrap your component in <AuthProvider>.", ne = {
|
|
1133
1135
|
dev: "https://auth.gizmette.local.com:3003",
|
|
1134
|
-
prod: "https://mylogin.gizmette.com"
|
|
1135
|
-
},
|
|
1136
|
+
prod: "https://mylogin.gizmette.com/auth"
|
|
1137
|
+
}, Q = "@@auth@@", L = "LOADING", W = "LOGIN", Xe = "LOGOUT", Ir = process.env.NODE_ENV === "production", Ze = !Ir, ie = async ({
|
|
1136
1138
|
type: e,
|
|
1137
1139
|
clientId: t,
|
|
1138
1140
|
params: r = {}
|
|
1139
1141
|
}) => {
|
|
1140
1142
|
try {
|
|
1141
1143
|
const n = await fetch(
|
|
1142
|
-
Ze ? `${
|
|
1144
|
+
Ze ? `${ne.dev}/${e}` : `${ne.prod}/${e}`,
|
|
1143
1145
|
{
|
|
1144
1146
|
credentials: "include",
|
|
1145
1147
|
method: "POST",
|
|
@@ -1161,7 +1163,7 @@ const B = "Oops! It looks like your session has expired. For your security, plea
|
|
|
1161
1163
|
} catch (n) {
|
|
1162
1164
|
return console.error(n), { status: 500, data: [] };
|
|
1163
1165
|
}
|
|
1164
|
-
},
|
|
1166
|
+
}, _r = async ({
|
|
1165
1167
|
userId: e,
|
|
1166
1168
|
idToken: t,
|
|
1167
1169
|
accessToken: r,
|
|
@@ -1204,7 +1206,7 @@ const B = "Oops! It looks like your session has expired. For your security, plea
|
|
|
1204
1206
|
type: ae.AUTHENTICATE,
|
|
1205
1207
|
clientId: r,
|
|
1206
1208
|
params: {
|
|
1207
|
-
type: a ||
|
|
1209
|
+
type: a || Y.ID_AND_ACCESS_TOKEN,
|
|
1208
1210
|
username: e,
|
|
1209
1211
|
password: t,
|
|
1210
1212
|
sessionExpiration: o,
|
|
@@ -1214,11 +1216,11 @@ const B = "Oops! It looks like your session has expired. For your security, plea
|
|
|
1214
1216
|
domain: u
|
|
1215
1217
|
}
|
|
1216
1218
|
}), l = await G(h.data.idToken);
|
|
1217
|
-
return l && l.payload[
|
|
1219
|
+
return l && l.payload[S.USER_ID_KEY] !== "" && l.payload[S.NONCE_KEY] === n ? {
|
|
1218
1220
|
idToken: h.data.idToken,
|
|
1219
1221
|
accessToken: h.data.accessToken,
|
|
1220
1222
|
refreshToken: h.data.refreshToken,
|
|
1221
|
-
userId: l.payload[
|
|
1223
|
+
userId: l.payload[S.USER_ID_KEY],
|
|
1222
1224
|
status: !0
|
|
1223
1225
|
} : {
|
|
1224
1226
|
status: !1
|
|
@@ -1228,7 +1230,7 @@ const B = "Oops! It looks like your session has expired. For your security, plea
|
|
|
1228
1230
|
status: !1
|
|
1229
1231
|
};
|
|
1230
1232
|
}
|
|
1231
|
-
},
|
|
1233
|
+
}, br = async ({
|
|
1232
1234
|
nonce: e,
|
|
1233
1235
|
clientId: t,
|
|
1234
1236
|
code_challenge: r
|
|
@@ -1238,7 +1240,7 @@ const B = "Oops! It looks like your session has expired. For your security, plea
|
|
|
1238
1240
|
type: ae.CODE,
|
|
1239
1241
|
clientId: t,
|
|
1240
1242
|
params: {
|
|
1241
|
-
type:
|
|
1243
|
+
type: Y.CODE,
|
|
1242
1244
|
nonce: e,
|
|
1243
1245
|
code_challenge: r
|
|
1244
1246
|
}
|
|
@@ -1254,7 +1256,7 @@ const B = "Oops! It looks like your session has expired. For your security, plea
|
|
|
1254
1256
|
status: !1
|
|
1255
1257
|
};
|
|
1256
1258
|
}
|
|
1257
|
-
},
|
|
1259
|
+
}, kr = async ({
|
|
1258
1260
|
clientId: e,
|
|
1259
1261
|
userId: t,
|
|
1260
1262
|
nonce: r,
|
|
@@ -1267,7 +1269,7 @@ const B = "Oops! It looks like your session has expired. For your security, plea
|
|
|
1267
1269
|
type: ae.AUTHENTICATE,
|
|
1268
1270
|
clientId: e,
|
|
1269
1271
|
params: {
|
|
1270
|
-
type:
|
|
1272
|
+
type: Y.REFRESH_TOKEN,
|
|
1271
1273
|
userId: t,
|
|
1272
1274
|
nonce: r,
|
|
1273
1275
|
refreshToken: n,
|
|
@@ -1275,10 +1277,10 @@ const B = "Oops! It looks like your session has expired. For your security, plea
|
|
|
1275
1277
|
domain: o
|
|
1276
1278
|
}
|
|
1277
1279
|
}), i = await G(s.data.accessToken);
|
|
1278
|
-
return i && i.payload[
|
|
1280
|
+
return i && i.payload[S.USER_ID_KEY] !== "" && i.payload[S.NONCE_KEY] === r ? {
|
|
1279
1281
|
accessToken: s.data.accessToken,
|
|
1280
1282
|
refreshToken: s.data.refreshToken,
|
|
1281
|
-
userId: i.payload[
|
|
1283
|
+
userId: i.payload[S.USER_ID_KEY],
|
|
1282
1284
|
status: !0
|
|
1283
1285
|
} : {
|
|
1284
1286
|
status: !1
|
|
@@ -1288,7 +1290,7 @@ const B = "Oops! It looks like your session has expired. For your security, plea
|
|
|
1288
1290
|
status: !1
|
|
1289
1291
|
};
|
|
1290
1292
|
}
|
|
1291
|
-
},
|
|
1293
|
+
}, X = {
|
|
1292
1294
|
GET_REGISTRATION_OPTIONS: `mutation GetPasskeyRegistrationOptions(
|
|
1293
1295
|
$clientId: String!,
|
|
1294
1296
|
$username: String!,
|
|
@@ -1363,19 +1365,19 @@ const B = "Oops! It looks like your session has expired. For your security, plea
|
|
|
1363
1365
|
}`
|
|
1364
1366
|
}, D = {
|
|
1365
1367
|
GET_REGISTRATION_OPTIONS: {
|
|
1366
|
-
schema:
|
|
1368
|
+
schema: X.GET_REGISTRATION_OPTIONS,
|
|
1367
1369
|
method: "getPasskeyRegistrationOptions"
|
|
1368
1370
|
},
|
|
1369
1371
|
VERIFY_REGISTRATION: {
|
|
1370
|
-
schema:
|
|
1372
|
+
schema: X.VERIFY_REGISTRATION,
|
|
1371
1373
|
method: "verifyPasskeyRegistration"
|
|
1372
1374
|
},
|
|
1373
1375
|
GET_AUTHENTICATION_OPTIONS: {
|
|
1374
|
-
schema:
|
|
1376
|
+
schema: X.GET_AUTHENTICATION_OPTIONS,
|
|
1375
1377
|
method: "getPasskeyAuthenticationOptions"
|
|
1376
1378
|
},
|
|
1377
1379
|
VERIFY_AUTHENTICATION: {
|
|
1378
|
-
schema:
|
|
1380
|
+
schema: X.VERIFY_AUTHENTICATION,
|
|
1379
1381
|
method: "verifyPasskeyAuthentication"
|
|
1380
1382
|
}
|
|
1381
1383
|
}, U = async ({
|
|
@@ -1386,7 +1388,7 @@ const B = "Oops! It looks like your session has expired. For your security, plea
|
|
|
1386
1388
|
}) => {
|
|
1387
1389
|
try {
|
|
1388
1390
|
const a = t != null && t.data ? t.data(n) : n, o = `Bearer ${e}`, s = await fetch(
|
|
1389
|
-
Ze ? `${
|
|
1391
|
+
Ze ? `${ne.dev}/graphql` : `${ne.prod}/graphql`,
|
|
1390
1392
|
{
|
|
1391
1393
|
method: "POST",
|
|
1392
1394
|
credentials: "include",
|
|
@@ -1414,7 +1416,7 @@ const B = "Oops! It looks like your session has expired. For your security, plea
|
|
|
1414
1416
|
return console.error(a), { status: 500, data: [] };
|
|
1415
1417
|
}
|
|
1416
1418
|
};
|
|
1417
|
-
class
|
|
1419
|
+
class Or {
|
|
1418
1420
|
constructor(t = null, r = null) {
|
|
1419
1421
|
M(this, "refreshTokenPromise", null);
|
|
1420
1422
|
M(this, "accessToken");
|
|
@@ -1446,8 +1448,8 @@ class kr {
|
|
|
1446
1448
|
domain: a
|
|
1447
1449
|
}) {
|
|
1448
1450
|
const o = await G(this.refreshToken);
|
|
1449
|
-
if (o && o.payload[
|
|
1450
|
-
const s = await
|
|
1451
|
+
if (o && o.payload[S.USER_ID_KEY] !== "") {
|
|
1452
|
+
const s = await kr({
|
|
1451
1453
|
clientId: t,
|
|
1452
1454
|
userId: r,
|
|
1453
1455
|
nonce: n,
|
|
@@ -1473,6 +1475,7 @@ const K = () => {
|
|
|
1473
1475
|
}, et = yt({
|
|
1474
1476
|
isAuthenticated: !1,
|
|
1475
1477
|
isLoading: !1,
|
|
1478
|
+
authenticationType: null,
|
|
1476
1479
|
login: K,
|
|
1477
1480
|
logout: K,
|
|
1478
1481
|
getAccessToken: K,
|
|
@@ -1484,6 +1487,7 @@ const K = () => {
|
|
|
1484
1487
|
state: {
|
|
1485
1488
|
isLoading: !0,
|
|
1486
1489
|
isAuthenticated: !1,
|
|
1490
|
+
authenticationType: null,
|
|
1487
1491
|
user: void 0,
|
|
1488
1492
|
logoutReason: ""
|
|
1489
1493
|
},
|
|
@@ -1497,12 +1501,14 @@ const K = () => {
|
|
|
1497
1501
|
isLoading: !1,
|
|
1498
1502
|
isAuthenticated: !0,
|
|
1499
1503
|
user: t.payload.user,
|
|
1504
|
+
authenticationType: t.payload.authenticationType,
|
|
1500
1505
|
logoutReason: ""
|
|
1501
1506
|
} : (t == null ? void 0 : t.type) === Xe ? {
|
|
1502
1507
|
...e,
|
|
1503
1508
|
isLoading: !1,
|
|
1504
1509
|
isAuthenticated: !1,
|
|
1505
1510
|
user: void 0,
|
|
1511
|
+
authenticationType: null,
|
|
1506
1512
|
logoutReason: t.payload.logoutReason
|
|
1507
1513
|
} : e, Kr = ({
|
|
1508
1514
|
children: e,
|
|
@@ -1513,24 +1519,25 @@ const K = () => {
|
|
|
1513
1519
|
const [a, o] = mt(vr, {
|
|
1514
1520
|
isLoading: !0,
|
|
1515
1521
|
isAuthenticated: !1,
|
|
1522
|
+
authenticationType: null,
|
|
1516
1523
|
user: void 0,
|
|
1517
1524
|
logoutReason: ""
|
|
1518
|
-
}), s = Et(!1), [i, u, , h] =
|
|
1519
|
-
key: `${
|
|
1520
|
-
}), [l, f, , m] =
|
|
1521
|
-
key: `${
|
|
1522
|
-
}), [d,
|
|
1525
|
+
}), s = Et(!1), [i, u, , h] = F({
|
|
1526
|
+
key: `${Q}::${r}::@@user@@`
|
|
1527
|
+
}), [l, f, , m] = F({
|
|
1528
|
+
key: `${Q}::${r}::@@access@@`
|
|
1529
|
+
}), [d, T, , C] = F(
|
|
1523
1530
|
{
|
|
1524
|
-
key: `${
|
|
1531
|
+
key: `${Q}::${r}::@@refresh@@`
|
|
1525
1532
|
}
|
|
1526
|
-
), [tt, ge, , Ae] =
|
|
1527
|
-
key: `${
|
|
1528
|
-
}), rt = new
|
|
1533
|
+
), [tt, ge, , Ae] = F({
|
|
1534
|
+
key: `${Q}::${r}::@@nonce@@`
|
|
1535
|
+
}), rt = new Or(l, d), N = x(
|
|
1529
1536
|
(c) => {
|
|
1530
1537
|
console.warn(c), o({
|
|
1531
1538
|
type: Xe,
|
|
1532
1539
|
payload: {
|
|
1533
|
-
logoutReason: c ||
|
|
1540
|
+
logoutReason: c || q
|
|
1534
1541
|
}
|
|
1535
1542
|
}), h(), m(), C(), Ae(), o({ type: L, payload: { isLoading: !1 } });
|
|
1536
1543
|
},
|
|
@@ -1538,14 +1545,14 @@ const K = () => {
|
|
|
1538
1545
|
), P = x(
|
|
1539
1546
|
async (c) => {
|
|
1540
1547
|
const { user: y } = a;
|
|
1541
|
-
await
|
|
1548
|
+
await _r({
|
|
1542
1549
|
userId: (y == null ? void 0 : y.userId) || "",
|
|
1543
1550
|
idToken: i,
|
|
1544
1551
|
accessToken: l,
|
|
1545
1552
|
refreshToken: d,
|
|
1546
1553
|
clientId: r,
|
|
1547
1554
|
domain: n
|
|
1548
|
-
}), N(c ||
|
|
1555
|
+
}), N(c || q);
|
|
1549
1556
|
},
|
|
1550
1557
|
[
|
|
1551
1558
|
l,
|
|
@@ -1562,17 +1569,18 @@ const K = () => {
|
|
|
1562
1569
|
return a.isLoading && i !== null ? (async () => {
|
|
1563
1570
|
try {
|
|
1564
1571
|
const c = await G(i);
|
|
1565
|
-
c && c.payload[
|
|
1572
|
+
c && c.payload[S.USER_ID_KEY] !== "" ? o({
|
|
1566
1573
|
type: W,
|
|
1567
1574
|
payload: {
|
|
1575
|
+
authenticationType: c.payload[S.AUTH_TYPE_KEY],
|
|
1568
1576
|
user: {
|
|
1569
|
-
userId: c.payload[
|
|
1570
|
-
username: c.payload[
|
|
1577
|
+
userId: c.payload[S.USER_ID_KEY],
|
|
1578
|
+
username: c.payload[S.USERNAME_KEY]
|
|
1571
1579
|
}
|
|
1572
1580
|
}
|
|
1573
|
-
}) : await P(
|
|
1581
|
+
}) : await P(q);
|
|
1574
1582
|
} catch {
|
|
1575
|
-
await P(
|
|
1583
|
+
await P(q);
|
|
1576
1584
|
}
|
|
1577
1585
|
})() : o({ type: L, payload: { isLoading: !1 } }), () => {
|
|
1578
1586
|
s.current = !0;
|
|
@@ -1580,8 +1588,8 @@ const K = () => {
|
|
|
1580
1588
|
}, [a.isLoading, i, P]);
|
|
1581
1589
|
const nt = async (c, y, p) => {
|
|
1582
1590
|
const R = fe();
|
|
1583
|
-
if (ge(R), o({ type: L, payload: { isLoading: !0 } }), h(), m(), C(), p ===
|
|
1584
|
-
const { code_verifier: ut, code_challenge: lt } = await yr(), Se = await
|
|
1591
|
+
if (ge(R), o({ type: L, payload: { isLoading: !0 } }), h(), m(), C(), p === Y.CODE) {
|
|
1592
|
+
const { code_verifier: ut, code_challenge: lt } = await yr(), Se = await br({
|
|
1585
1593
|
nonce: R,
|
|
1586
1594
|
clientId: r,
|
|
1587
1595
|
code_challenge: lt
|
|
@@ -1598,15 +1606,16 @@ const K = () => {
|
|
|
1598
1606
|
code_verifier: ut,
|
|
1599
1607
|
domain: n
|
|
1600
1608
|
});
|
|
1601
|
-
return $.status ? (u($.idToken), f($.accessToken),
|
|
1609
|
+
return $.status ? (u($.idToken), f($.accessToken), T($.refreshToken), o({
|
|
1602
1610
|
type: W,
|
|
1603
1611
|
payload: {
|
|
1612
|
+
authenticationType: p,
|
|
1604
1613
|
user: {
|
|
1605
1614
|
userId: $.userId,
|
|
1606
1615
|
username: c
|
|
1607
1616
|
}
|
|
1608
1617
|
}
|
|
1609
|
-
}), !0) : (N(
|
|
1618
|
+
}), !0) : (N(z), !1);
|
|
1610
1619
|
}
|
|
1611
1620
|
return !1;
|
|
1612
1621
|
}
|
|
@@ -1619,15 +1628,16 @@ const K = () => {
|
|
|
1619
1628
|
type: p,
|
|
1620
1629
|
domain: n
|
|
1621
1630
|
});
|
|
1622
|
-
return H.status ? (u(H.idToken), f(H.accessToken),
|
|
1631
|
+
return H.status ? (u(H.idToken), f(H.accessToken), T(H.refreshToken), o({
|
|
1623
1632
|
type: W,
|
|
1624
1633
|
payload: {
|
|
1634
|
+
authenticationType: p,
|
|
1625
1635
|
user: {
|
|
1626
1636
|
userId: H.userId,
|
|
1627
1637
|
username: c
|
|
1628
1638
|
}
|
|
1629
1639
|
}
|
|
1630
|
-
}), !0) : (N(
|
|
1640
|
+
}), !0) : (N(z), !1);
|
|
1631
1641
|
}, at = async (c) => {
|
|
1632
1642
|
c == null || c.preventDefault(), await P(Tr);
|
|
1633
1643
|
}, st = async () => {
|
|
@@ -1636,7 +1646,7 @@ const K = () => {
|
|
|
1636
1646
|
if (c && y && y.userId) {
|
|
1637
1647
|
if (l) {
|
|
1638
1648
|
const R = await G(l);
|
|
1639
|
-
if (R && R.payload[
|
|
1649
|
+
if (R && R.payload[S.USER_ID_KEY] !== "")
|
|
1640
1650
|
return l;
|
|
1641
1651
|
}
|
|
1642
1652
|
const p = await rt.refreshtoken({
|
|
@@ -1645,7 +1655,7 @@ const K = () => {
|
|
|
1645
1655
|
nonce: tt,
|
|
1646
1656
|
domain: n
|
|
1647
1657
|
});
|
|
1648
|
-
return p.status && p.status === "success" ? (f(p.newAccessToken),
|
|
1658
|
+
return p.status && p.status === "success" ? (f(p.newAccessToken), T(p.newRefreshToken), p.newAccessToken) : (await P(ye), "");
|
|
1649
1659
|
}
|
|
1650
1660
|
return await P(ye), "";
|
|
1651
1661
|
} catch {
|
|
@@ -1708,7 +1718,7 @@ const K = () => {
|
|
|
1708
1718
|
});
|
|
1709
1719
|
if (p.status)
|
|
1710
1720
|
try {
|
|
1711
|
-
const R = await
|
|
1721
|
+
const R = await _t(p.data);
|
|
1712
1722
|
return p = await U({
|
|
1713
1723
|
accessToken: l,
|
|
1714
1724
|
clientId: r,
|
|
@@ -1720,15 +1730,16 @@ const K = () => {
|
|
|
1720
1730
|
nonce: c,
|
|
1721
1731
|
domain: n
|
|
1722
1732
|
}
|
|
1723
|
-
}), p.data.status === "success" ? (u(p.data.idToken), f(p.data.accessToken),
|
|
1733
|
+
}), p.data.status === "success" ? (u(p.data.idToken), f(p.data.accessToken), T(p.data.refreshToken), o({
|
|
1724
1734
|
type: W,
|
|
1725
1735
|
payload: {
|
|
1736
|
+
authenticationType: Y.PASSKEY,
|
|
1726
1737
|
user: {
|
|
1727
1738
|
userId: p.data.userId,
|
|
1728
1739
|
username: p.data.username
|
|
1729
1740
|
}
|
|
1730
1741
|
}
|
|
1731
|
-
}), !0) : (N(
|
|
1742
|
+
}), !0) : (N(z), !1);
|
|
1732
1743
|
} catch {
|
|
1733
1744
|
return await U({
|
|
1734
1745
|
accessToken: l,
|
|
@@ -1741,7 +1752,7 @@ const K = () => {
|
|
|
1741
1752
|
nonce: c,
|
|
1742
1753
|
domain: n
|
|
1743
1754
|
}
|
|
1744
|
-
}), N(
|
|
1755
|
+
}), N(z), !1;
|
|
1745
1756
|
}
|
|
1746
1757
|
};
|
|
1747
1758
|
return /* @__PURE__ */ Te(Pr.Provider, { value: { state: a, dispatch: o }, children: /* @__PURE__ */ Te(
|
|
@@ -1761,7 +1772,7 @@ const K = () => {
|
|
|
1761
1772
|
) });
|
|
1762
1773
|
}, Hr = (e = et) => wt(e);
|
|
1763
1774
|
export {
|
|
1764
|
-
|
|
1775
|
+
Y as AUTH_TYPES,
|
|
1765
1776
|
Kr as AuthProvider,
|
|
1766
1777
|
Hr as useAuth
|
|
1767
1778
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versini/auth-provider",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"publishConfig": {
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@simplewebauthn/browser": "10.0.0",
|
|
48
|
-
"@versini/auth-common": "2.
|
|
48
|
+
"@versini/auth-common": "2.12.1",
|
|
49
49
|
"@versini/ui-hooks": "4.0.1",
|
|
50
50
|
"jose": "5.6.3",
|
|
51
51
|
"uuid": "10.0.0"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "0c1ec6aec9a55466a3ade7f55ab6b6c386f3305b"
|
|
54
54
|
}
|