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