@versini/auth-provider 7.4.2 → 7.5.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 +2 -1
- package/dist/index.js +621 -597
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { jsx as
|
|
5
|
-
import
|
|
1
|
+
var St = Object.defineProperty;
|
|
2
|
+
var At = (e, t, r) => t in e ? St(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var Z = (e, t, r) => At(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { jsx as ke } from "react/jsx-runtime";
|
|
5
|
+
import Tt, { useSyncExternalStore as Rt, useCallback as D, useEffect as $e, createContext as _t, useReducer as It, useRef as bt, useContext as kt } from "react";
|
|
6
6
|
/*!
|
|
7
|
-
@versini/auth-provider v7.
|
|
7
|
+
@versini/auth-provider v7.5.0
|
|
8
8
|
© 2025 gizmette.com
|
|
9
9
|
*/
|
|
10
10
|
try {
|
|
11
11
|
window.__VERSINI_AUTH_CLIENT__ || (window.__VERSINI_AUTH_CLIENT__ = {
|
|
12
|
-
version: "7.
|
|
13
|
-
buildTime: "02/09/2025
|
|
12
|
+
version: "7.5.0",
|
|
13
|
+
buildTime: "02/09/2025 07:44 PM EST",
|
|
14
14
|
homepage: "https://github.com/aversini/auth-client",
|
|
15
15
|
license: "MIT"
|
|
16
16
|
});
|
|
@@ -23,101 +23,101 @@ function k(e) {
|
|
|
23
23
|
r += String.fromCharCode(a);
|
|
24
24
|
return btoa(r).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
const t = e.replace(/-/g, "+").replace(/_/g, "/"), r = (4 - t.length % 4) % 4, n = t.padEnd(t.length + r, "="), a = atob(n),
|
|
26
|
+
function se(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
|
-
|
|
30
|
-
return
|
|
29
|
+
s[i] = a.charCodeAt(i);
|
|
30
|
+
return o;
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function Ae() {
|
|
33
33
|
return window?.PublicKeyCredential !== void 0 && typeof window.PublicKeyCredential == "function";
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function Je(e) {
|
|
36
36
|
const { id: t } = e;
|
|
37
37
|
return {
|
|
38
38
|
...e,
|
|
39
|
-
id:
|
|
39
|
+
id: se(t),
|
|
40
40
|
transports: e.transports
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function Ye(e) {
|
|
44
44
|
return e === "localhost" || /^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e);
|
|
45
45
|
}
|
|
46
|
-
class
|
|
46
|
+
class A extends Error {
|
|
47
47
|
constructor({ message: t, code: r, cause: n, name: a }) {
|
|
48
48
|
super(t, { cause: n }), this.name = a ?? n.name, this.code = r;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
function
|
|
51
|
+
function Ot({ error: e, options: t }) {
|
|
52
52
|
const { publicKey: r } = t;
|
|
53
53
|
if (!r)
|
|
54
54
|
throw Error("options was missing required publicKey property");
|
|
55
55
|
if (e.name === "AbortError") {
|
|
56
56
|
if (t.signal instanceof AbortSignal)
|
|
57
|
-
return new
|
|
57
|
+
return new A({
|
|
58
58
|
message: "Registration ceremony was sent an abort signal",
|
|
59
59
|
code: "ERROR_CEREMONY_ABORTED",
|
|
60
60
|
cause: e
|
|
61
61
|
});
|
|
62
62
|
} else if (e.name === "ConstraintError") {
|
|
63
63
|
if (r.authenticatorSelection?.requireResidentKey === !0)
|
|
64
|
-
return new
|
|
64
|
+
return new A({
|
|
65
65
|
message: "Discoverable credentials were required but no available authenticator supported it",
|
|
66
66
|
code: "ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",
|
|
67
67
|
cause: e
|
|
68
68
|
});
|
|
69
69
|
if (r.authenticatorSelection?.userVerification === "required")
|
|
70
|
-
return new
|
|
70
|
+
return new A({
|
|
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
|
|
77
|
+
return new A({
|
|
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
|
|
83
|
+
return new A({
|
|
84
84
|
message: e.message,
|
|
85
85
|
code: "ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",
|
|
86
86
|
cause: e
|
|
87
87
|
});
|
|
88
88
|
if (e.name === "NotSupportedError")
|
|
89
|
-
return r.pubKeyCredParams.filter((a) => a.type === "public-key").length === 0 ? new
|
|
89
|
+
return r.pubKeyCredParams.filter((a) => a.type === "public-key").length === 0 ? new A({
|
|
90
90
|
message: 'No entry in pubKeyCredParams was of type "public-key"',
|
|
91
91
|
code: "ERROR_MALFORMED_PUBKEYCREDPARAMS",
|
|
92
92
|
cause: e
|
|
93
|
-
}) : new
|
|
93
|
+
}) : new A({
|
|
94
94
|
message: "No available authenticator supported any of the specified pubKeyCredParams algorithms",
|
|
95
95
|
code: "ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",
|
|
96
96
|
cause: e
|
|
97
97
|
});
|
|
98
98
|
if (e.name === "SecurityError") {
|
|
99
99
|
const n = window.location.hostname;
|
|
100
|
-
if (
|
|
100
|
+
if (Ye(n)) {
|
|
101
101
|
if (r.rp.id !== n)
|
|
102
|
-
return new
|
|
102
|
+
return new A({
|
|
103
103
|
message: `The RP ID "${r.rp.id}" is invalid for this domain`,
|
|
104
104
|
code: "ERROR_INVALID_RP_ID",
|
|
105
105
|
cause: e
|
|
106
106
|
});
|
|
107
|
-
} else return new
|
|
107
|
+
} else return new A({
|
|
108
108
|
message: `${window.location.hostname} is an invalid domain`,
|
|
109
109
|
code: "ERROR_INVALID_DOMAIN",
|
|
110
110
|
cause: e
|
|
111
111
|
});
|
|
112
112
|
} else if (e.name === "TypeError") {
|
|
113
113
|
if (r.user.id.byteLength < 1 || r.user.id.byteLength > 64)
|
|
114
|
-
return new
|
|
114
|
+
return new A({
|
|
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
|
|
120
|
+
return new A({
|
|
121
121
|
message: "The authenticator was unable to process the specified options, or could not create a new credential",
|
|
122
122
|
code: "ERROR_AUTHENTICATOR_GENERAL_ERROR",
|
|
123
123
|
cause: e
|
|
@@ -125,7 +125,7 @@ function vt({ error: e, options: t }) {
|
|
|
125
125
|
}
|
|
126
126
|
return e;
|
|
127
127
|
}
|
|
128
|
-
class
|
|
128
|
+
class vt {
|
|
129
129
|
createNewAbortSignal() {
|
|
130
130
|
if (this.controller) {
|
|
131
131
|
const r = new Error("Cancelling existing WebAuthn API call for new one");
|
|
@@ -141,117 +141,117 @@ class Pt {
|
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
-
const
|
|
145
|
-
function
|
|
146
|
-
if (e && !(
|
|
144
|
+
const xe = new vt(), Pt = ["cross-platform", "platform"];
|
|
145
|
+
function Me(e) {
|
|
146
|
+
if (e && !(Pt.indexOf(e) < 0))
|
|
147
147
|
return e;
|
|
148
148
|
}
|
|
149
|
-
async function
|
|
150
|
-
if (!
|
|
149
|
+
async function Ct(e) {
|
|
150
|
+
if (!Ae())
|
|
151
151
|
throw new Error("WebAuthn is not supported in this browser");
|
|
152
152
|
const r = { publicKey: {
|
|
153
153
|
...e,
|
|
154
|
-
challenge:
|
|
154
|
+
challenge: se(e.challenge),
|
|
155
155
|
user: {
|
|
156
156
|
...e.user,
|
|
157
|
-
id:
|
|
157
|
+
id: se(e.user.id)
|
|
158
158
|
},
|
|
159
|
-
excludeCredentials: e.excludeCredentials?.map(
|
|
159
|
+
excludeCredentials: e.excludeCredentials?.map(Je)
|
|
160
160
|
} };
|
|
161
|
-
r.signal =
|
|
161
|
+
r.signal = xe.createNewAbortSignal();
|
|
162
162
|
let n;
|
|
163
163
|
try {
|
|
164
164
|
n = await navigator.credentials.create(r);
|
|
165
|
-
} catch (
|
|
166
|
-
throw
|
|
165
|
+
} catch (d) {
|
|
166
|
+
throw Ot({ error: d, options: r });
|
|
167
167
|
}
|
|
168
168
|
if (!n)
|
|
169
169
|
throw new Error("Registration was not completed");
|
|
170
|
-
const { id: a, rawId:
|
|
170
|
+
const { id: a, rawId: o, response: s, type: i } = n;
|
|
171
171
|
let c;
|
|
172
|
-
typeof
|
|
173
|
-
let h;
|
|
174
|
-
if (typeof o.getPublicKeyAlgorithm == "function")
|
|
175
|
-
try {
|
|
176
|
-
h = o.getPublicKeyAlgorithm();
|
|
177
|
-
} catch (l) {
|
|
178
|
-
ye("getPublicKeyAlgorithm()", l);
|
|
179
|
-
}
|
|
172
|
+
typeof s.getTransports == "function" && (c = s.getTransports());
|
|
180
173
|
let y;
|
|
181
|
-
if (typeof
|
|
174
|
+
if (typeof s.getPublicKeyAlgorithm == "function")
|
|
182
175
|
try {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
ye("getPublicKey()", l);
|
|
176
|
+
y = s.getPublicKeyAlgorithm();
|
|
177
|
+
} catch (d) {
|
|
178
|
+
pe("getPublicKeyAlgorithm()", d);
|
|
187
179
|
}
|
|
188
180
|
let p;
|
|
189
|
-
if (typeof
|
|
181
|
+
if (typeof s.getPublicKey == "function")
|
|
182
|
+
try {
|
|
183
|
+
const d = s.getPublicKey();
|
|
184
|
+
d !== null && (p = k(d));
|
|
185
|
+
} catch (d) {
|
|
186
|
+
pe("getPublicKey()", d);
|
|
187
|
+
}
|
|
188
|
+
let h;
|
|
189
|
+
if (typeof s.getAuthenticatorData == "function")
|
|
190
190
|
try {
|
|
191
|
-
|
|
192
|
-
} catch (
|
|
193
|
-
|
|
191
|
+
h = k(s.getAuthenticatorData());
|
|
192
|
+
} catch (d) {
|
|
193
|
+
pe("getAuthenticatorData()", d);
|
|
194
194
|
}
|
|
195
195
|
return {
|
|
196
196
|
id: a,
|
|
197
|
-
rawId: k(
|
|
197
|
+
rawId: k(o),
|
|
198
198
|
response: {
|
|
199
|
-
attestationObject: k(
|
|
200
|
-
clientDataJSON: k(
|
|
199
|
+
attestationObject: k(s.attestationObject),
|
|
200
|
+
clientDataJSON: k(s.clientDataJSON),
|
|
201
201
|
transports: c,
|
|
202
|
-
publicKeyAlgorithm:
|
|
203
|
-
publicKey:
|
|
204
|
-
authenticatorData:
|
|
202
|
+
publicKeyAlgorithm: y,
|
|
203
|
+
publicKey: p,
|
|
204
|
+
authenticatorData: h
|
|
205
205
|
},
|
|
206
206
|
type: i,
|
|
207
207
|
clientExtensionResults: n.getClientExtensionResults(),
|
|
208
|
-
authenticatorAttachment:
|
|
208
|
+
authenticatorAttachment: Me(n.authenticatorAttachment)
|
|
209
209
|
};
|
|
210
210
|
}
|
|
211
|
-
function
|
|
211
|
+
function pe(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
|
|
216
|
-
if (!
|
|
215
|
+
function Nt() {
|
|
216
|
+
if (!Ae())
|
|
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
|
|
221
|
+
function Kt({ error: e, options: t }) {
|
|
222
222
|
const { publicKey: r } = t;
|
|
223
223
|
if (!r)
|
|
224
224
|
throw Error("options was missing required publicKey property");
|
|
225
225
|
if (e.name === "AbortError") {
|
|
226
226
|
if (t.signal instanceof AbortSignal)
|
|
227
|
-
return new
|
|
227
|
+
return new A({
|
|
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
|
|
234
|
+
return new A({
|
|
235
235
|
message: e.message,
|
|
236
236
|
code: "ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",
|
|
237
237
|
cause: e
|
|
238
238
|
});
|
|
239
239
|
if (e.name === "SecurityError") {
|
|
240
240
|
const n = window.location.hostname;
|
|
241
|
-
if (
|
|
241
|
+
if (Ye(n)) {
|
|
242
242
|
if (r.rpId !== n)
|
|
243
|
-
return new
|
|
243
|
+
return new A({
|
|
244
244
|
message: `The RP ID "${r.rpId}" is invalid for this domain`,
|
|
245
245
|
code: "ERROR_INVALID_RP_ID",
|
|
246
246
|
cause: e
|
|
247
247
|
});
|
|
248
|
-
} else return new
|
|
248
|
+
} else return new A({
|
|
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
|
|
254
|
+
return new A({
|
|
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,46 +259,46 @@ function Dt({ error: e, options: t }) {
|
|
|
259
259
|
}
|
|
260
260
|
return e;
|
|
261
261
|
}
|
|
262
|
-
async function
|
|
263
|
-
if (!
|
|
262
|
+
async function Dt(e, t = !1) {
|
|
263
|
+
if (!Ae())
|
|
264
264
|
throw new Error("WebAuthn is not supported in this browser");
|
|
265
265
|
let r;
|
|
266
|
-
e.allowCredentials?.length !== 0 && (r = e.allowCredentials?.map(
|
|
266
|
+
e.allowCredentials?.length !== 0 && (r = e.allowCredentials?.map(Je));
|
|
267
267
|
const n = {
|
|
268
268
|
...e,
|
|
269
|
-
challenge:
|
|
269
|
+
challenge: se(e.challenge),
|
|
270
270
|
allowCredentials: r
|
|
271
271
|
}, a = {};
|
|
272
272
|
if (t) {
|
|
273
|
-
if (!await
|
|
273
|
+
if (!await Nt())
|
|
274
274
|
throw Error("Browser does not support WebAuthn autofill");
|
|
275
275
|
if (document.querySelectorAll("input[autocomplete$='webauthn']").length < 1)
|
|
276
276
|
throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');
|
|
277
277
|
a.mediation = "conditional", n.allowCredentials = [];
|
|
278
278
|
}
|
|
279
|
-
a.publicKey = n, a.signal =
|
|
280
|
-
let
|
|
279
|
+
a.publicKey = n, a.signal = xe.createNewAbortSignal();
|
|
280
|
+
let o;
|
|
281
281
|
try {
|
|
282
|
-
|
|
283
|
-
} catch (
|
|
284
|
-
throw
|
|
282
|
+
o = await navigator.credentials.get(a);
|
|
283
|
+
} catch (h) {
|
|
284
|
+
throw Kt({ error: h, options: a });
|
|
285
285
|
}
|
|
286
|
-
if (!
|
|
286
|
+
if (!o)
|
|
287
287
|
throw new Error("Authentication was not completed");
|
|
288
|
-
const { id:
|
|
289
|
-
let
|
|
290
|
-
return c.userHandle && (
|
|
291
|
-
id:
|
|
288
|
+
const { id: s, rawId: i, response: c, type: y } = o;
|
|
289
|
+
let p;
|
|
290
|
+
return c.userHandle && (p = k(c.userHandle)), {
|
|
291
|
+
id: s,
|
|
292
292
|
rawId: k(i),
|
|
293
293
|
response: {
|
|
294
294
|
authenticatorData: k(c.authenticatorData),
|
|
295
295
|
clientDataJSON: k(c.clientDataJSON),
|
|
296
296
|
signature: k(c.signature),
|
|
297
|
-
userHandle:
|
|
297
|
+
userHandle: p
|
|
298
298
|
},
|
|
299
|
-
type:
|
|
300
|
-
clientExtensionResults:
|
|
301
|
-
authenticatorAttachment:
|
|
299
|
+
type: y,
|
|
300
|
+
clientExtensionResults: o.getClientExtensionResults(),
|
|
301
|
+
authenticatorAttachment: Me(o.authenticatorAttachment)
|
|
302
302
|
};
|
|
303
303
|
}
|
|
304
304
|
/*!
|
|
@@ -308,7 +308,7 @@ async function Ut(e, t = !1) {
|
|
|
308
308
|
try {
|
|
309
309
|
window.__VERSINI_AUTH_COMMON__ || (window.__VERSINI_AUTH_COMMON__ = {
|
|
310
310
|
version: "4.2.0",
|
|
311
|
-
buildTime: "02/09/2025
|
|
311
|
+
buildTime: "02/09/2025 07:44 PM EST",
|
|
312
312
|
homepage: "https://github.com/aversini/auth-client",
|
|
313
313
|
license: "MIT"
|
|
314
314
|
});
|
|
@@ -321,9 +321,9 @@ const M = {
|
|
|
321
321
|
CODE: "code",
|
|
322
322
|
REFRESH_TOKEN: "refresh_token",
|
|
323
323
|
PASSKEY: "passkey"
|
|
324
|
-
},
|
|
324
|
+
}, Ge = {
|
|
325
325
|
CLIENT_ID: "X-Auth-ClientId"
|
|
326
|
-
},
|
|
326
|
+
}, E = {
|
|
327
327
|
ALG: "RS256",
|
|
328
328
|
USER_ID_KEY: "sub",
|
|
329
329
|
USERNAME_KEY: "username",
|
|
@@ -336,7 +336,7 @@ const M = {
|
|
|
336
336
|
SCOPES_KEY: "scopes",
|
|
337
337
|
CLIENT_ID_KEY: "aud",
|
|
338
338
|
ISSUER: "gizmette.com"
|
|
339
|
-
},
|
|
339
|
+
}, Ut = `-----BEGIN PUBLIC KEY-----
|
|
340
340
|
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsF6i3Jd9fY/3COqCw/m7
|
|
341
341
|
w5PKyTYLGAI2I6SIIdpe6i6DOCbEkmDz7LdVsBqwNtVi8gvWYIj+8ol6rU3qu1v5
|
|
342
342
|
i1Jd45GSK4kzkVdgCmQZbM5ak0KI99q5wsrAIzUd+LRJ2HRvWtr5IYdsIiXaQjle
|
|
@@ -349,9 +349,9 @@ awIDAQAB
|
|
|
349
349
|
LOGOUT: "logout",
|
|
350
350
|
LOGIN: "login",
|
|
351
351
|
REFRESH: "refresh"
|
|
352
|
-
}, le = crypto,
|
|
353
|
-
function
|
|
354
|
-
const t = e.reduce((a, { length:
|
|
352
|
+
}, le = crypto, Ve = (e) => e instanceof CryptoKey, ee = new TextEncoder(), q = new TextDecoder();
|
|
353
|
+
function Lt(...e) {
|
|
354
|
+
const t = e.reduce((a, { length: o }) => a + o, 0), r = new Uint8Array(t);
|
|
355
355
|
let n = 0;
|
|
356
356
|
for (const a of e)
|
|
357
357
|
r.set(a, n), n += a.length;
|
|
@@ -371,107 +371,107 @@ const Wt = (e) => {
|
|
|
371
371
|
throw new TypeError("The input to be decoded is not correctly encoded.");
|
|
372
372
|
}
|
|
373
373
|
};
|
|
374
|
-
let
|
|
374
|
+
let T = class extends Error {
|
|
375
375
|
constructor(t, r) {
|
|
376
376
|
var n;
|
|
377
377
|
super(t, r), this.code = "ERR_JOSE_GENERIC", this.name = this.constructor.name, (n = Error.captureStackTrace) == null || n.call(Error, this, this.constructor);
|
|
378
378
|
}
|
|
379
379
|
};
|
|
380
|
-
|
|
381
|
-
class _ extends
|
|
380
|
+
T.code = "ERR_JOSE_GENERIC";
|
|
381
|
+
class _ extends T {
|
|
382
382
|
constructor(t, r, n = "unspecified", a = "unspecified") {
|
|
383
383
|
super(t, { cause: { claim: n, reason: a, payload: r } }), this.code = "ERR_JWT_CLAIM_VALIDATION_FAILED", this.claim = n, this.reason = a, this.payload = r;
|
|
384
384
|
}
|
|
385
385
|
}
|
|
386
386
|
_.code = "ERR_JWT_CLAIM_VALIDATION_FAILED";
|
|
387
|
-
class
|
|
387
|
+
class we extends T {
|
|
388
388
|
constructor(t, r, n = "unspecified", a = "unspecified") {
|
|
389
389
|
super(t, { cause: { claim: n, reason: a, payload: r } }), this.code = "ERR_JWT_EXPIRED", this.claim = n, this.reason = a, this.payload = r;
|
|
390
390
|
}
|
|
391
391
|
}
|
|
392
|
-
|
|
393
|
-
class
|
|
392
|
+
we.code = "ERR_JWT_EXPIRED";
|
|
393
|
+
class je extends T {
|
|
394
394
|
constructor() {
|
|
395
395
|
super(...arguments), this.code = "ERR_JOSE_ALG_NOT_ALLOWED";
|
|
396
396
|
}
|
|
397
397
|
}
|
|
398
|
-
|
|
399
|
-
class I extends
|
|
398
|
+
je.code = "ERR_JOSE_ALG_NOT_ALLOWED";
|
|
399
|
+
class I extends T {
|
|
400
400
|
constructor() {
|
|
401
401
|
super(...arguments), this.code = "ERR_JOSE_NOT_SUPPORTED";
|
|
402
402
|
}
|
|
403
403
|
}
|
|
404
404
|
I.code = "ERR_JOSE_NOT_SUPPORTED";
|
|
405
|
-
class
|
|
405
|
+
class Ht extends T {
|
|
406
406
|
constructor(t = "decryption operation failed", r) {
|
|
407
407
|
super(t, r), this.code = "ERR_JWE_DECRYPTION_FAILED";
|
|
408
408
|
}
|
|
409
409
|
}
|
|
410
|
-
|
|
411
|
-
class
|
|
410
|
+
Ht.code = "ERR_JWE_DECRYPTION_FAILED";
|
|
411
|
+
class $t extends T {
|
|
412
412
|
constructor() {
|
|
413
413
|
super(...arguments), this.code = "ERR_JWE_INVALID";
|
|
414
414
|
}
|
|
415
415
|
}
|
|
416
|
-
|
|
417
|
-
class
|
|
416
|
+
$t.code = "ERR_JWE_INVALID";
|
|
417
|
+
class g extends T {
|
|
418
418
|
constructor() {
|
|
419
419
|
super(...arguments), this.code = "ERR_JWS_INVALID";
|
|
420
420
|
}
|
|
421
421
|
}
|
|
422
|
-
|
|
423
|
-
let b = class extends
|
|
422
|
+
g.code = "ERR_JWS_INVALID";
|
|
423
|
+
let b = class extends T {
|
|
424
424
|
constructor() {
|
|
425
425
|
super(...arguments), this.code = "ERR_JWT_INVALID";
|
|
426
426
|
}
|
|
427
427
|
};
|
|
428
428
|
b.code = "ERR_JWT_INVALID";
|
|
429
|
-
class
|
|
429
|
+
class Jt extends T {
|
|
430
430
|
constructor() {
|
|
431
431
|
super(...arguments), this.code = "ERR_JWK_INVALID";
|
|
432
432
|
}
|
|
433
433
|
}
|
|
434
|
-
|
|
435
|
-
class
|
|
434
|
+
Jt.code = "ERR_JWK_INVALID";
|
|
435
|
+
class Yt extends T {
|
|
436
436
|
constructor() {
|
|
437
437
|
super(...arguments), this.code = "ERR_JWKS_INVALID";
|
|
438
438
|
}
|
|
439
439
|
}
|
|
440
|
-
|
|
441
|
-
class
|
|
440
|
+
Yt.code = "ERR_JWKS_INVALID";
|
|
441
|
+
class xt extends T {
|
|
442
442
|
constructor(t = "no applicable key found in the JSON Web Key Set", r) {
|
|
443
443
|
super(t, r), this.code = "ERR_JWKS_NO_MATCHING_KEY";
|
|
444
444
|
}
|
|
445
445
|
}
|
|
446
|
-
|
|
447
|
-
class
|
|
446
|
+
xt.code = "ERR_JWKS_NO_MATCHING_KEY";
|
|
447
|
+
class Mt extends T {
|
|
448
448
|
constructor(t = "multiple matching keys found in the JSON Web Key Set", r) {
|
|
449
449
|
super(t, r), this.code = "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
|
|
450
450
|
}
|
|
451
451
|
}
|
|
452
|
-
|
|
453
|
-
class
|
|
452
|
+
Mt.code = "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
|
|
453
|
+
class Gt extends T {
|
|
454
454
|
constructor(t = "request timed out", r) {
|
|
455
455
|
super(t, r), this.code = "ERR_JWKS_TIMEOUT";
|
|
456
456
|
}
|
|
457
457
|
}
|
|
458
|
-
|
|
459
|
-
class
|
|
458
|
+
Gt.code = "ERR_JWKS_TIMEOUT";
|
|
459
|
+
class Fe extends T {
|
|
460
460
|
constructor(t = "signature verification failed", r) {
|
|
461
461
|
super(t, r), this.code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED";
|
|
462
462
|
}
|
|
463
463
|
}
|
|
464
|
-
|
|
464
|
+
Fe.code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED";
|
|
465
465
|
function v(e, t = "algorithm.name") {
|
|
466
466
|
return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`);
|
|
467
467
|
}
|
|
468
|
-
function
|
|
468
|
+
function te(e, t) {
|
|
469
469
|
return e.name === t;
|
|
470
470
|
}
|
|
471
|
-
function
|
|
471
|
+
function ye(e) {
|
|
472
472
|
return parseInt(e.name.slice(4), 10);
|
|
473
473
|
}
|
|
474
|
-
function
|
|
474
|
+
function Vt(e) {
|
|
475
475
|
switch (e) {
|
|
476
476
|
case "ES256":
|
|
477
477
|
return "P-256";
|
|
@@ -483,7 +483,7 @@ function jt(e) {
|
|
|
483
483
|
throw new Error("unreachable");
|
|
484
484
|
}
|
|
485
485
|
}
|
|
486
|
-
function
|
|
486
|
+
function jt(e, t) {
|
|
487
487
|
if (t.length && !t.some((r) => e.usages.includes(r))) {
|
|
488
488
|
let r = "CryptoKey does not support this operation, its usages must include ";
|
|
489
489
|
if (t.length > 2) {
|
|
@@ -493,35 +493,35 @@ function Ft(e, t) {
|
|
|
493
493
|
throw new TypeError(r);
|
|
494
494
|
}
|
|
495
495
|
}
|
|
496
|
-
function
|
|
496
|
+
function Ft(e, t, ...r) {
|
|
497
497
|
switch (t) {
|
|
498
498
|
case "HS256":
|
|
499
499
|
case "HS384":
|
|
500
500
|
case "HS512": {
|
|
501
|
-
if (!
|
|
501
|
+
if (!te(e.algorithm, "HMAC"))
|
|
502
502
|
throw v("HMAC");
|
|
503
503
|
const n = parseInt(t.slice(2), 10);
|
|
504
|
-
if (
|
|
504
|
+
if (ye(e.algorithm.hash) !== n)
|
|
505
505
|
throw v(`SHA-${n}`, "algorithm.hash");
|
|
506
506
|
break;
|
|
507
507
|
}
|
|
508
508
|
case "RS256":
|
|
509
509
|
case "RS384":
|
|
510
510
|
case "RS512": {
|
|
511
|
-
if (!
|
|
511
|
+
if (!te(e.algorithm, "RSASSA-PKCS1-v1_5"))
|
|
512
512
|
throw v("RSASSA-PKCS1-v1_5");
|
|
513
513
|
const n = parseInt(t.slice(2), 10);
|
|
514
|
-
if (
|
|
514
|
+
if (ye(e.algorithm.hash) !== n)
|
|
515
515
|
throw v(`SHA-${n}`, "algorithm.hash");
|
|
516
516
|
break;
|
|
517
517
|
}
|
|
518
518
|
case "PS256":
|
|
519
519
|
case "PS384":
|
|
520
520
|
case "PS512": {
|
|
521
|
-
if (!
|
|
521
|
+
if (!te(e.algorithm, "RSA-PSS"))
|
|
522
522
|
throw v("RSA-PSS");
|
|
523
523
|
const n = parseInt(t.slice(2), 10);
|
|
524
|
-
if (
|
|
524
|
+
if (ye(e.algorithm.hash) !== n)
|
|
525
525
|
throw v(`SHA-${n}`, "algorithm.hash");
|
|
526
526
|
break;
|
|
527
527
|
}
|
|
@@ -533,9 +533,9 @@ function Bt(e, t, ...r) {
|
|
|
533
533
|
case "ES256":
|
|
534
534
|
case "ES384":
|
|
535
535
|
case "ES512": {
|
|
536
|
-
if (!
|
|
536
|
+
if (!te(e.algorithm, "ECDSA"))
|
|
537
537
|
throw v("ECDSA");
|
|
538
|
-
const n =
|
|
538
|
+
const n = Vt(t);
|
|
539
539
|
if (e.algorithm.namedCurve !== n)
|
|
540
540
|
throw v(n, "algorithm.namedCurve");
|
|
541
541
|
break;
|
|
@@ -543,9 +543,9 @@ function Bt(e, t, ...r) {
|
|
|
543
543
|
default:
|
|
544
544
|
throw new TypeError("CryptoKey does not support this operation");
|
|
545
545
|
}
|
|
546
|
-
|
|
546
|
+
jt(e, r);
|
|
547
547
|
}
|
|
548
|
-
function
|
|
548
|
+
function Be(e, t, ...r) {
|
|
549
549
|
var n;
|
|
550
550
|
if (r = r.filter(Boolean), r.length > 2) {
|
|
551
551
|
const a = r.pop();
|
|
@@ -553,11 +553,11 @@ function qe(e, t, ...r) {
|
|
|
553
553
|
} else r.length === 2 ? e += `one of type ${r[0]} or ${r[1]}.` : e += `of type ${r[0]}.`;
|
|
554
554
|
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;
|
|
555
555
|
}
|
|
556
|
-
const
|
|
557
|
-
function
|
|
558
|
-
return
|
|
556
|
+
const Oe = (e, ...t) => Be("Key must be ", e, ...t);
|
|
557
|
+
function qe(e, t, ...r) {
|
|
558
|
+
return Be(`Key for the ${e} algorithm must be `, t, ...r);
|
|
559
559
|
}
|
|
560
|
-
const
|
|
560
|
+
const ze = (e) => Ve(e) ? !0 : e?.[Symbol.toStringTag] === "KeyObject", ie = ["CryptoKey"], Bt = (...e) => {
|
|
561
561
|
const t = e.filter(Boolean);
|
|
562
562
|
if (t.length === 0 || t.length === 1)
|
|
563
563
|
return !0;
|
|
@@ -568,19 +568,19 @@ const Qe = (e) => je(e) ? !0 : e?.[Symbol.toStringTag] === "KeyObject", se = ["C
|
|
|
568
568
|
r = new Set(a);
|
|
569
569
|
continue;
|
|
570
570
|
}
|
|
571
|
-
for (const
|
|
572
|
-
if (r.has(
|
|
571
|
+
for (const o of a) {
|
|
572
|
+
if (r.has(o))
|
|
573
573
|
return !1;
|
|
574
|
-
r.add(
|
|
574
|
+
r.add(o);
|
|
575
575
|
}
|
|
576
576
|
}
|
|
577
577
|
return !0;
|
|
578
578
|
};
|
|
579
|
-
function
|
|
579
|
+
function qt(e) {
|
|
580
580
|
return typeof e == "object" && e !== null;
|
|
581
581
|
}
|
|
582
582
|
function G(e) {
|
|
583
|
-
if (!
|
|
583
|
+
if (!qt(e) || Object.prototype.toString.call(e) !== "[object Object]")
|
|
584
584
|
return !1;
|
|
585
585
|
if (Object.getPrototypeOf(e) === null)
|
|
586
586
|
return !0;
|
|
@@ -589,7 +589,7 @@ function G(e) {
|
|
|
589
589
|
t = Object.getPrototypeOf(t);
|
|
590
590
|
return Object.getPrototypeOf(e) === t;
|
|
591
591
|
}
|
|
592
|
-
const
|
|
592
|
+
const zt = (e, t) => {
|
|
593
593
|
if (e.startsWith("RS") || e.startsWith("PS")) {
|
|
594
594
|
const { modulusLength: r } = t.algorithm;
|
|
595
595
|
if (typeof r != "number" || r < 2048)
|
|
@@ -599,16 +599,16 @@ const Qt = (e, t) => {
|
|
|
599
599
|
function j(e) {
|
|
600
600
|
return G(e) && typeof e.kty == "string";
|
|
601
601
|
}
|
|
602
|
-
function
|
|
602
|
+
function Qt(e) {
|
|
603
603
|
return e.kty !== "oct" && typeof e.d == "string";
|
|
604
604
|
}
|
|
605
|
-
function
|
|
605
|
+
function Xt(e) {
|
|
606
606
|
return e.kty !== "oct" && typeof e.d > "u";
|
|
607
607
|
}
|
|
608
|
-
function
|
|
608
|
+
function Zt(e) {
|
|
609
609
|
return j(e) && e.kty === "oct" && typeof e.k == "string";
|
|
610
610
|
}
|
|
611
|
-
function
|
|
611
|
+
function er(e) {
|
|
612
612
|
let t, r;
|
|
613
613
|
switch (e.kty) {
|
|
614
614
|
case "RSA": {
|
|
@@ -680,43 +680,43 @@ function tr(e) {
|
|
|
680
680
|
}
|
|
681
681
|
return { algorithm: t, keyUsages: r };
|
|
682
682
|
}
|
|
683
|
-
const
|
|
683
|
+
const Qe = async (e) => {
|
|
684
684
|
if (!e.alg)
|
|
685
685
|
throw new TypeError('"alg" argument is required when "jwk.alg" is not present');
|
|
686
|
-
const { algorithm: t, keyUsages: r } =
|
|
686
|
+
const { algorithm: t, keyUsages: r } = er(e), n = [
|
|
687
687
|
t,
|
|
688
688
|
e.ext ?? !1,
|
|
689
689
|
e.key_ops ?? r
|
|
690
690
|
], a = { ...e };
|
|
691
691
|
return delete a.alg, delete a.use, le.subtle.importKey("jwk", a, ...n);
|
|
692
|
-
},
|
|
693
|
-
let L,
|
|
694
|
-
const
|
|
695
|
-
let
|
|
696
|
-
if (
|
|
697
|
-
return
|
|
698
|
-
const
|
|
699
|
-
return a && Object.freeze(t),
|
|
700
|
-
},
|
|
701
|
-
if (
|
|
692
|
+
}, Xe = (e) => C(e);
|
|
693
|
+
let L, W;
|
|
694
|
+
const Ze = (e) => e?.[Symbol.toStringTag] === "KeyObject", ce = async (e, t, r, n, a = !1) => {
|
|
695
|
+
let o = e.get(t);
|
|
696
|
+
if (o != null && o[n])
|
|
697
|
+
return o[n];
|
|
698
|
+
const s = await Qe({ ...r, alg: n });
|
|
699
|
+
return a && Object.freeze(t), o ? o[n] = s : e.set(t, { [n]: s }), s;
|
|
700
|
+
}, tr = (e, t) => {
|
|
701
|
+
if (Ze(e)) {
|
|
702
702
|
let r = e.export({ format: "jwk" });
|
|
703
|
-
return delete r.d, delete r.dp, delete r.dq, delete r.p, delete r.q, delete r.qi, r.k ?
|
|
703
|
+
return delete r.d, delete r.dp, delete r.dq, delete r.p, delete r.q, delete r.qi, r.k ? Xe(r.k) : (W || (W = /* @__PURE__ */ new WeakMap()), ce(W, e, r, t));
|
|
704
704
|
}
|
|
705
|
-
return j(e) ? e.k ? C(e.k) : (
|
|
706
|
-
},
|
|
707
|
-
if (
|
|
705
|
+
return j(e) ? e.k ? C(e.k) : (W || (W = /* @__PURE__ */ new WeakMap()), ce(W, e, e, t, !0)) : e;
|
|
706
|
+
}, rr = (e, t) => {
|
|
707
|
+
if (Ze(e)) {
|
|
708
708
|
let r = e.export({ format: "jwk" });
|
|
709
|
-
return r.k ?
|
|
709
|
+
return r.k ? Xe(r.k) : (L || (L = /* @__PURE__ */ new WeakMap()), ce(L, e, r, t));
|
|
710
710
|
}
|
|
711
|
-
return j(e) ? e.k ? C(e.k) : (L || (L = /* @__PURE__ */ new WeakMap()),
|
|
712
|
-
},
|
|
711
|
+
return j(e) ? e.k ? C(e.k) : (L || (L = /* @__PURE__ */ new WeakMap()), ce(L, e, e, t, !0)) : e;
|
|
712
|
+
}, nr = { normalizePublicKey: tr, normalizePrivateKey: rr }, P = (e, t, r = 0) => {
|
|
713
713
|
r === 0 && (t.unshift(t.length), t.unshift(6));
|
|
714
714
|
const n = e.indexOf(t[0], r);
|
|
715
715
|
if (n === -1)
|
|
716
716
|
return !1;
|
|
717
717
|
const a = e.subarray(n, n + t.length);
|
|
718
|
-
return a.length !== t.length ? !1 : a.every((
|
|
719
|
-
},
|
|
718
|
+
return a.length !== t.length ? !1 : a.every((o, s) => o === t[s]) || P(e, t, n + 1);
|
|
719
|
+
}, ve = (e) => {
|
|
720
720
|
switch (!0) {
|
|
721
721
|
case P(e, [42, 134, 72, 206, 61, 3, 1, 7]):
|
|
722
722
|
return "P-256";
|
|
@@ -735,60 +735,60 @@ const et = (e) => e?.[Symbol.toStringTag] === "KeyObject", ie = async (e, t, r,
|
|
|
735
735
|
default:
|
|
736
736
|
throw new I("Invalid or unsupported EC Key Curve or OKP Key Sub Type");
|
|
737
737
|
}
|
|
738
|
-
},
|
|
739
|
-
let
|
|
738
|
+
}, ar = async (e, t, r, n, a) => {
|
|
739
|
+
let o, s;
|
|
740
740
|
const i = new Uint8Array(atob(r.replace(e, "")).split("").map((c) => c.charCodeAt(0)));
|
|
741
741
|
switch (n) {
|
|
742
742
|
case "PS256":
|
|
743
743
|
case "PS384":
|
|
744
744
|
case "PS512":
|
|
745
|
-
|
|
745
|
+
o = { name: "RSA-PSS", hash: `SHA-${n.slice(-3)}` }, s = ["verify"];
|
|
746
746
|
break;
|
|
747
747
|
case "RS256":
|
|
748
748
|
case "RS384":
|
|
749
749
|
case "RS512":
|
|
750
|
-
|
|
750
|
+
o = { name: "RSASSA-PKCS1-v1_5", hash: `SHA-${n.slice(-3)}` }, s = ["verify"];
|
|
751
751
|
break;
|
|
752
752
|
case "RSA-OAEP":
|
|
753
753
|
case "RSA-OAEP-256":
|
|
754
754
|
case "RSA-OAEP-384":
|
|
755
755
|
case "RSA-OAEP-512":
|
|
756
|
-
|
|
756
|
+
o = {
|
|
757
757
|
name: "RSA-OAEP",
|
|
758
758
|
hash: `SHA-${parseInt(n.slice(-3), 10) || 1}`
|
|
759
|
-
},
|
|
759
|
+
}, s = ["encrypt", "wrapKey"];
|
|
760
760
|
break;
|
|
761
761
|
case "ES256":
|
|
762
|
-
|
|
762
|
+
o = { name: "ECDSA", namedCurve: "P-256" }, s = ["verify"];
|
|
763
763
|
break;
|
|
764
764
|
case "ES384":
|
|
765
|
-
|
|
765
|
+
o = { name: "ECDSA", namedCurve: "P-384" }, s = ["verify"];
|
|
766
766
|
break;
|
|
767
767
|
case "ES512":
|
|
768
|
-
|
|
768
|
+
o = { name: "ECDSA", namedCurve: "P-521" }, s = ["verify"];
|
|
769
769
|
break;
|
|
770
770
|
case "ECDH-ES":
|
|
771
771
|
case "ECDH-ES+A128KW":
|
|
772
772
|
case "ECDH-ES+A192KW":
|
|
773
773
|
case "ECDH-ES+A256KW": {
|
|
774
|
-
const c =
|
|
775
|
-
|
|
774
|
+
const c = ve(i);
|
|
775
|
+
o = c.startsWith("P-") ? { name: "ECDH", namedCurve: c } : { name: c }, s = [];
|
|
776
776
|
break;
|
|
777
777
|
}
|
|
778
778
|
case "EdDSA":
|
|
779
|
-
|
|
779
|
+
o = { name: ve(i) }, s = ["verify"];
|
|
780
780
|
break;
|
|
781
781
|
default:
|
|
782
782
|
throw new I('Invalid or unsupported "alg" (Algorithm) value');
|
|
783
783
|
}
|
|
784
|
-
return le.subtle.importKey(t, i,
|
|
785
|
-
},
|
|
786
|
-
async function
|
|
784
|
+
return le.subtle.importKey(t, i, o, !1, s);
|
|
785
|
+
}, or = (e, t, r) => ar(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g, "spki", e, t);
|
|
786
|
+
async function sr(e, t, r) {
|
|
787
787
|
if (e.indexOf("-----BEGIN PUBLIC KEY-----") !== 0)
|
|
788
788
|
throw new TypeError('"spki" must be SPKI formatted string');
|
|
789
|
-
return
|
|
789
|
+
return or(e, t);
|
|
790
790
|
}
|
|
791
|
-
async function
|
|
791
|
+
async function ir(e, t) {
|
|
792
792
|
if (!G(e))
|
|
793
793
|
throw new TypeError("JWK must be an object");
|
|
794
794
|
switch (t || (t = e.alg), e.kty) {
|
|
@@ -801,12 +801,12 @@ async function cr(e, t) {
|
|
|
801
801
|
throw new I('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');
|
|
802
802
|
case "EC":
|
|
803
803
|
case "OKP":
|
|
804
|
-
return
|
|
804
|
+
return Qe({ ...e, alg: t });
|
|
805
805
|
default:
|
|
806
806
|
throw new I('Unsupported "kty" (Key Type) Parameter value');
|
|
807
807
|
}
|
|
808
808
|
}
|
|
809
|
-
const x = (e) => e?.[Symbol.toStringTag],
|
|
809
|
+
const x = (e) => e?.[Symbol.toStringTag], Se = (e, t, r) => {
|
|
810
810
|
var n, a;
|
|
811
811
|
if (t.use !== void 0 && t.use !== "sig")
|
|
812
812
|
throw new TypeError("Invalid key for this operation, when present its use must be sig");
|
|
@@ -815,32 +815,32 @@ const x = (e) => e?.[Symbol.toStringTag], Ae = (e, t, r) => {
|
|
|
815
815
|
if (t.alg !== void 0 && t.alg !== e)
|
|
816
816
|
throw new TypeError(`Invalid key for this operation, when present its alg must be ${e}`);
|
|
817
817
|
return !0;
|
|
818
|
-
},
|
|
818
|
+
}, cr = (e, t, r, n) => {
|
|
819
819
|
if (!(t instanceof Uint8Array)) {
|
|
820
820
|
if (n && j(t)) {
|
|
821
|
-
if (
|
|
821
|
+
if (Zt(t) && Se(e, t, r))
|
|
822
822
|
return;
|
|
823
823
|
throw new TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present');
|
|
824
824
|
}
|
|
825
|
-
if (!
|
|
826
|
-
throw new TypeError(
|
|
825
|
+
if (!ze(t))
|
|
826
|
+
throw new TypeError(qe(e, t, ...ie, "Uint8Array", n ? "JSON Web Key" : null));
|
|
827
827
|
if (t.type !== "secret")
|
|
828
828
|
throw new TypeError(`${x(t)} instances for symmetric algorithms must be of type "secret"`);
|
|
829
829
|
}
|
|
830
|
-
},
|
|
830
|
+
}, ur = (e, t, r, n) => {
|
|
831
831
|
if (n && j(t))
|
|
832
832
|
switch (r) {
|
|
833
833
|
case "sign":
|
|
834
|
-
if (
|
|
834
|
+
if (Qt(t) && Se(e, t, r))
|
|
835
835
|
return;
|
|
836
836
|
throw new TypeError("JSON Web Key for this operation be a private JWK");
|
|
837
837
|
case "verify":
|
|
838
|
-
if (
|
|
838
|
+
if (Xt(t) && Se(e, t, r))
|
|
839
839
|
return;
|
|
840
840
|
throw new TypeError("JSON Web Key for this operation be a public JWK");
|
|
841
841
|
}
|
|
842
|
-
if (!
|
|
843
|
-
throw new TypeError(
|
|
842
|
+
if (!ze(t))
|
|
843
|
+
throw new TypeError(qe(e, t, ...ie, n ? "JSON Web Key" : null));
|
|
844
844
|
if (t.type === "secret")
|
|
845
845
|
throw new TypeError(`${x(t)} instances for asymmetric algorithms must not be of type "secret"`);
|
|
846
846
|
if (r === "sign" && t.type === "public")
|
|
@@ -852,37 +852,37 @@ const x = (e) => e?.[Symbol.toStringTag], Ae = (e, t, r) => {
|
|
|
852
852
|
if (t.algorithm && r === "encrypt" && t.type === "private")
|
|
853
853
|
throw new TypeError(`${x(t)} instances for asymmetric algorithm encryption must be of type "public"`);
|
|
854
854
|
};
|
|
855
|
-
function
|
|
856
|
-
t.startsWith("HS") || t === "dir" || t.startsWith("PBES2") || /^A\d{3}(?:GCM)?KW$/.test(t) ?
|
|
855
|
+
function et(e, t, r, n) {
|
|
856
|
+
t.startsWith("HS") || t === "dir" || t.startsWith("PBES2") || /^A\d{3}(?:GCM)?KW$/.test(t) ? cr(t, r, n, e) : ur(t, r, n, e);
|
|
857
857
|
}
|
|
858
|
-
|
|
859
|
-
const
|
|
860
|
-
function
|
|
858
|
+
et.bind(void 0, !1);
|
|
859
|
+
const Pe = et.bind(void 0, !0);
|
|
860
|
+
function lr(e, t, r, n, a) {
|
|
861
861
|
if (a.crit !== void 0 && n?.crit === void 0)
|
|
862
862
|
throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');
|
|
863
863
|
if (!n || n.crit === void 0)
|
|
864
864
|
return /* @__PURE__ */ new Set();
|
|
865
|
-
if (!Array.isArray(n.crit) || n.crit.length === 0 || n.crit.some((
|
|
865
|
+
if (!Array.isArray(n.crit) || n.crit.length === 0 || n.crit.some((s) => typeof s != "string" || s.length === 0))
|
|
866
866
|
throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');
|
|
867
|
-
let
|
|
868
|
-
r !== void 0 ?
|
|
869
|
-
for (const
|
|
870
|
-
if (!
|
|
871
|
-
throw new I(`Extension Header Parameter "${
|
|
872
|
-
if (a[
|
|
873
|
-
throw new e(`Extension Header Parameter "${
|
|
874
|
-
if (
|
|
875
|
-
throw new e(`Extension Header Parameter "${
|
|
867
|
+
let o;
|
|
868
|
+
r !== void 0 ? o = new Map([...Object.entries(r), ...t.entries()]) : o = t;
|
|
869
|
+
for (const s of n.crit) {
|
|
870
|
+
if (!o.has(s))
|
|
871
|
+
throw new I(`Extension Header Parameter "${s}" is not recognized`);
|
|
872
|
+
if (a[s] === void 0)
|
|
873
|
+
throw new e(`Extension Header Parameter "${s}" is missing`);
|
|
874
|
+
if (o.get(s) && n[s] === void 0)
|
|
875
|
+
throw new e(`Extension Header Parameter "${s}" MUST be integrity protected`);
|
|
876
876
|
}
|
|
877
877
|
return new Set(n.crit);
|
|
878
878
|
}
|
|
879
|
-
const
|
|
879
|
+
const dr = (e, t) => {
|
|
880
880
|
if (t !== void 0 && (!Array.isArray(t) || t.some((r) => typeof r != "string")))
|
|
881
881
|
throw new TypeError(`"${e}" option must be an array of strings`);
|
|
882
882
|
if (t)
|
|
883
883
|
return new Set(t);
|
|
884
884
|
};
|
|
885
|
-
function
|
|
885
|
+
function hr(e, t) {
|
|
886
886
|
const r = `SHA-${e.slice(-3)}`;
|
|
887
887
|
switch (e) {
|
|
888
888
|
case "HS256":
|
|
@@ -907,100 +907,100 @@ function pr(e, t) {
|
|
|
907
907
|
throw new I(`alg ${e} is not supported either by JOSE or your javascript runtime`);
|
|
908
908
|
}
|
|
909
909
|
}
|
|
910
|
-
async function
|
|
911
|
-
if (t = await
|
|
912
|
-
return
|
|
910
|
+
async function pr(e, t, r) {
|
|
911
|
+
if (t = await nr.normalizePublicKey(t, e), Ve(t))
|
|
912
|
+
return Ft(t, e, r), t;
|
|
913
913
|
if (t instanceof Uint8Array) {
|
|
914
914
|
if (!e.startsWith("HS"))
|
|
915
|
-
throw new TypeError(
|
|
915
|
+
throw new TypeError(Oe(t, ...ie));
|
|
916
916
|
return le.subtle.importKey("raw", t, { hash: `SHA-${e.slice(-3)}`, name: "HMAC" }, !1, [r]);
|
|
917
917
|
}
|
|
918
|
-
throw new TypeError(
|
|
918
|
+
throw new TypeError(Oe(t, ...ie, "Uint8Array", "JSON Web Key"));
|
|
919
919
|
}
|
|
920
|
-
const
|
|
921
|
-
const a = await
|
|
922
|
-
|
|
923
|
-
const
|
|
920
|
+
const yr = async (e, t, r, n) => {
|
|
921
|
+
const a = await pr(e, t, "verify");
|
|
922
|
+
zt(e, a);
|
|
923
|
+
const o = hr(e, a.algorithm);
|
|
924
924
|
try {
|
|
925
|
-
return await le.subtle.verify(
|
|
925
|
+
return await le.subtle.verify(o, a, r, n);
|
|
926
926
|
} catch {
|
|
927
927
|
return !1;
|
|
928
928
|
}
|
|
929
929
|
};
|
|
930
|
-
async function
|
|
930
|
+
async function fr(e, t, r) {
|
|
931
931
|
if (!G(e))
|
|
932
|
-
throw new
|
|
932
|
+
throw new g("Flattened JWS must be an object");
|
|
933
933
|
if (e.protected === void 0 && e.header === void 0)
|
|
934
|
-
throw new
|
|
934
|
+
throw new g('Flattened JWS must have either of the "protected" or "header" members');
|
|
935
935
|
if (e.protected !== void 0 && typeof e.protected != "string")
|
|
936
|
-
throw new
|
|
936
|
+
throw new g("JWS Protected Header incorrect type");
|
|
937
937
|
if (e.payload === void 0)
|
|
938
|
-
throw new
|
|
938
|
+
throw new g("JWS Payload missing");
|
|
939
939
|
if (typeof e.signature != "string")
|
|
940
|
-
throw new
|
|
940
|
+
throw new g("JWS Signature missing or incorrect type");
|
|
941
941
|
if (e.header !== void 0 && !G(e.header))
|
|
942
|
-
throw new
|
|
942
|
+
throw new g("JWS Unprotected Header incorrect type");
|
|
943
943
|
let n = {};
|
|
944
944
|
if (e.protected)
|
|
945
945
|
try {
|
|
946
946
|
const R = C(e.protected);
|
|
947
947
|
n = JSON.parse(q.decode(R));
|
|
948
948
|
} catch {
|
|
949
|
-
throw new
|
|
949
|
+
throw new g("JWS Protected Header is invalid");
|
|
950
950
|
}
|
|
951
|
-
if (!
|
|
952
|
-
throw new
|
|
951
|
+
if (!Bt(n, e.header))
|
|
952
|
+
throw new g("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
|
|
953
953
|
const a = {
|
|
954
954
|
...n,
|
|
955
955
|
...e.header
|
|
956
|
-
},
|
|
957
|
-
let
|
|
958
|
-
if (
|
|
959
|
-
throw new
|
|
956
|
+
}, o = lr(g, /* @__PURE__ */ new Map([["b64", !0]]), r?.crit, n, a);
|
|
957
|
+
let s = !0;
|
|
958
|
+
if (o.has("b64") && (s = n.b64, typeof s != "boolean"))
|
|
959
|
+
throw new g('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
|
|
960
960
|
const { alg: i } = a;
|
|
961
961
|
if (typeof i != "string" || !i)
|
|
962
|
-
throw new
|
|
963
|
-
const c = r &&
|
|
962
|
+
throw new g('JWS "alg" (Algorithm) Header Parameter missing or invalid');
|
|
963
|
+
const c = r && dr("algorithms", r.algorithms);
|
|
964
964
|
if (c && !c.has(i))
|
|
965
|
-
throw new
|
|
966
|
-
if (
|
|
965
|
+
throw new je('"alg" (Algorithm) Header Parameter value not allowed');
|
|
966
|
+
if (s) {
|
|
967
967
|
if (typeof e.payload != "string")
|
|
968
|
-
throw new
|
|
968
|
+
throw new g("JWS Payload must be a string");
|
|
969
969
|
} else if (typeof e.payload != "string" && !(e.payload instanceof Uint8Array))
|
|
970
|
-
throw new
|
|
971
|
-
let
|
|
972
|
-
typeof t == "function" ? (t = await t(n, e),
|
|
973
|
-
const
|
|
974
|
-
let
|
|
970
|
+
throw new g("JWS Payload must be a string or an Uint8Array instance");
|
|
971
|
+
let y = !1;
|
|
972
|
+
typeof t == "function" ? (t = await t(n, e), y = !0, Pe(i, t, "verify"), j(t) && (t = await ir(t, i))) : Pe(i, t, "verify");
|
|
973
|
+
const p = Lt(ee.encode(e.protected ?? ""), ee.encode("."), typeof e.payload == "string" ? ee.encode(e.payload) : e.payload);
|
|
974
|
+
let h;
|
|
975
975
|
try {
|
|
976
|
-
|
|
976
|
+
h = C(e.signature);
|
|
977
977
|
} catch {
|
|
978
|
-
throw new
|
|
978
|
+
throw new g("Failed to base64url decode the signature");
|
|
979
979
|
}
|
|
980
|
-
if (!await
|
|
981
|
-
throw new
|
|
982
|
-
let
|
|
983
|
-
if (
|
|
980
|
+
if (!await yr(i, t, h, p))
|
|
981
|
+
throw new Fe();
|
|
982
|
+
let d;
|
|
983
|
+
if (s)
|
|
984
984
|
try {
|
|
985
|
-
|
|
985
|
+
d = C(e.payload);
|
|
986
986
|
} catch {
|
|
987
|
-
throw new
|
|
987
|
+
throw new g("Failed to base64url decode the payload");
|
|
988
988
|
}
|
|
989
|
-
else typeof e.payload == "string" ?
|
|
990
|
-
const
|
|
991
|
-
return e.protected !== void 0 && (
|
|
989
|
+
else typeof e.payload == "string" ? d = ee.encode(e.payload) : d = e.payload;
|
|
990
|
+
const f = { payload: d };
|
|
991
|
+
return e.protected !== void 0 && (f.protectedHeader = n), e.header !== void 0 && (f.unprotectedHeader = e.header), y ? { ...f, key: t } : f;
|
|
992
992
|
}
|
|
993
|
-
async function
|
|
993
|
+
async function Er(e, t, r) {
|
|
994
994
|
if (e instanceof Uint8Array && (e = q.decode(e)), typeof e != "string")
|
|
995
|
-
throw new
|
|
996
|
-
const { 0: n, 1: a, 2:
|
|
997
|
-
if (
|
|
998
|
-
throw new
|
|
999
|
-
const i = await
|
|
995
|
+
throw new g("Compact JWS must be a string or Uint8Array");
|
|
996
|
+
const { 0: n, 1: a, 2: o, length: s } = e.split(".");
|
|
997
|
+
if (s !== 3)
|
|
998
|
+
throw new g("Invalid Compact JWS");
|
|
999
|
+
const i = await fr({ payload: a, protected: n, signature: o }, t, r), c = { payload: i.payload, protectedHeader: i.protectedHeader };
|
|
1000
1000
|
return typeof t == "function" ? { ...c, key: i.key } : c;
|
|
1001
1001
|
}
|
|
1002
|
-
const
|
|
1003
|
-
const t =
|
|
1002
|
+
const gr = (e) => Math.floor(e.getTime() / 1e3), tt = 60, rt = tt * 60, Te = rt * 24, mr = Te * 7, wr = Te * 365.25, Sr = /^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i, Ce = (e) => {
|
|
1003
|
+
const t = Sr.exec(e);
|
|
1004
1004
|
if (!t || t[4] && t[1])
|
|
1005
1005
|
throw new TypeError("Invalid time period format");
|
|
1006
1006
|
const r = parseFloat(t[2]), n = t[3].toLowerCase();
|
|
@@ -1018,31 +1018,31 @@ const mr = (e) => Math.floor(e.getTime() / 1e3), rt = 60, nt = rt * 60, Re = nt
|
|
|
1018
1018
|
case "min":
|
|
1019
1019
|
case "mins":
|
|
1020
1020
|
case "m":
|
|
1021
|
-
a = Math.round(r *
|
|
1021
|
+
a = Math.round(r * tt);
|
|
1022
1022
|
break;
|
|
1023
1023
|
case "hour":
|
|
1024
1024
|
case "hours":
|
|
1025
1025
|
case "hr":
|
|
1026
1026
|
case "hrs":
|
|
1027
1027
|
case "h":
|
|
1028
|
-
a = Math.round(r *
|
|
1028
|
+
a = Math.round(r * rt);
|
|
1029
1029
|
break;
|
|
1030
1030
|
case "day":
|
|
1031
1031
|
case "days":
|
|
1032
1032
|
case "d":
|
|
1033
|
-
a = Math.round(r *
|
|
1033
|
+
a = Math.round(r * Te);
|
|
1034
1034
|
break;
|
|
1035
1035
|
case "week":
|
|
1036
1036
|
case "weeks":
|
|
1037
1037
|
case "w":
|
|
1038
|
-
a = Math.round(r *
|
|
1038
|
+
a = Math.round(r * mr);
|
|
1039
1039
|
break;
|
|
1040
1040
|
default:
|
|
1041
|
-
a = Math.round(r *
|
|
1041
|
+
a = Math.round(r * wr);
|
|
1042
1042
|
break;
|
|
1043
1043
|
}
|
|
1044
1044
|
return t[1] === "-" || t[4] === "ago" ? -a : a;
|
|
1045
|
-
},
|
|
1045
|
+
}, Ne = (e) => e.toLowerCase().replace(/^application\//, ""), Ar = (e, t) => typeof e == "string" ? t.includes(e) : Array.isArray(e) ? t.some(Set.prototype.has.bind(new Set(e))) : !1, Tr = (e, t, r = {}) => {
|
|
1046
1046
|
let n;
|
|
1047
1047
|
try {
|
|
1048
1048
|
n = JSON.parse(q.decode(t));
|
|
@@ -1051,67 +1051,67 @@ const mr = (e) => Math.floor(e.getTime() / 1e3), rt = 60, nt = rt * 60, Re = nt
|
|
|
1051
1051
|
if (!G(n))
|
|
1052
1052
|
throw new b("JWT Claims Set must be a top-level JSON object");
|
|
1053
1053
|
const { typ: a } = r;
|
|
1054
|
-
if (a && (typeof e.typ != "string" ||
|
|
1054
|
+
if (a && (typeof e.typ != "string" || Ne(e.typ) !== Ne(a)))
|
|
1055
1055
|
throw new _('unexpected "typ" JWT header value', n, "typ", "check_failed");
|
|
1056
|
-
const { requiredClaims:
|
|
1057
|
-
|
|
1058
|
-
for (const R of new Set(
|
|
1056
|
+
const { requiredClaims: o = [], issuer: s, subject: i, audience: c, maxTokenAge: y } = r, p = [...o];
|
|
1057
|
+
y !== void 0 && p.push("iat"), c !== void 0 && p.push("aud"), i !== void 0 && p.push("sub"), s !== void 0 && p.push("iss");
|
|
1058
|
+
for (const R of new Set(p.reverse()))
|
|
1059
1059
|
if (!(R in n))
|
|
1060
1060
|
throw new _(`missing required "${R}" claim`, n, R, "missing");
|
|
1061
|
-
if (
|
|
1061
|
+
if (s && !(Array.isArray(s) ? s : [s]).includes(n.iss))
|
|
1062
1062
|
throw new _('unexpected "iss" claim value', n, "iss", "check_failed");
|
|
1063
1063
|
if (i && n.sub !== i)
|
|
1064
1064
|
throw new _('unexpected "sub" claim value', n, "sub", "check_failed");
|
|
1065
|
-
if (c && !
|
|
1065
|
+
if (c && !Ar(n.aud, typeof c == "string" ? [c] : c))
|
|
1066
1066
|
throw new _('unexpected "aud" claim value', n, "aud", "check_failed");
|
|
1067
|
-
let
|
|
1067
|
+
let h;
|
|
1068
1068
|
switch (typeof r.clockTolerance) {
|
|
1069
1069
|
case "string":
|
|
1070
|
-
|
|
1070
|
+
h = Ce(r.clockTolerance);
|
|
1071
1071
|
break;
|
|
1072
1072
|
case "number":
|
|
1073
|
-
|
|
1073
|
+
h = r.clockTolerance;
|
|
1074
1074
|
break;
|
|
1075
1075
|
case "undefined":
|
|
1076
|
-
|
|
1076
|
+
h = 0;
|
|
1077
1077
|
break;
|
|
1078
1078
|
default:
|
|
1079
1079
|
throw new TypeError("Invalid clockTolerance option type");
|
|
1080
1080
|
}
|
|
1081
|
-
const { currentDate:
|
|
1082
|
-
if ((n.iat !== void 0 ||
|
|
1081
|
+
const { currentDate: d } = r, f = gr(d || /* @__PURE__ */ new Date());
|
|
1082
|
+
if ((n.iat !== void 0 || y) && typeof n.iat != "number")
|
|
1083
1083
|
throw new _('"iat" claim must be a number', n, "iat", "invalid");
|
|
1084
1084
|
if (n.nbf !== void 0) {
|
|
1085
1085
|
if (typeof n.nbf != "number")
|
|
1086
1086
|
throw new _('"nbf" claim must be a number', n, "nbf", "invalid");
|
|
1087
|
-
if (n.nbf >
|
|
1087
|
+
if (n.nbf > f + h)
|
|
1088
1088
|
throw new _('"nbf" claim timestamp check failed', n, "nbf", "check_failed");
|
|
1089
1089
|
}
|
|
1090
1090
|
if (n.exp !== void 0) {
|
|
1091
1091
|
if (typeof n.exp != "number")
|
|
1092
1092
|
throw new _('"exp" claim must be a number', n, "exp", "invalid");
|
|
1093
|
-
if (n.exp <=
|
|
1094
|
-
throw new
|
|
1095
|
-
}
|
|
1096
|
-
if (
|
|
1097
|
-
const R =
|
|
1098
|
-
if (R -
|
|
1099
|
-
throw new
|
|
1100
|
-
if (R < 0 -
|
|
1093
|
+
if (n.exp <= f - h)
|
|
1094
|
+
throw new we('"exp" claim timestamp check failed', n, "exp", "check_failed");
|
|
1095
|
+
}
|
|
1096
|
+
if (y) {
|
|
1097
|
+
const R = f - n.iat, Q = typeof y == "number" ? y : Ce(y);
|
|
1098
|
+
if (R - h > Q)
|
|
1099
|
+
throw new we('"iat" claim timestamp check failed (too far in the past)', n, "iat", "check_failed");
|
|
1100
|
+
if (R < 0 - h)
|
|
1101
1101
|
throw new _('"iat" claim timestamp check failed (it should be in the past)', n, "iat", "check_failed");
|
|
1102
1102
|
}
|
|
1103
1103
|
return n;
|
|
1104
1104
|
};
|
|
1105
|
-
async function
|
|
1105
|
+
async function Rr(e, t, r) {
|
|
1106
1106
|
var n;
|
|
1107
|
-
const a = await
|
|
1107
|
+
const a = await Er(e, t, r);
|
|
1108
1108
|
if ((n = a.protectedHeader.crit) != null && n.includes("b64") && a.protectedHeader.b64 === !1)
|
|
1109
1109
|
throw new b("JWTs MUST NOT use unencoded payload");
|
|
1110
|
-
const
|
|
1111
|
-
return typeof t == "function" ? { ...
|
|
1110
|
+
const o = { payload: Tr(a.protectedHeader, a.payload, r), protectedHeader: a.protectedHeader };
|
|
1111
|
+
return typeof t == "function" ? { ...o, key: a.key } : o;
|
|
1112
1112
|
}
|
|
1113
|
-
const
|
|
1114
|
-
function
|
|
1113
|
+
const _r = C;
|
|
1114
|
+
function Ir(e) {
|
|
1115
1115
|
if (typeof e != "string")
|
|
1116
1116
|
throw new b("JWTs must use Compact JWS serialization, JWT must be a string");
|
|
1117
1117
|
const { 1: t, length: r } = e.split(".");
|
|
@@ -1123,7 +1123,7 @@ function br(e) {
|
|
|
1123
1123
|
throw new b("JWTs must contain a payload");
|
|
1124
1124
|
let n;
|
|
1125
1125
|
try {
|
|
1126
|
-
n =
|
|
1126
|
+
n = _r(t);
|
|
1127
1127
|
} catch {
|
|
1128
1128
|
throw new b("Failed to base64url decode the payload");
|
|
1129
1129
|
}
|
|
@@ -1139,56 +1139,56 @@ function br(e) {
|
|
|
1139
1139
|
}
|
|
1140
1140
|
const V = async (e) => {
|
|
1141
1141
|
try {
|
|
1142
|
-
const t =
|
|
1143
|
-
return await
|
|
1144
|
-
issuer:
|
|
1142
|
+
const t = E.ALG, r = await sr(Ut, t);
|
|
1143
|
+
return await Rr(e, r, {
|
|
1144
|
+
issuer: E.ISSUER
|
|
1145
1145
|
});
|
|
1146
1146
|
} catch {
|
|
1147
1147
|
return;
|
|
1148
1148
|
}
|
|
1149
|
-
},
|
|
1149
|
+
}, br = (e) => {
|
|
1150
1150
|
try {
|
|
1151
|
-
return
|
|
1151
|
+
return Ir(e);
|
|
1152
1152
|
} catch {
|
|
1153
1153
|
return;
|
|
1154
1154
|
}
|
|
1155
|
-
},
|
|
1155
|
+
}, w = [];
|
|
1156
1156
|
for (let e = 0; e < 256; ++e)
|
|
1157
|
-
|
|
1158
|
-
function
|
|
1159
|
-
return (
|
|
1157
|
+
w.push((e + 256).toString(16).slice(1));
|
|
1158
|
+
function kr(e, t = 0) {
|
|
1159
|
+
return (w[e[t + 0]] + w[e[t + 1]] + w[e[t + 2]] + w[e[t + 3]] + "-" + w[e[t + 4]] + w[e[t + 5]] + "-" + w[e[t + 6]] + w[e[t + 7]] + "-" + w[e[t + 8]] + w[e[t + 9]] + "-" + w[e[t + 10]] + w[e[t + 11]] + w[e[t + 12]] + w[e[t + 13]] + w[e[t + 14]] + w[e[t + 15]]).toLowerCase();
|
|
1160
1160
|
}
|
|
1161
|
-
let
|
|
1162
|
-
const
|
|
1163
|
-
function
|
|
1164
|
-
if (!
|
|
1161
|
+
let fe;
|
|
1162
|
+
const Or = new Uint8Array(16);
|
|
1163
|
+
function vr() {
|
|
1164
|
+
if (!fe) {
|
|
1165
1165
|
if (typeof crypto > "u" || !crypto.getRandomValues)
|
|
1166
1166
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
1167
|
-
|
|
1167
|
+
fe = crypto.getRandomValues.bind(crypto);
|
|
1168
1168
|
}
|
|
1169
|
-
return
|
|
1169
|
+
return fe(Or);
|
|
1170
1170
|
}
|
|
1171
|
-
const
|
|
1172
|
-
function
|
|
1173
|
-
if (
|
|
1174
|
-
return
|
|
1171
|
+
const Pr = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Ke = { randomUUID: Pr };
|
|
1172
|
+
function De(e, t, r) {
|
|
1173
|
+
if (Ke.randomUUID && !t && !e)
|
|
1174
|
+
return Ke.randomUUID();
|
|
1175
1175
|
e = e || {};
|
|
1176
|
-
const n = e.random || (e.rng ||
|
|
1177
|
-
return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128,
|
|
1176
|
+
const n = e.random || (e.rng || vr)();
|
|
1177
|
+
return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, kr(n);
|
|
1178
1178
|
}
|
|
1179
|
-
const
|
|
1179
|
+
const Ue = globalThis.crypto, Cr = (e) => `${De()}${De()}`.slice(0, e), Nr = (e) => btoa(
|
|
1180
1180
|
[...new Uint8Array(e)].map((t) => String.fromCharCode(t)).join("")
|
|
1181
1181
|
);
|
|
1182
|
-
async function
|
|
1183
|
-
if (!
|
|
1182
|
+
async function Kr(e) {
|
|
1183
|
+
if (!Ue.subtle)
|
|
1184
1184
|
throw new Error(
|
|
1185
1185
|
"crypto.subtle is available only in secure contexts (HTTPS)."
|
|
1186
1186
|
);
|
|
1187
|
-
const t = new TextEncoder().encode(e), r = await
|
|
1188
|
-
return
|
|
1187
|
+
const t = new TextEncoder().encode(e), r = await Ue.subtle.digest("SHA-256", t);
|
|
1188
|
+
return Nr(r).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
1189
1189
|
}
|
|
1190
|
-
async function
|
|
1191
|
-
const r =
|
|
1190
|
+
async function Dr(e) {
|
|
1191
|
+
const r = Cr(43), n = await Kr(r);
|
|
1192
1192
|
return {
|
|
1193
1193
|
code_verifier: r,
|
|
1194
1194
|
code_challenge: n
|
|
@@ -1197,33 +1197,33 @@ async function Ur(e) {
|
|
|
1197
1197
|
const sn = async (e, t) => {
|
|
1198
1198
|
var r;
|
|
1199
1199
|
const n = await V(e);
|
|
1200
|
-
if (!n || !Array.isArray((r = n.payload) == null ? void 0 : r[
|
|
1200
|
+
if (!n || !Array.isArray((r = n.payload) == null ? void 0 : r[E.SCOPES_KEY]))
|
|
1201
1201
|
return !1;
|
|
1202
|
-
const a = n.payload[
|
|
1203
|
-
return Array.isArray(t) ? t.every((
|
|
1204
|
-
(
|
|
1202
|
+
const a = n.payload[E.SCOPES_KEY];
|
|
1203
|
+
return Array.isArray(t) ? t.every((o) => a.includes(o)) : Object.keys(t).some(
|
|
1204
|
+
(o) => t[o].every((s) => a.includes(s))
|
|
1205
1205
|
);
|
|
1206
1206
|
};
|
|
1207
|
-
function
|
|
1207
|
+
function nt(e, t) {
|
|
1208
1208
|
window.dispatchEvent(new StorageEvent("storage", { key: e, newValue: t }));
|
|
1209
1209
|
}
|
|
1210
|
-
const
|
|
1210
|
+
const Le = (e, t) => {
|
|
1211
1211
|
const r = JSON.stringify(
|
|
1212
1212
|
typeof t == "function" ? t() : t
|
|
1213
1213
|
);
|
|
1214
|
-
window.localStorage.setItem(e, r),
|
|
1215
|
-
},
|
|
1216
|
-
window.localStorage.removeItem(e),
|
|
1217
|
-
}, We = (e) => window.localStorage.getItem(e),
|
|
1218
|
-
function
|
|
1214
|
+
window.localStorage.setItem(e, r), nt(e, r);
|
|
1215
|
+
}, Ur = (e) => {
|
|
1216
|
+
window.localStorage.removeItem(e), nt(e, null);
|
|
1217
|
+
}, We = (e) => window.localStorage.getItem(e), Lr = (e) => (window.addEventListener("storage", e), () => window.removeEventListener("storage", e));
|
|
1218
|
+
function re({
|
|
1219
1219
|
key: e,
|
|
1220
1220
|
initialValue: t
|
|
1221
1221
|
}) {
|
|
1222
|
-
const r =
|
|
1223
|
-
(
|
|
1222
|
+
const r = Rt(Lr, () => We(e)), n = D(
|
|
1223
|
+
(s) => {
|
|
1224
1224
|
try {
|
|
1225
|
-
const i = typeof
|
|
1226
|
-
i == null ?
|
|
1225
|
+
const i = typeof s == "function" ? s(JSON.parse(r)) : s;
|
|
1226
|
+
i == null ? Ur(e) : Le(e, i);
|
|
1227
1227
|
} catch (i) {
|
|
1228
1228
|
console.warn(i);
|
|
1229
1229
|
}
|
|
@@ -1231,42 +1231,42 @@ function te({
|
|
|
1231
1231
|
[e, r]
|
|
1232
1232
|
), a = D(() => {
|
|
1233
1233
|
n(t);
|
|
1234
|
-
}, [t, n]),
|
|
1234
|
+
}, [t, n]), o = D(() => {
|
|
1235
1235
|
n(null);
|
|
1236
1236
|
}, [n]);
|
|
1237
|
-
return
|
|
1237
|
+
return $e(() => {
|
|
1238
1238
|
try {
|
|
1239
|
-
We(e) === null && typeof t < "u" &&
|
|
1240
|
-
} catch (
|
|
1241
|
-
console.warn(
|
|
1239
|
+
We(e) === null && typeof t < "u" && Le(e, t);
|
|
1240
|
+
} catch (s) {
|
|
1241
|
+
console.warn(s);
|
|
1242
1242
|
}
|
|
1243
|
-
}, [e, t]), [r ? JSON.parse(r) : null, n, a,
|
|
1243
|
+
}, [e, t]), [r ? JSON.parse(r) : null, n, a, o];
|
|
1244
1244
|
}
|
|
1245
|
-
const
|
|
1245
|
+
const S = [];
|
|
1246
1246
|
for (let e = 0; e < 256; ++e)
|
|
1247
|
-
|
|
1247
|
+
S.push((e + 256).toString(16).slice(1));
|
|
1248
1248
|
function Wr(e, t = 0) {
|
|
1249
|
-
return (
|
|
1249
|
+
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();
|
|
1250
1250
|
}
|
|
1251
|
-
let
|
|
1252
|
-
const
|
|
1253
|
-
function
|
|
1254
|
-
if (!
|
|
1251
|
+
let Ee;
|
|
1252
|
+
const Hr = new Uint8Array(16);
|
|
1253
|
+
function $r() {
|
|
1254
|
+
if (!Ee) {
|
|
1255
1255
|
if (typeof crypto > "u" || !crypto.getRandomValues)
|
|
1256
1256
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
1257
|
-
|
|
1257
|
+
Ee = crypto.getRandomValues.bind(crypto);
|
|
1258
1258
|
}
|
|
1259
|
-
return
|
|
1259
|
+
return Ee(Hr);
|
|
1260
1260
|
}
|
|
1261
|
-
const
|
|
1262
|
-
function
|
|
1263
|
-
if (
|
|
1264
|
-
return
|
|
1261
|
+
const Jr = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), He = { randomUUID: Jr };
|
|
1262
|
+
function ge(e, t, r) {
|
|
1263
|
+
if (He.randomUUID && !t && !e)
|
|
1264
|
+
return He.randomUUID();
|
|
1265
1265
|
e = e || {};
|
|
1266
|
-
const n = e.random || (e.rng ||
|
|
1266
|
+
const n = e.random || (e.rng || $r)();
|
|
1267
1267
|
return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, Wr(n);
|
|
1268
1268
|
}
|
|
1269
|
-
const
|
|
1269
|
+
const H = "Your session has expired. For your security, please log in again to continue.", Yr = "Your session has been successfully terminated.", me = "Login failed. Please try again.", xr = "Error getting access token, please re-authenticate.", Mr = "You forgot to wrap your component in <AuthProvider>.", ne = "@@auth@@", B = "LOADING", oe = "LOGIN", at = "LOGOUT", z = "success", O = "failure", ot = "include", st = "POST", it = "application/json", ae = {
|
|
1270
1270
|
GET_REGISTRATION_OPTIONS: `mutation GetPasskeyRegistrationOptions(
|
|
1271
1271
|
$clientId: String!,
|
|
1272
1272
|
$username: String!,
|
|
@@ -1349,86 +1349,79 @@ const W = "Your session has expired. For your security, please log in again to c
|
|
|
1349
1349
|
}`
|
|
1350
1350
|
}, $ = {
|
|
1351
1351
|
GET_REGISTRATION_OPTIONS: {
|
|
1352
|
-
schema:
|
|
1352
|
+
schema: ae.GET_REGISTRATION_OPTIONS,
|
|
1353
1353
|
method: "getPasskeyRegistrationOptions"
|
|
1354
1354
|
},
|
|
1355
1355
|
VERIFY_REGISTRATION: {
|
|
1356
|
-
schema:
|
|
1356
|
+
schema: ae.VERIFY_REGISTRATION,
|
|
1357
1357
|
method: "verifyPasskeyRegistration"
|
|
1358
1358
|
},
|
|
1359
1359
|
GET_AUTHENTICATION_OPTIONS: {
|
|
1360
|
-
schema:
|
|
1360
|
+
schema: ae.GET_AUTHENTICATION_OPTIONS,
|
|
1361
1361
|
method: "getPasskeyAuthenticationOptions"
|
|
1362
1362
|
},
|
|
1363
1363
|
VERIFY_AUTHENTICATION: {
|
|
1364
|
-
schema:
|
|
1364
|
+
schema: ae.VERIFY_AUTHENTICATION,
|
|
1365
1365
|
method: "verifyPasskeyAuthentication"
|
|
1366
1366
|
}
|
|
1367
1367
|
}, J = async ({
|
|
1368
1368
|
accessToken: e,
|
|
1369
1369
|
type: t,
|
|
1370
1370
|
clientId: r,
|
|
1371
|
-
params: n = {}
|
|
1371
|
+
params: n = {},
|
|
1372
|
+
endpoint: a
|
|
1372
1373
|
}) => {
|
|
1373
1374
|
try {
|
|
1374
|
-
const
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
})
|
|
1388
|
-
}
|
|
1389
|
-
);
|
|
1375
|
+
const o = `Bearer ${e}`, s = await fetch(`${a}/graphql`, {
|
|
1376
|
+
credentials: ot,
|
|
1377
|
+
method: st,
|
|
1378
|
+
headers: {
|
|
1379
|
+
authorization: o,
|
|
1380
|
+
"Content-Type": it,
|
|
1381
|
+
[Ge.CLIENT_ID]: `${r}`
|
|
1382
|
+
},
|
|
1383
|
+
body: JSON.stringify({
|
|
1384
|
+
query: t.schema,
|
|
1385
|
+
variables: n
|
|
1386
|
+
})
|
|
1387
|
+
});
|
|
1390
1388
|
if (s.status !== 200)
|
|
1391
1389
|
return { status: O, data: [] };
|
|
1392
|
-
const { data:
|
|
1390
|
+
const { data: i } = await s.json();
|
|
1393
1391
|
return {
|
|
1394
1392
|
status: z,
|
|
1395
|
-
data:
|
|
1393
|
+
data: i[t.method]
|
|
1396
1394
|
};
|
|
1397
|
-
} catch (
|
|
1398
|
-
return console.error(
|
|
1395
|
+
} catch (o) {
|
|
1396
|
+
return console.error(o), { status: O, data: [] };
|
|
1399
1397
|
}
|
|
1400
1398
|
}, de = async ({
|
|
1401
1399
|
type: e,
|
|
1402
1400
|
clientId: t,
|
|
1403
|
-
params: r = {}
|
|
1401
|
+
params: r = {},
|
|
1402
|
+
endpoint: n
|
|
1404
1403
|
}) => {
|
|
1405
1404
|
try {
|
|
1406
|
-
const
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
}
|
|
1417
|
-
);
|
|
1418
|
-
if (n.status !== 200)
|
|
1405
|
+
const a = await fetch(`${n}/${e}`, {
|
|
1406
|
+
credentials: ot,
|
|
1407
|
+
method: st,
|
|
1408
|
+
headers: {
|
|
1409
|
+
"Content-Type": it,
|
|
1410
|
+
[Ge.CLIENT_ID]: `${t}`
|
|
1411
|
+
},
|
|
1412
|
+
body: JSON.stringify(r)
|
|
1413
|
+
});
|
|
1414
|
+
if (a.status !== 200)
|
|
1419
1415
|
return { status: O, data: [] };
|
|
1420
|
-
const { data:
|
|
1416
|
+
const { data: o } = await a.json();
|
|
1421
1417
|
return {
|
|
1422
1418
|
status: z,
|
|
1423
|
-
data:
|
|
1419
|
+
data: o || []
|
|
1424
1420
|
};
|
|
1425
|
-
} catch (
|
|
1426
|
-
return console.error(
|
|
1421
|
+
} catch (a) {
|
|
1422
|
+
return console.error(a), { status: O, data: [] };
|
|
1427
1423
|
}
|
|
1428
|
-
},
|
|
1429
|
-
dev: process.env.PUBLIC_AUTH_SERVER_URL || "https://auth.gizmette.local.com:3003",
|
|
1430
|
-
prod: "https://mylogin.gizmette.com/auth"
|
|
1431
|
-
}, lt = {
|
|
1424
|
+
}, Gr = process.env.NODE_ENV === "production", Vr = !Gr, ct = {
|
|
1432
1425
|
isLoading: !0,
|
|
1433
1426
|
isAuthenticated: !1,
|
|
1434
1427
|
user: void 0,
|
|
@@ -1437,8 +1430,8 @@ const W = "Your session has expired. For your security, please log in again to c
|
|
|
1437
1430
|
authenticationType: ""
|
|
1438
1431
|
}, jr = (e) => {
|
|
1439
1432
|
try {
|
|
1440
|
-
const t =
|
|
1441
|
-
return t ? t[
|
|
1433
|
+
const t = br(e);
|
|
1434
|
+
return t ? t[E.USER_ID_KEY] : "";
|
|
1442
1435
|
} catch {
|
|
1443
1436
|
return "";
|
|
1444
1437
|
}
|
|
@@ -1446,11 +1439,13 @@ const W = "Your session has expired. For your security, please log in again to c
|
|
|
1446
1439
|
userId: e,
|
|
1447
1440
|
clientId: t,
|
|
1448
1441
|
domain: r,
|
|
1449
|
-
idToken: n = ""
|
|
1442
|
+
idToken: n = "",
|
|
1443
|
+
endpoint: a
|
|
1450
1444
|
}) => {
|
|
1451
1445
|
try {
|
|
1452
1446
|
return {
|
|
1453
1447
|
status: (await de({
|
|
1448
|
+
endpoint: a,
|
|
1454
1449
|
type: ue.LOGOUT,
|
|
1455
1450
|
clientId: t,
|
|
1456
1451
|
params: {
|
|
@@ -1471,34 +1466,36 @@ const W = "Your session has expired. For your security, please log in again to c
|
|
|
1471
1466
|
clientId: r,
|
|
1472
1467
|
nonce: n,
|
|
1473
1468
|
type: a,
|
|
1474
|
-
sessionExpiration:
|
|
1475
|
-
code:
|
|
1469
|
+
sessionExpiration: o,
|
|
1470
|
+
code: s,
|
|
1476
1471
|
code_verifier: i,
|
|
1477
1472
|
domain: c,
|
|
1478
|
-
ua:
|
|
1473
|
+
ua: y,
|
|
1474
|
+
endpoint: p
|
|
1479
1475
|
}) => {
|
|
1480
1476
|
try {
|
|
1481
|
-
const
|
|
1477
|
+
const h = await de({
|
|
1478
|
+
endpoint: p,
|
|
1482
1479
|
type: ue.LOGIN,
|
|
1483
1480
|
clientId: r,
|
|
1484
1481
|
params: {
|
|
1485
1482
|
type: a || M.ID_AND_ACCESS_TOKEN,
|
|
1486
1483
|
username: e,
|
|
1487
1484
|
password: t,
|
|
1488
|
-
sessionExpiration:
|
|
1485
|
+
sessionExpiration: o,
|
|
1489
1486
|
nonce: n,
|
|
1490
|
-
code:
|
|
1487
|
+
code: s,
|
|
1491
1488
|
code_verifier: i,
|
|
1492
1489
|
domain: c,
|
|
1493
|
-
ua:
|
|
1490
|
+
ua: y
|
|
1494
1491
|
}
|
|
1495
|
-
}),
|
|
1496
|
-
return
|
|
1497
|
-
idToken:
|
|
1498
|
-
accessToken:
|
|
1499
|
-
refreshToken:
|
|
1500
|
-
userId:
|
|
1501
|
-
email:
|
|
1492
|
+
}), d = await V(h?.data?.idToken);
|
|
1493
|
+
return d && d.payload[E.USER_ID_KEY] !== "" && d.payload[E.NONCE_KEY] === n ? {
|
|
1494
|
+
idToken: h.data.idToken,
|
|
1495
|
+
accessToken: h.data.accessToken,
|
|
1496
|
+
refreshToken: h.data.refreshToken,
|
|
1497
|
+
userId: d.payload[E.USER_ID_KEY],
|
|
1498
|
+
email: d.payload[E.EMAIL_KEY],
|
|
1502
1499
|
status: !0
|
|
1503
1500
|
} : {
|
|
1504
1501
|
status: !1
|
|
@@ -1511,10 +1508,12 @@ const W = "Your session has expired. For your security, please log in again to c
|
|
|
1511
1508
|
}, qr = async ({
|
|
1512
1509
|
nonce: e,
|
|
1513
1510
|
clientId: t,
|
|
1514
|
-
code_challenge: r
|
|
1511
|
+
code_challenge: r,
|
|
1512
|
+
endpoint: n
|
|
1515
1513
|
}) => {
|
|
1516
1514
|
try {
|
|
1517
|
-
const
|
|
1515
|
+
const a = await de({
|
|
1516
|
+
endpoint: n,
|
|
1518
1517
|
type: ue.CODE,
|
|
1519
1518
|
clientId: t,
|
|
1520
1519
|
params: {
|
|
@@ -1523,9 +1522,9 @@ const W = "Your session has expired. For your security, please log in again to c
|
|
|
1523
1522
|
code_challenge: r
|
|
1524
1523
|
}
|
|
1525
1524
|
});
|
|
1526
|
-
return
|
|
1525
|
+
return a?.data?.code ? {
|
|
1527
1526
|
status: z,
|
|
1528
|
-
data:
|
|
1527
|
+
data: a.data.code
|
|
1529
1528
|
} : {
|
|
1530
1529
|
status: O,
|
|
1531
1530
|
data: ""
|
|
@@ -1542,10 +1541,12 @@ const W = "Your session has expired. For your security, please log in again to c
|
|
|
1542
1541
|
nonce: r,
|
|
1543
1542
|
refreshToken: n,
|
|
1544
1543
|
accessToken: a,
|
|
1545
|
-
domain:
|
|
1544
|
+
domain: o,
|
|
1545
|
+
endpoint: s
|
|
1546
1546
|
}) => {
|
|
1547
1547
|
try {
|
|
1548
|
-
const
|
|
1548
|
+
const i = await de({
|
|
1549
|
+
endpoint: s,
|
|
1549
1550
|
type: ue.REFRESH,
|
|
1550
1551
|
clientId: e,
|
|
1551
1552
|
params: {
|
|
@@ -1554,13 +1555,13 @@ const W = "Your session has expired. For your security, please log in again to c
|
|
|
1554
1555
|
nonce: r,
|
|
1555
1556
|
refreshToken: n,
|
|
1556
1557
|
accessToken: a,
|
|
1557
|
-
domain:
|
|
1558
|
+
domain: o
|
|
1558
1559
|
}
|
|
1559
|
-
}),
|
|
1560
|
-
return
|
|
1561
|
-
accessToken:
|
|
1562
|
-
refreshToken:
|
|
1563
|
-
userId:
|
|
1560
|
+
}), c = await V(i?.data?.accessToken);
|
|
1561
|
+
return c && c.payload[E.USER_ID_KEY] !== "" && c.payload[E.NONCE_KEY] === r ? {
|
|
1562
|
+
accessToken: i.data.accessToken,
|
|
1563
|
+
refreshToken: i.data.refreshToken,
|
|
1564
|
+
userId: c.payload[E.USER_ID_KEY],
|
|
1564
1565
|
status: !0
|
|
1565
1566
|
} : {
|
|
1566
1567
|
status: !1
|
|
@@ -1573,18 +1574,20 @@ const W = "Your session has expired. For your security, please log in again to c
|
|
|
1573
1574
|
};
|
|
1574
1575
|
class Qr {
|
|
1575
1576
|
constructor(t = null, r = null) {
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1577
|
+
Z(this, "refreshTokenPromise", null);
|
|
1578
|
+
Z(this, "accessToken");
|
|
1579
|
+
Z(this, "refreshToken");
|
|
1579
1580
|
this.accessToken = t || "", this.refreshToken = r || "";
|
|
1580
1581
|
}
|
|
1581
1582
|
async refreshtoken({
|
|
1582
1583
|
clientId: t,
|
|
1583
1584
|
userId: r,
|
|
1584
1585
|
nonce: n,
|
|
1585
|
-
domain: a
|
|
1586
|
+
domain: a,
|
|
1587
|
+
endpoint: o
|
|
1586
1588
|
}) {
|
|
1587
1589
|
this.refreshTokenPromise || (this.refreshTokenPromise = this._refreshToken({
|
|
1590
|
+
endpoint: o,
|
|
1588
1591
|
clientId: t,
|
|
1589
1592
|
userId: r,
|
|
1590
1593
|
nonce: n,
|
|
@@ -1597,25 +1600,27 @@ class Qr {
|
|
|
1597
1600
|
}
|
|
1598
1601
|
}
|
|
1599
1602
|
async _refreshToken({
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1603
|
+
endpoint: t,
|
|
1604
|
+
clientId: r,
|
|
1605
|
+
userId: n,
|
|
1606
|
+
nonce: a,
|
|
1607
|
+
domain: o
|
|
1604
1608
|
}) {
|
|
1605
1609
|
const s = await V(this.refreshToken);
|
|
1606
|
-
if (s && s.payload[
|
|
1607
|
-
const
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1610
|
+
if (s && s.payload[E.USER_ID_KEY] !== "") {
|
|
1611
|
+
const i = await zr({
|
|
1612
|
+
endpoint: t,
|
|
1613
|
+
clientId: r,
|
|
1614
|
+
userId: n,
|
|
1615
|
+
nonce: a,
|
|
1611
1616
|
refreshToken: this.refreshToken,
|
|
1612
1617
|
accessToken: this.accessToken,
|
|
1613
|
-
domain:
|
|
1618
|
+
domain: o
|
|
1614
1619
|
});
|
|
1615
|
-
return
|
|
1620
|
+
return i.status ? (this.accessToken = i.accessToken, this.refreshToken = i.refreshToken, {
|
|
1616
1621
|
status: z,
|
|
1617
|
-
newAccessToken:
|
|
1618
|
-
newRefreshToken:
|
|
1622
|
+
newAccessToken: i.accessToken,
|
|
1623
|
+
newRefreshToken: i.refreshToken
|
|
1619
1624
|
}) : {
|
|
1620
1625
|
status: O
|
|
1621
1626
|
};
|
|
@@ -1631,8 +1636,8 @@ const Xr = (e) => D(
|
|
|
1631
1636
|
},
|
|
1632
1637
|
[e]
|
|
1633
1638
|
), Y = () => {
|
|
1634
|
-
throw new Error(
|
|
1635
|
-
},
|
|
1639
|
+
throw new Error(Mr);
|
|
1640
|
+
}, ut = _t({
|
|
1636
1641
|
isAuthenticated: !1,
|
|
1637
1642
|
isLoading: !1,
|
|
1638
1643
|
login: Y,
|
|
@@ -1643,21 +1648,21 @@ const Xr = (e) => D(
|
|
|
1643
1648
|
loginWithPasskey: Y,
|
|
1644
1649
|
logoutReason: "",
|
|
1645
1650
|
authenticationType: ""
|
|
1646
|
-
}), Zr =
|
|
1647
|
-
state:
|
|
1651
|
+
}), Zr = Tt.createContext({
|
|
1652
|
+
state: ct,
|
|
1648
1653
|
dispatch: () => {
|
|
1649
1654
|
}
|
|
1650
1655
|
}), en = (e, t) => t?.type === B ? {
|
|
1651
1656
|
...e,
|
|
1652
1657
|
isLoading: t.payload.isLoading
|
|
1653
|
-
} : t?.type ===
|
|
1658
|
+
} : t?.type === oe ? {
|
|
1654
1659
|
...e,
|
|
1655
1660
|
isLoading: !1,
|
|
1656
1661
|
isAuthenticated: !0,
|
|
1657
1662
|
user: t.payload.user,
|
|
1658
1663
|
authenticationType: t.payload.authenticationType,
|
|
1659
1664
|
logoutReason: ""
|
|
1660
|
-
} : t?.type ===
|
|
1665
|
+
} : t?.type === at ? {
|
|
1661
1666
|
...e,
|
|
1662
1667
|
isLoading: !1,
|
|
1663
1668
|
isAuthenticated: !1,
|
|
@@ -1669,106 +1674,118 @@ const Xr = (e) => D(
|
|
|
1669
1674
|
sessionExpiration: t,
|
|
1670
1675
|
clientId: r,
|
|
1671
1676
|
domain: n = "",
|
|
1672
|
-
debug: a = !1
|
|
1677
|
+
debug: a = !1,
|
|
1678
|
+
endpoint: o = Vr ? "https://auth.gizmette.local.com:3003" : "https://mylogin.gizmette.com/auth"
|
|
1673
1679
|
}) => {
|
|
1674
|
-
const [s,
|
|
1675
|
-
...
|
|
1680
|
+
const [s, i] = It(en, {
|
|
1681
|
+
...ct,
|
|
1676
1682
|
debug: a
|
|
1677
|
-
}),
|
|
1678
|
-
key: `${
|
|
1679
|
-
}), [
|
|
1680
|
-
key: `${
|
|
1681
|
-
}), [
|
|
1683
|
+
}), c = Xr(a), y = bt(!1), [p, h, , d] = re({
|
|
1684
|
+
key: `${ne}::${r}::@@user@@`
|
|
1685
|
+
}), [f, R, , Q] = re({
|
|
1686
|
+
key: `${ne}::${r}::@@access@@`
|
|
1687
|
+
}), [lt, he, , Re] = re(
|
|
1682
1688
|
{
|
|
1683
|
-
key: `${
|
|
1689
|
+
key: `${ne}::${r}::@@refresh@@`
|
|
1684
1690
|
}
|
|
1685
|
-
), [
|
|
1686
|
-
key: `${
|
|
1687
|
-
}),
|
|
1688
|
-
|
|
1691
|
+
), [dt, _e, , Ie] = re({
|
|
1692
|
+
key: `${ne}::${r}::@@nonce@@`
|
|
1693
|
+
}), ht = new Qr(f, lt), X = D(() => {
|
|
1694
|
+
c("removeLocalStorage: removing local storage"), d(), Q(), Re(), Ie();
|
|
1689
1695
|
}, [
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1696
|
+
Q,
|
|
1697
|
+
d,
|
|
1698
|
+
Ie,
|
|
1699
|
+
Re,
|
|
1700
|
+
c
|
|
1695
1701
|
]), F = D(
|
|
1696
1702
|
(u) => {
|
|
1697
|
-
|
|
1703
|
+
c(
|
|
1698
1704
|
"removeStateAndLocalStorage: removing state and local storage with reason: ",
|
|
1699
1705
|
u
|
|
1700
|
-
),
|
|
1701
|
-
type:
|
|
1706
|
+
), i({
|
|
1707
|
+
type: at,
|
|
1702
1708
|
payload: {
|
|
1703
|
-
logoutReason: u ||
|
|
1709
|
+
logoutReason: u || H
|
|
1704
1710
|
}
|
|
1705
|
-
}),
|
|
1711
|
+
}), X(), i({ type: B, payload: { isLoading: !1 } });
|
|
1706
1712
|
},
|
|
1707
|
-
[
|
|
1713
|
+
[X, c]
|
|
1708
1714
|
), N = D(
|
|
1709
1715
|
async (u) => {
|
|
1710
|
-
|
|
1711
|
-
const { user:
|
|
1712
|
-
|
|
1716
|
+
c("invalidateAndLogout: invalidating and logging out");
|
|
1717
|
+
const { user: m } = s, l = m?.userId || jr(p);
|
|
1718
|
+
l || c(
|
|
1713
1719
|
"invalidateAndLogout: user cannot be identified, logging out without userId"
|
|
1714
1720
|
), await Fr({
|
|
1715
|
-
userId:
|
|
1721
|
+
userId: l,
|
|
1716
1722
|
clientId: r,
|
|
1717
1723
|
domain: n,
|
|
1718
|
-
idToken:
|
|
1719
|
-
|
|
1724
|
+
idToken: p,
|
|
1725
|
+
endpoint: o
|
|
1726
|
+
}), F(u || H);
|
|
1720
1727
|
},
|
|
1721
|
-
[
|
|
1728
|
+
[
|
|
1729
|
+
p,
|
|
1730
|
+
s,
|
|
1731
|
+
r,
|
|
1732
|
+
n,
|
|
1733
|
+
F,
|
|
1734
|
+
c,
|
|
1735
|
+
o
|
|
1736
|
+
]
|
|
1722
1737
|
);
|
|
1723
|
-
|
|
1724
|
-
if (!
|
|
1725
|
-
return s.isLoading &&
|
|
1738
|
+
$e(() => {
|
|
1739
|
+
if (!y.current)
|
|
1740
|
+
return s.isLoading && p !== null ? (async () => {
|
|
1726
1741
|
try {
|
|
1727
|
-
const u = await V(
|
|
1728
|
-
u && u.payload[
|
|
1729
|
-
type:
|
|
1742
|
+
const u = await V(p);
|
|
1743
|
+
u && u.payload[E.USER_ID_KEY] !== "" ? (c("useEffect: setting the authentication state"), i({
|
|
1744
|
+
type: oe,
|
|
1730
1745
|
payload: {
|
|
1731
|
-
authenticationType: u.payload[
|
|
1746
|
+
authenticationType: u.payload[E.AUTH_TYPE_KEY],
|
|
1732
1747
|
user: {
|
|
1733
|
-
userId: u.payload[
|
|
1734
|
-
username: u.payload[
|
|
1735
|
-
email: u.payload[
|
|
1748
|
+
userId: u.payload[E.USER_ID_KEY],
|
|
1749
|
+
username: u.payload[E.USERNAME_KEY],
|
|
1750
|
+
email: u.payload[E.EMAIL_KEY]
|
|
1736
1751
|
}
|
|
1737
1752
|
}
|
|
1738
|
-
})) : (
|
|
1753
|
+
})) : (c("useEffect: invalid JWT, invalidating and logging out"), await N(H));
|
|
1739
1754
|
} catch {
|
|
1740
|
-
|
|
1755
|
+
c(
|
|
1741
1756
|
"useEffect: exception validating JWT, invalidating and logging out"
|
|
1742
|
-
), await N(
|
|
1757
|
+
), await N(H);
|
|
1743
1758
|
}
|
|
1744
|
-
})() : (
|
|
1745
|
-
|
|
1759
|
+
})() : (c("useEffect: setting the loading state to false"), i({ type: B, payload: { isLoading: !1 } })), () => {
|
|
1760
|
+
y.current = !0;
|
|
1746
1761
|
};
|
|
1747
|
-
}, [s.isLoading,
|
|
1748
|
-
const
|
|
1749
|
-
|
|
1750
|
-
const
|
|
1751
|
-
|
|
1752
|
-
const { code_verifier: K, code_challenge:
|
|
1753
|
-
|
|
1762
|
+
}, [s.isLoading, p, N, c]);
|
|
1763
|
+
const pt = async (u, m) => {
|
|
1764
|
+
i({ type: B, payload: { isLoading: !0 } }), X();
|
|
1765
|
+
const l = ge();
|
|
1766
|
+
_e(l), c("login: Logging in with password");
|
|
1767
|
+
const { code_verifier: K, code_challenge: wt } = await Dr(), be = await qr({
|
|
1768
|
+
endpoint: o,
|
|
1769
|
+
nonce: l,
|
|
1754
1770
|
clientId: r,
|
|
1755
|
-
code_challenge:
|
|
1771
|
+
code_challenge: wt
|
|
1756
1772
|
});
|
|
1757
|
-
if (
|
|
1773
|
+
if (be.status) {
|
|
1758
1774
|
const U = await Br({
|
|
1775
|
+
endpoint: o,
|
|
1759
1776
|
username: u,
|
|
1760
|
-
password:
|
|
1777
|
+
password: m,
|
|
1761
1778
|
clientId: r,
|
|
1762
1779
|
sessionExpiration: t,
|
|
1763
|
-
nonce:
|
|
1780
|
+
nonce: l,
|
|
1764
1781
|
type: M.CODE,
|
|
1765
|
-
code:
|
|
1782
|
+
code: be.data,
|
|
1766
1783
|
code_verifier: K,
|
|
1767
1784
|
domain: n,
|
|
1768
1785
|
ua: navigator.userAgent
|
|
1769
1786
|
});
|
|
1770
|
-
return U.status ? (
|
|
1771
|
-
type:
|
|
1787
|
+
return U.status ? (h(U.idToken), R(U.accessToken), he(U.refreshToken), i({
|
|
1788
|
+
type: oe,
|
|
1772
1789
|
payload: {
|
|
1773
1790
|
authenticationType: M.CODE,
|
|
1774
1791
|
user: {
|
|
@@ -1777,44 +1794,46 @@ const Xr = (e) => D(
|
|
|
1777
1794
|
email: U.email
|
|
1778
1795
|
}
|
|
1779
1796
|
}
|
|
1780
|
-
}), !0) : (F(
|
|
1797
|
+
}), !0) : (F(me), !1);
|
|
1781
1798
|
}
|
|
1782
1799
|
return !1;
|
|
1783
|
-
},
|
|
1784
|
-
u?.preventDefault(), await N(
|
|
1785
|
-
},
|
|
1786
|
-
const { isAuthenticated: u, user:
|
|
1800
|
+
}, yt = async (u) => {
|
|
1801
|
+
u?.preventDefault(), await N(Yr);
|
|
1802
|
+
}, ft = async () => {
|
|
1803
|
+
const { isAuthenticated: u, user: m } = s;
|
|
1787
1804
|
try {
|
|
1788
|
-
if (u &&
|
|
1789
|
-
if (
|
|
1790
|
-
|
|
1791
|
-
const K = await V(
|
|
1792
|
-
if (K && K.payload[
|
|
1793
|
-
return
|
|
1805
|
+
if (u && m && m.userId) {
|
|
1806
|
+
if (f) {
|
|
1807
|
+
c("getAccessToken");
|
|
1808
|
+
const K = await V(f);
|
|
1809
|
+
if (K && K.payload[E.USER_ID_KEY] !== "")
|
|
1810
|
+
return f;
|
|
1794
1811
|
}
|
|
1795
|
-
|
|
1796
|
-
const
|
|
1812
|
+
c("getAccessToken: invalid access token, trying to refresh it");
|
|
1813
|
+
const l = await ht.refreshtoken({
|
|
1814
|
+
endpoint: o,
|
|
1797
1815
|
clientId: r,
|
|
1798
|
-
userId:
|
|
1799
|
-
nonce:
|
|
1816
|
+
userId: m.userId,
|
|
1817
|
+
nonce: dt,
|
|
1800
1818
|
domain: n
|
|
1801
1819
|
});
|
|
1802
|
-
return
|
|
1820
|
+
return l.status && l.status === "success" && l.newAccessToken ? (R(l.newAccessToken), he(l.newRefreshToken), l.newAccessToken) : (c(
|
|
1803
1821
|
"getAccessToken: invalid refresh token, need to re-authenticate"
|
|
1804
|
-
), await N(
|
|
1822
|
+
), await N(H), "");
|
|
1805
1823
|
}
|
|
1806
|
-
return
|
|
1824
|
+
return c(
|
|
1807
1825
|
"getAccessToken: user is not authenticated, cannot get access token"
|
|
1808
|
-
), await N(
|
|
1826
|
+
), await N(H), "";
|
|
1809
1827
|
} catch {
|
|
1810
|
-
return
|
|
1828
|
+
return c(
|
|
1811
1829
|
"getAccessToken: exception occurred, invalidating and logging out"
|
|
1812
|
-
), await N(
|
|
1830
|
+
), await N(xr), "";
|
|
1813
1831
|
}
|
|
1814
|
-
},
|
|
1832
|
+
}, Et = () => s.isAuthenticated && p ? p : "", gt = async () => {
|
|
1815
1833
|
const { user: u } = s;
|
|
1816
|
-
let
|
|
1817
|
-
|
|
1834
|
+
let m = await J({
|
|
1835
|
+
endpoint: o,
|
|
1836
|
+
accessToken: f,
|
|
1818
1837
|
clientId: r,
|
|
1819
1838
|
type: $.GET_REGISTRATION_OPTIONS,
|
|
1820
1839
|
params: {
|
|
@@ -1823,23 +1842,25 @@ const Xr = (e) => D(
|
|
|
1823
1842
|
username: u?.username
|
|
1824
1843
|
}
|
|
1825
1844
|
});
|
|
1826
|
-
if (
|
|
1845
|
+
if (m.status)
|
|
1827
1846
|
try {
|
|
1828
|
-
const
|
|
1829
|
-
return
|
|
1830
|
-
|
|
1847
|
+
const l = await Ct(m.data);
|
|
1848
|
+
return m = await J({
|
|
1849
|
+
endpoint: o,
|
|
1850
|
+
accessToken: f,
|
|
1831
1851
|
clientId: r,
|
|
1832
1852
|
type: $.VERIFY_REGISTRATION,
|
|
1833
1853
|
params: {
|
|
1834
1854
|
clientId: r,
|
|
1835
1855
|
id: u?.userId,
|
|
1836
1856
|
username: u?.username,
|
|
1837
|
-
registration:
|
|
1857
|
+
registration: l
|
|
1838
1858
|
}
|
|
1839
|
-
}), !!(
|
|
1859
|
+
}), !!(m.status && m.data.length > 0);
|
|
1840
1860
|
} catch {
|
|
1841
1861
|
return await J({
|
|
1842
|
-
|
|
1862
|
+
endpoint: o,
|
|
1863
|
+
accessToken: f,
|
|
1843
1864
|
clientId: r,
|
|
1844
1865
|
type: $.VERIFY_REGISTRATION,
|
|
1845
1866
|
params: {
|
|
@@ -1851,80 +1872,83 @@ const Xr = (e) => D(
|
|
|
1851
1872
|
}), !1;
|
|
1852
1873
|
}
|
|
1853
1874
|
return !1;
|
|
1854
|
-
},
|
|
1855
|
-
|
|
1856
|
-
const u =
|
|
1857
|
-
|
|
1858
|
-
const
|
|
1859
|
-
let
|
|
1860
|
-
|
|
1875
|
+
}, mt = async () => {
|
|
1876
|
+
i({ type: B, payload: { isLoading: !0 } }), X();
|
|
1877
|
+
const u = ge();
|
|
1878
|
+
_e(u), c("loginWithPasskey");
|
|
1879
|
+
const m = ge();
|
|
1880
|
+
let l = await J({
|
|
1881
|
+
endpoint: o,
|
|
1882
|
+
accessToken: f,
|
|
1861
1883
|
clientId: r,
|
|
1862
1884
|
type: $.GET_AUTHENTICATION_OPTIONS,
|
|
1863
1885
|
params: {
|
|
1864
|
-
id:
|
|
1886
|
+
id: m,
|
|
1865
1887
|
clientId: r
|
|
1866
1888
|
}
|
|
1867
1889
|
});
|
|
1868
|
-
if (
|
|
1890
|
+
if (l.status)
|
|
1869
1891
|
try {
|
|
1870
|
-
const K = await
|
|
1871
|
-
return
|
|
1872
|
-
|
|
1892
|
+
const K = await Dt(l.data);
|
|
1893
|
+
return l = await J({
|
|
1894
|
+
endpoint: o,
|
|
1895
|
+
accessToken: f,
|
|
1873
1896
|
clientId: r,
|
|
1874
1897
|
type: $.VERIFY_AUTHENTICATION,
|
|
1875
1898
|
params: {
|
|
1876
1899
|
clientId: r,
|
|
1877
|
-
id:
|
|
1900
|
+
id: m,
|
|
1878
1901
|
authentication: K,
|
|
1879
1902
|
nonce: u,
|
|
1880
1903
|
domain: n,
|
|
1881
1904
|
sessionExpiration: t,
|
|
1882
1905
|
ua: navigator.userAgent
|
|
1883
1906
|
}
|
|
1884
|
-
}),
|
|
1885
|
-
type:
|
|
1907
|
+
}), l.data.status === z ? (h(l.data.idToken), R(l.data.accessToken), he(l.data.refreshToken), i({
|
|
1908
|
+
type: oe,
|
|
1886
1909
|
payload: {
|
|
1887
1910
|
authenticationType: M.PASSKEY,
|
|
1888
1911
|
user: {
|
|
1889
|
-
userId:
|
|
1890
|
-
username:
|
|
1891
|
-
email:
|
|
1912
|
+
userId: l.data.userId,
|
|
1913
|
+
username: l.data.username,
|
|
1914
|
+
email: l.data.email
|
|
1892
1915
|
}
|
|
1893
1916
|
}
|
|
1894
|
-
}), !0) : (F(
|
|
1917
|
+
}), !0) : (F(me), !1);
|
|
1895
1918
|
} catch {
|
|
1896
1919
|
return await J({
|
|
1897
|
-
|
|
1920
|
+
endpoint: o,
|
|
1921
|
+
accessToken: f,
|
|
1898
1922
|
clientId: r,
|
|
1899
1923
|
type: $.VERIFY_AUTHENTICATION,
|
|
1900
1924
|
params: {
|
|
1901
1925
|
clientId: r,
|
|
1902
|
-
id:
|
|
1926
|
+
id: m,
|
|
1903
1927
|
authentication: {},
|
|
1904
1928
|
nonce: u,
|
|
1905
1929
|
domain: n,
|
|
1906
1930
|
sessionExpiration: t
|
|
1907
1931
|
}
|
|
1908
|
-
}), F(
|
|
1932
|
+
}), F(me), !1;
|
|
1909
1933
|
}
|
|
1910
1934
|
return !1;
|
|
1911
1935
|
};
|
|
1912
|
-
return /* @__PURE__ */
|
|
1913
|
-
|
|
1936
|
+
return /* @__PURE__ */ ke(Zr.Provider, { value: { state: s, dispatch: i }, children: /* @__PURE__ */ ke(
|
|
1937
|
+
ut.Provider,
|
|
1914
1938
|
{
|
|
1915
1939
|
value: {
|
|
1916
1940
|
...s,
|
|
1917
|
-
login:
|
|
1918
|
-
logout:
|
|
1919
|
-
getAccessToken:
|
|
1920
|
-
getIdToken:
|
|
1921
|
-
registeringForPasskey:
|
|
1922
|
-
loginWithPasskey:
|
|
1941
|
+
login: pt,
|
|
1942
|
+
logout: yt,
|
|
1943
|
+
getAccessToken: ft,
|
|
1944
|
+
getIdToken: Et,
|
|
1945
|
+
registeringForPasskey: gt,
|
|
1946
|
+
loginWithPasskey: mt
|
|
1923
1947
|
},
|
|
1924
1948
|
children: e
|
|
1925
1949
|
}
|
|
1926
1950
|
) });
|
|
1927
|
-
}, un = (e =
|
|
1951
|
+
}, un = (e = ut) => kt(e);
|
|
1928
1952
|
export {
|
|
1929
1953
|
M as AUTH_TYPES,
|
|
1930
1954
|
cn as AuthProvider,
|