@versini/auth-provider 6.3.3 → 6.3.5

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.
Files changed (2) hide show
  1. package/dist/index.js +663 -669
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,16 +1,16 @@
1
- var It = Object.defineProperty;
2
- var _t = (e, t, n) => t in e ? It(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var Q = (e, t, n) => _t(e, typeof t != "symbol" ? t + "" : t, n);
1
+ var vt = Object.defineProperty;
2
+ var Ct = (e, t, n) => t in e ? vt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var Q = (e, t, n) => Ct(e, typeof t != "symbol" ? t + "" : t, n);
4
4
  import { jsx as ve } from "react/jsx-runtime";
5
- import vt, { useSyncExternalStore as kt, useCallback as x, useEffect as Ae, createContext as Ct, useReducer as Pt, useRef as ke, useContext as Ot } from "react";
5
+ import Pt, { useSyncExternalStore as kt, useCallback as x, useEffect as Ae, createContext as Ot, useReducer as Nt, useRef as Ce, useContext as Dt } from "react";
6
6
  /*!
7
- @versini/auth-provider v6.3.3
7
+ @versini/auth-provider v6.3.5
8
8
  © 2024 gizmette.com
9
9
  */
10
10
  try {
11
11
  window.__VERSINI_AUTH_CLIENT__ || (window.__VERSINI_AUTH_CLIENT__ = {
12
- version: "6.3.3",
13
- buildTime: "07/24/2024 07:46 AM EDT",
12
+ version: "6.3.5",
13
+ buildTime: "07/24/2024 07:48 PM EDT",
14
14
  homepage: "https://github.com/aversini/auth-client",
15
15
  license: "MIT"
16
16
  });
@@ -30,9 +30,9 @@ function ie(e) {
30
30
  return s;
31
31
  }
32
32
  function Te() {
33
- return (window == null ? void 0 : window.PublicKeyCredential) !== void 0 && typeof window.PublicKeyCredential == "function";
33
+ return window?.PublicKeyCredential !== void 0 && typeof window.PublicKeyCredential == "function";
34
34
  }
35
- function Je(e) {
35
+ function Ye(e) {
36
36
  const { id: t } = e;
37
37
  return {
38
38
  ...e,
@@ -40,7 +40,7 @@ function Je(e) {
40
40
  transports: e.transports
41
41
  };
42
42
  }
43
- function Ye(e) {
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 {
@@ -48,8 +48,7 @@ class b extends Error {
48
48
  super(t, { cause: r }), this.name = a ?? r.name, this.code = n;
49
49
  }
50
50
  }
51
- function Nt({ error: e, options: t }) {
52
- var r, a;
51
+ function Ut({ error: e, options: t }) {
53
52
  const { publicKey: n } = t;
54
53
  if (!n)
55
54
  throw Error("options was missing required publicKey property");
@@ -61,13 +60,13 @@ function Nt({ error: e, options: t }) {
61
60
  cause: e
62
61
  });
63
62
  } else if (e.name === "ConstraintError") {
64
- if (((r = n.authenticatorSelection) == null ? void 0 : r.requireResidentKey) === !0)
63
+ if (n.authenticatorSelection?.requireResidentKey === !0)
65
64
  return new b({
66
65
  message: "Discoverable credentials were required but no available authenticator supported it",
67
66
  code: "ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",
68
67
  cause: e
69
68
  });
70
- if (((a = n.authenticatorSelection) == null ? void 0 : a.userVerification) === "required")
69
+ if (n.authenticatorSelection?.userVerification === "required")
71
70
  return new b({
72
71
  message: "User verification was required but no available authenticator supported it",
73
72
  code: "ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",
@@ -87,7 +86,7 @@ function Nt({ error: e, options: t }) {
87
86
  cause: e
88
87
  });
89
88
  if (e.name === "NotSupportedError")
90
- return n.pubKeyCredParams.filter((o) => o.type === "public-key").length === 0 ? new b({
89
+ return n.pubKeyCredParams.filter((a) => a.type === "public-key").length === 0 ? new b({
91
90
  message: 'No entry in pubKeyCredParams was of type "public-key"',
92
91
  code: "ERROR_MALFORMED_PUBKEYCREDPARAMS",
93
92
  cause: e
@@ -97,9 +96,9 @@ function Nt({ error: e, options: t }) {
97
96
  cause: e
98
97
  });
99
98
  if (e.name === "SecurityError") {
100
- const s = window.location.hostname;
101
- if (Ye(s)) {
102
- if (n.rp.id !== s)
99
+ const r = window.location.hostname;
100
+ if (Ve(r)) {
101
+ if (n.rp.id !== r)
103
102
  return new b({
104
103
  message: `The RP ID "${n.rp.id}" is invalid for this domain`,
105
104
  code: "ERROR_INVALID_RP_ID",
@@ -126,7 +125,7 @@ function Nt({ error: e, options: t }) {
126
125
  }
127
126
  return e;
128
127
  }
129
- class Dt {
128
+ class $t {
130
129
  createNewAbortSignal() {
131
130
  if (this.controller) {
132
131
  const n = new Error("Cancelling existing WebAuthn API call for new one");
@@ -142,13 +141,12 @@ class Dt {
142
141
  }
143
142
  }
144
143
  }
145
- const Ve = new Dt(), Ut = ["cross-platform", "platform"];
146
- function je(e) {
147
- if (e && !(Ut.indexOf(e) < 0))
144
+ const je = new $t(), Kt = ["cross-platform", "platform"];
145
+ function Fe(e) {
146
+ if (e && !(Kt.indexOf(e) < 0))
148
147
  return e;
149
148
  }
150
- async function $t(e) {
151
- var m;
149
+ async function Ht(e) {
152
150
  if (!Te())
153
151
  throw new Error("WebAuthn is not supported in this browser");
154
152
  const n = { publicKey: {
@@ -158,41 +156,41 @@ async function $t(e) {
158
156
  ...e.user,
159
157
  id: ie(e.user.id)
160
158
  },
161
- excludeCredentials: (m = e.excludeCredentials) == null ? void 0 : m.map(Je)
159
+ excludeCredentials: e.excludeCredentials?.map(Ye)
162
160
  } };
163
- n.signal = Ve.createNewAbortSignal();
161
+ n.signal = je.createNewAbortSignal();
164
162
  let r;
165
163
  try {
166
164
  r = await navigator.credentials.create(n);
167
- } catch (u) {
168
- throw Nt({ error: u, options: n });
165
+ } catch (y) {
166
+ throw Ut({ error: y, options: n });
169
167
  }
170
168
  if (!r)
171
169
  throw new Error("Registration was not completed");
172
170
  const { id: a, rawId: s, response: o, type: i } = r;
173
- let l;
174
- typeof o.getTransports == "function" && (l = o.getTransports());
175
- let y;
171
+ let c;
172
+ typeof o.getTransports == "function" && (c = o.getTransports());
173
+ let g;
176
174
  if (typeof o.getPublicKeyAlgorithm == "function")
177
175
  try {
178
- y = o.getPublicKeyAlgorithm();
179
- } catch (u) {
180
- fe("getPublicKeyAlgorithm()", u);
176
+ g = o.getPublicKeyAlgorithm();
177
+ } catch (y) {
178
+ fe("getPublicKeyAlgorithm()", y);
181
179
  }
182
- let h;
180
+ let l;
183
181
  if (typeof o.getPublicKey == "function")
184
182
  try {
185
- const u = o.getPublicKey();
186
- u !== null && (h = v(u));
187
- } catch (u) {
188
- fe("getPublicKey()", u);
183
+ const y = o.getPublicKey();
184
+ y !== null && (l = v(y));
185
+ } catch (y) {
186
+ fe("getPublicKey()", y);
189
187
  }
190
- let p;
188
+ let h;
191
189
  if (typeof o.getAuthenticatorData == "function")
192
190
  try {
193
- p = v(o.getAuthenticatorData());
194
- } catch (u) {
195
- fe("getAuthenticatorData()", u);
191
+ h = v(o.getAuthenticatorData());
192
+ } catch (y) {
193
+ fe("getAuthenticatorData()", y);
196
194
  }
197
195
  return {
198
196
  id: a,
@@ -200,27 +198,27 @@ async function $t(e) {
200
198
  response: {
201
199
  attestationObject: v(o.attestationObject),
202
200
  clientDataJSON: v(o.clientDataJSON),
203
- transports: l,
204
- publicKeyAlgorithm: y,
205
- publicKey: h,
206
- authenticatorData: p
201
+ transports: c,
202
+ publicKeyAlgorithm: g,
203
+ publicKey: l,
204
+ authenticatorData: h
207
205
  },
208
206
  type: i,
209
207
  clientExtensionResults: r.getClientExtensionResults(),
210
- authenticatorAttachment: je(r.authenticatorAttachment)
208
+ authenticatorAttachment: Fe(r.authenticatorAttachment)
211
209
  };
212
210
  }
213
211
  function fe(e, t) {
214
212
  console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.
215
213
  `, t);
216
214
  }
217
- function Kt() {
215
+ function Lt() {
218
216
  if (!Te())
219
217
  return new Promise((t) => t(!1));
220
218
  const e = window.PublicKeyCredential;
221
219
  return e.isConditionalMediationAvailable === void 0 ? new Promise((t) => t(!1)) : e.isConditionalMediationAvailable();
222
220
  }
223
- function Ht({ error: e, options: t }) {
221
+ function Wt({ error: e, options: t }) {
224
222
  const { publicKey: n } = t;
225
223
  if (!n)
226
224
  throw Error("options was missing required publicKey property");
@@ -240,7 +238,7 @@ function Ht({ error: e, options: t }) {
240
238
  });
241
239
  if (e.name === "SecurityError") {
242
240
  const r = window.location.hostname;
243
- if (Ye(r)) {
241
+ if (Ve(r)) {
244
242
  if (n.rpId !== r)
245
243
  return new b({
246
244
  message: `The RP ID "${n.rpId}" is invalid for this domain`,
@@ -261,47 +259,46 @@ function Ht({ error: e, options: t }) {
261
259
  }
262
260
  return e;
263
261
  }
264
- async function Lt(e, t = !1) {
265
- var p, m;
262
+ async function xt(e, t = !1) {
266
263
  if (!Te())
267
264
  throw new Error("WebAuthn is not supported in this browser");
268
265
  let n;
269
- ((p = e.allowCredentials) == null ? void 0 : p.length) !== 0 && (n = (m = e.allowCredentials) == null ? void 0 : m.map(Je));
266
+ e.allowCredentials?.length !== 0 && (n = e.allowCredentials?.map(Ye));
270
267
  const r = {
271
268
  ...e,
272
269
  challenge: ie(e.challenge),
273
270
  allowCredentials: n
274
271
  }, a = {};
275
272
  if (t) {
276
- if (!await Kt())
273
+ if (!await Lt())
277
274
  throw Error("Browser does not support WebAuthn autofill");
278
275
  if (document.querySelectorAll("input[autocomplete$='webauthn']").length < 1)
279
276
  throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');
280
277
  a.mediation = "conditional", r.allowCredentials = [];
281
278
  }
282
- a.publicKey = r, a.signal = Ve.createNewAbortSignal();
279
+ a.publicKey = r, a.signal = je.createNewAbortSignal();
283
280
  let s;
284
281
  try {
285
282
  s = await navigator.credentials.get(a);
286
- } catch (u) {
287
- throw Ht({ error: u, options: a });
283
+ } catch (h) {
284
+ throw Wt({ error: h, options: a });
288
285
  }
289
286
  if (!s)
290
287
  throw new Error("Authentication was not completed");
291
- const { id: o, rawId: i, response: l, type: y } = s;
292
- let h;
293
- return l.userHandle && (h = v(l.userHandle)), {
288
+ const { id: o, rawId: i, response: c, type: g } = s;
289
+ let l;
290
+ return c.userHandle && (l = v(c.userHandle)), {
294
291
  id: o,
295
292
  rawId: v(i),
296
293
  response: {
297
- authenticatorData: v(l.authenticatorData),
298
- clientDataJSON: v(l.clientDataJSON),
299
- signature: v(l.signature),
300
- userHandle: h
294
+ authenticatorData: v(c.authenticatorData),
295
+ clientDataJSON: v(c.clientDataJSON),
296
+ signature: v(c.signature),
297
+ userHandle: l
301
298
  },
302
- type: y,
299
+ type: g,
303
300
  clientExtensionResults: s.getClientExtensionResults(),
304
- authenticatorAttachment: je(s.authenticatorAttachment)
301
+ authenticatorAttachment: Fe(s.authenticatorAttachment)
305
302
  };
306
303
  }
307
304
  /*!
@@ -311,7 +308,7 @@ async function Lt(e, t = !1) {
311
308
  try {
312
309
  window.__VERSINI_AUTH_COMMON__ || (window.__VERSINI_AUTH_COMMON__ = {
313
310
  version: "3.3.0",
314
- buildTime: "07/24/2024 07:46 AM EDT",
311
+ buildTime: "07/24/2024 07:48 PM EDT",
315
312
  homepage: "https://github.com/aversini/auth-client",
316
313
  license: "MIT"
317
314
  });
@@ -324,9 +321,9 @@ const F = {
324
321
  CODE: "code",
325
322
  REFRESH_TOKEN: "refresh_token",
326
323
  PASSKEY: "passkey"
327
- }, Fe = {
324
+ }, Be = {
328
325
  CLIENT_ID: "X-Auth-ClientId"
329
- }, T = {
326
+ }, A = {
330
327
  ALG: "RS256",
331
328
  USER_ID_KEY: "sub",
332
329
  TOKEN_ID_KEY: "__raw",
@@ -337,7 +334,7 @@ const F = {
337
334
  CREATED_AT_KEY: "iat",
338
335
  SCOPES_KEY: "scopes",
339
336
  ISSUER: "gizmette.com"
340
- }, Wt = `-----BEGIN PUBLIC KEY-----
337
+ }, Mt = `-----BEGIN PUBLIC KEY-----
341
338
  MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsF6i3Jd9fY/3COqCw/m7
342
339
  w5PKyTYLGAI2I6SIIdpe6i6DOCbEkmDz7LdVsBqwNtVi8gvWYIj+8ol6rU3qu1v5
343
340
  i1Jd45GSK4kzkVdgCmQZbM5ak0KI99q5wsrAIzUd+LRJ2HRvWtr5IYdsIiXaQjle
@@ -349,15 +346,15 @@ awIDAQAB
349
346
  AUTHENTICATE: "authenticate",
350
347
  CODE: "code",
351
348
  LOGOUT: "logout"
352
- }, he = crypto, Be = (e) => e instanceof CryptoKey, X = new TextEncoder(), B = new TextDecoder();
353
- function xt(...e) {
349
+ }, he = crypto, qe = (e) => e instanceof CryptoKey, X = new TextEncoder(), B = new TextDecoder();
350
+ function Gt(...e) {
354
351
  const t = e.reduce((a, { length: s }) => a + s, 0), n = new Uint8Array(t);
355
352
  let r = 0;
356
353
  for (const a of e)
357
354
  n.set(a, r), r += a.length;
358
355
  return n;
359
356
  }
360
- const Mt = (e) => {
357
+ const Jt = (e) => {
361
358
  const t = atob(e), n = new Uint8Array(t.length);
362
359
  for (let r = 0; r < t.length; r++)
363
360
  n[r] = t.charCodeAt(r);
@@ -366,7 +363,7 @@ const Mt = (e) => {
366
363
  let t = e;
367
364
  t instanceof Uint8Array && (t = B.decode(t)), t = t.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "");
368
365
  try {
369
- return Mt(t);
366
+ return Jt(t);
370
367
  } catch {
371
368
  throw new TypeError("The input to be decoded is not correctly encoded.");
372
369
  }
@@ -386,7 +383,7 @@ let D = class extends Error {
386
383
  constructor(t, n, r = "unspecified", a = "unspecified") {
387
384
  super(t), this.code = "ERR_JWT_CLAIM_VALIDATION_FAILED", this.claim = r, this.reason = a, this.payload = n;
388
385
  }
389
- }, Ce = class extends D {
386
+ }, Pe = class extends D {
390
387
  static get code() {
391
388
  return "ERR_JWT_EXPIRED";
392
389
  }
@@ -394,7 +391,7 @@ let D = class extends Error {
394
391
  super(t), this.code = "ERR_JWT_EXPIRED", this.claim = r, this.reason = a, this.payload = n;
395
392
  }
396
393
  };
397
- class Gt extends D {
394
+ class Yt extends D {
398
395
  constructor() {
399
396
  super(...arguments), this.code = "ERR_JOSE_ALG_NOT_ALLOWED";
400
397
  }
@@ -410,7 +407,7 @@ let O = class extends D {
410
407
  return "ERR_JOSE_NOT_SUPPORTED";
411
408
  }
412
409
  };
413
- class A extends D {
410
+ class S extends D {
414
411
  constructor() {
415
412
  super(...arguments), this.code = "ERR_JWS_INVALID";
416
413
  }
@@ -418,7 +415,7 @@ class A extends D {
418
415
  return "ERR_JWS_INVALID";
419
416
  }
420
417
  }
421
- let C = class extends D {
418
+ let P = class extends D {
422
419
  constructor() {
423
420
  super(...arguments), this.code = "ERR_JWT_INVALID";
424
421
  }
@@ -426,7 +423,7 @@ let C = class extends D {
426
423
  return "ERR_JWT_INVALID";
427
424
  }
428
425
  };
429
- class Jt extends D {
426
+ class Vt extends D {
430
427
  constructor() {
431
428
  super(...arguments), this.code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED", this.message = "signature verification failed";
432
429
  }
@@ -434,7 +431,7 @@ class Jt extends D {
434
431
  return "ERR_JWS_SIGNATURE_VERIFICATION_FAILED";
435
432
  }
436
433
  }
437
- function k(e, t = "algorithm.name") {
434
+ function C(e, t = "algorithm.name") {
438
435
  return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`);
439
436
  }
440
437
  function Z(e, t) {
@@ -443,7 +440,7 @@ function Z(e, t) {
443
440
  function ye(e) {
444
441
  return parseInt(e.name.slice(4), 10);
445
442
  }
446
- function Yt(e) {
443
+ function jt(e) {
447
444
  switch (e) {
448
445
  case "ES256":
449
446
  return "P-256";
@@ -455,7 +452,7 @@ function Yt(e) {
455
452
  throw new Error("unreachable");
456
453
  }
457
454
  }
458
- function Vt(e, t) {
455
+ function Ft(e, t) {
459
456
  if (t.length && !t.some((n) => e.usages.includes(n))) {
460
457
  let n = "CryptoKey does not support this operation, its usages must include ";
461
458
  if (t.length > 2) {
@@ -465,59 +462,59 @@ function Vt(e, t) {
465
462
  throw new TypeError(n);
466
463
  }
467
464
  }
468
- function jt(e, t, ...n) {
465
+ function Bt(e, t, ...n) {
469
466
  switch (t) {
470
467
  case "HS256":
471
468
  case "HS384":
472
469
  case "HS512": {
473
470
  if (!Z(e.algorithm, "HMAC"))
474
- throw k("HMAC");
471
+ throw C("HMAC");
475
472
  const r = parseInt(t.slice(2), 10);
476
473
  if (ye(e.algorithm.hash) !== r)
477
- throw k(`SHA-${r}`, "algorithm.hash");
474
+ throw C(`SHA-${r}`, "algorithm.hash");
478
475
  break;
479
476
  }
480
477
  case "RS256":
481
478
  case "RS384":
482
479
  case "RS512": {
483
480
  if (!Z(e.algorithm, "RSASSA-PKCS1-v1_5"))
484
- throw k("RSASSA-PKCS1-v1_5");
481
+ throw C("RSASSA-PKCS1-v1_5");
485
482
  const r = parseInt(t.slice(2), 10);
486
483
  if (ye(e.algorithm.hash) !== r)
487
- throw k(`SHA-${r}`, "algorithm.hash");
484
+ throw C(`SHA-${r}`, "algorithm.hash");
488
485
  break;
489
486
  }
490
487
  case "PS256":
491
488
  case "PS384":
492
489
  case "PS512": {
493
490
  if (!Z(e.algorithm, "RSA-PSS"))
494
- throw k("RSA-PSS");
491
+ throw C("RSA-PSS");
495
492
  const r = parseInt(t.slice(2), 10);
496
493
  if (ye(e.algorithm.hash) !== r)
497
- throw k(`SHA-${r}`, "algorithm.hash");
494
+ throw C(`SHA-${r}`, "algorithm.hash");
498
495
  break;
499
496
  }
500
497
  case "EdDSA": {
501
498
  if (e.algorithm.name !== "Ed25519" && e.algorithm.name !== "Ed448")
502
- throw k("Ed25519 or Ed448");
499
+ throw C("Ed25519 or Ed448");
503
500
  break;
504
501
  }
505
502
  case "ES256":
506
503
  case "ES384":
507
504
  case "ES512": {
508
505
  if (!Z(e.algorithm, "ECDSA"))
509
- throw k("ECDSA");
510
- const r = Yt(t);
506
+ throw C("ECDSA");
507
+ const r = jt(t);
511
508
  if (e.algorithm.namedCurve !== r)
512
- throw k(r, "algorithm.namedCurve");
509
+ throw C(r, "algorithm.namedCurve");
513
510
  break;
514
511
  }
515
512
  default:
516
513
  throw new TypeError("CryptoKey does not support this operation");
517
514
  }
518
- Vt(e, n);
515
+ Ft(e, n);
519
516
  }
520
- function qe(e, t, ...n) {
517
+ function ze(e, t, ...n) {
521
518
  var r;
522
519
  if (n.length > 2) {
523
520
  const a = n.pop();
@@ -525,11 +522,11 @@ function qe(e, t, ...n) {
525
522
  } else n.length === 2 ? e += `one of type ${n[0]} or ${n[1]}.` : e += `of type ${n[0]}.`;
526
523
  return t == null ? e += ` Received ${t}` : typeof t == "function" && t.name ? e += ` Received function ${t.name}` : typeof t == "object" && t != null && (r = t.constructor) != null && r.name && (e += ` Received an instance of ${t.constructor.name}`), e;
527
524
  }
528
- const Pe = (e, ...t) => qe("Key must be ", e, ...t);
529
- function ze(e, t, ...n) {
530
- return qe(`Key for the ${e} algorithm must be `, t, ...n);
525
+ const ke = (e, ...t) => ze("Key must be ", e, ...t);
526
+ function Qe(e, t, ...n) {
527
+ return ze(`Key for the ${e} algorithm must be `, t, ...n);
531
528
  }
532
- const Qe = (e) => Be(e) ? !0 : (e == null ? void 0 : e[Symbol.toStringTag]) === "KeyObject", ce = ["CryptoKey"], Ft = (...e) => {
529
+ const Xe = (e) => qe(e) ? !0 : e?.[Symbol.toStringTag] === "KeyObject", ce = ["CryptoKey"], qt = (...e) => {
533
530
  const t = e.filter(Boolean);
534
531
  if (t.length === 0 || t.length === 1)
535
532
  return !0;
@@ -548,11 +545,11 @@ const Qe = (e) => Be(e) ? !0 : (e == null ? void 0 : e[Symbol.toStringTag]) ===
548
545
  }
549
546
  return !0;
550
547
  };
551
- function Bt(e) {
548
+ function zt(e) {
552
549
  return typeof e == "object" && e !== null;
553
550
  }
554
551
  function ue(e) {
555
- if (!Bt(e) || Object.prototype.toString.call(e) !== "[object Object]")
552
+ if (!zt(e) || Object.prototype.toString.call(e) !== "[object Object]")
556
553
  return !1;
557
554
  if (Object.getPrototypeOf(e) === null)
558
555
  return !0;
@@ -561,14 +558,14 @@ function ue(e) {
561
558
  t = Object.getPrototypeOf(t);
562
559
  return Object.getPrototypeOf(e) === t;
563
560
  }
564
- const qt = (e, t) => {
561
+ const Qt = (e, t) => {
565
562
  if (e.startsWith("RS") || e.startsWith("PS")) {
566
563
  const { modulusLength: n } = t.algorithm;
567
564
  if (typeof n != "number" || n < 2048)
568
565
  throw new TypeError(`${e} requires key modulusLength to be 2048 bits or larger`);
569
566
  }
570
567
  };
571
- function zt(e) {
568
+ function Xt(e) {
572
569
  let t, n;
573
570
  switch (e.kty) {
574
571
  case "RSA": {
@@ -640,64 +637,64 @@ function zt(e) {
640
637
  }
641
638
  return { algorithm: t, keyUsages: n };
642
639
  }
643
- const Qt = async (e) => {
640
+ const Zt = async (e) => {
644
641
  if (!e.alg)
645
642
  throw new TypeError('"alg" argument is required when "jwk.alg" is not present');
646
- const { algorithm: t, keyUsages: n } = zt(e), r = [
643
+ const { algorithm: t, keyUsages: n } = Xt(e), r = [
647
644
  t,
648
645
  e.ext ?? !1,
649
646
  e.key_ops ?? n
650
647
  ], a = { ...e };
651
648
  return delete a.alg, delete a.use, he.subtle.importKey("jwk", a, ...r);
652
- }, Xe = (e) => j(e);
649
+ }, Ze = (e) => j(e);
653
650
  let ge, me;
654
- const Ze = (e) => (e == null ? void 0 : e[Symbol.toStringTag]) === "KeyObject", et = async (e, t, n, r) => {
651
+ const et = (e) => e?.[Symbol.toStringTag] === "KeyObject", tt = async (e, t, n, r) => {
655
652
  let a = e.get(t);
656
653
  if (a != null && a[r])
657
654
  return a[r];
658
- const s = await Qt({ ...n, alg: r });
655
+ const s = await Zt({ ...n, alg: r });
659
656
  return a ? a[r] = s : e.set(t, { [r]: s }), s;
660
- }, Xt = (e, t) => {
661
- if (Ze(e)) {
657
+ }, en = (e, t) => {
658
+ if (et(e)) {
662
659
  let n = e.export({ format: "jwk" });
663
- return delete n.d, delete n.dp, delete n.dq, delete n.p, delete n.q, delete n.qi, n.k ? Xe(n.k) : (me || (me = /* @__PURE__ */ new WeakMap()), et(me, e, n, t));
660
+ return delete n.d, delete n.dp, delete n.dq, delete n.p, delete n.q, delete n.qi, n.k ? Ze(n.k) : (me || (me = /* @__PURE__ */ new WeakMap()), tt(me, e, n, t));
664
661
  }
665
662
  return e;
666
- }, Zt = (e, t) => {
667
- if (Ze(e)) {
663
+ }, tn = (e, t) => {
664
+ if (et(e)) {
668
665
  let n = e.export({ format: "jwk" });
669
- return n.k ? Xe(n.k) : (ge || (ge = /* @__PURE__ */ new WeakMap()), et(ge, e, n, t));
666
+ return n.k ? Ze(n.k) : (ge || (ge = /* @__PURE__ */ new WeakMap()), tt(ge, e, n, t));
670
667
  }
671
668
  return e;
672
- }, en = { normalizePublicKey: Xt, normalizePrivateKey: Zt }, P = (e, t, n = 0) => {
669
+ }, nn = { normalizePublicKey: en, normalizePrivateKey: tn }, k = (e, t, n = 0) => {
673
670
  n === 0 && (t.unshift(t.length), t.unshift(6));
674
671
  const r = e.indexOf(t[0], n);
675
672
  if (r === -1)
676
673
  return !1;
677
674
  const a = e.subarray(r, r + t.length);
678
- return a.length !== t.length ? !1 : a.every((s, o) => s === t[o]) || P(e, t, r + 1);
675
+ return a.length !== t.length ? !1 : a.every((s, o) => s === t[o]) || k(e, t, r + 1);
679
676
  }, Oe = (e) => {
680
677
  switch (!0) {
681
- case P(e, [42, 134, 72, 206, 61, 3, 1, 7]):
678
+ case k(e, [42, 134, 72, 206, 61, 3, 1, 7]):
682
679
  return "P-256";
683
- case P(e, [43, 129, 4, 0, 34]):
680
+ case k(e, [43, 129, 4, 0, 34]):
684
681
  return "P-384";
685
- case P(e, [43, 129, 4, 0, 35]):
682
+ case k(e, [43, 129, 4, 0, 35]):
686
683
  return "P-521";
687
- case P(e, [43, 101, 110]):
684
+ case k(e, [43, 101, 110]):
688
685
  return "X25519";
689
- case P(e, [43, 101, 111]):
686
+ case k(e, [43, 101, 111]):
690
687
  return "X448";
691
- case P(e, [43, 101, 112]):
688
+ case k(e, [43, 101, 112]):
692
689
  return "Ed25519";
693
- case P(e, [43, 101, 113]):
690
+ case k(e, [43, 101, 113]):
694
691
  return "Ed448";
695
692
  default:
696
693
  throw new O("Invalid or unsupported EC Key Curve or OKP Key Sub Type");
697
694
  }
698
- }, tn = async (e, t, n, r, a) => {
695
+ }, rn = async (e, t, n, r, a) => {
699
696
  let s, o;
700
- const i = new Uint8Array(atob(n.replace(e, "")).split("").map((l) => l.charCodeAt(0)));
697
+ const i = new Uint8Array(atob(n.replace(e, "")).split("").map((c) => c.charCodeAt(0)));
701
698
  switch (r) {
702
699
  case "PS256":
703
700
  case "PS384":
@@ -731,8 +728,8 @@ const Ze = (e) => (e == null ? void 0 : e[Symbol.toStringTag]) === "KeyObject",
731
728
  case "ECDH-ES+A128KW":
732
729
  case "ECDH-ES+A192KW":
733
730
  case "ECDH-ES+A256KW": {
734
- const l = Oe(i);
735
- s = l.startsWith("P-") ? { name: "ECDH", namedCurve: l } : { name: l }, o = [];
731
+ const c = Oe(i);
732
+ s = c.startsWith("P-") ? { name: "ECDH", namedCurve: c } : { name: c }, o = [];
736
733
  break;
737
734
  }
738
735
  case "EdDSA":
@@ -742,33 +739,33 @@ const Ze = (e) => (e == null ? void 0 : e[Symbol.toStringTag]) === "KeyObject",
742
739
  throw new O('Invalid or unsupported "alg" (Algorithm) value');
743
740
  }
744
741
  return he.subtle.importKey(t, i, s, !1, o);
745
- }, nn = (e, t, n) => tn(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g, "spki", e, t);
746
- async function rn(e, t, n) {
742
+ }, an = (e, t, n) => rn(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g, "spki", e, t);
743
+ async function on(e, t, n) {
747
744
  if (e.indexOf("-----BEGIN PUBLIC KEY-----") !== 0)
748
745
  throw new TypeError('"spki" must be SPKI formatted string');
749
- return nn(e, t);
746
+ return an(e, t);
750
747
  }
751
- const se = (e) => e == null ? void 0 : e[Symbol.toStringTag], an = (e, t) => {
748
+ const se = (e) => e?.[Symbol.toStringTag], sn = (e, t) => {
752
749
  if (!(t instanceof Uint8Array)) {
753
- if (!Qe(t))
754
- throw new TypeError(ze(e, t, ...ce, "Uint8Array"));
750
+ if (!Xe(t))
751
+ throw new TypeError(Qe(e, t, ...ce, "Uint8Array"));
755
752
  if (t.type !== "secret")
756
753
  throw new TypeError(`${se(t)} instances for symmetric algorithms must be of type "secret"`);
757
754
  }
758
- }, on = (e, t, n) => {
759
- if (!Qe(t))
760
- throw new TypeError(ze(e, t, ...ce));
755
+ }, cn = (e, t, n) => {
756
+ if (!Xe(t))
757
+ throw new TypeError(Qe(e, t, ...ce));
761
758
  if (t.type === "secret")
762
759
  throw new TypeError(`${se(t)} instances for asymmetric algorithms must not be of type "secret"`);
763
760
  if (t.algorithm && n === "verify" && t.type === "private")
764
761
  throw new TypeError(`${se(t)} instances for asymmetric algorithm verifying must be of type "public"`);
765
762
  if (t.algorithm && n === "encrypt" && t.type === "private")
766
763
  throw new TypeError(`${se(t)} instances for asymmetric algorithm encryption must be of type "public"`);
767
- }, sn = (e, t, n) => {
768
- e.startsWith("HS") || e === "dir" || e.startsWith("PBES2") || /^A\d{3}(?:GCM)?KW$/.test(e) ? an(e, t) : on(e, t, n);
764
+ }, un = (e, t, n) => {
765
+ e.startsWith("HS") || e === "dir" || e.startsWith("PBES2") || /^A\d{3}(?:GCM)?KW$/.test(e) ? sn(e, t) : cn(e, t, n);
769
766
  };
770
- function cn(e, t, n, r, a) {
771
- if (a.crit !== void 0 && (r == null ? void 0 : r.crit) === void 0)
767
+ function ln(e, t, n, r, a) {
768
+ if (a.crit !== void 0 && r?.crit === void 0)
772
769
  throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');
773
770
  if (!r || r.crit === void 0)
774
771
  return /* @__PURE__ */ new Set();
@@ -786,13 +783,13 @@ function cn(e, t, n, r, a) {
786
783
  }
787
784
  return new Set(r.crit);
788
785
  }
789
- const un = (e, t) => {
786
+ const dn = (e, t) => {
790
787
  if (t !== void 0 && (!Array.isArray(t) || t.some((n) => typeof n != "string")))
791
788
  throw new TypeError(`"${e}" option must be an array of strings`);
792
789
  if (t)
793
790
  return new Set(t);
794
791
  };
795
- function ln(e, t) {
792
+ function hn(e, t) {
796
793
  const n = `SHA-${e.slice(-3)}`;
797
794
  switch (e) {
798
795
  case "HS256":
@@ -817,100 +814,100 @@ function ln(e, t) {
817
814
  throw new O(`alg ${e} is not supported either by JOSE or your javascript runtime`);
818
815
  }
819
816
  }
820
- async function dn(e, t, n) {
821
- if (t = await en.normalizePublicKey(t, e), Be(t))
822
- return jt(t, e, n), t;
817
+ async function pn(e, t, n) {
818
+ if (t = await nn.normalizePublicKey(t, e), qe(t))
819
+ return Bt(t, e, n), t;
823
820
  if (t instanceof Uint8Array) {
824
821
  if (!e.startsWith("HS"))
825
- throw new TypeError(Pe(t, ...ce));
822
+ throw new TypeError(ke(t, ...ce));
826
823
  return he.subtle.importKey("raw", t, { hash: `SHA-${e.slice(-3)}`, name: "HMAC" }, !1, [n]);
827
824
  }
828
- throw new TypeError(Pe(t, ...ce, "Uint8Array"));
825
+ throw new TypeError(ke(t, ...ce, "Uint8Array"));
829
826
  }
830
- const hn = async (e, t, n, r) => {
831
- const a = await dn(e, t, "verify");
832
- qt(e, a);
833
- const s = ln(e, a.algorithm);
827
+ const fn = async (e, t, n, r) => {
828
+ const a = await pn(e, t, "verify");
829
+ Qt(e, a);
830
+ const s = hn(e, a.algorithm);
834
831
  try {
835
832
  return await he.subtle.verify(s, a, n, r);
836
833
  } catch {
837
834
  return !1;
838
835
  }
839
836
  };
840
- async function pn(e, t, n) {
837
+ async function yn(e, t, n) {
841
838
  if (!ue(e))
842
- throw new A("Flattened JWS must be an object");
839
+ throw new S("Flattened JWS must be an object");
843
840
  if (e.protected === void 0 && e.header === void 0)
844
- throw new A('Flattened JWS must have either of the "protected" or "header" members');
841
+ throw new S('Flattened JWS must have either of the "protected" or "header" members');
845
842
  if (e.protected !== void 0 && typeof e.protected != "string")
846
- throw new A("JWS Protected Header incorrect type");
843
+ throw new S("JWS Protected Header incorrect type");
847
844
  if (e.payload === void 0)
848
- throw new A("JWS Payload missing");
845
+ throw new S("JWS Payload missing");
849
846
  if (typeof e.signature != "string")
850
- throw new A("JWS Signature missing or incorrect type");
847
+ throw new S("JWS Signature missing or incorrect type");
851
848
  if (e.header !== void 0 && !ue(e.header))
852
- throw new A("JWS Unprotected Header incorrect type");
849
+ throw new S("JWS Unprotected Header incorrect type");
853
850
  let r = {};
854
851
  if (e.protected)
855
852
  try {
856
- const d = j(e.protected);
857
- r = JSON.parse(B.decode(d));
853
+ const u = j(e.protected);
854
+ r = JSON.parse(B.decode(u));
858
855
  } catch {
859
- throw new A("JWS Protected Header is invalid");
856
+ throw new S("JWS Protected Header is invalid");
860
857
  }
861
- if (!Ft(r, e.header))
862
- throw new A("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
858
+ if (!qt(r, e.header))
859
+ throw new S("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
863
860
  const a = {
864
861
  ...r,
865
862
  ...e.header
866
- }, s = cn(A, /* @__PURE__ */ new Map([["b64", !0]]), n == null ? void 0 : n.crit, r, a);
863
+ }, s = ln(S, /* @__PURE__ */ new Map([["b64", !0]]), n?.crit, r, a);
867
864
  let o = !0;
868
865
  if (s.has("b64") && (o = r.b64, typeof o != "boolean"))
869
- throw new A('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
866
+ throw new S('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
870
867
  const { alg: i } = a;
871
868
  if (typeof i != "string" || !i)
872
- throw new A('JWS "alg" (Algorithm) Header Parameter missing or invalid');
873
- const l = n && un("algorithms", n.algorithms);
874
- if (l && !l.has(i))
875
- throw new Gt('"alg" (Algorithm) Header Parameter value not allowed');
869
+ throw new S('JWS "alg" (Algorithm) Header Parameter missing or invalid');
870
+ const c = n && dn("algorithms", n.algorithms);
871
+ if (c && !c.has(i))
872
+ throw new Yt('"alg" (Algorithm) Header Parameter value not allowed');
876
873
  if (o) {
877
874
  if (typeof e.payload != "string")
878
- throw new A("JWS Payload must be a string");
875
+ throw new S("JWS Payload must be a string");
879
876
  } else if (typeof e.payload != "string" && !(e.payload instanceof Uint8Array))
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), sn(i, t, "verify");
883
- const h = xt(X.encode(e.protected ?? ""), X.encode("."), typeof e.payload == "string" ? X.encode(e.payload) : e.payload);
884
- let p;
877
+ throw new S("JWS Payload must be a string or an Uint8Array instance");
878
+ let g = !1;
879
+ typeof t == "function" && (t = await t(r, e), g = !0), un(i, t, "verify");
880
+ const l = Gt(X.encode(e.protected ?? ""), X.encode("."), typeof e.payload == "string" ? X.encode(e.payload) : e.payload);
881
+ let h;
885
882
  try {
886
- p = j(e.signature);
883
+ h = j(e.signature);
887
884
  } catch {
888
- throw new A("Failed to base64url decode the signature");
885
+ throw new S("Failed to base64url decode the signature");
889
886
  }
890
- if (!await hn(i, t, p, h))
891
- throw new Jt();
892
- let m;
887
+ if (!await fn(i, t, h, l))
888
+ throw new Vt();
889
+ let y;
893
890
  if (o)
894
891
  try {
895
- m = j(e.payload);
892
+ y = j(e.payload);
896
893
  } catch {
897
- throw new A("Failed to base64url decode the payload");
894
+ throw new S("Failed to base64url decode the payload");
898
895
  }
899
- else typeof e.payload == "string" ? m = X.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;
896
+ else typeof e.payload == "string" ? y = X.encode(e.payload) : y = e.payload;
897
+ const p = { payload: y };
898
+ return e.protected !== void 0 && (p.protectedHeader = r), e.header !== void 0 && (p.unprotectedHeader = e.header), g ? { ...p, key: t } : p;
902
899
  }
903
- async function fn(e, t, n) {
900
+ async function gn(e, t, n) {
904
901
  if (e instanceof Uint8Array && (e = B.decode(e)), typeof e != "string")
905
- throw new A("Compact JWS must be a string or Uint8Array");
902
+ throw new S("Compact JWS must be a string or Uint8Array");
906
903
  const { 0: r, 1: a, 2: s, length: o } = e.split(".");
907
904
  if (o !== 3)
908
- throw new A("Invalid Compact JWS");
909
- const i = await pn({ 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;
905
+ throw new S("Invalid Compact JWS");
906
+ const i = await yn({ payload: a, protected: r, signature: s }, t, n), c = { payload: i.payload, protectedHeader: i.protectedHeader };
907
+ return typeof t == "function" ? { ...c, key: i.key } : c;
911
908
  }
912
- const yn = (e) => Math.floor(e.getTime() / 1e3), tt = 60, nt = tt * 60, Re = nt * 24, gn = Re * 7, mn = Re * 365.25, wn = /^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i, Ne = (e) => {
913
- const t = wn.exec(e);
909
+ const mn = (e) => Math.floor(e.getTime() / 1e3), nt = 60, rt = nt * 60, Re = rt * 24, wn = Re * 7, En = Re * 365.25, Sn = /^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i, Ne = (e) => {
910
+ const t = Sn.exec(e);
914
911
  if (!t || t[4] && t[1])
915
912
  throw new TypeError("Invalid time period format");
916
913
  const n = parseFloat(t[2]), r = t[3].toLowerCase();
@@ -928,14 +925,14 @@ const yn = (e) => Math.floor(e.getTime() / 1e3), tt = 60, nt = tt * 60, Re = nt
928
925
  case "min":
929
926
  case "mins":
930
927
  case "m":
931
- a = Math.round(n * tt);
928
+ a = Math.round(n * nt);
932
929
  break;
933
930
  case "hour":
934
931
  case "hours":
935
932
  case "hr":
936
933
  case "hrs":
937
934
  case "h":
938
- a = Math.round(n * nt);
935
+ a = Math.round(n * rt);
939
936
  break;
940
937
  case "day":
941
938
  case "days":
@@ -945,135 +942,135 @@ const yn = (e) => Math.floor(e.getTime() / 1e3), tt = 60, nt = tt * 60, Re = nt
945
942
  case "week":
946
943
  case "weeks":
947
944
  case "w":
948
- a = Math.round(n * gn);
945
+ a = Math.round(n * wn);
949
946
  break;
950
947
  default:
951
- a = Math.round(n * mn);
948
+ a = Math.round(n * En);
952
949
  break;
953
950
  }
954
951
  return t[1] === "-" || t[4] === "ago" ? -a : a;
955
- }, De = (e) => e.toLowerCase().replace(/^application\//, ""), En = (e, t) => typeof e == "string" ? t.includes(e) : Array.isArray(e) ? t.some(Set.prototype.has.bind(new Set(e))) : !1, Sn = (e, t, n = {}) => {
952
+ }, De = (e) => e.toLowerCase().replace(/^application\//, ""), An = (e, t) => typeof e == "string" ? t.includes(e) : Array.isArray(e) ? t.some(Set.prototype.has.bind(new Set(e))) : !1, Tn = (e, t, n = {}) => {
956
953
  let r;
957
954
  try {
958
955
  r = JSON.parse(B.decode(t));
959
956
  } catch {
960
957
  }
961
958
  if (!ue(r))
962
- throw new C("JWT Claims Set must be a top-level JSON object");
959
+ throw new P("JWT Claims Set must be a top-level JSON object");
963
960
  const { typ: a } = n;
964
961
  if (a && (typeof e.typ != "string" || De(e.typ) !== De(a)))
965
962
  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()))
969
- if (!(d in r))
970
- throw new _(`missing required "${d}" claim`, r, d, "missing");
963
+ const { requiredClaims: s = [], issuer: o, subject: i, audience: c, maxTokenAge: g } = n, l = [...s];
964
+ g !== void 0 && l.push("iat"), c !== void 0 && l.push("aud"), i !== void 0 && l.push("sub"), o !== void 0 && l.push("iss");
965
+ for (const u of new Set(l.reverse()))
966
+ if (!(u in r))
967
+ throw new _(`missing required "${u}" claim`, r, u, "missing");
971
968
  if (o && !(Array.isArray(o) ? o : [o]).includes(r.iss))
972
969
  throw new _('unexpected "iss" claim value', r, "iss", "check_failed");
973
970
  if (i && r.sub !== i)
974
971
  throw new _('unexpected "sub" claim value', r, "sub", "check_failed");
975
- if (l && !En(r.aud, typeof l == "string" ? [l] : l))
972
+ if (c && !An(r.aud, typeof c == "string" ? [c] : c))
976
973
  throw new _('unexpected "aud" claim value', r, "aud", "check_failed");
977
- let p;
974
+ let h;
978
975
  switch (typeof n.clockTolerance) {
979
976
  case "string":
980
- p = Ne(n.clockTolerance);
977
+ h = Ne(n.clockTolerance);
981
978
  break;
982
979
  case "number":
983
- p = n.clockTolerance;
980
+ h = n.clockTolerance;
984
981
  break;
985
982
  case "undefined":
986
- p = 0;
983
+ h = 0;
987
984
  break;
988
985
  default:
989
986
  throw new TypeError("Invalid clockTolerance option type");
990
987
  }
991
- const { currentDate: m } = n, u = yn(m || /* @__PURE__ */ new Date());
992
- if ((r.iat !== void 0 || y) && typeof r.iat != "number")
988
+ const { currentDate: y } = n, p = mn(y || /* @__PURE__ */ new Date());
989
+ if ((r.iat !== void 0 || g) && typeof r.iat != "number")
993
990
  throw new _('"iat" claim must be a number', r, "iat", "invalid");
994
991
  if (r.nbf !== void 0) {
995
992
  if (typeof r.nbf != "number")
996
993
  throw new _('"nbf" claim must be a number', r, "nbf", "invalid");
997
- if (r.nbf > u + p)
994
+ if (r.nbf > p + h)
998
995
  throw new _('"nbf" claim timestamp check failed', r, "nbf", "check_failed");
999
996
  }
1000
997
  if (r.exp !== void 0) {
1001
998
  if (typeof r.exp != "number")
1002
999
  throw new _('"exp" claim must be a number', r, "exp", "invalid");
1003
- if (r.exp <= u - p)
1004
- throw new Ce('"exp" claim timestamp check failed', r, "exp", "check_failed");
1005
- }
1006
- if (y) {
1007
- const d = u - r.iat, g = typeof y == "number" ? y : Ne(y);
1008
- if (d - p > g)
1009
- throw new Ce('"iat" claim timestamp check failed (too far in the past)', r, "iat", "check_failed");
1010
- if (d < 0 - p)
1000
+ if (r.exp <= p - h)
1001
+ throw new Pe('"exp" claim timestamp check failed', r, "exp", "check_failed");
1002
+ }
1003
+ if (g) {
1004
+ const u = p - r.iat, m = typeof g == "number" ? g : Ne(g);
1005
+ if (u - h > m)
1006
+ throw new Pe('"iat" claim timestamp check failed (too far in the past)', r, "iat", "check_failed");
1007
+ if (u < 0 - h)
1011
1008
  throw new _('"iat" claim timestamp check failed (it should be in the past)', r, "iat", "check_failed");
1012
1009
  }
1013
1010
  return r;
1014
1011
  };
1015
- async function An(e, t, n) {
1012
+ async function Rn(e, t, n) {
1016
1013
  var r;
1017
- const a = await fn(e, t, n);
1014
+ const a = await gn(e, t, n);
1018
1015
  if ((r = a.protectedHeader.crit) != null && r.includes("b64") && a.protectedHeader.b64 === !1)
1019
- throw new C("JWTs MUST NOT use unencoded payload");
1020
- const s = { payload: Sn(a.protectedHeader, a.payload, n), protectedHeader: a.protectedHeader };
1016
+ throw new P("JWTs MUST NOT use unencoded payload");
1017
+ const s = { payload: Tn(a.protectedHeader, a.payload, n), protectedHeader: a.protectedHeader };
1021
1018
  return typeof t == "function" ? { ...s, key: a.key } : s;
1022
1019
  }
1023
- const Tn = j;
1024
- function Rn(e) {
1020
+ const bn = j;
1021
+ function In(e) {
1025
1022
  if (typeof e != "string")
1026
- throw new C("JWTs must use Compact JWS serialization, JWT must be a string");
1023
+ throw new P("JWTs must use Compact JWS serialization, JWT must be a string");
1027
1024
  const { 1: t, length: n } = e.split(".");
1028
1025
  if (n === 5)
1029
- throw new C("Only JWTs using Compact JWS serialization can be decoded");
1026
+ throw new P("Only JWTs using Compact JWS serialization can be decoded");
1030
1027
  if (n !== 3)
1031
- throw new C("Invalid JWT");
1028
+ throw new P("Invalid JWT");
1032
1029
  if (!t)
1033
- throw new C("JWTs must contain a payload");
1030
+ throw new P("JWTs must contain a payload");
1034
1031
  let r;
1035
1032
  try {
1036
- r = Tn(t);
1033
+ r = bn(t);
1037
1034
  } catch {
1038
- throw new C("Failed to base64url decode the payload");
1035
+ throw new P("Failed to base64url decode the payload");
1039
1036
  }
1040
1037
  let a;
1041
1038
  try {
1042
1039
  a = JSON.parse(B.decode(r));
1043
1040
  } catch {
1044
- throw new C("Failed to parse the decoded payload as JSON");
1041
+ throw new P("Failed to parse the decoded payload as JSON");
1045
1042
  }
1046
1043
  if (!ue(a))
1047
- throw new C("Invalid JWT Claims Set");
1044
+ throw new P("Invalid JWT Claims Set");
1048
1045
  return a;
1049
1046
  }
1050
1047
  const M = async (e) => {
1051
1048
  try {
1052
- const t = T.ALG, n = await rn(Wt, t);
1053
- return await An(e, n, {
1054
- issuer: T.ISSUER
1049
+ const t = A.ALG, n = await on(Mt, t);
1050
+ return await Rn(e, n, {
1051
+ issuer: A.ISSUER
1055
1052
  });
1056
1053
  } catch {
1057
1054
  return;
1058
1055
  }
1059
- }, bn = (e) => {
1056
+ }, _n = (e) => {
1060
1057
  try {
1061
- return Rn(e);
1058
+ return In(e);
1062
1059
  } catch {
1063
1060
  return;
1064
1061
  }
1065
1062
  };
1066
- var E = [];
1063
+ var w = [];
1067
1064
  for (var we = 0; we < 256; ++we)
1068
- E.push((we + 256).toString(16).slice(1));
1069
- function In(e, t = 0) {
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();
1065
+ w.push((we + 256).toString(16).slice(1));
1066
+ function vn(e, t = 0) {
1067
+ 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();
1071
1068
  }
1072
- var ee, _n = new Uint8Array(16);
1073
- function vn() {
1069
+ var ee, Cn = new Uint8Array(16);
1070
+ function Pn() {
1074
1071
  if (!ee && (ee = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !ee))
1075
1072
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
1076
- return ee(_n);
1073
+ return ee(Cn);
1077
1074
  }
1078
1075
  var kn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
1079
1076
  const Ue = {
@@ -1083,57 +1080,57 @@ function $e(e, t, n) {
1083
1080
  if (Ue.randomUUID && !t && !e)
1084
1081
  return Ue.randomUUID();
1085
1082
  e = e || {};
1086
- var r = e.random || (e.rng || vn)();
1087
- return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, In(r);
1083
+ var r = e.random || (e.rng || Pn)();
1084
+ return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, vn(r);
1088
1085
  }
1089
- const Ke = globalThis.crypto, Cn = (e) => `${$e()}${$e()}`.slice(0, e), Pn = (e) => btoa(
1086
+ const Ke = globalThis.crypto, On = (e) => `${$e()}${$e()}`.slice(0, e), Nn = (e) => btoa(
1090
1087
  [...new Uint8Array(e)].map((t) => String.fromCharCode(t)).join("")
1091
1088
  );
1092
- async function On(e) {
1089
+ async function Dn(e) {
1093
1090
  if (!Ke.subtle)
1094
1091
  throw new Error(
1095
1092
  "crypto.subtle is available only in secure contexts (HTTPS)."
1096
1093
  );
1097
1094
  const t = new TextEncoder().encode(e), n = await Ke.subtle.digest("SHA-256", t);
1098
- return Pn(n).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
1095
+ return Nn(n).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
1099
1096
  }
1100
- async function Nn(e) {
1101
- const n = Cn(43), r = await On(n);
1097
+ async function Un(e) {
1098
+ const n = On(43), r = await Dn(n);
1102
1099
  return {
1103
1100
  code_verifier: n,
1104
1101
  code_challenge: r
1105
1102
  };
1106
1103
  }
1107
- const Pr = async (e, t) => {
1104
+ const Dr = async (e, t) => {
1108
1105
  var n;
1109
1106
  const r = await M(e);
1110
- if (!r || !Array.isArray((n = r.payload) == null ? void 0 : n[T.SCOPES_KEY]))
1107
+ if (!r || !Array.isArray((n = r.payload) == null ? void 0 : n[A.SCOPES_KEY]))
1111
1108
  return !1;
1112
- const a = r.payload[T.SCOPES_KEY];
1109
+ const a = r.payload[A.SCOPES_KEY];
1113
1110
  return Array.isArray(t) ? t.every((s) => a.includes(s)) : Object.keys(t).some(
1114
1111
  (s) => t[s].every((o) => a.includes(o))
1115
1112
  );
1116
1113
  };
1117
- function rt(e, t) {
1114
+ function at(e, t) {
1118
1115
  window.dispatchEvent(new StorageEvent("storage", { key: e, newValue: t }));
1119
1116
  }
1120
1117
  const He = (e, t) => {
1121
1118
  const n = JSON.stringify(
1122
1119
  typeof t == "function" ? t() : t
1123
1120
  );
1124
- window.localStorage.setItem(e, n), rt(e, n);
1125
- }, Dn = (e) => {
1126
- window.localStorage.removeItem(e), rt(e, null);
1127
- }, Le = (e) => window.localStorage.getItem(e), Un = (e) => (window.addEventListener("storage", e), () => window.removeEventListener("storage", e));
1121
+ window.localStorage.setItem(e, n), at(e, n);
1122
+ }, $n = (e) => {
1123
+ window.localStorage.removeItem(e), at(e, null);
1124
+ }, Le = (e) => window.localStorage.getItem(e), Kn = (e) => (window.addEventListener("storage", e), () => window.removeEventListener("storage", e));
1128
1125
  function te({
1129
1126
  key: e,
1130
1127
  initialValue: t
1131
1128
  }) {
1132
- const n = kt(Un, () => Le(e)), r = x(
1129
+ const n = kt(Kn, () => Le(e)), r = x(
1133
1130
  (o) => {
1134
1131
  try {
1135
1132
  const i = typeof o == "function" ? o(JSON.parse(n)) : o;
1136
- i == null ? Dn(e) : He(e, i);
1133
+ i == null ? $n(e) : He(e, i);
1137
1134
  } catch (i) {
1138
1135
  console.warn(i);
1139
1136
  }
@@ -1152,29 +1149,33 @@ function te({
1152
1149
  }
1153
1150
  }, [e, t]), [n ? JSON.parse(n) : null, r, a, s];
1154
1151
  }
1155
- var S = [];
1152
+ var E = [];
1156
1153
  for (var Ee = 0; Ee < 256; ++Ee)
1157
- S.push((Ee + 256).toString(16).slice(1));
1158
- function $n(e, t = 0) {
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();
1154
+ E.push((Ee + 256).toString(16).slice(1));
1155
+ function Hn(e, t = 0) {
1156
+ 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();
1160
1157
  }
1161
- var ne, Kn = new Uint8Array(16);
1162
- function Hn() {
1158
+ var ne, Ln = new Uint8Array(16);
1159
+ function Wn() {
1163
1160
  if (!ne && (ne = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !ne))
1164
1161
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
1165
- return ne(Kn);
1162
+ return ne(Ln);
1166
1163
  }
1167
- var Ln = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
1164
+ var xn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
1168
1165
  const We = {
1169
- randomUUID: Ln
1166
+ randomUUID: xn
1170
1167
  };
1171
1168
  function Se(e, t, n) {
1172
1169
  if (We.randomUUID && !t && !e)
1173
1170
  return We.randomUUID();
1174
1171
  e = e || {};
1175
- var r = e.random || (e.rng || Hn)();
1176
- return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, $n(r);
1172
+ var r = e.random || (e.rng || Wn)();
1173
+ return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, Hn(r);
1177
1174
  }
1175
+ const $ = "Oops! It looks like your session has expired. For your security, please log in again to continue.", Mn = "Your session has been successfully terminated.", re = "Login failed. Please try again.", Gn = "Error getting access token, please re-authenticate.", Jn = "You forgot to wrap your component in <AuthProvider>.", le = {
1176
+ dev: "https://auth.gizmette.local.com:3003",
1177
+ prod: "https://mylogin.gizmette.com/auth"
1178
+ }, ae = "@@auth@@", Y = "LOADING", V = "LOGIN", ot = "LOGOUT", Yn = "success", xe = "failure";
1178
1179
  /*!
1179
1180
  @versini/ui-fingerprint v1.0.1
1180
1181
  © 2024 gizmette.com
@@ -1188,52 +1189,52 @@ try {
1188
1189
  });
1189
1190
  } catch {
1190
1191
  }
1191
- const Wn = (e) => Array.from(e).map((t) => t.toString(16).padStart(2, "0")).join(""), at = async (e) => {
1192
+ const Vn = (e) => Array.from(e).map((t) => t.toString(16).padStart(2, "0")).join(""), st = async (e) => {
1192
1193
  if (e === "")
1193
1194
  return "";
1194
1195
  const t = new TextEncoder().encode(e), n = await crypto.subtle.digest("SHA-256", t);
1195
1196
  return Array.from(new Uint8Array(n)).map((r) => r.toString(16).padStart(2, "0")).join("");
1196
1197
  };
1197
- function xe(e, t) {
1198
+ function Me(e, t) {
1198
1199
  return new Promise((n) => setTimeout(n, e, t));
1199
1200
  }
1200
- async function xn(e, t, n = 50) {
1201
+ async function jn(e, t, n = 50) {
1201
1202
  var r, a, s;
1202
1203
  const o = document;
1203
1204
  for (; !o.body; )
1204
- await xe(n);
1205
+ await Me(n);
1205
1206
  const i = o.createElement("iframe");
1206
1207
  try {
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);
1208
+ for (await new Promise((c, g) => {
1209
+ let l = !1;
1210
+ const h = () => {
1211
+ l = !0, c();
1212
+ }, y = (m) => {
1213
+ l = !0, g(m);
1213
1214
  };
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);
1217
- const d = () => {
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));
1215
+ i.onload = h, i.onerror = y;
1216
+ const { style: p } = i;
1217
+ p.setProperty("display", "block", "important"), p.position = "absolute", p.top = "0", p.left = "0", p.visibility = "hidden", i.src = "about:blank", o.body.appendChild(i);
1218
+ const u = () => {
1219
+ var m, T;
1220
+ l || (((T = (m = i.contentWindow) == null ? void 0 : m.document) == null ? void 0 : T.readyState) === "complete" ? h() : setTimeout(u, 10));
1220
1221
  };
1221
- d();
1222
+ u();
1222
1223
  }); !((a = (r = i.contentWindow) == null ? void 0 : r.document) != null && a.body); )
1223
- await xe(n);
1224
+ await Me(n);
1224
1225
  return await e(i, i.contentWindow);
1225
1226
  } finally {
1226
1227
  (s = i.parentNode) == null || s.removeChild(i);
1227
1228
  }
1228
1229
  }
1229
- const Mn = {
1230
+ const Fn = {
1230
1231
  audio: {
1231
1232
  sampleHash: "",
1232
1233
  oscillator: "",
1233
1234
  maxChannels: 0,
1234
1235
  channelCountMode: ""
1235
1236
  }
1236
- }, Gn = async (e) => new Promise((t) => {
1237
+ }, Bn = async (e) => new Promise((t) => {
1237
1238
  try {
1238
1239
  const n = new window.OfflineAudioContext(1, 5e3, 44100), r = n.createBufferSource(), a = n.createOscillator();
1239
1240
  a.frequency.value = 1e3;
@@ -1242,7 +1243,7 @@ const Mn = {
1242
1243
  const i = o.renderedBuffer.getChannelData(0);
1243
1244
  a.disconnect(), s.disconnect(), t({
1244
1245
  audio: {
1245
- sampleHash: Wn(i),
1246
+ sampleHash: Vn(i),
1246
1247
  oscillator: a.type,
1247
1248
  maxChannels: n.destination.maxChannelCount,
1248
1249
  channelCountMode: r.channelCountMode
@@ -1259,25 +1260,25 @@ const Mn = {
1259
1260
  }
1260
1261
  });
1261
1262
  }
1262
- }), ot = { browser: "" }, Jn = async (e) => typeof navigator > "u" ? ot : { browser: navigator.userAgent }, st = {
1263
+ }), it = { browser: "" }, qn = async (e) => typeof navigator > "u" ? it : { browser: navigator.userAgent }, ct = {
1263
1264
  canvas: {
1264
1265
  data: ""
1265
1266
  }
1266
- }, Yn = async (e) => {
1267
+ }, zn = async (e) => {
1267
1268
  try {
1268
1269
  const t = Array.from(
1269
1270
  { length: 3 },
1270
- () => Vn(300, 30)
1271
- ), n = Fn(t, 300, 30);
1271
+ () => Qn(300, 30)
1272
+ ), n = Zn(t, 300, 30);
1272
1273
  return {
1273
1274
  canvas: {
1274
- data: (await at(n.data.toString())).toString()
1275
+ data: (await st(n.data.toString())).toString()
1275
1276
  }
1276
1277
  };
1277
1278
  } catch {
1278
- return st;
1279
+ return ct;
1279
1280
  }
1280
- }, Vn = (e, t) => {
1281
+ }, Qn = (e, t) => {
1281
1282
  const n = document.createElement("canvas"), r = n.getContext("2d");
1282
1283
  if (!r)
1283
1284
  return new ImageData(1, 1);
@@ -1286,7 +1287,7 @@ const Mn = {
1286
1287
  a.addColorStop(0, "red"), a.addColorStop(1 / 6, "orange"), a.addColorStop(2 / 6, "yellow"), a.addColorStop(3 / 6, "green"), a.addColorStop(4 / 6, "blue"), a.addColorStop(5 / 6, "indigo"), a.addColorStop(1, "violet"), r.fillStyle = a, r.fillRect(0, 0, n.width, n.height);
1287
1288
  const s = "mmMwWLliI0O&1 - Les sanglots longs des violons de l'automne blessent mon coeur d'une langueur monotone";
1288
1289
  return r.font = "26.321px Arial", r.fillStyle = "black", r.fillText(s, -5, 15), r.fillStyle = "rgba(0, 0, 255, 0.5)", r.fillText(s, -3.3, 17.7), r.beginPath(), r.moveTo(0, 0), r.lineTo(n.width * 2 / 7, n.height), r.strokeStyle = "white", r.lineWidth = 2, r.stroke(), r.getImageData(0, 0, n.width, n.height);
1289
- }, jn = (e) => {
1290
+ }, Xn = (e) => {
1290
1291
  if (e.length === 0)
1291
1292
  return 0;
1292
1293
  const t = {};
@@ -1296,17 +1297,17 @@ const Mn = {
1296
1297
  for (const r in t)
1297
1298
  t[r] > t[n] && (n = parseInt(r, 10));
1298
1299
  return n;
1299
- }, Fn = (e, t, n) => {
1300
+ }, Zn = (e, t, n) => {
1300
1301
  const r = [];
1301
1302
  for (let o = 0; o < e[0].data.length; o++) {
1302
1303
  const i = [];
1303
- for (let l = 0; l < e.length; l++)
1304
- i.push(e[l].data[o]);
1305
- r.push(jn(i));
1304
+ for (let c = 0; c < e.length; c++)
1305
+ i.push(e[c].data[o]);
1306
+ r.push(Xn(i));
1306
1307
  }
1307
1308
  const a = r, s = new Uint8ClampedArray(a);
1308
1309
  return new ImageData(s, t, n);
1309
- }, Bn = [], qn = "mmMwWLliI0O&1", zn = "48px", $ = ["monospace", "sans-serif", "serif"], Me = [
1310
+ }, er = [], tr = "mmMwWLliI0O&1", nr = "48px", K = ["monospace", "sans-serif", "serif"], Ge = [
1310
1311
  "sans-serif-thin",
1311
1312
  "ARNO PRO",
1312
1313
  "Agency FB",
@@ -1344,44 +1345,44 @@ const Mn = {
1344
1345
  "TRAJAN PRO",
1345
1346
  "Univers CE 55 Medium",
1346
1347
  "ZWAdobeF"
1347
- ], Qn = async (e) => xn(async (t, { document: n }) => {
1348
+ ], rr = async (e) => jn(async (t, { document: n }) => {
1348
1349
  const r = n.body;
1349
- r.style.fontSize = zn;
1350
+ r.style.fontSize = nr;
1350
1351
  const a = n.createElement("div");
1351
1352
  a.style.setProperty("visibility", "hidden", "important");
1352
- const s = {}, o = {}, i = (d) => {
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 = qn, a.appendChild(g), g;
1355
- }, l = (d, g) => i(`'${d}',${g}`), y = () => $.map(i), h = () => {
1356
- const d = {};
1357
- for (const g of Me)
1358
- d[g] = $.map(
1359
- (R) => l(g, R)
1353
+ const s = {}, o = {}, i = (u) => {
1354
+ const m = n.createElement("span"), { style: T } = m;
1355
+ return T.position = "absolute", T.top = "0", T.left = "0", T.fontFamily = u, m.textContent = tr, a.appendChild(m), m;
1356
+ }, c = (u, m) => i(`'${u}',${m}`), g = () => K.map(i), l = () => {
1357
+ const u = {};
1358
+ for (const m of Ge)
1359
+ u[m] = K.map(
1360
+ (T) => c(m, T)
1360
1361
  );
1361
- return d;
1362
- }, p = (d) => $.some(
1363
- (g, R) => d[R].offsetWidth !== s[g] || d[R].offsetHeight !== o[g]
1364
- ), m = y(), u = h();
1362
+ return u;
1363
+ }, h = (u) => K.some(
1364
+ (m, T) => u[T].offsetWidth !== s[m] || u[T].offsetHeight !== o[m]
1365
+ ), y = g(), p = l();
1365
1366
  r.appendChild(a);
1366
- for (let d = 0; d < $.length; d++)
1367
- s[$[d]] = m[d].offsetWidth, o[$[d]] = m[d].offsetHeight;
1368
- return Me.filter((d) => p(u[d]));
1369
- }), it = {
1367
+ for (let u = 0; u < K.length; u++)
1368
+ s[K[u]] = y[u].offsetWidth, o[K[u]] = y[u].offsetHeight;
1369
+ return Ge.filter((u) => h(p[u]));
1370
+ }), ut = {
1370
1371
  vendor: "",
1371
1372
  vendorUnmasked: "",
1372
1373
  renderer: "",
1373
1374
  rendererUnmasked: "",
1374
1375
  version: "",
1375
1376
  shadingLanguageVersion: ""
1376
- }, ct = {
1377
+ }, lt = {
1377
1378
  hardware: {
1378
- videocard: it,
1379
+ videocard: ut,
1379
1380
  architecture: 0,
1380
1381
  deviceMemory: "undefined",
1381
1382
  jsHeapSizeLimit: 0
1382
1383
  }
1383
1384
  };
1384
- function Xn() {
1385
+ function ar() {
1385
1386
  const e = document.createElement("canvas"), t = e.getContext("webgl") ?? e.getContext("experimental-webgl");
1386
1387
  if (t && "getParameter" in t) {
1387
1388
  const n = t.getExtension("WEBGL_debug_renderer_info");
@@ -1394,41 +1395,41 @@ function Xn() {
1394
1395
  shadingLanguageVersion: (t.getParameter(t.SHADING_LANGUAGE_VERSION) || "").toString()
1395
1396
  };
1396
1397
  }
1397
- return it;
1398
+ return ut;
1398
1399
  }
1399
- function Zn() {
1400
+ function or() {
1400
1401
  const e = new Float32Array(1), t = new Uint8Array(e.buffer);
1401
1402
  return e[0] = 1 / 0, e[0] = e[0] - e[0], t[3];
1402
1403
  }
1403
- const er = () => navigator.deviceMemory || 0, tr = () => window.performance && window.performance.memory || {
1404
+ const sr = () => navigator.deviceMemory || 0, ir = () => window.performance && window.performance.memory || {
1404
1405
  jsHeapSizeLimit: 0
1405
- }, nr = async (e) => new Promise((t) => {
1406
+ }, cr = async (e) => new Promise((t) => {
1406
1407
  try {
1407
- const n = er(), r = tr();
1408
+ const n = sr(), r = ir();
1408
1409
  t({
1409
1410
  hardware: {
1410
- videocard: Xn(),
1411
- architecture: Zn(),
1411
+ videocard: ar(),
1412
+ architecture: or(),
1412
1413
  deviceMemory: n.toString() || "undefined",
1413
1414
  jsHeapSizeLimit: r.jsHeapSizeLimit || 0
1414
1415
  }
1415
1416
  });
1416
1417
  } catch {
1417
- t(ct);
1418
+ t(lt);
1418
1419
  }
1419
- }), rr = {
1420
+ }), ur = {
1420
1421
  locales: {
1421
1422
  languages: "",
1422
1423
  timezone: ""
1423
1424
  }
1424
- }, ar = async (e) => new Promise((t) => {
1425
+ }, lr = async (e) => new Promise((t) => {
1425
1426
  t({
1426
1427
  locales: {
1427
1428
  languages: navigator.language,
1428
1429
  timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
1429
1430
  }
1430
1431
  });
1431
- }), ut = {
1432
+ }), dt = {
1432
1433
  screen: {
1433
1434
  colorDepth: 0,
1434
1435
  pixelDepth: 0,
@@ -1436,7 +1437,7 @@ const er = () => navigator.deviceMemory || 0, tr = () => window.performance && w
1436
1437
  maxTouchPoints: 0,
1437
1438
  mediaMatches: []
1438
1439
  }
1439
- }, or = async (e) => new Promise((t) => {
1440
+ }, dr = async (e) => new Promise((t) => {
1440
1441
  try {
1441
1442
  const n = window.screen, r = {
1442
1443
  screen: {
@@ -1444,15 +1445,15 @@ const er = () => navigator.deviceMemory || 0, tr = () => window.performance && w
1444
1445
  pixelDepth: n.pixelDepth,
1445
1446
  isTouchScreen: navigator.maxTouchPoints > 0,
1446
1447
  maxTouchPoints: navigator.maxTouchPoints,
1447
- mediaMatches: sr()
1448
+ mediaMatches: hr()
1448
1449
  }
1449
1450
  };
1450
1451
  t(r);
1451
1452
  } catch {
1452
- t(ut);
1453
+ t(dt);
1453
1454
  }
1454
1455
  });
1455
- function sr() {
1456
+ function hr() {
1456
1457
  const e = [], t = {
1457
1458
  "prefers-contrast": [
1458
1459
  "high",
@@ -1480,7 +1481,7 @@ function sr() {
1480
1481
  });
1481
1482
  }), e;
1482
1483
  }
1483
- const ir = async (e) => {
1484
+ const pr = async (e) => {
1484
1485
  try {
1485
1486
  return {
1486
1487
  system: {
@@ -1491,55 +1492,175 @@ const ir = async (e) => {
1491
1492
  }
1492
1493
  };
1493
1494
  } catch {
1494
- return lt;
1495
+ return ht;
1495
1496
  }
1496
- }, lt = {
1497
+ }, ht = {
1497
1498
  system: {
1498
1499
  platform: "",
1499
1500
  cookieEnabled: !1,
1500
1501
  productSub: "",
1501
1502
  product: ""
1502
1503
  }
1503
- }, cr = async (e) => {
1504
+ }, fr = async (e) => {
1504
1505
  try {
1505
1506
  return Promise.all([
1506
- Gn(),
1507
- Jn(),
1508
- Yn(),
1509
- Qn(),
1510
- nr(),
1511
- ar(),
1512
- or(),
1513
- ir()
1507
+ Bn(e),
1508
+ qn(),
1509
+ zn(e),
1510
+ rr(),
1511
+ cr(e),
1512
+ lr(),
1513
+ dr(e),
1514
+ pr(e)
1514
1515
  ]);
1515
1516
  } catch {
1516
1517
  return [
1517
- Mn,
1518
- ot,
1519
- st,
1520
- Bn,
1518
+ Fn,
1519
+ it,
1521
1520
  ct,
1522
- rr,
1523
- ut,
1524
- lt
1521
+ er,
1522
+ lt,
1523
+ ur,
1524
+ dt,
1525
+ ht
1525
1526
  ];
1526
1527
  }
1527
- }, ur = async (e) => {
1528
+ }, yr = async (e) => {
1528
1529
  try {
1529
- const t = await cr();
1530
- return await at(JSON.stringify(t));
1530
+ const t = await fr(e);
1531
+ return await st(JSON.stringify(t));
1531
1532
  } catch {
1532
1533
  return "";
1533
1534
  }
1534
- }, K = "Oops! It looks like your session has expired. For your security, please log in again to continue.", lr = "Your session has been successfully terminated.", re = "Login failed. Please try again.", dr = "Error getting access token, please re-authenticate.", hr = "You forgot to wrap your component in <AuthProvider>.", le = {
1535
- dev: "https://auth.gizmette.local.com:3003",
1536
- prod: "https://mylogin.gizmette.com/auth"
1537
- }, ae = "@@auth@@", Y = "LOADING", V = "LOGIN", dt = "LOGOUT", pr = process.env.NODE_ENV === "production", ht = !pr, fr = (e) => {
1535
+ }, oe = {
1536
+ GET_REGISTRATION_OPTIONS: `mutation GetPasskeyRegistrationOptions(
1537
+ $clientId: String!,
1538
+ $username: String!,
1539
+ $id: String!) {
1540
+ getPasskeyRegistrationOptions(clientId: $clientId, username: $username, id: $id) {
1541
+ challenge
1542
+ rp {
1543
+ id
1544
+ name
1545
+ }
1546
+ user {
1547
+ id
1548
+ name
1549
+ displayName
1550
+ }
1551
+ pubKeyCredParams {
1552
+ type
1553
+ alg
1554
+ }
1555
+ timeout
1556
+ attestation
1557
+ }
1558
+ }`,
1559
+ VERIFY_REGISTRATION: `mutation VerifyPasskeyRegistration(
1560
+ $clientId: String!,
1561
+ $username: String!,
1562
+ $id: String!,
1563
+ $registration: RegistrationOptionsInput!) {
1564
+ verifyPasskeyRegistration(
1565
+ clientId: $clientId,
1566
+ username: $username,
1567
+ id: $id,
1568
+ registration: $registration) {
1569
+ status
1570
+ message
1571
+ }
1572
+ }`,
1573
+ GET_AUTHENTICATION_OPTIONS: `mutation GetPasskeyAuthenticationOptions(
1574
+ $id: String!,
1575
+ $clientId: String!,
1576
+ ) {
1577
+ getPasskeyAuthenticationOptions(
1578
+ id: $id,
1579
+ clientId: $clientId) {
1580
+ rpId,
1581
+ challenge,
1582
+ allowCredentials {
1583
+ id,
1584
+ type,
1585
+ transports
1586
+ }
1587
+ timeout,
1588
+ userVerification,
1589
+ }
1590
+ }`,
1591
+ VERIFY_AUTHENTICATION: `mutation VerifyPasskeyAuthentication(
1592
+ $clientId: String!,
1593
+ $id: String!,
1594
+ $authentication: AuthenticationOptionsInput!,
1595
+ $nonce: String!,
1596
+ $domain: String,
1597
+ $fingerprint: String) {
1598
+ verifyPasskeyAuthentication(
1599
+ clientId: $clientId,
1600
+ id: $id,
1601
+ authentication: $authentication,
1602
+ nonce: $nonce,
1603
+ domain: $domain,
1604
+ fingerprint: $fingerprint) {
1605
+ status,
1606
+ idToken,
1607
+ accessToken,
1608
+ refreshToken,
1609
+ userId,
1610
+ username,
1611
+ }
1612
+ }`
1613
+ }, H = {
1614
+ GET_REGISTRATION_OPTIONS: {
1615
+ schema: oe.GET_REGISTRATION_OPTIONS,
1616
+ method: "getPasskeyRegistrationOptions"
1617
+ },
1618
+ VERIFY_REGISTRATION: {
1619
+ schema: oe.VERIFY_REGISTRATION,
1620
+ method: "verifyPasskeyRegistration"
1621
+ },
1622
+ GET_AUTHENTICATION_OPTIONS: {
1623
+ schema: oe.GET_AUTHENTICATION_OPTIONS,
1624
+ method: "getPasskeyAuthenticationOptions"
1625
+ },
1626
+ VERIFY_AUTHENTICATION: {
1627
+ schema: oe.VERIFY_AUTHENTICATION,
1628
+ method: "verifyPasskeyAuthentication"
1629
+ }
1630
+ }, L = async ({
1631
+ accessToken: e,
1632
+ type: t,
1633
+ clientId: n,
1634
+ params: r = {}
1635
+ }) => {
1538
1636
  try {
1539
- const t = bn(e);
1540
- return t ? t[T.USER_ID_KEY] : "";
1541
- } catch {
1542
- return "";
1637
+ const a = t?.data ? t.data(r) : r, s = `Bearer ${e}`, o = await fetch(
1638
+ pt ? `${le.dev}/graphql` : `${le.prod}/graphql`,
1639
+ {
1640
+ method: "POST",
1641
+ credentials: "include",
1642
+ headers: {
1643
+ authorization: s,
1644
+ "Content-Type": "application/json",
1645
+ Accept: "application/json",
1646
+ [Be.CLIENT_ID]: `${n}`
1647
+ },
1648
+ body: JSON.stringify({
1649
+ query: t.schema,
1650
+ variables: a
1651
+ })
1652
+ }
1653
+ );
1654
+ if (o.status !== 200)
1655
+ return { status: o.status, data: [] };
1656
+ const { data: i, errors: c } = await o.json();
1657
+ return {
1658
+ status: o.status,
1659
+ data: i[t.method],
1660
+ errors: c
1661
+ };
1662
+ } catch (a) {
1663
+ return console.error(a), { status: 500, data: [] };
1543
1664
  }
1544
1665
  }, pe = async ({
1545
1666
  type: e,
@@ -1548,13 +1669,13 @@ const ir = async (e) => {
1548
1669
  }) => {
1549
1670
  try {
1550
1671
  const r = await fetch(
1551
- ht ? `${le.dev}/${e}` : `${le.prod}/${e}`,
1672
+ pt ? `${le.dev}/${e}` : `${le.prod}/${e}`,
1552
1673
  {
1553
1674
  credentials: "include",
1554
1675
  method: "POST",
1555
1676
  headers: {
1556
1677
  "Content-Type": "application/json",
1557
- [Fe.CLIENT_ID]: `${t}`
1678
+ [Be.CLIENT_ID]: `${t}`
1558
1679
  },
1559
1680
  body: JSON.stringify(n)
1560
1681
  }
@@ -1570,7 +1691,21 @@ const ir = async (e) => {
1570
1691
  } catch (r) {
1571
1692
  return console.error(r), { status: 500, data: [] };
1572
1693
  }
1573
- }, yr = async ({
1694
+ }, gr = process.env.NODE_ENV === "production", pt = !gr, ft = {
1695
+ isLoading: !0,
1696
+ isAuthenticated: !1,
1697
+ authenticationType: null,
1698
+ user: void 0,
1699
+ logoutReason: "",
1700
+ debug: !1
1701
+ }, mr = (e) => {
1702
+ try {
1703
+ const t = _n(e);
1704
+ return t ? t[A.USER_ID_KEY] : "";
1705
+ } catch {
1706
+ return "";
1707
+ }
1708
+ }, wr = async ({
1574
1709
  userId: e,
1575
1710
  idToken: t,
1576
1711
  accessToken: n,
@@ -1590,14 +1725,14 @@ const ir = async (e) => {
1590
1725
  refreshToken: r,
1591
1726
  domain: s
1592
1727
  }
1593
- })).status === 200
1728
+ }))?.status === 200
1594
1729
  };
1595
1730
  } catch {
1596
1731
  return {
1597
1732
  status: !1
1598
1733
  };
1599
1734
  }
1600
- }, Ge = async ({
1735
+ }, Je = async ({
1601
1736
  username: e,
1602
1737
  password: t,
1603
1738
  clientId: n,
@@ -1606,11 +1741,11 @@ const ir = async (e) => {
1606
1741
  sessionExpiration: s,
1607
1742
  code: o,
1608
1743
  code_verifier: i,
1609
- domain: l,
1610
- fingerprint: y
1744
+ domain: c,
1745
+ fingerprint: g
1611
1746
  }) => {
1612
1747
  try {
1613
- const h = await pe({
1748
+ const l = await pe({
1614
1749
  type: de.AUTHENTICATE,
1615
1750
  clientId: n,
1616
1751
  params: {
@@ -1621,15 +1756,15 @@ const ir = async (e) => {
1621
1756
  nonce: r,
1622
1757
  code: o,
1623
1758
  code_verifier: i,
1624
- domain: l,
1625
- fingerprint: y
1759
+ domain: c,
1760
+ fingerprint: g
1626
1761
  }
1627
- }), p = await M(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],
1762
+ }), h = await M(l?.data?.idToken);
1763
+ return h && h.payload[A.USER_ID_KEY] !== "" && h.payload[A.NONCE_KEY] === r ? {
1764
+ idToken: l.data.idToken,
1765
+ accessToken: l.data.accessToken,
1766
+ refreshToken: l.data.refreshToken,
1767
+ userId: h.payload[A.USER_ID_KEY],
1633
1768
  status: !0
1634
1769
  } : {
1635
1770
  status: !1
@@ -1639,7 +1774,7 @@ const ir = async (e) => {
1639
1774
  status: !1
1640
1775
  };
1641
1776
  }
1642
- }, gr = async ({
1777
+ }, Er = async ({
1643
1778
  nonce: e,
1644
1779
  clientId: t,
1645
1780
  code_challenge: n
@@ -1654,7 +1789,7 @@ const ir = async (e) => {
1654
1789
  code_challenge: n
1655
1790
  }
1656
1791
  });
1657
- return r.data.code ? {
1792
+ return r?.data?.code ? {
1658
1793
  status: !0,
1659
1794
  code: r.data.code
1660
1795
  } : {
@@ -1665,7 +1800,7 @@ const ir = async (e) => {
1665
1800
  status: !1
1666
1801
  };
1667
1802
  }
1668
- }, mr = async ({
1803
+ }, Sr = async ({
1669
1804
  clientId: e,
1670
1805
  userId: t,
1671
1806
  nonce: n,
@@ -1684,13 +1819,13 @@ const ir = async (e) => {
1684
1819
  refreshToken: r,
1685
1820
  accessToken: a,
1686
1821
  domain: s,
1687
- fingerprint: await pt()
1822
+ fingerprint: await yt()
1688
1823
  }
1689
- }), i = await M(o.data.accessToken);
1690
- return i && i.payload[T.USER_ID_KEY] !== "" && i.payload[T.NONCE_KEY] === n ? {
1824
+ }), i = await M(o?.data?.accessToken);
1825
+ return i && i.payload[A.USER_ID_KEY] !== "" && i.payload[A.NONCE_KEY] === n ? {
1691
1826
  accessToken: o.data.accessToken,
1692
1827
  refreshToken: o.data.refreshToken,
1693
- userId: i.payload[T.USER_ID_KEY],
1828
+ userId: i.payload[A.USER_ID_KEY],
1694
1829
  status: !0
1695
1830
  } : {
1696
1831
  status: !1
@@ -1700,144 +1835,14 @@ const ir = async (e) => {
1700
1835
  status: !1
1701
1836
  };
1702
1837
  }
1703
- }, oe = {
1704
- GET_REGISTRATION_OPTIONS: `mutation GetPasskeyRegistrationOptions(
1705
- $clientId: String!,
1706
- $username: String!,
1707
- $id: String!) {
1708
- getPasskeyRegistrationOptions(clientId: $clientId, username: $username, id: $id) {
1709
- challenge
1710
- rp {
1711
- id
1712
- name
1713
- }
1714
- user {
1715
- id
1716
- name
1717
- displayName
1718
- }
1719
- pubKeyCredParams {
1720
- type
1721
- alg
1722
- }
1723
- timeout
1724
- attestation
1725
- }
1726
- }`,
1727
- VERIFY_REGISTRATION: `mutation VerifyPasskeyRegistration(
1728
- $clientId: String!,
1729
- $username: String!,
1730
- $id: String!,
1731
- $registration: RegistrationOptionsInput!) {
1732
- verifyPasskeyRegistration(
1733
- clientId: $clientId,
1734
- username: $username,
1735
- id: $id,
1736
- registration: $registration) {
1737
- status
1738
- message
1739
- }
1740
- }`,
1741
- GET_AUTHENTICATION_OPTIONS: `mutation GetPasskeyAuthenticationOptions(
1742
- $id: String!,
1743
- $clientId: String!,
1744
- ) {
1745
- getPasskeyAuthenticationOptions(
1746
- id: $id,
1747
- clientId: $clientId) {
1748
- rpId,
1749
- challenge,
1750
- allowCredentials {
1751
- id,
1752
- type,
1753
- transports
1754
- }
1755
- timeout,
1756
- userVerification,
1757
- }
1758
- }`,
1759
- VERIFY_AUTHENTICATION: `mutation VerifyPasskeyAuthentication(
1760
- $clientId: String!,
1761
- $id: String!,
1762
- $authentication: AuthenticationOptionsInput!,
1763
- $nonce: String!,
1764
- $domain: String,
1765
- $fingerprint: String) {
1766
- verifyPasskeyAuthentication(
1767
- clientId: $clientId,
1768
- id: $id,
1769
- authentication: $authentication,
1770
- nonce: $nonce,
1771
- domain: $domain,
1772
- fingerprint: $fingerprint) {
1773
- status,
1774
- idToken,
1775
- accessToken,
1776
- refreshToken,
1777
- userId,
1778
- username,
1779
- }
1780
- }`
1781
- }, H = {
1782
- GET_REGISTRATION_OPTIONS: {
1783
- schema: oe.GET_REGISTRATION_OPTIONS,
1784
- method: "getPasskeyRegistrationOptions"
1785
- },
1786
- VERIFY_REGISTRATION: {
1787
- schema: oe.VERIFY_REGISTRATION,
1788
- method: "verifyPasskeyRegistration"
1789
- },
1790
- GET_AUTHENTICATION_OPTIONS: {
1791
- schema: oe.GET_AUTHENTICATION_OPTIONS,
1792
- method: "getPasskeyAuthenticationOptions"
1793
- },
1794
- VERIFY_AUTHENTICATION: {
1795
- schema: oe.VERIFY_AUTHENTICATION,
1796
- method: "verifyPasskeyAuthentication"
1797
- }
1798
- }, L = async ({
1799
- accessToken: e,
1800
- type: t,
1801
- clientId: n,
1802
- params: r = {}
1803
- }) => {
1804
- try {
1805
- const a = t != null && t.data ? t.data(r) : r, s = `Bearer ${e}`, o = await fetch(
1806
- ht ? `${le.dev}/graphql` : `${le.prod}/graphql`,
1807
- {
1808
- method: "POST",
1809
- credentials: "include",
1810
- headers: {
1811
- authorization: s,
1812
- "Content-Type": "application/json",
1813
- Accept: "application/json",
1814
- [Fe.CLIENT_ID]: `${n}`
1815
- },
1816
- body: JSON.stringify({
1817
- query: t.schema,
1818
- variables: a
1819
- })
1820
- }
1821
- );
1822
- if (o.status !== 200)
1823
- return { status: o.status, data: [] };
1824
- const { data: i, errors: l } = await o.json();
1825
- return {
1826
- status: o.status,
1827
- data: i[t.method],
1828
- errors: l
1829
- };
1830
- } catch (a) {
1831
- return console.error(a), { status: 500, data: [] };
1832
- }
1833
- }, pt = async () => {
1838
+ }, yt = async () => {
1834
1839
  try {
1835
- return await ur();
1840
+ return await yr();
1836
1841
  } catch {
1837
1842
  return "";
1838
1843
  }
1839
1844
  };
1840
- class wr {
1845
+ class Ar {
1841
1846
  constructor(t = null, n = null) {
1842
1847
  Q(this, "refreshTokenPromise", null);
1843
1848
  Q(this, "accessToken");
@@ -1869,8 +1874,8 @@ class wr {
1869
1874
  domain: a
1870
1875
  }) {
1871
1876
  const s = await M(this.refreshToken);
1872
- if (s && s.payload[T.USER_ID_KEY] !== "") {
1873
- const o = await mr({
1877
+ if (s && s.payload[A.USER_ID_KEY] !== "") {
1878
+ const o = await Sr({
1874
1879
  clientId: t,
1875
1880
  userId: n,
1876
1881
  nonce: r,
@@ -1879,26 +1884,26 @@ class wr {
1879
1884
  domain: a
1880
1885
  });
1881
1886
  return o.status ? (this.accessToken = o.accessToken, this.refreshToken = o.refreshToken, {
1882
- status: "success",
1887
+ status: Yn,
1883
1888
  newAccessToken: o.accessToken,
1884
1889
  newRefreshToken: o.refreshToken
1885
1890
  }) : {
1886
- status: "failure"
1891
+ status: xe
1887
1892
  };
1888
1893
  } else
1889
1894
  return {
1890
- status: "failure"
1895
+ status: xe
1891
1896
  };
1892
1897
  }
1893
1898
  }
1894
- const Er = (e) => x(
1899
+ const Tr = (e) => x(
1895
1900
  (...t) => {
1896
1901
  e && console.info(`==> [Auth ${Date.now()}]: `, ...t);
1897
1902
  },
1898
1903
  [e]
1899
1904
  ), W = () => {
1900
- throw new Error(hr);
1901
- }, ft = Ct({
1905
+ throw new Error(Jn);
1906
+ }, gt = Ot({
1902
1907
  isAuthenticated: !1,
1903
1908
  isLoading: !1,
1904
1909
  authenticationType: null,
@@ -1909,279 +1914,268 @@ const Er = (e) => x(
1909
1914
  registeringForPasskey: W,
1910
1915
  loginWithPasskey: W,
1911
1916
  logoutReason: ""
1912
- }), Sr = vt.createContext({
1913
- state: {
1914
- isLoading: !0,
1915
- isAuthenticated: !1,
1916
- authenticationType: null,
1917
- user: void 0,
1918
- logoutReason: "",
1919
- debug: !1
1920
- },
1917
+ }), Rr = Pt.createContext({
1918
+ state: ft,
1921
1919
  dispatch: () => {
1922
1920
  }
1923
- }), Ar = (e, t) => (t == null ? void 0 : t.type) === Y ? {
1921
+ }), br = (e, t) => t?.type === Y ? {
1924
1922
  ...e,
1925
1923
  isLoading: t.payload.isLoading
1926
- } : (t == null ? void 0 : t.type) === V ? {
1924
+ } : t?.type === V ? {
1927
1925
  ...e,
1928
1926
  isLoading: !1,
1929
1927
  isAuthenticated: !0,
1930
1928
  user: t.payload.user,
1931
1929
  authenticationType: t.payload.authenticationType,
1932
1930
  logoutReason: ""
1933
- } : (t == null ? void 0 : t.type) === dt ? {
1931
+ } : t?.type === ot ? {
1934
1932
  ...e,
1935
1933
  isLoading: !1,
1936
1934
  isAuthenticated: !1,
1937
1935
  user: void 0,
1938
1936
  authenticationType: null,
1939
1937
  logoutReason: t.payload.logoutReason
1940
- } : e, Or = ({
1938
+ } : e, Ur = ({
1941
1939
  children: e,
1942
1940
  sessionExpiration: t,
1943
1941
  clientId: n,
1944
1942
  domain: r = "",
1945
1943
  debug: a = !1
1946
1944
  }) => {
1947
- const [s, o] = Pt(Ar, {
1948
- isLoading: !0,
1949
- isAuthenticated: !1,
1950
- authenticationType: null,
1951
- user: void 0,
1952
- logoutReason: "",
1945
+ const [s, o] = Nt(br, {
1946
+ ...ft,
1953
1947
  debug: a
1954
- }), i = Er(a), l = ke(!1), y = ke(""), [h, p, , m] = te({
1948
+ }), i = Tr(a), c = Ce(!1), g = Ce(""), [l, h, , y] = te({
1955
1949
  key: `${ae}::${n}::@@user@@`
1956
- }), [u, d, , g] = te({
1950
+ }), [p, u, , m] = te({
1957
1951
  key: `${ae}::${n}::@@access@@`
1958
- }), [R, q, , z] = te(
1952
+ }), [T, q, , z] = te(
1959
1953
  {
1960
1954
  key: `${ae}::${n}::@@refresh@@`
1961
1955
  }
1962
- ), [yt, be, , Ie] = te({
1956
+ ), [mt, be, , Ie] = te({
1963
1957
  key: `${ae}::${n}::@@nonce@@`
1964
- }), gt = new wr(u, R), U = x(
1965
- (c) => {
1958
+ }), wt = new Ar(p, T), U = x(
1959
+ (d) => {
1966
1960
  i(
1967
1961
  "removeStateAndLocalStorage: removing state and local storage with reason: ",
1968
- c
1962
+ d
1969
1963
  ), o({
1970
- type: dt,
1964
+ type: ot,
1971
1965
  payload: {
1972
- logoutReason: c || K
1966
+ logoutReason: d || $
1973
1967
  }
1974
- }), m(), g(), z(), Ie(), o({ type: Y, payload: { isLoading: !1 } });
1968
+ }), y(), m(), z(), Ie(), o({ type: Y, payload: { isLoading: !1 } });
1975
1969
  },
1976
- [g, m, Ie, z, i]
1970
+ [m, y, Ie, z, i]
1977
1971
  ), N = x(
1978
- async (c) => {
1972
+ async (d) => {
1979
1973
  i("invalidateAndLogout: invalidating and logging out");
1980
- const { user: w } = s, f = (w == null ? void 0 : w.userId) || fr(h);
1974
+ const { user: R } = s, f = R?.userId || mr(l);
1981
1975
  f || i(
1982
1976
  "invalidateAndLogout: user cannot be identified, logging out without userId"
1983
- ), await yr({
1977
+ ), await wr({
1984
1978
  userId: f,
1985
- idToken: h,
1986
- accessToken: u,
1987
- refreshToken: R,
1979
+ idToken: l,
1980
+ accessToken: p,
1981
+ refreshToken: T,
1988
1982
  clientId: n,
1989
1983
  domain: r
1990
- }), U(c || K);
1984
+ }), U(d || $);
1991
1985
  },
1992
1986
  [
1993
- u,
1987
+ p,
1994
1988
  s,
1995
1989
  n,
1996
1990
  r,
1997
- h,
1998
- R,
1991
+ l,
1992
+ T,
1999
1993
  U,
2000
1994
  i
2001
1995
  ]
2002
1996
  );
2003
- Ae(() => ((async () => (i("useEffect: setting the fingerprint"), y.current = await pt()))(), () => {
2004
- i("useEffect: cleaning up the fingerprint"), y.current = "";
1997
+ Ae(() => ((async () => (i("useEffect: setting the fingerprint"), g.current = await yt()))(), () => {
1998
+ i("useEffect: cleaning up the fingerprint"), g.current = "";
2005
1999
  }), []), Ae(() => {
2006
- if (!l.current)
2007
- return s.isLoading && h !== null ? (async () => {
2000
+ if (!c.current)
2001
+ return s.isLoading && l !== null ? (async () => {
2008
2002
  try {
2009
- const c = await M(h);
2010
- c && c.payload[T.USER_ID_KEY] !== "" ? (i("useEffect: setting the authentication state"), o({
2003
+ const d = await M(l);
2004
+ d && d.payload[A.USER_ID_KEY] !== "" ? (i("useEffect: setting the authentication state"), o({
2011
2005
  type: V,
2012
2006
  payload: {
2013
- authenticationType: c.payload[T.AUTH_TYPE_KEY],
2007
+ authenticationType: d.payload[A.AUTH_TYPE_KEY],
2014
2008
  user: {
2015
- userId: c.payload[T.USER_ID_KEY],
2016
- username: c.payload[T.USERNAME_KEY]
2009
+ userId: d.payload[A.USER_ID_KEY],
2010
+ username: d.payload[A.USERNAME_KEY]
2017
2011
  }
2018
2012
  }
2019
- })) : (i("useEffect: invalid JWT, invalidating and logging out"), await N(K));
2013
+ })) : (i("useEffect: invalid JWT, invalidating and logging out"), await N($));
2020
2014
  } catch {
2021
2015
  i(
2022
2016
  "useEffect: exception validating JWT, invalidating and logging out"
2023
- ), await N(K);
2017
+ ), await N($);
2024
2018
  }
2025
2019
  })() : (i("useEffect: setting the loading state to false"), o({ type: Y, payload: { isLoading: !1 } })), () => {
2026
- l.current = !0;
2020
+ c.current = !0;
2027
2021
  };
2028
- }, [s.isLoading, h, N, i]);
2029
- const mt = async (c, w, f) => {
2022
+ }, [s.isLoading, l, N, i]);
2023
+ const Et = async (d, R, f) => {
2030
2024
  const I = Se();
2031
- if (be(I), o({ type: Y, payload: { isLoading: !0 } }), m(), g(), z(), i("login: Logging in with type: ", f), f === F.CODE) {
2032
- const { code_verifier: Rt, code_challenge: bt } = await Nn(), _e = await gr({
2025
+ if (be(I), o({ type: Y, payload: { isLoading: !0 } }), y(), m(), z(), i("login: Logging in with type: ", f), f === F.CODE) {
2026
+ const { code_verifier: It, code_challenge: _t } = await Un(), _e = await Er({
2033
2027
  nonce: I,
2034
2028
  clientId: n,
2035
- code_challenge: bt
2029
+ code_challenge: _t
2036
2030
  });
2037
2031
  if (_e.status) {
2038
- const J = await Ge({
2039
- username: c,
2040
- password: w,
2032
+ const J = await Je({
2033
+ username: d,
2034
+ password: R,
2041
2035
  clientId: n,
2042
2036
  sessionExpiration: t,
2043
2037
  nonce: I,
2044
2038
  type: f,
2045
2039
  code: _e.code,
2046
- code_verifier: Rt,
2040
+ code_verifier: It,
2047
2041
  domain: r,
2048
- fingerprint: y.current
2042
+ fingerprint: g.current
2049
2043
  });
2050
- return J.status ? (p(J.idToken), d(J.accessToken), q(J.refreshToken), o({
2044
+ return J.status ? (h(J.idToken), u(J.accessToken), q(J.refreshToken), o({
2051
2045
  type: V,
2052
2046
  payload: {
2053
2047
  authenticationType: f,
2054
2048
  user: {
2055
2049
  userId: J.userId,
2056
- username: c
2050
+ username: d
2057
2051
  }
2058
2052
  }
2059
2053
  }), !0) : (U(re), !1);
2060
2054
  }
2061
2055
  return !1;
2062
2056
  }
2063
- const G = await Ge({
2064
- username: c,
2065
- password: w,
2057
+ const G = await Je({
2058
+ username: d,
2059
+ password: R,
2066
2060
  clientId: n,
2067
2061
  sessionExpiration: t,
2068
2062
  nonce: I,
2069
2063
  type: f,
2070
2064
  domain: r,
2071
- fingerprint: y.current
2065
+ fingerprint: g.current
2072
2066
  });
2073
- return G.status ? (p(G.idToken), d(G.accessToken), q(G.refreshToken), o({
2067
+ return G.status ? (h(G.idToken), u(G.accessToken), q(G.refreshToken), o({
2074
2068
  type: V,
2075
2069
  payload: {
2076
2070
  authenticationType: f,
2077
2071
  user: {
2078
2072
  userId: G.userId,
2079
- username: c
2073
+ username: d
2080
2074
  }
2081
2075
  }
2082
2076
  }), !0) : (U(re), !1);
2083
- }, wt = async (c) => {
2084
- c == null || c.preventDefault(), await N(lr);
2085
- }, Et = async () => {
2086
- const { isAuthenticated: c, user: w } = s;
2077
+ }, St = async (d) => {
2078
+ d?.preventDefault(), await N(Mn);
2079
+ }, At = async () => {
2080
+ const { isAuthenticated: d, user: R } = s;
2087
2081
  try {
2088
- if (c && w && w.userId) {
2089
- if (u) {
2082
+ if (d && R && R.userId) {
2083
+ if (p) {
2090
2084
  i("getAccessToken");
2091
- const I = await M(u);
2092
- if (I && I.payload[T.USER_ID_KEY] !== "")
2093
- return u;
2085
+ const I = await M(p);
2086
+ if (I && I.payload[A.USER_ID_KEY] !== "")
2087
+ return p;
2094
2088
  }
2095
2089
  i("getAccessToken: invalid access token, trying to refresh it");
2096
- const f = await gt.refreshtoken({
2090
+ const f = await wt.refreshtoken({
2097
2091
  clientId: n,
2098
- userId: w.userId,
2099
- nonce: yt,
2092
+ userId: R.userId,
2093
+ nonce: mt,
2100
2094
  domain: r
2101
2095
  });
2102
- return f.status && f.status === "success" ? (d(f.newAccessToken), q(f.newRefreshToken), f.newAccessToken) : (i(
2096
+ return f.status && f.status === "success" ? (u(f.newAccessToken), q(f.newRefreshToken), f.newAccessToken) : (i(
2103
2097
  "getAccessToken: invalid refresh token, need to re-authenticate"
2104
- ), await N(K), "");
2098
+ ), await N($), "");
2105
2099
  }
2106
2100
  return i(
2107
2101
  "getAccessToken: user is not authenticated, cannot get access token"
2108
- ), await N(K), "";
2102
+ ), await N($), "";
2109
2103
  } catch {
2110
2104
  return i(
2111
2105
  "getAccessToken: exception occurred, invalidating and logging out"
2112
- ), await N(dr), "";
2106
+ ), await N(Gn), "";
2113
2107
  }
2114
- }, St = () => {
2115
- if (s.isAuthenticated && h)
2116
- return h;
2117
- }, At = async () => {
2118
- const { user: c } = s;
2119
- let w = await L({
2120
- accessToken: u,
2108
+ }, Tt = () => {
2109
+ if (s.isAuthenticated && l)
2110
+ return l;
2111
+ }, Rt = async () => {
2112
+ const { user: d } = s;
2113
+ let R = await L({
2114
+ accessToken: p,
2121
2115
  clientId: n,
2122
2116
  type: H.GET_REGISTRATION_OPTIONS,
2123
2117
  params: {
2124
2118
  clientId: n,
2125
- id: c == null ? void 0 : c.userId,
2126
- username: c == null ? void 0 : c.username
2119
+ id: d?.userId,
2120
+ username: d?.username
2127
2121
  }
2128
2122
  });
2129
- if (w.status)
2123
+ if (R.status)
2130
2124
  try {
2131
- const f = await $t(w.data);
2132
- w = await L({
2133
- accessToken: u,
2125
+ const f = await Ht(R.data);
2126
+ R = await L({
2127
+ accessToken: p,
2134
2128
  clientId: n,
2135
2129
  type: H.VERIFY_REGISTRATION,
2136
2130
  params: {
2137
2131
  clientId: n,
2138
- id: c == null ? void 0 : c.userId,
2139
- username: c == null ? void 0 : c.username,
2132
+ id: d?.userId,
2133
+ username: d?.username,
2140
2134
  registration: f
2141
2135
  }
2142
2136
  });
2143
2137
  } catch {
2144
2138
  return await L({
2145
- accessToken: u,
2139
+ accessToken: p,
2146
2140
  clientId: n,
2147
2141
  type: H.VERIFY_REGISTRATION,
2148
2142
  params: {
2149
2143
  clientId: n,
2150
- id: c == null ? void 0 : c.userId,
2151
- username: c == null ? void 0 : c.username,
2144
+ id: d?.userId,
2145
+ username: d?.username,
2152
2146
  registration: {}
2153
2147
  }
2154
2148
  }), !1;
2155
2149
  }
2156
- }, Tt = async () => {
2157
- const c = Se();
2158
- be(c), o({ type: Y, payload: { isLoading: !0 } }), m(), g(), z(), i("loginWithPasskey");
2159
- const w = Se();
2150
+ }, bt = async () => {
2151
+ const d = Se();
2152
+ be(d), o({ type: Y, payload: { isLoading: !0 } }), y(), m(), z(), i("loginWithPasskey");
2153
+ const R = Se();
2160
2154
  let f = await L({
2161
- accessToken: u,
2155
+ accessToken: p,
2162
2156
  clientId: n,
2163
2157
  type: H.GET_AUTHENTICATION_OPTIONS,
2164
2158
  params: {
2165
- id: w,
2159
+ id: R,
2166
2160
  clientId: n
2167
2161
  }
2168
2162
  });
2169
2163
  if (f.status)
2170
2164
  try {
2171
- const I = await Lt(f.data);
2165
+ const I = await xt(f.data);
2172
2166
  return f = await L({
2173
- accessToken: u,
2167
+ accessToken: p,
2174
2168
  clientId: n,
2175
2169
  type: H.VERIFY_AUTHENTICATION,
2176
2170
  params: {
2177
2171
  clientId: n,
2178
- id: w,
2172
+ id: R,
2179
2173
  authentication: I,
2180
- nonce: c,
2174
+ nonce: d,
2181
2175
  domain: r,
2182
- fingerprint: y.current
2176
+ fingerprint: g.current
2183
2177
  }
2184
- }), f.data.status === "success" ? (p(f.data.idToken), d(f.data.accessToken), q(f.data.refreshToken), o({
2178
+ }), f.data.status === "success" ? (h(f.data.idToken), u(f.data.accessToken), q(f.data.refreshToken), o({
2185
2179
  type: V,
2186
2180
  payload: {
2187
2181
  authenticationType: F.PASSKEY,
@@ -2193,38 +2187,38 @@ const Er = (e) => x(
2193
2187
  }), !0) : (U(re), !1);
2194
2188
  } catch {
2195
2189
  return await L({
2196
- accessToken: u,
2190
+ accessToken: p,
2197
2191
  clientId: n,
2198
2192
  type: H.VERIFY_AUTHENTICATION,
2199
2193
  params: {
2200
2194
  clientId: n,
2201
- id: w,
2195
+ id: R,
2202
2196
  authentication: {},
2203
- nonce: c,
2197
+ nonce: d,
2204
2198
  domain: r
2205
2199
  }
2206
2200
  }), U(re), !1;
2207
2201
  }
2208
2202
  };
2209
- return /* @__PURE__ */ ve(Sr.Provider, { value: { state: s, dispatch: o }, children: /* @__PURE__ */ ve(
2210
- ft.Provider,
2203
+ return /* @__PURE__ */ ve(Rr.Provider, { value: { state: s, dispatch: o }, children: /* @__PURE__ */ ve(
2204
+ gt.Provider,
2211
2205
  {
2212
2206
  value: {
2213
2207
  ...s,
2214
- login: mt,
2215
- logout: wt,
2216
- getAccessToken: Et,
2217
- getIdToken: St,
2218
- registeringForPasskey: At,
2219
- loginWithPasskey: Tt
2208
+ login: Et,
2209
+ logout: St,
2210
+ getAccessToken: At,
2211
+ getIdToken: Tt,
2212
+ registeringForPasskey: Rt,
2213
+ loginWithPasskey: bt
2220
2214
  },
2221
2215
  children: e
2222
2216
  }
2223
2217
  ) });
2224
- }, Nr = (e = ft) => Ot(e);
2218
+ }, $r = (e = gt) => Dt(e);
2225
2219
  export {
2226
2220
  F as AUTH_TYPES,
2227
- Or as AuthProvider,
2228
- Pr as isGranted,
2229
- Nr as useAuth
2221
+ Ur as AuthProvider,
2222
+ Dr as isGranted,
2223
+ $r as useAuth
2230
2224
  };