@versini/auth-provider 7.4.3 → 7.5.0

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.js CHANGED
@@ -1,16 +1,16 @@
1
1
  var St = Object.defineProperty;
2
2
  var At = (e, t, r) => t in e ? St(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var X = (e, t, r) => At(e, typeof t != "symbol" ? t + "" : t, r);
3
+ var Z = (e, t, r) => At(e, typeof t != "symbol" ? t + "" : t, r);
4
4
  import { jsx as ke } from "react/jsx-runtime";
5
5
  import Tt, { useSyncExternalStore as Rt, useCallback as D, useEffect as $e, createContext as _t, useReducer as It, useRef as bt, useContext as kt } from "react";
6
6
  /*!
7
- @versini/auth-provider v7.4.3
7
+ @versini/auth-provider v7.5.0
8
8
  © 2025 gizmette.com
9
9
  */
10
10
  try {
11
11
  window.__VERSINI_AUTH_CLIENT__ || (window.__VERSINI_AUTH_CLIENT__ = {
12
- version: "7.4.3",
13
- buildTime: "02/09/2025 06:40 PM EST",
12
+ version: "7.5.0",
13
+ buildTime: "02/09/2025 07:44 PM EST",
14
14
  homepage: "https://github.com/aversini/auth-client",
15
15
  license: "MIT"
16
16
  });
@@ -23,11 +23,11 @@ function k(e) {
23
23
  r += String.fromCharCode(a);
24
24
  return btoa(r).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
25
25
  }
26
- function oe(e) {
27
- const t = e.replace(/-/g, "+").replace(/_/g, "/"), r = (4 - t.length % 4) % 4, n = t.padEnd(t.length + r, "="), a = atob(n), s = new ArrayBuffer(a.length), o = new Uint8Array(s);
26
+ function se(e) {
27
+ const t = e.replace(/-/g, "+").replace(/_/g, "/"), r = (4 - t.length % 4) % 4, n = t.padEnd(t.length + r, "="), a = atob(n), o = new ArrayBuffer(a.length), s = new Uint8Array(o);
28
28
  for (let i = 0; i < a.length; i++)
29
- o[i] = a.charCodeAt(i);
30
- return s;
29
+ s[i] = a.charCodeAt(i);
30
+ return o;
31
31
  }
32
32
  function Ae() {
33
33
  return window?.PublicKeyCredential !== void 0 && typeof window.PublicKeyCredential == "function";
@@ -36,14 +36,14 @@ function Je(e) {
36
36
  const { id: t } = e;
37
37
  return {
38
38
  ...e,
39
- id: oe(t),
39
+ id: se(t),
40
40
  transports: e.transports
41
41
  };
42
42
  }
43
43
  function Ye(e) {
44
44
  return e === "localhost" || /^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e);
45
45
  }
46
- class S extends Error {
46
+ class A extends Error {
47
47
  constructor({ message: t, code: r, cause: n, name: a }) {
48
48
  super(t, { cause: n }), this.name = a ?? n.name, this.code = r;
49
49
  }
@@ -54,43 +54,43 @@ function Ot({ error: e, options: t }) {
54
54
  throw Error("options was missing required publicKey property");
55
55
  if (e.name === "AbortError") {
56
56
  if (t.signal instanceof AbortSignal)
57
- return new S({
57
+ return new A({
58
58
  message: "Registration ceremony was sent an abort signal",
59
59
  code: "ERROR_CEREMONY_ABORTED",
60
60
  cause: e
61
61
  });
62
62
  } else if (e.name === "ConstraintError") {
63
63
  if (r.authenticatorSelection?.requireResidentKey === !0)
64
- return new S({
64
+ return new A({
65
65
  message: "Discoverable credentials were required but no available authenticator supported it",
66
66
  code: "ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",
67
67
  cause: e
68
68
  });
69
69
  if (r.authenticatorSelection?.userVerification === "required")
70
- return new S({
70
+ return new A({
71
71
  message: "User verification was required but no available authenticator supported it",
72
72
  code: "ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",
73
73
  cause: e
74
74
  });
75
75
  } else {
76
76
  if (e.name === "InvalidStateError")
77
- return new S({
77
+ return new A({
78
78
  message: "The authenticator was previously registered",
79
79
  code: "ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",
80
80
  cause: e
81
81
  });
82
82
  if (e.name === "NotAllowedError")
83
- return new S({
83
+ return new A({
84
84
  message: e.message,
85
85
  code: "ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",
86
86
  cause: e
87
87
  });
88
88
  if (e.name === "NotSupportedError")
89
- return r.pubKeyCredParams.filter((a) => a.type === "public-key").length === 0 ? new S({
89
+ return r.pubKeyCredParams.filter((a) => a.type === "public-key").length === 0 ? new A({
90
90
  message: 'No entry in pubKeyCredParams was of type "public-key"',
91
91
  code: "ERROR_MALFORMED_PUBKEYCREDPARAMS",
92
92
  cause: e
93
- }) : new S({
93
+ }) : new A({
94
94
  message: "No available authenticator supported any of the specified pubKeyCredParams algorithms",
95
95
  code: "ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",
96
96
  cause: e
@@ -99,25 +99,25 @@ function Ot({ error: e, options: t }) {
99
99
  const n = window.location.hostname;
100
100
  if (Ye(n)) {
101
101
  if (r.rp.id !== n)
102
- return new S({
102
+ return new A({
103
103
  message: `The RP ID "${r.rp.id}" is invalid for this domain`,
104
104
  code: "ERROR_INVALID_RP_ID",
105
105
  cause: e
106
106
  });
107
- } else return new S({
107
+ } else return new A({
108
108
  message: `${window.location.hostname} is an invalid domain`,
109
109
  code: "ERROR_INVALID_DOMAIN",
110
110
  cause: e
111
111
  });
112
112
  } else if (e.name === "TypeError") {
113
113
  if (r.user.id.byteLength < 1 || r.user.id.byteLength > 64)
114
- return new S({
114
+ return new A({
115
115
  message: "User ID was not between 1 and 64 characters",
116
116
  code: "ERROR_INVALID_USER_ID_LENGTH",
117
117
  cause: e
118
118
  });
119
119
  } else if (e.name === "UnknownError")
120
- return new S({
120
+ return new A({
121
121
  message: "The authenticator was unable to process the specified options, or could not create a new credential",
122
122
  code: "ERROR_AUTHENTICATOR_GENERAL_ERROR",
123
123
  cause: e
@@ -151,10 +151,10 @@ async function Ct(e) {
151
151
  throw new Error("WebAuthn is not supported in this browser");
152
152
  const r = { publicKey: {
153
153
  ...e,
154
- challenge: oe(e.challenge),
154
+ challenge: se(e.challenge),
155
155
  user: {
156
156
  ...e.user,
157
- id: oe(e.user.id)
157
+ id: se(e.user.id)
158
158
  },
159
159
  excludeCredentials: e.excludeCredentials?.map(Je)
160
160
  } };
@@ -162,46 +162,46 @@ async function Ct(e) {
162
162
  let n;
163
163
  try {
164
164
  n = await navigator.credentials.create(r);
165
- } catch (l) {
166
- throw Ot({ error: l, options: r });
165
+ } catch (d) {
166
+ throw Ot({ error: d, options: r });
167
167
  }
168
168
  if (!n)
169
169
  throw new Error("Registration was not completed");
170
- const { id: a, rawId: s, response: o, type: i } = n;
170
+ const { id: a, rawId: o, response: s, type: i } = n;
171
171
  let c;
172
- typeof o.getTransports == "function" && (c = o.getTransports());
173
- let h;
174
- if (typeof o.getPublicKeyAlgorithm == "function")
175
- try {
176
- h = o.getPublicKeyAlgorithm();
177
- } catch (l) {
178
- pe("getPublicKeyAlgorithm()", l);
179
- }
172
+ typeof s.getTransports == "function" && (c = s.getTransports());
180
173
  let y;
181
- if (typeof o.getPublicKey == "function")
174
+ if (typeof s.getPublicKeyAlgorithm == "function")
182
175
  try {
183
- const l = o.getPublicKey();
184
- l !== null && (y = k(l));
185
- } catch (l) {
186
- pe("getPublicKey()", l);
176
+ y = s.getPublicKeyAlgorithm();
177
+ } catch (d) {
178
+ pe("getPublicKeyAlgorithm()", d);
187
179
  }
188
180
  let p;
189
- if (typeof o.getAuthenticatorData == "function")
181
+ if (typeof s.getPublicKey == "function")
190
182
  try {
191
- p = k(o.getAuthenticatorData());
192
- } catch (l) {
193
- pe("getAuthenticatorData()", l);
183
+ const d = s.getPublicKey();
184
+ d !== null && (p = k(d));
185
+ } catch (d) {
186
+ pe("getPublicKey()", d);
187
+ }
188
+ let h;
189
+ if (typeof s.getAuthenticatorData == "function")
190
+ try {
191
+ h = k(s.getAuthenticatorData());
192
+ } catch (d) {
193
+ pe("getAuthenticatorData()", d);
194
194
  }
195
195
  return {
196
196
  id: a,
197
- rawId: k(s),
197
+ rawId: k(o),
198
198
  response: {
199
- attestationObject: k(o.attestationObject),
200
- clientDataJSON: k(o.clientDataJSON),
199
+ attestationObject: k(s.attestationObject),
200
+ clientDataJSON: k(s.clientDataJSON),
201
201
  transports: c,
202
- publicKeyAlgorithm: h,
203
- publicKey: y,
204
- authenticatorData: p
202
+ publicKeyAlgorithm: y,
203
+ publicKey: p,
204
+ authenticatorData: h
205
205
  },
206
206
  type: i,
207
207
  clientExtensionResults: n.getClientExtensionResults(),
@@ -224,14 +224,14 @@ function Kt({ error: e, options: t }) {
224
224
  throw Error("options was missing required publicKey property");
225
225
  if (e.name === "AbortError") {
226
226
  if (t.signal instanceof AbortSignal)
227
- return new S({
227
+ return new A({
228
228
  message: "Authentication ceremony was sent an abort signal",
229
229
  code: "ERROR_CEREMONY_ABORTED",
230
230
  cause: e
231
231
  });
232
232
  } else {
233
233
  if (e.name === "NotAllowedError")
234
- return new S({
234
+ return new A({
235
235
  message: e.message,
236
236
  code: "ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",
237
237
  cause: e
@@ -240,18 +240,18 @@ function Kt({ error: e, options: t }) {
240
240
  const n = window.location.hostname;
241
241
  if (Ye(n)) {
242
242
  if (r.rpId !== n)
243
- return new S({
243
+ return new A({
244
244
  message: `The RP ID "${r.rpId}" is invalid for this domain`,
245
245
  code: "ERROR_INVALID_RP_ID",
246
246
  cause: e
247
247
  });
248
- } else return new S({
248
+ } else return new A({
249
249
  message: `${window.location.hostname} is an invalid domain`,
250
250
  code: "ERROR_INVALID_DOMAIN",
251
251
  cause: e
252
252
  });
253
253
  } else if (e.name === "UnknownError")
254
- return new S({
254
+ return new A({
255
255
  message: "The authenticator was unable to process the specified options, or could not create a new assertion signature",
256
256
  code: "ERROR_AUTHENTICATOR_GENERAL_ERROR",
257
257
  cause: e
@@ -266,7 +266,7 @@ async function Dt(e, t = !1) {
266
266
  e.allowCredentials?.length !== 0 && (r = e.allowCredentials?.map(Je));
267
267
  const n = {
268
268
  ...e,
269
- challenge: oe(e.challenge),
269
+ challenge: se(e.challenge),
270
270
  allowCredentials: r
271
271
  }, a = {};
272
272
  if (t) {
@@ -277,28 +277,28 @@ async function Dt(e, t = !1) {
277
277
  a.mediation = "conditional", n.allowCredentials = [];
278
278
  }
279
279
  a.publicKey = n, a.signal = xe.createNewAbortSignal();
280
- let s;
280
+ let o;
281
281
  try {
282
- s = await navigator.credentials.get(a);
283
- } catch (p) {
284
- throw Kt({ error: p, options: a });
282
+ o = await navigator.credentials.get(a);
283
+ } catch (h) {
284
+ throw Kt({ error: h, options: a });
285
285
  }
286
- if (!s)
286
+ if (!o)
287
287
  throw new Error("Authentication was not completed");
288
- const { id: o, rawId: i, response: c, type: h } = s;
289
- let y;
290
- return c.userHandle && (y = k(c.userHandle)), {
291
- id: o,
288
+ const { id: s, rawId: i, response: c, type: y } = o;
289
+ let p;
290
+ return c.userHandle && (p = k(c.userHandle)), {
291
+ id: s,
292
292
  rawId: k(i),
293
293
  response: {
294
294
  authenticatorData: k(c.authenticatorData),
295
295
  clientDataJSON: k(c.clientDataJSON),
296
296
  signature: k(c.signature),
297
- userHandle: y
297
+ userHandle: p
298
298
  },
299
- type: h,
300
- clientExtensionResults: s.getClientExtensionResults(),
301
- authenticatorAttachment: Me(s.authenticatorAttachment)
299
+ type: y,
300
+ clientExtensionResults: o.getClientExtensionResults(),
301
+ authenticatorAttachment: Me(o.authenticatorAttachment)
302
302
  };
303
303
  }
304
304
  /*!
@@ -308,7 +308,7 @@ async function Dt(e, t = !1) {
308
308
  try {
309
309
  window.__VERSINI_AUTH_COMMON__ || (window.__VERSINI_AUTH_COMMON__ = {
310
310
  version: "4.2.0",
311
- buildTime: "02/09/2025 06:40 PM EST",
311
+ buildTime: "02/09/2025 07:44 PM EST",
312
312
  homepage: "https://github.com/aversini/auth-client",
313
313
  license: "MIT"
314
314
  });
@@ -323,7 +323,7 @@ const M = {
323
323
  PASSKEY: "passkey"
324
324
  }, Ge = {
325
325
  CLIENT_ID: "X-Auth-ClientId"
326
- }, f = {
326
+ }, E = {
327
327
  ALG: "RS256",
328
328
  USER_ID_KEY: "sub",
329
329
  USERNAME_KEY: "username",
@@ -344,20 +344,20 @@ aMwPFOIcJH+rKfFgNcHLcaS5syp7zU1ANwZ+trgR+DifBr8TLVkBynmNeTyhDm2+
344
344
  l0haqjMk0UoNPPE8iYBWUHQJJE1Dqstj65d6Eh5g64Pao25y4cmYJbKjiblIGEkE
345
345
  sjqybA9mARAqh9k/eiIopecWSiffNQTwVQVd2I9ZH3BalhEXHlqFgrjz51kFqg81
346
346
  awIDAQAB
347
- -----END PUBLIC KEY-----`, ce = {
347
+ -----END PUBLIC KEY-----`, ue = {
348
348
  CODE: "code",
349
349
  LOGOUT: "logout",
350
350
  LOGIN: "login",
351
351
  REFRESH: "refresh"
352
- }, ue = crypto, Ve = (e) => e instanceof CryptoKey, Z = new TextEncoder(), q = new TextDecoder();
352
+ }, le = crypto, Ve = (e) => e instanceof CryptoKey, ee = new TextEncoder(), q = new TextDecoder();
353
353
  function Lt(...e) {
354
- const t = e.reduce((a, { length: s }) => a + s, 0), r = new Uint8Array(t);
354
+ const t = e.reduce((a, { length: o }) => a + o, 0), r = new Uint8Array(t);
355
355
  let n = 0;
356
356
  for (const a of e)
357
357
  r.set(a, n), n += a.length;
358
358
  return r;
359
359
  }
360
- const Ht = (e) => {
360
+ const Wt = (e) => {
361
361
  const t = atob(e), r = new Uint8Array(t.length);
362
362
  for (let n = 0; n < t.length; n++)
363
363
  r[n] = t.charCodeAt(n);
@@ -366,97 +366,97 @@ const Ht = (e) => {
366
366
  let t = e;
367
367
  t instanceof Uint8Array && (t = q.decode(t)), t = t.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "");
368
368
  try {
369
- return Ht(t);
369
+ return Wt(t);
370
370
  } catch {
371
371
  throw new TypeError("The input to be decoded is not correctly encoded.");
372
372
  }
373
373
  };
374
- let A = class extends Error {
374
+ let T = class extends Error {
375
375
  constructor(t, r) {
376
376
  var n;
377
377
  super(t, r), this.code = "ERR_JOSE_GENERIC", this.name = this.constructor.name, (n = Error.captureStackTrace) == null || n.call(Error, this, this.constructor);
378
378
  }
379
379
  };
380
- A.code = "ERR_JOSE_GENERIC";
381
- class _ extends A {
380
+ T.code = "ERR_JOSE_GENERIC";
381
+ class _ extends T {
382
382
  constructor(t, r, n = "unspecified", a = "unspecified") {
383
383
  super(t, { cause: { claim: n, reason: a, payload: r } }), this.code = "ERR_JWT_CLAIM_VALIDATION_FAILED", this.claim = n, this.reason = a, this.payload = r;
384
384
  }
385
385
  }
386
386
  _.code = "ERR_JWT_CLAIM_VALIDATION_FAILED";
387
- class we extends A {
387
+ class we extends T {
388
388
  constructor(t, r, n = "unspecified", a = "unspecified") {
389
389
  super(t, { cause: { claim: n, reason: a, payload: r } }), this.code = "ERR_JWT_EXPIRED", this.claim = n, this.reason = a, this.payload = r;
390
390
  }
391
391
  }
392
392
  we.code = "ERR_JWT_EXPIRED";
393
- class je extends A {
393
+ class je extends T {
394
394
  constructor() {
395
395
  super(...arguments), this.code = "ERR_JOSE_ALG_NOT_ALLOWED";
396
396
  }
397
397
  }
398
398
  je.code = "ERR_JOSE_ALG_NOT_ALLOWED";
399
- class I extends A {
399
+ class I extends T {
400
400
  constructor() {
401
401
  super(...arguments), this.code = "ERR_JOSE_NOT_SUPPORTED";
402
402
  }
403
403
  }
404
404
  I.code = "ERR_JOSE_NOT_SUPPORTED";
405
- class Wt extends A {
405
+ class Ht extends T {
406
406
  constructor(t = "decryption operation failed", r) {
407
407
  super(t, r), this.code = "ERR_JWE_DECRYPTION_FAILED";
408
408
  }
409
409
  }
410
- Wt.code = "ERR_JWE_DECRYPTION_FAILED";
411
- class $t extends A {
410
+ Ht.code = "ERR_JWE_DECRYPTION_FAILED";
411
+ class $t extends T {
412
412
  constructor() {
413
413
  super(...arguments), this.code = "ERR_JWE_INVALID";
414
414
  }
415
415
  }
416
416
  $t.code = "ERR_JWE_INVALID";
417
- class E extends A {
417
+ class g extends T {
418
418
  constructor() {
419
419
  super(...arguments), this.code = "ERR_JWS_INVALID";
420
420
  }
421
421
  }
422
- E.code = "ERR_JWS_INVALID";
423
- let b = class extends A {
422
+ g.code = "ERR_JWS_INVALID";
423
+ let b = class extends T {
424
424
  constructor() {
425
425
  super(...arguments), this.code = "ERR_JWT_INVALID";
426
426
  }
427
427
  };
428
428
  b.code = "ERR_JWT_INVALID";
429
- class Jt extends A {
429
+ class Jt extends T {
430
430
  constructor() {
431
431
  super(...arguments), this.code = "ERR_JWK_INVALID";
432
432
  }
433
433
  }
434
434
  Jt.code = "ERR_JWK_INVALID";
435
- class Yt extends A {
435
+ class Yt extends T {
436
436
  constructor() {
437
437
  super(...arguments), this.code = "ERR_JWKS_INVALID";
438
438
  }
439
439
  }
440
440
  Yt.code = "ERR_JWKS_INVALID";
441
- class xt extends A {
441
+ class xt extends T {
442
442
  constructor(t = "no applicable key found in the JSON Web Key Set", r) {
443
443
  super(t, r), this.code = "ERR_JWKS_NO_MATCHING_KEY";
444
444
  }
445
445
  }
446
446
  xt.code = "ERR_JWKS_NO_MATCHING_KEY";
447
- class Mt extends A {
447
+ class Mt extends T {
448
448
  constructor(t = "multiple matching keys found in the JSON Web Key Set", r) {
449
449
  super(t, r), this.code = "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
450
450
  }
451
451
  }
452
452
  Mt.code = "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
453
- class Gt extends A {
453
+ class Gt extends T {
454
454
  constructor(t = "request timed out", r) {
455
455
  super(t, r), this.code = "ERR_JWKS_TIMEOUT";
456
456
  }
457
457
  }
458
458
  Gt.code = "ERR_JWKS_TIMEOUT";
459
- class Fe extends A {
459
+ class Fe extends T {
460
460
  constructor(t = "signature verification failed", r) {
461
461
  super(t, r), this.code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED";
462
462
  }
@@ -465,7 +465,7 @@ Fe.code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED";
465
465
  function v(e, t = "algorithm.name") {
466
466
  return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`);
467
467
  }
468
- function ee(e, t) {
468
+ function te(e, t) {
469
469
  return e.name === t;
470
470
  }
471
471
  function ye(e) {
@@ -498,7 +498,7 @@ function Ft(e, t, ...r) {
498
498
  case "HS256":
499
499
  case "HS384":
500
500
  case "HS512": {
501
- if (!ee(e.algorithm, "HMAC"))
501
+ if (!te(e.algorithm, "HMAC"))
502
502
  throw v("HMAC");
503
503
  const n = parseInt(t.slice(2), 10);
504
504
  if (ye(e.algorithm.hash) !== n)
@@ -508,7 +508,7 @@ function Ft(e, t, ...r) {
508
508
  case "RS256":
509
509
  case "RS384":
510
510
  case "RS512": {
511
- if (!ee(e.algorithm, "RSASSA-PKCS1-v1_5"))
511
+ if (!te(e.algorithm, "RSASSA-PKCS1-v1_5"))
512
512
  throw v("RSASSA-PKCS1-v1_5");
513
513
  const n = parseInt(t.slice(2), 10);
514
514
  if (ye(e.algorithm.hash) !== n)
@@ -518,7 +518,7 @@ function Ft(e, t, ...r) {
518
518
  case "PS256":
519
519
  case "PS384":
520
520
  case "PS512": {
521
- if (!ee(e.algorithm, "RSA-PSS"))
521
+ if (!te(e.algorithm, "RSA-PSS"))
522
522
  throw v("RSA-PSS");
523
523
  const n = parseInt(t.slice(2), 10);
524
524
  if (ye(e.algorithm.hash) !== n)
@@ -533,7 +533,7 @@ function Ft(e, t, ...r) {
533
533
  case "ES256":
534
534
  case "ES384":
535
535
  case "ES512": {
536
- if (!ee(e.algorithm, "ECDSA"))
536
+ if (!te(e.algorithm, "ECDSA"))
537
537
  throw v("ECDSA");
538
538
  const n = Vt(t);
539
539
  if (e.algorithm.namedCurve !== n)
@@ -557,7 +557,7 @@ const Oe = (e, ...t) => Be("Key must be ", e, ...t);
557
557
  function qe(e, t, ...r) {
558
558
  return Be(`Key for the ${e} algorithm must be `, t, ...r);
559
559
  }
560
- const ze = (e) => Ve(e) ? !0 : e?.[Symbol.toStringTag] === "KeyObject", se = ["CryptoKey"], Bt = (...e) => {
560
+ const ze = (e) => Ve(e) ? !0 : e?.[Symbol.toStringTag] === "KeyObject", ie = ["CryptoKey"], Bt = (...e) => {
561
561
  const t = e.filter(Boolean);
562
562
  if (t.length === 0 || t.length === 1)
563
563
  return !0;
@@ -568,10 +568,10 @@ const ze = (e) => Ve(e) ? !0 : e?.[Symbol.toStringTag] === "KeyObject", se = ["C
568
568
  r = new Set(a);
569
569
  continue;
570
570
  }
571
- for (const s of a) {
572
- if (r.has(s))
571
+ for (const o of a) {
572
+ if (r.has(o))
573
573
  return !1;
574
- r.add(s);
574
+ r.add(o);
575
575
  }
576
576
  }
577
577
  return !0;
@@ -688,34 +688,34 @@ const Qe = async (e) => {
688
688
  e.ext ?? !1,
689
689
  e.key_ops ?? r
690
690
  ], a = { ...e };
691
- return delete a.alg, delete a.use, ue.subtle.importKey("jwk", a, ...n);
691
+ return delete a.alg, delete a.use, le.subtle.importKey("jwk", a, ...n);
692
692
  }, Xe = (e) => C(e);
693
- let L, H;
694
- const Ze = (e) => e?.[Symbol.toStringTag] === "KeyObject", ie = async (e, t, r, n, a = !1) => {
695
- let s = e.get(t);
696
- if (s != null && s[n])
697
- return s[n];
698
- const o = await Qe({ ...r, alg: n });
699
- return a && Object.freeze(t), s ? s[n] = o : e.set(t, { [n]: o }), o;
693
+ let L, W;
694
+ const Ze = (e) => e?.[Symbol.toStringTag] === "KeyObject", ce = async (e, t, r, n, a = !1) => {
695
+ let o = e.get(t);
696
+ if (o != null && o[n])
697
+ return o[n];
698
+ const s = await Qe({ ...r, alg: n });
699
+ return a && Object.freeze(t), o ? o[n] = s : e.set(t, { [n]: s }), s;
700
700
  }, tr = (e, t) => {
701
701
  if (Ze(e)) {
702
702
  let r = e.export({ format: "jwk" });
703
- return delete r.d, delete r.dp, delete r.dq, delete r.p, delete r.q, delete r.qi, r.k ? Xe(r.k) : (H || (H = /* @__PURE__ */ new WeakMap()), ie(H, e, r, t));
703
+ return delete r.d, delete r.dp, delete r.dq, delete r.p, delete r.q, delete r.qi, r.k ? Xe(r.k) : (W || (W = /* @__PURE__ */ new WeakMap()), ce(W, e, r, t));
704
704
  }
705
- return j(e) ? e.k ? C(e.k) : (H || (H = /* @__PURE__ */ new WeakMap()), ie(H, e, e, t, !0)) : e;
705
+ return j(e) ? e.k ? C(e.k) : (W || (W = /* @__PURE__ */ new WeakMap()), ce(W, e, e, t, !0)) : e;
706
706
  }, rr = (e, t) => {
707
707
  if (Ze(e)) {
708
708
  let r = e.export({ format: "jwk" });
709
- return r.k ? Xe(r.k) : (L || (L = /* @__PURE__ */ new WeakMap()), ie(L, e, r, t));
709
+ return r.k ? Xe(r.k) : (L || (L = /* @__PURE__ */ new WeakMap()), ce(L, e, r, t));
710
710
  }
711
- return j(e) ? e.k ? C(e.k) : (L || (L = /* @__PURE__ */ new WeakMap()), ie(L, e, e, t, !0)) : e;
711
+ return j(e) ? e.k ? C(e.k) : (L || (L = /* @__PURE__ */ new WeakMap()), ce(L, e, e, t, !0)) : e;
712
712
  }, nr = { normalizePublicKey: tr, normalizePrivateKey: rr }, P = (e, t, r = 0) => {
713
713
  r === 0 && (t.unshift(t.length), t.unshift(6));
714
714
  const n = e.indexOf(t[0], r);
715
715
  if (n === -1)
716
716
  return !1;
717
717
  const a = e.subarray(n, n + t.length);
718
- return a.length !== t.length ? !1 : a.every((s, o) => s === t[o]) || P(e, t, n + 1);
718
+ return a.length !== t.length ? !1 : a.every((o, s) => o === t[s]) || P(e, t, n + 1);
719
719
  }, ve = (e) => {
720
720
  switch (!0) {
721
721
  case P(e, [42, 134, 72, 206, 61, 3, 1, 7]):
@@ -736,52 +736,52 @@ const Ze = (e) => e?.[Symbol.toStringTag] === "KeyObject", ie = async (e, t, r,
736
736
  throw new I("Invalid or unsupported EC Key Curve or OKP Key Sub Type");
737
737
  }
738
738
  }, ar = async (e, t, r, n, a) => {
739
- let s, o;
739
+ let o, s;
740
740
  const i = new Uint8Array(atob(r.replace(e, "")).split("").map((c) => c.charCodeAt(0)));
741
741
  switch (n) {
742
742
  case "PS256":
743
743
  case "PS384":
744
744
  case "PS512":
745
- s = { name: "RSA-PSS", hash: `SHA-${n.slice(-3)}` }, o = ["verify"];
745
+ o = { name: "RSA-PSS", hash: `SHA-${n.slice(-3)}` }, s = ["verify"];
746
746
  break;
747
747
  case "RS256":
748
748
  case "RS384":
749
749
  case "RS512":
750
- s = { name: "RSASSA-PKCS1-v1_5", hash: `SHA-${n.slice(-3)}` }, o = ["verify"];
750
+ o = { name: "RSASSA-PKCS1-v1_5", hash: `SHA-${n.slice(-3)}` }, s = ["verify"];
751
751
  break;
752
752
  case "RSA-OAEP":
753
753
  case "RSA-OAEP-256":
754
754
  case "RSA-OAEP-384":
755
755
  case "RSA-OAEP-512":
756
- s = {
756
+ o = {
757
757
  name: "RSA-OAEP",
758
758
  hash: `SHA-${parseInt(n.slice(-3), 10) || 1}`
759
- }, o = ["encrypt", "wrapKey"];
759
+ }, s = ["encrypt", "wrapKey"];
760
760
  break;
761
761
  case "ES256":
762
- s = { name: "ECDSA", namedCurve: "P-256" }, o = ["verify"];
762
+ o = { name: "ECDSA", namedCurve: "P-256" }, s = ["verify"];
763
763
  break;
764
764
  case "ES384":
765
- s = { name: "ECDSA", namedCurve: "P-384" }, o = ["verify"];
765
+ o = { name: "ECDSA", namedCurve: "P-384" }, s = ["verify"];
766
766
  break;
767
767
  case "ES512":
768
- s = { name: "ECDSA", namedCurve: "P-521" }, o = ["verify"];
768
+ o = { name: "ECDSA", namedCurve: "P-521" }, s = ["verify"];
769
769
  break;
770
770
  case "ECDH-ES":
771
771
  case "ECDH-ES+A128KW":
772
772
  case "ECDH-ES+A192KW":
773
773
  case "ECDH-ES+A256KW": {
774
774
  const c = ve(i);
775
- s = c.startsWith("P-") ? { name: "ECDH", namedCurve: c } : { name: c }, o = [];
775
+ o = c.startsWith("P-") ? { name: "ECDH", namedCurve: c } : { name: c }, s = [];
776
776
  break;
777
777
  }
778
778
  case "EdDSA":
779
- s = { name: ve(i) }, o = ["verify"];
779
+ o = { name: ve(i) }, s = ["verify"];
780
780
  break;
781
781
  default:
782
782
  throw new I('Invalid or unsupported "alg" (Algorithm) value');
783
783
  }
784
- return ue.subtle.importKey(t, i, s, !1, o);
784
+ return le.subtle.importKey(t, i, o, !1, s);
785
785
  }, or = (e, t, r) => ar(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g, "spki", e, t);
786
786
  async function sr(e, t, r) {
787
787
  if (e.indexOf("-----BEGIN PUBLIC KEY-----") !== 0)
@@ -823,7 +823,7 @@ const x = (e) => e?.[Symbol.toStringTag], Se = (e, t, r) => {
823
823
  throw new TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present');
824
824
  }
825
825
  if (!ze(t))
826
- throw new TypeError(qe(e, t, ...se, "Uint8Array", n ? "JSON Web Key" : null));
826
+ throw new TypeError(qe(e, t, ...ie, "Uint8Array", n ? "JSON Web Key" : null));
827
827
  if (t.type !== "secret")
828
828
  throw new TypeError(`${x(t)} instances for symmetric algorithms must be of type "secret"`);
829
829
  }
@@ -840,7 +840,7 @@ const x = (e) => e?.[Symbol.toStringTag], Se = (e, t, r) => {
840
840
  throw new TypeError("JSON Web Key for this operation be a public JWK");
841
841
  }
842
842
  if (!ze(t))
843
- throw new TypeError(qe(e, t, ...se, n ? "JSON Web Key" : null));
843
+ throw new TypeError(qe(e, t, ...ie, n ? "JSON Web Key" : null));
844
844
  if (t.type === "secret")
845
845
  throw new TypeError(`${x(t)} instances for asymmetric algorithms must not be of type "secret"`);
846
846
  if (r === "sign" && t.type === "public")
@@ -862,17 +862,17 @@ function lr(e, t, r, n, a) {
862
862
  throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');
863
863
  if (!n || n.crit === void 0)
864
864
  return /* @__PURE__ */ new Set();
865
- if (!Array.isArray(n.crit) || n.crit.length === 0 || n.crit.some((o) => typeof o != "string" || o.length === 0))
865
+ if (!Array.isArray(n.crit) || n.crit.length === 0 || n.crit.some((s) => typeof s != "string" || s.length === 0))
866
866
  throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');
867
- let s;
868
- r !== void 0 ? s = new Map([...Object.entries(r), ...t.entries()]) : s = t;
869
- for (const o of n.crit) {
870
- if (!s.has(o))
871
- throw new I(`Extension Header Parameter "${o}" is not recognized`);
872
- if (a[o] === void 0)
873
- throw new e(`Extension Header Parameter "${o}" is missing`);
874
- if (s.get(o) && n[o] === void 0)
875
- throw new e(`Extension Header Parameter "${o}" MUST be integrity protected`);
867
+ let o;
868
+ r !== void 0 ? o = new Map([...Object.entries(r), ...t.entries()]) : o = t;
869
+ for (const s of n.crit) {
870
+ if (!o.has(s))
871
+ throw new I(`Extension Header Parameter "${s}" is not recognized`);
872
+ if (a[s] === void 0)
873
+ throw new e(`Extension Header Parameter "${s}" is missing`);
874
+ if (o.get(s) && n[s] === void 0)
875
+ throw new e(`Extension Header Parameter "${s}" MUST be integrity protected`);
876
876
  }
877
877
  return new Set(n.crit);
878
878
  }
@@ -912,91 +912,91 @@ async function pr(e, t, r) {
912
912
  return Ft(t, e, r), t;
913
913
  if (t instanceof Uint8Array) {
914
914
  if (!e.startsWith("HS"))
915
- throw new TypeError(Oe(t, ...se));
916
- return ue.subtle.importKey("raw", t, { hash: `SHA-${e.slice(-3)}`, name: "HMAC" }, !1, [r]);
915
+ throw new TypeError(Oe(t, ...ie));
916
+ return le.subtle.importKey("raw", t, { hash: `SHA-${e.slice(-3)}`, name: "HMAC" }, !1, [r]);
917
917
  }
918
- throw new TypeError(Oe(t, ...se, "Uint8Array", "JSON Web Key"));
918
+ throw new TypeError(Oe(t, ...ie, "Uint8Array", "JSON Web Key"));
919
919
  }
920
920
  const yr = async (e, t, r, n) => {
921
921
  const a = await pr(e, t, "verify");
922
922
  zt(e, a);
923
- const s = hr(e, a.algorithm);
923
+ const o = hr(e, a.algorithm);
924
924
  try {
925
- return await ue.subtle.verify(s, a, r, n);
925
+ return await le.subtle.verify(o, a, r, n);
926
926
  } catch {
927
927
  return !1;
928
928
  }
929
929
  };
930
930
  async function fr(e, t, r) {
931
931
  if (!G(e))
932
- throw new E("Flattened JWS must be an object");
932
+ throw new g("Flattened JWS must be an object");
933
933
  if (e.protected === void 0 && e.header === void 0)
934
- throw new E('Flattened JWS must have either of the "protected" or "header" members');
934
+ throw new g('Flattened JWS must have either of the "protected" or "header" members');
935
935
  if (e.protected !== void 0 && typeof e.protected != "string")
936
- throw new E("JWS Protected Header incorrect type");
936
+ throw new g("JWS Protected Header incorrect type");
937
937
  if (e.payload === void 0)
938
- throw new E("JWS Payload missing");
938
+ throw new g("JWS Payload missing");
939
939
  if (typeof e.signature != "string")
940
- throw new E("JWS Signature missing or incorrect type");
940
+ throw new g("JWS Signature missing or incorrect type");
941
941
  if (e.header !== void 0 && !G(e.header))
942
- throw new E("JWS Unprotected Header incorrect type");
942
+ throw new g("JWS Unprotected Header incorrect type");
943
943
  let n = {};
944
944
  if (e.protected)
945
945
  try {
946
946
  const R = C(e.protected);
947
947
  n = JSON.parse(q.decode(R));
948
948
  } catch {
949
- throw new E("JWS Protected Header is invalid");
949
+ throw new g("JWS Protected Header is invalid");
950
950
  }
951
951
  if (!Bt(n, e.header))
952
- throw new E("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
952
+ throw new g("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
953
953
  const a = {
954
954
  ...n,
955
955
  ...e.header
956
- }, s = lr(E, /* @__PURE__ */ new Map([["b64", !0]]), r?.crit, n, a);
957
- let o = !0;
958
- if (s.has("b64") && (o = n.b64, typeof o != "boolean"))
959
- throw new E('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
956
+ }, o = lr(g, /* @__PURE__ */ new Map([["b64", !0]]), r?.crit, n, a);
957
+ let s = !0;
958
+ if (o.has("b64") && (s = n.b64, typeof s != "boolean"))
959
+ throw new g('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
960
960
  const { alg: i } = a;
961
961
  if (typeof i != "string" || !i)
962
- throw new E('JWS "alg" (Algorithm) Header Parameter missing or invalid');
962
+ throw new g('JWS "alg" (Algorithm) Header Parameter missing or invalid');
963
963
  const c = r && dr("algorithms", r.algorithms);
964
964
  if (c && !c.has(i))
965
965
  throw new je('"alg" (Algorithm) Header Parameter value not allowed');
966
- if (o) {
966
+ if (s) {
967
967
  if (typeof e.payload != "string")
968
- throw new E("JWS Payload must be a string");
968
+ throw new g("JWS Payload must be a string");
969
969
  } else if (typeof e.payload != "string" && !(e.payload instanceof Uint8Array))
970
- throw new E("JWS Payload must be a string or an Uint8Array instance");
971
- let h = !1;
972
- typeof t == "function" ? (t = await t(n, e), h = !0, Pe(i, t, "verify"), j(t) && (t = await ir(t, i))) : Pe(i, t, "verify");
973
- const y = Lt(Z.encode(e.protected ?? ""), Z.encode("."), typeof e.payload == "string" ? Z.encode(e.payload) : e.payload);
974
- let p;
970
+ throw new g("JWS Payload must be a string or an Uint8Array instance");
971
+ let y = !1;
972
+ typeof t == "function" ? (t = await t(n, e), y = !0, Pe(i, t, "verify"), j(t) && (t = await ir(t, i))) : Pe(i, t, "verify");
973
+ const p = Lt(ee.encode(e.protected ?? ""), ee.encode("."), typeof e.payload == "string" ? ee.encode(e.payload) : e.payload);
974
+ let h;
975
975
  try {
976
- p = C(e.signature);
976
+ h = C(e.signature);
977
977
  } catch {
978
- throw new E("Failed to base64url decode the signature");
978
+ throw new g("Failed to base64url decode the signature");
979
979
  }
980
- if (!await yr(i, t, p, y))
980
+ if (!await yr(i, t, h, p))
981
981
  throw new Fe();
982
- let l;
983
- if (o)
982
+ let d;
983
+ if (s)
984
984
  try {
985
- l = C(e.payload);
985
+ d = C(e.payload);
986
986
  } catch {
987
- throw new E("Failed to base64url decode the payload");
987
+ throw new g("Failed to base64url decode the payload");
988
988
  }
989
- else typeof e.payload == "string" ? l = Z.encode(e.payload) : l = e.payload;
990
- const T = { payload: l };
991
- return e.protected !== void 0 && (T.protectedHeader = n), e.header !== void 0 && (T.unprotectedHeader = e.header), h ? { ...T, key: t } : T;
989
+ else typeof e.payload == "string" ? d = ee.encode(e.payload) : d = e.payload;
990
+ const f = { payload: d };
991
+ return e.protected !== void 0 && (f.protectedHeader = n), e.header !== void 0 && (f.unprotectedHeader = e.header), y ? { ...f, key: t } : f;
992
992
  }
993
993
  async function Er(e, t, r) {
994
994
  if (e instanceof Uint8Array && (e = q.decode(e)), typeof e != "string")
995
- throw new E("Compact JWS must be a string or Uint8Array");
996
- const { 0: n, 1: a, 2: s, length: o } = e.split(".");
997
- if (o !== 3)
998
- throw new E("Invalid Compact JWS");
999
- const i = await fr({ payload: a, protected: n, signature: s }, t, r), c = { payload: i.payload, protectedHeader: i.protectedHeader };
995
+ throw new g("Compact JWS must be a string or Uint8Array");
996
+ const { 0: n, 1: a, 2: o, length: s } = e.split(".");
997
+ if (s !== 3)
998
+ throw new g("Invalid Compact JWS");
999
+ const i = await fr({ payload: a, protected: n, signature: o }, t, r), c = { payload: i.payload, protectedHeader: i.protectedHeader };
1000
1000
  return typeof t == "function" ? { ...c, key: i.key } : c;
1001
1001
  }
1002
1002
  const gr = (e) => Math.floor(e.getTime() / 1e3), tt = 60, rt = tt * 60, Te = rt * 24, mr = Te * 7, wr = Te * 365.25, Sr = /^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i, Ce = (e) => {
@@ -1053,51 +1053,51 @@ const gr = (e) => Math.floor(e.getTime() / 1e3), tt = 60, rt = tt * 60, Te = rt
1053
1053
  const { typ: a } = r;
1054
1054
  if (a && (typeof e.typ != "string" || Ne(e.typ) !== Ne(a)))
1055
1055
  throw new _('unexpected "typ" JWT header value', n, "typ", "check_failed");
1056
- const { requiredClaims: s = [], issuer: o, subject: i, audience: c, maxTokenAge: h } = r, y = [...s];
1057
- h !== void 0 && y.push("iat"), c !== void 0 && y.push("aud"), i !== void 0 && y.push("sub"), o !== void 0 && y.push("iss");
1058
- for (const R of new Set(y.reverse()))
1056
+ const { requiredClaims: o = [], issuer: s, subject: i, audience: c, maxTokenAge: y } = r, p = [...o];
1057
+ y !== void 0 && p.push("iat"), c !== void 0 && p.push("aud"), i !== void 0 && p.push("sub"), s !== void 0 && p.push("iss");
1058
+ for (const R of new Set(p.reverse()))
1059
1059
  if (!(R in n))
1060
1060
  throw new _(`missing required "${R}" claim`, n, R, "missing");
1061
- if (o && !(Array.isArray(o) ? o : [o]).includes(n.iss))
1061
+ if (s && !(Array.isArray(s) ? s : [s]).includes(n.iss))
1062
1062
  throw new _('unexpected "iss" claim value', n, "iss", "check_failed");
1063
1063
  if (i && n.sub !== i)
1064
1064
  throw new _('unexpected "sub" claim value', n, "sub", "check_failed");
1065
1065
  if (c && !Ar(n.aud, typeof c == "string" ? [c] : c))
1066
1066
  throw new _('unexpected "aud" claim value', n, "aud", "check_failed");
1067
- let p;
1067
+ let h;
1068
1068
  switch (typeof r.clockTolerance) {
1069
1069
  case "string":
1070
- p = Ce(r.clockTolerance);
1070
+ h = Ce(r.clockTolerance);
1071
1071
  break;
1072
1072
  case "number":
1073
- p = r.clockTolerance;
1073
+ h = r.clockTolerance;
1074
1074
  break;
1075
1075
  case "undefined":
1076
- p = 0;
1076
+ h = 0;
1077
1077
  break;
1078
1078
  default:
1079
1079
  throw new TypeError("Invalid clockTolerance option type");
1080
1080
  }
1081
- const { currentDate: l } = r, T = gr(l || /* @__PURE__ */ new Date());
1082
- if ((n.iat !== void 0 || h) && typeof n.iat != "number")
1081
+ const { currentDate: d } = r, f = gr(d || /* @__PURE__ */ new Date());
1082
+ if ((n.iat !== void 0 || y) && typeof n.iat != "number")
1083
1083
  throw new _('"iat" claim must be a number', n, "iat", "invalid");
1084
1084
  if (n.nbf !== void 0) {
1085
1085
  if (typeof n.nbf != "number")
1086
1086
  throw new _('"nbf" claim must be a number', n, "nbf", "invalid");
1087
- if (n.nbf > T + p)
1087
+ if (n.nbf > f + h)
1088
1088
  throw new _('"nbf" claim timestamp check failed', n, "nbf", "check_failed");
1089
1089
  }
1090
1090
  if (n.exp !== void 0) {
1091
1091
  if (typeof n.exp != "number")
1092
1092
  throw new _('"exp" claim must be a number', n, "exp", "invalid");
1093
- if (n.exp <= T - p)
1093
+ if (n.exp <= f - h)
1094
1094
  throw new we('"exp" claim timestamp check failed', n, "exp", "check_failed");
1095
1095
  }
1096
- if (h) {
1097
- const R = T - n.iat, de = typeof h == "number" ? h : Ce(h);
1098
- if (R - p > de)
1096
+ if (y) {
1097
+ const R = f - n.iat, Q = typeof y == "number" ? y : Ce(y);
1098
+ if (R - h > Q)
1099
1099
  throw new we('"iat" claim timestamp check failed (too far in the past)', n, "iat", "check_failed");
1100
- if (R < 0 - p)
1100
+ if (R < 0 - h)
1101
1101
  throw new _('"iat" claim timestamp check failed (it should be in the past)', n, "iat", "check_failed");
1102
1102
  }
1103
1103
  return n;
@@ -1107,8 +1107,8 @@ async function Rr(e, t, r) {
1107
1107
  const a = await Er(e, t, r);
1108
1108
  if ((n = a.protectedHeader.crit) != null && n.includes("b64") && a.protectedHeader.b64 === !1)
1109
1109
  throw new b("JWTs MUST NOT use unencoded payload");
1110
- const s = { payload: Tr(a.protectedHeader, a.payload, r), protectedHeader: a.protectedHeader };
1111
- return typeof t == "function" ? { ...s, key: a.key } : s;
1110
+ const o = { payload: Tr(a.protectedHeader, a.payload, r), protectedHeader: a.protectedHeader };
1111
+ return typeof t == "function" ? { ...o, key: a.key } : o;
1112
1112
  }
1113
1113
  const _r = C;
1114
1114
  function Ir(e) {
@@ -1139,9 +1139,9 @@ function Ir(e) {
1139
1139
  }
1140
1140
  const V = async (e) => {
1141
1141
  try {
1142
- const t = f.ALG, r = await sr(Ut, t);
1142
+ const t = E.ALG, r = await sr(Ut, t);
1143
1143
  return await Rr(e, r, {
1144
- issuer: f.ISSUER
1144
+ issuer: E.ISSUER
1145
1145
  });
1146
1146
  } catch {
1147
1147
  return;
@@ -1152,11 +1152,11 @@ const V = async (e) => {
1152
1152
  } catch {
1153
1153
  return;
1154
1154
  }
1155
- }, m = [];
1155
+ }, w = [];
1156
1156
  for (let e = 0; e < 256; ++e)
1157
- m.push((e + 256).toString(16).slice(1));
1157
+ w.push((e + 256).toString(16).slice(1));
1158
1158
  function kr(e, t = 0) {
1159
- return (m[e[t + 0]] + m[e[t + 1]] + m[e[t + 2]] + m[e[t + 3]] + "-" + m[e[t + 4]] + m[e[t + 5]] + "-" + m[e[t + 6]] + m[e[t + 7]] + "-" + m[e[t + 8]] + m[e[t + 9]] + "-" + m[e[t + 10]] + m[e[t + 11]] + m[e[t + 12]] + m[e[t + 13]] + m[e[t + 14]] + m[e[t + 15]]).toLowerCase();
1159
+ return (w[e[t + 0]] + w[e[t + 1]] + w[e[t + 2]] + w[e[t + 3]] + "-" + w[e[t + 4]] + w[e[t + 5]] + "-" + w[e[t + 6]] + w[e[t + 7]] + "-" + w[e[t + 8]] + w[e[t + 9]] + "-" + w[e[t + 10]] + w[e[t + 11]] + w[e[t + 12]] + w[e[t + 13]] + w[e[t + 14]] + w[e[t + 15]]).toLowerCase();
1160
1160
  }
1161
1161
  let fe;
1162
1162
  const Or = new Uint8Array(16);
@@ -1197,11 +1197,11 @@ async function Dr(e) {
1197
1197
  const sn = async (e, t) => {
1198
1198
  var r;
1199
1199
  const n = await V(e);
1200
- if (!n || !Array.isArray((r = n.payload) == null ? void 0 : r[f.SCOPES_KEY]))
1200
+ if (!n || !Array.isArray((r = n.payload) == null ? void 0 : r[E.SCOPES_KEY]))
1201
1201
  return !1;
1202
- const a = n.payload[f.SCOPES_KEY];
1203
- return Array.isArray(t) ? t.every((s) => a.includes(s)) : Object.keys(t).some(
1204
- (s) => t[s].every((o) => a.includes(o))
1202
+ const a = n.payload[E.SCOPES_KEY];
1203
+ return Array.isArray(t) ? t.every((o) => a.includes(o)) : Object.keys(t).some(
1204
+ (o) => t[o].every((s) => a.includes(s))
1205
1205
  );
1206
1206
  };
1207
1207
  function nt(e, t) {
@@ -1214,15 +1214,15 @@ const Le = (e, t) => {
1214
1214
  window.localStorage.setItem(e, r), nt(e, r);
1215
1215
  }, Ur = (e) => {
1216
1216
  window.localStorage.removeItem(e), nt(e, null);
1217
- }, He = (e) => window.localStorage.getItem(e), Lr = (e) => (window.addEventListener("storage", e), () => window.removeEventListener("storage", e));
1218
- function te({
1217
+ }, We = (e) => window.localStorage.getItem(e), Lr = (e) => (window.addEventListener("storage", e), () => window.removeEventListener("storage", e));
1218
+ function re({
1219
1219
  key: e,
1220
1220
  initialValue: t
1221
1221
  }) {
1222
- const r = Rt(Lr, () => He(e)), n = D(
1223
- (o) => {
1222
+ const r = Rt(Lr, () => We(e)), n = D(
1223
+ (s) => {
1224
1224
  try {
1225
- const i = typeof o == "function" ? o(JSON.parse(r)) : o;
1225
+ const i = typeof s == "function" ? s(JSON.parse(r)) : s;
1226
1226
  i == null ? Ur(e) : Le(e, i);
1227
1227
  } catch (i) {
1228
1228
  console.warn(i);
@@ -1231,42 +1231,42 @@ function te({
1231
1231
  [e, r]
1232
1232
  ), a = D(() => {
1233
1233
  n(t);
1234
- }, [t, n]), s = D(() => {
1234
+ }, [t, n]), o = D(() => {
1235
1235
  n(null);
1236
1236
  }, [n]);
1237
1237
  return $e(() => {
1238
1238
  try {
1239
- He(e) === null && typeof t < "u" && Le(e, t);
1240
- } catch (o) {
1241
- console.warn(o);
1239
+ We(e) === null && typeof t < "u" && Le(e, t);
1240
+ } catch (s) {
1241
+ console.warn(s);
1242
1242
  }
1243
- }, [e, t]), [r ? JSON.parse(r) : null, n, a, s];
1243
+ }, [e, t]), [r ? JSON.parse(r) : null, n, a, o];
1244
1244
  }
1245
- const w = [];
1245
+ const S = [];
1246
1246
  for (let e = 0; e < 256; ++e)
1247
- w.push((e + 256).toString(16).slice(1));
1248
- function Hr(e, t = 0) {
1249
- return (w[e[t + 0]] + w[e[t + 1]] + w[e[t + 2]] + w[e[t + 3]] + "-" + w[e[t + 4]] + w[e[t + 5]] + "-" + w[e[t + 6]] + w[e[t + 7]] + "-" + w[e[t + 8]] + w[e[t + 9]] + "-" + w[e[t + 10]] + w[e[t + 11]] + w[e[t + 12]] + w[e[t + 13]] + w[e[t + 14]] + w[e[t + 15]]).toLowerCase();
1247
+ S.push((e + 256).toString(16).slice(1));
1248
+ function Wr(e, t = 0) {
1249
+ return (S[e[t + 0]] + S[e[t + 1]] + S[e[t + 2]] + S[e[t + 3]] + "-" + S[e[t + 4]] + S[e[t + 5]] + "-" + S[e[t + 6]] + S[e[t + 7]] + "-" + S[e[t + 8]] + S[e[t + 9]] + "-" + S[e[t + 10]] + S[e[t + 11]] + S[e[t + 12]] + S[e[t + 13]] + S[e[t + 14]] + S[e[t + 15]]).toLowerCase();
1250
1250
  }
1251
1251
  let Ee;
1252
- const Wr = new Uint8Array(16);
1252
+ const Hr = new Uint8Array(16);
1253
1253
  function $r() {
1254
1254
  if (!Ee) {
1255
1255
  if (typeof crypto > "u" || !crypto.getRandomValues)
1256
1256
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
1257
1257
  Ee = crypto.getRandomValues.bind(crypto);
1258
1258
  }
1259
- return Ee(Wr);
1259
+ return Ee(Hr);
1260
1260
  }
1261
- const Jr = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), We = { randomUUID: Jr };
1261
+ const Jr = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), He = { randomUUID: Jr };
1262
1262
  function ge(e, t, r) {
1263
- if (We.randomUUID && !t && !e)
1264
- return We.randomUUID();
1263
+ if (He.randomUUID && !t && !e)
1264
+ return He.randomUUID();
1265
1265
  e = e || {};
1266
1266
  const n = e.random || (e.rng || $r)();
1267
- return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, Hr(n);
1267
+ return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, Wr(n);
1268
1268
  }
1269
- const W = "Your session has expired. For your security, please log in again to continue.", Yr = "Your session has been successfully terminated.", me = "Login failed. Please try again.", xr = "Error getting access token, please re-authenticate.", Mr = "You forgot to wrap your component in <AuthProvider>.", re = "@@auth@@", B = "LOADING", ae = "LOGIN", at = "LOGOUT", z = "success", O = "failure", ot = "include", st = "POST", it = "application/json", ne = {
1269
+ const H = "Your session has expired. For your security, please log in again to continue.", Yr = "Your session has been successfully terminated.", me = "Login failed. Please try again.", xr = "Error getting access token, please re-authenticate.", Mr = "You forgot to wrap your component in <AuthProvider>.", ne = "@@auth@@", B = "LOADING", oe = "LOGIN", at = "LOGOUT", z = "success", O = "failure", ot = "include", st = "POST", it = "application/json", ae = {
1270
1270
  GET_REGISTRATION_OPTIONS: `mutation GetPasskeyRegistrationOptions(
1271
1271
  $clientId: String!,
1272
1272
  $username: String!,
@@ -1349,33 +1349,34 @@ const W = "Your session has expired. For your security, please log in again to c
1349
1349
  }`
1350
1350
  }, $ = {
1351
1351
  GET_REGISTRATION_OPTIONS: {
1352
- schema: ne.GET_REGISTRATION_OPTIONS,
1352
+ schema: ae.GET_REGISTRATION_OPTIONS,
1353
1353
  method: "getPasskeyRegistrationOptions"
1354
1354
  },
1355
1355
  VERIFY_REGISTRATION: {
1356
- schema: ne.VERIFY_REGISTRATION,
1356
+ schema: ae.VERIFY_REGISTRATION,
1357
1357
  method: "verifyPasskeyRegistration"
1358
1358
  },
1359
1359
  GET_AUTHENTICATION_OPTIONS: {
1360
- schema: ne.GET_AUTHENTICATION_OPTIONS,
1360
+ schema: ae.GET_AUTHENTICATION_OPTIONS,
1361
1361
  method: "getPasskeyAuthenticationOptions"
1362
1362
  },
1363
1363
  VERIFY_AUTHENTICATION: {
1364
- schema: ne.VERIFY_AUTHENTICATION,
1364
+ schema: ae.VERIFY_AUTHENTICATION,
1365
1365
  method: "verifyPasskeyAuthentication"
1366
1366
  }
1367
1367
  }, J = async ({
1368
1368
  accessToken: e,
1369
1369
  type: t,
1370
1370
  clientId: r,
1371
- params: n = {}
1371
+ params: n = {},
1372
+ endpoint: a
1372
1373
  }) => {
1373
1374
  try {
1374
- const a = `Bearer ${e}`, s = await fetch(`${ct()}/graphql`, {
1375
+ const o = `Bearer ${e}`, s = await fetch(`${a}/graphql`, {
1375
1376
  credentials: ot,
1376
1377
  method: st,
1377
1378
  headers: {
1378
- authorization: a,
1379
+ authorization: o,
1379
1380
  "Content-Type": it,
1380
1381
  [Ge.CLIENT_ID]: `${r}`
1381
1382
  },
@@ -1386,21 +1387,22 @@ const W = "Your session has expired. For your security, please log in again to c
1386
1387
  });
1387
1388
  if (s.status !== 200)
1388
1389
  return { status: O, data: [] };
1389
- const { data: o } = await s.json();
1390
+ const { data: i } = await s.json();
1390
1391
  return {
1391
1392
  status: z,
1392
- data: o[t.method]
1393
+ data: i[t.method]
1393
1394
  };
1394
- } catch (a) {
1395
- return console.error(a), { status: O, data: [] };
1395
+ } catch (o) {
1396
+ return console.error(o), { status: O, data: [] };
1396
1397
  }
1397
- }, le = async ({
1398
+ }, de = async ({
1398
1399
  type: e,
1399
1400
  clientId: t,
1400
- params: r = {}
1401
+ params: r = {},
1402
+ endpoint: n
1401
1403
  }) => {
1402
1404
  try {
1403
- const n = await fetch(`${ct()}/${e}`, {
1405
+ const a = await fetch(`${n}/${e}`, {
1404
1406
  credentials: ot,
1405
1407
  method: st,
1406
1408
  headers: {
@@ -1409,17 +1411,17 @@ const W = "Your session has expired. For your security, please log in again to c
1409
1411
  },
1410
1412
  body: JSON.stringify(r)
1411
1413
  });
1412
- if (n.status !== 200)
1414
+ if (a.status !== 200)
1413
1415
  return { status: O, data: [] };
1414
- const { data: a } = await n.json();
1416
+ const { data: o } = await a.json();
1415
1417
  return {
1416
1418
  status: z,
1417
- data: a || []
1419
+ data: o || []
1418
1420
  };
1419
- } catch (n) {
1420
- return console.error(n), { status: O, data: [] };
1421
+ } catch (a) {
1422
+ return console.error(a), { status: O, data: [] };
1421
1423
  }
1422
- }, Gr = process.env.NODE_ENV === "production", Vr = !Gr, ct = () => Vr ? process && process?.env?.PUBLIC_AUTH_SERVER_URL ? process?.env?.PUBLIC_AUTH_SERVER_URL : "https://auth.gizmette.local.com:3003" : "https://mylogin.gizmette.com/auth", ut = {
1424
+ }, Gr = process.env.NODE_ENV === "production", Vr = !Gr, ct = {
1423
1425
  isLoading: !0,
1424
1426
  isAuthenticated: !1,
1425
1427
  user: void 0,
@@ -1429,7 +1431,7 @@ const W = "Your session has expired. For your security, please log in again to c
1429
1431
  }, jr = (e) => {
1430
1432
  try {
1431
1433
  const t = br(e);
1432
- return t ? t[f.USER_ID_KEY] : "";
1434
+ return t ? t[E.USER_ID_KEY] : "";
1433
1435
  } catch {
1434
1436
  return "";
1435
1437
  }
@@ -1437,12 +1439,14 @@ const W = "Your session has expired. For your security, please log in again to c
1437
1439
  userId: e,
1438
1440
  clientId: t,
1439
1441
  domain: r,
1440
- idToken: n = ""
1442
+ idToken: n = "",
1443
+ endpoint: a
1441
1444
  }) => {
1442
1445
  try {
1443
1446
  return {
1444
- status: (await le({
1445
- type: ce.LOGOUT,
1447
+ status: (await de({
1448
+ endpoint: a,
1449
+ type: ue.LOGOUT,
1446
1450
  clientId: t,
1447
1451
  params: {
1448
1452
  userId: e,
@@ -1462,34 +1466,36 @@ const W = "Your session has expired. For your security, please log in again to c
1462
1466
  clientId: r,
1463
1467
  nonce: n,
1464
1468
  type: a,
1465
- sessionExpiration: s,
1466
- code: o,
1469
+ sessionExpiration: o,
1470
+ code: s,
1467
1471
  code_verifier: i,
1468
1472
  domain: c,
1469
- ua: h
1473
+ ua: y,
1474
+ endpoint: p
1470
1475
  }) => {
1471
1476
  try {
1472
- const y = await le({
1473
- type: ce.LOGIN,
1477
+ const h = await de({
1478
+ endpoint: p,
1479
+ type: ue.LOGIN,
1474
1480
  clientId: r,
1475
1481
  params: {
1476
1482
  type: a || M.ID_AND_ACCESS_TOKEN,
1477
1483
  username: e,
1478
1484
  password: t,
1479
- sessionExpiration: s,
1485
+ sessionExpiration: o,
1480
1486
  nonce: n,
1481
- code: o,
1487
+ code: s,
1482
1488
  code_verifier: i,
1483
1489
  domain: c,
1484
- ua: h
1490
+ ua: y
1485
1491
  }
1486
- }), p = await V(y?.data?.idToken);
1487
- return p && p.payload[f.USER_ID_KEY] !== "" && p.payload[f.NONCE_KEY] === n ? {
1488
- idToken: y.data.idToken,
1489
- accessToken: y.data.accessToken,
1490
- refreshToken: y.data.refreshToken,
1491
- userId: p.payload[f.USER_ID_KEY],
1492
- email: p.payload[f.EMAIL_KEY],
1492
+ }), d = await V(h?.data?.idToken);
1493
+ return d && d.payload[E.USER_ID_KEY] !== "" && d.payload[E.NONCE_KEY] === n ? {
1494
+ idToken: h.data.idToken,
1495
+ accessToken: h.data.accessToken,
1496
+ refreshToken: h.data.refreshToken,
1497
+ userId: d.payload[E.USER_ID_KEY],
1498
+ email: d.payload[E.EMAIL_KEY],
1493
1499
  status: !0
1494
1500
  } : {
1495
1501
  status: !1
@@ -1502,11 +1508,13 @@ const W = "Your session has expired. For your security, please log in again to c
1502
1508
  }, qr = async ({
1503
1509
  nonce: e,
1504
1510
  clientId: t,
1505
- code_challenge: r
1511
+ code_challenge: r,
1512
+ endpoint: n
1506
1513
  }) => {
1507
1514
  try {
1508
- const n = await le({
1509
- type: ce.CODE,
1515
+ const a = await de({
1516
+ endpoint: n,
1517
+ type: ue.CODE,
1510
1518
  clientId: t,
1511
1519
  params: {
1512
1520
  type: M.CODE,
@@ -1514,9 +1522,9 @@ const W = "Your session has expired. For your security, please log in again to c
1514
1522
  code_challenge: r
1515
1523
  }
1516
1524
  });
1517
- return n?.data?.code ? {
1525
+ return a?.data?.code ? {
1518
1526
  status: z,
1519
- data: n.data.code
1527
+ data: a.data.code
1520
1528
  } : {
1521
1529
  status: O,
1522
1530
  data: ""
@@ -1533,11 +1541,13 @@ const W = "Your session has expired. For your security, please log in again to c
1533
1541
  nonce: r,
1534
1542
  refreshToken: n,
1535
1543
  accessToken: a,
1536
- domain: s
1544
+ domain: o,
1545
+ endpoint: s
1537
1546
  }) => {
1538
1547
  try {
1539
- const o = await le({
1540
- type: ce.REFRESH,
1548
+ const i = await de({
1549
+ endpoint: s,
1550
+ type: ue.REFRESH,
1541
1551
  clientId: e,
1542
1552
  params: {
1543
1553
  type: M.REFRESH_TOKEN,
@@ -1545,13 +1555,13 @@ const W = "Your session has expired. For your security, please log in again to c
1545
1555
  nonce: r,
1546
1556
  refreshToken: n,
1547
1557
  accessToken: a,
1548
- domain: s
1558
+ domain: o
1549
1559
  }
1550
- }), i = await V(o?.data?.accessToken);
1551
- return i && i.payload[f.USER_ID_KEY] !== "" && i.payload[f.NONCE_KEY] === r ? {
1552
- accessToken: o.data.accessToken,
1553
- refreshToken: o.data.refreshToken,
1554
- userId: i.payload[f.USER_ID_KEY],
1560
+ }), c = await V(i?.data?.accessToken);
1561
+ return c && c.payload[E.USER_ID_KEY] !== "" && c.payload[E.NONCE_KEY] === r ? {
1562
+ accessToken: i.data.accessToken,
1563
+ refreshToken: i.data.refreshToken,
1564
+ userId: c.payload[E.USER_ID_KEY],
1555
1565
  status: !0
1556
1566
  } : {
1557
1567
  status: !1
@@ -1564,18 +1574,20 @@ const W = "Your session has expired. For your security, please log in again to c
1564
1574
  };
1565
1575
  class Qr {
1566
1576
  constructor(t = null, r = null) {
1567
- X(this, "refreshTokenPromise", null);
1568
- X(this, "accessToken");
1569
- X(this, "refreshToken");
1577
+ Z(this, "refreshTokenPromise", null);
1578
+ Z(this, "accessToken");
1579
+ Z(this, "refreshToken");
1570
1580
  this.accessToken = t || "", this.refreshToken = r || "";
1571
1581
  }
1572
1582
  async refreshtoken({
1573
1583
  clientId: t,
1574
1584
  userId: r,
1575
1585
  nonce: n,
1576
- domain: a
1586
+ domain: a,
1587
+ endpoint: o
1577
1588
  }) {
1578
1589
  this.refreshTokenPromise || (this.refreshTokenPromise = this._refreshToken({
1590
+ endpoint: o,
1579
1591
  clientId: t,
1580
1592
  userId: r,
1581
1593
  nonce: n,
@@ -1588,25 +1600,27 @@ class Qr {
1588
1600
  }
1589
1601
  }
1590
1602
  async _refreshToken({
1591
- clientId: t,
1592
- userId: r,
1593
- nonce: n,
1594
- domain: a
1603
+ endpoint: t,
1604
+ clientId: r,
1605
+ userId: n,
1606
+ nonce: a,
1607
+ domain: o
1595
1608
  }) {
1596
1609
  const s = await V(this.refreshToken);
1597
- if (s && s.payload[f.USER_ID_KEY] !== "") {
1598
- const o = await zr({
1599
- clientId: t,
1600
- userId: r,
1601
- nonce: n,
1610
+ if (s && s.payload[E.USER_ID_KEY] !== "") {
1611
+ const i = await zr({
1612
+ endpoint: t,
1613
+ clientId: r,
1614
+ userId: n,
1615
+ nonce: a,
1602
1616
  refreshToken: this.refreshToken,
1603
1617
  accessToken: this.accessToken,
1604
- domain: a
1618
+ domain: o
1605
1619
  });
1606
- return o.status ? (this.accessToken = o.accessToken, this.refreshToken = o.refreshToken, {
1620
+ return i.status ? (this.accessToken = i.accessToken, this.refreshToken = i.refreshToken, {
1607
1621
  status: z,
1608
- newAccessToken: o.accessToken,
1609
- newRefreshToken: o.refreshToken
1622
+ newAccessToken: i.accessToken,
1623
+ newRefreshToken: i.refreshToken
1610
1624
  }) : {
1611
1625
  status: O
1612
1626
  };
@@ -1623,7 +1637,7 @@ const Xr = (e) => D(
1623
1637
  [e]
1624
1638
  ), Y = () => {
1625
1639
  throw new Error(Mr);
1626
- }, lt = _t({
1640
+ }, ut = _t({
1627
1641
  isAuthenticated: !1,
1628
1642
  isLoading: !1,
1629
1643
  login: Y,
@@ -1635,13 +1649,13 @@ const Xr = (e) => D(
1635
1649
  logoutReason: "",
1636
1650
  authenticationType: ""
1637
1651
  }), Zr = Tt.createContext({
1638
- state: ut,
1652
+ state: ct,
1639
1653
  dispatch: () => {
1640
1654
  }
1641
1655
  }), en = (e, t) => t?.type === B ? {
1642
1656
  ...e,
1643
1657
  isLoading: t.payload.isLoading
1644
- } : t?.type === ae ? {
1658
+ } : t?.type === oe ? {
1645
1659
  ...e,
1646
1660
  isLoading: !1,
1647
1661
  isAuthenticated: !0,
@@ -1660,106 +1674,118 @@ const Xr = (e) => D(
1660
1674
  sessionExpiration: t,
1661
1675
  clientId: r,
1662
1676
  domain: n = "",
1663
- debug: a = !1
1677
+ debug: a = !1,
1678
+ endpoint: o = Vr ? "https://auth.gizmette.local.com:3003" : "https://mylogin.gizmette.com/auth"
1664
1679
  }) => {
1665
- const [s, o] = It(en, {
1666
- ...ut,
1680
+ const [s, i] = It(en, {
1681
+ ...ct,
1667
1682
  debug: a
1668
- }), i = Xr(a), c = bt(!1), [h, y, , p] = te({
1669
- key: `${re}::${r}::@@user@@`
1670
- }), [l, T, , R] = te({
1671
- key: `${re}::${r}::@@access@@`
1672
- }), [de, he, , Re] = te(
1683
+ }), c = Xr(a), y = bt(!1), [p, h, , d] = re({
1684
+ key: `${ne}::${r}::@@user@@`
1685
+ }), [f, R, , Q] = re({
1686
+ key: `${ne}::${r}::@@access@@`
1687
+ }), [lt, he, , Re] = re(
1673
1688
  {
1674
- key: `${re}::${r}::@@refresh@@`
1689
+ key: `${ne}::${r}::@@refresh@@`
1675
1690
  }
1676
- ), [dt, _e, , Ie] = te({
1677
- key: `${re}::${r}::@@nonce@@`
1678
- }), ht = new Qr(l, de), Q = D(() => {
1679
- i("removeLocalStorage: removing local storage"), p(), R(), Re(), Ie();
1691
+ ), [dt, _e, , Ie] = re({
1692
+ key: `${ne}::${r}::@@nonce@@`
1693
+ }), ht = new Qr(f, lt), X = D(() => {
1694
+ c("removeLocalStorage: removing local storage"), d(), Q(), Re(), Ie();
1680
1695
  }, [
1681
- R,
1682
- p,
1696
+ Q,
1697
+ d,
1683
1698
  Ie,
1684
1699
  Re,
1685
- i
1700
+ c
1686
1701
  ]), F = D(
1687
1702
  (u) => {
1688
- i(
1703
+ c(
1689
1704
  "removeStateAndLocalStorage: removing state and local storage with reason: ",
1690
1705
  u
1691
- ), o({
1706
+ ), i({
1692
1707
  type: at,
1693
1708
  payload: {
1694
- logoutReason: u || W
1709
+ logoutReason: u || H
1695
1710
  }
1696
- }), Q(), o({ type: B, payload: { isLoading: !1 } });
1711
+ }), X(), i({ type: B, payload: { isLoading: !1 } });
1697
1712
  },
1698
- [Q, i]
1713
+ [X, c]
1699
1714
  ), N = D(
1700
1715
  async (u) => {
1701
- i("invalidateAndLogout: invalidating and logging out");
1702
- const { user: g } = s, d = g?.userId || jr(h);
1703
- d || i(
1716
+ c("invalidateAndLogout: invalidating and logging out");
1717
+ const { user: m } = s, l = m?.userId || jr(p);
1718
+ l || c(
1704
1719
  "invalidateAndLogout: user cannot be identified, logging out without userId"
1705
1720
  ), await Fr({
1706
- userId: d,
1721
+ userId: l,
1707
1722
  clientId: r,
1708
1723
  domain: n,
1709
- idToken: h
1710
- }), F(u || W);
1724
+ idToken: p,
1725
+ endpoint: o
1726
+ }), F(u || H);
1711
1727
  },
1712
- [h, s, r, n, F, i]
1728
+ [
1729
+ p,
1730
+ s,
1731
+ r,
1732
+ n,
1733
+ F,
1734
+ c,
1735
+ o
1736
+ ]
1713
1737
  );
1714
1738
  $e(() => {
1715
- if (!c.current)
1716
- return s.isLoading && h !== null ? (async () => {
1739
+ if (!y.current)
1740
+ return s.isLoading && p !== null ? (async () => {
1717
1741
  try {
1718
- const u = await V(h);
1719
- u && u.payload[f.USER_ID_KEY] !== "" ? (i("useEffect: setting the authentication state"), o({
1720
- type: ae,
1742
+ const u = await V(p);
1743
+ u && u.payload[E.USER_ID_KEY] !== "" ? (c("useEffect: setting the authentication state"), i({
1744
+ type: oe,
1721
1745
  payload: {
1722
- authenticationType: u.payload[f.AUTH_TYPE_KEY],
1746
+ authenticationType: u.payload[E.AUTH_TYPE_KEY],
1723
1747
  user: {
1724
- userId: u.payload[f.USER_ID_KEY],
1725
- username: u.payload[f.USERNAME_KEY],
1726
- email: u.payload[f.EMAIL_KEY]
1748
+ userId: u.payload[E.USER_ID_KEY],
1749
+ username: u.payload[E.USERNAME_KEY],
1750
+ email: u.payload[E.EMAIL_KEY]
1727
1751
  }
1728
1752
  }
1729
- })) : (i("useEffect: invalid JWT, invalidating and logging out"), await N(W));
1753
+ })) : (c("useEffect: invalid JWT, invalidating and logging out"), await N(H));
1730
1754
  } catch {
1731
- i(
1755
+ c(
1732
1756
  "useEffect: exception validating JWT, invalidating and logging out"
1733
- ), await N(W);
1757
+ ), await N(H);
1734
1758
  }
1735
- })() : (i("useEffect: setting the loading state to false"), o({ type: B, payload: { isLoading: !1 } })), () => {
1736
- c.current = !0;
1759
+ })() : (c("useEffect: setting the loading state to false"), i({ type: B, payload: { isLoading: !1 } })), () => {
1760
+ y.current = !0;
1737
1761
  };
1738
- }, [s.isLoading, h, N, i]);
1739
- const pt = async (u, g) => {
1740
- o({ type: B, payload: { isLoading: !0 } }), Q();
1741
- const d = ge();
1742
- _e(d), i("login: Logging in with password");
1762
+ }, [s.isLoading, p, N, c]);
1763
+ const pt = async (u, m) => {
1764
+ i({ type: B, payload: { isLoading: !0 } }), X();
1765
+ const l = ge();
1766
+ _e(l), c("login: Logging in with password");
1743
1767
  const { code_verifier: K, code_challenge: wt } = await Dr(), be = await qr({
1744
- nonce: d,
1768
+ endpoint: o,
1769
+ nonce: l,
1745
1770
  clientId: r,
1746
1771
  code_challenge: wt
1747
1772
  });
1748
1773
  if (be.status) {
1749
1774
  const U = await Br({
1775
+ endpoint: o,
1750
1776
  username: u,
1751
- password: g,
1777
+ password: m,
1752
1778
  clientId: r,
1753
1779
  sessionExpiration: t,
1754
- nonce: d,
1780
+ nonce: l,
1755
1781
  type: M.CODE,
1756
1782
  code: be.data,
1757
1783
  code_verifier: K,
1758
1784
  domain: n,
1759
1785
  ua: navigator.userAgent
1760
1786
  });
1761
- return U.status ? (y(U.idToken), T(U.accessToken), he(U.refreshToken), o({
1762
- type: ae,
1787
+ return U.status ? (h(U.idToken), R(U.accessToken), he(U.refreshToken), i({
1788
+ type: oe,
1763
1789
  payload: {
1764
1790
  authenticationType: M.CODE,
1765
1791
  user: {
@@ -1774,38 +1800,40 @@ const Xr = (e) => D(
1774
1800
  }, yt = async (u) => {
1775
1801
  u?.preventDefault(), await N(Yr);
1776
1802
  }, ft = async () => {
1777
- const { isAuthenticated: u, user: g } = s;
1803
+ const { isAuthenticated: u, user: m } = s;
1778
1804
  try {
1779
- if (u && g && g.userId) {
1780
- if (l) {
1781
- i("getAccessToken");
1782
- const K = await V(l);
1783
- if (K && K.payload[f.USER_ID_KEY] !== "")
1784
- return l;
1805
+ if (u && m && m.userId) {
1806
+ if (f) {
1807
+ c("getAccessToken");
1808
+ const K = await V(f);
1809
+ if (K && K.payload[E.USER_ID_KEY] !== "")
1810
+ return f;
1785
1811
  }
1786
- i("getAccessToken: invalid access token, trying to refresh it");
1787
- const d = await ht.refreshtoken({
1812
+ c("getAccessToken: invalid access token, trying to refresh it");
1813
+ const l = await ht.refreshtoken({
1814
+ endpoint: o,
1788
1815
  clientId: r,
1789
- userId: g.userId,
1816
+ userId: m.userId,
1790
1817
  nonce: dt,
1791
1818
  domain: n
1792
1819
  });
1793
- return d.status && d.status === "success" && d.newAccessToken ? (T(d.newAccessToken), he(d.newRefreshToken), d.newAccessToken) : (i(
1820
+ return l.status && l.status === "success" && l.newAccessToken ? (R(l.newAccessToken), he(l.newRefreshToken), l.newAccessToken) : (c(
1794
1821
  "getAccessToken: invalid refresh token, need to re-authenticate"
1795
- ), await N(W), "");
1822
+ ), await N(H), "");
1796
1823
  }
1797
- return i(
1824
+ return c(
1798
1825
  "getAccessToken: user is not authenticated, cannot get access token"
1799
- ), await N(W), "";
1826
+ ), await N(H), "";
1800
1827
  } catch {
1801
- return i(
1828
+ return c(
1802
1829
  "getAccessToken: exception occurred, invalidating and logging out"
1803
1830
  ), await N(xr), "";
1804
1831
  }
1805
- }, Et = () => s.isAuthenticated && h ? h : "", gt = async () => {
1832
+ }, Et = () => s.isAuthenticated && p ? p : "", gt = async () => {
1806
1833
  const { user: u } = s;
1807
- let g = await J({
1808
- accessToken: l,
1834
+ let m = await J({
1835
+ endpoint: o,
1836
+ accessToken: f,
1809
1837
  clientId: r,
1810
1838
  type: $.GET_REGISTRATION_OPTIONS,
1811
1839
  params: {
@@ -1814,23 +1842,25 @@ const Xr = (e) => D(
1814
1842
  username: u?.username
1815
1843
  }
1816
1844
  });
1817
- if (g.status)
1845
+ if (m.status)
1818
1846
  try {
1819
- const d = await Ct(g.data);
1820
- return g = await J({
1821
- accessToken: l,
1847
+ const l = await Ct(m.data);
1848
+ return m = await J({
1849
+ endpoint: o,
1850
+ accessToken: f,
1822
1851
  clientId: r,
1823
1852
  type: $.VERIFY_REGISTRATION,
1824
1853
  params: {
1825
1854
  clientId: r,
1826
1855
  id: u?.userId,
1827
1856
  username: u?.username,
1828
- registration: d
1857
+ registration: l
1829
1858
  }
1830
- }), !!(g.status && g.data.length > 0);
1859
+ }), !!(m.status && m.data.length > 0);
1831
1860
  } catch {
1832
1861
  return await J({
1833
- accessToken: l,
1862
+ endpoint: o,
1863
+ accessToken: f,
1834
1864
  clientId: r,
1835
1865
  type: $.VERIFY_REGISTRATION,
1836
1866
  params: {
@@ -1843,54 +1873,57 @@ const Xr = (e) => D(
1843
1873
  }
1844
1874
  return !1;
1845
1875
  }, mt = async () => {
1846
- o({ type: B, payload: { isLoading: !0 } }), Q();
1876
+ i({ type: B, payload: { isLoading: !0 } }), X();
1847
1877
  const u = ge();
1848
- _e(u), i("loginWithPasskey");
1849
- const g = ge();
1850
- let d = await J({
1851
- accessToken: l,
1878
+ _e(u), c("loginWithPasskey");
1879
+ const m = ge();
1880
+ let l = await J({
1881
+ endpoint: o,
1882
+ accessToken: f,
1852
1883
  clientId: r,
1853
1884
  type: $.GET_AUTHENTICATION_OPTIONS,
1854
1885
  params: {
1855
- id: g,
1886
+ id: m,
1856
1887
  clientId: r
1857
1888
  }
1858
1889
  });
1859
- if (d.status)
1890
+ if (l.status)
1860
1891
  try {
1861
- const K = await Dt(d.data);
1862
- return d = await J({
1863
- accessToken: l,
1892
+ const K = await Dt(l.data);
1893
+ return l = await J({
1894
+ endpoint: o,
1895
+ accessToken: f,
1864
1896
  clientId: r,
1865
1897
  type: $.VERIFY_AUTHENTICATION,
1866
1898
  params: {
1867
1899
  clientId: r,
1868
- id: g,
1900
+ id: m,
1869
1901
  authentication: K,
1870
1902
  nonce: u,
1871
1903
  domain: n,
1872
1904
  sessionExpiration: t,
1873
1905
  ua: navigator.userAgent
1874
1906
  }
1875
- }), d.data.status === z ? (y(d.data.idToken), T(d.data.accessToken), he(d.data.refreshToken), o({
1876
- type: ae,
1907
+ }), l.data.status === z ? (h(l.data.idToken), R(l.data.accessToken), he(l.data.refreshToken), i({
1908
+ type: oe,
1877
1909
  payload: {
1878
1910
  authenticationType: M.PASSKEY,
1879
1911
  user: {
1880
- userId: d.data.userId,
1881
- username: d.data.username,
1882
- email: d.data.email
1912
+ userId: l.data.userId,
1913
+ username: l.data.username,
1914
+ email: l.data.email
1883
1915
  }
1884
1916
  }
1885
1917
  }), !0) : (F(me), !1);
1886
1918
  } catch {
1887
1919
  return await J({
1888
- accessToken: l,
1920
+ endpoint: o,
1921
+ accessToken: f,
1889
1922
  clientId: r,
1890
1923
  type: $.VERIFY_AUTHENTICATION,
1891
1924
  params: {
1892
1925
  clientId: r,
1893
- id: g,
1926
+ id: m,
1894
1927
  authentication: {},
1895
1928
  nonce: u,
1896
1929
  domain: n,
@@ -1900,8 +1933,8 @@ const Xr = (e) => D(
1900
1933
  }
1901
1934
  return !1;
1902
1935
  };
1903
- return /* @__PURE__ */ ke(Zr.Provider, { value: { state: s, dispatch: o }, children: /* @__PURE__ */ ke(
1904
- lt.Provider,
1936
+ return /* @__PURE__ */ ke(Zr.Provider, { value: { state: s, dispatch: i }, children: /* @__PURE__ */ ke(
1937
+ ut.Provider,
1905
1938
  {
1906
1939
  value: {
1907
1940
  ...s,
@@ -1915,7 +1948,7 @@ const Xr = (e) => D(
1915
1948
  children: e
1916
1949
  }
1917
1950
  ) });
1918
- }, un = (e = lt) => kt(e);
1951
+ }, un = (e = ut) => kt(e);
1919
1952
  export {
1920
1953
  M as AUTH_TYPES,
1921
1954
  cn as AuthProvider,