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