@versini/auth-provider 8.0.6 → 8.1.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/auth.js CHANGED
@@ -1,18 +1,18 @@
1
- var Pe = Object.defineProperty;
2
- var Ce = (e, t, n) => t in e ? Pe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var K = (e, t, n) => Ce(e, typeof t != "symbol" ? t + "" : t, n);
1
+ var ke = Object.defineProperty;
2
+ var Ce = (e, t, n) => t in e ? ke(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var $ = (e, t, n) => Ce(e, typeof t != "symbol" ? t + "" : t, n);
4
4
  import { jsx as V } from "react/jsx-runtime";
5
- import { HEADERS as ie, decodeToken as ve, JWT as T, API_TYPE as M, AUTH_TYPES as C, verifyAndExtractToken as D, pkceChallengePair as Ue } from "@versini/auth-common";
6
- import De, { useSyncExternalStore as Le, useCallback as S, useEffect as ce, createContext as $e, useContext as Ke, useReducer as Ye, useRef as Ge } from "react";
5
+ import { HEADERS as ie, decodeToken as ve, JWT as T, API_TYPE as F, AUTH_TYPES as C, verifyAndExtractToken as D, pkceChallengePair as Ue } from "@versini/auth-common";
6
+ import De, { useSyncExternalStore as Le, useCallback as S, useEffect as ce, createContext as Ke, useContext as $e, useReducer as Ye, useRef as Ge } from "react";
7
7
  import { AuthHookContext as He } from "./AuthHookContext-C9a2AwWZ.js";
8
8
  /*!
9
- @versini/auth-provider v8.0.6
9
+ @versini/auth-provider v8.1.1
10
10
  © 2025 gizmette.com
11
11
  */
12
12
  try {
13
13
  window.__VERSINI_AUTH_CLIENT__ || (window.__VERSINI_AUTH_CLIENT__ = {
14
- version: "8.0.6",
15
- buildTime: "11/23/2025 02:59 PM EST",
14
+ version: "8.1.1",
15
+ buildTime: "11/29/2025 08:06 PM EST",
16
16
  homepage: "https://github.com/aversini/auth-client",
17
17
  license: "MIT"
18
18
  });
@@ -25,11 +25,11 @@ function R(e) {
25
25
  n += String.fromCharCode(s);
26
26
  return btoa(n).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
27
27
  }
28
- function F(e) {
29
- const t = e.replace(/-/g, "+").replace(/_/g, "/"), n = (4 - t.length % 4) % 4, a = t.padEnd(t.length + n, "="), s = atob(a), o = new ArrayBuffer(s.length), c = new Uint8Array(o);
30
- for (let r = 0; r < s.length; r++)
31
- c[r] = s.charCodeAt(r);
32
- return o;
28
+ function M(e) {
29
+ const t = e.replace(/-/g, "+").replace(/_/g, "/"), n = (4 - t.length % 4) % 4, a = t.padEnd(t.length + n, "="), s = atob(a), i = new ArrayBuffer(s.length), c = new Uint8Array(i);
30
+ for (let o = 0; o < s.length; o++)
31
+ c[o] = s.charCodeAt(o);
32
+ return i;
33
33
  }
34
34
  function X() {
35
35
  return Ve.stubThis(globalThis?.PublicKeyCredential !== void 0 && typeof globalThis.PublicKeyCredential == "function");
@@ -41,7 +41,7 @@ function ue(e) {
41
41
  const { id: t } = e;
42
42
  return {
43
43
  ...e,
44
- id: F(t),
44
+ id: M(t),
45
45
  /**
46
46
  * `descriptor.transports` is an array of our `AuthenticatorTransportFuture` that includes newer
47
47
  * transports that TypeScript's DOM lib is ignorant of. Convince TS that our list of transports
@@ -152,7 +152,7 @@ function xe({ error: e, options: t }) {
152
152
  }
153
153
  return e;
154
154
  }
155
- class Fe {
155
+ class Me {
156
156
  constructor() {
157
157
  Object.defineProperty(this, "controller", {
158
158
  enumerable: !0,
@@ -176,9 +176,9 @@ class Fe {
176
176
  }
177
177
  }
178
178
  }
179
- const de = new Fe(), Me = ["cross-platform", "platform"];
179
+ const de = new Me(), Fe = ["cross-platform", "platform"];
180
180
  function he(e) {
181
- if (e && !(Me.indexOf(e) < 0))
181
+ if (e && !(Fe.indexOf(e) < 0))
182
182
  return e;
183
183
  }
184
184
  async function Je(e) {
@@ -188,61 +188,61 @@ async function Je(e) {
188
188
  throw new Error("WebAuthn is not supported in this browser");
189
189
  const a = {
190
190
  ...t,
191
- challenge: F(t.challenge),
191
+ challenge: M(t.challenge),
192
192
  user: {
193
193
  ...t.user,
194
- id: F(t.user.id)
194
+ id: M(t.user.id)
195
195
  },
196
196
  excludeCredentials: t.excludeCredentials?.map(ue)
197
197
  }, s = {};
198
198
  n && (s.mediation = "conditional"), s.publicKey = a, s.signal = de.createNewAbortSignal();
199
- let o;
199
+ let i;
200
200
  try {
201
- o = await navigator.credentials.create(s);
202
- } catch (E) {
203
- throw xe({ error: E, options: s });
201
+ i = await navigator.credentials.create(s);
202
+ } catch (y) {
203
+ throw xe({ error: y, options: s });
204
204
  }
205
- if (!o)
205
+ if (!i)
206
206
  throw new Error("Registration was not completed");
207
- const { id: c, rawId: r, response: i, type: w } = o;
207
+ const { id: c, rawId: o, response: r, type: w } = i;
208
208
  let d;
209
- typeof i.getTransports == "function" && (d = i.getTransports());
209
+ typeof r.getTransports == "function" && (d = r.getTransports());
210
210
  let m;
211
- if (typeof i.getPublicKeyAlgorithm == "function")
211
+ if (typeof r.getPublicKeyAlgorithm == "function")
212
212
  try {
213
- m = i.getPublicKeyAlgorithm();
214
- } catch (E) {
215
- j("getPublicKeyAlgorithm()", E);
213
+ m = r.getPublicKeyAlgorithm();
214
+ } catch (y) {
215
+ j("getPublicKeyAlgorithm()", y);
216
216
  }
217
- let y;
218
- if (typeof i.getPublicKey == "function")
217
+ let E;
218
+ if (typeof r.getPublicKey == "function")
219
219
  try {
220
- const E = i.getPublicKey();
221
- E !== null && (y = R(E));
222
- } catch (E) {
223
- j("getPublicKey()", E);
220
+ const y = r.getPublicKey();
221
+ y !== null && (E = R(y));
222
+ } catch (y) {
223
+ j("getPublicKey()", y);
224
224
  }
225
225
  let f;
226
- if (typeof i.getAuthenticatorData == "function")
226
+ if (typeof r.getAuthenticatorData == "function")
227
227
  try {
228
- f = R(i.getAuthenticatorData());
229
- } catch (E) {
230
- j("getAuthenticatorData()", E);
228
+ f = R(r.getAuthenticatorData());
229
+ } catch (y) {
230
+ j("getAuthenticatorData()", y);
231
231
  }
232
232
  return {
233
233
  id: c,
234
- rawId: R(r),
234
+ rawId: R(o),
235
235
  response: {
236
- attestationObject: R(i.attestationObject),
237
- clientDataJSON: R(i.clientDataJSON),
236
+ attestationObject: R(r.attestationObject),
237
+ clientDataJSON: R(r.clientDataJSON),
238
238
  transports: d,
239
239
  publicKeyAlgorithm: m,
240
- publicKey: y,
240
+ publicKey: E,
241
241
  authenticatorData: f
242
242
  },
243
243
  type: w,
244
- clientExtensionResults: o.getClientExtensionResults(),
245
- authenticatorAttachment: he(o.authenticatorAttachment)
244
+ clientExtensionResults: i.getClientExtensionResults(),
245
+ authenticatorAttachment: he(i.authenticatorAttachment)
246
246
  };
247
247
  }
248
248
  function j(e, t) {
@@ -306,9 +306,9 @@ async function Be(e) {
306
306
  throw new Error("WebAuthn is not supported in this browser");
307
307
  let s;
308
308
  t.allowCredentials?.length !== 0 && (s = t.allowCredentials?.map(ue));
309
- const o = {
309
+ const i = {
310
310
  ...t,
311
- challenge: F(t.challenge),
311
+ challenge: M(t.challenge),
312
312
  allowCredentials: s
313
313
  }, c = {};
314
314
  if (n) {
@@ -316,70 +316,94 @@ async function Be(e) {
316
316
  throw Error("Browser does not support WebAuthn autofill");
317
317
  if (document.querySelectorAll("input[autocomplete$='webauthn']").length < 1 && a)
318
318
  throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');
319
- c.mediation = "conditional", o.allowCredentials = [];
319
+ c.mediation = "conditional", i.allowCredentials = [];
320
320
  }
321
- c.publicKey = o, c.signal = de.createNewAbortSignal();
322
- let r;
321
+ c.publicKey = i, c.signal = de.createNewAbortSignal();
322
+ let o;
323
323
  try {
324
- r = await navigator.credentials.get(c);
324
+ o = await navigator.credentials.get(c);
325
325
  } catch (f) {
326
326
  throw je({ error: f, options: c });
327
327
  }
328
- if (!r)
328
+ if (!o)
329
329
  throw new Error("Authentication was not completed");
330
- const { id: i, rawId: w, response: d, type: m } = r;
331
- let y;
332
- return d.userHandle && (y = R(d.userHandle)), {
333
- id: i,
330
+ const { id: r, rawId: w, response: d, type: m } = o;
331
+ let E;
332
+ return d.userHandle && (E = R(d.userHandle)), {
333
+ id: r,
334
334
  rawId: R(w),
335
335
  response: {
336
336
  authenticatorData: R(d.authenticatorData),
337
337
  clientDataJSON: R(d.clientDataJSON),
338
338
  signature: R(d.signature),
339
- userHandle: y
339
+ userHandle: E
340
340
  },
341
341
  type: m,
342
- clientExtensionResults: r.getClientExtensionResults(),
343
- authenticatorAttachment: he(r.authenticatorAttachment)
342
+ clientExtensionResults: o.getClientExtensionResults(),
343
+ authenticatorAttachment: he(o.authenticatorAttachment)
344
344
  };
345
345
  }
346
+ /*!
347
+ @versini/ui-hooks v5.2.0
348
+ © 2025 gizmette.com
349
+ */
350
+ try {
351
+ window.__VERSINI_UI_HOOKS__ || (window.__VERSINI_UI_HOOKS__ = {
352
+ version: "5.2.0",
353
+ buildTime: "11/04/2025 03:42 PM EST",
354
+ homepage: "https://github.com/aversini/ui-components",
355
+ license: "MIT"
356
+ });
357
+ } catch {
358
+ }
346
359
  function ge(e, t) {
347
- window.dispatchEvent(new StorageEvent("storage", { key: e, newValue: t }));
360
+ window.dispatchEvent(new StorageEvent("storage", {
361
+ key: e,
362
+ newValue: t
363
+ }));
348
364
  }
349
365
  const se = (e, t) => {
350
- const n = JSON.stringify(
351
- typeof t == "function" ? t() : t
352
- );
366
+ const n = JSON.stringify(typeof t == "function" ? t() : t);
353
367
  window.localStorage.setItem(e, n), ge(e, n);
354
368
  }, qe = (e) => {
355
369
  window.localStorage.removeItem(e), ge(e, null);
356
370
  }, re = (e) => window.localStorage.getItem(e), ze = (e) => (window.addEventListener("storage", e), () => window.removeEventListener("storage", e));
357
- function Y({
358
- key: e,
359
- initialValue: t
360
- }) {
361
- const n = Le(ze, () => re(e)), a = S(
362
- (c) => {
363
- try {
364
- const r = typeof c == "function" ? c(JSON.parse(n)) : c;
365
- r == null ? qe(e) : se(e, r);
366
- } catch (r) {
367
- console.warn(r);
368
- }
369
- },
370
- [e, n]
371
- ), s = S(() => {
372
- a(t);
373
- }, [t, a]), o = S(() => {
374
- a(null);
375
- }, [a]);
371
+ function Y({ key: e, initialValue: t }) {
372
+ const a = Le(ze, () => re(e)), s = S((o) => {
373
+ try {
374
+ const r = typeof o == "function" ? o(JSON.parse(a)) : o;
375
+ r == null ? qe(e) : se(e, r);
376
+ } catch (r) {
377
+ console.warn(r);
378
+ }
379
+ }, [
380
+ e,
381
+ a
382
+ ]), i = S(() => {
383
+ s(t);
384
+ }, [
385
+ t,
386
+ s
387
+ ]), c = S(() => {
388
+ s(null);
389
+ }, [
390
+ s
391
+ ]);
376
392
  return ce(() => {
377
393
  try {
378
394
  re(e) === null && typeof t < "u" && se(e, t);
379
- } catch (c) {
380
- console.warn(c);
395
+ } catch (o) {
396
+ console.warn(o);
381
397
  }
382
- }, [e, t]), [n ? JSON.parse(n) : null, a, s, o];
398
+ }, [
399
+ e,
400
+ t
401
+ ]), [
402
+ a ? JSON.parse(a) : null,
403
+ s,
404
+ i,
405
+ c
406
+ ];
383
407
  }
384
408
  const g = [];
385
409
  for (let e = 0; e < 256; ++e)
@@ -407,7 +431,7 @@ function z(e, t, n) {
407
431
  throw new Error("Random bytes length must be >= 16");
408
432
  return a[6] = a[6] & 15 | 64, a[8] = a[8] & 63 | 128, Qe(a);
409
433
  }
410
- const b = "Your session has expired. For your security, please log in again to continue.", tt = "Your session has been successfully terminated.", Q = "Login failed. Please try again.", nt = "Error getting access token, please re-authenticate.", at = "You forgot to wrap your component in <AuthProvider>.", G = "@@auth@@", U = "LOADING", x = "LOGIN", pe = "LOGOUT", L = "success", A = "failure", fe = "include", Te = "POST", ye = "application/json", H = {
434
+ const b = "Your session has expired. For your security, please log in again to continue.", tt = "Your session has been successfully terminated.", Q = "Login failed. Please try again.", nt = "Error getting access token, please re-authenticate.", at = "You forgot to wrap your component in <AuthProvider>.", G = "@@auth@@", U = "LOADING", x = "LOGIN", pe = "LOGOUT", L = "success", A = "failure", fe = "include", Te = "POST", Ee = "application/json", H = {
411
435
  GET_REGISTRATION_OPTIONS: `mutation GetPasskeyRegistrationOptions(
412
436
  $clientId: String!,
413
437
  $username: String!,
@@ -505,7 +529,7 @@ const b = "Your session has expired. For your security, please log in again to c
505
529
  schema: H.VERIFY_AUTHENTICATION,
506
530
  method: "verifyPasskeyAuthentication"
507
531
  }
508
- }, k = async ({
532
+ }, P = async ({
509
533
  accessToken: e,
510
534
  type: t,
511
535
  clientId: n,
@@ -513,12 +537,12 @@ const b = "Your session has expired. For your security, please log in again to c
513
537
  endpoint: s
514
538
  }) => {
515
539
  try {
516
- const o = `Bearer ${e}`, c = await fetch(`${s}/graphql`, {
540
+ const i = `Bearer ${e}`, c = await fetch(`${s}/graphql`, {
517
541
  credentials: fe,
518
542
  method: Te,
519
543
  headers: {
520
- authorization: o,
521
- "Content-Type": ye,
544
+ authorization: i,
545
+ "Content-Type": Ee,
522
546
  [ie.CLIENT_ID]: `${n}`
523
547
  },
524
548
  body: JSON.stringify({
@@ -528,13 +552,13 @@ const b = "Your session has expired. For your security, please log in again to c
528
552
  });
529
553
  if (c.status !== 200)
530
554
  return { status: A, data: [] };
531
- const { data: r } = await c.json();
555
+ const { data: o } = await c.json();
532
556
  return {
533
557
  status: L,
534
- data: r[t.method]
558
+ data: o[t.method]
535
559
  };
536
- } catch (o) {
537
- return console.error(o), { status: A, data: [] };
560
+ } catch (i) {
561
+ return console.error(i), { status: A, data: [] };
538
562
  }
539
563
  }, J = async ({
540
564
  type: e,
@@ -547,22 +571,22 @@ const b = "Your session has expired. For your security, please log in again to c
547
571
  credentials: fe,
548
572
  method: Te,
549
573
  headers: {
550
- "Content-Type": ye,
574
+ "Content-Type": Ee,
551
575
  [ie.CLIENT_ID]: `${t}`
552
576
  },
553
577
  body: JSON.stringify(n)
554
578
  });
555
579
  if (s.status !== 200)
556
580
  return { status: A, data: [] };
557
- const { data: o } = await s.json();
581
+ const { data: i } = await s.json();
558
582
  return {
559
583
  status: L,
560
- data: o || []
584
+ data: i || []
561
585
  };
562
586
  } catch (s) {
563
587
  return console.error(s), { status: A, data: [] };
564
588
  }
565
- }, st = process.env.NODE_ENV === "production", rt = !st, Ee = {
589
+ }, st = process.env.NODE_ENV === "production", rt = !st, ye = {
566
590
  isLoading: !0,
567
591
  isAuthenticated: !1,
568
592
  user: void 0,
@@ -587,7 +611,7 @@ const b = "Your session has expired. For your security, please log in again to c
587
611
  return {
588
612
  status: (await J({
589
613
  endpoint: s,
590
- type: M.LOGOUT,
614
+ type: F.LOGOUT,
591
615
  clientId: t,
592
616
  params: {
593
617
  userId: e,
@@ -607,36 +631,36 @@ const b = "Your session has expired. For your security, please log in again to c
607
631
  clientId: n,
608
632
  nonce: a,
609
633
  type: s,
610
- sessionExpiration: o,
634
+ sessionExpiration: i,
611
635
  code: c,
612
- code_verifier: r,
613
- domain: i,
636
+ code_verifier: o,
637
+ domain: r,
614
638
  ua: w,
615
639
  endpoint: d
616
640
  }) => {
617
641
  try {
618
642
  const m = await J({
619
643
  endpoint: d,
620
- type: M.LOGIN,
644
+ type: F.LOGIN,
621
645
  clientId: n,
622
646
  params: {
623
647
  type: s || C.ID_AND_ACCESS_TOKEN,
624
648
  username: e,
625
649
  password: t,
626
- sessionExpiration: o,
650
+ sessionExpiration: i,
627
651
  nonce: a,
628
652
  code: c,
629
- code_verifier: r,
630
- domain: i,
653
+ code_verifier: o,
654
+ domain: r,
631
655
  ua: w
632
656
  }
633
- }), y = await D(m?.data?.idToken);
634
- return y && y.payload[T.USER_ID_KEY] !== "" && y.payload[T.NONCE_KEY] === a ? {
657
+ }), E = await D(m?.data?.idToken);
658
+ return E && E.payload[T.USER_ID_KEY] !== "" && E.payload[T.NONCE_KEY] === a ? {
635
659
  idToken: m.data.idToken,
636
660
  accessToken: m.data.accessToken,
637
661
  refreshToken: m.data.refreshToken,
638
- userId: y.payload[T.USER_ID_KEY],
639
- email: y.payload[T.EMAIL_KEY],
662
+ userId: E.payload[T.USER_ID_KEY],
663
+ email: E.payload[T.EMAIL_KEY],
640
664
  status: !0
641
665
  } : {
642
666
  status: !1
@@ -655,7 +679,7 @@ const b = "Your session has expired. For your security, please log in again to c
655
679
  try {
656
680
  const s = await J({
657
681
  endpoint: a,
658
- type: M.CODE,
682
+ type: F.CODE,
659
683
  clientId: t,
660
684
  params: {
661
685
  type: C.CODE,
@@ -682,13 +706,13 @@ const b = "Your session has expired. For your security, please log in again to c
682
706
  nonce: n,
683
707
  refreshToken: a,
684
708
  accessToken: s,
685
- domain: o,
709
+ domain: i,
686
710
  endpoint: c
687
711
  }) => {
688
712
  try {
689
- const r = await J({
713
+ const o = await J({
690
714
  endpoint: c,
691
- type: M.REFRESH,
715
+ type: F.REFRESH,
692
716
  clientId: e,
693
717
  params: {
694
718
  type: C.REFRESH_TOKEN,
@@ -696,13 +720,13 @@ const b = "Your session has expired. For your security, please log in again to c
696
720
  nonce: n,
697
721
  refreshToken: a,
698
722
  accessToken: s,
699
- domain: o
723
+ domain: i
700
724
  }
701
- }), i = await D(r?.data?.accessToken);
702
- return i && i.payload[T.USER_ID_KEY] !== "" && i.payload[T.NONCE_KEY] === n ? {
703
- accessToken: r.data.accessToken,
704
- refreshToken: r.data.refreshToken,
705
- userId: i.payload[T.USER_ID_KEY],
725
+ }), r = await D(o?.data?.accessToken);
726
+ return r && r.payload[T.USER_ID_KEY] !== "" && r.payload[T.NONCE_KEY] === n ? {
727
+ accessToken: o.data.accessToken,
728
+ refreshToken: o.data.refreshToken,
729
+ userId: r.payload[T.USER_ID_KEY],
706
730
  status: !0
707
731
  } : {
708
732
  status: !1
@@ -715,9 +739,9 @@ const b = "Your session has expired. For your security, please log in again to c
715
739
  };
716
740
  class dt {
717
741
  constructor(t = null, n = null) {
718
- K(this, "refreshTokenPromise", null);
719
- K(this, "accessToken");
720
- K(this, "refreshToken");
742
+ $(this, "refreshTokenPromise", null);
743
+ $(this, "accessToken");
744
+ $(this, "refreshToken");
721
745
  this.accessToken = t || "", this.refreshToken = n || "";
722
746
  }
723
747
  async refreshtoken({
@@ -725,10 +749,10 @@ class dt {
725
749
  userId: n,
726
750
  nonce: a,
727
751
  domain: s,
728
- endpoint: o
752
+ endpoint: i
729
753
  }) {
730
754
  this.refreshTokenPromise || (this.refreshTokenPromise = this._refreshToken({
731
- endpoint: o,
755
+ endpoint: i,
732
756
  clientId: t,
733
757
  userId: n,
734
758
  nonce: a,
@@ -745,23 +769,23 @@ class dt {
745
769
  clientId: n,
746
770
  userId: a,
747
771
  nonce: s,
748
- domain: o
772
+ domain: i
749
773
  }) {
750
774
  const c = await D(this.refreshToken);
751
775
  if (c && c.payload[T.USER_ID_KEY] !== "") {
752
- const r = await lt({
776
+ const o = await lt({
753
777
  endpoint: t,
754
778
  clientId: n,
755
779
  userId: a,
756
780
  nonce: s,
757
781
  refreshToken: this.refreshToken,
758
782
  accessToken: this.accessToken,
759
- domain: o
783
+ domain: i
760
784
  });
761
- return r.status ? (this.accessToken = r.accessToken, this.refreshToken = r.refreshToken, {
785
+ return o.status ? (this.accessToken = o.accessToken, this.refreshToken = o.refreshToken, {
762
786
  status: L,
763
- newAccessToken: r.accessToken,
764
- newRefreshToken: r.refreshToken
787
+ newAccessToken: o.accessToken,
788
+ newRefreshToken: o.refreshToken
765
789
  }) : {
766
790
  status: A
767
791
  };
@@ -771,28 +795,28 @@ class dt {
771
795
  };
772
796
  }
773
797
  }
774
- const P = () => {
798
+ const k = () => {
775
799
  throw new Error(at);
776
- }, me = $e({
800
+ }, me = Ke({
777
801
  isAuthenticated: !1,
778
802
  isLoading: !1,
779
- login: P,
780
- logout: P,
781
- getAccessToken: P,
782
- getIdToken: P,
783
- registeringForPasskey: P,
784
- loginWithPasskey: P,
803
+ login: k,
804
+ logout: k,
805
+ getAccessToken: k,
806
+ getIdToken: k,
807
+ registeringForPasskey: k,
808
+ loginWithPasskey: k,
785
809
  logoutReason: "",
786
810
  authenticationType: ""
787
811
  }), ht = () => ({
788
- ...Ke(me)
812
+ ...$e(me)
789
813
  }), gt = (e) => S(
790
814
  (...t) => {
791
815
  e && console.info(`==> [Auth ${Date.now()}]: `, ...t);
792
816
  },
793
817
  [e]
794
818
  ), pt = De.createContext({
795
- state: Ee,
819
+ state: ye,
796
820
  dispatch: () => {
797
821
  }
798
822
  }), ft = (e, t) => t?.type === U ? {
@@ -821,14 +845,14 @@ const P = () => {
821
845
  clientId: n,
822
846
  domain: a = "",
823
847
  debug: s = !1,
824
- endpoint: o = rt ? "https://auth.gizmette.local.com:3003" : "https://mylogin.gizmette.com/auth"
848
+ endpoint: i = rt ? "https://auth.gizmette.local.com:3003" : "https://mylogin.gizmette.com/auth"
825
849
  }) => {
826
- const [c, r] = Ye(ft, {
827
- ...Ee,
850
+ const [c, o] = Ye(ft, {
851
+ ...ye,
828
852
  debug: s
829
- }), i = gt(s), w = Ge(!1), [d, m, , y] = Y({
853
+ }), r = gt(s), w = Ge(!1), [d, m, , E] = Y({
830
854
  key: `${G}::${n}::@@user@@`
831
- }), [f, E, , Z] = Y({
855
+ }), [f, y, , Z] = Y({
832
856
  key: `${G}::${n}::@@access@@`
833
857
  }), [Re, W, , ee] = Y(
834
858
  {
@@ -836,39 +860,39 @@ const P = () => {
836
860
  }
837
861
  ), [Ae, te, , ne] = Y({
838
862
  key: `${G}::${n}::@@nonce@@`
839
- }), we = new dt(f, Re), $ = S(() => {
840
- i("removeLocalStorage: removing local storage"), y(), Z(), ee(), ne();
863
+ }), we = new dt(f, Re), K = S(() => {
864
+ r("removeLocalStorage: removing local storage"), E(), Z(), ee(), ne();
841
865
  }, [
842
866
  Z,
843
- y,
867
+ E,
844
868
  ne,
845
869
  ee,
846
- i
870
+ r
847
871
  ]), v = S(
848
872
  (u) => {
849
- i(
873
+ r(
850
874
  "removeStateAndLocalStorage: removing state and local storage with reason: ",
851
875
  u
852
- ), r({
876
+ ), o({
853
877
  type: pe,
854
878
  payload: {
855
879
  logoutReason: u || b
856
880
  }
857
- }), $(), r({ type: U, payload: { isLoading: !1 } });
881
+ }), K(), o({ type: U, payload: { isLoading: !1 } });
858
882
  },
859
- [$, i]
883
+ [K, r]
860
884
  ), I = S(
861
885
  async (u) => {
862
- i("invalidateAndLogout: invalidating and logging out");
886
+ r("invalidateAndLogout: invalidating and logging out");
863
887
  const { user: h } = c, l = h?.userId || ot(d);
864
- l || i(
888
+ l || r(
865
889
  "invalidateAndLogout: user cannot be identified, logging out without userId"
866
890
  ), await it({
867
891
  userId: l,
868
892
  clientId: n,
869
893
  domain: a,
870
894
  idToken: d,
871
- endpoint: o
895
+ endpoint: i
872
896
  }), v(u || b);
873
897
  },
874
898
  [
@@ -877,8 +901,8 @@ const P = () => {
877
901
  n,
878
902
  a,
879
903
  v,
880
- i,
881
- o
904
+ r,
905
+ i
882
906
  ]
883
907
  );
884
908
  ce(() => {
@@ -886,7 +910,7 @@ const P = () => {
886
910
  return c.isLoading && d !== null ? (async () => {
887
911
  try {
888
912
  const u = await D(d);
889
- u && u.payload[T.USER_ID_KEY] !== "" ? (i("useEffect: setting the authentication state"), r({
913
+ u && u.payload[T.USER_ID_KEY] !== "" ? (r("useEffect: setting the authentication state"), o({
890
914
  type: x,
891
915
  payload: {
892
916
  authenticationType: u.payload[T.AUTH_TYPE_KEY],
@@ -896,29 +920,29 @@ const P = () => {
896
920
  email: u.payload[T.EMAIL_KEY]
897
921
  }
898
922
  }
899
- })) : (i("useEffect: invalid JWT, invalidating and logging out"), await I(b));
923
+ })) : (r("useEffect: invalid JWT, invalidating and logging out"), await I(b));
900
924
  } catch {
901
- i(
925
+ r(
902
926
  "useEffect: exception validating JWT, invalidating and logging out"
903
927
  ), await I(b);
904
928
  }
905
- })() : (i("useEffect: setting the loading state to false"), r({ type: U, payload: { isLoading: !1 } })), () => {
929
+ })() : (r("useEffect: setting the loading state to false"), o({ type: U, payload: { isLoading: !1 } })), () => {
906
930
  w.current = !0;
907
931
  };
908
- }, [c.isLoading, d, I, i]);
932
+ }, [c.isLoading, d, I, r]);
909
933
  const Ie = async (u, h) => {
910
- r({ type: U, payload: { isLoading: !0 } }), $();
934
+ o({ type: U, payload: { isLoading: !0 } }), K();
911
935
  const l = z();
912
- te(l), i("login: Logging in with password");
913
- const { code_verifier: _, code_challenge: ke } = await Ue(), ae = await ut({
914
- endpoint: o,
936
+ te(l), r("login: Logging in with password");
937
+ const { code_verifier: _, code_challenge: Pe } = await Ue(), ae = await ut({
938
+ endpoint: i,
915
939
  nonce: l,
916
940
  clientId: n,
917
- code_challenge: ke
941
+ code_challenge: Pe
918
942
  });
919
943
  if (ae.status) {
920
944
  const O = await ct({
921
- endpoint: o,
945
+ endpoint: i,
922
946
  username: u,
923
947
  password: h,
924
948
  clientId: n,
@@ -930,7 +954,7 @@ const P = () => {
930
954
  domain: a,
931
955
  ua: navigator.userAgent
932
956
  });
933
- return O.status ? (m(O.idToken), E(O.accessToken), W(O.refreshToken), r({
957
+ return O.status ? (m(O.idToken), y(O.accessToken), W(O.refreshToken), o({
934
958
  type: x,
935
959
  payload: {
936
960
  authenticationType: C.CODE,
@@ -950,35 +974,35 @@ const P = () => {
950
974
  try {
951
975
  if (u && h && h.userId) {
952
976
  if (f) {
953
- i("getAccessToken");
977
+ r("getAccessToken");
954
978
  const _ = await D(f);
955
979
  if (_ && _.payload[T.USER_ID_KEY] !== "")
956
980
  return f;
957
981
  }
958
- i("getAccessToken: invalid access token, trying to refresh it");
982
+ r("getAccessToken: invalid access token, trying to refresh it");
959
983
  const l = await we.refreshtoken({
960
- endpoint: o,
984
+ endpoint: i,
961
985
  clientId: n,
962
986
  userId: h.userId,
963
987
  nonce: Ae,
964
988
  domain: a
965
989
  });
966
- return l.status && l.status === "success" && l.newAccessToken ? (E(l.newAccessToken), W(l.newRefreshToken), l.newAccessToken) : (i(
990
+ return l.status && l.status === "success" && l.newAccessToken ? (y(l.newAccessToken), W(l.newRefreshToken), l.newAccessToken) : (r(
967
991
  "getAccessToken: invalid refresh token, need to re-authenticate"
968
992
  ), await I(b), "");
969
993
  }
970
- return i(
994
+ return r(
971
995
  "getAccessToken: user is not authenticated, cannot get access token"
972
996
  ), await I(b), "";
973
997
  } catch {
974
- return i(
998
+ return r(
975
999
  "getAccessToken: exception occurred, invalidating and logging out"
976
1000
  ), await I(nt), "";
977
1001
  }
978
1002
  }, Oe = () => c.isAuthenticated && d ? d : "", be = async () => {
979
1003
  const { user: u } = c;
980
- let h = await k({
981
- endpoint: o,
1004
+ let h = await P({
1005
+ endpoint: i,
982
1006
  accessToken: f,
983
1007
  clientId: n,
984
1008
  type: N.GET_REGISTRATION_OPTIONS,
@@ -993,8 +1017,8 @@ const P = () => {
993
1017
  const l = await Je({
994
1018
  optionsJSON: h.data
995
1019
  });
996
- return h = await k({
997
- endpoint: o,
1020
+ return h = await P({
1021
+ endpoint: i,
998
1022
  accessToken: f,
999
1023
  clientId: n,
1000
1024
  type: N.VERIFY_REGISTRATION,
@@ -1006,8 +1030,8 @@ const P = () => {
1006
1030
  }
1007
1031
  }), !!(h.status && h.data.length > 0);
1008
1032
  } catch {
1009
- return await k({
1010
- endpoint: o,
1033
+ return await P({
1034
+ endpoint: i,
1011
1035
  accessToken: f,
1012
1036
  clientId: n,
1013
1037
  type: N.VERIFY_REGISTRATION,
@@ -1021,12 +1045,12 @@ const P = () => {
1021
1045
  }
1022
1046
  return !1;
1023
1047
  }, Ne = async () => {
1024
- r({ type: U, payload: { isLoading: !0 } }), $();
1048
+ o({ type: U, payload: { isLoading: !0 } }), K();
1025
1049
  const u = z();
1026
- te(u), i("loginWithPasskey");
1050
+ te(u), r("loginWithPasskey");
1027
1051
  const h = z();
1028
- let l = await k({
1029
- endpoint: o,
1052
+ let l = await P({
1053
+ endpoint: i,
1030
1054
  accessToken: f,
1031
1055
  clientId: n,
1032
1056
  type: N.GET_AUTHENTICATION_OPTIONS,
@@ -1040,8 +1064,8 @@ const P = () => {
1040
1064
  const _ = await Be({
1041
1065
  optionsJSON: l.data
1042
1066
  });
1043
- return l = await k({
1044
- endpoint: o,
1067
+ return l = await P({
1068
+ endpoint: i,
1045
1069
  accessToken: f,
1046
1070
  clientId: n,
1047
1071
  type: N.VERIFY_AUTHENTICATION,
@@ -1054,7 +1078,7 @@ const P = () => {
1054
1078
  sessionExpiration: t,
1055
1079
  ua: navigator.userAgent
1056
1080
  }
1057
- }), l.data.status === L ? (m(l.data.idToken), E(l.data.accessToken), W(l.data.refreshToken), r({
1081
+ }), l.data.status === L ? (m(l.data.idToken), y(l.data.accessToken), W(l.data.refreshToken), o({
1058
1082
  type: x,
1059
1083
  payload: {
1060
1084
  authenticationType: C.PASSKEY,
@@ -1066,8 +1090,8 @@ const P = () => {
1066
1090
  }
1067
1091
  }), !0) : (v(Q), !1);
1068
1092
  } catch {
1069
- return await k({
1070
- endpoint: o,
1093
+ return await P({
1094
+ endpoint: i,
1071
1095
  accessToken: f,
1072
1096
  clientId: n,
1073
1097
  type: N.VERIFY_AUTHENTICATION,
@@ -1083,7 +1107,7 @@ const P = () => {
1083
1107
  }
1084
1108
  return !1;
1085
1109
  };
1086
- return /* @__PURE__ */ V(pt.Provider, { value: { state: c, dispatch: r }, children: /* @__PURE__ */ V(
1110
+ return /* @__PURE__ */ V(pt.Provider, { value: { state: c, dispatch: o }, children: /* @__PURE__ */ V(
1087
1111
  me.Provider,
1088
1112
  {
1089
1113
  value: {