@versini/auth-provider 6.4.4 → 7.1.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.
Files changed (3) hide show
  1. package/dist/index.d.ts +1 -12
  2. package/dist/index.js +865 -1269
  3. package/package.json +3 -4
package/dist/index.js CHANGED
@@ -1,123 +1,123 @@
1
- var Nt = Object.defineProperty;
2
- var Dt = (e, t, n) => t in e ? Nt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var X = (e, t, n) => Dt(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { jsx as ke } from "react/jsx-runtime";
5
- import Ut, { useSyncExternalStore as $t, useCallback as U, useEffect as Re, createContext as Kt, useReducer as Ht, useRef as Oe, useContext as Lt } from "react";
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);
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";
6
6
  /*!
7
- @versini/auth-provider v6.4.4
7
+ @versini/auth-provider v7.1.0
8
8
  © 2024 gizmette.com
9
9
  */
10
10
  try {
11
11
  window.__VERSINI_AUTH_CLIENT__ || (window.__VERSINI_AUTH_CLIENT__ = {
12
- version: "6.4.4",
13
- buildTime: "07/31/2024 08:11 PM EDT",
12
+ version: "7.1.0",
13
+ buildTime: "08/25/2024 01:31 PM EDT",
14
14
  homepage: "https://github.com/aversini/auth-client",
15
15
  license: "MIT"
16
16
  });
17
17
  } catch {
18
18
  }
