@versini/auth-provider 7.1.2 → 7.3.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
- var Et = Object.defineProperty;
2
- var mt = (e, t, r) => t in e ? Et(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var j = (e, t, r) => mt(e, typeof t != "symbol" ? t + "" : t, r);
1
+ var gt = Object.defineProperty;
2
+ var Et = (e, t, r) => t in e ? gt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var F = (e, t, r) => Et(e, typeof t != "symbol" ? t + "" : t, r);
4
4
  import { jsx as be } from "react/jsx-runtime";
5
- import wt, { useSyncExternalStore as St, useCallback as N, useEffect as He, createContext as At, useReducer as Tt, useRef as Rt, useContext as _t } from "react";
5
+ import mt, { useSyncExternalStore as wt, useCallback as N, useEffect as He, createContext as St, useReducer as At, useRef as Tt, useContext as Rt } from "react";
6
6
  /*!
7
- @versini/auth-provider v7.1.2
7
+ @versini/auth-provider v7.3.0
8
8
  © 2024 gizmette.com
9
9
  */
10
10
  try {
11
11
  window.__VERSINI_AUTH_CLIENT__ || (window.__VERSINI_AUTH_CLIENT__ = {
12
- version: "7.1.2",
13
- buildTime: "08/26/2024 06:52 PM EDT",
12
+ version: "7.3.0",
13
+ buildTime: "09/01/2024 05:46 PM EDT",
14
14
  homepage: "https://github.com/aversini/auth-client",
15
15
  license: "MIT"
16
16
  });
@@ -23,7 +23,7 @@ function _(e) {
23
23
  r += String.fromCharCode(a);
24
24
  return btoa(r).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
25
25
  }
26
- function re(e) {
26
+ function ne(e) {
27
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
29
  s[i] = a.charCodeAt(i);
@@ -36,88 +36,88 @@ function We(e) {
36
36
  const { id: t } = e;
37
37
  return {
38
38
  ...e,
39
- id: re(t),
39
+ id: ne(t),
40
40
  transports: e.transports
41
41
  };
42
42
  }
43
- function xe(e) {
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 w extends Error {
46
+ class S 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
  }
50
50
  }
51
- function It({ error: e, options: t }) {
51
+ function _t({ error: e, options: t }) {
52
52
  const { publicKey: r } = t;
53
53
  if (!r)
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 w({
57
+ return new S({
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 w({
64
+ return new S({
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 w({
70
+ return new S({
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 w({
77
+ return new S({
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 w({
83
+ return new S({
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 w({
89
+ return r.pubKeyCredParams.filter((a) => a.type === "public-key").length === 0 ? new S({
90
90
  message: 'No entry in pubKeyCredParams was of type "public-key"',
91
91
  code: "ERROR_MALFORMED_PUBKEYCREDPARAMS",
92
92
  cause: e
93
- }) : new w({
93
+ }) : new S({
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
97
97
  });
98
98
  if (e.name === "SecurityError") {
99
99
  const n = window.location.hostname;
100
- if (xe(n)) {
100
+ if (Ye(n)) {
101
101
  if (r.rp.id !== n)
102
- return new w({
102
+ return new S({
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 w({
107
+ } else return new S({
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 w({
114
+ return new S({
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 w({
120
+ return new S({
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
@@ -125,7 +125,7 @@ function It({ error: e, options: t }) {
125
125
  }
126
126
  return e;
127
127
  }
128
- class bt {
128
+ class It {
129
129
  createNewAbortSignal() {
130
130
  if (this.controller) {
131
131
  const r = new Error("Cancelling existing WebAuthn API call for new one");
@@ -141,29 +141,29 @@ class bt {
141
141
  }
142
142
  }
143
143
  }
144
- const Je = new bt(), vt = ["cross-platform", "platform"];
145
- function Ye(e) {
146
- if (e && !(vt.indexOf(e) < 0))
144
+ const xe = new It(), bt = ["cross-platform", "platform"];
145
+ function Je(e) {
146
+ if (e && !(bt.indexOf(e) < 0))
147
147
  return e;
148
148
  }
149
- async function Ot(e) {
149
+ async function vt(e) {
150
150
  if (!Se())
151
151
  throw new Error("WebAuthn is not supported in this browser");
152
152
  const r = { publicKey: {
153
153
  ...e,
154
- challenge: re(e.challenge),
154
+ challenge: ne(e.challenge),
155
155
  user: {
156
156
  ...e.user,
157
- id: re(e.user.id)
157
+ id: ne(e.user.id)
158
158
  },
159
159
  excludeCredentials: e.excludeCredentials?.map(We)
160
160
  } };
161
- r.signal = Je.createNewAbortSignal();
161
+ r.signal = xe.createNewAbortSignal();
162
162
  let n;
163
163
  try {
164
164
  n = await navigator.credentials.create(r);
165
- } catch (u) {
166
- throw It({ error: u, options: r });
165
+ } catch (l) {
166
+ throw _t({ error: l, options: r });
167
167
  }
168
168
  if (!n)
169
169
  throw new Error("Registration was not completed");
@@ -174,23 +174,23 @@ async function Ot(e) {
174
174
  if (typeof s.getPublicKeyAlgorithm == "function")
175
175
  try {
176
176
  h = s.getPublicKeyAlgorithm();
177
- } catch (u) {
178
- he("getPublicKeyAlgorithm()", u);
177
+ } catch (l) {
178
+ he("getPublicKeyAlgorithm()", l);
179
179
  }
180
- let f;
180
+ let y;
181
181
  if (typeof s.getPublicKey == "function")
182
182
  try {
183
- const u = s.getPublicKey();
184
- u !== null && (f = _(u));
185
- } catch (u) {
186
- he("getPublicKey()", u);
183
+ const l = s.getPublicKey();
184
+ l !== null && (y = _(l));
185
+ } catch (l) {
186
+ he("getPublicKey()", l);
187
187
  }
188
188
  let p;
189
189
  if (typeof s.getAuthenticatorData == "function")
190
190
  try {
191
191
  p = _(s.getAuthenticatorData());
192
- } catch (u) {
193
- he("getAuthenticatorData()", u);
192
+ } catch (l) {
193
+ he("getAuthenticatorData()", l);
194
194
  }
195
195
  return {
196
196
  id: a,
@@ -200,58 +200,58 @@ async function Ot(e) {
200
200
  clientDataJSON: _(s.clientDataJSON),
201
201
  transports: c,
202
202
  publicKeyAlgorithm: h,
203
- publicKey: f,
203
+ publicKey: y,
204
204
  authenticatorData: p
205
205
  },
206
206
  type: i,
207
207
  clientExtensionResults: n.getClientExtensionResults(),
208
- authenticatorAttachment: Ye(n.authenticatorAttachment)
208
+ authenticatorAttachment: Je(n.authenticatorAttachment)
209
209
  };
210
210
  }
211
211
  function he(e, t) {
212
212
  console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.
213
213
  `, t);
214
214
  }
215
- function kt() {
215
+ function Ot() {
216
216
  if (!Se())
217
217
  return new Promise((t) => t(!1));
218
218
  const e = window.PublicKeyCredential;
219
219
  return e.isConditionalMediationAvailable === void 0 ? new Promise((t) => t(!1)) : e.isConditionalMediationAvailable();
220
220
  }
221
- function Pt({ error: e, options: t }) {
221
+ function kt({ error: e, options: t }) {
222
222
  const { publicKey: r } = t;
223
223
  if (!r)
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 w({
227
+ return new S({
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 w({
234
+ return new S({
235
235
  message: e.message,
236
236
  code: "ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",
237
237
  cause: e
238
238
  });
239
239
  if (e.name === "SecurityError") {
240
240
  const n = window.location.hostname;
241
- if (xe(n)) {
241
+ if (Ye(n)) {
242
242
  if (r.rpId !== n)
243
- return new w({
243
+ return new S({
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 w({
248
+ } else return new S({
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 w({
254
+ return new S({
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
@@ -259,62 +259,62 @@ function Pt({ error: e, options: t }) {
259
259
  }
260
260
  return e;
261
261
  }
262
- async function Ct(e, t = !1) {
262
+ async function Pt(e, t = !1) {
263
263
  if (!Se())
264
264
  throw new Error("WebAuthn is not supported in this browser");
265
265
  let r;
266
266
  e.allowCredentials?.length !== 0 && (r = e.allowCredentials?.map(We));
267
267
  const n = {
268
268
  ...e,
269
- challenge: re(e.challenge),
269
+ challenge: ne(e.challenge),
270
270
  allowCredentials: r
271
271
  }, a = {};
272
272
  if (t) {
273
- if (!await kt())
273
+ if (!await Ot())
274
274
  throw Error("Browser does not support WebAuthn autofill");
275
275
  if (document.querySelectorAll("input[autocomplete$='webauthn']").length < 1)
276
276
  throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');
277
277
  a.mediation = "conditional", n.allowCredentials = [];
278
278
  }
279
- a.publicKey = n, a.signal = Je.createNewAbortSignal();
279
+ a.publicKey = n, a.signal = xe.createNewAbortSignal();
280
280
  let o;
281
281
  try {
282
282
  o = await navigator.credentials.get(a);
283
283
  } catch (p) {
284
- throw Pt({ error: p, options: a });
284
+ throw kt({ error: p, options: a });
285
285
  }
286
286
  if (!o)
287
287
  throw new Error("Authentication was not completed");
288
288
  const { id: s, rawId: i, response: c, type: h } = o;
289
- let f;
290
- return c.userHandle && (f = _(c.userHandle)), {
289
+ let y;
290
+ return c.userHandle && (y = _(c.userHandle)), {
291
291
  id: s,
292
292
  rawId: _(i),
293
293
  response: {
294
294
  authenticatorData: _(c.authenticatorData),
295
295
  clientDataJSON: _(c.clientDataJSON),
296
296
  signature: _(c.signature),
297
- userHandle: f
297
+ userHandle: y
298
298
  },
299
299
  type: h,
300
300
  clientExtensionResults: o.getClientExtensionResults(),
301
- authenticatorAttachment: Ye(o.authenticatorAttachment)
301
+ authenticatorAttachment: Je(o.authenticatorAttachment)
302
302
  };
303
303
  }
304
304
  /*!
305
- @versini/auth-common v4.0.0
305
+ @versini/auth-common v4.1.0
306
306
  © 2024 gizmette.com
307
307
  */
308
308
  try {
309
309
  window.__VERSINI_AUTH_COMMON__ || (window.__VERSINI_AUTH_COMMON__ = {
310
- version: "4.0.0",
311
- buildTime: "08/26/2024 06:51 PM EDT",
310
+ version: "4.1.0",
311
+ buildTime: "09/01/2024 05:46 PM EDT",
312
312
  homepage: "https://github.com/aversini/auth-client",
313
313
  license: "MIT"
314
314
  });
315
315
  } catch {
316
316
  }
317
- const oe = {
317
+ const W = {
318
318
  ID_TOKEN: "id_token",
319
319
  ACCESS_TOKEN: "token",
320
320
  ID_AND_ACCESS_TOKEN: "id_token token",
@@ -323,19 +323,20 @@ const oe = {
323
323
  PASSKEY: "passkey"
324
324
  }, Ge = {
325
325
  CLIENT_ID: "X-Auth-ClientId"
326
- }, S = {
326
+ }, f = {
327
327
  ALG: "RS256",
328
328
  USER_ID_KEY: "sub",
329
+ USERNAME_KEY: "username",
330
+ EMAIL_KEY: "email",
329
331
  TOKEN_ID_KEY: "__raw",
330
332
  NONCE_KEY: "_nonce",
331
- USERNAME_KEY: "username",
332
333
  AUTH_TYPE_KEY: "auth_type",
333
334
  EXPIRES_AT_KEY: "exp",
334
335
  CREATED_AT_KEY: "iat",
335
336
  SCOPES_KEY: "scopes",
336
337
  CLIENT_ID_KEY: "aud",
337
338
  ISSUER: "gizmette.com"
338
- }, Nt = `-----BEGIN PUBLIC KEY-----
339
+ }, Ct = `-----BEGIN PUBLIC KEY-----
339
340
  MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsF6i3Jd9fY/3COqCw/m7
340
341
  w5PKyTYLGAI2I6SIIdpe6i6DOCbEkmDz7LdVsBqwNtVi8gvWYIj+8ol6rU3qu1v5
341
342
  i1Jd45GSK4kzkVdgCmQZbM5ak0KI99q5wsrAIzUd+LRJ2HRvWtr5IYdsIiXaQjle
@@ -348,24 +349,24 @@ awIDAQAB
348
349
  LOGOUT: "logout",
349
350
  LOGIN: "login",
350
351
  REFRESH: "refresh"
351
- }, ce = crypto, Me = (e) => e instanceof CryptoKey, F = new TextEncoder(), G = new TextDecoder();
352
- function Dt(...e) {
352
+ }, ce = crypto, Me = (e) => e instanceof CryptoKey, B = new TextEncoder(), M = new TextDecoder();
353
+ function Nt(...e) {
353
354
  const t = e.reduce((a, { length: o }) => a + o, 0), r = new Uint8Array(t);
354
355
  let n = 0;
355
356
  for (const a of e)
356
357
  r.set(a, n), n += a.length;
357
358
  return r;
358
359
  }
359
- const Ut = (e) => {
360
+ const Dt = (e) => {
360
361
  const t = atob(e), r = new Uint8Array(t.length);
361
362
  for (let n = 0; n < t.length; n++)
362
363
  r[n] = t.charCodeAt(n);
363
364
  return r;
364
- }, Y = (e) => {
365
+ }, G = (e) => {
365
366
  let t = e;
366
- t instanceof Uint8Array && (t = G.decode(t)), t = t.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "");
367
+ t instanceof Uint8Array && (t = M.decode(t)), t = t.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "");
367
368
  try {
368
- return Ut(t);
369
+ return Dt(t);
369
370
  } catch {
370
371
  throw new TypeError("The input to be decoded is not correctly encoded.");
371
372
  }
@@ -395,7 +396,7 @@ class ve extends D {
395
396
  super(t), this.code = "ERR_JWT_EXPIRED", this.claim = n, this.reason = a, this.payload = r;
396
397
  }
397
398
  }
398
- class Kt extends D {
399
+ class Ut extends D {
399
400
  constructor() {
400
401
  super(...arguments), this.code = "ERR_JOSE_ALG_NOT_ALLOWED";
401
402
  }
@@ -411,7 +412,7 @@ class k extends D {
411
412
  return "ERR_JOSE_NOT_SUPPORTED";
412
413
  }
413
414
  }
414
- class m extends D {
415
+ class w extends D {
415
416
  constructor() {
416
417
  super(...arguments), this.code = "ERR_JWS_INVALID";
417
418
  }
@@ -427,7 +428,7 @@ let v = class extends D {
427
428
  return "ERR_JWT_INVALID";
428
429
  }
429
430
  };
430
- class $t extends D {
431
+ class Kt extends D {
431
432
  constructor() {
432
433
  super(...arguments), this.code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED", this.message = "signature verification failed";
433
434
  }
@@ -438,7 +439,7 @@ class $t extends D {
438
439
  function b(e, t = "algorithm.name") {
439
440
  return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`);
440
441
  }
441
- function B(e, t) {
442
+ function q(e, t) {
442
443
  return e.name === t;
443
444
  }
444
445
  function pe(e) {
@@ -456,7 +457,7 @@ function Lt(e) {
456
457
  throw new Error("unreachable");
457
458
  }
458
459
  }
459
- function Ht(e, t) {
460
+ function $t(e, t) {
460
461
  if (t.length && !t.some((r) => e.usages.includes(r))) {
461
462
  let r = "CryptoKey does not support this operation, its usages must include ";
462
463
  if (t.length > 2) {
@@ -466,12 +467,12 @@ function Ht(e, t) {
466
467
  throw new TypeError(r);
467
468
  }
468
469
  }
469
- function Wt(e, t, ...r) {
470
+ function Ht(e, t, ...r) {
470
471
  switch (t) {
471
472
  case "HS256":
472
473
  case "HS384":
473
474
  case "HS512": {
474
- if (!B(e.algorithm, "HMAC"))
475
+ if (!q(e.algorithm, "HMAC"))
475
476
  throw b("HMAC");
476
477
  const n = parseInt(t.slice(2), 10);
477
478
  if (pe(e.algorithm.hash) !== n)
@@ -481,7 +482,7 @@ function Wt(e, t, ...r) {
481
482
  case "RS256":
482
483
  case "RS384":
483
484
  case "RS512": {
484
- if (!B(e.algorithm, "RSASSA-PKCS1-v1_5"))
485
+ if (!q(e.algorithm, "RSASSA-PKCS1-v1_5"))
485
486
  throw b("RSASSA-PKCS1-v1_5");
486
487
  const n = parseInt(t.slice(2), 10);
487
488
  if (pe(e.algorithm.hash) !== n)
@@ -491,7 +492,7 @@ function Wt(e, t, ...r) {
491
492
  case "PS256":
492
493
  case "PS384":
493
494
  case "PS512": {
494
- if (!B(e.algorithm, "RSA-PSS"))
495
+ if (!q(e.algorithm, "RSA-PSS"))
495
496
  throw b("RSA-PSS");
496
497
  const n = parseInt(t.slice(2), 10);
497
498
  if (pe(e.algorithm.hash) !== n)
@@ -506,7 +507,7 @@ function Wt(e, t, ...r) {
506
507
  case "ES256":
507
508
  case "ES384":
508
509
  case "ES512": {
509
- if (!B(e.algorithm, "ECDSA"))
510
+ if (!q(e.algorithm, "ECDSA"))
510
511
  throw b("ECDSA");
511
512
  const n = Lt(t);
512
513
  if (e.algorithm.namedCurve !== n)
@@ -516,7 +517,7 @@ function Wt(e, t, ...r) {
516
517
  default:
517
518
  throw new TypeError("CryptoKey does not support this operation");
518
519
  }
519
- Ht(e, r);
520
+ $t(e, r);
520
521
  }
521
522
  function Ve(e, t, ...r) {
522
523
  var n;
@@ -530,7 +531,7 @@ const Oe = (e, ...t) => Ve("Key must be ", e, ...t);
530
531
  function je(e, t, ...r) {
531
532
  return Ve(`Key for the ${e} algorithm must be `, t, ...r);
532
533
  }
533
- const Fe = (e) => Me(e) ? !0 : e?.[Symbol.toStringTag] === "KeyObject", ne = ["CryptoKey"], xt = (...e) => {
534
+ const Fe = (e) => Me(e) ? !0 : e?.[Symbol.toStringTag] === "KeyObject", ae = ["CryptoKey"], Wt = (...e) => {
534
535
  const t = e.filter(Boolean);
535
536
  if (t.length === 0 || t.length === 1)
536
537
  return !0;
@@ -549,11 +550,11 @@ const Fe = (e) => Me(e) ? !0 : e?.[Symbol.toStringTag] === "KeyObject", ne = ["C
549
550
  }
550
551
  return !0;
551
552
  };
552
- function Jt(e) {
553
+ function Yt(e) {
553
554
  return typeof e == "object" && e !== null;
554
555
  }
555
- function ae(e) {
556
- if (!Jt(e) || Object.prototype.toString.call(e) !== "[object Object]")
556
+ function se(e) {
557
+ if (!Yt(e) || Object.prototype.toString.call(e) !== "[object Object]")
557
558
  return !1;
558
559
  if (Object.getPrototypeOf(e) === null)
559
560
  return !0;
@@ -562,14 +563,14 @@ function ae(e) {
562
563
  t = Object.getPrototypeOf(t);
563
564
  return Object.getPrototypeOf(e) === t;
564
565
  }
565
- const Yt = (e, t) => {
566
+ const xt = (e, t) => {
566
567
  if (e.startsWith("RS") || e.startsWith("PS")) {
567
568
  const { modulusLength: r } = t.algorithm;
568
569
  if (typeof r != "number" || r < 2048)
569
570
  throw new TypeError(`${e} requires key modulusLength to be 2048 bits or larger`);
570
571
  }
571
572
  };
572
- function Gt(e) {
573
+ function Jt(e) {
573
574
  let t, r;
574
575
  switch (e.kty) {
575
576
  case "RSA": {
@@ -641,36 +642,36 @@ function Gt(e) {
641
642
  }
642
643
  return { algorithm: t, keyUsages: r };
643
644
  }
644
- const Mt = async (e) => {
645
+ const Gt = async (e) => {
645
646
  if (!e.alg)
646
647
  throw new TypeError('"alg" argument is required when "jwk.alg" is not present');
647
- const { algorithm: t, keyUsages: r } = Gt(e), n = [
648
+ const { algorithm: t, keyUsages: r } = Jt(e), n = [
648
649
  t,
649
650
  e.ext ?? !1,
650
651
  e.key_ops ?? r
651
652
  ], a = { ...e };
652
653
  return delete a.alg, delete a.use, ce.subtle.importKey("jwk", a, ...n);
653
- }, Be = (e) => Y(e);
654
- let fe, ye;
654
+ }, Be = (e) => G(e);
655
+ let ye, fe;
655
656
  const qe = (e) => e?.[Symbol.toStringTag] === "KeyObject", ze = async (e, t, r, n) => {
656
657
  let a = e.get(t);
657
658
  if (a != null && a[n])
658
659
  return a[n];
659
- const o = await Mt({ ...r, alg: n });
660
+ const o = await Gt({ ...r, alg: n });
660
661
  return a ? a[n] = o : e.set(t, { [n]: o }), o;
661
- }, Vt = (e, t) => {
662
+ }, Mt = (e, t) => {
662
663
  if (qe(e)) {
663
664
  let r = e.export({ format: "jwk" });
664
- return delete r.d, delete r.dp, delete r.dq, delete r.p, delete r.q, delete r.qi, r.k ? Be(r.k) : (ye || (ye = /* @__PURE__ */ new WeakMap()), ze(ye, e, r, t));
665
+ return delete r.d, delete r.dp, delete r.dq, delete r.p, delete r.q, delete r.qi, r.k ? Be(r.k) : (fe || (fe = /* @__PURE__ */ new WeakMap()), ze(fe, e, r, t));
665
666
  }
666
667
  return e;
667
- }, jt = (e, t) => {
668
+ }, Vt = (e, t) => {
668
669
  if (qe(e)) {
669
670
  let r = e.export({ format: "jwk" });
670
- return r.k ? Be(r.k) : (fe || (fe = /* @__PURE__ */ new WeakMap()), ze(fe, e, r, t));
671
+ return r.k ? Be(r.k) : (ye || (ye = /* @__PURE__ */ new WeakMap()), ze(ye, e, r, t));
671
672
  }
672
673
  return e;
673
- }, Ft = { normalizePublicKey: Vt, normalizePrivateKey: jt }, O = (e, t, r = 0) => {
674
+ }, jt = { normalizePublicKey: Mt, normalizePrivateKey: Vt }, O = (e, t, r = 0) => {
674
675
  r === 0 && (t.unshift(t.length), t.unshift(6));
675
676
  const n = e.indexOf(t[0], r);
676
677
  if (n === -1)
@@ -696,7 +697,7 @@ const qe = (e) => e?.[Symbol.toStringTag] === "KeyObject", ze = async (e, t, r,
696
697
  default:
697
698
  throw new k("Invalid or unsupported EC Key Curve or OKP Key Sub Type");
698
699
  }
699
- }, Bt = async (e, t, r, n, a) => {
700
+ }, Ft = async (e, t, r, n, a) => {
700
701
  let o, s;
701
702
  const i = new Uint8Array(atob(r.replace(e, "")).split("").map((c) => c.charCodeAt(0)));
702
703
  switch (n) {
@@ -743,32 +744,32 @@ const qe = (e) => e?.[Symbol.toStringTag] === "KeyObject", ze = async (e, t, r,
743
744
  throw new k('Invalid or unsupported "alg" (Algorithm) value');
744
745
  }
745
746
  return ce.subtle.importKey(t, i, o, !1, s);
746
- }, qt = (e, t, r) => Bt(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g, "spki", e, t);
747
- async function zt(e, t, r) {
747
+ }, Bt = (e, t, r) => Ft(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g, "spki", e, t);
748
+ async function qt(e, t, r) {
748
749
  if (e.indexOf("-----BEGIN PUBLIC KEY-----") !== 0)
749
750
  throw new TypeError('"spki" must be SPKI formatted string');
750
- return qt(e, t);
751
+ return Bt(e, t);
751
752
  }
752
- const ee = (e) => e?.[Symbol.toStringTag], Qt = (e, t) => {
753
+ const te = (e) => e?.[Symbol.toStringTag], zt = (e, t) => {
753
754
  if (!(t instanceof Uint8Array)) {
754
755
  if (!Fe(t))
755
- throw new TypeError(je(e, t, ...ne, "Uint8Array"));
756
+ throw new TypeError(je(e, t, ...ae, "Uint8Array"));
756
757
  if (t.type !== "secret")
757
- throw new TypeError(`${ee(t)} instances for symmetric algorithms must be of type "secret"`);
758
+ throw new TypeError(`${te(t)} instances for symmetric algorithms must be of type "secret"`);
758
759
  }
759
- }, Xt = (e, t, r) => {
760
+ }, Qt = (e, t, r) => {
760
761
  if (!Fe(t))
761
- throw new TypeError(je(e, t, ...ne));
762
+ throw new TypeError(je(e, t, ...ae));
762
763
  if (t.type === "secret")
763
- throw new TypeError(`${ee(t)} instances for asymmetric algorithms must not be of type "secret"`);
764
+ throw new TypeError(`${te(t)} instances for asymmetric algorithms must not be of type "secret"`);
764
765
  if (t.algorithm && r === "verify" && t.type === "private")
765
- throw new TypeError(`${ee(t)} instances for asymmetric algorithm verifying must be of type "public"`);
766
+ throw new TypeError(`${te(t)} instances for asymmetric algorithm verifying must be of type "public"`);
766
767
  if (t.algorithm && r === "encrypt" && t.type === "private")
767
- throw new TypeError(`${ee(t)} instances for asymmetric algorithm encryption must be of type "public"`);
768
- }, Zt = (e, t, r) => {
769
- e.startsWith("HS") || e === "dir" || e.startsWith("PBES2") || /^A\d{3}(?:GCM)?KW$/.test(e) ? Qt(e, t) : Xt(e, t, r);
768
+ throw new TypeError(`${te(t)} instances for asymmetric algorithm encryption must be of type "public"`);
769
+ }, Xt = (e, t, r) => {
770
+ e.startsWith("HS") || e === "dir" || e.startsWith("PBES2") || /^A\d{3}(?:GCM)?KW$/.test(e) ? zt(e, t) : Qt(e, t, r);
770
771
  };
771
- function er(e, t, r, n, a) {
772
+ function Zt(e, t, r, n, a) {
772
773
  if (a.crit !== void 0 && n?.crit === void 0)
773
774
  throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');
774
775
  if (!n || n.crit === void 0)
@@ -787,13 +788,13 @@ function er(e, t, r, n, a) {
787
788
  }
788
789
  return new Set(n.crit);
789
790
  }
790
- const tr = (e, t) => {
791
+ const er = (e, t) => {
791
792
  if (t !== void 0 && (!Array.isArray(t) || t.some((r) => typeof r != "string")))
792
793
  throw new TypeError(`"${e}" option must be an array of strings`);
793
794
  if (t)
794
795
  return new Set(t);
795
796
  };
796
- function rr(e, t) {
797
+ function tr(e, t) {
797
798
  const r = `SHA-${e.slice(-3)}`;
798
799
  switch (e) {
799
800
  case "HS256":
@@ -818,100 +819,100 @@ function rr(e, t) {
818
819
  throw new k(`alg ${e} is not supported either by JOSE or your javascript runtime`);
819
820
  }
820
821
  }
821
- async function nr(e, t, r) {
822
- if (t = await Ft.normalizePublicKey(t, e), Me(t))
823
- return Wt(t, e, r), t;
822
+ async function rr(e, t, r) {
823
+ if (t = await jt.normalizePublicKey(t, e), Me(t))
824
+ return Ht(t, e, r), t;
824
825
  if (t instanceof Uint8Array) {
825
826
  if (!e.startsWith("HS"))
826
- throw new TypeError(Oe(t, ...ne));
827
+ throw new TypeError(Oe(t, ...ae));
827
828
  return ce.subtle.importKey("raw", t, { hash: `SHA-${e.slice(-3)}`, name: "HMAC" }, !1, [r]);
828
829
  }
829
- throw new TypeError(Oe(t, ...ne, "Uint8Array"));
830
+ throw new TypeError(Oe(t, ...ae, "Uint8Array"));
830
831
  }
831
- const ar = async (e, t, r, n) => {
832
- const a = await nr(e, t, "verify");
833
- Yt(e, a);
834
- const o = rr(e, a.algorithm);
832
+ const nr = async (e, t, r, n) => {
833
+ const a = await rr(e, t, "verify");
834
+ xt(e, a);
835
+ const o = tr(e, a.algorithm);
835
836
  try {
836
837
  return await ce.subtle.verify(o, a, r, n);
837
838
  } catch {
838
839
  return !1;
839
840
  }
840
841
  };
841
- async function sr(e, t, r) {
842
- if (!ae(e))
843
- throw new m("Flattened JWS must be an object");
842
+ async function ar(e, t, r) {
843
+ if (!se(e))
844
+ throw new w("Flattened JWS must be an object");
844
845
  if (e.protected === void 0 && e.header === void 0)
845
- throw new m('Flattened JWS must have either of the "protected" or "header" members');
846
+ throw new w('Flattened JWS must have either of the "protected" or "header" members');
846
847
  if (e.protected !== void 0 && typeof e.protected != "string")
847
- throw new m("JWS Protected Header incorrect type");
848
+ throw new w("JWS Protected Header incorrect type");
848
849
  if (e.payload === void 0)
849
- throw new m("JWS Payload missing");
850
+ throw new w("JWS Payload missing");
850
851
  if (typeof e.signature != "string")
851
- throw new m("JWS Signature missing or incorrect type");
852
- if (e.header !== void 0 && !ae(e.header))
853
- throw new m("JWS Unprotected Header incorrect type");
852
+ throw new w("JWS Signature missing or incorrect type");
853
+ if (e.header !== void 0 && !se(e.header))
854
+ throw new w("JWS Unprotected Header incorrect type");
854
855
  let n = {};
855
856
  if (e.protected)
856
857
  try {
857
- const T = Y(e.protected);
858
- n = JSON.parse(G.decode(T));
858
+ const T = G(e.protected);
859
+ n = JSON.parse(M.decode(T));
859
860
  } catch {
860
- throw new m("JWS Protected Header is invalid");
861
+ throw new w("JWS Protected Header is invalid");
861
862
  }
862
- if (!xt(n, e.header))
863
- throw new m("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
863
+ if (!Wt(n, e.header))
864
+ throw new w("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
864
865
  const a = {
865
866
  ...n,
866
867
  ...e.header
867
- }, o = er(m, /* @__PURE__ */ new Map([["b64", !0]]), r?.crit, n, a);
868
+ }, o = Zt(w, /* @__PURE__ */ new Map([["b64", !0]]), r?.crit, n, a);
868
869
  let s = !0;
869
870
  if (o.has("b64") && (s = n.b64, typeof s != "boolean"))
870
- throw new m('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
871
+ throw new w('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
871
872
  const { alg: i } = a;
872
873
  if (typeof i != "string" || !i)
873
- throw new m('JWS "alg" (Algorithm) Header Parameter missing or invalid');
874
- const c = r && tr("algorithms", r.algorithms);
874
+ throw new w('JWS "alg" (Algorithm) Header Parameter missing or invalid');
875
+ const c = r && er("algorithms", r.algorithms);
875
876
  if (c && !c.has(i))
876
- throw new Kt('"alg" (Algorithm) Header Parameter value not allowed');
877
+ throw new Ut('"alg" (Algorithm) Header Parameter value not allowed');
877
878
  if (s) {
878
879
  if (typeof e.payload != "string")
879
- throw new m("JWS Payload must be a string");
880
+ throw new w("JWS Payload must be a string");
880
881
  } else if (typeof e.payload != "string" && !(e.payload instanceof Uint8Array))
881
- throw new m("JWS Payload must be a string or an Uint8Array instance");
882
+ throw new w("JWS Payload must be a string or an Uint8Array instance");
882
883
  let h = !1;
883
- typeof t == "function" && (t = await t(n, e), h = !0), Zt(i, t, "verify");
884
- const f = Dt(F.encode(e.protected ?? ""), F.encode("."), typeof e.payload == "string" ? F.encode(e.payload) : e.payload);
884
+ typeof t == "function" && (t = await t(n, e), h = !0), Xt(i, t, "verify");
885
+ const y = Nt(B.encode(e.protected ?? ""), B.encode("."), typeof e.payload == "string" ? B.encode(e.payload) : e.payload);
885
886
  let p;
886
887
  try {
887
- p = Y(e.signature);
888
+ p = G(e.signature);
888
889
  } catch {
889
- throw new m("Failed to base64url decode the signature");
890
+ throw new w("Failed to base64url decode the signature");
890
891
  }
891
- if (!await ar(i, t, p, f))
892
- throw new $t();
893
- let u;
892
+ if (!await nr(i, t, p, y))
893
+ throw new Kt();
894
+ let l;
894
895
  if (s)
895
896
  try {
896
- u = Y(e.payload);
897
+ l = G(e.payload);
897
898
  } catch {
898
- throw new m("Failed to base64url decode the payload");
899
+ throw new w("Failed to base64url decode the payload");
899
900
  }
900
- else typeof e.payload == "string" ? u = F.encode(e.payload) : u = e.payload;
901
- const A = { payload: u };
901
+ else typeof e.payload == "string" ? l = B.encode(e.payload) : l = e.payload;
902
+ const A = { payload: l };
902
903
  return e.protected !== void 0 && (A.protectedHeader = n), e.header !== void 0 && (A.unprotectedHeader = e.header), h ? { ...A, key: t } : A;
903
904
  }
904
- async function or(e, t, r) {
905
- if (e instanceof Uint8Array && (e = G.decode(e)), typeof e != "string")
906
- throw new m("Compact JWS must be a string or Uint8Array");
905
+ async function sr(e, t, r) {
906
+ if (e instanceof Uint8Array && (e = M.decode(e)), typeof e != "string")
907
+ throw new w("Compact JWS must be a string or Uint8Array");
907
908
  const { 0: n, 1: a, 2: o, length: s } = e.split(".");
908
909
  if (s !== 3)
909
- throw new m("Invalid Compact JWS");
910
- const i = await sr({ payload: a, protected: n, signature: o }, t, r), c = { payload: i.payload, protectedHeader: i.protectedHeader };
910
+ throw new w("Invalid Compact JWS");
911
+ const i = await ar({ payload: a, protected: n, signature: o }, t, r), c = { payload: i.payload, protectedHeader: i.protectedHeader };
911
912
  return typeof t == "function" ? { ...c, key: i.key } : c;
912
913
  }
913
- const ir = (e) => Math.floor(e.getTime() / 1e3), Qe = 60, Xe = Qe * 60, Ae = Xe * 24, cr = Ae * 7, ur = Ae * 365.25, lr = /^(\+|\-)? ?(\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) => {
914
- const t = lr.exec(e);
914
+ const or = (e) => Math.floor(e.getTime() / 1e3), Qe = 60, Xe = Qe * 60, Ae = Xe * 24, ir = Ae * 7, cr = Ae * 365.25, ur = /^(\+|\-)? ?(\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) => {
915
+ const t = ur.exec(e);
915
916
  if (!t || t[4] && t[1])
916
917
  throw new TypeError("Invalid time period format");
917
918
  const r = parseFloat(t[2]), n = t[3].toLowerCase();
@@ -946,34 +947,34 @@ const ir = (e) => Math.floor(e.getTime() / 1e3), Qe = 60, Xe = Qe * 60, Ae = Xe
946
947
  case "week":
947
948
  case "weeks":
948
949
  case "w":
949
- a = Math.round(r * cr);
950
+ a = Math.round(r * ir);
950
951
  break;
951
952
  default:
952
- a = Math.round(r * ur);
953
+ a = Math.round(r * cr);
953
954
  break;
954
955
  }
955
956
  return t[1] === "-" || t[4] === "ago" ? -a : a;
956
- }, Ce = (e) => e.toLowerCase().replace(/^application\//, ""), dr = (e, t) => typeof e == "string" ? t.includes(e) : Array.isArray(e) ? t.some(Set.prototype.has.bind(new Set(e))) : !1, hr = (e, t, r = {}) => {
957
+ }, Ce = (e) => e.toLowerCase().replace(/^application\//, ""), lr = (e, t) => typeof e == "string" ? t.includes(e) : Array.isArray(e) ? t.some(Set.prototype.has.bind(new Set(e))) : !1, dr = (e, t, r = {}) => {
957
958
  let n;
958
959
  try {
959
- n = JSON.parse(G.decode(t));
960
+ n = JSON.parse(M.decode(t));
960
961
  } catch {
961
962
  }
962
- if (!ae(n))
963
+ if (!se(n))
963
964
  throw new v("JWT Claims Set must be a top-level JSON object");
964
965
  const { typ: a } = r;
965
966
  if (a && (typeof e.typ != "string" || Ce(e.typ) !== Ce(a)))
966
967
  throw new R('unexpected "typ" JWT header value', n, "typ", "check_failed");
967
- const { requiredClaims: o = [], issuer: s, subject: i, audience: c, maxTokenAge: h } = r, f = [...o];
968
- h !== void 0 && f.push("iat"), c !== void 0 && f.push("aud"), i !== void 0 && f.push("sub"), s !== void 0 && f.push("iss");
969
- for (const T of new Set(f.reverse()))
968
+ const { requiredClaims: o = [], issuer: s, subject: i, audience: c, maxTokenAge: h } = r, y = [...o];
969
+ h !== void 0 && y.push("iat"), c !== void 0 && y.push("aud"), i !== void 0 && y.push("sub"), s !== void 0 && y.push("iss");
970
+ for (const T of new Set(y.reverse()))
970
971
  if (!(T in n))
971
972
  throw new R(`missing required "${T}" claim`, n, T, "missing");
972
973
  if (s && !(Array.isArray(s) ? s : [s]).includes(n.iss))
973
974
  throw new R('unexpected "iss" claim value', n, "iss", "check_failed");
974
975
  if (i && n.sub !== i)
975
976
  throw new R('unexpected "sub" claim value', n, "sub", "check_failed");
976
- if (c && !dr(n.aud, typeof c == "string" ? [c] : c))
977
+ if (c && !lr(n.aud, typeof c == "string" ? [c] : c))
977
978
  throw new R('unexpected "aud" claim value', n, "aud", "check_failed");
978
979
  let p;
979
980
  switch (typeof r.clockTolerance) {
@@ -989,7 +990,7 @@ const ir = (e) => Math.floor(e.getTime() / 1e3), Qe = 60, Xe = Qe * 60, Ae = Xe
989
990
  default:
990
991
  throw new TypeError("Invalid clockTolerance option type");
991
992
  }
992
- const { currentDate: u } = r, A = ir(u || /* @__PURE__ */ new Date());
993
+ const { currentDate: l } = r, A = or(l || /* @__PURE__ */ new Date());
993
994
  if ((n.iat !== void 0 || h) && typeof n.iat != "number")
994
995
  throw new R('"iat" claim must be a number', n, "iat", "invalid");
995
996
  if (n.nbf !== void 0) {
@@ -1013,15 +1014,15 @@ const ir = (e) => Math.floor(e.getTime() / 1e3), Qe = 60, Xe = Qe * 60, Ae = Xe
1013
1014
  }
1014
1015
  return n;
1015
1016
  };
1016
- async function pr(e, t, r) {
1017
+ async function hr(e, t, r) {
1017
1018
  var n;
1018
- const a = await or(e, t, r);
1019
+ const a = await sr(e, t, r);
1019
1020
  if ((n = a.protectedHeader.crit) != null && n.includes("b64") && a.protectedHeader.b64 === !1)
1020
1021
  throw new v("JWTs MUST NOT use unencoded payload");
1021
- const o = { payload: hr(a.protectedHeader, a.payload, r), protectedHeader: a.protectedHeader };
1022
+ const o = { payload: dr(a.protectedHeader, a.payload, r), protectedHeader: a.protectedHeader };
1022
1023
  return typeof t == "function" ? { ...o, key: a.key } : o;
1023
1024
  }
1024
- const fr = Y;
1025
+ const pr = G;
1025
1026
  function yr(e) {
1026
1027
  if (typeof e != "string")
1027
1028
  throw new v("JWTs must use Compact JWS serialization, JWT must be a string");
@@ -1034,83 +1035,83 @@ function yr(e) {
1034
1035
  throw new v("JWTs must contain a payload");
1035
1036
  let n;
1036
1037
  try {
1037
- n = fr(t);
1038
+ n = pr(t);
1038
1039
  } catch {
1039
1040
  throw new v("Failed to base64url decode the payload");
1040
1041
  }
1041
1042
  let a;
1042
1043
  try {
1043
- a = JSON.parse(G.decode(n));
1044
+ a = JSON.parse(M.decode(n));
1044
1045
  } catch {
1045
1046
  throw new v("Failed to parse the decoded payload as JSON");
1046
1047
  }
1047
- if (!ae(a))
1048
+ if (!se(a))
1048
1049
  throw new v("Invalid JWT Claims Set");
1049
1050
  return a;
1050
1051
  }
1051
- const H = async (e) => {
1052
+ const Y = async (e) => {
1052
1053
  try {
1053
- const t = S.ALG, r = await zt(Nt, t);
1054
- return await pr(e, r, {
1055
- issuer: S.ISSUER
1054
+ const t = f.ALG, r = await qt(Ct, t);
1055
+ return await hr(e, r, {
1056
+ issuer: f.ISSUER
1056
1057
  });
1057
1058
  } catch {
1058
1059
  return;
1059
1060
  }
1060
- }, gr = (e) => {
1061
+ }, fr = (e) => {
1061
1062
  try {
1062
1063
  return yr(e);
1063
1064
  } catch {
1064
1065
  return;
1065
1066
  }
1066
1067
  };
1067
- var g = [];
1068
+ var E = [];
1068
1069
  for (var ge = 0; ge < 256; ++ge)
1069
- g.push((ge + 256).toString(16).slice(1));
1070
- function Er(e, t = 0) {
1071
- return (g[e[t + 0]] + g[e[t + 1]] + g[e[t + 2]] + g[e[t + 3]] + "-" + g[e[t + 4]] + g[e[t + 5]] + "-" + g[e[t + 6]] + g[e[t + 7]] + "-" + g[e[t + 8]] + g[e[t + 9]] + "-" + g[e[t + 10]] + g[e[t + 11]] + g[e[t + 12]] + g[e[t + 13]] + g[e[t + 14]] + g[e[t + 15]]).toLowerCase();
1070
+ E.push((ge + 256).toString(16).slice(1));
1071
+ function gr(e, t = 0) {
1072
+ return (E[e[t + 0]] + E[e[t + 1]] + E[e[t + 2]] + E[e[t + 3]] + "-" + E[e[t + 4]] + E[e[t + 5]] + "-" + E[e[t + 6]] + E[e[t + 7]] + "-" + E[e[t + 8]] + E[e[t + 9]] + "-" + E[e[t + 10]] + E[e[t + 11]] + E[e[t + 12]] + E[e[t + 13]] + E[e[t + 14]] + E[e[t + 15]]).toLowerCase();
1072
1073
  }
1073
- var q, mr = new Uint8Array(16);
1074
- function wr() {
1075
- if (!q && (q = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !q))
1074
+ var z, Er = new Uint8Array(16);
1075
+ function mr() {
1076
+ if (!z && (z = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !z))
1076
1077
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
1077
- return q(mr);
1078
+ return z(Er);
1078
1079
  }
1079
- var Sr = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
1080
+ var wr = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
1080
1081
  const Ne = {
1081
- randomUUID: Sr
1082
+ randomUUID: wr
1082
1083
  };
1083
1084
  function De(e, t, r) {
1084
1085
  if (Ne.randomUUID && !t && !e)
1085
1086
  return Ne.randomUUID();
1086
1087
  e = e || {};
1087
- var n = e.random || (e.rng || wr)();
1088
- return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, Er(n);
1088
+ var n = e.random || (e.rng || mr)();
1089
+ return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, gr(n);
1089
1090
  }
1090
- const Ue = globalThis.crypto, Ar = (e) => `${De()}${De()}`.slice(0, e), Tr = (e) => btoa(
1091
+ const Ue = globalThis.crypto, Sr = (e) => `${De()}${De()}`.slice(0, e), Ar = (e) => btoa(
1091
1092
  [...new Uint8Array(e)].map((t) => String.fromCharCode(t)).join("")
1092
1093
  );
1093
- async function Rr(e) {
1094
+ async function Tr(e) {
1094
1095
  if (!Ue.subtle)
1095
1096
  throw new Error(
1096
1097
  "crypto.subtle is available only in secure contexts (HTTPS)."
1097
1098
  );
1098
1099
  const t = new TextEncoder().encode(e), r = await Ue.subtle.digest("SHA-256", t);
1099
- return Tr(r).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
1100
+ return Ar(r).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
1100
1101
  }
1101
- async function _r(e) {
1102
- const r = Ar(43), n = await Rr(r);
1102
+ async function Rr(e) {
1103
+ const r = Sr(43), n = await Tr(r);
1103
1104
  return {
1104
1105
  code_verifier: r,
1105
1106
  code_challenge: n
1106
1107
  };
1107
1108
  }
1108
- const Br = async (e, t) => {
1109
+ const Fr = async (e, t) => {
1109
1110
  var r;
1110
- const n = await H(e);
1111
- if (!n || !Array.isArray((r = n.payload) == null ? void 0 : r[S.SCOPES_KEY]))
1111
+ const n = await Y(e);
1112
+ if (!n || !Array.isArray((r = n.payload) == null ? void 0 : r[f.SCOPES_KEY]))
1112
1113
  return !1;
1113
- const a = n.payload[S.SCOPES_KEY];
1114
+ const a = n.payload[f.SCOPES_KEY];
1114
1115
  return Array.isArray(t) ? t.every((o) => a.includes(o)) : Object.keys(t).some(
1115
1116
  (o) => t[o].every((s) => a.includes(s))
1116
1117
  );
@@ -1123,18 +1124,18 @@ const Ke = (e, t) => {
1123
1124
  typeof t == "function" ? t() : t
1124
1125
  );
1125
1126
  window.localStorage.setItem(e, r), Ze(e, r);
1126
- }, Ir = (e) => {
1127
+ }, _r = (e) => {
1127
1128
  window.localStorage.removeItem(e), Ze(e, null);
1128
- }, $e = (e) => window.localStorage.getItem(e), br = (e) => (window.addEventListener("storage", e), () => window.removeEventListener("storage", e));
1129
- function z({
1129
+ }, Le = (e) => window.localStorage.getItem(e), Ir = (e) => (window.addEventListener("storage", e), () => window.removeEventListener("storage", e));
1130
+ function Q({
1130
1131
  key: e,
1131
1132
  initialValue: t
1132
1133
  }) {
1133
- const r = St(br, () => $e(e)), n = N(
1134
+ const r = wt(Ir, () => Le(e)), n = N(
1134
1135
  (s) => {
1135
1136
  try {
1136
1137
  const i = typeof s == "function" ? s(JSON.parse(r)) : s;
1137
- i == null ? Ir(e) : Ke(e, i);
1138
+ i == null ? _r(e) : Ke(e, i);
1138
1139
  } catch (i) {
1139
1140
  console.warn(i);
1140
1141
  }
@@ -1147,39 +1148,39 @@ function z({
1147
1148
  }, [n]);
1148
1149
  return He(() => {
1149
1150
  try {
1150
- $e(e) === null && typeof t < "u" && Ke(e, t);
1151
+ Le(e) === null && typeof t < "u" && Ke(e, t);
1151
1152
  } catch (s) {
1152
1153
  console.warn(s);
1153
1154
  }
1154
1155
  }, [e, t]), [r ? JSON.parse(r) : null, n, a, o];
1155
1156
  }
1156
- var E = [];
1157
+ var m = [];
1157
1158
  for (var Ee = 0; Ee < 256; ++Ee)
1158
- E.push((Ee + 256).toString(16).slice(1));
1159
- function vr(e, t = 0) {
1160
- return (E[e[t + 0]] + E[e[t + 1]] + E[e[t + 2]] + E[e[t + 3]] + "-" + E[e[t + 4]] + E[e[t + 5]] + "-" + E[e[t + 6]] + E[e[t + 7]] + "-" + E[e[t + 8]] + E[e[t + 9]] + "-" + E[e[t + 10]] + E[e[t + 11]] + E[e[t + 12]] + E[e[t + 13]] + E[e[t + 14]] + E[e[t + 15]]).toLowerCase();
1159
+ m.push((Ee + 256).toString(16).slice(1));
1160
+ function br(e, t = 0) {
1161
+ 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();
1161
1162
  }
1162
- var Q, Or = new Uint8Array(16);
1163
- function kr() {
1164
- if (!Q && (Q = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !Q))
1163
+ var X, vr = new Uint8Array(16);
1164
+ function Or() {
1165
+ if (!X && (X = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !X))
1165
1166
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
1166
- return Q(Or);
1167
+ return X(vr);
1167
1168
  }
1168
- var Pr = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
1169
- const Le = {
1170
- randomUUID: Pr
1169
+ var kr = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
1170
+ const $e = {
1171
+ randomUUID: kr
1171
1172
  };
1172
1173
  function me(e, t, r) {
1173
- if (Le.randomUUID && !t && !e)
1174
- return Le.randomUUID();
1174
+ if ($e.randomUUID && !t && !e)
1175
+ return $e.randomUUID();
1175
1176
  e = e || {};
1176
- var n = e.random || (e.rng || kr)();
1177
- return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, vr(n);
1177
+ var n = e.random || (e.rng || Or)();
1178
+ return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, br(n);
1178
1179
  }
1179
- const U = "Your session has expired. For your security, please log in again to continue.", Cr = "Your session has been successfully terminated.", we = "Login failed. Please try again.", Nr = "Error getting access token, please re-authenticate.", Dr = "You forgot to wrap your component in <AuthProvider>.", se = {
1180
+ const K = "Your session has expired. For your security, please log in again to continue.", Pr = "Your session has been successfully terminated.", we = "Login failed. Please try again.", Cr = "Error getting access token, please re-authenticate.", Nr = "You forgot to wrap your component in <AuthProvider>.", oe = {
1180
1181
  dev: "https://auth.gizmette.local.com:3003",
1181
1182
  prod: "https://mylogin.gizmette.com/auth"
1182
- }, X = "@@auth@@", J = "LOADING", te = "LOGIN", et = "LOGOUT", M = "success", I = "failure", tt = "include", rt = "POST", nt = "application/json", Z = {
1183
+ }, Z = "@@auth@@", J = "LOADING", re = "LOGIN", et = "LOGOUT", V = "success", I = "failure", tt = "include", rt = "POST", nt = "application/json", ee = {
1183
1184
  GET_REGISTRATION_OPTIONS: `mutation GetPasskeyRegistrationOptions(
1184
1185
  $clientId: String!,
1185
1186
  $username: String!,
@@ -1257,23 +1258,24 @@ const U = "Your session has expired. For your security, please log in again to c
1257
1258
  refreshToken,
1258
1259
  userId,
1259
1260
  username,
1261
+ email
1260
1262
  }
1261
1263
  }`
1262
- }, K = {
1264
+ }, L = {
1263
1265
  GET_REGISTRATION_OPTIONS: {
1264
- schema: Z.GET_REGISTRATION_OPTIONS,
1266
+ schema: ee.GET_REGISTRATION_OPTIONS,
1265
1267
  method: "getPasskeyRegistrationOptions"
1266
1268
  },
1267
1269
  VERIFY_REGISTRATION: {
1268
- schema: Z.VERIFY_REGISTRATION,
1270
+ schema: ee.VERIFY_REGISTRATION,
1269
1271
  method: "verifyPasskeyRegistration"
1270
1272
  },
1271
1273
  GET_AUTHENTICATION_OPTIONS: {
1272
- schema: Z.GET_AUTHENTICATION_OPTIONS,
1274
+ schema: ee.GET_AUTHENTICATION_OPTIONS,
1273
1275
  method: "getPasskeyAuthenticationOptions"
1274
1276
  },
1275
1277
  VERIFY_AUTHENTICATION: {
1276
- schema: Z.VERIFY_AUTHENTICATION,
1278
+ schema: ee.VERIFY_AUTHENTICATION,
1277
1279
  method: "verifyPasskeyAuthentication"
1278
1280
  }
1279
1281
  }, $ = async ({
@@ -1284,7 +1286,7 @@ const U = "Your session has expired. For your security, please log in again to c
1284
1286
  }) => {
1285
1287
  try {
1286
1288
  const a = `Bearer ${e}`, o = await fetch(
1287
- at ? `${se.dev}/graphql` : `${se.prod}/graphql`,
1289
+ at ? `${oe.dev}/graphql` : `${oe.prod}/graphql`,
1288
1290
  {
1289
1291
  credentials: tt,
1290
1292
  method: rt,
@@ -1303,7 +1305,7 @@ const U = "Your session has expired. For your security, please log in again to c
1303
1305
  return { status: I, data: [] };
1304
1306
  const { data: s } = await o.json();
1305
1307
  return {
1306
- status: M,
1308
+ status: V,
1307
1309
  data: s[t.method]
1308
1310
  };
1309
1311
  } catch (a) {
@@ -1316,7 +1318,7 @@ const U = "Your session has expired. For your security, please log in again to c
1316
1318
  }) => {
1317
1319
  try {
1318
1320
  const n = await fetch(
1319
- at ? `${se.dev}/${e}` : `${se.prod}/${e}`,
1321
+ at ? `${oe.dev}/${e}` : `${oe.prod}/${e}`,
1320
1322
  {
1321
1323
  credentials: tt,
1322
1324
  method: rt,
@@ -1331,26 +1333,27 @@ const U = "Your session has expired. For your security, please log in again to c
1331
1333
  return { status: I, data: [] };
1332
1334
  const { data: a } = await n.json();
1333
1335
  return {
1334
- status: M,
1336
+ status: V,
1335
1337
  data: a || []
1336
1338
  };
1337
1339
  } catch (n) {
1338
1340
  return console.error(n), { status: I, data: [] };
1339
1341
  }
1340
- }, Ur = process.env.NODE_ENV === "production", at = !Ur, st = {
1342
+ }, Dr = process.env.NODE_ENV === "production", at = !Dr, st = {
1341
1343
  isLoading: !0,
1342
1344
  isAuthenticated: !1,
1343
1345
  user: void 0,
1344
1346
  logoutReason: "",
1345
- debug: !1
1346
- }, Kr = (e) => {
1347
+ debug: !1,
1348
+ authenticationType: ""
1349
+ }, Ur = (e) => {
1347
1350
  try {
1348
- const t = gr(e);
1349
- return t ? t[S.USER_ID_KEY] : "";
1351
+ const t = fr(e);
1352
+ return t ? t[f.USER_ID_KEY] : "";
1350
1353
  } catch {
1351
1354
  return "";
1352
1355
  }
1353
- }, $r = async ({
1356
+ }, Kr = async ({
1354
1357
  userId: e,
1355
1358
  clientId: t,
1356
1359
  domain: r,
@@ -1386,11 +1389,11 @@ const U = "Your session has expired. For your security, please log in again to c
1386
1389
  ua: h
1387
1390
  }) => {
1388
1391
  try {
1389
- const f = await ue({
1392
+ const y = await ue({
1390
1393
  type: ie.LOGIN,
1391
1394
  clientId: r,
1392
1395
  params: {
1393
- type: a || oe.ID_AND_ACCESS_TOKEN,
1396
+ type: a || W.ID_AND_ACCESS_TOKEN,
1394
1397
  username: e,
1395
1398
  password: t,
1396
1399
  sessionExpiration: o,
@@ -1400,12 +1403,13 @@ const U = "Your session has expired. For your security, please log in again to c
1400
1403
  domain: c,
1401
1404
  ua: h
1402
1405
  }
1403
- }), p = await H(f?.data?.idToken);
1404
- return p && p.payload[S.USER_ID_KEY] !== "" && p.payload[S.NONCE_KEY] === n ? {
1405
- idToken: f.data.idToken,
1406
- accessToken: f.data.accessToken,
1407
- refreshToken: f.data.refreshToken,
1408
- userId: p.payload[S.USER_ID_KEY],
1406
+ }), p = await Y(y?.data?.idToken);
1407
+ return p && p.payload[f.USER_ID_KEY] !== "" && p.payload[f.NONCE_KEY] === n ? {
1408
+ idToken: y.data.idToken,
1409
+ accessToken: y.data.accessToken,
1410
+ refreshToken: y.data.refreshToken,
1411
+ userId: p.payload[f.USER_ID_KEY],
1412
+ email: p.payload[f.EMAIL_KEY],
1409
1413
  status: !0
1410
1414
  } : {
1411
1415
  status: !1
@@ -1415,7 +1419,7 @@ const U = "Your session has expired. For your security, please log in again to c
1415
1419
  status: !1
1416
1420
  };
1417
1421
  }
1418
- }, Hr = async ({
1422
+ }, $r = async ({
1419
1423
  nonce: e,
1420
1424
  clientId: t,
1421
1425
  code_challenge: r
@@ -1425,13 +1429,13 @@ const U = "Your session has expired. For your security, please log in again to c
1425
1429
  type: ie.CODE,
1426
1430
  clientId: t,
1427
1431
  params: {
1428
- type: oe.CODE,
1432
+ type: W.CODE,
1429
1433
  nonce: e,
1430
1434
  code_challenge: r
1431
1435
  }
1432
1436
  });
1433
1437
  return n?.data?.code ? {
1434
- status: M,
1438
+ status: V,
1435
1439
  data: n.data.code
1436
1440
  } : {
1437
1441
  status: I,
@@ -1443,7 +1447,7 @@ const U = "Your session has expired. For your security, please log in again to c
1443
1447
  data: ""
1444
1448
  };
1445
1449
  }
1446
- }, Wr = async ({
1450
+ }, Hr = async ({
1447
1451
  clientId: e,
1448
1452
  userId: t,
1449
1453
  nonce: r,
@@ -1456,18 +1460,18 @@ const U = "Your session has expired. For your security, please log in again to c
1456
1460
  type: ie.REFRESH,
1457
1461
  clientId: e,
1458
1462
  params: {
1459
- type: oe.REFRESH_TOKEN,
1463
+ type: W.REFRESH_TOKEN,
1460
1464
  userId: t,
1461
1465
  nonce: r,
1462
1466
  refreshToken: n,
1463
1467
  accessToken: a,
1464
1468
  domain: o
1465
1469
  }
1466
- }), i = await H(s?.data?.accessToken);
1467
- return i && i.payload[S.USER_ID_KEY] !== "" && i.payload[S.NONCE_KEY] === r ? {
1470
+ }), i = await Y(s?.data?.accessToken);
1471
+ return i && i.payload[f.USER_ID_KEY] !== "" && i.payload[f.NONCE_KEY] === r ? {
1468
1472
  accessToken: s.data.accessToken,
1469
1473
  refreshToken: s.data.refreshToken,
1470
- userId: i.payload[S.USER_ID_KEY],
1474
+ userId: i.payload[f.USER_ID_KEY],
1471
1475
  status: !0
1472
1476
  } : {
1473
1477
  status: !1
@@ -1478,11 +1482,11 @@ const U = "Your session has expired. For your security, please log in again to c
1478
1482
  };
1479
1483
  }
1480
1484
  };
1481
- class xr {
1485
+ class Wr {
1482
1486
  constructor(t = null, r = null) {
1483
- j(this, "refreshTokenPromise", null);
1484
- j(this, "accessToken");
1485
- j(this, "refreshToken");
1487
+ F(this, "refreshTokenPromise", null);
1488
+ F(this, "accessToken");
1489
+ F(this, "refreshToken");
1486
1490
  this.accessToken = t || "", this.refreshToken = r || "";
1487
1491
  }
1488
1492
  async refreshtoken({
@@ -1509,9 +1513,9 @@ class xr {
1509
1513
  nonce: n,
1510
1514
  domain: a
1511
1515
  }) {
1512
- const o = await H(this.refreshToken);
1513
- if (o && o.payload[S.USER_ID_KEY] !== "") {
1514
- const s = await Wr({
1516
+ const o = await Y(this.refreshToken);
1517
+ if (o && o.payload[f.USER_ID_KEY] !== "") {
1518
+ const s = await Hr({
1515
1519
  clientId: t,
1516
1520
  userId: r,
1517
1521
  nonce: n,
@@ -1520,7 +1524,7 @@ class xr {
1520
1524
  domain: a
1521
1525
  });
1522
1526
  return s.status ? (this.accessToken = s.accessToken, this.refreshToken = s.refreshToken, {
1523
- status: M,
1527
+ status: V,
1524
1528
  newAccessToken: s.accessToken,
1525
1529
  newRefreshToken: s.refreshToken
1526
1530
  }) : {
@@ -1532,63 +1536,66 @@ class xr {
1532
1536
  };
1533
1537
  }
1534
1538
  }
1535
- const Jr = (e) => N(
1539
+ const Yr = (e) => N(
1536
1540
  (...t) => {
1537
1541
  e && console.info(`==> [Auth ${Date.now()}]: `, ...t);
1538
1542
  },
1539
1543
  [e]
1540
- ), L = () => {
1541
- throw new Error(Dr);
1542
- }, ot = At({
1544
+ ), H = () => {
1545
+ throw new Error(Nr);
1546
+ }, ot = St({
1543
1547
  isAuthenticated: !1,
1544
1548
  isLoading: !1,
1545
- login: L,
1546
- logout: L,
1547
- getAccessToken: L,
1548
- getIdToken: L,
1549
- registeringForPasskey: L,
1550
- loginWithPasskey: L,
1551
- logoutReason: ""
1552
- }), Yr = wt.createContext({
1549
+ login: H,
1550
+ logout: H,
1551
+ getAccessToken: H,
1552
+ getIdToken: H,
1553
+ registeringForPasskey: H,
1554
+ loginWithPasskey: H,
1555
+ logoutReason: "",
1556
+ authenticationType: ""
1557
+ }), xr = mt.createContext({
1553
1558
  state: st,
1554
1559
  dispatch: () => {
1555
1560
  }
1556
- }), Gr = (e, t) => t?.type === J ? {
1561
+ }), Jr = (e, t) => t?.type === J ? {
1557
1562
  ...e,
1558
1563
  isLoading: t.payload.isLoading
1559
- } : t?.type === te ? {
1564
+ } : t?.type === re ? {
1560
1565
  ...e,
1561
1566
  isLoading: !1,
1562
1567
  isAuthenticated: !0,
1563
1568
  user: t.payload.user,
1569
+ authenticationType: t.payload.authenticationType,
1564
1570
  logoutReason: ""
1565
1571
  } : t?.type === et ? {
1566
1572
  ...e,
1567
1573
  isLoading: !1,
1568
1574
  isAuthenticated: !1,
1569
1575
  user: void 0,
1576
+ authenticationType: "",
1570
1577
  logoutReason: t.payload.logoutReason
1571
- } : e, qr = ({
1578
+ } : e, Br = ({
1572
1579
  children: e,
1573
1580
  sessionExpiration: t,
1574
1581
  clientId: r,
1575
1582
  domain: n = "",
1576
1583
  debug: a = !1
1577
1584
  }) => {
1578
- const [o, s] = Tt(Gr, {
1585
+ const [o, s] = At(Jr, {
1579
1586
  ...st,
1580
1587
  debug: a
1581
- }), i = Jr(a), c = Rt(!1), [h, f, , p] = z({
1582
- key: `${X}::${r}::@@user@@`
1583
- }), [u, A, , T] = z({
1584
- key: `${X}::${r}::@@access@@`
1585
- }), [le, de, , Te] = z(
1588
+ }), i = Yr(a), c = Tt(!1), [h, y, , p] = Q({
1589
+ key: `${Z}::${r}::@@user@@`
1590
+ }), [l, A, , T] = Q({
1591
+ key: `${Z}::${r}::@@access@@`
1592
+ }), [le, de, , Te] = Q(
1586
1593
  {
1587
- key: `${X}::${r}::@@refresh@@`
1594
+ key: `${Z}::${r}::@@refresh@@`
1588
1595
  }
1589
- ), [it, Re, , _e] = z({
1590
- key: `${X}::${r}::@@nonce@@`
1591
- }), ct = new xr(u, le), V = N(() => {
1596
+ ), [it, Re, , _e] = Q({
1597
+ key: `${Z}::${r}::@@nonce@@`
1598
+ }), ct = new Wr(l, le), j = N(() => {
1592
1599
  i("removeLocalStorage: removing local storage"), p(), T(), Te(), _e();
1593
1600
  }, [
1594
1601
  T,
@@ -1596,218 +1603,224 @@ const Jr = (e) => N(
1596
1603
  _e,
1597
1604
  Te,
1598
1605
  i
1599
- ]), W = N(
1600
- (l) => {
1606
+ ]), x = N(
1607
+ (u) => {
1601
1608
  i(
1602
1609
  "removeStateAndLocalStorage: removing state and local storage with reason: ",
1603
- l
1610
+ u
1604
1611
  ), s({
1605
1612
  type: et,
1606
1613
  payload: {
1607
- logoutReason: l || U
1614
+ logoutReason: u || K
1608
1615
  }
1609
- }), V(), s({ type: J, payload: { isLoading: !1 } });
1616
+ }), j(), s({ type: J, payload: { isLoading: !1 } });
1610
1617
  },
1611
- [V, i]
1618
+ [j, i]
1612
1619
  ), P = N(
1613
- async (l) => {
1620
+ async (u) => {
1614
1621
  i("invalidateAndLogout: invalidating and logging out");
1615
- const { user: y } = o, d = y?.userId || Kr(h);
1622
+ const { user: g } = o, d = g?.userId || Ur(h);
1616
1623
  d || i(
1617
1624
  "invalidateAndLogout: user cannot be identified, logging out without userId"
1618
- ), await $r({
1625
+ ), await Kr({
1619
1626
  userId: d,
1620
1627
  clientId: r,
1621
1628
  domain: n,
1622
1629
  idToken: h
1623
- }), W(l || U);
1630
+ }), x(u || K);
1624
1631
  },
1625
- [h, o, r, n, W, i]
1632
+ [h, o, r, n, x, i]
1626
1633
  );
1627
1634
  He(() => {
1628
1635
  if (!c.current)
1629
1636
  return o.isLoading && h !== null ? (async () => {
1630
1637
  try {
1631
- const l = await H(h);
1632
- l && l.payload[S.USER_ID_KEY] !== "" ? (i("useEffect: setting the authentication state"), s({
1633
- type: te,
1638
+ const u = await Y(h);
1639
+ u && u.payload[f.USER_ID_KEY] !== "" ? (i("useEffect: setting the authentication state"), s({
1640
+ type: re,
1634
1641
  payload: {
1642
+ authenticationType: u.payload[f.AUTH_TYPE_KEY],
1635
1643
  user: {
1636
- userId: l.payload[S.USER_ID_KEY],
1637
- username: l.payload[S.USERNAME_KEY]
1644
+ userId: u.payload[f.USER_ID_KEY],
1645
+ username: u.payload[f.USERNAME_KEY],
1646
+ email: u.payload[f.EMAIL_KEY]
1638
1647
  }
1639
1648
  }
1640
- })) : (i("useEffect: invalid JWT, invalidating and logging out"), await P(U));
1649
+ })) : (i("useEffect: invalid JWT, invalidating and logging out"), await P(K));
1641
1650
  } catch {
1642
1651
  i(
1643
1652
  "useEffect: exception validating JWT, invalidating and logging out"
1644
- ), await P(U);
1653
+ ), await P(K);
1645
1654
  }
1646
1655
  })() : (i("useEffect: setting the loading state to false"), s({ type: J, payload: { isLoading: !1 } })), () => {
1647
1656
  c.current = !0;
1648
1657
  };
1649
1658
  }, [o.isLoading, h, P, i]);
1650
- const ut = async (l, y) => {
1651
- s({ type: J, payload: { isLoading: !0 } }), V();
1659
+ const ut = async (u, g) => {
1660
+ s({ type: J, payload: { isLoading: !0 } }), j();
1652
1661
  const d = me();
1653
1662
  Re(d), i("login: Logging in with password");
1654
- const C = oe.CODE, { code_verifier: yt, code_challenge: gt } = await _r(), Ie = await Hr({
1663
+ const { code_verifier: C, code_challenge: ft } = await Rr(), Ie = await $r({
1655
1664
  nonce: d,
1656
1665
  clientId: r,
1657
- code_challenge: gt
1666
+ code_challenge: ft
1658
1667
  });
1659
1668
  if (Ie.status) {
1660
- const x = await Lr({
1661
- username: l,
1662
- password: y,
1669
+ const U = await Lr({
1670
+ username: u,
1671
+ password: g,
1663
1672
  clientId: r,
1664
1673
  sessionExpiration: t,
1665
1674
  nonce: d,
1666
- type: C,
1675
+ type: W.CODE,
1667
1676
  code: Ie.data,
1668
- code_verifier: yt,
1677
+ code_verifier: C,
1669
1678
  domain: n,
1670
1679
  ua: navigator.userAgent
1671
1680
  });
1672
- return x.status ? (f(x.idToken), A(x.accessToken), de(x.refreshToken), s({
1673
- type: te,
1681
+ return U.status ? (y(U.idToken), A(U.accessToken), de(U.refreshToken), s({
1682
+ type: re,
1674
1683
  payload: {
1684
+ authenticationType: W.CODE,
1675
1685
  user: {
1676
- userId: x.userId,
1677
- username: l
1686
+ userId: U.userId,
1687
+ username: u,
1688
+ email: U.email
1678
1689
  }
1679
1690
  }
1680
- }), !0) : (W(we), !1);
1691
+ }), !0) : (x(we), !1);
1681
1692
  }
1682
1693
  return !1;
1683
- }, lt = async (l) => {
1684
- l?.preventDefault(), await P(Cr);
1694
+ }, lt = async (u) => {
1695
+ u?.preventDefault(), await P(Pr);
1685
1696
  }, dt = async () => {
1686
- const { isAuthenticated: l, user: y } = o;
1697
+ const { isAuthenticated: u, user: g } = o;
1687
1698
  try {
1688
- if (l && y && y.userId) {
1689
- if (u) {
1699
+ if (u && g && g.userId) {
1700
+ if (l) {
1690
1701
  i("getAccessToken");
1691
- const C = await H(u);
1692
- if (C && C.payload[S.USER_ID_KEY] !== "")
1693
- return u;
1702
+ const C = await Y(l);
1703
+ if (C && C.payload[f.USER_ID_KEY] !== "")
1704
+ return l;
1694
1705
  }
1695
1706
  i("getAccessToken: invalid access token, trying to refresh it");
1696
1707
  const d = await ct.refreshtoken({
1697
1708
  clientId: r,
1698
- userId: y.userId,
1709
+ userId: g.userId,
1699
1710
  nonce: it,
1700
1711
  domain: n
1701
1712
  });
1702
1713
  return d.status && d.status === "success" && d.newAccessToken ? (A(d.newAccessToken), de(d.newRefreshToken), d.newAccessToken) : (i(
1703
1714
  "getAccessToken: invalid refresh token, need to re-authenticate"
1704
- ), await P(U), "");
1715
+ ), await P(K), "");
1705
1716
  }
1706
1717
  return i(
1707
1718
  "getAccessToken: user is not authenticated, cannot get access token"
1708
- ), await P(U), "";
1719
+ ), await P(K), "";
1709
1720
  } catch {
1710
1721
  return i(
1711
1722
  "getAccessToken: exception occurred, invalidating and logging out"
1712
- ), await P(Nr), "";
1723
+ ), await P(Cr), "";
1713
1724
  }
1714
1725
  }, ht = () => o.isAuthenticated && h ? h : "", pt = async () => {
1715
- const { user: l } = o;
1716
- let y = await $({
1717
- accessToken: u,
1726
+ const { user: u } = o;
1727
+ let g = await $({
1728
+ accessToken: l,
1718
1729
  clientId: r,
1719
- type: K.GET_REGISTRATION_OPTIONS,
1730
+ type: L.GET_REGISTRATION_OPTIONS,
1720
1731
  params: {
1721
1732
  clientId: r,
1722
- id: l?.userId,
1723
- username: l?.username
1733
+ id: u?.userId,
1734
+ username: u?.username
1724
1735
  }
1725
1736
  });
1726
- if (y.status)
1737
+ if (g.status)
1727
1738
  try {
1728
- const d = await Ot(y.data);
1729
- return y = await $({
1730
- accessToken: u,
1739
+ const d = await vt(g.data);
1740
+ return g = await $({
1741
+ accessToken: l,
1731
1742
  clientId: r,
1732
- type: K.VERIFY_REGISTRATION,
1743
+ type: L.VERIFY_REGISTRATION,
1733
1744
  params: {
1734
1745
  clientId: r,
1735
- id: l?.userId,
1736
- username: l?.username,
1746
+ id: u?.userId,
1747
+ username: u?.username,
1737
1748
  registration: d
1738
1749
  }
1739
- }), !!(y.status && y.data.length > 0);
1750
+ }), !!(g.status && g.data.length > 0);
1740
1751
  } catch {
1741
1752
  return await $({
1742
- accessToken: u,
1753
+ accessToken: l,
1743
1754
  clientId: r,
1744
- type: K.VERIFY_REGISTRATION,
1755
+ type: L.VERIFY_REGISTRATION,
1745
1756
  params: {
1746
1757
  clientId: r,
1747
- id: l?.userId,
1748
- username: l?.username,
1758
+ id: u?.userId,
1759
+ username: u?.username,
1749
1760
  registration: {}
1750
1761
  }
1751
1762
  }), !1;
1752
1763
  }
1753
1764
  return !1;
1754
- }, ft = async () => {
1755
- s({ type: J, payload: { isLoading: !0 } }), V();
1756
- const l = me();
1757
- Re(l), i("loginWithPasskey");
1758
- const y = me();
1765
+ }, yt = async () => {
1766
+ s({ type: J, payload: { isLoading: !0 } }), j();
1767
+ const u = me();
1768
+ Re(u), i("loginWithPasskey");
1769
+ const g = me();
1759
1770
  let d = await $({
1760
- accessToken: u,
1771
+ accessToken: l,
1761
1772
  clientId: r,
1762
- type: K.GET_AUTHENTICATION_OPTIONS,
1773
+ type: L.GET_AUTHENTICATION_OPTIONS,
1763
1774
  params: {
1764
- id: y,
1775
+ id: g,
1765
1776
  clientId: r
1766
1777
  }
1767
1778
  });
1768
1779
  if (d.status)
1769
1780
  try {
1770
- const C = await Ct(d.data);
1781
+ const C = await Pt(d.data);
1771
1782
  return d = await $({
1772
- accessToken: u,
1783
+ accessToken: l,
1773
1784
  clientId: r,
1774
- type: K.VERIFY_AUTHENTICATION,
1785
+ type: L.VERIFY_AUTHENTICATION,
1775
1786
  params: {
1776
1787
  clientId: r,
1777
- id: y,
1788
+ id: g,
1778
1789
  authentication: C,
1779
- nonce: l,
1790
+ nonce: u,
1780
1791
  domain: n,
1781
1792
  sessionExpiration: t,
1782
1793
  ua: navigator.userAgent
1783
1794
  }
1784
- }), d.data.status === M ? (f(d.data.idToken), A(d.data.accessToken), de(d.data.refreshToken), s({
1785
- type: te,
1795
+ }), d.data.status === V ? (y(d.data.idToken), A(d.data.accessToken), de(d.data.refreshToken), s({
1796
+ type: re,
1786
1797
  payload: {
1798
+ authenticationType: W.PASSKEY,
1787
1799
  user: {
1788
1800
  userId: d.data.userId,
1789
- username: d.data.username
1801
+ username: d.data.username,
1802
+ email: d.data.email
1790
1803
  }
1791
1804
  }
1792
- }), !0) : (W(we), !1);
1805
+ }), !0) : (x(we), !1);
1793
1806
  } catch {
1794
1807
  return await $({
1795
- accessToken: u,
1808
+ accessToken: l,
1796
1809
  clientId: r,
1797
- type: K.VERIFY_AUTHENTICATION,
1810
+ type: L.VERIFY_AUTHENTICATION,
1798
1811
  params: {
1799
1812
  clientId: r,
1800
- id: y,
1813
+ id: g,
1801
1814
  authentication: {},
1802
- nonce: l,
1815
+ nonce: u,
1803
1816
  domain: n,
1804
1817
  sessionExpiration: t
1805
1818
  }
1806
- }), W(we), !1;
1819
+ }), x(we), !1;
1807
1820
  }
1808
1821
  return !1;
1809
1822
  };
1810
- return /* @__PURE__ */ be(Yr.Provider, { value: { state: o, dispatch: s }, children: /* @__PURE__ */ be(
1823
+ return /* @__PURE__ */ be(xr.Provider, { value: { state: o, dispatch: s }, children: /* @__PURE__ */ be(
1811
1824
  ot.Provider,
1812
1825
  {
1813
1826
  value: {
@@ -1817,15 +1830,15 @@ const Jr = (e) => N(
1817
1830
  getAccessToken: dt,
1818
1831
  getIdToken: ht,
1819
1832
  registeringForPasskey: pt,
1820
- loginWithPasskey: ft
1833
+ loginWithPasskey: yt
1821
1834
  },
1822
1835
  children: e
1823
1836
  }
1824
1837
  ) });
1825
- }, zr = (e = ot) => _t(e);
1838
+ }, qr = (e = ot) => Rt(e);
1826
1839
  export {
1827
- oe as AUTH_TYPES,
1828
- qr as AuthProvider,
1829
- Br as isGranted,
1830
- zr as useAuth
1840
+ W as AUTH_TYPES,
1841
+ Br as AuthProvider,
1842
+ Fr as isGranted,
1843
+ qr as useAuth
1831
1844
  };