@versini/auth-provider 5.0.6 → 5.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/index.d.ts CHANGED
@@ -7,6 +7,7 @@ type AuthProviderProps = {
7
7
  sessionExpiration?: string;
8
8
  clientId: string;
9
9
  accessType?: string;
10
+ domain?: string;
10
11
  };
11
12
 
12
13
  type AuthState = {
@@ -32,7 +33,7 @@ type AuthContextProps = {
32
33
  getIdToken: () => string;
33
34
  } & AuthState;
34
35
 
35
- declare const AuthProvider: ({ children, sessionExpiration, clientId, }: AuthProviderProps) => react_jsx_runtime.JSX.Element;
36
+ declare const AuthProvider: ({ children, sessionExpiration, clientId, domain, }: AuthProviderProps) => react_jsx_runtime.JSX.Element;
36
37
 
37
38
  declare const useAuth: (context?: react.Context<AuthContextProps>) => AuthContextProps;
38
39
 
package/dist/index.js CHANGED
@@ -1,51 +1,51 @@
1
- var Me = Object.defineProperty;
2
- var Ve = (e, t, r) => t in e ? Me(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var L = (e, t, r) => (Ve(e, typeof t != "symbol" ? t + "" : t, r), r);
4
- import { jsx as Ye } from "react/jsx-runtime";
1
+ var Ve = Object.defineProperty;
2
+ var Ye = (e, t, r) => t in e ? Ve(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var N = (e, t, r) => (Ye(e, typeof t != "symbol" ? t + "" : t, r), r);
4
+ import { jsx as Be } from "react/jsx-runtime";
5
5
  import * as U from "react";
6
- import { createContext as Be, useRef as Fe, useState as Ge, useCallback as de, useEffect as qe, useContext as ze } from "react";
6
+ import { createContext as Fe, useRef as Ge, useState as qe, useCallback as le, useEffect as ze, useContext as Xe } from "react";
7
7
  /*!
8
- @versini/auth-provider v5.0.6
8
+ @versini/auth-provider v5.1.1
9
9
  © 2024 gizmette.com
10
10
  */
11
11
  try {
12
12
  window.__VERSINI_AUTH_CLIENT__ || (window.__VERSINI_AUTH_CLIENT__ = {
13
- version: "5.0.6",
14
- buildTime: "07/06/2024 03:39 PM EDT",
13
+ version: "5.1.1",
14
+ buildTime: "07/07/2024 10:59 AM EDT",
15
15
  homepage: "https://github.com/aversini/auth-client",
16
16
  license: "MIT"
17
17
  });
18
18
  } catch {
19
19
  }
20
20
  /*!
21
- @versini/auth-common v2.10.1
21
+ @versini/auth-common v2.11.0
22
22
  © 2024 gizmette.com
23
23
  */
24
24
  try {
25
25
  window.__VERSINI_AUTH_COMMON__ || (window.__VERSINI_AUTH_COMMON__ = {
26
- version: "2.10.1",
27
- buildTime: "07/06/2024 03:39 PM EDT",
26
+ version: "2.11.0",
27
+ buildTime: "07/07/2024 10:59 AM EDT",
28
28
  homepage: "https://github.com/aversini/auth-client",
29
29
  license: "MIT"
30
30
  });
31
31
  } catch {
32
32
  }
33
- const q = {
33
+ const G = {
34
34
  ID_TOKEN: "id_token",
35
35
  ACCESS_TOKEN: "token",
36
36
  ID_AND_ACCESS_TOKEN: "id_token token",
37
37
  CODE: "code",
38
38
  REFRESH_TOKEN: "refresh_token"
39
- }, Xe = {
39
+ }, Qe = {
40
40
  CLIENT_ID: "X-Auth-ClientId"
41
- }, y = {
41
+ }, w = {
42
42
  ALG: "RS256",
43
43
  USER_ID_KEY: "sub",
44
44
  TOKEN_ID_KEY: "__raw",
45
45
  NONCE_KEY: "_nonce",
46
46
  USERNAME_KEY: "username",
47
47
  ISSUER: "gizmette.com"
48
- }, Qe = `-----BEGIN PUBLIC KEY-----
48
+ }, Ze = `-----BEGIN PUBLIC KEY-----
49
49
  MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsF6i3Jd9fY/3COqCw/m7
50
50
  w5PKyTYLGAI2I6SIIdpe6i6DOCbEkmDz7LdVsBqwNtVi8gvWYIj+8ol6rU3qu1v5
51
51
  i1Jd45GSK4kzkVdgCmQZbM5ak0KI99q5wsrAIzUd+LRJ2HRvWtr5IYdsIiXaQjle
@@ -53,28 +53,28 @@ aMwPFOIcJH+rKfFgNcHLcaS5syp7zU1ANwZ+trgR+DifBr8TLVkBynmNeTyhDm2+
53
53
  l0haqjMk0UoNPPE8iYBWUHQJJE1Dqstj65d6Eh5g64Pao25y4cmYJbKjiblIGEkE
54
54
  sjqybA9mARAqh9k/eiIopecWSiffNQTwVQVd2I9ZH3BalhEXHlqFgrjz51kFqg81
55
55
  awIDAQAB
56
- -----END PUBLIC KEY-----`, z = {
56
+ -----END PUBLIC KEY-----`, q = {
57
57
  AUTHENTICATE: "authenticate",
58
58
  CODE: "code",
59
59
  LOGOUT: "logout"
60
- }, X = crypto, _e = (e) => e instanceof CryptoKey, $ = new TextEncoder(), Q = new TextDecoder();
61
- function Ze(...e) {
60
+ }, z = crypto, ve = (e) => e instanceof CryptoKey, L = new TextEncoder(), X = new TextDecoder();
61
+ function et(...e) {
62
62
  const t = e.reduce((n, { length: s }) => n + s, 0), r = new Uint8Array(t);
63
63
  let a = 0;
64
64
  for (const n of e)
65
65
  r.set(n, a), a += n.length;
66
66
  return r;
67
67
  }
68
- const et = (e) => {
68
+ const tt = (e) => {
69
69
  const t = atob(e), r = new Uint8Array(t.length);
70
70
  for (let a = 0; a < t.length; a++)
71
71
  r[a] = t.charCodeAt(a);
72
72
  return r;
73
- }, B = (e) => {
73
+ }, Y = (e) => {
74
74
  let t = e;
75
- t instanceof Uint8Array && (t = Q.decode(t)), t = t.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "");
75
+ t instanceof Uint8Array && (t = X.decode(t)), t = t.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "");
76
76
  try {
77
- return et(t);
77
+ return tt(t);
78
78
  } catch {
79
79
  throw new TypeError("The input to be decoded is not correctly encoded.");
80
80
  }
@@ -96,7 +96,7 @@ class A extends C {
96
96
  super(t), this.code = "ERR_JWT_CLAIM_VALIDATION_FAILED", this.claim = a, this.reason = n, this.payload = r;
97
97
  }
98
98
  }
99
- class le extends C {
99
+ class he extends C {
100
100
  static get code() {
101
101
  return "ERR_JWT_EXPIRED";
102
102
  }
@@ -104,7 +104,7 @@ class le extends C {
104
104
  super(t), this.code = "ERR_JWT_EXPIRED", this.claim = a, this.reason = n, this.payload = r;
105
105
  }
106
106
  }
107
- class tt extends C {
107
+ class rt extends C {
108
108
  constructor() {
109
109
  super(...arguments), this.code = "ERR_JOSE_ALG_NOT_ALLOWED";
110
110
  }
@@ -127,7 +127,7 @@ let _ = class extends C {
127
127
  return "ERR_JWS_INVALID";
128
128
  }
129
129
  };
130
- class ve extends C {
130
+ class Re extends C {
131
131
  constructor() {
132
132
  super(...arguments), this.code = "ERR_JWT_INVALID";
133
133
  }
@@ -135,7 +135,7 @@ class ve extends C {
135
135
  return "ERR_JWT_INVALID";
136
136
  }
137
137
  }
138
- class rt extends C {
138
+ class at extends C {
139
139
  constructor() {
140
140
  super(...arguments), this.code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED", this.message = "signature verification failed";
141
141
  }
@@ -146,13 +146,13 @@ class rt extends C {
146
146
  function T(e, t = "algorithm.name") {
147
147
  return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`);
148
148
  }
149
- function W(e, t) {
149
+ function $(e, t) {
150
150
  return e.name === t;
151
151
  }
152
152
  function te(e) {
153
153
  return parseInt(e.name.slice(4), 10);
154
154
  }
155
- function at(e) {
155
+ function nt(e) {
156
156
  switch (e) {
157
157
  case "ES256":
158
158
  return "P-256";
@@ -164,7 +164,7 @@ function at(e) {
164
164
  throw new Error("unreachable");
165
165
  }
166
166
  }
167
- function nt(e, t) {
167
+ function st(e, t) {
168
168
  if (t.length && !t.some((r) => e.usages.includes(r))) {
169
169
  let r = "CryptoKey does not support this operation, its usages must include ";
170
170
  if (t.length > 2) {
@@ -175,12 +175,12 @@ function nt(e, t) {
175
175
  throw new TypeError(r);
176
176
  }
177
177
  }
178
- function st(e, t, ...r) {
178
+ function ot(e, t, ...r) {
179
179
  switch (t) {
180
180
  case "HS256":
181
181
  case "HS384":
182
182
  case "HS512": {
183
- if (!W(e.algorithm, "HMAC"))
183
+ if (!$(e.algorithm, "HMAC"))
184
184
  throw T("HMAC");
185
185
  const a = parseInt(t.slice(2), 10);
186
186
  if (te(e.algorithm.hash) !== a)
@@ -190,7 +190,7 @@ function st(e, t, ...r) {
190
190
  case "RS256":
191
191
  case "RS384":
192
192
  case "RS512": {
193
- if (!W(e.algorithm, "RSASSA-PKCS1-v1_5"))
193
+ if (!$(e.algorithm, "RSASSA-PKCS1-v1_5"))
194
194
  throw T("RSASSA-PKCS1-v1_5");
195
195
  const a = parseInt(t.slice(2), 10);
196
196
  if (te(e.algorithm.hash) !== a)
@@ -200,7 +200,7 @@ function st(e, t, ...r) {
200
200
  case "PS256":
201
201
  case "PS384":
202
202
  case "PS512": {
203
- if (!W(e.algorithm, "RSA-PSS"))
203
+ if (!$(e.algorithm, "RSA-PSS"))
204
204
  throw T("RSA-PSS");
205
205
  const a = parseInt(t.slice(2), 10);
206
206
  if (te(e.algorithm.hash) !== a)
@@ -215,9 +215,9 @@ function st(e, t, ...r) {
215
215
  case "ES256":
216
216
  case "ES384":
217
217
  case "ES512": {
218
- if (!W(e.algorithm, "ECDSA"))
218
+ if (!$(e.algorithm, "ECDSA"))
219
219
  throw T("ECDSA");
220
- const a = at(t);
220
+ const a = nt(t);
221
221
  if (e.algorithm.namedCurve !== a)
222
222
  throw T(a, "algorithm.namedCurve");
223
223
  break;
@@ -225,9 +225,9 @@ function st(e, t, ...r) {
225
225
  default:
226
226
  throw new TypeError("CryptoKey does not support this operation");
227
227
  }
228
- nt(e, r);
228
+ st(e, r);
229
229
  }
230
- function Re(e, t, ...r) {
230
+ function Ie(e, t, ...r) {
231
231
  var a;
232
232
  if (r.length > 2) {
233
233
  const n = r.pop();
@@ -236,11 +236,11 @@ function Re(e, t, ...r) {
236
236
  r.length === 2 ? e += `one of type ${r[0]} or ${r[1]}.` : e += `of type ${r[0]}.`;
237
237
  return t == null ? e += ` Received ${t}` : typeof t == "function" && t.name ? e += ` Received function ${t.name}` : typeof t == "object" && t != null && (a = t.constructor) != null && a.name && (e += ` Received an instance of ${t.constructor.name}`), e;
238
238
  }
239
- const he = (e, ...t) => Re("Key must be ", e, ...t);
240
- function Ie(e, t, ...r) {
241
- return Re(`Key for the ${e} algorithm must be `, t, ...r);
239
+ const fe = (e, ...t) => Ie("Key must be ", e, ...t);
240
+ function Ce(e, t, ...r) {
241
+ return Ie(`Key for the ${e} algorithm must be `, t, ...r);
242
242
  }
243
- const Ce = (e) => _e(e) ? !0 : (e == null ? void 0 : e[Symbol.toStringTag]) === "KeyObject", G = ["CryptoKey"], ot = (...e) => {
243
+ const Pe = (e) => ve(e) ? !0 : (e == null ? void 0 : e[Symbol.toStringTag]) === "KeyObject", F = ["CryptoKey"], it = (...e) => {
244
244
  const t = e.filter(Boolean);
245
245
  if (t.length === 0 || t.length === 1)
246
246
  return !0;
@@ -259,11 +259,11 @@ const Ce = (e) => _e(e) ? !0 : (e == null ? void 0 : e[Symbol.toStringTag]) ===
259
259
  }
260
260
  return !0;
261
261
  };
262
- function it(e) {
262
+ function ct(e) {
263
263
  return typeof e == "object" && e !== null;
264
264
  }
265
265
  function ie(e) {
266
- if (!it(e) || Object.prototype.toString.call(e) !== "[object Object]")
266
+ if (!ct(e) || Object.prototype.toString.call(e) !== "[object Object]")
267
267
  return !1;
268
268
  if (Object.getPrototypeOf(e) === null)
269
269
  return !0;
@@ -272,14 +272,14 @@ function ie(e) {
272
272
  t = Object.getPrototypeOf(t);
273
273
  return Object.getPrototypeOf(e) === t;
274
274
  }
275
- const ct = (e, t) => {
275
+ const ut = (e, t) => {
276
276
  if (e.startsWith("RS") || e.startsWith("PS")) {
277
277
  const { modulusLength: r } = t.algorithm;
278
278
  if (typeof r != "number" || r < 2048)
279
279
  throw new TypeError(`${e} requires key modulusLength to be 2048 bits or larger`);
280
280
  }
281
281
  };
282
- function ut(e) {
282
+ function dt(e) {
283
283
  let t, r;
284
284
  switch (e.kty) {
285
285
  case "RSA": {
@@ -351,43 +351,43 @@ function ut(e) {
351
351
  }
352
352
  return { algorithm: t, keyUsages: r };
353
353
  }
354
- const dt = async (e) => {
354
+ const lt = async (e) => {
355
355
  if (!e.alg)
356
356
  throw new TypeError('"alg" argument is required when "jwk.alg" is not present');
357
- const { algorithm: t, keyUsages: r } = ut(e), a = [
357
+ const { algorithm: t, keyUsages: r } = dt(e), a = [
358
358
  t,
359
359
  e.ext ?? !1,
360
360
  e.key_ops ?? r
361
361
  ], n = { ...e };
362
- return delete n.alg, delete n.use, X.subtle.importKey("jwk", n, ...a);
363
- }, Pe = (e) => B(e);
362
+ return delete n.alg, delete n.use, z.subtle.importKey("jwk", n, ...a);
363
+ }, Oe = (e) => Y(e);
364
364
  let re, ae;
365
- const Oe = (e) => (e == null ? void 0 : e[Symbol.toStringTag]) === "KeyObject", De = async (e, t, r, a) => {
365
+ const De = (e) => (e == null ? void 0 : e[Symbol.toStringTag]) === "KeyObject", Ue = async (e, t, r, a) => {
366
366
  let n = e.get(t);
367
367
  if (n != null && n[a])
368
368
  return n[a];
369
- const s = await dt({ ...r, alg: a });
369
+ const s = await lt({ ...r, alg: a });
370
370
  return n ? n[a] = s : e.set(t, { [a]: s }), s;
371
- }, lt = (e, t) => {
372
- if (Oe(e)) {
371
+ }, ht = (e, t) => {
372
+ if (De(e)) {
373
373
  let r = e.export({ format: "jwk" });
374
- return delete r.d, delete r.dp, delete r.dq, delete r.p, delete r.q, delete r.qi, r.k ? Pe(r.k) : (ae || (ae = /* @__PURE__ */ new WeakMap()), De(ae, e, r, t));
374
+ return delete r.d, delete r.dp, delete r.dq, delete r.p, delete r.q, delete r.qi, r.k ? Oe(r.k) : (ae || (ae = /* @__PURE__ */ new WeakMap()), Ue(ae, e, r, t));
375
375
  }
376
376
  return e;
377
- }, ht = (e, t) => {
378
- if (Oe(e)) {
377
+ }, ft = (e, t) => {
378
+ if (De(e)) {
379
379
  let r = e.export({ format: "jwk" });
380
- return r.k ? Pe(r.k) : (re || (re = /* @__PURE__ */ new WeakMap()), De(re, e, r, t));
380
+ return r.k ? Oe(r.k) : (re || (re = /* @__PURE__ */ new WeakMap()), Ue(re, e, r, t));
381
381
  }
382
382
  return e;
383
- }, ft = { normalizePublicKey: lt, normalizePrivateKey: ht }, b = (e, t, r = 0) => {
383
+ }, pt = { normalizePublicKey: ht, normalizePrivateKey: ft }, b = (e, t, r = 0) => {
384
384
  r === 0 && (t.unshift(t.length), t.unshift(6));
385
385
  const a = e.indexOf(t[0], r);
386
386
  if (a === -1)
387
387
  return !1;
388
388
  const n = e.subarray(a, a + t.length);
389
389
  return n.length !== t.length ? !1 : n.every((s, o) => s === t[o]) || b(e, t, a + 1);
390
- }, fe = (e) => {
390
+ }, pe = (e) => {
391
391
  switch (!0) {
392
392
  case b(e, [42, 134, 72, 206, 61, 3, 1, 7]):
393
393
  return "P-256";
@@ -406,7 +406,7 @@ const Oe = (e) => (e == null ? void 0 : e[Symbol.toStringTag]) === "KeyObject",
406
406
  default:
407
407
  throw new _("Invalid or unsupported EC Key Curve or OKP Key Sub Type");
408
408
  }
409
- }, pt = async (e, t, r, a, n) => {
409
+ }, yt = async (e, t, r, a, n) => {
410
410
  let s, o;
411
411
  const i = new Uint8Array(atob(r.replace(e, "")).split("").map((c) => c.charCodeAt(0)));
412
412
  switch (a) {
@@ -442,43 +442,43 @@ const Oe = (e) => (e == null ? void 0 : e[Symbol.toStringTag]) === "KeyObject",
442
442
  case "ECDH-ES+A128KW":
443
443
  case "ECDH-ES+A192KW":
444
444
  case "ECDH-ES+A256KW": {
445
- const c = fe(i);
445
+ const c = pe(i);
446
446
  s = c.startsWith("P-") ? { name: "ECDH", namedCurve: c } : { name: c }, o = [];
447
447
  break;
448
448
  }
449
449
  case "EdDSA":
450
- s = { name: fe(i) }, o = ["verify"];
450
+ s = { name: pe(i) }, o = ["verify"];
451
451
  break;
452
452
  default:
453
453
  throw new _('Invalid or unsupported "alg" (Algorithm) value');
454
454
  }
455
- return X.subtle.importKey(t, i, s, !1, o);
456
- }, yt = (e, t, r) => pt(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g, "spki", e, t);
455
+ return z.subtle.importKey(t, i, s, !1, o);
456
+ }, wt = (e, t, r) => yt(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g, "spki", e, t);
457
457
  async function mt(e, t, r) {
458
458
  if (e.indexOf("-----BEGIN PUBLIC KEY-----") !== 0)
459
459
  throw new TypeError('"spki" must be SPKI formatted string');
460
- return yt(e, t);
460
+ return wt(e, t);
461
461
  }
462
- const F = (e) => e == null ? void 0 : e[Symbol.toStringTag], wt = (e, t) => {
462
+ const B = (e) => e == null ? void 0 : e[Symbol.toStringTag], Et = (e, t) => {
463
463
  if (!(t instanceof Uint8Array)) {
464
- if (!Ce(t))
465
- throw new TypeError(Ie(e, t, ...G, "Uint8Array"));
464
+ if (!Pe(t))
465
+ throw new TypeError(Ce(e, t, ...F, "Uint8Array"));
466
466
  if (t.type !== "secret")
467
- throw new TypeError(`${F(t)} instances for symmetric algorithms must be of type "secret"`);
467
+ throw new TypeError(`${B(t)} instances for symmetric algorithms must be of type "secret"`);
468
468
  }
469
- }, Et = (e, t, r) => {
470
- if (!Ce(t))
471
- throw new TypeError(Ie(e, t, ...G));
469
+ }, St = (e, t, r) => {
470
+ if (!Pe(t))
471
+ throw new TypeError(Ce(e, t, ...F));
472
472
  if (t.type === "secret")
473
- throw new TypeError(`${F(t)} instances for asymmetric algorithms must not be of type "secret"`);
473
+ throw new TypeError(`${B(t)} instances for asymmetric algorithms must not be of type "secret"`);
474
474
  if (t.algorithm && r === "verify" && t.type === "private")
475
- throw new TypeError(`${F(t)} instances for asymmetric algorithm verifying must be of type "public"`);
475
+ throw new TypeError(`${B(t)} instances for asymmetric algorithm verifying must be of type "public"`);
476
476
  if (t.algorithm && r === "encrypt" && t.type === "private")
477
- throw new TypeError(`${F(t)} instances for asymmetric algorithm encryption must be of type "public"`);
478
- }, St = (e, t, r) => {
479
- e.startsWith("HS") || e === "dir" || e.startsWith("PBES2") || /^A\d{3}(?:GCM)?KW$/.test(e) ? wt(e, t) : Et(e, t, r);
477
+ throw new TypeError(`${B(t)} instances for asymmetric algorithm encryption must be of type "public"`);
478
+ }, gt = (e, t, r) => {
479
+ e.startsWith("HS") || e === "dir" || e.startsWith("PBES2") || /^A\d{3}(?:GCM)?KW$/.test(e) ? Et(e, t) : St(e, t, r);
480
480
  };
481
- function gt(e, t, r, a, n) {
481
+ function At(e, t, r, a, n) {
482
482
  if (n.crit !== void 0 && (a == null ? void 0 : a.crit) === void 0)
483
483
  throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');
484
484
  if (!a || a.crit === void 0)
@@ -497,13 +497,13 @@ function gt(e, t, r, a, n) {
497
497
  }
498
498
  return new Set(a.crit);
499
499
  }
500
- const At = (e, t) => {
500
+ const Tt = (e, t) => {
501
501
  if (t !== void 0 && (!Array.isArray(t) || t.some((r) => typeof r != "string")))
502
502
  throw new TypeError(`"${e}" option must be an array of strings`);
503
503
  if (t)
504
504
  return new Set(t);
505
505
  };
506
- function Tt(e, t) {
506
+ function kt(e, t) {
507
507
  const r = `SHA-${e.slice(-3)}`;
508
508
  switch (e) {
509
509
  case "HS256":
@@ -528,27 +528,27 @@ function Tt(e, t) {
528
528
  throw new _(`alg ${e} is not supported either by JOSE or your javascript runtime`);
529
529
  }
530
530
  }
531
- async function kt(e, t, r) {
532
- if (t = await ft.normalizePublicKey(t, e), _e(t))
533
- return st(t, e, r), t;
531
+ async function bt(e, t, r) {
532
+ if (t = await pt.normalizePublicKey(t, e), ve(t))
533
+ return ot(t, e, r), t;
534
534
  if (t instanceof Uint8Array) {
535
535
  if (!e.startsWith("HS"))
536
- throw new TypeError(he(t, ...G));
537
- return X.subtle.importKey("raw", t, { hash: `SHA-${e.slice(-3)}`, name: "HMAC" }, !1, [r]);
536
+ throw new TypeError(fe(t, ...F));
537
+ return z.subtle.importKey("raw", t, { hash: `SHA-${e.slice(-3)}`, name: "HMAC" }, !1, [r]);
538
538
  }
539
- throw new TypeError(he(t, ...G, "Uint8Array"));
539
+ throw new TypeError(fe(t, ...F, "Uint8Array"));
540
540
  }
541
- const bt = async (e, t, r, a) => {
542
- const n = await kt(e, t, "verify");
543
- ct(e, n);
544
- const s = Tt(e, n.algorithm);
541
+ const _t = async (e, t, r, a) => {
542
+ const n = await bt(e, t, "verify");
543
+ ut(e, n);
544
+ const s = kt(e, n.algorithm);
545
545
  try {
546
- return await X.subtle.verify(s, n, r, a);
546
+ return await z.subtle.verify(s, n, r, a);
547
547
  } catch {
548
548
  return !1;
549
549
  }
550
550
  };
551
- async function _t(e, t, r) {
551
+ async function vt(e, t, r) {
552
552
  if (!ie(e))
553
553
  throw new f("Flattened JWS must be an object");
554
554
  if (e.protected === void 0 && e.header === void 0)
@@ -564,65 +564,65 @@ async function _t(e, t, r) {
564
564
  let a = {};
565
565
  if (e.protected)
566
566
  try {
567
- const S = B(e.protected);
568
- a = JSON.parse(Q.decode(S));
567
+ const S = Y(e.protected);
568
+ a = JSON.parse(X.decode(S));
569
569
  } catch {
570
570
  throw new f("JWS Protected Header is invalid");
571
571
  }
572
- if (!ot(a, e.header))
572
+ if (!it(a, e.header))
573
573
  throw new f("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
574
574
  const n = {
575
575
  ...a,
576
576
  ...e.header
577
- }, s = gt(f, /* @__PURE__ */ new Map([["b64", !0]]), r == null ? void 0 : r.crit, a, n);
577
+ }, s = At(f, /* @__PURE__ */ new Map([["b64", !0]]), r == null ? void 0 : r.crit, a, n);
578
578
  let o = !0;
579
579
  if (s.has("b64") && (o = a.b64, typeof o != "boolean"))
580
580
  throw new f('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
581
581
  const { alg: i } = n;
582
582
  if (typeof i != "string" || !i)
583
583
  throw new f('JWS "alg" (Algorithm) Header Parameter missing or invalid');
584
- const c = r && At("algorithms", r.algorithms);
584
+ const c = r && Tt("algorithms", r.algorithms);
585
585
  if (c && !c.has(i))
586
- throw new tt('"alg" (Algorithm) Header Parameter value not allowed');
586
+ throw new rt('"alg" (Algorithm) Header Parameter value not allowed');
587
587
  if (o) {
588
588
  if (typeof e.payload != "string")
589
589
  throw new f("JWS Payload must be a string");
590
590
  } else if (typeof e.payload != "string" && !(e.payload instanceof Uint8Array))
591
591
  throw new f("JWS Payload must be a string or an Uint8Array instance");
592
592
  let d = !1;
593
- typeof t == "function" && (t = await t(a, e), d = !0), St(i, t, "verify");
594
- const m = Ze($.encode(e.protected ?? ""), $.encode("."), typeof e.payload == "string" ? $.encode(e.payload) : e.payload);
595
- let p;
593
+ typeof t == "function" && (t = await t(a, e), d = !0), gt(i, t, "verify");
594
+ const p = et(L.encode(e.protected ?? ""), L.encode("."), typeof e.payload == "string" ? L.encode(e.payload) : e.payload);
595
+ let y;
596
596
  try {
597
- p = B(e.signature);
597
+ y = Y(e.signature);
598
598
  } catch {
599
599
  throw new f("Failed to base64url decode the signature");
600
600
  }
601
- if (!await bt(i, t, p, m))
602
- throw new rt();
603
- let w;
601
+ if (!await _t(i, t, y, p))
602
+ throw new at();
603
+ let E;
604
604
  if (o)
605
605
  try {
606
- w = B(e.payload);
606
+ E = Y(e.payload);
607
607
  } catch {
608
608
  throw new f("Failed to base64url decode the payload");
609
609
  }
610
610
  else
611
- typeof e.payload == "string" ? w = $.encode(e.payload) : w = e.payload;
612
- const E = { payload: w };
613
- return e.protected !== void 0 && (E.protectedHeader = a), e.header !== void 0 && (E.unprotectedHeader = e.header), d ? { ...E, key: t } : E;
611
+ typeof e.payload == "string" ? E = L.encode(e.payload) : E = e.payload;
612
+ const m = { payload: E };
613
+ return e.protected !== void 0 && (m.protectedHeader = a), e.header !== void 0 && (m.unprotectedHeader = e.header), d ? { ...m, key: t } : m;
614
614
  }
615
- async function vt(e, t, r) {
616
- if (e instanceof Uint8Array && (e = Q.decode(e)), typeof e != "string")
615
+ async function Rt(e, t, r) {
616
+ if (e instanceof Uint8Array && (e = X.decode(e)), typeof e != "string")
617
617
  throw new f("Compact JWS must be a string or Uint8Array");
618
618
  const { 0: a, 1: n, 2: s, length: o } = e.split(".");
619
619
  if (o !== 3)
620
620
  throw new f("Invalid Compact JWS");
621
- const i = await _t({ payload: n, protected: a, signature: s }, t, r), c = { payload: i.payload, protectedHeader: i.protectedHeader };
621
+ const i = await vt({ payload: n, protected: a, signature: s }, t, r), c = { payload: i.payload, protectedHeader: i.protectedHeader };
622
622
  return typeof t == "function" ? { ...c, key: i.key } : c;
623
623
  }
624
- const Rt = (e) => Math.floor(e.getTime() / 1e3), Ue = 60, He = Ue * 60, ce = He * 24, It = ce * 7, Ct = ce * 365.25, Pt = /^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i, pe = (e) => {
625
- const t = Pt.exec(e);
624
+ const It = (e) => Math.floor(e.getTime() / 1e3), He = 60, Ke = He * 60, ce = Ke * 24, Ct = ce * 7, Pt = ce * 365.25, Ot = /^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i, ye = (e) => {
625
+ const t = Ot.exec(e);
626
626
  if (!t || t[4] && t[1])
627
627
  throw new TypeError("Invalid time period format");
628
628
  const r = parseFloat(t[2]), a = t[3].toLowerCase();
@@ -640,14 +640,14 @@ const Rt = (e) => Math.floor(e.getTime() / 1e3), Ue = 60, He = Ue * 60, ce = He
640
640
  case "min":
641
641
  case "mins":
642
642
  case "m":
643
- n = Math.round(r * Ue);
643
+ n = Math.round(r * He);
644
644
  break;
645
645
  case "hour":
646
646
  case "hours":
647
647
  case "hr":
648
648
  case "hrs":
649
649
  case "h":
650
- n = Math.round(r * He);
650
+ n = Math.round(r * Ke);
651
651
  break;
652
652
  case "day":
653
653
  case "days":
@@ -657,86 +657,86 @@ const Rt = (e) => Math.floor(e.getTime() / 1e3), Ue = 60, He = Ue * 60, ce = He
657
657
  case "week":
658
658
  case "weeks":
659
659
  case "w":
660
- n = Math.round(r * It);
660
+ n = Math.round(r * Ct);
661
661
  break;
662
662
  default:
663
- n = Math.round(r * Ct);
663
+ n = Math.round(r * Pt);
664
664
  break;
665
665
  }
666
666
  return t[1] === "-" || t[4] === "ago" ? -n : n;
667
- }, ye = (e) => e.toLowerCase().replace(/^application\//, ""), Ot = (e, t) => typeof e == "string" ? t.includes(e) : Array.isArray(e) ? t.some(Set.prototype.has.bind(new Set(e))) : !1, Dt = (e, t, r = {}) => {
667
+ }, we = (e) => e.toLowerCase().replace(/^application\//, ""), Dt = (e, t) => typeof e == "string" ? t.includes(e) : Array.isArray(e) ? t.some(Set.prototype.has.bind(new Set(e))) : !1, Ut = (e, t, r = {}) => {
668
668
  let a;
669
669
  try {
670
- a = JSON.parse(Q.decode(t));
670
+ a = JSON.parse(X.decode(t));
671
671
  } catch {
672
672
  }
673
673
  if (!ie(a))
674
- throw new ve("JWT Claims Set must be a top-level JSON object");
674
+ throw new Re("JWT Claims Set must be a top-level JSON object");
675
675
  const { typ: n } = r;
676
- if (n && (typeof e.typ != "string" || ye(e.typ) !== ye(n)))
676
+ if (n && (typeof e.typ != "string" || we(e.typ) !== we(n)))
677
677
  throw new A('unexpected "typ" JWT header value', a, "typ", "check_failed");
678
- const { requiredClaims: s = [], issuer: o, subject: i, audience: c, maxTokenAge: d } = r, m = [...s];
679
- d !== void 0 && m.push("iat"), c !== void 0 && m.push("aud"), i !== void 0 && m.push("sub"), o !== void 0 && m.push("iss");
680
- for (const S of new Set(m.reverse()))
678
+ const { requiredClaims: s = [], issuer: o, subject: i, audience: c, maxTokenAge: d } = r, p = [...s];
679
+ d !== void 0 && p.push("iat"), c !== void 0 && p.push("aud"), i !== void 0 && p.push("sub"), o !== void 0 && p.push("iss");
680
+ for (const S of new Set(p.reverse()))
681
681
  if (!(S in a))
682
682
  throw new A(`missing required "${S}" claim`, a, S, "missing");
683
683
  if (o && !(Array.isArray(o) ? o : [o]).includes(a.iss))
684
684
  throw new A('unexpected "iss" claim value', a, "iss", "check_failed");
685
685
  if (i && a.sub !== i)
686
686
  throw new A('unexpected "sub" claim value', a, "sub", "check_failed");
687
- if (c && !Ot(a.aud, typeof c == "string" ? [c] : c))
687
+ if (c && !Dt(a.aud, typeof c == "string" ? [c] : c))
688
688
  throw new A('unexpected "aud" claim value', a, "aud", "check_failed");
689
- let p;
689
+ let y;
690
690
  switch (typeof r.clockTolerance) {
691
691
  case "string":
692
- p = pe(r.clockTolerance);
692
+ y = ye(r.clockTolerance);
693
693
  break;
694
694
  case "number":
695
- p = r.clockTolerance;
695
+ y = r.clockTolerance;
696
696
  break;
697
697
  case "undefined":
698
- p = 0;
698
+ y = 0;
699
699
  break;
700
700
  default:
701
701
  throw new TypeError("Invalid clockTolerance option type");
702
702
  }
703
- const { currentDate: w } = r, E = Rt(w || /* @__PURE__ */ new Date());
703
+ const { currentDate: E } = r, m = It(E || /* @__PURE__ */ new Date());
704
704
  if ((a.iat !== void 0 || d) && typeof a.iat != "number")
705
705
  throw new A('"iat" claim must be a number', a, "iat", "invalid");
706
706
  if (a.nbf !== void 0) {
707
707
  if (typeof a.nbf != "number")
708
708
  throw new A('"nbf" claim must be a number', a, "nbf", "invalid");
709
- if (a.nbf > E + p)
709
+ if (a.nbf > m + y)
710
710
  throw new A('"nbf" claim timestamp check failed', a, "nbf", "check_failed");
711
711
  }
712
712
  if (a.exp !== void 0) {
713
713
  if (typeof a.exp != "number")
714
714
  throw new A('"exp" claim must be a number', a, "exp", "invalid");
715
- if (a.exp <= E - p)
716
- throw new le('"exp" claim timestamp check failed', a, "exp", "check_failed");
715
+ if (a.exp <= m - y)
716
+ throw new he('"exp" claim timestamp check failed', a, "exp", "check_failed");
717
717
  }
718
718
  if (d) {
719
- const S = E - a.iat, K = typeof d == "number" ? d : pe(d);
720
- if (S - p > K)
721
- throw new le('"iat" claim timestamp check failed (too far in the past)', a, "iat", "check_failed");
722
- if (S < 0 - p)
719
+ const S = m - a.iat, Z = typeof d == "number" ? d : ye(d);
720
+ if (S - y > Z)
721
+ throw new he('"iat" claim timestamp check failed (too far in the past)', a, "iat", "check_failed");
722
+ if (S < 0 - y)
723
723
  throw new A('"iat" claim timestamp check failed (it should be in the past)', a, "iat", "check_failed");
724
724
  }
725
725
  return a;
726
726
  };
727
- async function Ut(e, t, r) {
727
+ async function Ht(e, t, r) {
728
728
  var a;
729
- const n = await vt(e, t, r);
729
+ const n = await Rt(e, t, r);
730
730
  if ((a = n.protectedHeader.crit) != null && a.includes("b64") && n.protectedHeader.b64 === !1)
731
- throw new ve("JWTs MUST NOT use unencoded payload");
732
- const s = { payload: Dt(n.protectedHeader, n.payload, r), protectedHeader: n.protectedHeader };
731
+ throw new Re("JWTs MUST NOT use unencoded payload");
732
+ const s = { payload: Ut(n.protectedHeader, n.payload, r), protectedHeader: n.protectedHeader };
733
733
  return typeof t == "function" ? { ...s, key: n.key } : s;
734
734
  }
735
735
  const H = async (e) => {
736
736
  try {
737
- const t = y.ALG, r = await mt(Qe, t);
738
- return await Ut(e, r, {
739
- issuer: y.ISSUER
737
+ const t = w.ALG, r = await mt(Ze, t);
738
+ return await Ht(e, r, {
739
+ issuer: w.ISSUER
740
740
  });
741
741
  } catch {
742
742
  return;
@@ -745,67 +745,67 @@ const H = async (e) => {
745
745
  var l = [];
746
746
  for (var ne = 0; ne < 256; ++ne)
747
747
  l.push((ne + 256).toString(16).slice(1));
748
- function Ht(e, t = 0) {
748
+ function Kt(e, t = 0) {
749
749
  return (l[e[t + 0]] + l[e[t + 1]] + l[e[t + 2]] + l[e[t + 3]] + "-" + l[e[t + 4]] + l[e[t + 5]] + "-" + l[e[t + 6]] + l[e[t + 7]] + "-" + l[e[t + 8]] + l[e[t + 9]] + "-" + l[e[t + 10]] + l[e[t + 11]] + l[e[t + 12]] + l[e[t + 13]] + l[e[t + 14]] + l[e[t + 15]]).toLowerCase();
750
750
  }
751
- var J, Kt = new Uint8Array(16);
752
- function Nt() {
753
- if (!J && (J = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !J))
751
+ var W, Nt = new Uint8Array(16);
752
+ function Lt() {
753
+ if (!W && (W = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !W))
754
754
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
755
- return J(Kt);
755
+ return W(Nt);
756
756
  }
757
- var Lt = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
757
+ var $t = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
758
758
  const me = {
759
- randomUUID: Lt
759
+ randomUUID: $t
760
760
  };
761
- function we(e, t, r) {
761
+ function Ee(e, t, r) {
762
762
  if (me.randomUUID && !t && !e)
763
763
  return me.randomUUID();
764
764
  e = e || {};
765
- var a = e.random || (e.rng || Nt)();
766
- return a[6] = a[6] & 15 | 64, a[8] = a[8] & 63 | 128, Ht(a);
765
+ var a = e.random || (e.rng || Lt)();
766
+ return a[6] = a[6] & 15 | 64, a[8] = a[8] & 63 | 128, Kt(a);
767
767
  }
768
- const Ee = globalThis.crypto, $t = (e) => `${we()}${we()}`.slice(0, e), Wt = (e) => btoa(
768
+ const Se = globalThis.crypto, Wt = (e) => `${Ee()}${Ee()}`.slice(0, e), Jt = (e) => btoa(
769
769
  [...new Uint8Array(e)].map((t) => String.fromCharCode(t)).join("")
770
770
  );
771
- async function Jt(e) {
772
- if (!Ee.subtle)
771
+ async function xt(e) {
772
+ if (!Se.subtle)
773
773
  throw new Error(
774
774
  "crypto.subtle is available only in secure contexts (HTTPS)."
775
775
  );
776
- const t = new TextEncoder().encode(e), r = await Ee.subtle.digest("SHA-256", t);
777
- return Wt(r).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
776
+ const t = new TextEncoder().encode(e), r = await Se.subtle.digest("SHA-256", t);
777
+ return Jt(r).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
778
778
  }
779
- async function xt(e) {
780
- const r = $t(43), a = await Jt(r);
779
+ async function jt(e) {
780
+ const r = Wt(43), a = await xt(r);
781
781
  return {
782
782
  code_verifier: r,
783
783
  code_challenge: a
784
784
  };
785
785
  }
786
- function Ke(e, t) {
786
+ function Ne(e, t) {
787
787
  window.dispatchEvent(new StorageEvent("storage", { key: e, newValue: t }));
788
788
  }
789
- const Se = (e, t) => {
789
+ const ge = (e, t) => {
790
790
  const r = JSON.stringify(
791
791
  typeof t == "function" ? t() : t
792
792
  );
793
- window.localStorage.setItem(e, r), Ke(e, r);
794
- }, jt = (e) => {
795
- window.localStorage.removeItem(e), Ke(e, null);
796
- }, ge = (e) => window.localStorage.getItem(e), Mt = (e) => (window.addEventListener("storage", e), () => window.removeEventListener("storage", e));
797
- function x({
793
+ window.localStorage.setItem(e, r), Ne(e, r);
794
+ }, Mt = (e) => {
795
+ window.localStorage.removeItem(e), Ne(e, null);
796
+ }, Ae = (e) => window.localStorage.getItem(e), Vt = (e) => (window.addEventListener("storage", e), () => window.removeEventListener("storage", e));
797
+ function J({
798
798
  key: e,
799
799
  initialValue: t
800
800
  }) {
801
- const r = () => ge(e), a = U.useSyncExternalStore(
802
- Mt,
801
+ const r = () => Ae(e), a = U.useSyncExternalStore(
802
+ Vt,
803
803
  r
804
804
  ), n = U.useCallback(
805
805
  (i) => {
806
806
  try {
807
807
  const c = typeof i == "function" ? i(JSON.parse(a)) : i;
808
- c == null ? jt(e) : Se(e, c);
808
+ c == null ? Mt(e) : ge(e, c);
809
809
  } catch (c) {
810
810
  console.warn(c);
811
811
  }
@@ -818,7 +818,7 @@ function x({
818
818
  }, [n]);
819
819
  return U.useEffect(() => {
820
820
  try {
821
- ge(e) === null && typeof t < "u" && Se(e, t);
821
+ Ae(e) === null && typeof t < "u" && ge(e, t);
822
822
  } catch (i) {
823
823
  console.warn(i);
824
824
  }
@@ -827,43 +827,43 @@ function x({
827
827
  var h = [];
828
828
  for (var se = 0; se < 256; ++se)
829
829
  h.push((se + 256).toString(16).slice(1));
830
- function Vt(e, t = 0) {
830
+ function Yt(e, t = 0) {
831
831
  return (h[e[t + 0]] + h[e[t + 1]] + h[e[t + 2]] + h[e[t + 3]] + "-" + h[e[t + 4]] + h[e[t + 5]] + "-" + h[e[t + 6]] + h[e[t + 7]] + "-" + h[e[t + 8]] + h[e[t + 9]] + "-" + h[e[t + 10]] + h[e[t + 11]] + h[e[t + 12]] + h[e[t + 13]] + h[e[t + 14]] + h[e[t + 15]]).toLowerCase();
832
832
  }
833
- var j, Yt = new Uint8Array(16);
834
- function Bt() {
835
- if (!j && (j = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !j))
833
+ var x, Bt = new Uint8Array(16);
834
+ function Ft() {
835
+ if (!x && (x = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !x))
836
836
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
837
- return j(Yt);
837
+ return x(Bt);
838
838
  }
839
- var Ft = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
840
- const Ae = {
841
- randomUUID: Ft
839
+ var Gt = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
840
+ const Te = {
841
+ randomUUID: Gt
842
842
  };
843
- function Gt(e, t, r) {
844
- if (Ae.randomUUID && !t && !e)
845
- return Ae.randomUUID();
843
+ function qt(e, t, r) {
844
+ if (Te.randomUUID && !t && !e)
845
+ return Te.randomUUID();
846
846
  e = e || {};
847
- var a = e.random || (e.rng || Bt)();
848
- return a[6] = a[6] & 15 | 64, a[8] = a[8] & 63 | 128, Vt(a);
847
+ var a = e.random || (e.rng || Ft)();
848
+ return a[6] = a[6] & 15 | 64, a[8] = a[8] & 63 | 128, Yt(a);
849
849
  }
850
- const M = "Oops! It looks like your session has expired. For your security, please log in again to continue.", qt = "Your session has been successfully terminated.", Te = "Login failed. Please try again.", oe = "Error getting access token, please re-authenticate.", zt = "You forgot to wrap your component in <AuthProvider>.", ke = {
850
+ const j = "Oops! It looks like your session has expired. For your security, please log in again to continue.", zt = "Your session has been successfully terminated.", ke = "Login failed. Please try again.", oe = "Error getting access token, please re-authenticate.", Xt = "You forgot to wrap your component in <AuthProvider>.", be = {
851
851
  dev: "https://auth.gizmette.local.com:3003",
852
852
  prod: "https://mylogin.gizmette.com"
853
- }, V = "@@auth@@", Xt = process.env.NODE_ENV === "production", Qt = !Xt, Z = async ({
853
+ }, M = "@@auth@@", Qt = process.env.NODE_ENV === "production", Zt = !Qt, Q = async ({
854
854
  type: e,
855
855
  clientId: t,
856
856
  params: r = {}
857
857
  }) => {
858
858
  try {
859
859
  const a = await fetch(
860
- Qt ? `${ke.dev}/${e}` : `${ke.prod}/${e}`,
860
+ Zt ? `${be.dev}/${e}` : `${be.prod}/${e}`,
861
861
  {
862
862
  credentials: "include",
863
863
  method: "POST",
864
864
  headers: {
865
865
  "Content-Type": "application/json",
866
- [Xe.CLIENT_ID]: `${t}`
866
+ [Qe.CLIENT_ID]: `${t}`
867
867
  },
868
868
  body: JSON.stringify(r)
869
869
  }
@@ -879,21 +879,23 @@ const M = "Oops! It looks like your session has expired. For your security, plea
879
879
  } catch (a) {
880
880
  return console.error(a), { status: 500, data: [] };
881
881
  }
882
- }, Zt = async ({
882
+ }, er = async ({
883
883
  idToken: e,
884
884
  accessToken: t,
885
885
  refreshToken: r,
886
- clientId: a
886
+ clientId: a,
887
+ domain: n
887
888
  }) => {
888
889
  try {
889
890
  return {
890
- status: (await Z({
891
- type: z.LOGOUT,
891
+ status: (await Q({
892
+ type: q.LOGOUT,
892
893
  clientId: a,
893
894
  params: {
894
895
  idToken: e,
895
896
  accessToken: t,
896
- refreshToken: r
897
+ refreshToken: r,
898
+ domain: n
897
899
  }
898
900
  })).status === 200
899
901
  };
@@ -902,7 +904,7 @@ const M = "Oops! It looks like your session has expired. For your security, plea
902
904
  status: !1
903
905
  };
904
906
  }
905
- }, be = async ({
907
+ }, _e = async ({
906
908
  username: e,
907
909
  password: t,
908
910
  clientId: r,
@@ -910,27 +912,29 @@ const M = "Oops! It looks like your session has expired. For your security, plea
910
912
  type: n,
911
913
  sessionExpiration: s,
912
914
  code: o,
913
- code_verifier: i
915
+ code_verifier: i,
916
+ domain: c
914
917
  }) => {
915
918
  try {
916
- const c = await Z({
917
- type: z.AUTHENTICATE,
919
+ const d = await Q({
920
+ type: q.AUTHENTICATE,
918
921
  clientId: r,
919
922
  params: {
920
- type: n || q.ID_AND_ACCESS_TOKEN,
923
+ type: n || G.ID_AND_ACCESS_TOKEN,
921
924
  username: e,
922
925
  password: t,
923
926
  sessionExpiration: s,
924
927
  nonce: a,
925
928
  code: o,
926
- code_verifier: i
929
+ code_verifier: i,
930
+ domain: c
927
931
  }
928
- }), d = await H(c.data.idToken);
929
- return d && d.payload[y.USER_ID_KEY] !== "" && d.payload[y.NONCE_KEY] === a ? {
930
- idToken: c.data.idToken,
931
- accessToken: c.data.accessToken,
932
- refreshToken: c.data.refreshToken,
933
- userId: d.payload[y.USER_ID_KEY],
932
+ }), p = await H(d.data.idToken);
933
+ return p && p.payload[w.USER_ID_KEY] !== "" && p.payload[w.NONCE_KEY] === a ? {
934
+ idToken: d.data.idToken,
935
+ accessToken: d.data.accessToken,
936
+ refreshToken: d.data.refreshToken,
937
+ userId: p.payload[w.USER_ID_KEY],
934
938
  status: !0
935
939
  } : {
936
940
  status: !1
@@ -940,17 +944,17 @@ const M = "Oops! It looks like your session has expired. For your security, plea
940
944
  status: !1
941
945
  };
942
946
  }
943
- }, er = async ({
947
+ }, tr = async ({
944
948
  nonce: e,
945
949
  clientId: t,
946
950
  code_challenge: r
947
951
  }) => {
948
952
  try {
949
- const a = await Z({
950
- type: z.CODE,
953
+ const a = await Q({
954
+ type: q.CODE,
951
955
  clientId: t,
952
956
  params: {
953
- type: q.CODE,
957
+ type: G.CODE,
954
958
  nonce: e,
955
959
  code_challenge: r
956
960
  }
@@ -966,29 +970,31 @@ const M = "Oops! It looks like your session has expired. For your security, plea
966
970
  status: !1
967
971
  };
968
972
  }
969
- }, tr = async ({
973
+ }, rr = async ({
970
974
  clientId: e,
971
975
  userId: t,
972
976
  nonce: r,
973
977
  refreshToken: a,
974
- accessToken: n
978
+ accessToken: n,
979
+ domain: s
975
980
  }) => {
976
981
  try {
977
- const s = await Z({
978
- type: z.AUTHENTICATE,
982
+ const o = await Q({
983
+ type: q.AUTHENTICATE,
979
984
  clientId: e,
980
985
  params: {
981
- type: q.REFRESH_TOKEN,
986
+ type: G.REFRESH_TOKEN,
982
987
  userId: t,
983
988
  nonce: r,
984
989
  refreshToken: a,
985
- accessToken: n
990
+ accessToken: n,
991
+ domain: s
986
992
  }
987
- }), o = await H(s.data.accessToken);
988
- return o && o.payload[y.USER_ID_KEY] !== "" && o.payload[y.NONCE_KEY] === r ? {
989
- accessToken: s.data.accessToken,
990
- refreshToken: s.data.refreshToken,
991
- userId: o.payload[y.USER_ID_KEY],
993
+ }), i = await H(o.data.accessToken);
994
+ return i && i.payload[w.USER_ID_KEY] !== "" && i.payload[w.NONCE_KEY] === r ? {
995
+ accessToken: o.data.accessToken,
996
+ refreshToken: o.data.refreshToken,
997
+ userId: i.payload[w.USER_ID_KEY],
992
998
  status: !0
993
999
  } : {
994
1000
  status: !1
@@ -999,22 +1005,24 @@ const M = "Oops! It looks like your session has expired. For your security, plea
999
1005
  };
1000
1006
  }
1001
1007
  };
1002
- class rr {
1008
+ class ar {
1003
1009
  constructor(t = null, r = null) {
1004
- L(this, "refreshTokenPromise", null);
1005
- L(this, "accessToken");
1006
- L(this, "refreshToken");
1010
+ N(this, "refreshTokenPromise", null);
1011
+ N(this, "accessToken");
1012
+ N(this, "refreshToken");
1007
1013
  this.accessToken = t || "", this.refreshToken = r || "";
1008
1014
  }
1009
1015
  async refreshtoken({
1010
1016
  clientId: t,
1011
1017
  userId: r,
1012
- nonce: a
1018
+ nonce: a,
1019
+ domain: n
1013
1020
  }) {
1014
1021
  this.refreshTokenPromise || (this.refreshTokenPromise = this._refreshToken({
1015
1022
  clientId: t,
1016
1023
  userId: r,
1017
- nonce: a
1024
+ nonce: a,
1025
+ domain: n
1018
1026
  }));
1019
1027
  try {
1020
1028
  return await this.refreshTokenPromise;
@@ -1025,21 +1033,23 @@ class rr {
1025
1033
  async _refreshToken({
1026
1034
  clientId: t,
1027
1035
  userId: r,
1028
- nonce: a
1036
+ nonce: a,
1037
+ domain: n
1029
1038
  }) {
1030
- const n = await H(this.refreshToken);
1031
- if (n && n.payload[y.USER_ID_KEY] !== "") {
1032
- const s = await tr({
1039
+ const s = await H(this.refreshToken);
1040
+ if (s && s.payload[w.USER_ID_KEY] !== "") {
1041
+ const o = await rr({
1033
1042
  clientId: t,
1034
1043
  userId: r,
1035
1044
  nonce: a,
1036
1045
  refreshToken: this.refreshToken,
1037
- accessToken: this.accessToken
1046
+ accessToken: this.accessToken,
1047
+ domain: n
1038
1048
  });
1039
- return s.status ? (this.accessToken = s.accessToken, this.refreshToken = s.refreshToken, {
1049
+ return o.status ? (this.accessToken = o.accessToken, this.refreshToken = o.refreshToken, {
1040
1050
  status: "success",
1041
- newAccessToken: s.accessToken,
1042
- newRefreshToken: s.refreshToken
1051
+ newAccessToken: o.accessToken,
1052
+ newRefreshToken: o.refreshToken
1043
1053
  }) : {
1044
1054
  status: "failure"
1045
1055
  };
@@ -1049,107 +1059,117 @@ class rr {
1049
1059
  };
1050
1060
  }
1051
1061
  }
1052
- const Y = () => {
1053
- throw new Error(zt);
1054
- }, Ne = Be({
1062
+ const V = () => {
1063
+ throw new Error(Xt);
1064
+ }, Le = Fe({
1055
1065
  isAuthenticated: !1,
1056
1066
  isLoading: !1,
1057
- login: Y,
1058
- logout: Y,
1059
- getAccessToken: Y,
1060
- getIdToken: Y,
1067
+ login: V,
1068
+ logout: V,
1069
+ getAccessToken: V,
1070
+ getIdToken: V,
1061
1071
  logoutReason: ""
1062
- }), cr = ({
1072
+ }), ur = ({
1063
1073
  children: e,
1064
1074
  sessionExpiration: t,
1065
- clientId: r
1075
+ clientId: r,
1076
+ domain: a = ""
1066
1077
  }) => {
1067
- const a = Fe(!1), [n, s, , o] = x({
1068
- key: `${V}::${r}::@@user@@`
1069
- }), [i, c, , d] = x({
1070
- key: `${V}::${r}::@@access@@`
1071
- }), [m, p, , w] = x(
1078
+ const n = Ge(!1), [s, o, , i] = J({
1079
+ key: `${M}::${r}::@@user@@`
1080
+ }), [c, d, , p] = J({
1081
+ key: `${M}::${r}::@@access@@`
1082
+ }), [y, E, , m] = J(
1072
1083
  {
1073
- key: `${V}::${r}::@@refresh@@`
1084
+ key: `${M}::${r}::@@refresh@@`
1074
1085
  }
1075
- ), [E, S, , K] = x({
1076
- key: `${V}::${r}::@@nonce@@`
1077
- }), Le = new rr(i, m), [P, v] = Ge({
1086
+ ), [S, Z, , ue] = J({
1087
+ key: `${M}::${r}::@@nonce@@`
1088
+ }), $e = new ar(c, y), [P, v] = qe({
1078
1089
  isLoading: !0,
1079
1090
  isAuthenticated: !1,
1080
1091
  user: void 0,
1081
1092
  logoutReason: ""
1082
- }), N = de(
1093
+ }), K = le(
1083
1094
  (u) => {
1084
1095
  console.warn(u), v({
1085
1096
  isLoading: !0,
1086
1097
  isAuthenticated: !1,
1087
1098
  user: void 0,
1088
- logoutReason: u || M
1089
- }), o(), d(), w(), K();
1099
+ logoutReason: u || j
1100
+ }), i(), p(), m(), ue();
1090
1101
  },
1091
- [o, d, K, w]
1092
- ), R = de(
1102
+ [p, i, ue, m]
1103
+ ), R = le(
1093
1104
  async (u) => {
1094
- N(u || M), await Zt({
1095
- idToken: n,
1096
- accessToken: i,
1097
- refreshToken: m,
1098
- clientId: r
1105
+ K(u || j), await er({
1106
+ idToken: s,
1107
+ accessToken: c,
1108
+ refreshToken: y,
1109
+ clientId: r,
1110
+ domain: a
1099
1111
  }), v((k) => ({
1100
1112
  ...k,
1101
1113
  isLoading: !1
1102
1114
  }));
1103
1115
  },
1104
- [i, r, n, N, m]
1116
+ [
1117
+ c,
1118
+ r,
1119
+ a,
1120
+ s,
1121
+ y,
1122
+ K
1123
+ ]
1105
1124
  );
1106
- qe(() => {
1107
- if (!a.current)
1108
- return P.isLoading && n !== null ? (async () => {
1125
+ ze(() => {
1126
+ if (!n.current)
1127
+ return P.isLoading && s !== null ? (async () => {
1109
1128
  try {
1110
- const u = await H(n);
1111
- u && u.payload[y.USER_ID_KEY] !== "" ? v({
1129
+ const u = await H(s);
1130
+ u && u.payload[w.USER_ID_KEY] !== "" ? v({
1112
1131
  isLoading: !1,
1113
1132
  isAuthenticated: !0,
1114
1133
  user: {
1115
- userId: u.payload[y.USER_ID_KEY],
1116
- username: u.payload[y.USERNAME_KEY]
1134
+ userId: u.payload[w.USER_ID_KEY],
1135
+ username: u.payload[w.USERNAME_KEY]
1117
1136
  },
1118
1137
  logoutReason: ""
1119
- }) : await R(M);
1138
+ }) : await R(j);
1120
1139
  } catch {
1121
- await R(M);
1140
+ await R(j);
1122
1141
  }
1123
1142
  })() : v((u) => ({
1124
1143
  ...u,
1125
1144
  isLoading: !1
1126
1145
  })), () => {
1127
- a.current = !0;
1146
+ n.current = !0;
1128
1147
  };
1129
- }, [P.isLoading, n, R]);
1130
- const $e = async (u, k, g) => {
1131
- const I = Gt();
1132
- if (S(I), v((ee) => ({
1148
+ }, [P.isLoading, s, R]);
1149
+ const We = async (u, k, g) => {
1150
+ const I = qt();
1151
+ if (Z(I), v((ee) => ({
1133
1152
  ...ee,
1134
1153
  isLoading: !0
1135
- })), o(), d(), w(), g === q.CODE) {
1136
- const { code_verifier: ee, code_challenge: je } = await xt(), ue = await er({
1154
+ })), i(), p(), m(), g === G.CODE) {
1155
+ const { code_verifier: ee, code_challenge: Me } = await jt(), de = await tr({
1137
1156
  nonce: I,
1138
1157
  clientId: r,
1139
- code_challenge: je
1158
+ code_challenge: Me
1140
1159
  });
1141
- if (ue.status) {
1142
- const D = await be({
1160
+ if (de.status) {
1161
+ const D = await _e({
1143
1162
  username: u,
1144
1163
  password: k,
1145
1164
  clientId: r,
1146
1165
  sessionExpiration: t,
1147
1166
  nonce: I,
1148
1167
  type: g,
1149
- code: ue.code,
1150
- code_verifier: ee
1168
+ code: de.code,
1169
+ code_verifier: ee,
1170
+ domain: a
1151
1171
  });
1152
- return D.status ? (s(D.idToken), c(D.accessToken), p(D.refreshToken), v({
1172
+ return D.status ? (o(D.idToken), d(D.accessToken), E(D.refreshToken), v({
1153
1173
  isLoading: !1,
1154
1174
  isAuthenticated: !0,
1155
1175
  user: {
@@ -1157,62 +1177,64 @@ const Y = () => {
1157
1177
  username: u
1158
1178
  },
1159
1179
  logoutReason: ""
1160
- }), !0) : (N(Te), !1);
1180
+ }), !0) : (K(ke), !1);
1161
1181
  }
1162
1182
  return !1;
1163
1183
  }
1164
- const O = await be({
1184
+ const O = await _e({
1165
1185
  username: u,
1166
1186
  password: k,
1167
1187
  clientId: r,
1168
1188
  sessionExpiration: t,
1169
1189
  nonce: I,
1170
- type: g
1190
+ type: g,
1191
+ domain: a
1171
1192
  });
1172
- return O.status ? (s(O.idToken), c(O.accessToken), p(O.refreshToken), v({
1193
+ return O.status ? (o(O.idToken), d(O.accessToken), E(O.refreshToken), v({
1173
1194
  isLoading: !1,
1174
1195
  isAuthenticated: !0,
1175
1196
  user: {
1176
1197
  userId: O.userId,
1177
1198
  username: u
1178
1199
  }
1179
- }), !0) : (N(Te), !1);
1180
- }, We = async (u) => {
1181
- u == null || u.preventDefault(), await R(qt);
1182
- }, Je = async () => {
1200
+ }), !0) : (K(ke), !1);
1201
+ }, Je = async (u) => {
1202
+ u == null || u.preventDefault(), await R(zt);
1203
+ }, xe = async () => {
1183
1204
  const { isAuthenticated: u, user: k } = P;
1184
1205
  try {
1185
1206
  if (u && k && k.userId) {
1186
- if (i) {
1187
- const I = await H(i);
1188
- if (I && I.payload[y.USER_ID_KEY] !== "")
1189
- return i;
1207
+ if (c) {
1208
+ const I = await H(c);
1209
+ if (I && I.payload[w.USER_ID_KEY] !== "")
1210
+ return c;
1190
1211
  }
1191
- const g = await Le.refreshtoken({
1212
+ const g = await $e.refreshtoken({
1192
1213
  clientId: r,
1193
1214
  userId: k.userId,
1194
- nonce: E
1215
+ nonce: S,
1216
+ domain: a
1195
1217
  });
1196
- return g.status && g.status === "success" ? (c(g.newAccessToken), p(g.newRefreshToken), g.newAccessToken) : (await R(oe), "");
1218
+ return g.status && g.status === "success" ? (d(g.newAccessToken), E(g.newRefreshToken), g.newAccessToken) : (await R(oe), "");
1197
1219
  }
1198
1220
  return await R(oe), "";
1199
1221
  } catch {
1200
1222
  return await R(oe), "";
1201
1223
  }
1202
- }, xe = () => {
1203
- if (P.isAuthenticated && n)
1204
- return n;
1224
+ }, je = () => {
1225
+ if (P.isAuthenticated && s)
1226
+ return s;
1205
1227
  };
1206
- return /* @__PURE__ */ Ye(
1207
- Ne.Provider,
1228
+ return /* @__PURE__ */ Be(
1229
+ Le.Provider,
1208
1230
  {
1209
- value: { ...P, login: $e, logout: We, getAccessToken: Je, getIdToken: xe },
1231
+ value: { ...P, login: We, logout: Je, getAccessToken: xe, getIdToken: je },
1210
1232
  children: e
1211
1233
  }
1212
1234
  );
1213
- }, ur = (e = Ne) => ze(e);
1235
+ }, dr = (e = Le) => Xe(e);
1214
1236
  export {
1215
- q as AUTH_TYPES,
1216
- cr as AuthProvider,
1217
- ur as useAuth
1237
+ G as AUTH_TYPES,
1238
+ ur as AuthProvider,
1239
+ dr as useAuth
1218
1240
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versini/auth-provider",
3
- "version": "5.0.6",
3
+ "version": "5.1.1",
4
4
  "license": "MIT",
5
5
  "author": "Arno Versini",
6
6
  "publishConfig": {
@@ -44,10 +44,10 @@
44
44
  "react-dom": "18.3.1"
45
45
  },
46
46
  "dependencies": {
47
- "@versini/auth-common": "2.10.1",
47
+ "@versini/auth-common": "2.11.0",
48
48
  "@versini/ui-hooks": "4.0.0",
49
49
  "jose": "5.6.3",
50
50
  "uuid": "10.0.0"
51
51
  },
52
- "gitHead": "86d112a1eb52d8150f740a052decb9bf2cc0a4a7"
52
+ "gitHead": "4a4defa7caa76ea05f4bdf40333b66d5b752b257"
53
53
  }