@versini/auth-provider 8.1.1 → 8.1.2

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,14 @@
1
1
  var ke = Object.defineProperty;
2
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
- import { jsx as V } from "react/jsx-runtime";
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";
3
+ var K = (e, t, n) => Ce(e, typeof t != "symbol" ? t + "" : t, n);
4
+ import { jsx as x } 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";
7
7
  import { AuthHookContext as He } from "./AuthHookContext-C9a2AwWZ.js";
8
- /*!
9
- @versini/auth-provider v8.1.1
10
- © 2025 gizmette.com
11
- */
12
8
  try {
13
9
  window.__VERSINI_AUTH_CLIENT__ || (window.__VERSINI_AUTH_CLIENT__ = {
14
- version: "8.1.1",
15
- buildTime: "11/29/2025 08:06 PM EST",
10
+ version: "8.1.2",
11
+ buildTime: "01/23/2026 08:37 PM EST",
16
12
  homepage: "https://github.com/aversini/auth-client",
17
13
  license: "MIT"
18
14
  });
@@ -25,23 +21,23 @@ function R(e) {
25
21
  n += String.fromCharCode(s);
26
22
  return btoa(n).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
27
23
  }
28
- function M(e) {
24
+ function F(e) {
29
25
  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
26
  for (let o = 0; o < s.length; o++)
31
27
  c[o] = s.charCodeAt(o);
32
28
  return i;
33
29
  }
34
30
  function X() {
35
- return Ve.stubThis(globalThis?.PublicKeyCredential !== void 0 && typeof globalThis.PublicKeyCredential == "function");
31
+ return xe.stubThis(globalThis?.PublicKeyCredential !== void 0 && typeof globalThis.PublicKeyCredential == "function");
36
32
  }
37
- const Ve = {
33
+ const xe = {
38
34
  stubThis: (e) => e
39
35
  };
40
36
  function ue(e) {
41
37
  const { id: t } = e;
42
38
  return {
43
39
  ...e,
44
- id: M(t),
40
+ id: F(t),
45
41
  /**
46
42
  * `descriptor.transports` is an array of our `AuthenticatorTransportFuture` that includes newer
47
43
  * transports that TypeScript's DOM lib is ignorant of. Convince TS that our list of transports
@@ -56,7 +52,7 @@ function le(e) {
56
52
  e === "localhost" || /^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)
57
53
  );
58
54
  }
59
- class p extends Error {
55
+ class f extends Error {
60
56
  constructor({ message: t, code: n, cause: a, name: s }) {
61
57
  super(t, { cause: a }), Object.defineProperty(this, "code", {
62
58
  enumerable: !0,
@@ -66,20 +62,20 @@ class p extends Error {
66
62
  }), this.name = s ?? a.name, this.code = n;
67
63
  }
68
64
  }
69
- function xe({ error: e, options: t }) {
65
+ function Ve({ error: e, options: t }) {
70
66
  const { publicKey: n } = t;
71
67
  if (!n)
72
68
  throw Error("options was missing required publicKey property");
73
69
  if (e.name === "AbortError") {
74
70
  if (t.signal instanceof AbortSignal)
75
- return new p({
71
+ return new f({
76
72
  message: "Registration ceremony was sent an abort signal",
77
73
  code: "ERROR_CEREMONY_ABORTED",
78
74
  cause: e
79
75
  });
80
76
  } else if (e.name === "ConstraintError") {
81
77
  if (n.authenticatorSelection?.requireResidentKey === !0)
82
- return new p({
78
+ return new f({
83
79
  message: "Discoverable credentials were required but no available authenticator supported it",
84
80
  code: "ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",
85
81
  cause: e
@@ -88,36 +84,36 @@ function xe({ error: e, options: t }) {
88
84
  // @ts-ignore: `mediation` doesn't yet exist on CredentialCreationOptions but it's possible as of Sept 2024
89
85
  t.mediation === "conditional" && n.authenticatorSelection?.userVerification === "required"
90
86
  )
91
- return new p({
87
+ return new f({
92
88
  message: "User verification was required during automatic registration but it could not be performed",
93
89
  code: "ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",
94
90
  cause: e
95
91
  });
96
92
  if (n.authenticatorSelection?.userVerification === "required")
97
- return new p({
93
+ return new f({
98
94
  message: "User verification was required but no available authenticator supported it",
99
95
  code: "ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",
100
96
  cause: e
101
97
  });
102
98
  } else {
103
99
  if (e.name === "InvalidStateError")
104
- return new p({
100
+ return new f({
105
101
  message: "The authenticator was previously registered",
106
102
  code: "ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",
107
103
  cause: e
108
104
  });
109
105
  if (e.name === "NotAllowedError")
110
- return new p({
106
+ return new f({
111
107
  message: e.message,
112
108
  code: "ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",
113
109
  cause: e
114
110
  });
115
111
  if (e.name === "NotSupportedError")
116
- return n.pubKeyCredParams.filter((s) => s.type === "public-key").length === 0 ? new p({
112
+ return n.pubKeyCredParams.filter((s) => s.type === "public-key").length === 0 ? new f({
117
113
  message: 'No entry in pubKeyCredParams was of type "public-key"',
118
114
  code: "ERROR_MALFORMED_PUBKEYCREDPARAMS",
119
115
  cause: e
120
- }) : new p({
116
+ }) : new f({
121
117
  message: "No available authenticator supported any of the specified pubKeyCredParams algorithms",
122
118
  code: "ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",
123
119
  cause: e
@@ -126,25 +122,25 @@ function xe({ error: e, options: t }) {
126
122
  const a = globalThis.location.hostname;
127
123
  if (le(a)) {
128
124
  if (n.rp.id !== a)
129
- return new p({
125
+ return new f({
130
126
  message: `The RP ID "${n.rp.id}" is invalid for this domain`,
131
127
  code: "ERROR_INVALID_RP_ID",
132
128
  cause: e
133
129
  });
134
- } else return new p({
130
+ } else return new f({
135
131
  message: `${globalThis.location.hostname} is an invalid domain`,
136
132
  code: "ERROR_INVALID_DOMAIN",
137
133
  cause: e
138
134
  });
139
135
  } else if (e.name === "TypeError") {
140
136
  if (n.user.id.byteLength < 1 || n.user.id.byteLength > 64)
141
- return new p({
137
+ return new f({
142
138
  message: "User ID was not between 1 and 64 characters",
143
139
  code: "ERROR_INVALID_USER_ID_LENGTH",
144
140
  cause: e
145
141
  });
146
142
  } else if (e.name === "UnknownError")
147
- return new p({
143
+ return new f({
148
144
  message: "The authenticator was unable to process the specified options, or could not create a new credential",
149
145
  code: "ERROR_AUTHENTICATOR_GENERAL_ERROR",
150
146
  cause: e
@@ -152,7 +148,7 @@ function xe({ error: e, options: t }) {
152
148
  }
153
149
  return e;
154
150
  }
155
- class Me {
151
+ class Fe {
156
152
  constructor() {
157
153
  Object.defineProperty(this, "controller", {
158
154
  enumerable: !0,
@@ -176,9 +172,9 @@ class Me {
176
172
  }
177
173
  }
178
174
  }
179
- const de = new Me(), Fe = ["cross-platform", "platform"];
175
+ const de = new Fe(), Me = ["cross-platform", "platform"];
180
176
  function he(e) {
181
- if (e && !(Fe.indexOf(e) < 0))
177
+ if (e && !(Me.indexOf(e) < 0))
182
178
  return e;
183
179
  }
184
180
  async function Je(e) {
@@ -188,10 +184,10 @@ async function Je(e) {
188
184
  throw new Error("WebAuthn is not supported in this browser");
189
185
  const a = {
190
186
  ...t,
191
- challenge: M(t.challenge),
187
+ challenge: F(t.challenge),
192
188
  user: {
193
189
  ...t.user,
194
- id: M(t.user.id)
190
+ id: F(t.user.id)
195
191
  },
196
192
  excludeCredentials: t.excludeCredentials?.map(ue)
197
193
  }, s = {};
@@ -200,7 +196,7 @@ async function Je(e) {
200
196
  try {
201
197
  i = await navigator.credentials.create(s);
202
198
  } catch (y) {
203
- throw xe({ error: y, options: s });
199
+ throw Ve({ error: y, options: s });
204
200
  }
205
201
  if (!i)
206
202
  throw new Error("Registration was not completed");
@@ -222,10 +218,10 @@ async function Je(e) {
222
218
  } catch (y) {
223
219
  j("getPublicKey()", y);
224
220
  }
225
- let f;
221
+ let p;
226
222
  if (typeof r.getAuthenticatorData == "function")
227
223
  try {
228
- f = R(r.getAuthenticatorData());
224
+ p = R(r.getAuthenticatorData());
229
225
  } catch (y) {
230
226
  j("getAuthenticatorData()", y);
231
227
  }
@@ -238,7 +234,7 @@ async function Je(e) {
238
234
  transports: d,
239
235
  publicKeyAlgorithm: m,
240
236
  publicKey: E,
241
- authenticatorData: f
237
+ authenticatorData: p
242
238
  },
243
239
  type: w,
244
240
  clientExtensionResults: i.getClientExtensionResults(),
@@ -264,14 +260,14 @@ function je({ error: e, options: t }) {
264
260
  throw Error("options was missing required publicKey property");
265
261
  if (e.name === "AbortError") {
266
262
  if (t.signal instanceof AbortSignal)
267
- return new p({
263
+ return new f({
268
264
  message: "Authentication ceremony was sent an abort signal",
269
265
  code: "ERROR_CEREMONY_ABORTED",
270
266
  cause: e
271
267
  });
272
268
  } else {
273
269
  if (e.name === "NotAllowedError")
274
- return new p({
270
+ return new f({
275
271
  message: e.message,
276
272
  code: "ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",
277
273
  cause: e
@@ -280,18 +276,18 @@ function je({ error: e, options: t }) {
280
276
  const a = globalThis.location.hostname;
281
277
  if (le(a)) {
282
278
  if (n.rpId !== a)
283
- return new p({
279
+ return new f({
284
280
  message: `The RP ID "${n.rpId}" is invalid for this domain`,
285
281
  code: "ERROR_INVALID_RP_ID",
286
282
  cause: e
287
283
  });
288
- } else return new p({
284
+ } else return new f({
289
285
  message: `${globalThis.location.hostname} is an invalid domain`,
290
286
  code: "ERROR_INVALID_DOMAIN",
291
287
  cause: e
292
288
  });
293
289
  } else if (e.name === "UnknownError")
294
- return new p({
290
+ return new f({
295
291
  message: "The authenticator was unable to process the specified options, or could not create a new assertion signature",
296
292
  code: "ERROR_AUTHENTICATOR_GENERAL_ERROR",
297
293
  cause: e
@@ -308,7 +304,7 @@ async function Be(e) {
308
304
  t.allowCredentials?.length !== 0 && (s = t.allowCredentials?.map(ue));
309
305
  const i = {
310
306
  ...t,
311
- challenge: M(t.challenge),
307
+ challenge: F(t.challenge),
312
308
  allowCredentials: s
313
309
  }, c = {};
314
310
  if (n) {
@@ -322,8 +318,8 @@ async function Be(e) {
322
318
  let o;
323
319
  try {
324
320
  o = await navigator.credentials.get(c);
325
- } catch (f) {
326
- throw je({ error: f, options: c });
321
+ } catch (p) {
322
+ throw je({ error: p, options: c });
327
323
  }
328
324
  if (!o)
329
325
  throw new Error("Authentication was not completed");
@@ -343,19 +339,6 @@ async function Be(e) {
343
339
  authenticatorAttachment: he(o.authenticatorAttachment)
344
340
  };
345
341
  }
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
- }
359
342
  function ge(e, t) {
360
343
  window.dispatchEvent(new StorageEvent("storage", {
361
344
  key: e,
@@ -422,16 +405,17 @@ function Ze() {
422
405
  return q(Xe);
423
406
  }
424
407
  const et = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), oe = { randomUUID: et };
425
- function z(e, t, n) {
426
- if (oe.randomUUID && !e)
427
- return oe.randomUUID();
408
+ function tt(e, t, n) {
428
409
  e = e || {};
429
410
  const a = e.random ?? e.rng?.() ?? Ze();
430
411
  if (a.length < 16)
431
412
  throw new Error("Random bytes length must be >= 16");
432
413
  return a[6] = a[6] & 15 | 64, a[8] = a[8] & 63 | 128, Qe(a);
433
414
  }
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 = {
415
+ function z(e, t, n) {
416
+ return oe.randomUUID && !e ? oe.randomUUID() : tt(e);
417
+ }
418
+ const O = "Your session has expired. For your security, please log in again to continue.", nt = "Your session has been successfully terminated.", Q = "Login failed. Please try again.", at = "Error getting access token, please re-authenticate.", st = "You forgot to wrap your component in <AuthProvider>.", G = "@@auth@@", U = "LOADING", V = "LOGIN", fe = "LOGOUT", L = "success", A = "failure", pe = "include", Te = "POST", Ee = "application/json", H = {
435
419
  GET_REGISTRATION_OPTIONS: `mutation GetPasskeyRegistrationOptions(
436
420
  $clientId: String!,
437
421
  $username: String!,
@@ -538,7 +522,7 @@ const b = "Your session has expired. For your security, please log in again to c
538
522
  }) => {
539
523
  try {
540
524
  const i = `Bearer ${e}`, c = await fetch(`${s}/graphql`, {
541
- credentials: fe,
525
+ credentials: pe,
542
526
  method: Te,
543
527
  headers: {
544
528
  authorization: i,
@@ -568,7 +552,7 @@ const b = "Your session has expired. For your security, please log in again to c
568
552
  }) => {
569
553
  try {
570
554
  const s = await fetch(`${a}/${e}`, {
571
- credentials: fe,
555
+ credentials: pe,
572
556
  method: Te,
573
557
  headers: {
574
558
  "Content-Type": Ee,
@@ -586,21 +570,21 @@ const b = "Your session has expired. For your security, please log in again to c
586
570
  } catch (s) {
587
571
  return console.error(s), { status: A, data: [] };
588
572
  }
589
- }, st = process.env.NODE_ENV === "production", rt = !st, ye = {
573
+ }, rt = process.env.NODE_ENV === "production", ot = !rt, ye = {
590
574
  isLoading: !0,
591
575
  isAuthenticated: !1,
592
576
  user: void 0,
593
577
  logoutReason: "",
594
578
  debug: !1,
595
579
  authenticationType: ""
596
- }, ot = (e) => {
580
+ }, it = (e) => {
597
581
  try {
598
582
  const t = ve(e);
599
583
  return t ? t[T.USER_ID_KEY] : "";
600
584
  } catch {
601
585
  return "";
602
586
  }
603
- }, it = async ({
587
+ }, ct = async ({
604
588
  userId: e,
605
589
  clientId: t,
606
590
  domain: n,
@@ -611,7 +595,7 @@ const b = "Your session has expired. For your security, please log in again to c
611
595
  return {
612
596
  status: (await J({
613
597
  endpoint: s,
614
- type: F.LOGOUT,
598
+ type: M.LOGOUT,
615
599
  clientId: t,
616
600
  params: {
617
601
  userId: e,
@@ -625,7 +609,7 @@ const b = "Your session has expired. For your security, please log in again to c
625
609
  status: A
626
610
  };
627
611
  }
628
- }, ct = async ({
612
+ }, ut = async ({
629
613
  username: e,
630
614
  password: t,
631
615
  clientId: n,
@@ -641,7 +625,7 @@ const b = "Your session has expired. For your security, please log in again to c
641
625
  try {
642
626
  const m = await J({
643
627
  endpoint: d,
644
- type: F.LOGIN,
628
+ type: M.LOGIN,
645
629
  clientId: n,
646
630
  params: {
647
631
  type: s || C.ID_AND_ACCESS_TOKEN,
@@ -670,7 +654,7 @@ const b = "Your session has expired. For your security, please log in again to c
670
654
  status: !1
671
655
  };
672
656
  }
673
- }, ut = async ({
657
+ }, lt = async ({
674
658
  nonce: e,
675
659
  clientId: t,
676
660
  code_challenge: n,
@@ -679,7 +663,7 @@ const b = "Your session has expired. For your security, please log in again to c
679
663
  try {
680
664
  const s = await J({
681
665
  endpoint: a,
682
- type: F.CODE,
666
+ type: M.CODE,
683
667
  clientId: t,
684
668
  params: {
685
669
  type: C.CODE,
@@ -700,7 +684,7 @@ const b = "Your session has expired. For your security, please log in again to c
700
684
  data: ""
701
685
  };
702
686
  }
703
- }, lt = async ({
687
+ }, dt = async ({
704
688
  clientId: e,
705
689
  userId: t,
706
690
  nonce: n,
@@ -712,7 +696,7 @@ const b = "Your session has expired. For your security, please log in again to c
712
696
  try {
713
697
  const o = await J({
714
698
  endpoint: c,
715
- type: F.REFRESH,
699
+ type: M.REFRESH,
716
700
  clientId: e,
717
701
  params: {
718
702
  type: C.REFRESH_TOKEN,
@@ -737,11 +721,11 @@ const b = "Your session has expired. For your security, please log in again to c
737
721
  };
738
722
  }
739
723
  };
740
- class dt {
724
+ class ht {
741
725
  constructor(t = null, n = null) {
742
- $(this, "refreshTokenPromise", null);
743
- $(this, "accessToken");
744
- $(this, "refreshToken");
726
+ K(this, "refreshTokenPromise", null);
727
+ K(this, "accessToken");
728
+ K(this, "refreshToken");
745
729
  this.accessToken = t || "", this.refreshToken = n || "";
746
730
  }
747
731
  async refreshtoken({
@@ -773,7 +757,7 @@ class dt {
773
757
  }) {
774
758
  const c = await D(this.refreshToken);
775
759
  if (c && c.payload[T.USER_ID_KEY] !== "") {
776
- const o = await lt({
760
+ const o = await dt({
777
761
  endpoint: t,
778
762
  clientId: n,
779
763
  userId: a,
@@ -796,8 +780,8 @@ class dt {
796
780
  }
797
781
  }
798
782
  const k = () => {
799
- throw new Error(at);
800
- }, me = Ke({
783
+ throw new Error(st);
784
+ }, me = $e({
801
785
  isAuthenticated: !1,
802
786
  isLoading: !1,
803
787
  login: k,
@@ -808,9 +792,9 @@ const k = () => {
808
792
  loginWithPasskey: k,
809
793
  logoutReason: "",
810
794
  authenticationType: ""
811
- }), ht = () => ({
812
- ...$e(me)
813
- }), gt = (e) => S(
795
+ }), gt = () => ({
796
+ ...Ke(me)
797
+ }), ft = (e) => S(
814
798
  (...t) => {
815
799
  e && console.info(`==> [Auth ${Date.now()}]: `, ...t);
816
800
  },
@@ -819,40 +803,40 @@ const k = () => {
819
803
  state: ye,
820
804
  dispatch: () => {
821
805
  }
822
- }), ft = (e, t) => t?.type === U ? {
806
+ }), Tt = (e, t) => t?.type === U ? {
823
807
  ...e,
824
808
  isLoading: t.payload.isLoading
825
- } : t?.type === x ? {
809
+ } : t?.type === V ? {
826
810
  ...e,
827
811
  isLoading: !1,
828
812
  isAuthenticated: !0,
829
813
  user: t.payload.user,
830
814
  authenticationType: t.payload.authenticationType,
831
815
  logoutReason: ""
832
- } : t?.type === pe ? {
816
+ } : t?.type === fe ? {
833
817
  ...e,
834
818
  isLoading: !1,
835
819
  isAuthenticated: !1,
836
820
  user: void 0,
837
821
  authenticationType: "",
838
822
  logoutReason: t.payload.logoutReason
839
- } : e, Tt = ({ children: e }) => {
840
- const t = ht();
841
- return /* @__PURE__ */ V(He.Provider, { value: t, children: e });
842
- }, wt = ({
823
+ } : e, Et = ({ children: e }) => {
824
+ const t = gt();
825
+ return /* @__PURE__ */ x(He.Provider, { value: t, children: e });
826
+ }, It = ({
843
827
  children: e,
844
828
  sessionExpiration: t,
845
829
  clientId: n,
846
830
  domain: a = "",
847
831
  debug: s = !1,
848
- endpoint: i = rt ? "https://auth.gizmette.local.com:3003" : "https://mylogin.gizmette.com/auth"
832
+ endpoint: i = ot ? "https://auth.gizmette.local.com:3003" : "https://mylogin.gizmette.com/auth"
849
833
  }) => {
850
- const [c, o] = Ye(ft, {
834
+ const [c, o] = Ye(Tt, {
851
835
  ...ye,
852
836
  debug: s
853
- }), r = gt(s), w = Ge(!1), [d, m, , E] = Y({
837
+ }), r = ft(s), w = Ge(!1), [d, m, , E] = Y({
854
838
  key: `${G}::${n}::@@user@@`
855
- }), [f, y, , Z] = Y({
839
+ }), [p, y, , Z] = Y({
856
840
  key: `${G}::${n}::@@access@@`
857
841
  }), [Re, W, , ee] = Y(
858
842
  {
@@ -860,7 +844,7 @@ const k = () => {
860
844
  }
861
845
  ), [Ae, te, , ne] = Y({
862
846
  key: `${G}::${n}::@@nonce@@`
863
- }), we = new dt(f, Re), K = S(() => {
847
+ }), we = new ht(p, Re), $ = S(() => {
864
848
  r("removeLocalStorage: removing local storage"), E(), Z(), ee(), ne();
865
849
  }, [
866
850
  Z,
@@ -874,26 +858,26 @@ const k = () => {
874
858
  "removeStateAndLocalStorage: removing state and local storage with reason: ",
875
859
  u
876
860
  ), o({
877
- type: pe,
861
+ type: fe,
878
862
  payload: {
879
- logoutReason: u || b
863
+ logoutReason: u || O
880
864
  }
881
- }), K(), o({ type: U, payload: { isLoading: !1 } });
865
+ }), $(), o({ type: U, payload: { isLoading: !1 } });
882
866
  },
883
- [K, r]
867
+ [$, r]
884
868
  ), I = S(
885
869
  async (u) => {
886
870
  r("invalidateAndLogout: invalidating and logging out");
887
- const { user: h } = c, l = h?.userId || ot(d);
871
+ const { user: h } = c, l = h?.userId || it(d);
888
872
  l || r(
889
873
  "invalidateAndLogout: user cannot be identified, logging out without userId"
890
- ), await it({
874
+ ), await ct({
891
875
  userId: l,
892
876
  clientId: n,
893
877
  domain: a,
894
878
  idToken: d,
895
879
  endpoint: i
896
- }), v(u || b);
880
+ }), v(u || O);
897
881
  },
898
882
  [
899
883
  d,
@@ -911,7 +895,7 @@ const k = () => {
911
895
  try {
912
896
  const u = await D(d);
913
897
  u && u.payload[T.USER_ID_KEY] !== "" ? (r("useEffect: setting the authentication state"), o({
914
- type: x,
898
+ type: V,
915
899
  payload: {
916
900
  authenticationType: u.payload[T.AUTH_TYPE_KEY],
917
901
  user: {
@@ -920,28 +904,28 @@ const k = () => {
920
904
  email: u.payload[T.EMAIL_KEY]
921
905
  }
922
906
  }
923
- })) : (r("useEffect: invalid JWT, invalidating and logging out"), await I(b));
907
+ })) : (r("useEffect: invalid JWT, invalidating and logging out"), await I(O));
924
908
  } catch {
925
909
  r(
926
910
  "useEffect: exception validating JWT, invalidating and logging out"
927
- ), await I(b);
911
+ ), await I(O);
928
912
  }
929
913
  })() : (r("useEffect: setting the loading state to false"), o({ type: U, payload: { isLoading: !1 } })), () => {
930
914
  w.current = !0;
931
915
  };
932
916
  }, [c.isLoading, d, I, r]);
933
917
  const Ie = async (u, h) => {
934
- o({ type: U, payload: { isLoading: !0 } }), K();
918
+ o({ type: U, payload: { isLoading: !0 } }), $();
935
919
  const l = z();
936
920
  te(l), r("login: Logging in with password");
937
- const { code_verifier: _, code_challenge: Pe } = await Ue(), ae = await ut({
921
+ const { code_verifier: _, code_challenge: Pe } = await Ue(), ae = await lt({
938
922
  endpoint: i,
939
923
  nonce: l,
940
924
  clientId: n,
941
925
  code_challenge: Pe
942
926
  });
943
927
  if (ae.status) {
944
- const O = await ct({
928
+ const b = await ut({
945
929
  endpoint: i,
946
930
  username: u,
947
931
  password: h,
@@ -954,30 +938,30 @@ const k = () => {
954
938
  domain: a,
955
939
  ua: navigator.userAgent
956
940
  });
957
- return O.status ? (m(O.idToken), y(O.accessToken), W(O.refreshToken), o({
958
- type: x,
941
+ return b.status ? (m(b.idToken), y(b.accessToken), W(b.refreshToken), o({
942
+ type: V,
959
943
  payload: {
960
944
  authenticationType: C.CODE,
961
945
  user: {
962
- userId: O.userId,
946
+ userId: b.userId,
963
947
  username: u,
964
- email: O.email
948
+ email: b.email
965
949
  }
966
950
  }
967
951
  }), !0) : (v(Q), !1);
968
952
  }
969
953
  return !1;
970
954
  }, _e = async (u) => {
971
- u?.preventDefault(), await I(tt);
955
+ u?.preventDefault(), await I(nt);
972
956
  }, Se = async () => {
973
957
  const { isAuthenticated: u, user: h } = c;
974
958
  try {
975
959
  if (u && h && h.userId) {
976
- if (f) {
960
+ if (p) {
977
961
  r("getAccessToken");
978
- const _ = await D(f);
962
+ const _ = await D(p);
979
963
  if (_ && _.payload[T.USER_ID_KEY] !== "")
980
- return f;
964
+ return p;
981
965
  }
982
966
  r("getAccessToken: invalid access token, trying to refresh it");
983
967
  const l = await we.refreshtoken({
@@ -989,21 +973,21 @@ const k = () => {
989
973
  });
990
974
  return l.status && l.status === "success" && l.newAccessToken ? (y(l.newAccessToken), W(l.newRefreshToken), l.newAccessToken) : (r(
991
975
  "getAccessToken: invalid refresh token, need to re-authenticate"
992
- ), await I(b), "");
976
+ ), await I(O), "");
993
977
  }
994
978
  return r(
995
979
  "getAccessToken: user is not authenticated, cannot get access token"
996
- ), await I(b), "";
980
+ ), await I(O), "";
997
981
  } catch {
998
982
  return r(
999
983
  "getAccessToken: exception occurred, invalidating and logging out"
1000
- ), await I(nt), "";
984
+ ), await I(at), "";
1001
985
  }
1002
- }, Oe = () => c.isAuthenticated && d ? d : "", be = async () => {
986
+ }, be = () => c.isAuthenticated && d ? d : "", Oe = async () => {
1003
987
  const { user: u } = c;
1004
988
  let h = await P({
1005
989
  endpoint: i,
1006
- accessToken: f,
990
+ accessToken: p,
1007
991
  clientId: n,
1008
992
  type: N.GET_REGISTRATION_OPTIONS,
1009
993
  params: {
@@ -1019,7 +1003,7 @@ const k = () => {
1019
1003
  });
1020
1004
  return h = await P({
1021
1005
  endpoint: i,
1022
- accessToken: f,
1006
+ accessToken: p,
1023
1007
  clientId: n,
1024
1008
  type: N.VERIFY_REGISTRATION,
1025
1009
  params: {
@@ -1032,7 +1016,7 @@ const k = () => {
1032
1016
  } catch {
1033
1017
  return await P({
1034
1018
  endpoint: i,
1035
- accessToken: f,
1019
+ accessToken: p,
1036
1020
  clientId: n,
1037
1021
  type: N.VERIFY_REGISTRATION,
1038
1022
  params: {
@@ -1045,13 +1029,13 @@ const k = () => {
1045
1029
  }
1046
1030
  return !1;
1047
1031
  }, Ne = async () => {
1048
- o({ type: U, payload: { isLoading: !0 } }), K();
1032
+ o({ type: U, payload: { isLoading: !0 } }), $();
1049
1033
  const u = z();
1050
1034
  te(u), r("loginWithPasskey");
1051
1035
  const h = z();
1052
1036
  let l = await P({
1053
1037
  endpoint: i,
1054
- accessToken: f,
1038
+ accessToken: p,
1055
1039
  clientId: n,
1056
1040
  type: N.GET_AUTHENTICATION_OPTIONS,
1057
1041
  params: {
@@ -1066,7 +1050,7 @@ const k = () => {
1066
1050
  });
1067
1051
  return l = await P({
1068
1052
  endpoint: i,
1069
- accessToken: f,
1053
+ accessToken: p,
1070
1054
  clientId: n,
1071
1055
  type: N.VERIFY_AUTHENTICATION,
1072
1056
  params: {
@@ -1079,7 +1063,7 @@ const k = () => {
1079
1063
  ua: navigator.userAgent
1080
1064
  }
1081
1065
  }), l.data.status === L ? (m(l.data.idToken), y(l.data.accessToken), W(l.data.refreshToken), o({
1082
- type: x,
1066
+ type: V,
1083
1067
  payload: {
1084
1068
  authenticationType: C.PASSKEY,
1085
1069
  user: {
@@ -1092,7 +1076,7 @@ const k = () => {
1092
1076
  } catch {
1093
1077
  return await P({
1094
1078
  endpoint: i,
1095
- accessToken: f,
1079
+ accessToken: p,
1096
1080
  clientId: n,
1097
1081
  type: N.VERIFY_AUTHENTICATION,
1098
1082
  params: {
@@ -1107,7 +1091,7 @@ const k = () => {
1107
1091
  }
1108
1092
  return !1;
1109
1093
  };
1110
- return /* @__PURE__ */ V(pt.Provider, { value: { state: c, dispatch: o }, children: /* @__PURE__ */ V(
1094
+ return /* @__PURE__ */ x(pt.Provider, { value: { state: c, dispatch: o }, children: /* @__PURE__ */ x(
1111
1095
  me.Provider,
1112
1096
  {
1113
1097
  value: {
@@ -1115,14 +1099,14 @@ const k = () => {
1115
1099
  login: Ie,
1116
1100
  logout: _e,
1117
1101
  getAccessToken: Se,
1118
- getIdToken: Oe,
1119
- registeringForPasskey: be,
1102
+ getIdToken: be,
1103
+ registeringForPasskey: Oe,
1120
1104
  loginWithPasskey: Ne
1121
1105
  },
1122
- children: /* @__PURE__ */ V(Tt, { children: e })
1106
+ children: /* @__PURE__ */ x(Et, { children: e })
1123
1107
  }
1124
1108
  ) });
1125
1109
  };
1126
1110
  export {
1127
- wt as AuthProvider
1111
+ It as AuthProvider
1128
1112
  };
package/dist/hooks.js CHANGED
@@ -1,13 +1,9 @@
1
1
  import { useContext as o } from "react";
2
2
  import { AuthHookContext as e } from "./AuthHookContext-C9a2AwWZ.js";
3
- /*!
4
- @versini/auth-provider v8.1.1
5
- © 2025 gizmette.com
6
- */
7
3
  try {
8
4
  window.__VERSINI_AUTH_CLIENT__ || (window.__VERSINI_AUTH_CLIENT__ = {
9
- version: "8.1.1",
10
- buildTime: "11/29/2025 08:06 PM EST",
5
+ version: "8.1.2",
6
+ buildTime: "01/23/2026 08:37 PM EST",
11
7
  homepage: "https://github.com/aversini/auth-client",
12
8
  license: "MIT"
13
9
  });
package/dist/index.js CHANGED
@@ -1,12 +1,8 @@
1
1
  import { AUTH_TYPES as r, isGranted as t } from "@versini/auth-common";
2
- /*!
3
- @versini/auth-provider v8.1.1
4
- © 2025 gizmette.com
5
- */
6
2
  try {
7
3
  window.__VERSINI_AUTH_CLIENT__ || (window.__VERSINI_AUTH_CLIENT__ = {
8
- version: "8.1.1",
9
- buildTime: "11/29/2025 08:06 PM EST",
4
+ version: "8.1.2",
5
+ buildTime: "01/23/2026 08:37 PM EST",
10
6
  homepage: "https://github.com/aversini/auth-client",
11
7
  license: "MIT"
12
8
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versini/auth-provider",
3
- "version": "8.1.1",
3
+ "version": "8.1.2",
4
4
  "license": "MIT",
5
5
  "author": "Arno Versini",
6
6
  "publishConfig": {
@@ -46,16 +46,12 @@
46
46
  "test:watch": "vitest",
47
47
  "test": "vitest run"
48
48
  },
49
- "peerDependencies": {
50
- "react": ">=19.0.0",
51
- "react-dom": ">=19.0.0"
52
- },
53
49
  "dependencies": {
54
50
  "@simplewebauthn/browser": "13.2.2",
55
- "@versini/auth-common": "4.6.1",
56
- "@versini/ui-hooks": "5.2.0",
57
- "jose": "6.1.2",
58
- "uuid": "11.1.0"
51
+ "@versini/auth-common": "4.6.2",
52
+ "@versini/ui-hooks": "6.1.1",
53
+ "jose": "6.1.3",
54
+ "uuid": "13.0.0"
59
55
  },
60
- "gitHead": "f9cc50d9cfb4b7ac832410455a02bb7c65cf82a3"
56
+ "gitHead": "78e93181feacb67a6de1628448ae7a22fddfdf34"
61
57
  }