19
- function v(e) {
19
+ function _(e) {
20
20
  const t = new Uint8Array(e);
21
- let n = "";
21
+ let r = "";
22
22
  for (const a of t)
23
- n += String.fromCharCode(a);
24
- return btoa(n).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
23
+ r += String.fromCharCode(a);
24
+ return btoa(r).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
25
25
  }
26
- function ce(e) {
27
- const t = e.replace(/-/g, "+").replace(/_/g, "/"), n = (4 - t.length % 4) % 4, r = t.padEnd(t.length + n, "="), a = atob(r), s = new ArrayBuffer(a.length), o = new Uint8Array(s);
26
+ function re(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
- function be() {
32
+ function Se() {
33
33
  return window?.PublicKeyCredential !== void 0 && typeof window.PublicKeyCredential == "function";
34
34
  }
35
- function je(e) {
35
+ function We(e) {
36
36
  const { id: t } = e;
37
37
  return {
38
38
  ...e,
39
- id: ce(t),
39
+ id: re(t),
40
40
  transports: e.transports
41
41
  };
42
42
  }
43
- function Fe(e) {
43
+ function xe(e) {
44
44
  return e === "localhost" || /^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e);
45
45
  }
46
- class b extends Error {
47
- constructor({ message: t, code: n, cause: r, name: a }) {
48
- super(t, { cause: r }), this.name = a ?? r.name, this.code = n;
46
+ class w extends Error {
47
+ constructor({ message: t, code: r, cause: n, name: a }) {
48
+ super(t, { cause: n }), this.name = a ?? n.name, this.code = r;
49
49
  }
50
50
  }
51
- function Wt({ error: e, options: t }) {
52
- const { publicKey: n } = t;
53
- if (!n)
51
+ function It({ error: e, options: t }) {
52
+ const { publicKey: r } = t;
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 b({
57
+ return new w({
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
- if (n.authenticatorSelection?.requireResidentKey === !0)
64
- return new b({
63
+ if (r.authenticatorSelection?.requireResidentKey === !0)
64
+ return new w({
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
- if (n.authenticatorSelection?.userVerification === "required")
70
- return new b({
69
+ if (r.authenticatorSelection?.userVerification === "required")
70
+ return new w({
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 b({
77
+ return new w({
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 b({
83
+ return new w({
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 n.pubKeyCredParams.filter((a) => a.type === "public-key").length === 0 ? new b({
89
+ return r.pubKeyCredParams.filter((a) => a.type === "public-key").length === 0 ? new w({
90
90
  message: 'No entry in pubKeyCredParams was of type "public-key"',
91
91
  code: "ERROR_MALFORMED_PUBKEYCREDPARAMS",
92
92
  cause: e
93
- }) : new b({
93
+ }) : new w({
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
- const r = window.location.hostname;
100
- if (Fe(r)) {
101
- if (n.rp.id !== r)
102
- return new b({
103
- message: `The RP ID "${n.rp.id}" is invalid for this domain`,
99
+ const n = window.location.hostname;
100
+ if (xe(n)) {
101
+ if (r.rp.id !== n)
102
+ return new w({
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 b({
107
+ } else return new w({
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
- if (n.user.id.byteLength < 1 || n.user.id.byteLength > 64)
114
- return new b({
113
+ if (r.user.id.byteLength < 1 || r.user.id.byteLength > 64)
114
+ return new w({
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 b({
120
+ return new w({
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,11 +125,11 @@ function Wt({ error: e, options: t }) {
125
125
  }
126
126
  return e;
127
127
  }
128
- class xt {
128
+ class bt {
129
129
  createNewAbortSignal() {
130
130
  if (this.controller) {
131
- const n = new Error("Cancelling existing WebAuthn API call for new one");
132
- n.name = "AbortError", this.controller.abort(n);
131
+ const r = new Error("Cancelling existing WebAuthn API call for new one");
132
+ r.name = "AbortError", this.controller.abort(r);
133
133
  }
134
134
  const t = new AbortController();
135
135
  return this.controller = t, t.signal;
@@ -141,117 +141,117 @@ class xt {
141
141
  }
142
142
  }
143
143
  }
144
- const Be = new xt(), Mt = ["cross-platform", "platform"];
145
- function qe(e) {
146
- if (e && !(Mt.indexOf(e) < 0))
144
+ const Je = new bt(), vt = ["cross-platform", "platform"];
145
+ function Ye(e) {
146
+ if (e && !(vt.indexOf(e) < 0))
147
147
  return e;
148
148
  }
149
- async function Gt(e) {
150
- if (!be())
149
+ async function Ot(e) {
150
+ if (!Se())
151
151
  throw new Error("WebAuthn is not supported in this browser");
152
- const n = { publicKey: {
152
+ const r = { publicKey: {
153
153
  ...e,
154
- challenge: ce(e.challenge),
154
+ challenge: re(e.challenge),
155
155
  user: {
156
156
  ...e.user,
157
- id: ce(e.user.id)
157
+ id: re(e.user.id)
158
158
  },
159
- excludeCredentials: e.excludeCredentials?.map(je)
159
+ excludeCredentials: e.excludeCredentials?.map(We)
160
160
  } };
161
- n.signal = Be.createNewAbortSignal();
162
- let r;
161
+ r.signal = Je.createNewAbortSignal();
162
+ let n;
163
163
  try {
164
- r = await navigator.credentials.create(n);
165
- } catch (g) {
166
- throw Wt({ error: g, options: n });
164
+ n = await navigator.credentials.create(r);
165
+ } catch (u) {
166
+ throw It({ error: u, options: r });
167
167
  }
168
- if (!r)
168
+ if (!n)
169
169
  throw new Error("Registration was not completed");
170
- const { id: a, rawId: s, response: o, type: i } = r;
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 y;
174
- if (typeof o.getPublicKeyAlgorithm == "function")
172
+ typeof s.getTransports == "function" && (c = s.getTransports());
173
+ let h;
174
+ if (typeof s.getPublicKeyAlgorithm == "function")
175
175
  try {
176
- y = o.getPublicKeyAlgorithm();
177
- } catch (g) {
178
- ge("getPublicKeyAlgorithm()", g);
176
+ h = s.getPublicKeyAlgorithm();
177
+ } catch (u) {
178
+ he("getPublicKeyAlgorithm()", u);
179
179
  }
180
- let l;
181
- if (typeof o.getPublicKey == "function")
180
+ let f;
181
+ if (typeof s.getPublicKey == "function")
182
182
  try {
183
- const g = o.getPublicKey();
184
- g !== null && (l = v(g));
185
- } catch (g) {
186
- ge("getPublicKey()", g);
183
+ const u = s.getPublicKey();
184
+ u !== null && (f = _(u));
185
+ } catch (u) {
186
+ he("getPublicKey()", u);
187
187
  }
188
- let h;
189
- if (typeof o.getAuthenticatorData == "function")
188
+ let p;
189
+ if (typeof s.getAuthenticatorData == "function")
190
190
  try {
191
- h = v(o.getAuthenticatorData());
192
- } catch (g) {
193
- ge("getAuthenticatorData()", g);
191
+ p = _(s.getAuthenticatorData());
192
+ } catch (u) {
193
+ he("getAuthenticatorData()", u);
194
194
  }
195
195
  return {
196
196
  id: a,
197
- rawId: v(s),
197
+ rawId: _(o),
198
198
  response: {
199
- attestationObject: v(o.attestationObject),
200
- clientDataJSON: v(o.clientDataJSON),
199
+ attestationObject: _(s.attestationObject),
200
+ clientDataJSON: _(s.clientDataJSON),
201
201
  transports: c,
202
- publicKeyAlgorithm: y,
203
- publicKey: l,
204
- authenticatorData: h
202
+ publicKeyAlgorithm: h,
203
+ publicKey: f,
204
+ authenticatorData: p
205
205
  },
206
206
  type: i,
207
- clientExtensionResults: r.getClientExtensionResults(),
208
- authenticatorAttachment: qe(r.authenticatorAttachment)
207
+ clientExtensionResults: n.getClientExtensionResults(),
208
+ authenticatorAttachment: Ye(n.authenticatorAttachment)
209
209
  };
210
210
  }
211
- function ge(e, t) {
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 Jt() {
216
- if (!be())
215
+ function kt() {
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 Yt({ error: e, options: t }) {
222
- const { publicKey: n } = t;
223
- if (!n)
221
+ function Pt({ error: e, options: t }) {
222
+ const { publicKey: r } = t;
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 b({
227
+ return new w({
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 b({
234
+ return new w({
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
- const r = window.location.hostname;
241
- if (Fe(r)) {
242
- if (n.rpId !== r)
243
- return new b({
244
- message: `The RP ID "${n.rpId}" is invalid for this domain`,
240
+ const n = window.location.hostname;
241
+ if (xe(n)) {
242
+ if (r.rpId !== n)
243
+ return new w({
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 b({
248
+ } else return new w({
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 b({
254
+ return new w({
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,71 +259,71 @@ function Yt({ error: e, options: t }) {
259
259
  }
260
260
  return e;
261
261
  }
262
- async function Vt(e, t = !1) {
263
- if (!be())
262
+ async function Ct(e, t = !1) {
263
+ if (!Se())
264
264
  throw new Error("WebAuthn is not supported in this browser");
265
- let n;
266
- e.allowCredentials?.length !== 0 && (n = e.allowCredentials?.map(je));
267
- const r = {
265
+ let r;
266
+ e.allowCredentials?.length !== 0 && (r = e.allowCredentials?.map(We));
267
+ const n = {
268
268
  ...e,
269
- challenge: ce(e.challenge),
270
- allowCredentials: n
269
+ challenge: re(e.challenge),
270
+ allowCredentials: r
271
271
  }, a = {};
272
272
  if (t) {
273
- if (!await Jt())
273
+ if (!await kt())
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
- a.mediation = "conditional", r.allowCredentials = [];
277
+ a.mediation = "conditional", n.allowCredentials = [];
278
278
  }
279
- a.publicKey = r, a.signal = Be.createNewAbortSignal();
280
- let s;
279
+ a.publicKey = n, a.signal = Je.createNewAbortSignal();
280
+ let o;
281
281
  try {
282
- s = await navigator.credentials.get(a);
283
- } catch (h) {
284
- throw Yt({ error: h, options: a });
282
+ o = await navigator.credentials.get(a);
283
+ } catch (p) {
284
+ throw Pt({ error: p, 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: y } = s;
289
- let l;
290
- return c.userHandle && (l = v(c.userHandle)), {
291
- id: o,
292
- rawId: v(i),
288
+ const { id: s, rawId: i, response: c, type: h } = o;
289
+ let f;
290
+ return c.userHandle && (f = _(c.userHandle)), {
291
+ id: s,
292
+ rawId: _(i),
293
293
  response: {
294
- authenticatorData: v(c.authenticatorData),
295
- clientDataJSON: v(c.clientDataJSON),
296
- signature: v(c.signature),
297
- userHandle: l
294
+ authenticatorData: _(c.authenticatorData),
295
+ clientDataJSON: _(c.clientDataJSON),
296
+ signature: _(c.signature),
297
+ userHandle: f
298
298
  },
299
- type: y,
300
- clientExtensionResults: s.getClientExtensionResults(),
301
- authenticatorAttachment: qe(s.authenticatorAttachment)
299
+ type: h,
300
+ clientExtensionResults: o.getClientExtensionResults(),
301
+ authenticatorAttachment: Ye(o.authenticatorAttachment)
302
302
  };
303
303
  }
304
304
  /*!
305
- @versini/auth-common v3.3.0
305
+ @versini/auth-common v4.0.0
306
306
  © 2024 gizmette.com
307
307
  */
308
308
  try {
309
309
  window.__VERSINI_AUTH_COMMON__ || (window.__VERSINI_AUTH_COMMON__ = {
310
- version: "3.3.0",
311
- buildTime: "07/31/2024 08:11 PM EDT",
310
+ version: "4.0.0",
311
+ buildTime: "08/25/2024 01:31 PM EDT",
312
312
  homepage: "https://github.com/aversini/auth-client",
313
313
  license: "MIT"
314
314
  });
315
315
  } catch {
316
316
  }
317
- const G = {
317
+ const oe = {
318
318
  ID_TOKEN: "id_token",
319
319
  ACCESS_TOKEN: "token",
320
320
  ID_AND_ACCESS_TOKEN: "id_token token",
321
321
  CODE: "code",
322
322
  REFRESH_TOKEN: "refresh_token",
323
323
  PASSKEY: "passkey"
324
- }, ze = {
324
+ }, Ge = {
325
325
  CLIENT_ID: "X-Auth-ClientId"
326
- }, T = {
326
+ }, S = {
327
327
  ALG: "RS256",
328
328
  USER_ID_KEY: "sub",
329
329
  TOKEN_ID_KEY: "__raw",
@@ -333,8 +333,9 @@ const G = {
333
333
  EXPIRES_AT_KEY: "exp",
334
334
  CREATED_AT_KEY: "iat",
335
335
  SCOPES_KEY: "scopes",
336
+ CLIENT_ID_KEY: "aud",
336
337
  ISSUER: "gizmette.com"
337
- }, jt = `-----BEGIN PUBLIC KEY-----
338
+ }, Nt = `-----BEGIN PUBLIC KEY-----
338
339
  MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsF6i3Jd9fY/3COqCw/m7
339
340
  w5PKyTYLGAI2I6SIIdpe6i6DOCbEkmDz7LdVsBqwNtVi8gvWYIj+8ol6rU3qu1v5
340
341
  i1Jd45GSK4kzkVdgCmQZbM5ak0KI99q5wsrAIzUd+LRJ2HRvWtr5IYdsIiXaQjle
@@ -342,56 +343,59 @@ aMwPFOIcJH+rKfFgNcHLcaS5syp7zU1ANwZ+trgR+DifBr8TLVkBynmNeTyhDm2+
342
343
  l0haqjMk0UoNPPE8iYBWUHQJJE1Dqstj65d6Eh5g64Pao25y4cmYJbKjiblIGEkE
343
344
  sjqybA9mARAqh9k/eiIopecWSiffNQTwVQVd2I9ZH3BalhEXHlqFgrjz51kFqg81
344
345
  awIDAQAB
345
- -----END PUBLIC KEY-----`, he = {
346
- AUTHENTICATE: "authenticate",
346
+ -----END PUBLIC KEY-----`, ie = {
347
347
  CODE: "code",
348
- LOGOUT: "logout"
349
- }, pe = crypto, Qe = (e) => e instanceof CryptoKey, Z = new TextEncoder(), q = new TextDecoder();
350
- function Ft(...e) {
351
- const t = e.reduce((a, { length: s }) => a + s, 0), n = new Uint8Array(t);
352
- let r = 0;
348
+ LOGOUT: "logout",
349
+ LOGIN: "login",
350
+ REFRESH: "refresh"
351
+ }, ce = crypto, Me = (e) => e instanceof CryptoKey, F = new TextEncoder(), G = new TextDecoder();
352
+ function Dt(...e) {
353
+ const t = e.reduce((a, { length: o }) => a + o, 0), r = new Uint8Array(t);
354
+ let n = 0;
353
355
  for (const a of e)
354
- n.set(a, r), r += a.length;
355
- return n;
356
+ r.set(a, n), n += a.length;
357
+ return r;
356
358
  }
357
- const Bt = (e) => {
358
- const t = atob(e), n = new Uint8Array(t.length);
359
- for (let r = 0; r < t.length; r++)
360
- n[r] = t.charCodeAt(r);
361
- return n;
362
- }, B = (e) => {
359
+ const Ut = (e) => {
360
+ const t = atob(e), r = new Uint8Array(t.length);
361
+ for (let n = 0; n < t.length; n++)
362
+ r[n] = t.charCodeAt(n);
363
+ return r;
364
+ }, Y = (e) => {
363
365
  let t = e;
364
- t instanceof Uint8Array && (t = q.decode(t)), t = t.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "");
366
+ t instanceof Uint8Array && (t = G.decode(t)), t = t.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "");
365
367
  try {
366
- return Bt(t);
368
+ return Ut(t);
367
369
  } catch {
368
370
  throw new TypeError("The input to be decoded is not correctly encoded.");
369
371
  }
370
372
  };
371
- let $ = class extends Error {
373
+ class D extends Error {
372
374
  static get code() {
373
375
  return "ERR_JOSE_GENERIC";
374
376
  }
375
377
  constructor(t) {
376
- var n;
377
- super(t), this.code = "ERR_JOSE_GENERIC", this.name = this.constructor.name, (n = Error.captureStackTrace) == null || n.call(Error, this, this.constructor);
378
+ var r;
379
+ super(t), this.code = "ERR_JOSE_GENERIC", this.name = this.constructor.name, (r = Error.captureStackTrace) == null || r.call(Error, this, this.constructor);
378
380
  }
379
- }, _ = class extends $ {
381
+ }
382
+ class R extends D {
380
383
  static get code() {
381
384
  return "ERR_JWT_CLAIM_VALIDATION_FAILED";
382
385
  }
383
- constructor(t, n, r = "unspecified", a = "unspecified") {
384
- super(t), this.code = "ERR_JWT_CLAIM_VALIDATION_FAILED", this.claim = r, this.reason = a, this.payload = n;
386
+ constructor(t, r, n = "unspecified", a = "unspecified") {
387
+ super(t), this.code = "ERR_JWT_CLAIM_VALIDATION_FAILED", this.claim = n, this.reason = a, this.payload = r;
385
388
  }
386
- }, Ne = class extends $ {
389
+ }
390
+ class ve extends D {
387
391
  static get code() {
388
392
  return "ERR_JWT_EXPIRED";
389
393
  }
390
- constructor(t, n, r = "unspecified", a = "unspecified") {
391
- super(t), this.code = "ERR_JWT_EXPIRED", this.claim = r, this.reason = a, this.payload = n;
394
+ constructor(t, r, n = "unspecified", a = "unspecified") {
395
+ super(t), this.code = "ERR_JWT_EXPIRED", this.claim = n, this.reason = a, this.payload = r;
392
396
  }
393
- };
394
- class qt extends $ {
397
+ }
398
+ class Kt extends D {
395
399
  constructor() {
396
400
  super(...arguments), this.code = "ERR_JOSE_ALG_NOT_ALLOWED";
397
401
  }
@@ -399,15 +403,15 @@ class qt extends $ {
399
403
  return "ERR_JOSE_ALG_NOT_ALLOWED";
400
404
  }
401
405
  }
402
- let N = class extends $ {
406
+ class k extends D {
403
407
  constructor() {
404
408
  super(...arguments), this.code = "ERR_JOSE_NOT_SUPPORTED";
405
409
  }
406
410
  static get code() {
407
411
  return "ERR_JOSE_NOT_SUPPORTED";
408
412
  }
409
- };
410
- class A extends $ {
413
+ }
414
+ class m extends D {
411
415
  constructor() {
412
416
  super(...arguments), this.code = "ERR_JWS_INVALID";
413
417
  }
@@ -415,7 +419,7 @@ class A extends $ {
415
419
  return "ERR_JWS_INVALID";
416
420
  }
417
421
  }
418
- let k = class extends $ {
422
+ let v = class extends D {
419
423
  constructor() {
420
424
  super(...arguments), this.code = "ERR_JWT_INVALID";
421
425
  }
@@ -423,7 +427,7 @@ let k = class extends $ {
423
427
  return "ERR_JWT_INVALID";
424
428
  }
425
429
  };
426
- class zt extends $ {
430
+ class $t extends D {
427
431
  constructor() {
428
432
  super(...arguments), this.code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED", this.message = "signature verification failed";
429
433
  }
@@ -431,16 +435,16 @@ class zt extends $ {
431
435
  return "ERR_JWS_SIGNATURE_VERIFICATION_FAILED";
432
436
  }
433
437
  }
434
- function P(e, t = "algorithm.name") {
438
+ function b(e, t = "algorithm.name") {
435
439
  return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`);
436
440
  }
437
- function ee(e, t) {
441
+ function B(e, t) {
438
442
  return e.name === t;
439
443
  }
440
- function me(e) {
444
+ function pe(e) {
441
445
  return parseInt(e.name.slice(4), 10);
442
446
  }
443
- function Qt(e) {
447
+ function Lt(e) {
444
448
  switch (e) {
445
449
  case "ES256":
446
450
  return "P-256";
@@ -452,104 +456,104 @@ function Qt(e) {
452
456
  throw new Error("unreachable");
453
457
  }
454
458
  }
455
- function Xt(e, t) {
456
- if (t.length && !t.some((n) => e.usages.includes(n))) {
457
- let n = "CryptoKey does not support this operation, its usages must include ";
459
+ function Ht(e, t) {
460
+ if (t.length && !t.some((r) => e.usages.includes(r))) {
461
+ let r = "CryptoKey does not support this operation, its usages must include ";
458
462
  if (t.length > 2) {
459
- const r = t.pop();
460
- n += `one of ${t.join(", ")}, or ${r}.`;
461
- } else t.length === 2 ? n += `one of ${t[0]} or ${t[1]}.` : n += `${t[0]}.`;
462
- throw new TypeError(n);
463
+ const n = t.pop();
464
+ r += `one of ${t.join(", ")}, or ${n}.`;
465
+ } else t.length === 2 ? r += `one of ${t[0]} or ${t[1]}.` : r += `${t[0]}.`;
466
+ throw new TypeError(r);
463
467
  }
464
468
  }
465
- function Zt(e, t, ...n) {
469
+ function Wt(e, t, ...r) {
466
470
  switch (t) {
467
471
  case "HS256":
468
472
  case "HS384":
469
473
  case "HS512": {
470
- if (!ee(e.algorithm, "HMAC"))
471
- throw P("HMAC");
472
- const r = parseInt(t.slice(2), 10);
473
- if (me(e.algorithm.hash) !== r)
474
- throw P(`SHA-${r}`, "algorithm.hash");
474
+ if (!B(e.algorithm, "HMAC"))
475
+ throw b("HMAC");
476
+ const n = parseInt(t.slice(2), 10);
477
+ if (pe(e.algorithm.hash) !== n)
478
+ throw b(`SHA-${n}`, "algorithm.hash");
475
479
  break;
476
480
  }
477
481
  case "RS256":
478
482
  case "RS384":
479
483
  case "RS512": {
480
- if (!ee(e.algorithm, "RSASSA-PKCS1-v1_5"))
481
- throw P("RSASSA-PKCS1-v1_5");
482
- const r = parseInt(t.slice(2), 10);
483
- if (me(e.algorithm.hash) !== r)
484
- throw P(`SHA-${r}`, "algorithm.hash");
484
+ if (!B(e.algorithm, "RSASSA-PKCS1-v1_5"))
485
+ throw b("RSASSA-PKCS1-v1_5");
486
+ const n = parseInt(t.slice(2), 10);
487
+ if (pe(e.algorithm.hash) !== n)
488
+ throw b(`SHA-${n}`, "algorithm.hash");
485
489
  break;
486
490
  }
487
491
  case "PS256":
488
492
  case "PS384":
489
493
  case "PS512": {
490
- if (!ee(e.algorithm, "RSA-PSS"))
491
- throw P("RSA-PSS");
492
- const r = parseInt(t.slice(2), 10);
493
- if (me(e.algorithm.hash) !== r)
494
- throw P(`SHA-${r}`, "algorithm.hash");
494
+ if (!B(e.algorithm, "RSA-PSS"))
495
+ throw b("RSA-PSS");
496
+ const n = parseInt(t.slice(2), 10);
497
+ if (pe(e.algorithm.hash) !== n)
498
+ throw b(`SHA-${n}`, "algorithm.hash");
495
499
  break;
496
500
  }
497
501
  case "EdDSA": {
498
502
  if (e.algorithm.name !== "Ed25519" && e.algorithm.name !== "Ed448")
499
- throw P("Ed25519 or Ed448");
503
+ throw b("Ed25519 or Ed448");
500
504
  break;
501
505
  }
502
506
  case "ES256":
503
507
  case "ES384":
504
508
  case "ES512": {
505
- if (!ee(e.algorithm, "ECDSA"))
506
- throw P("ECDSA");
507
- const r = Qt(t);
508
- if (e.algorithm.namedCurve !== r)
509
- throw P(r, "algorithm.namedCurve");
509
+ if (!B(e.algorithm, "ECDSA"))
510
+ throw b("ECDSA");
511
+ const n = Lt(t);
512
+ if (e.algorithm.namedCurve !== n)
513
+ throw b(n, "algorithm.namedCurve");
510
514
  break;
511
515
  }
512
516
  default:
513
517
  throw new TypeError("CryptoKey does not support this operation");
514
518
  }
515
- Xt(e, n);
519
+ Ht(e, r);
516
520
  }
517
- function Xe(e, t, ...n) {
518
- var r;
519
- if (n.length > 2) {
520
- const a = n.pop();
521
- e += `one of type ${n.join(", ")}, or ${a}.`;
522
- } else n.length === 2 ? e += `one of type ${n[0]} or ${n[1]}.` : e += `of type ${n[0]}.`;
523
- return t == null ? e += ` Received ${t}` : typeof t == "function" && t.name ? e += ` Received function ${t.name}` : typeof t == "object" && t != null && (r = t.constructor) != null && r.name && (e += ` Received an instance of ${t.constructor.name}`), e;
521
+ function Ve(e, t, ...r) {
522
+ var n;
523
+ if (r.length > 2) {
524
+ const a = r.pop();
525
+ e += `one of type ${r.join(", ")}, or ${a}.`;
526
+ } else r.length === 2 ? e += `one of type ${r[0]} or ${r[1]}.` : e += `of type ${r[0]}.`;
527
+ return t == null ? e += ` Received ${t}` : typeof t == "function" && t.name ? e += ` Received function ${t.name}` : typeof t == "object" && t != null && (n = t.constructor) != null && n.name && (e += ` Received an instance of ${t.constructor.name}`), e;
524
528
  }
525
- const De = (e, ...t) => Xe("Key must be ", e, ...t);
526
- function Ze(e, t, ...n) {
527
- return Xe(`Key for the ${e} algorithm must be `, t, ...n);
529
+ const Oe = (e, ...t) => Ve("Key must be ", e, ...t);
530
+ function je(e, t, ...r) {
531
+ return Ve(`Key for the ${e} algorithm must be `, t, ...r);
528
532
  }
529
- const et = (e) => Qe(e) ? !0 : e?.[Symbol.toStringTag] === "KeyObject", ue = ["CryptoKey"], en = (...e) => {
533
+ const Fe = (e) => Me(e) ? !0 : e?.[Symbol.toStringTag] === "KeyObject", ne = ["CryptoKey"], xt = (...e) => {
530
534
  const t = e.filter(Boolean);
531
535
  if (t.length === 0 || t.length === 1)
532
536
  return !0;
533
- let n;
534
- for (const r of t) {
535
- const a = Object.keys(r);
536
- if (!n || n.size === 0) {
537
- n = new Set(a);
537
+ let r;
538
+ for (const n of t) {
539
+ const a = Object.keys(n);
540
+ if (!r || r.size === 0) {
541
+ r = new Set(a);
538
542
  continue;
539
543
  }
540
- for (const s of a) {
541
- if (n.has(s))
544
+ for (const o of a) {
545
+ if (r.has(o))
542
546
  return !1;
543
- n.add(s);
547
+ r.add(o);
544
548
  }
545
549
  }
546
550
  return !0;
547
551
  };
548
- function tn(e) {
552
+ function Jt(e) {
549
553
  return typeof e == "object" && e !== null;
550
554
  }
551
- function le(e) {
552
- if (!tn(e) || Object.prototype.toString.call(e) !== "[object Object]")
555
+ function ae(e) {
556
+ if (!Jt(e) || Object.prototype.toString.call(e) !== "[object Object]")
553
557
  return !1;
554
558
  if (Object.getPrototypeOf(e) === null)
555
559
  return !0;
@@ -558,27 +562,27 @@ function le(e) {
558
562
  t = Object.getPrototypeOf(t);
559
563
  return Object.getPrototypeOf(e) === t;
560
564
  }
561
- const nn = (e, t) => {
565
+ const Yt = (e, t) => {
562
566
  if (e.startsWith("RS") || e.startsWith("PS")) {
563
- const { modulusLength: n } = t.algorithm;
564
- if (typeof n != "number" || n < 2048)
567
+ const { modulusLength: r } = t.algorithm;
568
+ if (typeof r != "number" || r < 2048)
565
569
  throw new TypeError(`${e} requires key modulusLength to be 2048 bits or larger`);
566
570
  }
567
571
  };
568
- function rn(e) {
569
- let t, n;
572
+ function Gt(e) {
573
+ let t, r;
570
574
  switch (e.kty) {
571
575
  case "RSA": {
572
576
  switch (e.alg) {
573
577
  case "PS256":
574
578
  case "PS384":
575
579
  case "PS512":
576
- t = { name: "RSA-PSS", hash: `SHA-${e.alg.slice(-3)}` }, n = e.d ? ["sign"] : ["verify"];
580
+ t = { name: "RSA-PSS", hash: `SHA-${e.alg.slice(-3)}` }, r = e.d ? ["sign"] : ["verify"];
577
581
  break;
578
582
  case "RS256":
579
583
  case "RS384":
580
584
  case "RS512":
581
- t = { name: "RSASSA-PKCS1-v1_5", hash: `SHA-${e.alg.slice(-3)}` }, n = e.d ? ["sign"] : ["verify"];
585
+ t = { name: "RSASSA-PKCS1-v1_5", hash: `SHA-${e.alg.slice(-3)}` }, r = e.d ? ["sign"] : ["verify"];
582
586
  break;
583
587
  case "RSA-OAEP":
584
588
  case "RSA-OAEP-256":
@@ -587,93 +591,93 @@ function rn(e) {
587
591
  t = {
588
592
  name: "RSA-OAEP",
589
593
  hash: `SHA-${parseInt(e.alg.slice(-3), 10) || 1}`
590
- }, n = e.d ? ["decrypt", "unwrapKey"] : ["encrypt", "wrapKey"];
594
+ }, r = e.d ? ["decrypt", "unwrapKey"] : ["encrypt", "wrapKey"];
591
595
  break;
592
596
  default:
593
- throw new N('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
597
+ throw new k('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
594
598
  }
595
599
  break;
596
600
  }
597
601
  case "EC": {
598
602
  switch (e.alg) {
599
603
  case "ES256":
600
- t = { name: "ECDSA", namedCurve: "P-256" }, n = e.d ? ["sign"] : ["verify"];
604
+ t = { name: "ECDSA", namedCurve: "P-256" }, r = e.d ? ["sign"] : ["verify"];
601
605
  break;
602
606
  case "ES384":
603
- t = { name: "ECDSA", namedCurve: "P-384" }, n = e.d ? ["sign"] : ["verify"];
607
+ t = { name: "ECDSA", namedCurve: "P-384" }, r = e.d ? ["sign"] : ["verify"];
604
608
  break;
605
609
  case "ES512":
606
- t = { name: "ECDSA", namedCurve: "P-521" }, n = e.d ? ["sign"] : ["verify"];
610
+ t = { name: "ECDSA", namedCurve: "P-521" }, r = e.d ? ["sign"] : ["verify"];
607
611
  break;
608
612
  case "ECDH-ES":
609
613
  case "ECDH-ES+A128KW":
610
614
  case "ECDH-ES+A192KW":
611
615
  case "ECDH-ES+A256KW":
612
- t = { name: "ECDH", namedCurve: e.crv }, n = e.d ? ["deriveBits"] : [];
616
+ t = { name: "ECDH", namedCurve: e.crv }, r = e.d ? ["deriveBits"] : [];
613
617
  break;
614
618
  default:
615
- throw new N('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
619
+ throw new k('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
616
620
  }
617
621
  break;
618
622
  }
619
623
  case "OKP": {
620
624
  switch (e.alg) {
621
625
  case "EdDSA":
622
- t = { name: e.crv }, n = e.d ? ["sign"] : ["verify"];
626
+ t = { name: e.crv }, r = e.d ? ["sign"] : ["verify"];
623
627
  break;
624
628
  case "ECDH-ES":
625
629
  case "ECDH-ES+A128KW":
626
630
  case "ECDH-ES+A192KW":
627
631
  case "ECDH-ES+A256KW":
628
- t = { name: e.crv }, n = e.d ? ["deriveBits"] : [];
632
+ t = { name: e.crv }, r = e.d ? ["deriveBits"] : [];
629
633
  break;
630
634
  default:
631
- throw new N('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
635
+ throw new k('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
632
636
  }
633
637
  break;
634
638
  }
635
639
  default:
636
- throw new N('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
640
+ throw new k('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
637
641
  }
638
- return { algorithm: t, keyUsages: n };
642
+ return { algorithm: t, keyUsages: r };
639
643
  }
640
- const an = async (e) => {
644
+ const Mt = async (e) => {
641
645
  if (!e.alg)
642
646
  throw new TypeError('"alg" argument is required when "jwk.alg" is not present');
643
- const { algorithm: t, keyUsages: n } = rn(e), r = [
647
+ const { algorithm: t, keyUsages: r } = Gt(e), n = [
644
648
  t,
645
649
  e.ext ?? !1,
646
- e.key_ops ?? n
650
+ e.key_ops ?? r
647
651
  ], a = { ...e };
648
- return delete a.alg, delete a.use, pe.subtle.importKey("jwk", a, ...r);
649
- }, tt = (e) => B(e);
650
- let Ee, we;
651
- const nt = (e) => e?.[Symbol.toStringTag] === "KeyObject", rt = async (e, t, n, r) => {
652
+ return delete a.alg, delete a.use, ce.subtle.importKey("jwk", a, ...n);
653
+ }, Be = (e) => Y(e);
654
+ let fe, ye;
655
+ const qe = (e) => e?.[Symbol.toStringTag] === "KeyObject", ze = async (e, t, r, n) => {
652
656
  let a = e.get(t);
653
- if (a != null && a[r])
654
- return a[r];
655
- const s = await an({ ...n, alg: r });
656
- return a ? a[r] = s : e.set(t, { [r]: s }), s;
657
- }, on = (e, t) => {
658
- if (nt(e)) {
659
- let n = e.export({ format: "jwk" });
660
- return delete n.d, delete n.dp, delete n.dq, delete n.p, delete n.q, delete n.qi, n.k ? tt(n.k) : (we || (we = /* @__PURE__ */ new WeakMap()), rt(we, e, n, t));
657
+ if (a != null && a[n])
658
+ return a[n];
659
+ const o = await Mt({ ...r, alg: n });
660
+ return a ? a[n] = o : e.set(t, { [n]: o }), o;
661
+ }, Vt = (e, t) => {
662
+ if (qe(e)) {
663
+ 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));
661
665
  }
662
666
  return e;
663
- }, sn = (e, t) => {
664
- if (nt(e)) {
665
- let n = e.export({ format: "jwk" });
666
- return n.k ? tt(n.k) : (Ee || (Ee = /* @__PURE__ */ new WeakMap()), rt(Ee, e, n, t));
667
+ }, jt = (e, t) => {
668
+ if (qe(e)) {
669
+ let r = e.export({ format: "jwk" });
670
+ return r.k ? Be(r.k) : (fe || (fe = /* @__PURE__ */ new WeakMap()), ze(fe, e, r, t));
667
671
  }
668
672
  return e;
669
- }, cn = { normalizePublicKey: on, normalizePrivateKey: sn }, O = (e, t, n = 0) => {
670
- n === 0 && (t.unshift(t.length), t.unshift(6));
671
- const r = e.indexOf(t[0], n);
672
- if (r === -1)
673
+ }, Ft = { normalizePublicKey: Vt, normalizePrivateKey: jt }, O = (e, t, r = 0) => {
674
+ r === 0 && (t.unshift(t.length), t.unshift(6));
675
+ const n = e.indexOf(t[0], r);
676
+ if (n === -1)
673
677
  return !1;
674
- const a = e.subarray(r, r + t.length);
675
- return a.length !== t.length ? !1 : a.every((s, o) => s === t[o]) || O(e, t, r + 1);
676
- }, Ue = (e) => {
678
+ const a = e.subarray(n, n + t.length);
679
+ return a.length !== t.length ? !1 : a.every((o, s) => o === t[s]) || O(e, t, n + 1);
680
+ }, ke = (e) => {
677
681
  switch (!0) {
678
682
  case O(e, [42, 134, 72, 206, 61, 3, 1, 7]):
679
683
  return "P-256";
@@ -690,492 +694,492 @@ const nt = (e) => e?.[Symbol.toStringTag] === "KeyObject", rt = async (e, t, n,
690
694
  case O(e, [43, 101, 113]):
691
695
  return "Ed448";
692
696
  default:
693
- throw new N("Invalid or unsupported EC Key Curve or OKP Key Sub Type");
697
+ throw new k("Invalid or unsupported EC Key Curve or OKP Key Sub Type");
694
698
  }
695
- }, un = async (e, t, n, r, a) => {
696
- let s, o;
697
- const i = new Uint8Array(atob(n.replace(e, "")).split("").map((c) => c.charCodeAt(0)));
698
- switch (r) {
699
+ }, Bt = async (e, t, r, n, a) => {
700
+ let o, s;
701
+ const i = new Uint8Array(atob(r.replace(e, "")).split("").map((c) => c.charCodeAt(0)));
702
+ switch (n) {
699
703
  case "PS256":
700
704
  case "PS384":
701
705
  case "PS512":
702
- s = { name: "RSA-PSS", hash: `SHA-${r.slice(-3)}` }, o = ["verify"];
706
+ o = { name: "RSA-PSS", hash: `SHA-${n.slice(-3)}` }, s = ["verify"];
703
707
  break;
704
708
  case "RS256":
705
709
  case "RS384":
706
710
  case "RS512":
707
- s = { name: "RSASSA-PKCS1-v1_5", hash: `SHA-${r.slice(-3)}` }, o = ["verify"];
711
+ o = { name: "RSASSA-PKCS1-v1_5", hash: `SHA-${n.slice(-3)}` }, s = ["verify"];
708
712
  break;
709
713
  case "RSA-OAEP":
710
714
  case "RSA-OAEP-256":
711
715
  case "RSA-OAEP-384":
712
716
  case "RSA-OAEP-512":
713
- s = {
717
+ o = {
714
718
  name: "RSA-OAEP",
715
- hash: `SHA-${parseInt(r.slice(-3), 10) || 1}`
716
- }, o = ["encrypt", "wrapKey"];
719
+ hash: `SHA-${parseInt(n.slice(-3), 10) || 1}`
720
+ }, s = ["encrypt", "wrapKey"];
717
721
  break;
718
722
  case "ES256":
719
- s = { name: "ECDSA", namedCurve: "P-256" }, o = ["verify"];
723
+ o = { name: "ECDSA", namedCurve: "P-256" }, s = ["verify"];
720
724
  break;
721
725
  case "ES384":
722
- s = { name: "ECDSA", namedCurve: "P-384" }, o = ["verify"];
726
+ o = { name: "ECDSA", namedCurve: "P-384" }, s = ["verify"];
723
727
  break;
724
728
  case "ES512":
725
- s = { name: "ECDSA", namedCurve: "P-521" }, o = ["verify"];
729
+ o = { name: "ECDSA", namedCurve: "P-521" }, s = ["verify"];
726
730
  break;
727
731
  case "ECDH-ES":
728
732
  case "ECDH-ES+A128KW":
729
733
  case "ECDH-ES+A192KW":
730
734
  case "ECDH-ES+A256KW": {
731
- const c = Ue(i);
732
- s = c.startsWith("P-") ? { name: "ECDH", namedCurve: c } : { name: c }, o = [];
735
+ const c = ke(i);
736
+ o = c.startsWith("P-") ? { name: "ECDH", namedCurve: c } : { name: c }, s = [];
733
737
  break;
734
738
  }
735
739
  case "EdDSA":
736
- s = { name: Ue(i) }, o = ["verify"];
740
+ o = { name: ke(i) }, s = ["verify"];
737
741
  break;
738
742
  default:
739
- throw new N('Invalid or unsupported "alg" (Algorithm) value');
743
+ throw new k('Invalid or unsupported "alg" (Algorithm) value');
740
744
  }
741
- return pe.subtle.importKey(t, i, s, !1, o);
742
- }, ln = (e, t, n) => un(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g, "spki", e, t);
743
- async function dn(e, t, n) {
745
+ 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) {
744
748
  if (e.indexOf("-----BEGIN PUBLIC KEY-----") !== 0)
745
749
  throw new TypeError('"spki" must be SPKI formatted string');
746
- return ln(e, t);
750
+ return qt(e, t);
747
751
  }
748
- const ie = (e) => e?.[Symbol.toStringTag], hn = (e, t) => {
752
+ const ee = (e) => e?.[Symbol.toStringTag], Qt = (e, t) => {
749
753
  if (!(t instanceof Uint8Array)) {
750
- if (!et(t))
751
- throw new TypeError(Ze(e, t, ...ue, "Uint8Array"));
754
+ if (!Fe(t))
755
+ throw new TypeError(je(e, t, ...ne, "Uint8Array"));
752
756
  if (t.type !== "secret")
753
- throw new TypeError(`${ie(t)} instances for symmetric algorithms must be of type "secret"`);
757
+ throw new TypeError(`${ee(t)} instances for symmetric algorithms must be of type "secret"`);
754
758
  }
755
- }, pn = (e, t, n) => {
756
- if (!et(t))
757
- throw new TypeError(Ze(e, t, ...ue));
759
+ }, Xt = (e, t, r) => {
760
+ if (!Fe(t))
761
+ throw new TypeError(je(e, t, ...ne));
758
762
  if (t.type === "secret")
759
- throw new TypeError(`${ie(t)} instances for asymmetric algorithms must not be of type "secret"`);
760
- if (t.algorithm && n === "verify" && t.type === "private")
761
- throw new TypeError(`${ie(t)} instances for asymmetric algorithm verifying must be of type "public"`);
762
- if (t.algorithm && n === "encrypt" && t.type === "private")
763
- throw new TypeError(`${ie(t)} instances for asymmetric algorithm encryption must be of type "public"`);
764
- }, fn = (e, t, n) => {
765
- e.startsWith("HS") || e === "dir" || e.startsWith("PBES2") || /^A\d{3}(?:GCM)?KW$/.test(e) ? hn(e, t) : pn(e, t, n);
763
+ throw new TypeError(`${ee(t)} instances for asymmetric algorithms must not be of type "secret"`);
764
+ 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
+ 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);
766
770
  };
767
- function yn(e, t, n, r, a) {
768
- if (a.crit !== void 0 && r?.crit === void 0)
771
+ function er(e, t, r, n, a) {
772
+ if (a.crit !== void 0 && n?.crit === void 0)
769
773
  throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');
770
- if (!r || r.crit === void 0)
774
+ if (!n || n.crit === void 0)
771
775
  return /* @__PURE__ */ new Set();
772
- if (!Array.isArray(r.crit) || r.crit.length === 0 || r.crit.some((o) => typeof o != "string" || o.length === 0))
776
+ if (!Array.isArray(n.crit) || n.crit.length === 0 || n.crit.some((s) => typeof s != "string" || s.length === 0))
773
777
  throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');
774
- let s;
775
- n !== void 0 ? s = new Map([...Object.entries(n), ...t.entries()]) : s = t;
776
- for (const o of r.crit) {
777
- if (!s.has(o))
778
- throw new N(`Extension Header Parameter "${o}" is not recognized`);
779
- if (a[o] === void 0)
780
- throw new e(`Extension Header Parameter "${o}" is missing`);
781
- if (s.get(o) && r[o] === void 0)
782
- throw new e(`Extension Header Parameter "${o}" MUST be integrity protected`);
783
- }
784
- return new Set(r.crit);
778
+ let o;
779
+ r !== void 0 ? o = new Map([...Object.entries(r), ...t.entries()]) : o = t;
780
+ for (const s of n.crit) {
781
+ if (!o.has(s))
782
+ throw new k(`Extension Header Parameter "${s}" is not recognized`);
783
+ if (a[s] === void 0)
784
+ throw new e(`Extension Header Parameter "${s}" is missing`);
785
+ if (o.get(s) && n[s] === void 0)
786
+ throw new e(`Extension Header Parameter "${s}" MUST be integrity protected`);
787
+ }
788
+ return new Set(n.crit);
785
789
  }
786
- const gn = (e, t) => {
787
- if (t !== void 0 && (!Array.isArray(t) || t.some((n) => typeof n != "string")))
790
+ const tr = (e, t) => {
791
+ if (t !== void 0 && (!Array.isArray(t) || t.some((r) => typeof r != "string")))
788
792
  throw new TypeError(`"${e}" option must be an array of strings`);
789
793
  if (t)
790
794
  return new Set(t);
791
795
  };
792
- function mn(e, t) {
793
- const n = `SHA-${e.slice(-3)}`;
796
+ function rr(e, t) {
797
+ const r = `SHA-${e.slice(-3)}`;
794
798
  switch (e) {
795
799
  case "HS256":
796
800
  case "HS384":
797
801
  case "HS512":
798
- return { hash: n, name: "HMAC" };
802
+ return { hash: r, name: "HMAC" };
799
803
  case "PS256":
800
804
  case "PS384":
801
805
  case "PS512":
802
- return { hash: n, name: "RSA-PSS", saltLength: e.slice(-3) >> 3 };
806
+ return { hash: r, name: "RSA-PSS", saltLength: e.slice(-3) >> 3 };
803
807
  case "RS256":
804
808
  case "RS384":
805
809
  case "RS512":
806
- return { hash: n, name: "RSASSA-PKCS1-v1_5" };
810
+ return { hash: r, name: "RSASSA-PKCS1-v1_5" };
807
811
  case "ES256":
808
812
  case "ES384":
809
813
  case "ES512":
810
- return { hash: n, name: "ECDSA", namedCurve: t.namedCurve };
814
+ return { hash: r, name: "ECDSA", namedCurve: t.namedCurve };
811
815
  case "EdDSA":
812
816
  return { name: t.name };
813
817
  default:
814
- throw new N(`alg ${e} is not supported either by JOSE or your javascript runtime`);
818
+ throw new k(`alg ${e} is not supported either by JOSE or your javascript runtime`);
815
819
  }
816
820
  }
817
- async function En(e, t, n) {
818
- if (t = await cn.normalizePublicKey(t, e), Qe(t))
819
- return Zt(t, e, n), t;
821
+ async function nr(e, t, r) {
822
+ if (t = await Ft.normalizePublicKey(t, e), Me(t))
823
+ return Wt(t, e, r), t;
820
824
  if (t instanceof Uint8Array) {
821
825
  if (!e.startsWith("HS"))
822
- throw new TypeError(De(t, ...ue));
823
- return pe.subtle.importKey("raw", t, { hash: `SHA-${e.slice(-3)}`, name: "HMAC" }, !1, [n]);
826
+ throw new TypeError(Oe(t, ...ne));
827
+ return ce.subtle.importKey("raw", t, { hash: `SHA-${e.slice(-3)}`, name: "HMAC" }, !1, [r]);
824
828
  }
825
- throw new TypeError(De(t, ...ue, "Uint8Array"));
829
+ throw new TypeError(Oe(t, ...ne, "Uint8Array"));
826
830
  }
827
- const wn = async (e, t, n, r) => {
828
- const a = await En(e, t, "verify");
829
- nn(e, a);
830
- const s = mn(e, a.algorithm);
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);
831
835
  try {
832
- return await pe.subtle.verify(s, a, n, r);
836
+ return await ce.subtle.verify(o, a, r, n);
833
837
  } catch {
834
838
  return !1;
835
839
  }
836
840
  };
837
- async function Sn(e, t, n) {
838
- if (!le(e))
839
- throw new A("Flattened JWS must be an object");
841
+ async function sr(e, t, r) {
842
+ if (!ae(e))
843
+ throw new m("Flattened JWS must be an object");
840
844
  if (e.protected === void 0 && e.header === void 0)
841
- throw new A('Flattened JWS must have either of the "protected" or "header" members');
845
+ throw new m('Flattened JWS must have either of the "protected" or "header" members');
842
846
  if (e.protected !== void 0 && typeof e.protected != "string")
843
- throw new A("JWS Protected Header incorrect type");
847
+ throw new m("JWS Protected Header incorrect type");
844
848
  if (e.payload === void 0)
845
- throw new A("JWS Payload missing");
849
+ throw new m("JWS Payload missing");
846
850
  if (typeof e.signature != "string")
847
- throw new A("JWS Signature missing or incorrect type");
848
- if (e.header !== void 0 && !le(e.header))
849
- throw new A("JWS Unprotected Header incorrect type");
850
- let r = {};
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");
854
+ let n = {};
851
855
  if (e.protected)
852
856
  try {
853
- const u = B(e.protected);
854
- r = JSON.parse(q.decode(u));
857
+ const T = Y(e.protected);
858
+ n = JSON.parse(G.decode(T));
855
859
  } catch {
856
- throw new A("JWS Protected Header is invalid");
860
+ throw new m("JWS Protected Header is invalid");
857
861
  }
858
- if (!en(r, e.header))
859
- throw new A("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
862
+ if (!xt(n, e.header))
863
+ throw new m("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
860
864
  const a = {
861
- ...r,
865
+ ...n,
862
866
  ...e.header
863
- }, s = yn(A, /* @__PURE__ */ new Map([["b64", !0]]), n?.crit, r, a);
864
- let o = !0;
865
- if (s.has("b64") && (o = r.b64, typeof o != "boolean"))
866
- throw new A('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
867
+ }, o = er(m, /* @__PURE__ */ new Map([["b64", !0]]), r?.crit, n, a);
868
+ let s = !0;
869
+ 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');
867
871
  const { alg: i } = a;
868
872
  if (typeof i != "string" || !i)
869
- throw new A('JWS "alg" (Algorithm) Header Parameter missing or invalid');
870
- const c = n && gn("algorithms", n.algorithms);
873
+ throw new m('JWS "alg" (Algorithm) Header Parameter missing or invalid');
874
+ const c = r && tr("algorithms", r.algorithms);
871
875
  if (c && !c.has(i))
872
- throw new qt('"alg" (Algorithm) Header Parameter value not allowed');
873
- if (o) {
876
+ throw new Kt('"alg" (Algorithm) Header Parameter value not allowed');
877
+ if (s) {
874
878
  if (typeof e.payload != "string")
875
- throw new A("JWS Payload must be a string");
879
+ throw new m("JWS Payload must be a string");
876
880
  } else if (typeof e.payload != "string" && !(e.payload instanceof Uint8Array))
877
- throw new A("JWS Payload must be a string or an Uint8Array instance");
878
- let y = !1;
879
- typeof t == "function" && (t = await t(r, e), y = !0), fn(i, t, "verify");
880
- const l = Ft(Z.encode(e.protected ?? ""), Z.encode("."), typeof e.payload == "string" ? Z.encode(e.payload) : e.payload);
881
- let h;
881
+ throw new m("JWS Payload must be a string or an Uint8Array instance");
882
+ 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);
885
+ let p;
882
886
  try {
883
- h = B(e.signature);
887
+ p = Y(e.signature);
884
888
  } catch {
885
- throw new A("Failed to base64url decode the signature");
889
+ throw new m("Failed to base64url decode the signature");
886
890
  }
887
- if (!await wn(i, t, h, l))
888
- throw new zt();
889
- let g;
890
- if (o)
891
+ if (!await ar(i, t, p, f))
892
+ throw new $t();
893
+ let u;
894
+ if (s)
891
895
  try {
892
- g = B(e.payload);
896
+ u = Y(e.payload);
893
897
  } catch {
894
- throw new A("Failed to base64url decode the payload");
898
+ throw new m("Failed to base64url decode the payload");
895
899
  }
896
- else typeof e.payload == "string" ? g = Z.encode(e.payload) : g = e.payload;
897
- const f = { payload: g };
898
- return e.protected !== void 0 && (f.protectedHeader = r), e.header !== void 0 && (f.unprotectedHeader = e.header), y ? { ...f, key: t } : f;
900
+ else typeof e.payload == "string" ? u = F.encode(e.payload) : u = e.payload;
901
+ const A = { payload: u };
902
+ return e.protected !== void 0 && (A.protectedHeader = n), e.header !== void 0 && (A.unprotectedHeader = e.header), h ? { ...A, key: t } : A;
899
903
  }
900
- async function An(e, t, n) {
901
- if (e instanceof Uint8Array && (e = q.decode(e)), typeof e != "string")
902
- throw new A("Compact JWS must be a string or Uint8Array");
903
- const { 0: r, 1: a, 2: s, length: o } = e.split(".");
904
- if (o !== 3)
905
- throw new A("Invalid Compact JWS");
906
- const i = await Sn({ payload: a, protected: r, signature: s }, t, n), c = { payload: i.payload, protectedHeader: i.protectedHeader };
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");
907
+ const { 0: n, 1: a, 2: o, length: s } = e.split(".");
908
+ 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 };
907
911
  return typeof t == "function" ? { ...c, key: i.key } : c;
908
912
  }
909
- const Tn = (e) => Math.floor(e.getTime() / 1e3), at = 60, ot = at * 60, Ie = ot * 24, Rn = Ie * 7, bn = Ie * 365.25, In = /^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i, $e = (e) => {
910
- const t = In.exec(e);
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);
911
915
  if (!t || t[4] && t[1])
912
916
  throw new TypeError("Invalid time period format");
913
- const n = parseFloat(t[2]), r = t[3].toLowerCase();
917
+ const r = parseFloat(t[2]), n = t[3].toLowerCase();
914
918
  let a;
915
- switch (r) {
919
+ switch (n) {
916
920
  case "sec":
917
921
  case "secs":
918
922
  case "second":
919
923
  case "seconds":
920
924
  case "s":
921
- a = Math.round(n);
925
+ a = Math.round(r);
922
926
  break;
923
927
  case "minute":
924
928
  case "minutes":
925
929
  case "min":
926
930
  case "mins":
927
931
  case "m":
928
- a = Math.round(n * at);
932
+ a = Math.round(r * Qe);
929
933
  break;
930
934
  case "hour":
931
935
  case "hours":
932
936
  case "hr":
933
937
  case "hrs":
934
938
  case "h":
935
- a = Math.round(n * ot);
939
+ a = Math.round(r * Xe);
936
940
  break;
937
941
  case "day":
938
942
  case "days":
939
943
  case "d":
940
- a = Math.round(n * Ie);
944
+ a = Math.round(r * Ae);
941
945
  break;
942
946
  case "week":
943
947
  case "weeks":
944
948
  case "w":
945
- a = Math.round(n * Rn);
949
+ a = Math.round(r * cr);
946
950
  break;
947
951
  default:
948
- a = Math.round(n * bn);
952
+ a = Math.round(r * ur);
949
953
  break;
950
954
  }
951
955
  return t[1] === "-" || t[4] === "ago" ? -a : a;
952
- }, Ke = (e) => e.toLowerCase().replace(/^application\//, ""), _n = (e, t) => typeof e == "string" ? t.includes(e) : Array.isArray(e) ? t.some(Set.prototype.has.bind(new Set(e))) : !1, vn = (e, t, n = {}) => {
953
- let r;
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
+ let n;
954
958
  try {
955
- r = JSON.parse(q.decode(t));
959
+ n = JSON.parse(G.decode(t));
956
960
  } catch {
957
961
  }
958
- if (!le(r))
959
- throw new k("JWT Claims Set must be a top-level JSON object");
960
- const { typ: a } = n;
961
- if (a && (typeof e.typ != "string" || Ke(e.typ) !== Ke(a)))
962
- throw new _('unexpected "typ" JWT header value', r, "typ", "check_failed");
963
- const { requiredClaims: s = [], issuer: o, subject: i, audience: c, maxTokenAge: y } = n, l = [...s];
964
- y !== void 0 && l.push("iat"), c !== void 0 && l.push("aud"), i !== void 0 && l.push("sub"), o !== void 0 && l.push("iss");
965
- for (const u of new Set(l.reverse()))
966
- if (!(u in r))
967
- throw new _(`missing required "${u}" claim`, r, u, "missing");
968
- if (o && !(Array.isArray(o) ? o : [o]).includes(r.iss))
969
- throw new _('unexpected "iss" claim value', r, "iss", "check_failed");
970
- if (i && r.sub !== i)
971
- throw new _('unexpected "sub" claim value', r, "sub", "check_failed");
972
- if (c && !_n(r.aud, typeof c == "string" ? [c] : c))
973
- throw new _('unexpected "aud" claim value', r, "aud", "check_failed");
974
- let h;
975
- switch (typeof n.clockTolerance) {
962
+ if (!ae(n))
963
+ throw new v("JWT Claims Set must be a top-level JSON object");
964
+ const { typ: a } = r;
965
+ if (a && (typeof e.typ != "string" || Ce(e.typ) !== Ce(a)))
966
+ 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()))
970
+ if (!(T in n))
971
+ throw new R(`missing required "${T}" claim`, n, T, "missing");
972
+ if (s && !(Array.isArray(s) ? s : [s]).includes(n.iss))
973
+ throw new R('unexpected "iss" claim value', n, "iss", "check_failed");
974
+ if (i && n.sub !== i)
975
+ throw new R('unexpected "sub" claim value', n, "sub", "check_failed");
976
+ if (c && !dr(n.aud, typeof c == "string" ? [c] : c))
977
+ throw new R('unexpected "aud" claim value', n, "aud", "check_failed");
978
+ let p;
979
+ switch (typeof r.clockTolerance) {
976
980
  case "string":
977
- h = $e(n.clockTolerance);
981
+ p = Pe(r.clockTolerance);
978
982
  break;
979
983
  case "number":
980
- h = n.clockTolerance;
984
+ p = r.clockTolerance;
981
985
  break;
982
986
  case "undefined":
983
- h = 0;
987
+ p = 0;
984
988
  break;
985
989
  default:
986
990
  throw new TypeError("Invalid clockTolerance option type");
987
991
  }
988
- const { currentDate: g } = n, f = Tn(g || /* @__PURE__ */ new Date());
989
- if ((r.iat !== void 0 || y) && typeof r.iat != "number")
990
- throw new _('"iat" claim must be a number', r, "iat", "invalid");
991
- if (r.nbf !== void 0) {
992
- if (typeof r.nbf != "number")
993
- throw new _('"nbf" claim must be a number', r, "nbf", "invalid");
994
- if (r.nbf > f + h)
995
- throw new _('"nbf" claim timestamp check failed', r, "nbf", "check_failed");
996
- }
997
- if (r.exp !== void 0) {
998
- if (typeof r.exp != "number")
999
- throw new _('"exp" claim must be a number', r, "exp", "invalid");
1000
- if (r.exp <= f - h)
1001
- throw new Ne('"exp" claim timestamp check failed', r, "exp", "check_failed");
992
+ const { currentDate: u } = r, A = ir(u || /* @__PURE__ */ new Date());
993
+ if ((n.iat !== void 0 || h) && typeof n.iat != "number")
994
+ throw new R('"iat" claim must be a number', n, "iat", "invalid");
995
+ if (n.nbf !== void 0) {
996
+ if (typeof n.nbf != "number")
997
+ throw new R('"nbf" claim must be a number', n, "nbf", "invalid");
998
+ if (n.nbf > A + p)
999
+ throw new R('"nbf" claim timestamp check failed', n, "nbf", "check_failed");
1000
+ }
1001
+ if (n.exp !== void 0) {
1002
+ if (typeof n.exp != "number")
1003
+ throw new R('"exp" claim must be a number', n, "exp", "invalid");
1004
+ if (n.exp <= A - p)
1005
+ throw new ve('"exp" claim timestamp check failed', n, "exp", "check_failed");
1006
+ }
1007
+ if (h) {
1008
+ const T = A - n.iat, le = typeof h == "number" ? h : Pe(h);
1009
+ if (T - p > le)
1010
+ throw new ve('"iat" claim timestamp check failed (too far in the past)', n, "iat", "check_failed");
1011
+ if (T < 0 - p)
1012
+ throw new R('"iat" claim timestamp check failed (it should be in the past)', n, "iat", "check_failed");
1002
1013
  }
1003
- if (y) {
1004
- const u = f - r.iat, m = typeof y == "number" ? y : $e(y);
1005
- if (u - h > m)
1006
- throw new Ne('"iat" claim timestamp check failed (too far in the past)', r, "iat", "check_failed");
1007
- if (u < 0 - h)
1008
- throw new _('"iat" claim timestamp check failed (it should be in the past)', r, "iat", "check_failed");
1009
- }
1010
- return r;
1014
+ return n;
1011
1015
  };
1012
- async function Cn(e, t, n) {
1013
- var r;
1014
- const a = await An(e, t, n);
1015
- if ((r = a.protectedHeader.crit) != null && r.includes("b64") && a.protectedHeader.b64 === !1)
1016
- throw new k("JWTs MUST NOT use unencoded payload");
1017
- const s = { payload: vn(a.protectedHeader, a.payload, n), protectedHeader: a.protectedHeader };
1018
- return typeof t == "function" ? { ...s, key: a.key } : s;
1016
+ async function pr(e, t, r) {
1017
+ var n;
1018
+ const a = await or(e, t, r);
1019
+ if ((n = a.protectedHeader.crit) != null && n.includes("b64") && a.protectedHeader.b64 === !1)
1020
+ throw new v("JWTs MUST NOT use unencoded payload");
1021
+ const o = { payload: hr(a.protectedHeader, a.payload, r), protectedHeader: a.protectedHeader };
1022
+ return typeof t == "function" ? { ...o, key: a.key } : o;
1019
1023
  }
1020
- const Pn = B;
1021
- function kn(e) {
1024
+ const fr = Y;
1025
+ function yr(e) {
1022
1026
  if (typeof e != "string")
1023
- throw new k("JWTs must use Compact JWS serialization, JWT must be a string");
1024
- const { 1: t, length: n } = e.split(".");
1025
- if (n === 5)
1026
- throw new k("Only JWTs using Compact JWS serialization can be decoded");
1027
- if (n !== 3)
1028
- throw new k("Invalid JWT");
1027
+ throw new v("JWTs must use Compact JWS serialization, JWT must be a string");
1028
+ const { 1: t, length: r } = e.split(".");
1029
+ if (r === 5)
1030
+ throw new v("Only JWTs using Compact JWS serialization can be decoded");
1031
+ if (r !== 3)
1032
+ throw new v("Invalid JWT");
1029
1033
  if (!t)
1030
- throw new k("JWTs must contain a payload");
1031
- let r;
1034
+ throw new v("JWTs must contain a payload");
1035
+ let n;
1032
1036
  try {
1033
- r = Pn(t);
1037
+ n = fr(t);
1034
1038
  } catch {
1035
- throw new k("Failed to base64url decode the payload");
1039
+ throw new v("Failed to base64url decode the payload");
1036
1040
  }
1037
1041
  let a;
1038
1042
  try {
1039
- a = JSON.parse(q.decode(r));
1043
+ a = JSON.parse(G.decode(n));
1040
1044
  } catch {
1041
- throw new k("Failed to parse the decoded payload as JSON");
1045
+ throw new v("Failed to parse the decoded payload as JSON");
1042
1046
  }
1043
- if (!le(a))
1044
- throw new k("Invalid JWT Claims Set");
1047
+ if (!ae(a))
1048
+ throw new v("Invalid JWT Claims Set");
1045
1049
  return a;
1046
1050
  }
1047
- const J = async (e) => {
1051
+ const H = async (e) => {
1048
1052
  try {
1049
- const t = T.ALG, n = await dn(jt, t);
1050
- return await Cn(e, n, {
1051
- issuer: T.ISSUER
1053
+ const t = S.ALG, r = await zt(Nt, t);
1054
+ return await pr(e, r, {
1055
+ issuer: S.ISSUER
1052
1056
  });
1053
1057
  } catch {
1054
1058
  return;
1055
1059
  }
1056
- }, On = (e) => {
1060
+ }, gr = (e) => {
1057
1061
  try {
1058
- return kn(e);
1062
+ return yr(e);
1059
1063
  } catch {
1060
1064
  return;
1061
1065
  }
1062
1066
  };
1063
- var w = [];
1064
- for (var Se = 0; Se < 256; ++Se)
1065
- w.push((Se + 256).toString(16).slice(1));
1066
- function Nn(e, t = 0) {
1067
- 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();
1067
+ var g = [];
1068
+ 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();
1068
1072
  }
1069
- var te, Dn = new Uint8Array(16);
1070
- function Un() {
1071
- if (!te && (te = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !te))
1073
+ var q, mr = new Uint8Array(16);
1074
+ function wr() {
1075
+ if (!q && (q = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !q))
1072
1076
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
1073
- return te(Dn);
1077
+ return q(mr);
1074
1078
  }
1075
- var $n = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
1076
- const He = {
1077
- randomUUID: $n
1079
+ var Sr = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
1080
+ const Ne = {
1081
+ randomUUID: Sr
1078
1082
  };
1079
- function Le(e, t, n) {
1080
- if (He.randomUUID && !t && !e)
1081
- return He.randomUUID();
1083
+ function De(e, t, r) {
1084
+ if (Ne.randomUUID && !t && !e)
1085
+ return Ne.randomUUID();
1082
1086
  e = e || {};
1083
- var r = e.random || (e.rng || Un)();
1084
- return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, Nn(r);
1087
+ var n = e.random || (e.rng || wr)();
1088
+ return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, Er(n);
1085
1089
  }
1086
- const We = globalThis.crypto, Kn = (e) => `${Le()}${Le()}`.slice(0, e), Hn = (e) => btoa(
1090
+ const Ue = globalThis.crypto, Ar = (e) => `${De()}${De()}`.slice(0, e), Tr = (e) => btoa(
1087
1091
  [...new Uint8Array(e)].map((t) => String.fromCharCode(t)).join("")
1088
1092
  );
1089
- async function Ln(e) {
1090
- if (!We.subtle)
1093
+ async function Rr(e) {
1094
+ if (!Ue.subtle)
1091
1095
  throw new Error(
1092
1096
  "crypto.subtle is available only in secure contexts (HTTPS)."
1093
1097
  );
1094
- const t = new TextEncoder().encode(e), n = await We.subtle.digest("SHA-256", t);
1095
- return Hn(n).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
1098
+ const t = new TextEncoder().encode(e), r = await Ue.subtle.digest("SHA-256", t);
1099
+ return Tr(r).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
1096
1100
  }
1097
- async function Wn(e) {
1098
- const n = Kn(43), r = await Ln(n);
1101
+ async function _r(e) {
1102
+ const r = Ar(43), n = await Rr(r);
1099
1103
  return {
1100
- code_verifier: n,
1101
- code_challenge: r
1104
+ code_verifier: r,
1105
+ code_challenge: n
1102
1106
  };
1103
1107
  }
1104
- const Hr = async (e, t) => {
1105
- var n;
1106
- const r = await J(e);
1107
- if (!r || !Array.isArray((n = r.payload) == null ? void 0 : n[T.SCOPES_KEY]))
1108
+ const Br = async (e, t) => {
1109
+ var r;
1110
+ const n = await H(e);
1111
+ if (!n || !Array.isArray((r = n.payload) == null ? void 0 : r[S.SCOPES_KEY]))
1108
1112
  return !1;
1109
- const a = r.payload[T.SCOPES_KEY];
1110
- return Array.isArray(t) ? t.every((s) => a.includes(s)) : Object.keys(t).some(
1111
- (s) => t[s].every((o) => a.includes(o))
1113
+ const a = n.payload[S.SCOPES_KEY];
1114
+ return Array.isArray(t) ? t.every((o) => a.includes(o)) : Object.keys(t).some(
1115
+ (o) => t[o].every((s) => a.includes(s))
1112
1116
  );
1113
1117
  };
1114
- function st(e, t) {
1118
+ function Ze(e, t) {
1115
1119
  window.dispatchEvent(new StorageEvent("storage", { key: e, newValue: t }));
1116
1120
  }
1117
- const xe = (e, t) => {
1118
- const n = JSON.stringify(
1121
+ const Ke = (e, t) => {
1122
+ const r = JSON.stringify(
1119
1123
  typeof t == "function" ? t() : t
1120
1124
  );
1121
- window.localStorage.setItem(e, n), st(e, n);
1122
- }, xn = (e) => {
1123
- window.localStorage.removeItem(e), st(e, null);
1124
- }, Me = (e) => window.localStorage.getItem(e), Mn = (e) => (window.addEventListener("storage", e), () => window.removeEventListener("storage", e));
1125
- function ne({
1125
+ window.localStorage.setItem(e, r), Ze(e, r);
1126
+ }, Ir = (e) => {
1127
+ 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({
1126
1130
  key: e,
1127
1131
  initialValue: t
1128
1132
  }) {
1129
- const n = $t(Mn, () => Me(e)), r = U(
1130
- (o) => {
1133
+ const r = St(br, () => $e(e)), n = N(
1134
+ (s) => {
1131
1135
  try {
1132
- const i = typeof o == "function" ? o(JSON.parse(n)) : o;
1133
- i == null ? xn(e) : xe(e, i);
1136
+ const i = typeof s == "function" ? s(JSON.parse(r)) : s;
1137
+ i == null ? Ir(e) : Ke(e, i);
1134
1138
  } catch (i) {
1135
1139
  console.warn(i);
1136
1140
  }
1137
1141
  },
1138
- [e, n]
1139
- ), a = U(() => {
1140
- r(t);
1141
- }, [t, r]), s = U(() => {
1142
- r(null);
1143
- }, [r]);
1144
- return Re(() => {
1142
+ [e, r]
1143
+ ), a = N(() => {
1144
+ n(t);
1145
+ }, [t, n]), o = N(() => {
1146
+ n(null);
1147
+ }, [n]);
1148
+ return He(() => {
1145
1149
  try {
1146
- Me(e) === null && typeof t < "u" && xe(e, t);
1147
- } catch (o) {
1148
- console.warn(o);
1150
+ $e(e) === null && typeof t < "u" && Ke(e, t);
1151
+ } catch (s) {
1152
+ console.warn(s);
1149
1153
  }
1150
- }, [e, t]), [n ? JSON.parse(n) : null, r, a, s];
1154
+ }, [e, t]), [r ? JSON.parse(r) : null, n, a, o];
1151
1155
  }
1152
- var S = [];
1153
- for (var Ae = 0; Ae < 256; ++Ae)
1154
- S.push((Ae + 256).toString(16).slice(1));
1155
- function Gn(e, t = 0) {
1156
- 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();
1156
+ var E = [];
1157
+ 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();
1157
1161
  }
1158
- var re, Jn = new Uint8Array(16);
1159
- function Yn() {
1160
- if (!re && (re = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !re))
1162
+ var Q, Or = new Uint8Array(16);
1163
+ function kr() {
1164
+ if (!Q && (Q = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !Q))
1161
1165
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
1162
- return re(Jn);
1166
+ return Q(Or);
1163
1167
  }
1164
- var Vn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
1165
- const Ge = {
1166
- randomUUID: Vn
1168
+ var Pr = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
1169
+ const Le = {
1170
+ randomUUID: Pr
1167
1171
  };
1168
- function Te(e, t, n) {
1169
- if (Ge.randomUUID && !t && !e)
1170
- return Ge.randomUUID();
1172
+ function me(e, t, r) {
1173
+ if (Le.randomUUID && !t && !e)
1174
+ return Le.randomUUID();
1171
1175
  e = e || {};
1172
- var r = e.random || (e.rng || Yn)();
1173
- return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, Gn(r);
1176
+ var n = e.random || (e.rng || kr)();
1177
+ return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, vr(n);
1174
1178
  }
1175
- const H = "Your session has expired. For your security, please log in again to continue.", jn = "Your session has been successfully terminated.", ae = "Login failed. Please try again.", Fn = "Error getting access token, please re-authenticate.", Bn = "You forgot to wrap your component in <AuthProvider>.", de = {
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 = {
1176
1180
  dev: "https://auth.gizmette.local.com:3003",
1177
1181
  prod: "https://mylogin.gizmette.com/auth"
1178
- }, oe = "@@auth@@", j = "LOADING", F = "LOGIN", it = "LOGOUT", fe = "success", C = "failure", ct = "include", ut = "POST", lt = "application/json", se = {
1182
+ }, X = "@@auth@@", J = "LOADING", te = "LOGIN", et = "LOGOUT", M = "success", I = "failure", tt = "include", rt = "POST", nt = "application/json", Z = {
1179
1183
  GET_REGISTRATION_OPTIONS: `mutation GetPasskeyRegistrationOptions(
1180
1184
  $clientId: String!,
1181
1185
  $username: String!,
@@ -1237,14 +1241,16 @@ const H = "Your session has expired. For your security, please log in again to c
1237
1241
  $authentication: AuthenticationOptionsInput!,
1238
1242
  $nonce: String!,
1239
1243
  $domain: String,
1240
- $fingerprint: String) {
1244
+ $sessionExpiration: String,
1245
+ $ua: String) {
1241
1246
  verifyPasskeyAuthentication(
1242
1247
  clientId: $clientId,
1243
1248
  id: $id,
1244
1249
  authentication: $authentication,
1245
1250
  nonce: $nonce,
1246
1251
  domain: $domain,
1247
- fingerprint: $fingerprint) {
1252
+ sessionExpiration: $sessionExpiration,
1253
+ ua: $ua) {
1248
1254
  status,
1249
1255
  idToken,
1250
1256
  accessToken,
@@ -1253,515 +1259,151 @@ const H = "Your session has expired. For your security, please log in again to c
1253
1259
  username,
1254
1260
  }
1255
1261
  }`
1256
- };
1257
- /*!
1258
- @versini/ui-fingerprint v1.0.1
1259
- © 2024 gizmette.com
1260
- */
1261
- try {
1262
- window.__VERSINI_UI_FINGERPRINT__ || (window.__VERSINI_UI_FINGERPRINT__ = {
1263
- version: "1.0.1",
1264
- buildTime: "07/18/2024 09:17 AM EDT",
1265
- homepage: "https://github.com/aversini/ui-components",
1266
- license: "MIT"
1267
- });
1268
- } catch {
1269
- }
1270
- const qn = (e) => Array.from(e).map((t) => t.toString(16).padStart(2, "0")).join(""), dt = async (e) => {
1271
- if (e === "")
1272
- return "";
1273
- const t = new TextEncoder().encode(e), n = await crypto.subtle.digest("SHA-256", t);
1274
- return Array.from(new Uint8Array(n)).map((r) => r.toString(16).padStart(2, "0")).join("");
1275
- };
1276
- function Je(e, t) {
1277
- return new Promise((n) => setTimeout(n, e, t));
1278
- }
1279
- async function zn(e, t, n = 50) {
1280
- var r, a, s;
1281
- const o = document;
1282
- for (; !o.body; )
1283
- await Je(n);
1284
- const i = o.createElement("iframe");
1285
- try {
1286
- for (await new Promise((c, y) => {
1287
- let l = !1;
1288
- const h = () => {
1289
- l = !0, c();
1290
- }, g = (m) => {
1291
- l = !0, y(m);
1292
- };
1293
- i.onload = h, i.onerror = g;
1294
- const { style: f } = i;
1295
- f.setProperty("display", "block", "important"), f.position = "absolute", f.top = "0", f.left = "0", f.visibility = "hidden", i.src = "about:blank", o.body.appendChild(i);
1296
- const u = () => {
1297
- var m, R;
1298
- l || (((R = (m = i.contentWindow) == null ? void 0 : m.document) == null ? void 0 : R.readyState) === "complete" ? h() : setTimeout(u, 10));
1299
- };
1300
- u();
1301
- }); !((a = (r = i.contentWindow) == null ? void 0 : r.document) != null && a.body); )
1302
- await Je(n);
1303
- return await e(i, i.contentWindow);
1304
- } finally {
1305
- (s = i.parentNode) == null || s.removeChild(i);
1306
- }
1307
- }
1308
- const Qn = {
1309
- audio: {
1310
- sampleHash: "",
1311
- oscillator: "",
1312
- maxChannels: 0,
1313
- channelCountMode: ""
1314
- }
1315
- }, Xn = async (e) => new Promise((t) => {
1316
- try {
1317
- const n = new window.OfflineAudioContext(1, 5e3, 44100), r = n.createBufferSource(), a = n.createOscillator();
1318
- a.frequency.value = 1e3;
1319
- const s = n.createDynamicsCompressor();
1320
- s.threshold.value = -50, s.knee.value = 40, s.ratio.value = 12, s.attack.value = 0, s.release.value = 0.2, a.connect(s), s.connect(n.destination), a.start(), n.startRendering(), n.oncomplete = (o) => {
1321
- const i = o.renderedBuffer.getChannelData(0);
1322
- a.disconnect(), s.disconnect(), t({
1323
- audio: {
1324
- sampleHash: qn(i),
1325
- oscillator: a.type,
1326
- maxChannels: n.destination.maxChannelCount,
1327
- channelCountMode: r.channelCountMode
1328
- }
1329
- });
1330
- };
1331
- } catch {
1332
- t({
1333
- audio: {
1334
- sampleHash: "",
1335
- oscillator: "",
1336
- maxChannels: 0,
1337
- channelCountMode: ""
1338
- }
1339
- });
1340
- }
1341
- }), ht = { browser: "" }, Zn = async (e) => typeof navigator > "u" ? ht : { browser: navigator.userAgent }, pt = {
1342
- canvas: {
1343
- data: ""
1344
- }
1345
- }, er = async (e) => {
1346
- try {
1347
- const t = Array.from(
1348
- { length: 3 },
1349
- () => tr(300, 30)
1350
- ), n = rr(t, 300, 30);
1351
- return {
1352
- canvas: {
1353
- data: (await dt(n.data.toString())).toString()
1354
- }
1355
- };
1356
- } catch {
1357
- return pt;
1358
- }
1359
- }, tr = (e, t) => {
1360
- const n = document.createElement("canvas"), r = n.getContext("2d");
1361
- if (!r)
1362
- return new ImageData(1, 1);
1363
- n.width = e, n.height = t;
1364
- const a = r.createLinearGradient(0, 0, n.width, n.height);
1365
- a.addColorStop(0, "red"), a.addColorStop(1 / 6, "orange"), a.addColorStop(2 / 6, "yellow"), a.addColorStop(3 / 6, "green"), a.addColorStop(4 / 6, "blue"), a.addColorStop(5 / 6, "indigo"), a.addColorStop(1, "violet"), r.fillStyle = a, r.fillRect(0, 0, n.width, n.height);
1366
- const s = "mmMwWLliI0O&1 - Les sanglots longs des violons de l'automne blessent mon coeur d'une langueur monotone";
1367
- return r.font = "26.321px Arial", r.fillStyle = "black", r.fillText(s, -5, 15), r.fillStyle = "rgba(0, 0, 255, 0.5)", r.fillText(s, -3.3, 17.7), r.beginPath(), r.moveTo(0, 0), r.lineTo(n.width * 2 / 7, n.height), r.strokeStyle = "white", r.lineWidth = 2, r.stroke(), r.getImageData(0, 0, n.width, n.height);
1368
- }, nr = (e) => {
1369
- if (e.length === 0)
1370
- return 0;
1371
- const t = {};
1372
- for (const r of e)
1373
- t[r] = (t[r] || 0) + 1;
1374
- let n = e[0];
1375
- for (const r in t)
1376
- t[r] > t[n] && (n = parseInt(r, 10));
1377
- return n;
1378
- }, rr = (e, t, n) => {
1379
- const r = [];
1380
- for (let o = 0; o < e[0].data.length; o++) {
1381
- const i = [];
1382
- for (let c = 0; c < e.length; c++)
1383
- i.push(e[c].data[o]);
1384
- r.push(nr(i));
1385
- }
1386
- const a = r, s = new Uint8ClampedArray(a);
1387
- return new ImageData(s, t, n);
1388
- }, ar = [], or = "mmMwWLliI0O&1", sr = "48px", L = ["monospace", "sans-serif", "serif"], Ye = [
1389
- "sans-serif-thin",
1390
- "ARNO PRO",
1391
- "Agency FB",
1392
- "Arabic Typesetting",
1393
- "Arial Unicode MS",
1394
- "AvantGarde Bk BT",
1395
- "BankGothic Md BT",
1396
- "Bitstream Vera Sans Mono",
1397
- "Calibri",
1398
- "Century",
1399
- "Century Gothic",
1400
- "Clarendon",
1401
- "EUROSTILE",
1402
- "Franklin Gothic",
1403
- "GOTHAM",
1404
- "Gill Sans",
1405
- "Helvetica Neue",
1406
- "Letter Gothic",
1407
- "Menlo",
1408
- "MS Outlook",
1409
- "MS Reference Specialty",
1410
- "MS UI Gothic",
1411
- "MT Extra",
1412
- "MYRIAD PRO",
1413
- "Marlett",
1414
- "Microsoft Uighur",
1415
- "Minion Pro",
1416
- "Monotype Corsiva",
1417
- "PMingLiU",
1418
- "Pristina",
1419
- "SCRIPTINA",
1420
- "SimHei",
1421
- "Small Fonts",
1422
- "Staccato222 BT",
1423
- "TRAJAN PRO",
1424
- "Univers CE 55 Medium",
1425
- "ZWAdobeF"
1426
- ], ir = async (e) => zn(async (t, { document: n }) => {
1427
- const r = n.body;
1428
- r.style.fontSize = sr;
1429
- const a = n.createElement("div");
1430
- a.style.setProperty("visibility", "hidden", "important");
1431
- const s = {}, o = {}, i = (u) => {
1432
- const m = n.createElement("span"), { style: R } = m;
1433
- return R.position = "absolute", R.top = "0", R.left = "0", R.fontFamily = u, m.textContent = or, a.appendChild(m), m;
1434
- }, c = (u, m) => i(`'${u}',${m}`), y = () => L.map(i), l = () => {
1435
- const u = {};
1436
- for (const m of Ye)
1437
- u[m] = L.map(
1438
- (R) => c(m, R)
1439
- );
1440
- return u;
1441
- }, h = (u) => L.some(
1442
- (m, R) => u[R].offsetWidth !== s[m] || u[R].offsetHeight !== o[m]
1443
- ), g = y(), f = l();
1444
- r.appendChild(a);
1445
- for (let u = 0; u < L.length; u++)
1446
- s[L[u]] = g[u].offsetWidth, o[L[u]] = g[u].offsetHeight;
1447
- return Ye.filter((u) => h(f[u]));
1448
- }), ft = {
1449
- vendor: "",
1450
- vendorUnmasked: "",
1451
- renderer: "",
1452
- rendererUnmasked: "",
1453
- version: "",
1454
- shadingLanguageVersion: ""
1455
- }, yt = {
1456
- hardware: {
1457
- videocard: ft,
1458
- architecture: 0,
1459
- deviceMemory: "undefined",
1460
- jsHeapSizeLimit: 0
1461
- }
1462
- };
1463
- function cr() {
1464
- const e = document.createElement("canvas"), t = e.getContext("webgl") ?? e.getContext("experimental-webgl");
1465
- if (t && "getParameter" in t) {
1466
- const n = t.getExtension("WEBGL_debug_renderer_info");
1467
- return {
1468
- vendor: (t.getParameter(t.VENDOR) || "").toString(),
1469
- vendorUnmasked: n ? (t.getParameter(n.UNMASKED_VENDOR_WEBGL) || "").toString() : "",
1470
- renderer: (t.getParameter(t.RENDERER) || "").toString(),
1471
- rendererUnmasked: n ? (t.getParameter(n.UNMASKED_RENDERER_WEBGL) || "").toString() : "",
1472
- version: (t.getParameter(t.VERSION) || "").toString(),
1473
- shadingLanguageVersion: (t.getParameter(t.SHADING_LANGUAGE_VERSION) || "").toString()
1474
- };
1475
- }
1476
- return ft;
1477
- }
1478
- function ur() {
1479
- const e = new Float32Array(1), t = new Uint8Array(e.buffer);
1480
- return e[0] = 1 / 0, e[0] = e[0] - e[0], t[3];
1481
- }
1482
- const lr = () => navigator.deviceMemory || 0, dr = () => window.performance && window.performance.memory || {
1483
- jsHeapSizeLimit: 0
1484
- }, hr = async (e) => new Promise((t) => {
1485
- try {
1486
- const n = lr(), r = dr();
1487
- t({
1488
- hardware: {
1489
- videocard: cr(),
1490
- architecture: ur(),
1491
- deviceMemory: n.toString() || "undefined",
1492
- jsHeapSizeLimit: r.jsHeapSizeLimit || 0
1493
- }
1494
- });
1495
- } catch {
1496
- t(yt);
1497
- }
1498
- }), pr = {
1499
- locales: {
1500
- languages: "",
1501
- timezone: ""
1502
- }
1503
- }, fr = async (e) => new Promise((t) => {
1504
- t({
1505
- locales: {
1506
- languages: navigator.language,
1507
- timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
1508
- }
1509
- });
1510
- }), gt = {
1511
- screen: {
1512
- colorDepth: 0,
1513
- pixelDepth: 0,
1514
- isTouchScreen: !1,
1515
- maxTouchPoints: 0,
1516
- mediaMatches: []
1517
- }
1518
- }, yr = async (e) => new Promise((t) => {
1519
- try {
1520
- const n = window.screen, r = {
1521
- screen: {
1522
- colorDepth: n.colorDepth,
1523
- pixelDepth: n.pixelDepth,
1524
- isTouchScreen: navigator.maxTouchPoints > 0,
1525
- maxTouchPoints: navigator.maxTouchPoints,
1526
- mediaMatches: gr()
1527
- }
1528
- };
1529
- t(r);
1530
- } catch {
1531
- t(gt);
1532
- }
1533
- });
1534
- function gr() {
1535
- const e = [], t = {
1536
- "prefers-contrast": [
1537
- "high",
1538
- "more",
1539
- "low",
1540
- "less",
1541
- "forced",
1542
- "no-preference"
1543
- ],
1544
- "any-hover": ["hover", "none"],
1545
- "any-pointer": ["none", "coarse", "fine"],
1546
- pointer: ["none", "coarse", "fine"],
1547
- hover: ["hover", "none"],
1548
- update: ["fast", "slow"],
1549
- "inverted-colors": ["inverted", "none"],
1550
- "prefers-reduced-motion": ["reduce", "no-preference"],
1551
- "prefers-reduced-transparency": ["reduce", "no-preference"],
1552
- scripting: ["none", "initial-only", "enabled"],
1553
- "forced-colors": ["active", "none"],
1554
- "color-gamut": ["srgb", "p3", "rec2020"]
1555
- };
1556
- return Object.keys(t).forEach((n) => {
1557
- t[n].forEach((r) => {
1558
- matchMedia(`(${n}: ${r})`).matches && e.push(`${n}: ${r}`);
1559
- });
1560
- }), e;
1561
- }
1562
- const mr = async (e) => {
1563
- try {
1564
- return {
1565
- system: {
1566
- platform: navigator.platform,
1567
- cookieEnabled: navigator.cookieEnabled,
1568
- productSub: navigator.productSub,
1569
- product: navigator.product
1570
- }
1571
- };
1572
- } catch {
1573
- return mt;
1574
- }
1575
- }, mt = {
1576
- system: {
1577
- platform: "",
1578
- cookieEnabled: !1,
1579
- productSub: "",
1580
- product: ""
1581
- }
1582
- }, Er = async (e) => {
1583
- try {
1584
- return Promise.all([
1585
- Xn(e),
1586
- Zn(),
1587
- er(e),
1588
- ir(),
1589
- hr(e),
1590
- fr(),
1591
- yr(e),
1592
- mr(e)
1593
- ]);
1594
- } catch {
1595
- return [
1596
- Qn,
1597
- ht,
1598
- pt,
1599
- ar,
1600
- yt,
1601
- pr,
1602
- gt,
1603
- mt
1604
- ];
1605
- }
1606
- }, wr = async (e) => {
1607
- try {
1608
- const t = await Er(e);
1609
- return await dt(JSON.stringify(t));
1610
- } catch {
1611
- return "";
1612
- }
1613
- }, W = {
1262
+ }, K = {
1614
1263
  GET_REGISTRATION_OPTIONS: {
1615
- schema: se.GET_REGISTRATION_OPTIONS,
1264
+ schema: Z.GET_REGISTRATION_OPTIONS,
1616
1265
  method: "getPasskeyRegistrationOptions"
1617
1266
  },
1618
1267
  VERIFY_REGISTRATION: {
1619
- schema: se.VERIFY_REGISTRATION,
1268
+ schema: Z.VERIFY_REGISTRATION,
1620
1269
  method: "verifyPasskeyRegistration"
1621
1270
  },
1622
1271
  GET_AUTHENTICATION_OPTIONS: {
1623
- schema: se.GET_AUTHENTICATION_OPTIONS,
1272
+ schema: Z.GET_AUTHENTICATION_OPTIONS,
1624
1273
  method: "getPasskeyAuthenticationOptions"
1625
1274
  },
1626
1275
  VERIFY_AUTHENTICATION: {
1627
- schema: se.VERIFY_AUTHENTICATION,
1276
+ schema: Z.VERIFY_AUTHENTICATION,
1628
1277
  method: "verifyPasskeyAuthentication"
1629
1278
  }
1630
- }, x = async ({
1279
+ }, $ = async ({
1631
1280
  accessToken: e,
1632
1281
  type: t,
1633
- clientId: n,
1634
- params: r = {}
1282
+ clientId: r,
1283
+ params: n = {}
1635
1284
  }) => {
1636
1285
  try {
1637
- const a = r, s = `Bearer ${e}`, o = await fetch(
1638
- Et ? `${de.dev}/graphql` : `${de.prod}/graphql`,
1286
+ const a = `Bearer ${e}`, o = await fetch(
1287
+ at ? `${se.dev}/graphql` : `${se.prod}/graphql`,
1639
1288
  {
1640
- credentials: ct,
1641
- method: ut,
1289
+ credentials: tt,
1290
+ method: rt,
1642
1291
  headers: {
1643
- authorization: s,
1644
- "Content-Type": lt,
1645
- [ze.CLIENT_ID]: `${n}`
1292
+ authorization: a,
1293
+ "Content-Type": nt,
1294
+ [Ge.CLIENT_ID]: `${r}`
1646
1295
  },
1647
1296
  body: JSON.stringify({
1648
1297
  query: t.schema,
1649
- variables: a
1298
+ variables: n
1650
1299
  })
1651
1300
  }
1652
1301
  );
1653
1302
  if (o.status !== 200)
1654
- return { status: C, data: [] };
1655
- const { data: i } = await o.json();
1303
+ return { status: I, data: [] };
1304
+ const { data: s } = await o.json();
1656
1305
  return {
1657
- status: fe,
1658
- data: i[t.method]
1306
+ status: M,
1307
+ data: s[t.method]
1659
1308
  };
1660
1309
  } catch (a) {
1661
- return console.error(a), { status: C, data: [] };
1310
+ return console.error(a), { status: I, data: [] };
1662
1311
  }
1663
- }, ye = async ({
1312
+ }, ue = async ({
1664
1313
  type: e,
1665
1314
  clientId: t,
1666
- params: n = {}
1315
+ params: r = {}
1667
1316
  }) => {
1668
1317
  try {
1669
- const r = await fetch(
1670
- Et ? `${de.dev}/${e}` : `${de.prod}/${e}`,
1318
+ const n = await fetch(
1319
+ at ? `${se.dev}/${e}` : `${se.prod}/${e}`,
1671
1320
  {
1672
- credentials: ct,
1673
- method: ut,
1321
+ credentials: tt,
1322
+ method: rt,
1674
1323
  headers: {
1675
- "Content-Type": lt,
1676
- [ze.CLIENT_ID]: `${t}`
1324
+ "Content-Type": nt,
1325
+ [Ge.CLIENT_ID]: `${t}`
1677
1326
  },
1678
- body: JSON.stringify(n)
1327
+ body: JSON.stringify(r)
1679
1328
  }
1680
1329
  );
1681
- if (r.status !== 200)
1682
- return { status: C, data: [] };
1683
- const { data: a } = await r.json();
1330
+ if (n.status !== 200)
1331
+ return { status: I, data: [] };
1332
+ const { data: a } = await n.json();
1684
1333
  return {
1685
- status: fe,
1334
+ status: M,
1686
1335
  data: a || []
1687
1336
  };
1688
- } catch (r) {
1689
- return console.error(r), { status: C, data: [] };
1337
+ } catch (n) {
1338
+ return console.error(n), { status: I, data: [] };
1690
1339
  }
1691
- }, Sr = process.env.NODE_ENV === "production", Et = !Sr, wt = {
1340
+ }, Ur = process.env.NODE_ENV === "production", at = !Ur, st = {
1692
1341
  isLoading: !0,
1693
1342
  isAuthenticated: !1,
1694
- authenticationType: null,
1695
1343
  user: void 0,
1696
1344
  logoutReason: "",
1697
1345
  debug: !1
1698
- }, Ar = (e) => {
1346
+ }, Kr = (e) => {
1699
1347
  try {
1700
- const t = On(e);
1701
- return t ? t[T.USER_ID_KEY] : "";
1348
+ const t = gr(e);
1349
+ return t ? t[S.USER_ID_KEY] : "";
1702
1350
  } catch {
1703
1351
  return "";
1704
1352
  }
1705
- }, Tr = async ({
1353
+ }, $r = async ({
1706
1354
  userId: e,
1707
- idToken: t,
1708
- accessToken: n,
1709
- refreshToken: r,
1710
- clientId: a,
1711
- domain: s
1355
+ clientId: t,
1356
+ domain: r
1712
1357
  }) => {
1713
1358
  try {
1714
1359
  return {
1715
- status: (await ye({
1716
- type: he.LOGOUT,
1717
- clientId: a,
1360
+ status: (await ue({
1361
+ type: ie.LOGOUT,
1362
+ clientId: t,
1718
1363
  params: {
1719
1364
  userId: e,
1720
- idToken: t,
1721
- accessToken: n,
1722
- refreshToken: r,
1723
- domain: s
1365
+ domain: r
1724
1366
  }
1725
- }))?.status || C
1367
+ }))?.status || I
1726
1368
  };
1727
1369
  } catch {
1728
1370
  return {
1729
- status: C
1371
+ status: I
1730
1372
  };
1731
1373
  }
1732
- }, Ve = async ({
1374
+ }, Lr = async ({
1733
1375
  username: e,
1734
1376
  password: t,
1735
- clientId: n,
1736
- nonce: r,
1377
+ clientId: r,
1378
+ nonce: n,
1737
1379
  type: a,
1738
- sessionExpiration: s,
1739
- code: o,
1380
+ sessionExpiration: o,
1381
+ code: s,
1740
1382
  code_verifier: i,
1741
1383
  domain: c,
1742
- fingerprint: y
1384
+ ua: h
1743
1385
  }) => {
1744
1386
  try {
1745
- const l = await ye({
1746
- type: he.AUTHENTICATE,
1747
- clientId: n,
1387
+ const f = await ue({
1388
+ type: ie.LOGIN,
1389
+ clientId: r,
1748
1390
  params: {
1749
- type: a || G.ID_AND_ACCESS_TOKEN,
1391
+ type: a || oe.ID_AND_ACCESS_TOKEN,
1750
1392
  username: e,
1751
1393
  password: t,
1752
- sessionExpiration: s,
1753
- nonce: r,
1754
- code: o,
1394
+ sessionExpiration: o,
1395
+ nonce: n,
1396
+ code: s,
1755
1397
  code_verifier: i,
1756
1398
  domain: c,
1757
- fingerprint: y
1399
+ ua: h
1758
1400
  }
1759
- }), h = await J(l?.data?.idToken);
1760
- return h && h.payload[T.USER_ID_KEY] !== "" && h.payload[T.NONCE_KEY] === r ? {
1761
- idToken: l.data.idToken,
1762
- accessToken: l.data.accessToken,
1763
- refreshToken: l.data.refreshToken,
1764
- userId: h.payload[T.USER_ID_KEY],
1401
+ }), p = await H(f?.data?.idToken);
1402
+ return p && p.payload[S.USER_ID_KEY] !== "" && p.payload[S.NONCE_KEY] === n ? {
1403
+ idToken: f.data.idToken,
1404
+ accessToken: f.data.accessToken,
1405
+ refreshToken: f.data.refreshToken,
1406
+ userId: p.payload[S.USER_ID_KEY],
1765
1407
  status: !0
1766
1408
  } : {
1767
1409
  status: !1
@@ -1771,60 +1413,59 @@ const mr = async (e) => {
1771
1413
  status: !1
1772
1414
  };
1773
1415
  }
1774
- }, Rr = async ({
1416
+ }, Hr = async ({
1775
1417
  nonce: e,
1776
1418
  clientId: t,
1777
- code_challenge: n
1419
+ code_challenge: r
1778
1420
  }) => {
1779
1421
  try {
1780
- const r = await ye({
1781
- type: he.CODE,
1422
+ const n = await ue({
1423
+ type: ie.CODE,
1782
1424
  clientId: t,
1783
1425
  params: {
1784
- type: G.CODE,
1426
+ type: oe.CODE,
1785
1427
  nonce: e,
1786
- code_challenge: n
1428
+ code_challenge: r
1787
1429
  }
1788
1430
  });
1789
- return r?.data?.code ? {
1790
- status: fe,
1791
- data: r.data.code
1431
+ return n?.data?.code ? {
1432
+ status: M,
1433
+ data: n.data.code
1792
1434
  } : {
1793
- status: C,
1435
+ status: I,
1794
1436
  data: ""
1795
1437
  };
1796
1438
  } catch {
1797
1439
  return {
1798
- status: C,
1440
+ status: I,
1799
1441
  data: ""
1800
1442
  };
1801
1443
  }
1802
- }, br = async ({
1444
+ }, Wr = async ({
1803
1445
  clientId: e,
1804
1446
  userId: t,
1805
- nonce: n,
1806
- refreshToken: r,
1447
+ nonce: r,
1448
+ refreshToken: n,
1807
1449
  accessToken: a,
1808
- domain: s
1450
+ domain: o
1809
1451
  }) => {
1810
1452
  try {
1811
- const o = await ye({
1812
- type: he.AUTHENTICATE,
1453
+ const s = await ue({
1454
+ type: ie.REFRESH,
1813
1455
  clientId: e,
1814
1456
  params: {
1815
- type: G.REFRESH_TOKEN,
1457
+ type: oe.REFRESH_TOKEN,
1816
1458
  userId: t,
1817
- nonce: n,
1818
- refreshToken: r,
1459
+ nonce: r,
1460
+ refreshToken: n,
1819
1461
  accessToken: a,
1820
- domain: s,
1821
- fingerprint: await St()
1462
+ domain: o
1822
1463
  }
1823
- }), i = await J(o?.data?.accessToken);
1824
- return i && i.payload[T.USER_ID_KEY] !== "" && i.payload[T.NONCE_KEY] === n ? {
1825
- accessToken: o.data.accessToken,
1826
- refreshToken: o.data.refreshToken,
1827
- userId: i.payload[T.USER_ID_KEY],
1464
+ }), i = await H(s?.data?.accessToken);
1465
+ return i && i.payload[S.USER_ID_KEY] !== "" && i.payload[S.NONCE_KEY] === r ? {
1466
+ accessToken: s.data.accessToken,
1467
+ refreshToken: s.data.refreshToken,
1468
+ userId: i.payload[S.USER_ID_KEY],
1828
1469
  status: !0
1829
1470
  } : {
1830
1471
  status: !1
@@ -1834,30 +1475,24 @@ const mr = async (e) => {
1834
1475
  status: !1
1835
1476
  };
1836
1477
  }
1837
- }, St = async () => {
1838
- try {
1839
- return await wr();
1840
- } catch {
1841
- return "";
1842
- }
1843
1478
  };
1844
- class Ir {
1845
- constructor(t = null, n = null) {
1846
- X(this, "refreshTokenPromise", null);
1847
- X(this, "accessToken");
1848
- X(this, "refreshToken");
1849
- this.accessToken = t || "", this.refreshToken = n || "";
1479
+ class xr {
1480
+ constructor(t = null, r = null) {
1481
+ j(this, "refreshTokenPromise", null);
1482
+ j(this, "accessToken");
1483
+ j(this, "refreshToken");
1484
+ this.accessToken = t || "", this.refreshToken = r || "";
1850
1485
  }
1851
1486
  async refreshtoken({
1852
1487
  clientId: t,
1853
- userId: n,
1854
- nonce: r,
1488
+ userId: r,
1489
+ nonce: n,
1855
1490
  domain: a
1856
1491
  }) {
1857
1492
  this.refreshTokenPromise || (this.refreshTokenPromise = this._refreshToken({
1858
1493
  clientId: t,
1859
- userId: n,
1860
- nonce: r,
1494
+ userId: r,
1495
+ nonce: n,
1861
1496
  domain: a
1862
1497
  }));
1863
1498
  try {
@@ -1868,365 +1503,326 @@ class Ir {
1868
1503
  }
1869
1504
  async _refreshToken({
1870
1505
  clientId: t,
1871
- userId: n,
1872
- nonce: r,
1506
+ userId: r,
1507
+ nonce: n,
1873
1508
  domain: a
1874
1509
  }) {
1875
- const s = await J(this.refreshToken);
1876
- if (s && s.payload[T.USER_ID_KEY] !== "") {
1877
- const o = await br({
1510
+ const o = await H(this.refreshToken);
1511
+ if (o && o.payload[S.USER_ID_KEY] !== "") {
1512
+ const s = await Wr({
1878
1513
  clientId: t,
1879
- userId: n,
1880
- nonce: r,
1514
+ userId: r,
1515
+ nonce: n,
1881
1516
  refreshToken: this.refreshToken,
1882
1517
  accessToken: this.accessToken,
1883
1518
  domain: a
1884
1519
  });
1885
- return o.status ? (this.accessToken = o.accessToken, this.refreshToken = o.refreshToken, {
1886
- status: fe,
1887
- newAccessToken: o.accessToken,
1888
- newRefreshToken: o.refreshToken
1520
+ return s.status ? (this.accessToken = s.accessToken, this.refreshToken = s.refreshToken, {
1521
+ status: M,
1522
+ newAccessToken: s.accessToken,
1523
+ newRefreshToken: s.refreshToken
1889
1524
  }) : {
1890
- status: C
1525
+ status: I
1891
1526
  };
1892
1527
  } else
1893
1528
  return {
1894
- status: C
1529
+ status: I
1895
1530
  };
1896
1531
  }
1897
1532
  }
1898
- const _r = (e) => U(
1533
+ const Jr = (e) => N(
1899
1534
  (...t) => {
1900
1535
  e && console.info(`==> [Auth ${Date.now()}]: `, ...t);
1901
1536
  },
1902
1537
  [e]
1903
- ), M = () => {
1904
- throw new Error(Bn);
1905
- }, At = Kt({
1538
+ ), L = () => {
1539
+ throw new Error(Dr);
1540
+ }, ot = At({
1906
1541
  isAuthenticated: !1,
1907
1542
  isLoading: !1,
1908
- authenticationType: null,
1909
- login: M,
1910
- logout: M,
1911
- getAccessToken: M,
1912
- getIdToken: M,
1913
- registeringForPasskey: M,
1914
- loginWithPasskey: M,
1543
+ login: L,
1544
+ logout: L,
1545
+ getAccessToken: L,
1546
+ getIdToken: L,
1547
+ registeringForPasskey: L,
1548
+ loginWithPasskey: L,
1915
1549
  logoutReason: ""
1916
- }), vr = Ut.createContext({
1917
- state: wt,
1550
+ }), Yr = wt.createContext({
1551
+ state: st,
1918
1552
  dispatch: () => {
1919
1553
  }
1920
- }), Cr = (e, t) => t?.type === j ? {
1554
+ }), Gr = (e, t) => t?.type === J ? {
1921
1555
  ...e,
1922
1556
  isLoading: t.payload.isLoading
1923
- } : t?.type === F ? {
1557
+ } : t?.type === te ? {
1924
1558
  ...e,
1925
1559
  isLoading: !1,
1926
1560
  isAuthenticated: !0,
1927
1561
  user: t.payload.user,
1928
- authenticationType: t.payload.authenticationType,
1929
1562
  logoutReason: ""
1930
- } : t?.type === it ? {
1563
+ } : t?.type === et ? {
1931
1564
  ...e,
1932
1565
  isLoading: !1,
1933
1566
  isAuthenticated: !1,
1934
1567
  user: void 0,
1935
- authenticationType: null,
1936
1568
  logoutReason: t.payload.logoutReason
1937
- } : e, Lr = ({
1569
+ } : e, qr = ({
1938
1570
  children: e,
1939
1571
  sessionExpiration: t,
1940
- clientId: n,
1941
- domain: r = "",
1572
+ clientId: r,
1573
+ domain: n = "",
1942
1574
  debug: a = !1
1943
1575
  }) => {
1944
- const [s, o] = Ht(Cr, {
1945
- ...wt,
1576
+ const [o, s] = Tt(Gr, {
1577
+ ...st,
1946
1578
  debug: a
1947
- }), i = _r(a), c = Oe(!1), y = Oe(""), [l, h, , g] = ne({
1948
- key: `${oe}::${n}::@@user@@`
1949
- }), [f, u, , m] = ne({
1950
- key: `${oe}::${n}::@@access@@`
1951
- }), [R, z, , _e] = ne(
1579
+ }), i = Jr(a), c = Rt(!1), [h, f, , p] = z({
1580
+ key: `${X}::${r}::@@user@@`
1581
+ }), [u, A, , T] = z({
1582
+ key: `${X}::${r}::@@access@@`
1583
+ }), [le, de, , Te] = z(
1952
1584
  {
1953
- key: `${oe}::${n}::@@refresh@@`
1585
+ key: `${X}::${r}::@@refresh@@`
1954
1586
  }
1955
- ), [Tt, ve, , Ce] = ne({
1956
- key: `${oe}::${n}::@@nonce@@`
1957
- }), Rt = new Ir(f, R), Q = U(() => {
1958
- i("removeLocalStorage: removing local storage"), g(), m(), _e(), Ce();
1587
+ ), [it, Re, , _e] = z({
1588
+ key: `${X}::${r}::@@nonce@@`
1589
+ }), ct = new xr(u, le), V = N(() => {
1590
+ i("removeLocalStorage: removing local storage"), p(), T(), Te(), _e();
1959
1591
  }, [
1960
- m,
1961
- g,
1962
- Ce,
1592
+ T,
1593
+ p,
1963
1594
  _e,
1595
+ Te,
1964
1596
  i
1965
- ]), K = U(
1966
- (d) => {
1597
+ ]), W = N(
1598
+ (l) => {
1967
1599
  i(
1968
1600
  "removeStateAndLocalStorage: removing state and local storage with reason: ",
1969
- d
1970
- ), o({
1971
- type: it,
1601
+ l
1602
+ ), s({
1603
+ type: et,
1972
1604
  payload: {
1973
- logoutReason: d || H
1605
+ logoutReason: l || U
1974
1606
  }
1975
- }), Q(), o({ type: j, payload: { isLoading: !1 } });
1607
+ }), V(), s({ type: J, payload: { isLoading: !1 } });
1976
1608
  },
1977
- [Q, i]
1978
- ), D = U(
1979
- async (d) => {
1609
+ [V, i]
1610
+ ), P = N(
1611
+ async (l) => {
1980
1612
  i("invalidateAndLogout: invalidating and logging out");
1981
- const { user: E } = s, p = E?.userId || Ar(l);
1982
- p || i(
1613
+ const { user: y } = o, d = y?.userId || Kr(h);
1614
+ d || i(
1983
1615
  "invalidateAndLogout: user cannot be identified, logging out without userId"
1984
- ), await Tr({
1985
- userId: p,
1986
- idToken: l,
1987
- accessToken: f,
1988
- refreshToken: R,
1989
- clientId: n,
1990
- domain: r
1991
- }), K(d || H);
1616
+ ), await $r({
1617
+ userId: d,
1618
+ clientId: r,
1619
+ domain: n
1620
+ }), W(l || U);
1992
1621
  },
1993
- [
1994
- f,
1995
- s,
1996
- n,
1997
- r,
1998
- l,
1999
- R,
2000
- K,
2001
- i
2002
- ]
1622
+ [h, o, r, n, W, i]
2003
1623
  );
2004
- Re(() => ((async () => y.current = await St())(), () => {
2005
- y.current = "";
2006
- }), []), Re(() => {
1624
+ He(() => {
2007
1625
  if (!c.current)
2008
- return s.isLoading && l !== null ? (async () => {
1626
+ return o.isLoading && h !== null ? (async () => {
2009
1627
  try {
2010
- const d = await J(l);
2011
- d && d.payload[T.USER_ID_KEY] !== "" ? (i("useEffect: setting the authentication state"), o({
2012
- type: F,
1628
+ const l = await H(h);
1629
+ l && l.payload[S.USER_ID_KEY] !== "" ? (i("useEffect: setting the authentication state"), s({
1630
+ type: te,
2013
1631
  payload: {
2014
- authenticationType: d.payload[T.AUTH_TYPE_KEY],
2015
1632
  user: {
2016
- userId: d.payload[T.USER_ID_KEY],
2017
- username: d.payload[T.USERNAME_KEY]
1633
+ userId: l.payload[S.USER_ID_KEY],
1634
+ username: l.payload[S.USERNAME_KEY]
2018
1635
  }
2019
1636
  }
2020
- })) : (i("useEffect: invalid JWT, invalidating and logging out"), await D(H));
1637
+ })) : (i("useEffect: invalid JWT, invalidating and logging out"), await P(U));
2021
1638
  } catch {
2022
1639
  i(
2023
1640
  "useEffect: exception validating JWT, invalidating and logging out"
2024
- ), await D(H);
1641
+ ), await P(U);
2025
1642
  }
2026
- })() : (i("useEffect: setting the loading state to false"), o({ type: j, payload: { isLoading: !1 } })), () => {
1643
+ })() : (i("useEffect: setting the loading state to false"), s({ type: J, payload: { isLoading: !1 } })), () => {
2027
1644
  c.current = !0;
2028
1645
  };
2029
- }, [s.isLoading, l, D, i]);
2030
- const bt = async (d, E, p = G.CODE) => {
2031
- o({ type: j, payload: { isLoading: !0 } }), Q();
2032
- const I = Te();
2033
- if (ve(I), i("login: Logging in with type: ", p), p === G.CODE) {
2034
- const { code_verifier: kt, code_challenge: Ot } = await Wn(), Pe = await Rr({
2035
- nonce: I,
2036
- clientId: n,
2037
- code_challenge: Ot
1646
+ }, [o.isLoading, h, P, i]);
1647
+ const ut = async (l, y) => {
1648
+ s({ type: J, payload: { isLoading: !0 } }), V();
1649
+ const d = me();
1650
+ Re(d), i("login: Logging in with password");
1651
+ const C = oe.CODE, { code_verifier: yt, code_challenge: gt } = await _r(), Ie = await Hr({
1652
+ nonce: d,
1653
+ clientId: r,
1654
+ code_challenge: gt
1655
+ });
1656
+ if (Ie.status) {
1657
+ const x = await Lr({
1658
+ username: l,
1659
+ password: y,
1660
+ clientId: r,
1661
+ sessionExpiration: t,
1662
+ nonce: d,
1663
+ type: C,
1664
+ code: Ie.data,
1665
+ code_verifier: yt,
1666
+ domain: n,
1667
+ ua: navigator.userAgent
2038
1668
  });
2039
- if (Pe.status) {
2040
- const V = await Ve({
2041
- username: d,
2042
- password: E,
2043
- clientId: n,
2044
- sessionExpiration: t,
2045
- nonce: I,
2046
- type: p,
2047
- code: Pe.data,
2048
- code_verifier: kt,
2049
- domain: r,
2050
- fingerprint: y.current
2051
- });
2052
- return V.status ? (h(V.idToken), u(V.accessToken), z(V.refreshToken), o({
2053
- type: F,
2054
- payload: {
2055
- authenticationType: p,
2056
- user: {
2057
- userId: V.userId,
2058
- username: d
2059
- }
1669
+ return x.status ? (f(x.idToken), A(x.accessToken), de(x.refreshToken), s({
1670
+ type: te,
1671
+ payload: {
1672
+ user: {
1673
+ userId: x.userId,
1674
+ username: l
2060
1675
  }
2061
- }), !0) : (K(ae), !1);
2062
- }
2063
- return !1;
2064
- }
2065
- const Y = await Ve({
2066
- username: d,
2067
- password: E,
2068
- clientId: n,
2069
- sessionExpiration: t,
2070
- nonce: I,
2071
- type: p,
2072
- domain: r,
2073
- fingerprint: y.current
2074
- });
2075
- return Y.status ? (h(Y.idToken), u(Y.accessToken), z(Y.refreshToken), o({
2076
- type: F,
2077
- payload: {
2078
- authenticationType: p,
2079
- user: {
2080
- userId: Y.userId,
2081
- username: d
2082
1676
  }
2083
- }
2084
- }), !0) : (K(ae), !1);
2085
- }, It = async (d) => {
2086
- d?.preventDefault(), await D(jn);
2087
- }, _t = async () => {
2088
- const { isAuthenticated: d, user: E } = s;
1677
+ }), !0) : (W(we), !1);
1678
+ }
1679
+ return !1;
1680
+ }, lt = async (l) => {
1681
+ l?.preventDefault(), await P(Cr);
1682
+ }, dt = async () => {
1683
+ const { isAuthenticated: l, user: y } = o;
2089
1684
  try {
2090
- if (d && E && E.userId) {
2091
- if (f) {
1685
+ if (l && y && y.userId) {
1686
+ if (u) {
2092
1687
  i("getAccessToken");
2093
- const I = await J(f);
2094
- if (I && I.payload[T.USER_ID_KEY] !== "")
2095
- return f;
1688
+ const C = await H(u);
1689
+ if (C && C.payload[S.USER_ID_KEY] !== "")
1690
+ return u;
2096
1691
  }
2097
1692
  i("getAccessToken: invalid access token, trying to refresh it");
2098
- const p = await Rt.refreshtoken({
2099
- clientId: n,
2100
- userId: E.userId,
2101
- nonce: Tt,
2102
- domain: r
1693
+ const d = await ct.refreshtoken({
1694
+ clientId: r,
1695
+ userId: y.userId,
1696
+ nonce: it,
1697
+ domain: n
2103
1698
  });
2104
- return p.status && p.status === "success" && p.newAccessToken ? (u(p.newAccessToken), z(p.newRefreshToken), p.newAccessToken) : (i(
1699
+ return d.status && d.status === "success" && d.newAccessToken ? (A(d.newAccessToken), de(d.newRefreshToken), d.newAccessToken) : (i(
2105
1700
  "getAccessToken: invalid refresh token, need to re-authenticate"
2106
- ), await D(H), "");
1701
+ ), await P(U), "");
2107
1702
  }
2108
1703
  return i(
2109
1704
  "getAccessToken: user is not authenticated, cannot get access token"
2110
- ), await D(H), "";
1705
+ ), await P(U), "";
2111
1706
  } catch {
2112
1707
  return i(
2113
1708
  "getAccessToken: exception occurred, invalidating and logging out"
2114
- ), await D(Fn), "";
1709
+ ), await P(Nr), "";
2115
1710
  }
2116
- }, vt = () => s.isAuthenticated && l ? l : "", Ct = async () => {
2117
- const { user: d } = s;
2118
- let E = await x({
2119
- accessToken: f,
2120
- clientId: n,
2121
- type: W.GET_REGISTRATION_OPTIONS,
1711
+ }, ht = () => o.isAuthenticated && h ? h : "", pt = async () => {
1712
+ const { user: l } = o;
1713
+ let y = await $({
1714
+ accessToken: u,
1715
+ clientId: r,
1716
+ type: K.GET_REGISTRATION_OPTIONS,
2122
1717
  params: {
2123
- clientId: n,
2124
- id: d?.userId,
2125
- username: d?.username
1718
+ clientId: r,
1719
+ id: l?.userId,
1720
+ username: l?.username
2126
1721
  }
2127
1722
  });
2128
- if (E.status)
1723
+ if (y.status)
2129
1724
  try {
2130
- const p = await Gt(E.data);
2131
- return E = await x({
2132
- accessToken: f,
2133
- clientId: n,
2134
- type: W.VERIFY_REGISTRATION,
1725
+ const d = await Ot(y.data);
1726
+ return y = await $({
1727
+ accessToken: u,
1728
+ clientId: r,
1729
+ type: K.VERIFY_REGISTRATION,
2135
1730
  params: {
2136
- clientId: n,
2137
- id: d?.userId,
2138
- username: d?.username,
2139
- registration: p
1731
+ clientId: r,
1732
+ id: l?.userId,
1733
+ username: l?.username,
1734
+ registration: d
2140
1735
  }
2141
- }), !!(E.status && E.data.length > 0);
1736
+ }), !!(y.status && y.data.length > 0);
2142
1737
  } catch {
2143
- return await x({
2144
- accessToken: f,
2145
- clientId: n,
2146
- type: W.VERIFY_REGISTRATION,
1738
+ return await $({
1739
+ accessToken: u,
1740
+ clientId: r,
1741
+ type: K.VERIFY_REGISTRATION,
2147
1742
  params: {
2148
- clientId: n,
2149
- id: d?.userId,
2150
- username: d?.username,
1743
+ clientId: r,
1744
+ id: l?.userId,
1745
+ username: l?.username,
2151
1746
  registration: {}
2152
1747
  }
2153
1748
  }), !1;
2154
1749
  }
2155
1750
  return !1;
2156
- }, Pt = async () => {
2157
- o({ type: j, payload: { isLoading: !0 } }), Q();
2158
- const d = Te();
2159
- ve(d), i("loginWithPasskey");
2160
- const E = Te();
2161
- let p = await x({
2162
- accessToken: f,
2163
- clientId: n,
2164
- type: W.GET_AUTHENTICATION_OPTIONS,
1751
+ }, ft = async () => {
1752
+ s({ type: J, payload: { isLoading: !0 } }), V();
1753
+ const l = me();
1754
+ Re(l), i("loginWithPasskey");
1755
+ const y = me();
1756
+ let d = await $({
1757
+ accessToken: u,
1758
+ clientId: r,
1759
+ type: K.GET_AUTHENTICATION_OPTIONS,
2165
1760
  params: {
2166
- id: E,
2167
- clientId: n
1761
+ id: y,
1762
+ clientId: r
2168
1763
  }
2169
1764
  });
2170
- if (p.status)
1765
+ if (d.status)
2171
1766
  try {
2172
- const I = await Vt(p.data);
2173
- return p = await x({
2174
- accessToken: f,
2175
- clientId: n,
2176
- type: W.VERIFY_AUTHENTICATION,
1767
+ const C = await Ct(d.data);
1768
+ return d = await $({
1769
+ accessToken: u,
1770
+ clientId: r,
1771
+ type: K.VERIFY_AUTHENTICATION,
2177
1772
  params: {
2178
- clientId: n,
2179
- id: E,
2180
- authentication: I,
2181
- nonce: d,
2182
- domain: r,
2183
- fingerprint: y.current
1773
+ clientId: r,
1774
+ id: y,
1775
+ authentication: C,
1776
+ nonce: l,
1777
+ domain: n,
1778
+ sessionExpiration: t,
1779
+ ua: navigator.userAgent
2184
1780
  }
2185
- }), p.data.status === "success" ? (h(p.data.idToken), u(p.data.accessToken), z(p.data.refreshToken), o({
2186
- type: F,
1781
+ }), d.data.status === M ? (f(d.data.idToken), A(d.data.accessToken), de(d.data.refreshToken), s({
1782
+ type: te,
2187
1783
  payload: {
2188
- authenticationType: G.PASSKEY,
2189
1784
  user: {
2190
- userId: p.data.userId,
2191
- username: p.data.username
1785
+ userId: d.data.userId,
1786
+ username: d.data.username
2192
1787
  }
2193
1788
  }
2194
- }), !0) : (K(ae), !1);
1789
+ }), !0) : (W(we), !1);
2195
1790
  } catch {
2196
- return await x({
2197
- accessToken: f,
2198
- clientId: n,
2199
- type: W.VERIFY_AUTHENTICATION,
1791
+ return await $({
1792
+ accessToken: u,
1793
+ clientId: r,
1794
+ type: K.VERIFY_AUTHENTICATION,
2200
1795
  params: {
2201
- clientId: n,
2202
- id: E,
1796
+ clientId: r,
1797
+ id: y,
2203
1798
  authentication: {},
2204
- nonce: d,
2205
- domain: r
1799
+ nonce: l,
1800
+ domain: n,
1801
+ sessionExpiration: t
2206
1802
  }
2207
- }), K(ae), !1;
1803
+ }), W(we), !1;
2208
1804
  }
2209
1805
  return !1;
2210
1806
  };
2211
- return /* @__PURE__ */ ke(vr.Provider, { value: { state: s, dispatch: o }, children: /* @__PURE__ */ ke(
2212
- At.Provider,
1807
+ return /* @__PURE__ */ be(Yr.Provider, { value: { state: o, dispatch: s }, children: /* @__PURE__ */ be(
1808
+ ot.Provider,
2213
1809
  {
2214
1810
  value: {
2215
- ...s,
2216
- login: bt,
2217
- logout: It,
2218
- getAccessToken: _t,
2219
- getIdToken: vt,
2220
- registeringForPasskey: Ct,
2221
- loginWithPasskey: Pt
1811
+ ...o,
1812
+ login: ut,
1813
+ logout: lt,
1814
+ getAccessToken: dt,
1815
+ getIdToken: ht,
1816
+ registeringForPasskey: pt,
1817
+ loginWithPasskey: ft
2222
1818
  },
2223
1819
  children: e
2224
1820
  }
2225
1821
  ) });
2226
- }, Wr = (e = At) => Lt(e);
1822
+ }, zr = (e = ot) => _t(e);
2227
1823
  export {
2228
- G as AUTH_TYPES,
2229
- Lr as AuthProvider,
2230
- Hr as isGranted,
2231
- Wr as useAuth
1824
+ oe as AUTH_TYPES,
1825
+ qr as AuthProvider,
1826
+ Br as isGranted,
1827
+ zr as useAuth
2232
1828
  };