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