@versini/auth-provider 6.2.1 → 6.3.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 -1
- package/dist/index.js +377 -363
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -2,21 +2,21 @@ var _t = Object.defineProperty;
|
|
|
2
2
|
var vt = (e, t, n) => t in e ? _t(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
3
|
var z = (e, t, n) => vt(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
4
|
import { jsx as ke } from "react/jsx-runtime";
|
|
5
|
-
import kt, { useSyncExternalStore as
|
|
5
|
+
import kt, { useSyncExternalStore as Ct, useCallback as W, useEffect as Te, createContext as Pt, useReducer as Ot, useRef as Ce, useContext as Nt } from "react";
|
|
6
6
|
/*!
|
|
7
|
-
@versini/auth-provider v6.
|
|
7
|
+
@versini/auth-provider v6.3.1
|
|
8
8
|
© 2024 gizmette.com
|
|
9
9
|
*/
|
|
10
10
|
try {
|
|
11
11
|
window.__VERSINI_AUTH_CLIENT__ || (window.__VERSINI_AUTH_CLIENT__ = {
|
|
12
|
-
version: "6.
|
|
13
|
-
buildTime: "07/
|
|
12
|
+
version: "6.3.1",
|
|
13
|
+
buildTime: "07/22/2024 07:45 AM 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 v(e) {
|
|
20
20
|
const t = new Uint8Array(e);
|
|
21
21
|
let n = "";
|
|
22
22
|
for (const a of t)
|
|
@@ -32,7 +32,7 @@ function ie(e) {
|
|
|
32
32
|
function Re() {
|
|
33
33
|
return (window == null ? void 0 : window.PublicKeyCredential) !== void 0 && typeof window.PublicKeyCredential == "function";
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function Ye(e) {
|
|
36
36
|
const { id: t } = e;
|
|
37
37
|
return {
|
|
38
38
|
...e,
|
|
@@ -40,7 +40,7 @@ function Ve(e) {
|
|
|
40
40
|
transports: e.transports
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function Ve(e) {
|
|
44
44
|
return e === "localhost" || /^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e);
|
|
45
45
|
}
|
|
46
46
|
class b extends Error {
|
|
@@ -98,7 +98,7 @@ function Dt({ error: e, options: t }) {
|
|
|
98
98
|
});
|
|
99
99
|
if (e.name === "SecurityError") {
|
|
100
100
|
const s = window.location.hostname;
|
|
101
|
-
if (
|
|
101
|
+
if (Ve(s)) {
|
|
102
102
|
if (n.rp.id !== s)
|
|
103
103
|
return new b({
|
|
104
104
|
message: `The RP ID "${n.rp.id}" is invalid for this domain`,
|
|
@@ -148,7 +148,7 @@ function Fe(e) {
|
|
|
148
148
|
return e;
|
|
149
149
|
}
|
|
150
150
|
async function Kt(e) {
|
|
151
|
-
var
|
|
151
|
+
var m;
|
|
152
152
|
if (!Re())
|
|
153
153
|
throw new Error("WebAuthn is not supported in this browser");
|
|
154
154
|
const n = { publicKey: {
|
|
@@ -158,52 +158,52 @@ async function Kt(e) {
|
|
|
158
158
|
...e.user,
|
|
159
159
|
id: ie(e.user.id)
|
|
160
160
|
},
|
|
161
|
-
excludeCredentials: (
|
|
161
|
+
excludeCredentials: (m = e.excludeCredentials) == null ? void 0 : m.map(Ye)
|
|
162
162
|
} };
|
|
163
163
|
n.signal = je.createNewAbortSignal();
|
|
164
164
|
let r;
|
|
165
165
|
try {
|
|
166
166
|
r = await navigator.credentials.create(n);
|
|
167
|
-
} catch (
|
|
168
|
-
throw Dt({ error:
|
|
167
|
+
} catch (u) {
|
|
168
|
+
throw Dt({ error: u, options: n });
|
|
169
169
|
}
|
|
170
170
|
if (!r)
|
|
171
171
|
throw new Error("Registration was not completed");
|
|
172
172
|
const { id: a, rawId: s, response: o, type: i } = r;
|
|
173
|
-
let
|
|
174
|
-
typeof o.getTransports == "function" && (
|
|
175
|
-
let
|
|
173
|
+
let l;
|
|
174
|
+
typeof o.getTransports == "function" && (l = o.getTransports());
|
|
175
|
+
let y;
|
|
176
176
|
if (typeof o.getPublicKeyAlgorithm == "function")
|
|
177
177
|
try {
|
|
178
|
-
|
|
179
|
-
} catch (
|
|
180
|
-
fe("getPublicKeyAlgorithm()",
|
|
178
|
+
y = o.getPublicKeyAlgorithm();
|
|
179
|
+
} catch (u) {
|
|
180
|
+
fe("getPublicKeyAlgorithm()", u);
|
|
181
181
|
}
|
|
182
|
-
let
|
|
182
|
+
let h;
|
|
183
183
|
if (typeof o.getPublicKey == "function")
|
|
184
184
|
try {
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
} catch (
|
|
188
|
-
fe("getPublicKey()",
|
|
185
|
+
const u = o.getPublicKey();
|
|
186
|
+
u !== null && (h = v(u));
|
|
187
|
+
} catch (u) {
|
|
188
|
+
fe("getPublicKey()", u);
|
|
189
189
|
}
|
|
190
|
-
let
|
|
190
|
+
let p;
|
|
191
191
|
if (typeof o.getAuthenticatorData == "function")
|
|
192
192
|
try {
|
|
193
|
-
|
|
194
|
-
} catch (
|
|
195
|
-
fe("getAuthenticatorData()",
|
|
193
|
+
p = v(o.getAuthenticatorData());
|
|
194
|
+
} catch (u) {
|
|
195
|
+
fe("getAuthenticatorData()", u);
|
|
196
196
|
}
|
|
197
197
|
return {
|
|
198
198
|
id: a,
|
|
199
|
-
rawId:
|
|
199
|
+
rawId: v(s),
|
|
200
200
|
response: {
|
|
201
|
-
attestationObject:
|
|
202
|
-
clientDataJSON:
|
|
203
|
-
transports:
|
|
204
|
-
publicKeyAlgorithm:
|
|
205
|
-
publicKey:
|
|
206
|
-
authenticatorData:
|
|
201
|
+
attestationObject: v(o.attestationObject),
|
|
202
|
+
clientDataJSON: v(o.clientDataJSON),
|
|
203
|
+
transports: l,
|
|
204
|
+
publicKeyAlgorithm: y,
|
|
205
|
+
publicKey: h,
|
|
206
|
+
authenticatorData: p
|
|
207
207
|
},
|
|
208
208
|
type: i,
|
|
209
209
|
clientExtensionResults: r.getClientExtensionResults(),
|
|
@@ -240,7 +240,7 @@ function Lt({ error: e, options: t }) {
|
|
|
240
240
|
});
|
|
241
241
|
if (e.name === "SecurityError") {
|
|
242
242
|
const r = window.location.hostname;
|
|
243
|
-
if (
|
|
243
|
+
if (Ve(r)) {
|
|
244
244
|
if (n.rpId !== r)
|
|
245
245
|
return new b({
|
|
246
246
|
message: `The RP ID "${n.rpId}" is invalid for this domain`,
|
|
@@ -262,11 +262,11 @@ function Lt({ error: e, options: t }) {
|
|
|
262
262
|
return e;
|
|
263
263
|
}
|
|
264
264
|
async function Wt(e, t = !1) {
|
|
265
|
-
var
|
|
265
|
+
var p, m;
|
|
266
266
|
if (!Re())
|
|
267
267
|
throw new Error("WebAuthn is not supported in this browser");
|
|
268
268
|
let n;
|
|
269
|
-
((
|
|
269
|
+
((p = e.allowCredentials) == null ? void 0 : p.length) !== 0 && (n = (m = e.allowCredentials) == null ? void 0 : m.map(Ye));
|
|
270
270
|
const r = {
|
|
271
271
|
...e,
|
|
272
272
|
challenge: ie(e.challenge),
|
|
@@ -283,35 +283,35 @@ async function Wt(e, t = !1) {
|
|
|
283
283
|
let s;
|
|
284
284
|
try {
|
|
285
285
|
s = await navigator.credentials.get(a);
|
|
286
|
-
} catch (
|
|
287
|
-
throw Lt({ error:
|
|
286
|
+
} catch (u) {
|
|
287
|
+
throw Lt({ error: u, options: a });
|
|
288
288
|
}
|
|
289
289
|
if (!s)
|
|
290
290
|
throw new Error("Authentication was not completed");
|
|
291
|
-
const { id: o, rawId: i, response:
|
|
292
|
-
let
|
|
293
|
-
return
|
|
291
|
+
const { id: o, rawId: i, response: l, type: y } = s;
|
|
292
|
+
let h;
|
|
293
|
+
return l.userHandle && (h = v(l.userHandle)), {
|
|
294
294
|
id: o,
|
|
295
|
-
rawId:
|
|
295
|
+
rawId: v(i),
|
|
296
296
|
response: {
|
|
297
|
-
authenticatorData:
|
|
298
|
-
clientDataJSON:
|
|
299
|
-
signature:
|
|
300
|
-
userHandle:
|
|
297
|
+
authenticatorData: v(l.authenticatorData),
|
|
298
|
+
clientDataJSON: v(l.clientDataJSON),
|
|
299
|
+
signature: v(l.signature),
|
|
300
|
+
userHandle: h
|
|
301
301
|
},
|
|
302
|
-
type:
|
|
302
|
+
type: y,
|
|
303
303
|
clientExtensionResults: s.getClientExtensionResults(),
|
|
304
304
|
authenticatorAttachment: Fe(s.authenticatorAttachment)
|
|
305
305
|
};
|
|
306
306
|
}
|
|
307
307
|
/*!
|
|
308
|
-
@versini/auth-common
|
|
308
|
+
@versini/auth-common v3.3.0
|
|
309
309
|
© 2024 gizmette.com
|
|
310
310
|
*/
|
|
311
311
|
try {
|
|
312
312
|
window.__VERSINI_AUTH_COMMON__ || (window.__VERSINI_AUTH_COMMON__ = {
|
|
313
|
-
version: "
|
|
314
|
-
buildTime: "07/
|
|
313
|
+
version: "3.3.0",
|
|
314
|
+
buildTime: "07/22/2024 07:45 AM EDT",
|
|
315
315
|
homepage: "https://github.com/aversini/auth-client",
|
|
316
316
|
license: "MIT"
|
|
317
317
|
});
|
|
@@ -326,13 +326,16 @@ const j = {
|
|
|
326
326
|
PASSKEY: "passkey"
|
|
327
327
|
}, Be = {
|
|
328
328
|
CLIENT_ID: "X-Auth-ClientId"
|
|
329
|
-
},
|
|
329
|
+
}, T = {
|
|
330
330
|
ALG: "RS256",
|
|
331
331
|
USER_ID_KEY: "sub",
|
|
332
332
|
TOKEN_ID_KEY: "__raw",
|
|
333
333
|
NONCE_KEY: "_nonce",
|
|
334
334
|
USERNAME_KEY: "username",
|
|
335
335
|
AUTH_TYPE_KEY: "auth_type",
|
|
336
|
+
EXPIRES_AT_KEY: "exp",
|
|
337
|
+
CREATED_AT_KEY: "iat",
|
|
338
|
+
SCOPES_KEY: "scopes",
|
|
336
339
|
ISSUER: "gizmette.com"
|
|
337
340
|
}, xt = `-----BEGIN PUBLIC KEY-----
|
|
338
341
|
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsF6i3Jd9fY/3COqCw/m7
|
|
@@ -346,7 +349,7 @@ awIDAQAB
|
|
|
346
349
|
AUTHENTICATE: "authenticate",
|
|
347
350
|
CODE: "code",
|
|
348
351
|
LOGOUT: "logout"
|
|
349
|
-
}, he = crypto, qe = (e) => e instanceof CryptoKey, Q = new TextEncoder(),
|
|
352
|
+
}, he = crypto, qe = (e) => e instanceof CryptoKey, Q = new TextEncoder(), F = new TextDecoder();
|
|
350
353
|
function Mt(...e) {
|
|
351
354
|
const t = e.reduce((a, { length: s }) => a + s, 0), n = new Uint8Array(t);
|
|
352
355
|
let r = 0;
|
|
@@ -359,16 +362,16 @@ const Gt = (e) => {
|
|
|
359
362
|
for (let r = 0; r < t.length; r++)
|
|
360
363
|
n[r] = t.charCodeAt(r);
|
|
361
364
|
return n;
|
|
362
|
-
},
|
|
365
|
+
}, V = (e) => {
|
|
363
366
|
let t = e;
|
|
364
|
-
t instanceof Uint8Array && (t =
|
|
367
|
+
t instanceof Uint8Array && (t = F.decode(t)), t = t.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "");
|
|
365
368
|
try {
|
|
366
369
|
return Gt(t);
|
|
367
370
|
} catch {
|
|
368
371
|
throw new TypeError("The input to be decoded is not correctly encoded.");
|
|
369
372
|
}
|
|
370
373
|
};
|
|
371
|
-
let
|
|
374
|
+
let D = class extends Error {
|
|
372
375
|
static get code() {
|
|
373
376
|
return "ERR_JOSE_GENERIC";
|
|
374
377
|
}
|
|
@@ -376,14 +379,14 @@ let U = class extends Error {
|
|
|
376
379
|
var n;
|
|
377
380
|
super(t), this.code = "ERR_JOSE_GENERIC", this.name = this.constructor.name, (n = Error.captureStackTrace) == null || n.call(Error, this, this.constructor);
|
|
378
381
|
}
|
|
379
|
-
},
|
|
382
|
+
}, _ = class extends D {
|
|
380
383
|
static get code() {
|
|
381
384
|
return "ERR_JWT_CLAIM_VALIDATION_FAILED";
|
|
382
385
|
}
|
|
383
386
|
constructor(t, n, r = "unspecified", a = "unspecified") {
|
|
384
387
|
super(t), this.code = "ERR_JWT_CLAIM_VALIDATION_FAILED", this.claim = r, this.reason = a, this.payload = n;
|
|
385
388
|
}
|
|
386
|
-
},
|
|
389
|
+
}, Pe = class extends D {
|
|
387
390
|
static get code() {
|
|
388
391
|
return "ERR_JWT_EXPIRED";
|
|
389
392
|
}
|
|
@@ -391,7 +394,7 @@ let U = class extends Error {
|
|
|
391
394
|
super(t), this.code = "ERR_JWT_EXPIRED", this.claim = r, this.reason = a, this.payload = n;
|
|
392
395
|
}
|
|
393
396
|
};
|
|
394
|
-
class Jt extends
|
|
397
|
+
class Jt extends D {
|
|
395
398
|
constructor() {
|
|
396
399
|
super(...arguments), this.code = "ERR_JOSE_ALG_NOT_ALLOWED";
|
|
397
400
|
}
|
|
@@ -399,7 +402,7 @@ class Jt extends U {
|
|
|
399
402
|
return "ERR_JOSE_ALG_NOT_ALLOWED";
|
|
400
403
|
}
|
|
401
404
|
}
|
|
402
|
-
let
|
|
405
|
+
let O = class extends D {
|
|
403
406
|
constructor() {
|
|
404
407
|
super(...arguments), this.code = "ERR_JOSE_NOT_SUPPORTED";
|
|
405
408
|
}
|
|
@@ -407,7 +410,7 @@ let N = class extends U {
|
|
|
407
410
|
return "ERR_JOSE_NOT_SUPPORTED";
|
|
408
411
|
}
|
|
409
412
|
};
|
|
410
|
-
class
|
|
413
|
+
class A extends D {
|
|
411
414
|
constructor() {
|
|
412
415
|
super(...arguments), this.code = "ERR_JWS_INVALID";
|
|
413
416
|
}
|
|
@@ -415,7 +418,7 @@ class R extends U {
|
|
|
415
418
|
return "ERR_JWS_INVALID";
|
|
416
419
|
}
|
|
417
420
|
}
|
|
418
|
-
let C = class extends
|
|
421
|
+
let C = class extends D {
|
|
419
422
|
constructor() {
|
|
420
423
|
super(...arguments), this.code = "ERR_JWT_INVALID";
|
|
421
424
|
}
|
|
@@ -423,7 +426,7 @@ let C = class extends U {
|
|
|
423
426
|
return "ERR_JWT_INVALID";
|
|
424
427
|
}
|
|
425
428
|
};
|
|
426
|
-
class
|
|
429
|
+
class Yt extends D {
|
|
427
430
|
constructor() {
|
|
428
431
|
super(...arguments), this.code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED", this.message = "signature verification failed";
|
|
429
432
|
}
|
|
@@ -431,7 +434,7 @@ class Vt extends U {
|
|
|
431
434
|
return "ERR_JWS_SIGNATURE_VERIFICATION_FAILED";
|
|
432
435
|
}
|
|
433
436
|
}
|
|
434
|
-
function
|
|
437
|
+
function k(e, t = "algorithm.name") {
|
|
435
438
|
return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`);
|
|
436
439
|
}
|
|
437
440
|
function X(e, t) {
|
|
@@ -440,7 +443,7 @@ function X(e, t) {
|
|
|
440
443
|
function ye(e) {
|
|
441
444
|
return parseInt(e.name.slice(4), 10);
|
|
442
445
|
}
|
|
443
|
-
function
|
|
446
|
+
function Vt(e) {
|
|
444
447
|
switch (e) {
|
|
445
448
|
case "ES256":
|
|
446
449
|
return "P-256";
|
|
@@ -468,45 +471,45 @@ function Ft(e, t, ...n) {
|
|
|
468
471
|
case "HS384":
|
|
469
472
|
case "HS512": {
|
|
470
473
|
if (!X(e.algorithm, "HMAC"))
|
|
471
|
-
throw
|
|
474
|
+
throw k("HMAC");
|
|
472
475
|
const r = parseInt(t.slice(2), 10);
|
|
473
476
|
if (ye(e.algorithm.hash) !== r)
|
|
474
|
-
throw
|
|
477
|
+
throw k(`SHA-${r}`, "algorithm.hash");
|
|
475
478
|
break;
|
|
476
479
|
}
|
|
477
480
|
case "RS256":
|
|
478
481
|
case "RS384":
|
|
479
482
|
case "RS512": {
|
|
480
483
|
if (!X(e.algorithm, "RSASSA-PKCS1-v1_5"))
|
|
481
|
-
throw
|
|
484
|
+
throw k("RSASSA-PKCS1-v1_5");
|
|
482
485
|
const r = parseInt(t.slice(2), 10);
|
|
483
486
|
if (ye(e.algorithm.hash) !== r)
|
|
484
|
-
throw
|
|
487
|
+
throw k(`SHA-${r}`, "algorithm.hash");
|
|
485
488
|
break;
|
|
486
489
|
}
|
|
487
490
|
case "PS256":
|
|
488
491
|
case "PS384":
|
|
489
492
|
case "PS512": {
|
|
490
493
|
if (!X(e.algorithm, "RSA-PSS"))
|
|
491
|
-
throw
|
|
494
|
+
throw k("RSA-PSS");
|
|
492
495
|
const r = parseInt(t.slice(2), 10);
|
|
493
496
|
if (ye(e.algorithm.hash) !== r)
|
|
494
|
-
throw
|
|
497
|
+
throw k(`SHA-${r}`, "algorithm.hash");
|
|
495
498
|
break;
|
|
496
499
|
}
|
|
497
500
|
case "EdDSA": {
|
|
498
501
|
if (e.algorithm.name !== "Ed25519" && e.algorithm.name !== "Ed448")
|
|
499
|
-
throw
|
|
502
|
+
throw k("Ed25519 or Ed448");
|
|
500
503
|
break;
|
|
501
504
|
}
|
|
502
505
|
case "ES256":
|
|
503
506
|
case "ES384":
|
|
504
507
|
case "ES512": {
|
|
505
508
|
if (!X(e.algorithm, "ECDSA"))
|
|
506
|
-
throw
|
|
507
|
-
const r =
|
|
509
|
+
throw k("ECDSA");
|
|
510
|
+
const r = Vt(t);
|
|
508
511
|
if (e.algorithm.namedCurve !== r)
|
|
509
|
-
throw
|
|
512
|
+
throw k(r, "algorithm.namedCurve");
|
|
510
513
|
break;
|
|
511
514
|
}
|
|
512
515
|
default:
|
|
@@ -590,7 +593,7 @@ function Qt(e) {
|
|
|
590
593
|
}, n = e.d ? ["decrypt", "unwrapKey"] : ["encrypt", "wrapKey"];
|
|
591
594
|
break;
|
|
592
595
|
default:
|
|
593
|
-
throw new
|
|
596
|
+
throw new O('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
594
597
|
}
|
|
595
598
|
break;
|
|
596
599
|
}
|
|
@@ -612,7 +615,7 @@ function Qt(e) {
|
|
|
612
615
|
t = { name: "ECDH", namedCurve: e.crv }, n = e.d ? ["deriveBits"] : [];
|
|
613
616
|
break;
|
|
614
617
|
default:
|
|
615
|
-
throw new
|
|
618
|
+
throw new O('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
616
619
|
}
|
|
617
620
|
break;
|
|
618
621
|
}
|
|
@@ -628,12 +631,12 @@ function Qt(e) {
|
|
|
628
631
|
t = { name: e.crv }, n = e.d ? ["deriveBits"] : [];
|
|
629
632
|
break;
|
|
630
633
|
default:
|
|
631
|
-
throw new
|
|
634
|
+
throw new O('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
632
635
|
}
|
|
633
636
|
break;
|
|
634
637
|
}
|
|
635
638
|
default:
|
|
636
|
-
throw new
|
|
639
|
+
throw new O('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
|
|
637
640
|
}
|
|
638
641
|
return { algorithm: t, keyUsages: n };
|
|
639
642
|
}
|
|
@@ -646,7 +649,7 @@ const Xt = async (e) => {
|
|
|
646
649
|
e.key_ops ?? n
|
|
647
650
|
], a = { ...e };
|
|
648
651
|
return delete a.alg, delete a.use, he.subtle.importKey("jwk", a, ...r);
|
|
649
|
-
}, Ze = (e) =>
|
|
652
|
+
}, Ze = (e) => V(e);
|
|
650
653
|
let ge, me;
|
|
651
654
|
const et = (e) => (e == null ? void 0 : e[Symbol.toStringTag]) === "KeyObject", tt = async (e, t, n, r) => {
|
|
652
655
|
let a = e.get(t);
|
|
@@ -666,35 +669,35 @@ const et = (e) => (e == null ? void 0 : e[Symbol.toStringTag]) === "KeyObject",
|
|
|
666
669
|
return n.k ? Ze(n.k) : (ge || (ge = /* @__PURE__ */ new WeakMap()), tt(ge, e, n, t));
|
|
667
670
|
}
|
|
668
671
|
return e;
|
|
669
|
-
}, tn = { normalizePublicKey: Zt, normalizePrivateKey: en },
|
|
672
|
+
}, tn = { normalizePublicKey: Zt, normalizePrivateKey: en }, P = (e, t, n = 0) => {
|
|
670
673
|
n === 0 && (t.unshift(t.length), t.unshift(6));
|
|
671
674
|
const r = e.indexOf(t[0], n);
|
|
672
675
|
if (r === -1)
|
|
673
676
|
return !1;
|
|
674
677
|
const a = e.subarray(r, r + t.length);
|
|
675
|
-
return a.length !== t.length ? !1 : a.every((s, o) => s === t[o]) ||
|
|
678
|
+
return a.length !== t.length ? !1 : a.every((s, o) => s === t[o]) || P(e, t, r + 1);
|
|
676
679
|
}, Ne = (e) => {
|
|
677
680
|
switch (!0) {
|
|
678
|
-
case
|
|
681
|
+
case P(e, [42, 134, 72, 206, 61, 3, 1, 7]):
|
|
679
682
|
return "P-256";
|
|
680
|
-
case
|
|
683
|
+
case P(e, [43, 129, 4, 0, 34]):
|
|
681
684
|
return "P-384";
|
|
682
|
-
case
|
|
685
|
+
case P(e, [43, 129, 4, 0, 35]):
|
|
683
686
|
return "P-521";
|
|
684
|
-
case
|
|
687
|
+
case P(e, [43, 101, 110]):
|
|
685
688
|
return "X25519";
|
|
686
|
-
case
|
|
689
|
+
case P(e, [43, 101, 111]):
|
|
687
690
|
return "X448";
|
|
688
|
-
case
|
|
691
|
+
case P(e, [43, 101, 112]):
|
|
689
692
|
return "Ed25519";
|
|
690
|
-
case
|
|
693
|
+
case P(e, [43, 101, 113]):
|
|
691
694
|
return "Ed448";
|
|
692
695
|
default:
|
|
693
|
-
throw new
|
|
696
|
+
throw new O("Invalid or unsupported EC Key Curve or OKP Key Sub Type");
|
|
694
697
|
}
|
|
695
698
|
}, nn = async (e, t, n, r, a) => {
|
|
696
699
|
let s, o;
|
|
697
|
-
const i = new Uint8Array(atob(n.replace(e, "")).split("").map((
|
|
700
|
+
const i = new Uint8Array(atob(n.replace(e, "")).split("").map((l) => l.charCodeAt(0)));
|
|
698
701
|
switch (r) {
|
|
699
702
|
case "PS256":
|
|
700
703
|
case "PS384":
|
|
@@ -728,15 +731,15 @@ const et = (e) => (e == null ? void 0 : e[Symbol.toStringTag]) === "KeyObject",
|
|
|
728
731
|
case "ECDH-ES+A128KW":
|
|
729
732
|
case "ECDH-ES+A192KW":
|
|
730
733
|
case "ECDH-ES+A256KW": {
|
|
731
|
-
const
|
|
732
|
-
s =
|
|
734
|
+
const l = Ne(i);
|
|
735
|
+
s = l.startsWith("P-") ? { name: "ECDH", namedCurve: l } : { name: l }, o = [];
|
|
733
736
|
break;
|
|
734
737
|
}
|
|
735
738
|
case "EdDSA":
|
|
736
739
|
s = { name: Ne(i) }, o = ["verify"];
|
|
737
740
|
break;
|
|
738
741
|
default:
|
|
739
|
-
throw new
|
|
742
|
+
throw new O('Invalid or unsupported "alg" (Algorithm) value');
|
|
740
743
|
}
|
|
741
744
|
return he.subtle.importKey(t, i, s, !1, o);
|
|
742
745
|
}, rn = (e, t, n) => nn(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g, "spki", e, t);
|
|
@@ -775,7 +778,7 @@ function un(e, t, n, r, a) {
|
|
|
775
778
|
n !== void 0 ? s = new Map([...Object.entries(n), ...t.entries()]) : s = t;
|
|
776
779
|
for (const o of r.crit) {
|
|
777
780
|
if (!s.has(o))
|
|
778
|
-
throw new
|
|
781
|
+
throw new O(`Extension Header Parameter "${o}" is not recognized`);
|
|
779
782
|
if (a[o] === void 0)
|
|
780
783
|
throw new e(`Extension Header Parameter "${o}" is missing`);
|
|
781
784
|
if (s.get(o) && r[o] === void 0)
|
|
@@ -811,7 +814,7 @@ function dn(e, t) {
|
|
|
811
814
|
case "EdDSA":
|
|
812
815
|
return { name: t.name };
|
|
813
816
|
default:
|
|
814
|
-
throw new
|
|
817
|
+
throw new O(`alg ${e} is not supported either by JOSE or your javascript runtime`);
|
|
815
818
|
}
|
|
816
819
|
}
|
|
817
820
|
async function hn(e, t, n) {
|
|
@@ -836,75 +839,75 @@ const pn = async (e, t, n, r) => {
|
|
|
836
839
|
};
|
|
837
840
|
async function fn(e, t, n) {
|
|
838
841
|
if (!ue(e))
|
|
839
|
-
throw new
|
|
842
|
+
throw new A("Flattened JWS must be an object");
|
|
840
843
|
if (e.protected === void 0 && e.header === void 0)
|
|
841
|
-
throw new
|
|
844
|
+
throw new A('Flattened JWS must have either of the "protected" or "header" members');
|
|
842
845
|
if (e.protected !== void 0 && typeof e.protected != "string")
|
|
843
|
-
throw new
|
|
846
|
+
throw new A("JWS Protected Header incorrect type");
|
|
844
847
|
if (e.payload === void 0)
|
|
845
|
-
throw new
|
|
848
|
+
throw new A("JWS Payload missing");
|
|
846
849
|
if (typeof e.signature != "string")
|
|
847
|
-
throw new
|
|
850
|
+
throw new A("JWS Signature missing or incorrect type");
|
|
848
851
|
if (e.header !== void 0 && !ue(e.header))
|
|
849
|
-
throw new
|
|
852
|
+
throw new A("JWS Unprotected Header incorrect type");
|
|
850
853
|
let r = {};
|
|
851
854
|
if (e.protected)
|
|
852
855
|
try {
|
|
853
|
-
const d =
|
|
854
|
-
r = JSON.parse(
|
|
856
|
+
const d = V(e.protected);
|
|
857
|
+
r = JSON.parse(F.decode(d));
|
|
855
858
|
} catch {
|
|
856
|
-
throw new
|
|
859
|
+
throw new A("JWS Protected Header is invalid");
|
|
857
860
|
}
|
|
858
861
|
if (!Bt(r, e.header))
|
|
859
|
-
throw new
|
|
862
|
+
throw new A("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
|
|
860
863
|
const a = {
|
|
861
864
|
...r,
|
|
862
865
|
...e.header
|
|
863
|
-
}, s = un(
|
|
866
|
+
}, s = un(A, /* @__PURE__ */ new Map([["b64", !0]]), n == null ? void 0 : n.crit, r, a);
|
|
864
867
|
let o = !0;
|
|
865
868
|
if (s.has("b64") && (o = r.b64, typeof o != "boolean"))
|
|
866
|
-
throw new
|
|
869
|
+
throw new A('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
|
|
867
870
|
const { alg: i } = a;
|
|
868
871
|
if (typeof i != "string" || !i)
|
|
869
|
-
throw new
|
|
870
|
-
const
|
|
871
|
-
if (
|
|
872
|
+
throw new A('JWS "alg" (Algorithm) Header Parameter missing or invalid');
|
|
873
|
+
const l = n && ln("algorithms", n.algorithms);
|
|
874
|
+
if (l && !l.has(i))
|
|
872
875
|
throw new Jt('"alg" (Algorithm) Header Parameter value not allowed');
|
|
873
876
|
if (o) {
|
|
874
877
|
if (typeof e.payload != "string")
|
|
875
|
-
throw new
|
|
878
|
+
throw new A("JWS Payload must be a string");
|
|
876
879
|
} else if (typeof e.payload != "string" && !(e.payload instanceof Uint8Array))
|
|
877
|
-
throw new
|
|
878
|
-
let
|
|
879
|
-
typeof t == "function" && (t = await t(r, e),
|
|
880
|
-
const
|
|
881
|
-
let
|
|
880
|
+
throw new A("JWS Payload must be a string or an Uint8Array instance");
|
|
881
|
+
let y = !1;
|
|
882
|
+
typeof t == "function" && (t = await t(r, e), y = !0), cn(i, t, "verify");
|
|
883
|
+
const h = Mt(Q.encode(e.protected ?? ""), Q.encode("."), typeof e.payload == "string" ? Q.encode(e.payload) : e.payload);
|
|
884
|
+
let p;
|
|
882
885
|
try {
|
|
883
|
-
|
|
886
|
+
p = V(e.signature);
|
|
884
887
|
} catch {
|
|
885
|
-
throw new
|
|
888
|
+
throw new A("Failed to base64url decode the signature");
|
|
886
889
|
}
|
|
887
|
-
if (!await pn(i, t,
|
|
888
|
-
throw new
|
|
889
|
-
let
|
|
890
|
+
if (!await pn(i, t, p, h))
|
|
891
|
+
throw new Yt();
|
|
892
|
+
let m;
|
|
890
893
|
if (o)
|
|
891
894
|
try {
|
|
892
|
-
|
|
895
|
+
m = V(e.payload);
|
|
893
896
|
} catch {
|
|
894
|
-
throw new
|
|
897
|
+
throw new A("Failed to base64url decode the payload");
|
|
895
898
|
}
|
|
896
|
-
else typeof e.payload == "string" ?
|
|
897
|
-
const
|
|
898
|
-
return e.protected !== void 0 && (
|
|
899
|
+
else typeof e.payload == "string" ? m = Q.encode(e.payload) : m = e.payload;
|
|
900
|
+
const u = { payload: m };
|
|
901
|
+
return e.protected !== void 0 && (u.protectedHeader = r), e.header !== void 0 && (u.unprotectedHeader = e.header), y ? { ...u, key: t } : u;
|
|
899
902
|
}
|
|
900
903
|
async function yn(e, t, n) {
|
|
901
|
-
if (e instanceof Uint8Array && (e =
|
|
902
|
-
throw new
|
|
904
|
+
if (e instanceof Uint8Array && (e = F.decode(e)), typeof e != "string")
|
|
905
|
+
throw new A("Compact JWS must be a string or Uint8Array");
|
|
903
906
|
const { 0: r, 1: a, 2: s, length: o } = e.split(".");
|
|
904
907
|
if (o !== 3)
|
|
905
|
-
throw new
|
|
906
|
-
const i = await fn({ payload: a, protected: r, signature: s }, t, n),
|
|
907
|
-
return typeof t == "function" ? { ...
|
|
908
|
+
throw new A("Invalid Compact JWS");
|
|
909
|
+
const i = await fn({ payload: a, protected: r, signature: s }, t, n), l = { payload: i.payload, protectedHeader: i.protectedHeader };
|
|
910
|
+
return typeof t == "function" ? { ...l, key: i.key } : l;
|
|
908
911
|
}
|
|
909
912
|
const gn = (e) => Math.floor(e.getTime() / 1e3), nt = 60, rt = nt * 60, be = rt * 24, mn = be * 7, wn = be * 365.25, En = /^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i, De = (e) => {
|
|
910
913
|
const t = En.exec(e);
|
|
@@ -952,60 +955,60 @@ const gn = (e) => Math.floor(e.getTime() / 1e3), nt = 60, rt = nt * 60, be = rt
|
|
|
952
955
|
}, Ue = (e) => e.toLowerCase().replace(/^application\//, ""), Sn = (e, t) => typeof e == "string" ? t.includes(e) : Array.isArray(e) ? t.some(Set.prototype.has.bind(new Set(e))) : !1, An = (e, t, n = {}) => {
|
|
953
956
|
let r;
|
|
954
957
|
try {
|
|
955
|
-
r = JSON.parse(
|
|
958
|
+
r = JSON.parse(F.decode(t));
|
|
956
959
|
} catch {
|
|
957
960
|
}
|
|
958
961
|
if (!ue(r))
|
|
959
962
|
throw new C("JWT Claims Set must be a top-level JSON object");
|
|
960
963
|
const { typ: a } = n;
|
|
961
964
|
if (a && (typeof e.typ != "string" || Ue(e.typ) !== Ue(a)))
|
|
962
|
-
throw new
|
|
963
|
-
const { requiredClaims: s = [], issuer: o, subject: i, audience:
|
|
964
|
-
|
|
965
|
-
for (const d of new Set(
|
|
965
|
+
throw new _('unexpected "typ" JWT header value', r, "typ", "check_failed");
|
|
966
|
+
const { requiredClaims: s = [], issuer: o, subject: i, audience: l, maxTokenAge: y } = n, h = [...s];
|
|
967
|
+
y !== void 0 && h.push("iat"), l !== void 0 && h.push("aud"), i !== void 0 && h.push("sub"), o !== void 0 && h.push("iss");
|
|
968
|
+
for (const d of new Set(h.reverse()))
|
|
966
969
|
if (!(d in r))
|
|
967
|
-
throw new
|
|
970
|
+
throw new _(`missing required "${d}" claim`, r, d, "missing");
|
|
968
971
|
if (o && !(Array.isArray(o) ? o : [o]).includes(r.iss))
|
|
969
|
-
throw new
|
|
972
|
+
throw new _('unexpected "iss" claim value', r, "iss", "check_failed");
|
|
970
973
|
if (i && r.sub !== i)
|
|
971
|
-
throw new
|
|
972
|
-
if (
|
|
973
|
-
throw new
|
|
974
|
-
let
|
|
974
|
+
throw new _('unexpected "sub" claim value', r, "sub", "check_failed");
|
|
975
|
+
if (l && !Sn(r.aud, typeof l == "string" ? [l] : l))
|
|
976
|
+
throw new _('unexpected "aud" claim value', r, "aud", "check_failed");
|
|
977
|
+
let p;
|
|
975
978
|
switch (typeof n.clockTolerance) {
|
|
976
979
|
case "string":
|
|
977
|
-
|
|
980
|
+
p = De(n.clockTolerance);
|
|
978
981
|
break;
|
|
979
982
|
case "number":
|
|
980
|
-
|
|
983
|
+
p = n.clockTolerance;
|
|
981
984
|
break;
|
|
982
985
|
case "undefined":
|
|
983
|
-
|
|
986
|
+
p = 0;
|
|
984
987
|
break;
|
|
985
988
|
default:
|
|
986
989
|
throw new TypeError("Invalid clockTolerance option type");
|
|
987
990
|
}
|
|
988
|
-
const { currentDate:
|
|
989
|
-
if ((r.iat !== void 0 ||
|
|
990
|
-
throw new
|
|
991
|
+
const { currentDate: m } = n, u = gn(m || /* @__PURE__ */ new Date());
|
|
992
|
+
if ((r.iat !== void 0 || y) && typeof r.iat != "number")
|
|
993
|
+
throw new _('"iat" claim must be a number', r, "iat", "invalid");
|
|
991
994
|
if (r.nbf !== void 0) {
|
|
992
995
|
if (typeof r.nbf != "number")
|
|
993
|
-
throw new
|
|
994
|
-
if (r.nbf >
|
|
995
|
-
throw new
|
|
996
|
+
throw new _('"nbf" claim must be a number', r, "nbf", "invalid");
|
|
997
|
+
if (r.nbf > u + p)
|
|
998
|
+
throw new _('"nbf" claim timestamp check failed', r, "nbf", "check_failed");
|
|
996
999
|
}
|
|
997
1000
|
if (r.exp !== void 0) {
|
|
998
1001
|
if (typeof r.exp != "number")
|
|
999
|
-
throw new
|
|
1000
|
-
if (r.exp <=
|
|
1001
|
-
throw new
|
|
1002
|
+
throw new _('"exp" claim must be a number', r, "exp", "invalid");
|
|
1003
|
+
if (r.exp <= u - p)
|
|
1004
|
+
throw new Pe('"exp" claim timestamp check failed', r, "exp", "check_failed");
|
|
1002
1005
|
}
|
|
1003
|
-
if (
|
|
1004
|
-
const d =
|
|
1005
|
-
if (d -
|
|
1006
|
-
throw new
|
|
1007
|
-
if (d < 0 -
|
|
1008
|
-
throw new
|
|
1006
|
+
if (y) {
|
|
1007
|
+
const d = u - r.iat, g = typeof y == "number" ? y : De(y);
|
|
1008
|
+
if (d - p > g)
|
|
1009
|
+
throw new Pe('"iat" claim timestamp check failed (too far in the past)', r, "iat", "check_failed");
|
|
1010
|
+
if (d < 0 - p)
|
|
1011
|
+
throw new _('"iat" claim timestamp check failed (it should be in the past)', r, "iat", "check_failed");
|
|
1009
1012
|
}
|
|
1010
1013
|
return r;
|
|
1011
1014
|
};
|
|
@@ -1017,7 +1020,7 @@ async function Tn(e, t, n) {
|
|
|
1017
1020
|
const s = { payload: An(a.protectedHeader, a.payload, n), protectedHeader: a.protectedHeader };
|
|
1018
1021
|
return typeof t == "function" ? { ...s, key: a.key } : s;
|
|
1019
1022
|
}
|
|
1020
|
-
const Rn =
|
|
1023
|
+
const Rn = V;
|
|
1021
1024
|
function bn(e) {
|
|
1022
1025
|
if (typeof e != "string")
|
|
1023
1026
|
throw new C("JWTs must use Compact JWS serialization, JWT must be a string");
|
|
@@ -1036,7 +1039,7 @@ function bn(e) {
|
|
|
1036
1039
|
}
|
|
1037
1040
|
let a;
|
|
1038
1041
|
try {
|
|
1039
|
-
a = JSON.parse(
|
|
1042
|
+
a = JSON.parse(F.decode(r));
|
|
1040
1043
|
} catch {
|
|
1041
1044
|
throw new C("Failed to parse the decoded payload as JSON");
|
|
1042
1045
|
}
|
|
@@ -1044,11 +1047,11 @@ function bn(e) {
|
|
|
1044
1047
|
throw new C("Invalid JWT Claims Set");
|
|
1045
1048
|
return a;
|
|
1046
1049
|
}
|
|
1047
|
-
const
|
|
1050
|
+
const x = async (e) => {
|
|
1048
1051
|
try {
|
|
1049
|
-
const t =
|
|
1052
|
+
const t = T.ALG, n = await an(xt, t);
|
|
1050
1053
|
return await Tn(e, n, {
|
|
1051
|
-
issuer:
|
|
1054
|
+
issuer: T.ISSUER
|
|
1052
1055
|
});
|
|
1053
1056
|
} catch {
|
|
1054
1057
|
return;
|
|
@@ -1060,11 +1063,11 @@ const F = async (e) => {
|
|
|
1060
1063
|
return;
|
|
1061
1064
|
}
|
|
1062
1065
|
};
|
|
1063
|
-
var
|
|
1066
|
+
var E = [];
|
|
1064
1067
|
for (var we = 0; we < 256; ++we)
|
|
1065
|
-
|
|
1068
|
+
E.push((we + 256).toString(16).slice(1));
|
|
1066
1069
|
function _n(e, t = 0) {
|
|
1067
|
-
return (
|
|
1070
|
+
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();
|
|
1068
1071
|
}
|
|
1069
1072
|
var Z, vn = new Uint8Array(16);
|
|
1070
1073
|
function kn() {
|
|
@@ -1072,9 +1075,9 @@ function kn() {
|
|
|
1072
1075
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
1073
1076
|
return Z(vn);
|
|
1074
1077
|
}
|
|
1075
|
-
var
|
|
1078
|
+
var Cn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
1076
1079
|
const $e = {
|
|
1077
|
-
randomUUID:
|
|
1080
|
+
randomUUID: Cn
|
|
1078
1081
|
};
|
|
1079
1082
|
function Ke(e, t, n) {
|
|
1080
1083
|
if ($e.randomUUID && !t && !e)
|
|
@@ -1083,7 +1086,7 @@ function Ke(e, t, n) {
|
|
|
1083
1086
|
var r = e.random || (e.rng || kn)();
|
|
1084
1087
|
return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, _n(r);
|
|
1085
1088
|
}
|
|
1086
|
-
const He = globalThis.crypto,
|
|
1089
|
+
const He = globalThis.crypto, Pn = (e) => `${Ke()}${Ke()}`.slice(0, e), On = (e) => btoa(
|
|
1087
1090
|
[...new Uint8Array(e)].map((t) => String.fromCharCode(t)).join("")
|
|
1088
1091
|
);
|
|
1089
1092
|
async function Nn(e) {
|
|
@@ -1095,12 +1098,22 @@ async function Nn(e) {
|
|
|
1095
1098
|
return On(n).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
1096
1099
|
}
|
|
1097
1100
|
async function Dn(e) {
|
|
1098
|
-
const n =
|
|
1101
|
+
const n = Pn(43), r = await Nn(n);
|
|
1099
1102
|
return {
|
|
1100
1103
|
code_verifier: n,
|
|
1101
1104
|
code_challenge: r
|
|
1102
1105
|
};
|
|
1103
1106
|
}
|
|
1107
|
+
const Pr = async (e, t) => {
|
|
1108
|
+
var n;
|
|
1109
|
+
const r = await x(e);
|
|
1110
|
+
if (!r || !Array.isArray((n = r.payload) == null ? void 0 : n[T.SCOPES_KEY]))
|
|
1111
|
+
return !1;
|
|
1112
|
+
const a = r.payload[T.SCOPES_KEY];
|
|
1113
|
+
return Array.isArray(t) ? t.every((s) => a.includes(s)) : Object.keys(t).some(
|
|
1114
|
+
(s) => t[s].every((o) => a.includes(o))
|
|
1115
|
+
);
|
|
1116
|
+
};
|
|
1104
1117
|
function at(e, t) {
|
|
1105
1118
|
window.dispatchEvent(new StorageEvent("storage", { key: e, newValue: t }));
|
|
1106
1119
|
}
|
|
@@ -1116,7 +1129,7 @@ function ee({
|
|
|
1116
1129
|
key: e,
|
|
1117
1130
|
initialValue: t
|
|
1118
1131
|
}) {
|
|
1119
|
-
const n =
|
|
1132
|
+
const n = Ct($n, () => We(e)), r = W(
|
|
1120
1133
|
(o) => {
|
|
1121
1134
|
try {
|
|
1122
1135
|
const i = typeof o == "function" ? o(JSON.parse(n)) : o;
|
|
@@ -1126,9 +1139,9 @@ function ee({
|
|
|
1126
1139
|
}
|
|
1127
1140
|
},
|
|
1128
1141
|
[e, n]
|
|
1129
|
-
), a =
|
|
1142
|
+
), a = W(() => {
|
|
1130
1143
|
r(t);
|
|
1131
|
-
}, [t, r]), s =
|
|
1144
|
+
}, [t, r]), s = W(() => {
|
|
1132
1145
|
r(null);
|
|
1133
1146
|
}, [r]);
|
|
1134
1147
|
return Te(() => {
|
|
@@ -1139,11 +1152,11 @@ function ee({
|
|
|
1139
1152
|
}
|
|
1140
1153
|
}, [e, t]), [n ? JSON.parse(n) : null, r, a, s];
|
|
1141
1154
|
}
|
|
1142
|
-
var
|
|
1155
|
+
var S = [];
|
|
1143
1156
|
for (var Ee = 0; Ee < 256; ++Ee)
|
|
1144
|
-
|
|
1157
|
+
S.push((Ee + 256).toString(16).slice(1));
|
|
1145
1158
|
function Kn(e, t = 0) {
|
|
1146
|
-
return (
|
|
1159
|
+
return (S[e[t + 0]] + S[e[t + 1]] + S[e[t + 2]] + S[e[t + 3]] + "-" + S[e[t + 4]] + S[e[t + 5]] + "-" + S[e[t + 6]] + S[e[t + 7]] + "-" + S[e[t + 8]] + S[e[t + 9]] + "-" + S[e[t + 10]] + S[e[t + 11]] + S[e[t + 12]] + S[e[t + 13]] + S[e[t + 14]] + S[e[t + 15]]).toLowerCase();
|
|
1147
1160
|
}
|
|
1148
1161
|
var te, Hn = new Uint8Array(16);
|
|
1149
1162
|
function Ln() {
|
|
@@ -1191,19 +1204,19 @@ async function Mn(e, t, n = 50) {
|
|
|
1191
1204
|
await Me(n);
|
|
1192
1205
|
const i = o.createElement("iframe");
|
|
1193
1206
|
try {
|
|
1194
|
-
for (await new Promise((
|
|
1195
|
-
let
|
|
1196
|
-
const
|
|
1197
|
-
|
|
1198
|
-
},
|
|
1199
|
-
|
|
1207
|
+
for (await new Promise((l, y) => {
|
|
1208
|
+
let h = !1;
|
|
1209
|
+
const p = () => {
|
|
1210
|
+
h = !0, l();
|
|
1211
|
+
}, m = (g) => {
|
|
1212
|
+
h = !0, y(g);
|
|
1200
1213
|
};
|
|
1201
|
-
i.onload =
|
|
1202
|
-
const { style:
|
|
1203
|
-
|
|
1214
|
+
i.onload = p, i.onerror = m;
|
|
1215
|
+
const { style: u } = i;
|
|
1216
|
+
u.setProperty("display", "block", "important"), u.position = "absolute", u.top = "0", u.left = "0", u.visibility = "hidden", i.src = "about:blank", o.body.appendChild(i);
|
|
1204
1217
|
const d = () => {
|
|
1205
|
-
var
|
|
1206
|
-
|
|
1218
|
+
var g, R;
|
|
1219
|
+
h || (((R = (g = i.contentWindow) == null ? void 0 : g.document) == null ? void 0 : R.readyState) === "complete" ? p() : setTimeout(d, 10));
|
|
1207
1220
|
};
|
|
1208
1221
|
d();
|
|
1209
1222
|
}); !((a = (r = i.contentWindow) == null ? void 0 : r.document) != null && a.body); )
|
|
@@ -1246,11 +1259,11 @@ const Gn = {
|
|
|
1246
1259
|
}
|
|
1247
1260
|
});
|
|
1248
1261
|
}
|
|
1249
|
-
}), st = { browser: "" },
|
|
1262
|
+
}), st = { browser: "" }, Yn = async (e) => typeof navigator > "u" ? st : { browser: navigator.userAgent }, it = {
|
|
1250
1263
|
canvas: {
|
|
1251
1264
|
data: ""
|
|
1252
1265
|
}
|
|
1253
|
-
},
|
|
1266
|
+
}, Vn = async (e) => {
|
|
1254
1267
|
try {
|
|
1255
1268
|
const t = Array.from(
|
|
1256
1269
|
{ length: 3 },
|
|
@@ -1287,13 +1300,13 @@ const Gn = {
|
|
|
1287
1300
|
const r = [];
|
|
1288
1301
|
for (let o = 0; o < e[0].data.length; o++) {
|
|
1289
1302
|
const i = [];
|
|
1290
|
-
for (let
|
|
1291
|
-
i.push(e[
|
|
1303
|
+
for (let l = 0; l < e.length; l++)
|
|
1304
|
+
i.push(e[l].data[o]);
|
|
1292
1305
|
r.push(Fn(i));
|
|
1293
1306
|
}
|
|
1294
1307
|
const a = r, s = new Uint8ClampedArray(a);
|
|
1295
1308
|
return new ImageData(s, t, n);
|
|
1296
|
-
}, qn = [], zn = "mmMwWLliI0O&1", Qn = "48px",
|
|
1309
|
+
}, qn = [], zn = "mmMwWLliI0O&1", Qn = "48px", $ = ["monospace", "sans-serif", "serif"], Ge = [
|
|
1297
1310
|
"sans-serif-thin",
|
|
1298
1311
|
"ARNO PRO",
|
|
1299
1312
|
"Agency FB",
|
|
@@ -1337,22 +1350,22 @@ const Gn = {
|
|
|
1337
1350
|
const a = n.createElement("div");
|
|
1338
1351
|
a.style.setProperty("visibility", "hidden", "important");
|
|
1339
1352
|
const s = {}, o = {}, i = (d) => {
|
|
1340
|
-
const
|
|
1341
|
-
return
|
|
1342
|
-
},
|
|
1353
|
+
const g = n.createElement("span"), { style: R } = g;
|
|
1354
|
+
return R.position = "absolute", R.top = "0", R.left = "0", R.fontFamily = d, g.textContent = zn, a.appendChild(g), g;
|
|
1355
|
+
}, l = (d, g) => i(`'${d}',${g}`), y = () => $.map(i), h = () => {
|
|
1343
1356
|
const d = {};
|
|
1344
|
-
for (const
|
|
1345
|
-
d[
|
|
1346
|
-
(
|
|
1357
|
+
for (const g of Ge)
|
|
1358
|
+
d[g] = $.map(
|
|
1359
|
+
(R) => l(g, R)
|
|
1347
1360
|
);
|
|
1348
1361
|
return d;
|
|
1349
|
-
},
|
|
1350
|
-
(
|
|
1351
|
-
),
|
|
1362
|
+
}, p = (d) => $.some(
|
|
1363
|
+
(g, R) => d[R].offsetWidth !== s[g] || d[R].offsetHeight !== o[g]
|
|
1364
|
+
), m = y(), u = h();
|
|
1352
1365
|
r.appendChild(a);
|
|
1353
|
-
for (let d = 0; d <
|
|
1354
|
-
s[
|
|
1355
|
-
return Ge.filter((d) =>
|
|
1366
|
+
for (let d = 0; d < $.length; d++)
|
|
1367
|
+
s[$[d]] = m[d].offsetWidth, o[$[d]] = m[d].offsetHeight;
|
|
1368
|
+
return Ge.filter((d) => p(u[d]));
|
|
1356
1369
|
}), ct = {
|
|
1357
1370
|
vendor: "",
|
|
1358
1371
|
vendorUnmasked: "",
|
|
@@ -1491,8 +1504,8 @@ const cr = async (e) => {
|
|
|
1491
1504
|
try {
|
|
1492
1505
|
return Promise.all([
|
|
1493
1506
|
Jn(),
|
|
1494
|
-
Vn(),
|
|
1495
1507
|
Yn(),
|
|
1508
|
+
Vn(),
|
|
1496
1509
|
Xn(),
|
|
1497
1510
|
rr(),
|
|
1498
1511
|
or(),
|
|
@@ -1521,10 +1534,10 @@ const cr = async (e) => {
|
|
|
1521
1534
|
}, ne = "Oops! It looks like your session has expired. For your security, please log in again to continue.", dr = "Your session has been successfully terminated.", re = "Login failed. Please try again.", Ae = "Error getting access token, please re-authenticate.", hr = "You forgot to wrap your component in <AuthProvider>.", le = {
|
|
1522
1535
|
dev: "https://auth.gizmette.local.com:3003",
|
|
1523
1536
|
prod: "https://mylogin.gizmette.com/auth"
|
|
1524
|
-
}, ae = "@@auth@@", J = "LOADING",
|
|
1537
|
+
}, ae = "@@auth@@", J = "LOADING", Y = "LOGIN", ht = "LOGOUT", pr = process.env.NODE_ENV === "production", pt = !pr, fr = (e) => {
|
|
1525
1538
|
try {
|
|
1526
1539
|
const t = In(e);
|
|
1527
|
-
return t ? t[
|
|
1540
|
+
return t ? t[T.USER_ID_KEY] : "";
|
|
1528
1541
|
} catch {
|
|
1529
1542
|
return "";
|
|
1530
1543
|
}
|
|
@@ -1593,11 +1606,11 @@ const cr = async (e) => {
|
|
|
1593
1606
|
sessionExpiration: s,
|
|
1594
1607
|
code: o,
|
|
1595
1608
|
code_verifier: i,
|
|
1596
|
-
domain:
|
|
1597
|
-
fingerprint:
|
|
1609
|
+
domain: l,
|
|
1610
|
+
fingerprint: y
|
|
1598
1611
|
}) => {
|
|
1599
1612
|
try {
|
|
1600
|
-
const
|
|
1613
|
+
const h = await pe({
|
|
1601
1614
|
type: de.AUTHENTICATE,
|
|
1602
1615
|
clientId: n,
|
|
1603
1616
|
params: {
|
|
@@ -1608,15 +1621,15 @@ const cr = async (e) => {
|
|
|
1608
1621
|
nonce: r,
|
|
1609
1622
|
code: o,
|
|
1610
1623
|
code_verifier: i,
|
|
1611
|
-
domain:
|
|
1612
|
-
fingerprint:
|
|
1624
|
+
domain: l,
|
|
1625
|
+
fingerprint: y
|
|
1613
1626
|
}
|
|
1614
|
-
}),
|
|
1615
|
-
return
|
|
1616
|
-
idToken:
|
|
1617
|
-
accessToken:
|
|
1618
|
-
refreshToken:
|
|
1619
|
-
userId:
|
|
1627
|
+
}), p = await x(h.data.idToken);
|
|
1628
|
+
return p && p.payload[T.USER_ID_KEY] !== "" && p.payload[T.NONCE_KEY] === r ? {
|
|
1629
|
+
idToken: h.data.idToken,
|
|
1630
|
+
accessToken: h.data.accessToken,
|
|
1631
|
+
refreshToken: h.data.refreshToken,
|
|
1632
|
+
userId: p.payload[T.USER_ID_KEY],
|
|
1620
1633
|
status: !0
|
|
1621
1634
|
} : {
|
|
1622
1635
|
status: !1
|
|
@@ -1673,11 +1686,11 @@ const cr = async (e) => {
|
|
|
1673
1686
|
domain: s,
|
|
1674
1687
|
fingerprint: await ft()
|
|
1675
1688
|
}
|
|
1676
|
-
}), i = await
|
|
1677
|
-
return i && i.payload[
|
|
1689
|
+
}), i = await x(o.data.accessToken);
|
|
1690
|
+
return i && i.payload[T.USER_ID_KEY] !== "" && i.payload[T.NONCE_KEY] === n ? {
|
|
1678
1691
|
accessToken: o.data.accessToken,
|
|
1679
1692
|
refreshToken: o.data.refreshToken,
|
|
1680
|
-
userId: i.payload[
|
|
1693
|
+
userId: i.payload[T.USER_ID_KEY],
|
|
1681
1694
|
status: !0
|
|
1682
1695
|
} : {
|
|
1683
1696
|
status: !1
|
|
@@ -1762,7 +1775,7 @@ const cr = async (e) => {
|
|
|
1762
1775
|
username,
|
|
1763
1776
|
}
|
|
1764
1777
|
}`
|
|
1765
|
-
},
|
|
1778
|
+
}, K = {
|
|
1766
1779
|
GET_REGISTRATION_OPTIONS: {
|
|
1767
1780
|
schema: oe.GET_REGISTRATION_OPTIONS,
|
|
1768
1781
|
method: "getPasskeyRegistrationOptions"
|
|
@@ -1779,7 +1792,7 @@ const cr = async (e) => {
|
|
|
1779
1792
|
schema: oe.VERIFY_AUTHENTICATION,
|
|
1780
1793
|
method: "verifyPasskeyAuthentication"
|
|
1781
1794
|
}
|
|
1782
|
-
},
|
|
1795
|
+
}, H = async ({
|
|
1783
1796
|
accessToken: e,
|
|
1784
1797
|
type: t,
|
|
1785
1798
|
clientId: n,
|
|
@@ -1805,11 +1818,11 @@ const cr = async (e) => {
|
|
|
1805
1818
|
);
|
|
1806
1819
|
if (o.status !== 200)
|
|
1807
1820
|
return { status: o.status, data: [] };
|
|
1808
|
-
const { data: i, errors:
|
|
1821
|
+
const { data: i, errors: l } = await o.json();
|
|
1809
1822
|
return {
|
|
1810
1823
|
status: o.status,
|
|
1811
1824
|
data: i[t.method],
|
|
1812
|
-
errors:
|
|
1825
|
+
errors: l
|
|
1813
1826
|
};
|
|
1814
1827
|
} catch (a) {
|
|
1815
1828
|
return console.error(a), { status: 500, data: [] };
|
|
@@ -1852,8 +1865,8 @@ class wr {
|
|
|
1852
1865
|
nonce: r,
|
|
1853
1866
|
domain: a
|
|
1854
1867
|
}) {
|
|
1855
|
-
const s = await
|
|
1856
|
-
if (s && s.payload[
|
|
1868
|
+
const s = await x(this.refreshToken);
|
|
1869
|
+
if (s && s.payload[T.USER_ID_KEY] !== "") {
|
|
1857
1870
|
const o = await mr({
|
|
1858
1871
|
clientId: t,
|
|
1859
1872
|
userId: n,
|
|
@@ -1875,20 +1888,25 @@ class wr {
|
|
|
1875
1888
|
};
|
|
1876
1889
|
}
|
|
1877
1890
|
}
|
|
1878
|
-
const
|
|
1891
|
+
const Er = (e) => W(
|
|
1892
|
+
(...t) => {
|
|
1893
|
+
e && console.info(`==> [Auth ${Date.now()}]: `, ...t);
|
|
1894
|
+
},
|
|
1895
|
+
[e]
|
|
1896
|
+
), L = () => {
|
|
1879
1897
|
throw new Error(hr);
|
|
1880
|
-
}, yt =
|
|
1898
|
+
}, yt = Pt({
|
|
1881
1899
|
isAuthenticated: !1,
|
|
1882
1900
|
isLoading: !1,
|
|
1883
1901
|
authenticationType: null,
|
|
1884
|
-
login:
|
|
1885
|
-
logout:
|
|
1886
|
-
getAccessToken:
|
|
1887
|
-
getIdToken:
|
|
1888
|
-
registeringForPasskey:
|
|
1889
|
-
loginWithPasskey:
|
|
1902
|
+
login: L,
|
|
1903
|
+
logout: L,
|
|
1904
|
+
getAccessToken: L,
|
|
1905
|
+
getIdToken: L,
|
|
1906
|
+
registeringForPasskey: L,
|
|
1907
|
+
loginWithPasskey: L,
|
|
1890
1908
|
logoutReason: ""
|
|
1891
|
-
}),
|
|
1909
|
+
}), Sr = kt.createContext({
|
|
1892
1910
|
state: {
|
|
1893
1911
|
isLoading: !0,
|
|
1894
1912
|
isAuthenticated: !1,
|
|
@@ -1899,10 +1917,10 @@ const W = () => {
|
|
|
1899
1917
|
},
|
|
1900
1918
|
dispatch: () => {
|
|
1901
1919
|
}
|
|
1902
|
-
}),
|
|
1920
|
+
}), Ar = (e, t) => (t == null ? void 0 : t.type) === J ? {
|
|
1903
1921
|
...e,
|
|
1904
1922
|
isLoading: t.payload.isLoading
|
|
1905
|
-
} : (t == null ? void 0 : t.type) ===
|
|
1923
|
+
} : (t == null ? void 0 : t.type) === Y ? {
|
|
1906
1924
|
...e,
|
|
1907
1925
|
isLoading: !1,
|
|
1908
1926
|
isAuthenticated: !0,
|
|
@@ -1916,38 +1934,33 @@ const W = () => {
|
|
|
1916
1934
|
user: void 0,
|
|
1917
1935
|
authenticationType: null,
|
|
1918
1936
|
logoutReason: t.payload.logoutReason
|
|
1919
|
-
} : e,
|
|
1937
|
+
} : e, Or = ({
|
|
1920
1938
|
children: e,
|
|
1921
1939
|
sessionExpiration: t,
|
|
1922
1940
|
clientId: n,
|
|
1923
1941
|
domain: r = "",
|
|
1924
1942
|
debug: a = !1
|
|
1925
1943
|
}) => {
|
|
1926
|
-
const [s, o] = Ot(
|
|
1944
|
+
const [s, o] = Ot(Ar, {
|
|
1927
1945
|
isLoading: !0,
|
|
1928
1946
|
isAuthenticated: !1,
|
|
1929
1947
|
authenticationType: null,
|
|
1930
1948
|
user: void 0,
|
|
1931
1949
|
logoutReason: "",
|
|
1932
1950
|
debug: a
|
|
1933
|
-
}), i =
|
|
1951
|
+
}), i = Er(a), l = Ce(!1), y = Ce(""), [h, p, , m] = ee({
|
|
1934
1952
|
key: `${ae}::${n}::@@user@@`
|
|
1935
|
-
}), [
|
|
1953
|
+
}), [u, d, , g] = ee({
|
|
1936
1954
|
key: `${ae}::${n}::@@access@@`
|
|
1937
|
-
}), [
|
|
1955
|
+
}), [R, B, , q] = ee(
|
|
1938
1956
|
{
|
|
1939
1957
|
key: `${ae}::${n}::@@refresh@@`
|
|
1940
1958
|
}
|
|
1941
1959
|
), [gt, Ie, , _e] = ee({
|
|
1942
1960
|
key: `${ae}::${n}::@@nonce@@`
|
|
1943
|
-
}),
|
|
1944
|
-
(...c) => {
|
|
1945
|
-
a && console.info(`==> [Auth ${Date.now()}]: `, ...c);
|
|
1946
|
-
},
|
|
1947
|
-
[a]
|
|
1948
|
-
), mt = new wr(p, m), $ = x(
|
|
1961
|
+
}), mt = new wr(u, R), U = W(
|
|
1949
1962
|
(c) => {
|
|
1950
|
-
|
|
1963
|
+
i(
|
|
1951
1964
|
"removeStateAndLocalStorage: removing state and local storage with reason: ",
|
|
1952
1965
|
c
|
|
1953
1966
|
), o({
|
|
@@ -1955,178 +1968,178 @@ const W = () => {
|
|
|
1955
1968
|
payload: {
|
|
1956
1969
|
logoutReason: c || ne
|
|
1957
1970
|
}
|
|
1958
|
-
}),
|
|
1971
|
+
}), m(), g(), q(), _e(), o({ type: J, payload: { isLoading: !1 } });
|
|
1959
1972
|
},
|
|
1960
|
-
[
|
|
1961
|
-
),
|
|
1973
|
+
[g, m, _e, q, i]
|
|
1974
|
+
), N = W(
|
|
1962
1975
|
async (c) => {
|
|
1963
|
-
|
|
1964
|
-
const { user:
|
|
1965
|
-
|
|
1976
|
+
i("invalidateAndLogout: invalidating and logging out");
|
|
1977
|
+
const { user: w } = s, f = (w == null ? void 0 : w.userId) || fr(h);
|
|
1978
|
+
f || i(
|
|
1966
1979
|
"invalidateAndLogout: user cannot be identified, logging out without userId"
|
|
1967
1980
|
), await yr({
|
|
1968
|
-
userId:
|
|
1969
|
-
idToken:
|
|
1970
|
-
accessToken:
|
|
1971
|
-
refreshToken:
|
|
1981
|
+
userId: f,
|
|
1982
|
+
idToken: h,
|
|
1983
|
+
accessToken: u,
|
|
1984
|
+
refreshToken: R,
|
|
1972
1985
|
clientId: n,
|
|
1973
1986
|
domain: r
|
|
1974
|
-
}),
|
|
1987
|
+
}), U(c || ne);
|
|
1975
1988
|
},
|
|
1976
1989
|
[
|
|
1977
|
-
|
|
1990
|
+
u,
|
|
1978
1991
|
s,
|
|
1979
1992
|
n,
|
|
1980
1993
|
r,
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1994
|
+
h,
|
|
1995
|
+
R,
|
|
1996
|
+
U,
|
|
1997
|
+
i
|
|
1985
1998
|
]
|
|
1986
1999
|
);
|
|
1987
|
-
Te(() => ((async () => (
|
|
1988
|
-
|
|
2000
|
+
Te(() => ((async () => (i("useEffect: setting the fingerprint"), y.current = await ft()))(), () => {
|
|
2001
|
+
i("useEffect: cleaning up the fingerprint"), y.current = "";
|
|
1989
2002
|
}), []), Te(() => {
|
|
1990
|
-
if (!
|
|
1991
|
-
return s.isLoading &&
|
|
2003
|
+
if (!l.current)
|
|
2004
|
+
return s.isLoading && h !== null ? (async () => {
|
|
1992
2005
|
try {
|
|
1993
|
-
const c = await
|
|
1994
|
-
c && c.payload[
|
|
1995
|
-
type:
|
|
2006
|
+
const c = await x(h);
|
|
2007
|
+
c && c.payload[T.USER_ID_KEY] !== "" ? (i("useEffect: setting the authentication state"), o({
|
|
2008
|
+
type: Y,
|
|
1996
2009
|
payload: {
|
|
1997
|
-
authenticationType: c.payload[
|
|
2010
|
+
authenticationType: c.payload[T.AUTH_TYPE_KEY],
|
|
1998
2011
|
user: {
|
|
1999
|
-
userId: c.payload[
|
|
2000
|
-
username: c.payload[
|
|
2012
|
+
userId: c.payload[T.USER_ID_KEY],
|
|
2013
|
+
username: c.payload[T.USERNAME_KEY]
|
|
2001
2014
|
}
|
|
2002
2015
|
}
|
|
2003
|
-
})) : (
|
|
2016
|
+
})) : (i("useEffect: invalid JWT, invalidating and logging out"), await N(ne));
|
|
2004
2017
|
} catch {
|
|
2005
|
-
|
|
2018
|
+
i(
|
|
2006
2019
|
"useEffect: exception validating JWT, invalidating and logging out"
|
|
2007
|
-
), await
|
|
2020
|
+
), await N(ne);
|
|
2008
2021
|
}
|
|
2009
|
-
})() : (
|
|
2010
|
-
|
|
2022
|
+
})() : (i("useEffect: setting the loading state to false"), o({ type: J, payload: { isLoading: !1 } })), () => {
|
|
2023
|
+
l.current = !0;
|
|
2011
2024
|
};
|
|
2012
|
-
}, [s.isLoading,
|
|
2013
|
-
const wt = async (c,
|
|
2014
|
-
const
|
|
2015
|
-
if (Ie(
|
|
2025
|
+
}, [s.isLoading, h, N, i]);
|
|
2026
|
+
const wt = async (c, w, f) => {
|
|
2027
|
+
const I = Se();
|
|
2028
|
+
if (Ie(I), o({ type: J, payload: { isLoading: !0 } }), m(), g(), q(), i("login: Logging in with type: ", f), f === j.CODE) {
|
|
2016
2029
|
const { code_verifier: bt, code_challenge: It } = await Dn(), ve = await gr({
|
|
2017
|
-
nonce:
|
|
2030
|
+
nonce: I,
|
|
2018
2031
|
clientId: n,
|
|
2019
2032
|
code_challenge: It
|
|
2020
2033
|
});
|
|
2021
2034
|
if (ve.status) {
|
|
2022
2035
|
const G = await Je({
|
|
2023
2036
|
username: c,
|
|
2024
|
-
password:
|
|
2037
|
+
password: w,
|
|
2025
2038
|
clientId: n,
|
|
2026
2039
|
sessionExpiration: t,
|
|
2027
|
-
nonce:
|
|
2028
|
-
type:
|
|
2040
|
+
nonce: I,
|
|
2041
|
+
type: f,
|
|
2029
2042
|
code: ve.code,
|
|
2030
2043
|
code_verifier: bt,
|
|
2031
2044
|
domain: r,
|
|
2032
|
-
fingerprint:
|
|
2045
|
+
fingerprint: y.current
|
|
2033
2046
|
});
|
|
2034
|
-
return G.status ? (
|
|
2035
|
-
type:
|
|
2047
|
+
return G.status ? (p(G.idToken), d(G.accessToken), B(G.refreshToken), o({
|
|
2048
|
+
type: Y,
|
|
2036
2049
|
payload: {
|
|
2037
|
-
authenticationType:
|
|
2050
|
+
authenticationType: f,
|
|
2038
2051
|
user: {
|
|
2039
2052
|
userId: G.userId,
|
|
2040
2053
|
username: c
|
|
2041
2054
|
}
|
|
2042
2055
|
}
|
|
2043
|
-
}), !0) : (
|
|
2056
|
+
}), !0) : (U(re), !1);
|
|
2044
2057
|
}
|
|
2045
2058
|
return !1;
|
|
2046
2059
|
}
|
|
2047
2060
|
const M = await Je({
|
|
2048
2061
|
username: c,
|
|
2049
|
-
password:
|
|
2062
|
+
password: w,
|
|
2050
2063
|
clientId: n,
|
|
2051
2064
|
sessionExpiration: t,
|
|
2052
|
-
nonce:
|
|
2053
|
-
type:
|
|
2065
|
+
nonce: I,
|
|
2066
|
+
type: f,
|
|
2054
2067
|
domain: r,
|
|
2055
|
-
fingerprint:
|
|
2068
|
+
fingerprint: y.current
|
|
2056
2069
|
});
|
|
2057
|
-
return M.status ? (
|
|
2058
|
-
type:
|
|
2070
|
+
return M.status ? (p(M.idToken), d(M.accessToken), B(M.refreshToken), o({
|
|
2071
|
+
type: Y,
|
|
2059
2072
|
payload: {
|
|
2060
|
-
authenticationType:
|
|
2073
|
+
authenticationType: f,
|
|
2061
2074
|
user: {
|
|
2062
2075
|
userId: M.userId,
|
|
2063
2076
|
username: c
|
|
2064
2077
|
}
|
|
2065
2078
|
}
|
|
2066
|
-
}), !0) : (
|
|
2079
|
+
}), !0) : (U(re), !1);
|
|
2067
2080
|
}, Et = async (c) => {
|
|
2068
|
-
c == null || c.preventDefault(), await
|
|
2081
|
+
c == null || c.preventDefault(), await N(dr);
|
|
2069
2082
|
}, St = async () => {
|
|
2070
|
-
const { isAuthenticated: c, user:
|
|
2083
|
+
const { isAuthenticated: c, user: w } = s;
|
|
2071
2084
|
try {
|
|
2072
|
-
if (c &&
|
|
2073
|
-
if (
|
|
2074
|
-
|
|
2075
|
-
const
|
|
2076
|
-
if (
|
|
2077
|
-
return
|
|
2085
|
+
if (c && w && w.userId) {
|
|
2086
|
+
if (u) {
|
|
2087
|
+
i("getAccessToken");
|
|
2088
|
+
const I = await x(u);
|
|
2089
|
+
if (I && I.payload[T.USER_ID_KEY] !== "")
|
|
2090
|
+
return u;
|
|
2078
2091
|
}
|
|
2079
|
-
|
|
2080
|
-
const
|
|
2092
|
+
i("getAccessToken: invalid access token, refreshing it");
|
|
2093
|
+
const f = await mt.refreshtoken({
|
|
2081
2094
|
clientId: n,
|
|
2082
|
-
userId:
|
|
2095
|
+
userId: w.userId,
|
|
2083
2096
|
nonce: gt,
|
|
2084
2097
|
domain: r
|
|
2085
2098
|
});
|
|
2086
|
-
return
|
|
2099
|
+
return f.status && f.status === "success" ? (d(f.newAccessToken), B(f.newRefreshToken), f.newAccessToken) : (i("getAccessToken: invalid refresh token, re-authenticating user"), await N(Ae), "");
|
|
2087
2100
|
}
|
|
2088
|
-
return
|
|
2101
|
+
return i(
|
|
2089
2102
|
"getAccessToken: user is not authenticated, cannot get access token"
|
|
2090
|
-
), await
|
|
2103
|
+
), await N(Ae), "";
|
|
2091
2104
|
} catch {
|
|
2092
|
-
return
|
|
2105
|
+
return i(
|
|
2093
2106
|
"getAccessToken: exception occurred, invalidating and logging out"
|
|
2094
|
-
), await
|
|
2107
|
+
), await N(Ae), "";
|
|
2095
2108
|
}
|
|
2096
2109
|
}, At = () => {
|
|
2097
|
-
if (s.isAuthenticated &&
|
|
2098
|
-
return
|
|
2110
|
+
if (s.isAuthenticated && h)
|
|
2111
|
+
return h;
|
|
2099
2112
|
}, Tt = async () => {
|
|
2100
2113
|
const { user: c } = s;
|
|
2101
|
-
let
|
|
2102
|
-
accessToken:
|
|
2114
|
+
let w = await H({
|
|
2115
|
+
accessToken: u,
|
|
2103
2116
|
clientId: n,
|
|
2104
|
-
type:
|
|
2117
|
+
type: K.GET_REGISTRATION_OPTIONS,
|
|
2105
2118
|
params: {
|
|
2106
2119
|
clientId: n,
|
|
2107
2120
|
id: c == null ? void 0 : c.userId,
|
|
2108
2121
|
username: c == null ? void 0 : c.username
|
|
2109
2122
|
}
|
|
2110
2123
|
});
|
|
2111
|
-
if (
|
|
2124
|
+
if (w.status)
|
|
2112
2125
|
try {
|
|
2113
|
-
const
|
|
2114
|
-
|
|
2115
|
-
accessToken:
|
|
2126
|
+
const f = await Kt(w.data);
|
|
2127
|
+
w = await H({
|
|
2128
|
+
accessToken: u,
|
|
2116
2129
|
clientId: n,
|
|
2117
|
-
type:
|
|
2130
|
+
type: K.VERIFY_REGISTRATION,
|
|
2118
2131
|
params: {
|
|
2119
2132
|
clientId: n,
|
|
2120
2133
|
id: c == null ? void 0 : c.userId,
|
|
2121
2134
|
username: c == null ? void 0 : c.username,
|
|
2122
|
-
registration:
|
|
2135
|
+
registration: f
|
|
2123
2136
|
}
|
|
2124
2137
|
});
|
|
2125
2138
|
} catch {
|
|
2126
|
-
return await
|
|
2127
|
-
accessToken:
|
|
2139
|
+
return await H({
|
|
2140
|
+
accessToken: u,
|
|
2128
2141
|
clientId: n,
|
|
2129
|
-
type:
|
|
2142
|
+
type: K.VERIFY_REGISTRATION,
|
|
2130
2143
|
params: {
|
|
2131
2144
|
clientId: n,
|
|
2132
2145
|
id: c == null ? void 0 : c.userId,
|
|
@@ -2137,58 +2150,58 @@ const W = () => {
|
|
|
2137
2150
|
}
|
|
2138
2151
|
}, Rt = async () => {
|
|
2139
2152
|
const c = Se();
|
|
2140
|
-
Ie(c), o({ type: J, payload: { isLoading: !0 } }),
|
|
2141
|
-
const
|
|
2142
|
-
let
|
|
2143
|
-
accessToken:
|
|
2153
|
+
Ie(c), o({ type: J, payload: { isLoading: !0 } }), m(), g(), q(), i("loginWithPasskey");
|
|
2154
|
+
const w = Se();
|
|
2155
|
+
let f = await H({
|
|
2156
|
+
accessToken: u,
|
|
2144
2157
|
clientId: n,
|
|
2145
|
-
type:
|
|
2158
|
+
type: K.GET_AUTHENTICATION_OPTIONS,
|
|
2146
2159
|
params: {
|
|
2147
|
-
id:
|
|
2160
|
+
id: w,
|
|
2148
2161
|
clientId: n
|
|
2149
2162
|
}
|
|
2150
2163
|
});
|
|
2151
|
-
if (
|
|
2164
|
+
if (f.status)
|
|
2152
2165
|
try {
|
|
2153
|
-
const
|
|
2154
|
-
return
|
|
2155
|
-
accessToken:
|
|
2166
|
+
const I = await Wt(f.data);
|
|
2167
|
+
return f = await H({
|
|
2168
|
+
accessToken: u,
|
|
2156
2169
|
clientId: n,
|
|
2157
|
-
type:
|
|
2170
|
+
type: K.VERIFY_AUTHENTICATION,
|
|
2158
2171
|
params: {
|
|
2159
2172
|
clientId: n,
|
|
2160
|
-
id:
|
|
2161
|
-
authentication:
|
|
2173
|
+
id: w,
|
|
2174
|
+
authentication: I,
|
|
2162
2175
|
nonce: c,
|
|
2163
2176
|
domain: r,
|
|
2164
|
-
fingerprint:
|
|
2177
|
+
fingerprint: y.current
|
|
2165
2178
|
}
|
|
2166
|
-
}),
|
|
2167
|
-
type:
|
|
2179
|
+
}), f.data.status === "success" ? (p(f.data.idToken), d(f.data.accessToken), B(f.data.refreshToken), o({
|
|
2180
|
+
type: Y,
|
|
2168
2181
|
payload: {
|
|
2169
2182
|
authenticationType: j.PASSKEY,
|
|
2170
2183
|
user: {
|
|
2171
|
-
userId:
|
|
2172
|
-
username:
|
|
2184
|
+
userId: f.data.userId,
|
|
2185
|
+
username: f.data.username
|
|
2173
2186
|
}
|
|
2174
2187
|
}
|
|
2175
|
-
}), !0) : (
|
|
2188
|
+
}), !0) : (U(re), !1);
|
|
2176
2189
|
} catch {
|
|
2177
|
-
return await
|
|
2178
|
-
accessToken:
|
|
2190
|
+
return await H({
|
|
2191
|
+
accessToken: u,
|
|
2179
2192
|
clientId: n,
|
|
2180
|
-
type:
|
|
2193
|
+
type: K.VERIFY_AUTHENTICATION,
|
|
2181
2194
|
params: {
|
|
2182
2195
|
clientId: n,
|
|
2183
|
-
id:
|
|
2196
|
+
id: w,
|
|
2184
2197
|
authentication: {},
|
|
2185
2198
|
nonce: c,
|
|
2186
2199
|
domain: r
|
|
2187
2200
|
}
|
|
2188
|
-
}),
|
|
2201
|
+
}), U(re), !1;
|
|
2189
2202
|
}
|
|
2190
2203
|
};
|
|
2191
|
-
return /* @__PURE__ */ ke(
|
|
2204
|
+
return /* @__PURE__ */ ke(Sr.Provider, { value: { state: s, dispatch: o }, children: /* @__PURE__ */ ke(
|
|
2192
2205
|
yt.Provider,
|
|
2193
2206
|
{
|
|
2194
2207
|
value: {
|
|
@@ -2203,9 +2216,10 @@ const W = () => {
|
|
|
2203
2216
|
children: e
|
|
2204
2217
|
}
|
|
2205
2218
|
) });
|
|
2206
|
-
},
|
|
2219
|
+
}, Nr = (e = yt) => Nt(e);
|
|
2207
2220
|
export {
|
|
2208
2221
|
j as AUTH_TYPES,
|
|
2209
|
-
|
|
2210
|
-
|
|
2222
|
+
Or as AuthProvider,
|
|
2223
|
+
Pr as isGranted,
|
|
2224
|
+
Nr as useAuth
|
|
2211
2225
|
};
|