@versini/auth-provider 7.5.1 → 7.5.3
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.js +536 -492
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
var yt = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var X = (e, t, r) =>
|
|
4
|
-
import { jsx as
|
|
5
|
-
import
|
|
2
|
+
var pt = (e, t, r) => t in e ? yt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var X = (e, t, r) => pt(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { jsx as _e } from "react/jsx-runtime";
|
|
5
|
+
import ft, { useSyncExternalStore as Et, useCallback as D, useEffect as Ue, createContext as gt, useReducer as mt, useRef as wt, useContext as St } from "react";
|
|
6
6
|
/*!
|
|
7
|
-
@versini/auth-provider v7.5.
|
|
7
|
+
@versini/auth-provider v7.5.3
|
|
8
8
|
© 2025 gizmette.com
|
|
9
9
|
*/
|
|
10
10
|
try {
|
|
11
11
|
window.__VERSINI_AUTH_CLIENT__ || (window.__VERSINI_AUTH_CLIENT__ = {
|
|
12
|
-
version: "7.5.
|
|
13
|
-
buildTime: "04/02/2025
|
|
12
|
+
version: "7.5.3",
|
|
13
|
+
buildTime: "04/02/2025 05:48 PM EDT",
|
|
14
14
|
homepage: "https://github.com/aversini/auth-client",
|
|
15
15
|
license: "MIT"
|
|
16
16
|
});
|
|
@@ -30,94 +30,119 @@ function se(e) {
|
|
|
30
30
|
return s;
|
|
31
31
|
}
|
|
32
32
|
function me() {
|
|
33
|
-
return
|
|
33
|
+
return At.stubThis(globalThis?.PublicKeyCredential !== void 0 && typeof globalThis.PublicKeyCredential == "function");
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
const At = {
|
|
36
|
+
stubThis: (e) => e
|
|
37
|
+
};
|
|
38
|
+
function He(e) {
|
|
36
39
|
const { id: t } = e;
|
|
37
40
|
return {
|
|
38
41
|
...e,
|
|
39
42
|
id: se(t),
|
|
43
|
+
/**
|
|
44
|
+
* `descriptor.transports` is an array of our `AuthenticatorTransportFuture` that includes newer
|
|
45
|
+
* transports that TypeScript's DOM lib is ignorant of. Convince TS that our list of transports
|
|
46
|
+
* are fine to pass to WebAuthn since browsers will recognize the new value.
|
|
47
|
+
*/
|
|
40
48
|
transports: e.transports
|
|
41
49
|
};
|
|
42
50
|
}
|
|
43
|
-
function
|
|
44
|
-
return
|
|
51
|
+
function Le(e) {
|
|
52
|
+
return (
|
|
53
|
+
// Consider localhost valid as well since it's okay wrt Secure Contexts
|
|
54
|
+
e === "localhost" || /^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)
|
|
55
|
+
);
|
|
45
56
|
}
|
|
46
|
-
class
|
|
57
|
+
class b extends Error {
|
|
47
58
|
constructor({ message: t, code: r, cause: a, name: n }) {
|
|
48
|
-
super(t, { cause: a }), this
|
|
59
|
+
super(t, { cause: a }), Object.defineProperty(this, "code", {
|
|
60
|
+
enumerable: !0,
|
|
61
|
+
configurable: !0,
|
|
62
|
+
writable: !0,
|
|
63
|
+
value: void 0
|
|
64
|
+
}), this.name = n ?? a.name, this.code = r;
|
|
49
65
|
}
|
|
50
66
|
}
|
|
51
|
-
function
|
|
67
|
+
function Tt({ error: e, options: t }) {
|
|
52
68
|
const { publicKey: r } = t;
|
|
53
69
|
if (!r)
|
|
54
70
|
throw Error("options was missing required publicKey property");
|
|
55
71
|
if (e.name === "AbortError") {
|
|
56
72
|
if (t.signal instanceof AbortSignal)
|
|
57
|
-
return new
|
|
73
|
+
return new b({
|
|
58
74
|
message: "Registration ceremony was sent an abort signal",
|
|
59
75
|
code: "ERROR_CEREMONY_ABORTED",
|
|
60
76
|
cause: e
|
|
61
77
|
});
|
|
62
78
|
} else if (e.name === "ConstraintError") {
|
|
63
79
|
if (r.authenticatorSelection?.requireResidentKey === !0)
|
|
64
|
-
return new
|
|
80
|
+
return new b({
|
|
65
81
|
message: "Discoverable credentials were required but no available authenticator supported it",
|
|
66
82
|
code: "ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",
|
|
67
83
|
cause: e
|
|
68
84
|
});
|
|
85
|
+
if (
|
|
86
|
+
// @ts-ignore: `mediation` doesn't yet exist on CredentialCreationOptions but it's possible as of Sept 2024
|
|
87
|
+
t.mediation === "conditional" && r.authenticatorSelection?.userVerification === "required"
|
|
88
|
+
)
|
|
89
|
+
return new b({
|
|
90
|
+
message: "User verification was required during automatic registration but it could not be performed",
|
|
91
|
+
code: "ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",
|
|
92
|
+
cause: e
|
|
93
|
+
});
|
|
69
94
|
if (r.authenticatorSelection?.userVerification === "required")
|
|
70
|
-
return new
|
|
95
|
+
return new b({
|
|
71
96
|
message: "User verification was required but no available authenticator supported it",
|
|
72
97
|
code: "ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",
|
|
73
98
|
cause: e
|
|
74
99
|
});
|
|
75
100
|
} else {
|
|
76
101
|
if (e.name === "InvalidStateError")
|
|
77
|
-
return new
|
|
102
|
+
return new b({
|
|
78
103
|
message: "The authenticator was previously registered",
|
|
79
104
|
code: "ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",
|
|
80
105
|
cause: e
|
|
81
106
|
});
|
|
82
107
|
if (e.name === "NotAllowedError")
|
|
83
|
-
return new
|
|
108
|
+
return new b({
|
|
84
109
|
message: e.message,
|
|
85
110
|
code: "ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",
|
|
86
111
|
cause: e
|
|
87
112
|
});
|
|
88
113
|
if (e.name === "NotSupportedError")
|
|
89
|
-
return r.pubKeyCredParams.filter((n) => n.type === "public-key").length === 0 ? new
|
|
114
|
+
return r.pubKeyCredParams.filter((n) => n.type === "public-key").length === 0 ? new b({
|
|
90
115
|
message: 'No entry in pubKeyCredParams was of type "public-key"',
|
|
91
116
|
code: "ERROR_MALFORMED_PUBKEYCREDPARAMS",
|
|
92
117
|
cause: e
|
|
93
|
-
}) : new
|
|
118
|
+
}) : new b({
|
|
94
119
|
message: "No available authenticator supported any of the specified pubKeyCredParams algorithms",
|
|
95
120
|
code: "ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",
|
|
96
121
|
cause: e
|
|
97
122
|
});
|
|
98
123
|
if (e.name === "SecurityError") {
|
|
99
|
-
const a =
|
|
100
|
-
if (
|
|
124
|
+
const a = globalThis.location.hostname;
|
|
125
|
+
if (Le(a)) {
|
|
101
126
|
if (r.rp.id !== a)
|
|
102
|
-
return new
|
|
127
|
+
return new b({
|
|
103
128
|
message: `The RP ID "${r.rp.id}" is invalid for this domain`,
|
|
104
129
|
code: "ERROR_INVALID_RP_ID",
|
|
105
130
|
cause: e
|
|
106
131
|
});
|
|
107
|
-
} else return new
|
|
108
|
-
message: `${
|
|
132
|
+
} else return new b({
|
|
133
|
+
message: `${globalThis.location.hostname} is an invalid domain`,
|
|
109
134
|
code: "ERROR_INVALID_DOMAIN",
|
|
110
135
|
cause: e
|
|
111
136
|
});
|
|
112
137
|
} else if (e.name === "TypeError") {
|
|
113
138
|
if (r.user.id.byteLength < 1 || r.user.id.byteLength > 64)
|
|
114
|
-
return new
|
|
139
|
+
return new b({
|
|
115
140
|
message: "User ID was not between 1 and 64 characters",
|
|
116
141
|
code: "ERROR_INVALID_USER_ID_LENGTH",
|
|
117
142
|
cause: e
|
|
118
143
|
});
|
|
119
144
|
} else if (e.name === "UnknownError")
|
|
120
|
-
return new
|
|
145
|
+
return new b({
|
|
121
146
|
message: "The authenticator was unable to process the specified options, or could not create a new credential",
|
|
122
147
|
code: "ERROR_AUTHENTICATOR_GENERAL_ERROR",
|
|
123
148
|
cause: e
|
|
@@ -125,7 +150,15 @@ function St({ error: e, options: t }) {
|
|
|
125
150
|
}
|
|
126
151
|
return e;
|
|
127
152
|
}
|
|
128
|
-
class
|
|
153
|
+
class bt {
|
|
154
|
+
constructor() {
|
|
155
|
+
Object.defineProperty(this, "controller", {
|
|
156
|
+
enumerable: !0,
|
|
157
|
+
configurable: !0,
|
|
158
|
+
writable: !0,
|
|
159
|
+
value: void 0
|
|
160
|
+
});
|
|
161
|
+
}
|
|
129
162
|
createNewAbortSignal() {
|
|
130
163
|
if (this.controller) {
|
|
131
164
|
const r = new Error("Cancelling existing WebAuthn API call for new one");
|
|
@@ -141,117 +174,122 @@ class At {
|
|
|
141
174
|
}
|
|
142
175
|
}
|
|
143
176
|
}
|
|
144
|
-
const
|
|
145
|
-
function
|
|
146
|
-
if (e && !(
|
|
177
|
+
const $e = new bt(), Rt = ["cross-platform", "platform"];
|
|
178
|
+
function We(e) {
|
|
179
|
+
if (e && !(Rt.indexOf(e) < 0))
|
|
147
180
|
return e;
|
|
148
181
|
}
|
|
149
|
-
async function
|
|
182
|
+
async function _t(e) {
|
|
183
|
+
!e.optionsJSON && e.challenge && (console.warn("startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information."), e = { optionsJSON: e });
|
|
184
|
+
const { optionsJSON: t, useAutoRegister: r = !1 } = e;
|
|
150
185
|
if (!me())
|
|
151
186
|
throw new Error("WebAuthn is not supported in this browser");
|
|
152
|
-
const
|
|
153
|
-
...
|
|
154
|
-
challenge: se(
|
|
187
|
+
const a = {
|
|
188
|
+
...t,
|
|
189
|
+
challenge: se(t.challenge),
|
|
155
190
|
user: {
|
|
156
|
-
...
|
|
157
|
-
id: se(
|
|
191
|
+
...t.user,
|
|
192
|
+
id: se(t.user.id)
|
|
158
193
|
},
|
|
159
|
-
excludeCredentials:
|
|
160
|
-
} };
|
|
161
|
-
r.signal =
|
|
162
|
-
let
|
|
194
|
+
excludeCredentials: t.excludeCredentials?.map(He)
|
|
195
|
+
}, n = {};
|
|
196
|
+
r && (n.mediation = "conditional"), n.publicKey = a, n.signal = $e.createNewAbortSignal();
|
|
197
|
+
let s;
|
|
163
198
|
try {
|
|
164
|
-
|
|
199
|
+
s = await navigator.credentials.create(n);
|
|
165
200
|
} catch (h) {
|
|
166
|
-
throw
|
|
201
|
+
throw Tt({ error: h, options: n });
|
|
167
202
|
}
|
|
168
|
-
if (!
|
|
203
|
+
if (!s)
|
|
169
204
|
throw new Error("Registration was not completed");
|
|
170
|
-
const { id:
|
|
171
|
-
let
|
|
172
|
-
typeof
|
|
173
|
-
let
|
|
174
|
-
if (typeof
|
|
205
|
+
const { id: o, rawId: i, response: c, type: m } = s;
|
|
206
|
+
let d;
|
|
207
|
+
typeof c.getTransports == "function" && (d = c.getTransports());
|
|
208
|
+
let p;
|
|
209
|
+
if (typeof c.getPublicKeyAlgorithm == "function")
|
|
175
210
|
try {
|
|
176
|
-
|
|
211
|
+
p = c.getPublicKeyAlgorithm();
|
|
177
212
|
} catch (h) {
|
|
178
213
|
ue("getPublicKeyAlgorithm()", h);
|
|
179
214
|
}
|
|
180
|
-
let
|
|
181
|
-
if (typeof
|
|
215
|
+
let E;
|
|
216
|
+
if (typeof c.getPublicKey == "function")
|
|
182
217
|
try {
|
|
183
|
-
const h =
|
|
184
|
-
h !== null && (
|
|
218
|
+
const h = c.getPublicKey();
|
|
219
|
+
h !== null && (E = I(h));
|
|
185
220
|
} catch (h) {
|
|
186
221
|
ue("getPublicKey()", h);
|
|
187
222
|
}
|
|
188
|
-
let
|
|
189
|
-
if (typeof
|
|
223
|
+
let y;
|
|
224
|
+
if (typeof c.getAuthenticatorData == "function")
|
|
190
225
|
try {
|
|
191
|
-
|
|
226
|
+
y = I(c.getAuthenticatorData());
|
|
192
227
|
} catch (h) {
|
|
193
228
|
ue("getAuthenticatorData()", h);
|
|
194
229
|
}
|
|
195
230
|
return {
|
|
196
|
-
id:
|
|
197
|
-
rawId: I(
|
|
231
|
+
id: o,
|
|
232
|
+
rawId: I(i),
|
|
198
233
|
response: {
|
|
199
|
-
attestationObject: I(
|
|
200
|
-
clientDataJSON: I(
|
|
201
|
-
transports:
|
|
202
|
-
publicKeyAlgorithm:
|
|
203
|
-
publicKey:
|
|
204
|
-
authenticatorData:
|
|
234
|
+
attestationObject: I(c.attestationObject),
|
|
235
|
+
clientDataJSON: I(c.clientDataJSON),
|
|
236
|
+
transports: d,
|
|
237
|
+
publicKeyAlgorithm: p,
|
|
238
|
+
publicKey: E,
|
|
239
|
+
authenticatorData: y
|
|
205
240
|
},
|
|
206
|
-
type:
|
|
207
|
-
clientExtensionResults:
|
|
208
|
-
authenticatorAttachment:
|
|
241
|
+
type: m,
|
|
242
|
+
clientExtensionResults: s.getClientExtensionResults(),
|
|
243
|
+
authenticatorAttachment: We(s.authenticatorAttachment)
|
|
209
244
|
};
|
|
210
245
|
}
|
|
211
246
|
function ue(e, t) {
|
|
212
247
|
console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.
|
|
213
248
|
`, t);
|
|
214
249
|
}
|
|
215
|
-
function
|
|
250
|
+
function It() {
|
|
216
251
|
if (!me())
|
|
217
|
-
return new Promise((t) => t(!1));
|
|
218
|
-
const e =
|
|
219
|
-
return e
|
|
252
|
+
return le.stubThis(new Promise((t) => t(!1)));
|
|
253
|
+
const e = globalThis.PublicKeyCredential;
|
|
254
|
+
return e?.isConditionalMediationAvailable === void 0 ? le.stubThis(new Promise((t) => t(!1))) : le.stubThis(e.isConditionalMediationAvailable());
|
|
220
255
|
}
|
|
221
|
-
|
|
256
|
+
const le = {
|
|
257
|
+
stubThis: (e) => e
|
|
258
|
+
};
|
|
259
|
+
function Ot({ error: e, options: t }) {
|
|
222
260
|
const { publicKey: r } = t;
|
|
223
261
|
if (!r)
|
|
224
262
|
throw Error("options was missing required publicKey property");
|
|
225
263
|
if (e.name === "AbortError") {
|
|
226
264
|
if (t.signal instanceof AbortSignal)
|
|
227
|
-
return new
|
|
265
|
+
return new b({
|
|
228
266
|
message: "Authentication ceremony was sent an abort signal",
|
|
229
267
|
code: "ERROR_CEREMONY_ABORTED",
|
|
230
268
|
cause: e
|
|
231
269
|
});
|
|
232
270
|
} else {
|
|
233
271
|
if (e.name === "NotAllowedError")
|
|
234
|
-
return new
|
|
272
|
+
return new b({
|
|
235
273
|
message: e.message,
|
|
236
274
|
code: "ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",
|
|
237
275
|
cause: e
|
|
238
276
|
});
|
|
239
277
|
if (e.name === "SecurityError") {
|
|
240
|
-
const a =
|
|
241
|
-
if (
|
|
278
|
+
const a = globalThis.location.hostname;
|
|
279
|
+
if (Le(a)) {
|
|
242
280
|
if (r.rpId !== a)
|
|
243
|
-
return new
|
|
281
|
+
return new b({
|
|
244
282
|
message: `The RP ID "${r.rpId}" is invalid for this domain`,
|
|
245
283
|
code: "ERROR_INVALID_RP_ID",
|
|
246
284
|
cause: e
|
|
247
285
|
});
|
|
248
|
-
} else return new
|
|
249
|
-
message: `${
|
|
286
|
+
} else return new b({
|
|
287
|
+
message: `${globalThis.location.hostname} is an invalid domain`,
|
|
250
288
|
code: "ERROR_INVALID_DOMAIN",
|
|
251
289
|
cause: e
|
|
252
290
|
});
|
|
253
291
|
} else if (e.name === "UnknownError")
|
|
254
|
-
return new
|
|
292
|
+
return new b({
|
|
255
293
|
message: "The authenticator was unable to process the specified options, or could not create a new assertion signature",
|
|
256
294
|
code: "ERROR_AUTHENTICATOR_GENERAL_ERROR",
|
|
257
295
|
cause: e
|
|
@@ -259,49 +297,51 @@ function _t({ error: e, options: t }) {
|
|
|
259
297
|
}
|
|
260
298
|
return e;
|
|
261
299
|
}
|
|
262
|
-
async function
|
|
300
|
+
async function vt(e) {
|
|
301
|
+
!e.optionsJSON && e.challenge && (console.warn("startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information."), e = { optionsJSON: e });
|
|
302
|
+
const { optionsJSON: t, useBrowserAutofill: r = !1, verifyBrowserAutofillInput: a = !0 } = e;
|
|
263
303
|
if (!me())
|
|
264
304
|
throw new Error("WebAuthn is not supported in this browser");
|
|
265
|
-
let
|
|
266
|
-
|
|
267
|
-
const
|
|
268
|
-
...
|
|
269
|
-
challenge: se(
|
|
270
|
-
allowCredentials:
|
|
271
|
-
},
|
|
272
|
-
if (
|
|
273
|
-
if (!await
|
|
305
|
+
let n;
|
|
306
|
+
t.allowCredentials?.length !== 0 && (n = t.allowCredentials?.map(He));
|
|
307
|
+
const s = {
|
|
308
|
+
...t,
|
|
309
|
+
challenge: se(t.challenge),
|
|
310
|
+
allowCredentials: n
|
|
311
|
+
}, o = {};
|
|
312
|
+
if (r) {
|
|
313
|
+
if (!await It())
|
|
274
314
|
throw Error("Browser does not support WebAuthn autofill");
|
|
275
|
-
if (document.querySelectorAll("input[autocomplete$='webauthn']").length < 1)
|
|
315
|
+
if (document.querySelectorAll("input[autocomplete$='webauthn']").length < 1 && a)
|
|
276
316
|
throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');
|
|
277
|
-
|
|
317
|
+
o.mediation = "conditional", s.allowCredentials = [];
|
|
278
318
|
}
|
|
279
|
-
|
|
280
|
-
let
|
|
319
|
+
o.publicKey = s, o.signal = $e.createNewAbortSignal();
|
|
320
|
+
let i;
|
|
281
321
|
try {
|
|
282
|
-
|
|
283
|
-
} catch (
|
|
284
|
-
throw
|
|
322
|
+
i = await navigator.credentials.get(o);
|
|
323
|
+
} catch (y) {
|
|
324
|
+
throw Ot({ error: y, options: o });
|
|
285
325
|
}
|
|
286
|
-
if (!
|
|
326
|
+
if (!i)
|
|
287
327
|
throw new Error("Authentication was not completed");
|
|
288
|
-
const { id:
|
|
289
|
-
let
|
|
290
|
-
return
|
|
291
|
-
id:
|
|
292
|
-
rawId: I(
|
|
328
|
+
const { id: c, rawId: m, response: d, type: p } = i;
|
|
329
|
+
let E;
|
|
330
|
+
return d.userHandle && (E = I(d.userHandle)), {
|
|
331
|
+
id: c,
|
|
332
|
+
rawId: I(m),
|
|
293
333
|
response: {
|
|
294
|
-
authenticatorData: I(
|
|
295
|
-
clientDataJSON: I(
|
|
296
|
-
signature: I(
|
|
297
|
-
userHandle:
|
|
334
|
+
authenticatorData: I(d.authenticatorData),
|
|
335
|
+
clientDataJSON: I(d.clientDataJSON),
|
|
336
|
+
signature: I(d.signature),
|
|
337
|
+
userHandle: E
|
|
298
338
|
},
|
|
299
|
-
type:
|
|
300
|
-
clientExtensionResults:
|
|
301
|
-
authenticatorAttachment:
|
|
339
|
+
type: p,
|
|
340
|
+
clientExtensionResults: i.getClientExtensionResults(),
|
|
341
|
+
authenticatorAttachment: We(i.authenticatorAttachment)
|
|
302
342
|
};
|
|
303
343
|
}
|
|
304
|
-
var
|
|
344
|
+
var kt = Object.defineProperty, Ct = (e, t, r) => t in e ? kt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, f = (e, t, r) => Ct(e, typeof t != "symbol" ? t + "" : t, r);
|
|
305
345
|
/*!
|
|
306
346
|
@versini/auth-common v4.2.1
|
|
307
347
|
© 2025 gizmette.com
|
|
@@ -309,7 +349,7 @@ var vt = Object.defineProperty, kt = (e, t, r) => t in e ? vt(e, t, { enumerable
|
|
|
309
349
|
try {
|
|
310
350
|
window.__VERSINI_AUTH_COMMON__ || (window.__VERSINI_AUTH_COMMON__ = {
|
|
311
351
|
version: "4.2.1",
|
|
312
|
-
buildTime: "04/02/2025
|
|
352
|
+
buildTime: "04/02/2025 05:48 PM EDT",
|
|
313
353
|
homepage: "https://github.com/aversini/auth-client",
|
|
314
354
|
license: "MIT"
|
|
315
355
|
});
|
|
@@ -322,9 +362,9 @@ const x = {
|
|
|
322
362
|
CODE: "code",
|
|
323
363
|
REFRESH_TOKEN: "refresh_token",
|
|
324
364
|
PASSKEY: "passkey"
|
|
325
|
-
},
|
|
365
|
+
}, Je = {
|
|
326
366
|
CLIENT_ID: "X-Auth-ClientId"
|
|
327
|
-
},
|
|
367
|
+
}, g = {
|
|
328
368
|
ALG: "RS256",
|
|
329
369
|
USER_ID_KEY: "sub",
|
|
330
370
|
USERNAME_KEY: "username",
|
|
@@ -337,7 +377,7 @@ const x = {
|
|
|
337
377
|
SCOPES_KEY: "scopes",
|
|
338
378
|
CLIENT_ID_KEY: "aud",
|
|
339
379
|
ISSUER: "gizmette.com"
|
|
340
|
-
},
|
|
380
|
+
}, Pt = `-----BEGIN PUBLIC KEY-----
|
|
341
381
|
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsF6i3Jd9fY/3COqCw/m7
|
|
342
382
|
w5PKyTYLGAI2I6SIIdpe6i6DOCbEkmDz7LdVsBqwNtVi8gvWYIj+8ol6rU3qu1v5
|
|
343
383
|
i1Jd45GSK4kzkVdgCmQZbM5ak0KI99q5wsrAIzUd+LRJ2HRvWtr5IYdsIiXaQjle
|
|
@@ -351,14 +391,14 @@ awIDAQAB
|
|
|
351
391
|
LOGIN: "login",
|
|
352
392
|
REFRESH: "refresh"
|
|
353
393
|
}, Z = new TextEncoder(), G = new TextDecoder();
|
|
354
|
-
function
|
|
394
|
+
function Nt(...e) {
|
|
355
395
|
const t = e.reduce((n, { length: s }) => n + s, 0), r = new Uint8Array(t);
|
|
356
396
|
let a = 0;
|
|
357
397
|
for (const n of e)
|
|
358
398
|
r.set(n, a), a += n.length;
|
|
359
399
|
return r;
|
|
360
400
|
}
|
|
361
|
-
function
|
|
401
|
+
function Kt(e) {
|
|
362
402
|
if (Uint8Array.fromBase64)
|
|
363
403
|
return Uint8Array.fromBase64(e);
|
|
364
404
|
const t = atob(e), r = new Uint8Array(t.length);
|
|
@@ -374,7 +414,7 @@ function F(e) {
|
|
|
374
414
|
let t = e;
|
|
375
415
|
t instanceof Uint8Array && (t = G.decode(t)), t = t.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "");
|
|
376
416
|
try {
|
|
377
|
-
return
|
|
417
|
+
return Kt(t);
|
|
378
418
|
} catch {
|
|
379
419
|
throw new TypeError("The input to be decoded is not correctly encoded.");
|
|
380
420
|
}
|
|
@@ -382,62 +422,62 @@ function F(e) {
|
|
|
382
422
|
class P extends Error {
|
|
383
423
|
constructor(t, r) {
|
|
384
424
|
var a;
|
|
385
|
-
super(t, r),
|
|
425
|
+
super(t, r), f(this, "code", "ERR_JOSE_GENERIC"), this.name = this.constructor.name, (a = Error.captureStackTrace) == null || a.call(Error, this, this.constructor);
|
|
386
426
|
}
|
|
387
427
|
}
|
|
388
|
-
|
|
428
|
+
f(P, "code", "ERR_JOSE_GENERIC");
|
|
389
429
|
class R extends P {
|
|
390
430
|
constructor(t, r, a = "unspecified", n = "unspecified") {
|
|
391
|
-
super(t, { cause: { claim: a, reason: n, payload: r } }),
|
|
431
|
+
super(t, { cause: { claim: a, reason: n, payload: r } }), f(this, "code", "ERR_JWT_CLAIM_VALIDATION_FAILED"), f(this, "claim"), f(this, "reason"), f(this, "payload"), this.claim = a, this.reason = n, this.payload = r;
|
|
392
432
|
}
|
|
393
433
|
}
|
|
394
|
-
|
|
395
|
-
class
|
|
434
|
+
f(R, "code", "ERR_JWT_CLAIM_VALIDATION_FAILED");
|
|
435
|
+
class Ee extends P {
|
|
396
436
|
constructor(t, r, a = "unspecified", n = "unspecified") {
|
|
397
|
-
super(t, { cause: { claim: a, reason: n, payload: r } }),
|
|
437
|
+
super(t, { cause: { claim: a, reason: n, payload: r } }), f(this, "code", "ERR_JWT_EXPIRED"), f(this, "claim"), f(this, "reason"), f(this, "payload"), this.claim = a, this.reason = n, this.payload = r;
|
|
398
438
|
}
|
|
399
439
|
}
|
|
400
|
-
|
|
401
|
-
class
|
|
440
|
+
f(Ee, "code", "ERR_JWT_EXPIRED");
|
|
441
|
+
class Ye extends P {
|
|
402
442
|
constructor() {
|
|
403
|
-
super(...arguments),
|
|
443
|
+
super(...arguments), f(this, "code", "ERR_JOSE_ALG_NOT_ALLOWED");
|
|
404
444
|
}
|
|
405
445
|
}
|
|
406
|
-
|
|
407
|
-
let
|
|
446
|
+
f(Ye, "code", "ERR_JOSE_ALG_NOT_ALLOWED");
|
|
447
|
+
let k = class extends P {
|
|
408
448
|
constructor() {
|
|
409
|
-
super(...arguments),
|
|
449
|
+
super(...arguments), f(this, "code", "ERR_JOSE_NOT_SUPPORTED");
|
|
410
450
|
}
|
|
411
451
|
};
|
|
412
|
-
|
|
413
|
-
class
|
|
452
|
+
f(k, "code", "ERR_JOSE_NOT_SUPPORTED");
|
|
453
|
+
class w extends P {
|
|
414
454
|
constructor() {
|
|
415
|
-
super(...arguments),
|
|
455
|
+
super(...arguments), f(this, "code", "ERR_JWS_INVALID");
|
|
416
456
|
}
|
|
417
457
|
}
|
|
418
|
-
|
|
458
|
+
f(w, "code", "ERR_JWS_INVALID");
|
|
419
459
|
class _ extends P {
|
|
420
460
|
constructor() {
|
|
421
|
-
super(...arguments),
|
|
461
|
+
super(...arguments), f(this, "code", "ERR_JWT_INVALID");
|
|
422
462
|
}
|
|
423
463
|
}
|
|
424
|
-
|
|
425
|
-
class
|
|
464
|
+
f(_, "code", "ERR_JWT_INVALID");
|
|
465
|
+
class xe extends P {
|
|
426
466
|
constructor(t = "signature verification failed", r) {
|
|
427
|
-
super(t, r),
|
|
467
|
+
super(t, r), f(this, "code", "ERR_JWS_SIGNATURE_VERIFICATION_FAILED");
|
|
428
468
|
}
|
|
429
469
|
}
|
|
430
|
-
|
|
431
|
-
function
|
|
470
|
+
f(xe, "code", "ERR_JWS_SIGNATURE_VERIFICATION_FAILED");
|
|
471
|
+
function v(e, t = "algorithm.name") {
|
|
432
472
|
return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`);
|
|
433
473
|
}
|
|
434
474
|
function V(e, t) {
|
|
435
475
|
return e.name === t;
|
|
436
476
|
}
|
|
437
|
-
function
|
|
477
|
+
function de(e) {
|
|
438
478
|
return parseInt(e.name.slice(4), 10);
|
|
439
479
|
}
|
|
440
|
-
function
|
|
480
|
+
function Dt(e) {
|
|
441
481
|
switch (e) {
|
|
442
482
|
case "ES256":
|
|
443
483
|
return "P-256";
|
|
@@ -449,64 +489,64 @@ function Kt(e) {
|
|
|
449
489
|
throw new Error("unreachable");
|
|
450
490
|
}
|
|
451
491
|
}
|
|
452
|
-
function
|
|
492
|
+
function Ut(e, t) {
|
|
453
493
|
if (!e.usages.includes(t))
|
|
454
494
|
throw new TypeError(`CryptoKey does not support this operation, its usages must include ${t}.`);
|
|
455
495
|
}
|
|
456
|
-
function
|
|
496
|
+
function Ht(e, t, r) {
|
|
457
497
|
switch (t) {
|
|
458
498
|
case "HS256":
|
|
459
499
|
case "HS384":
|
|
460
500
|
case "HS512": {
|
|
461
501
|
if (!V(e.algorithm, "HMAC"))
|
|
462
|
-
throw
|
|
502
|
+
throw v("HMAC");
|
|
463
503
|
const a = parseInt(t.slice(2), 10);
|
|
464
|
-
if (
|
|
465
|
-
throw
|
|
504
|
+
if (de(e.algorithm.hash) !== a)
|
|
505
|
+
throw v(`SHA-${a}`, "algorithm.hash");
|
|
466
506
|
break;
|
|
467
507
|
}
|
|
468
508
|
case "RS256":
|
|
469
509
|
case "RS384":
|
|
470
510
|
case "RS512": {
|
|
471
511
|
if (!V(e.algorithm, "RSASSA-PKCS1-v1_5"))
|
|
472
|
-
throw
|
|
512
|
+
throw v("RSASSA-PKCS1-v1_5");
|
|
473
513
|
const a = parseInt(t.slice(2), 10);
|
|
474
|
-
if (
|
|
475
|
-
throw
|
|
514
|
+
if (de(e.algorithm.hash) !== a)
|
|
515
|
+
throw v(`SHA-${a}`, "algorithm.hash");
|
|
476
516
|
break;
|
|
477
517
|
}
|
|
478
518
|
case "PS256":
|
|
479
519
|
case "PS384":
|
|
480
520
|
case "PS512": {
|
|
481
521
|
if (!V(e.algorithm, "RSA-PSS"))
|
|
482
|
-
throw
|
|
522
|
+
throw v("RSA-PSS");
|
|
483
523
|
const a = parseInt(t.slice(2), 10);
|
|
484
|
-
if (
|
|
485
|
-
throw
|
|
524
|
+
if (de(e.algorithm.hash) !== a)
|
|
525
|
+
throw v(`SHA-${a}`, "algorithm.hash");
|
|
486
526
|
break;
|
|
487
527
|
}
|
|
488
528
|
case "Ed25519":
|
|
489
529
|
case "EdDSA": {
|
|
490
530
|
if (!V(e.algorithm, "Ed25519"))
|
|
491
|
-
throw
|
|
531
|
+
throw v("Ed25519");
|
|
492
532
|
break;
|
|
493
533
|
}
|
|
494
534
|
case "ES256":
|
|
495
535
|
case "ES384":
|
|
496
536
|
case "ES512": {
|
|
497
537
|
if (!V(e.algorithm, "ECDSA"))
|
|
498
|
-
throw
|
|
499
|
-
const a =
|
|
538
|
+
throw v("ECDSA");
|
|
539
|
+
const a = Dt(t);
|
|
500
540
|
if (e.algorithm.namedCurve !== a)
|
|
501
|
-
throw
|
|
541
|
+
throw v(a, "algorithm.namedCurve");
|
|
502
542
|
break;
|
|
503
543
|
}
|
|
504
544
|
default:
|
|
505
545
|
throw new TypeError("CryptoKey does not support this operation");
|
|
506
546
|
}
|
|
507
|
-
|
|
547
|
+
Ut(e, r);
|
|
508
548
|
}
|
|
509
|
-
function
|
|
549
|
+
function Ge(e, t, ...r) {
|
|
510
550
|
var a;
|
|
511
551
|
if (r = r.filter(Boolean), r.length > 2) {
|
|
512
552
|
const n = r.pop();
|
|
@@ -514,17 +554,17 @@ function xe(e, t, ...r) {
|
|
|
514
554
|
} else r.length === 2 ? e += `one of type ${r[0]} or ${r[1]}.` : e += `of type ${r[0]}.`;
|
|
515
555
|
return t == null ? e += ` Received ${t}` : typeof t == "function" && t.name ? e += ` Received function ${t.name}` : typeof t == "object" && t != null && (a = t.constructor) != null && a.name && (e += ` Received an instance of ${t.constructor.name}`), e;
|
|
516
556
|
}
|
|
517
|
-
const
|
|
518
|
-
function
|
|
519
|
-
return
|
|
557
|
+
const Lt = (e, ...t) => Ge("Key must be ", e, ...t);
|
|
558
|
+
function Me(e, t, ...r) {
|
|
559
|
+
return Ge(`Key for the ${e} algorithm must be `, t, ...r);
|
|
520
560
|
}
|
|
521
|
-
function
|
|
561
|
+
function je(e) {
|
|
522
562
|
return e?.[Symbol.toStringTag] === "CryptoKey";
|
|
523
563
|
}
|
|
524
|
-
function
|
|
564
|
+
function Ve(e) {
|
|
525
565
|
return e?.[Symbol.toStringTag] === "KeyObject";
|
|
526
566
|
}
|
|
527
|
-
const
|
|
567
|
+
const Be = (e) => je(e) || Ve(e), $t = (...e) => {
|
|
528
568
|
const t = e.filter(Boolean);
|
|
529
569
|
if (t.length === 0 || t.length === 1)
|
|
530
570
|
return !0;
|
|
@@ -543,11 +583,11 @@ const Ve = (e) => Me(e) || je(e), Ht = (...e) => {
|
|
|
543
583
|
}
|
|
544
584
|
return !0;
|
|
545
585
|
};
|
|
546
|
-
function
|
|
586
|
+
function Wt(e) {
|
|
547
587
|
return typeof e == "object" && e !== null;
|
|
548
588
|
}
|
|
549
589
|
const q = (e) => {
|
|
550
|
-
if (!
|
|
590
|
+
if (!Wt(e) || Object.prototype.toString.call(e) !== "[object Object]")
|
|
551
591
|
return !1;
|
|
552
592
|
if (Object.getPrototypeOf(e) === null)
|
|
553
593
|
return !0;
|
|
@@ -555,7 +595,7 @@ const q = (e) => {
|
|
|
555
595
|
for (; Object.getPrototypeOf(t) !== null; )
|
|
556
596
|
t = Object.getPrototypeOf(t);
|
|
557
597
|
return Object.getPrototypeOf(e) === t;
|
|
558
|
-
},
|
|
598
|
+
}, Jt = (e, t) => {
|
|
559
599
|
if (e.startsWith("RS") || e.startsWith("PS")) {
|
|
560
600
|
const { modulusLength: r } = t.algorithm;
|
|
561
601
|
if (typeof r != "number" || r < 2048)
|
|
@@ -568,7 +608,7 @@ const q = (e) => {
|
|
|
568
608
|
return !1;
|
|
569
609
|
const n = e.subarray(a, a + t.length);
|
|
570
610
|
return n.length !== t.length ? !1 : n.every((s, o) => s === t[o]) || ae(e, t, a + 1);
|
|
571
|
-
},
|
|
611
|
+
}, Yt = (e) => {
|
|
572
612
|
switch (!0) {
|
|
573
613
|
case ae(e, [42, 134, 72, 206, 61, 3, 1, 7]):
|
|
574
614
|
return "P-256";
|
|
@@ -579,7 +619,7 @@ const q = (e) => {
|
|
|
579
619
|
default:
|
|
580
620
|
return;
|
|
581
621
|
}
|
|
582
|
-
},
|
|
622
|
+
}, xt = async (e, t, r, a, n) => {
|
|
583
623
|
let s, o;
|
|
584
624
|
const i = new Uint8Array(atob(r.replace(e, "")).split("").map((c) => c.charCodeAt(0)));
|
|
585
625
|
switch (a) {
|
|
@@ -615,7 +655,7 @@ const q = (e) => {
|
|
|
615
655
|
case "ECDH-ES+A128KW":
|
|
616
656
|
case "ECDH-ES+A192KW":
|
|
617
657
|
case "ECDH-ES+A256KW": {
|
|
618
|
-
const c =
|
|
658
|
+
const c = Yt(i);
|
|
619
659
|
s = c != null && c.startsWith("P-") ? { name: "ECDH", namedCurve: c } : { name: "X25519" }, o = [];
|
|
620
660
|
break;
|
|
621
661
|
}
|
|
@@ -624,11 +664,11 @@ const q = (e) => {
|
|
|
624
664
|
s = { name: "Ed25519" }, o = ["verify"];
|
|
625
665
|
break;
|
|
626
666
|
default:
|
|
627
|
-
throw new
|
|
667
|
+
throw new k('Invalid or unsupported "alg" (Algorithm) value');
|
|
628
668
|
}
|
|
629
669
|
return crypto.subtle.importKey(t, i, s, !0, o);
|
|
630
|
-
},
|
|
631
|
-
function
|
|
670
|
+
}, Gt = (e, t, r) => xt(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g, "spki", e, t);
|
|
671
|
+
function Mt(e) {
|
|
632
672
|
let t, r;
|
|
633
673
|
switch (e.kty) {
|
|
634
674
|
case "RSA": {
|
|
@@ -653,7 +693,7 @@ function xt(e) {
|
|
|
653
693
|
}, r = e.d ? ["decrypt", "unwrapKey"] : ["encrypt", "wrapKey"];
|
|
654
694
|
break;
|
|
655
695
|
default:
|
|
656
|
-
throw new
|
|
696
|
+
throw new k('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
657
697
|
}
|
|
658
698
|
break;
|
|
659
699
|
}
|
|
@@ -675,7 +715,7 @@ function xt(e) {
|
|
|
675
715
|
t = { name: "ECDH", namedCurve: e.crv }, r = e.d ? ["deriveBits"] : [];
|
|
676
716
|
break;
|
|
677
717
|
default:
|
|
678
|
-
throw new
|
|
718
|
+
throw new k('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
679
719
|
}
|
|
680
720
|
break;
|
|
681
721
|
}
|
|
@@ -692,27 +732,27 @@ function xt(e) {
|
|
|
692
732
|
t = { name: e.crv }, r = e.d ? ["deriveBits"] : [];
|
|
693
733
|
break;
|
|
694
734
|
default:
|
|
695
|
-
throw new
|
|
735
|
+
throw new k('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
696
736
|
}
|
|
697
737
|
break;
|
|
698
738
|
}
|
|
699
739
|
default:
|
|
700
|
-
throw new
|
|
740
|
+
throw new k('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
|
|
701
741
|
}
|
|
702
742
|
return { algorithm: t, keyUsages: r };
|
|
703
743
|
}
|
|
704
|
-
const
|
|
744
|
+
const jt = async (e) => {
|
|
705
745
|
if (!e.alg)
|
|
706
746
|
throw new TypeError('"alg" argument is required when "jwk.alg" is not present');
|
|
707
|
-
const { algorithm: t, keyUsages: r } =
|
|
747
|
+
const { algorithm: t, keyUsages: r } = Mt(e), a = { ...e };
|
|
708
748
|
return delete a.alg, delete a.use, crypto.subtle.importKey("jwk", a, t, e.ext ?? !e.d, e.key_ops ?? r);
|
|
709
749
|
};
|
|
710
|
-
async function
|
|
750
|
+
async function Vt(e, t, r) {
|
|
711
751
|
if (e.indexOf("-----BEGIN PUBLIC KEY-----") !== 0)
|
|
712
752
|
throw new TypeError('"spki" must be SPKI formatted string');
|
|
713
|
-
return
|
|
753
|
+
return Gt(e, t);
|
|
714
754
|
}
|
|
715
|
-
const
|
|
755
|
+
const Bt = (e, t, r, a, n) => {
|
|
716
756
|
if (n.crit !== void 0 && a?.crit === void 0)
|
|
717
757
|
throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');
|
|
718
758
|
if (!a || a.crit === void 0)
|
|
@@ -723,40 +763,40 @@ const jt = (e, t, r, a, n) => {
|
|
|
723
763
|
r !== void 0 ? s = new Map([...Object.entries(r), ...t.entries()]) : s = t;
|
|
724
764
|
for (const o of a.crit) {
|
|
725
765
|
if (!s.has(o))
|
|
726
|
-
throw new
|
|
766
|
+
throw new k(`Extension Header Parameter "${o}" is not recognized`);
|
|
727
767
|
if (n[o] === void 0)
|
|
728
768
|
throw new e(`Extension Header Parameter "${o}" is missing`);
|
|
729
769
|
if (s.get(o) && a[o] === void 0)
|
|
730
770
|
throw new e(`Extension Header Parameter "${o}" MUST be integrity protected`);
|
|
731
771
|
}
|
|
732
772
|
return new Set(a.crit);
|
|
733
|
-
},
|
|
773
|
+
}, Ft = (e, t) => {
|
|
734
774
|
if (t !== void 0 && (!Array.isArray(t) || t.some((r) => typeof r != "string")))
|
|
735
775
|
throw new TypeError(`"${e}" option must be an array of strings`);
|
|
736
776
|
if (t)
|
|
737
777
|
return new Set(t);
|
|
738
778
|
};
|
|
739
|
-
function
|
|
779
|
+
function we(e) {
|
|
740
780
|
return q(e) && typeof e.kty == "string";
|
|
741
781
|
}
|
|
742
|
-
function
|
|
782
|
+
function qt(e) {
|
|
743
783
|
return e.kty !== "oct" && typeof e.d == "string";
|
|
744
784
|
}
|
|
745
|
-
function
|
|
785
|
+
function zt(e) {
|
|
746
786
|
return e.kty !== "oct" && typeof e.d > "u";
|
|
747
787
|
}
|
|
748
|
-
function
|
|
788
|
+
function Qt(e) {
|
|
749
789
|
return e.kty === "oct" && typeof e.k == "string";
|
|
750
790
|
}
|
|
751
791
|
let C;
|
|
752
|
-
const
|
|
792
|
+
const Ie = async (e, t, r, a = !1) => {
|
|
753
793
|
C || (C = /* @__PURE__ */ new WeakMap());
|
|
754
794
|
let n = C.get(e);
|
|
755
795
|
if (n != null && n[r])
|
|
756
796
|
return n[r];
|
|
757
|
-
const s = await
|
|
797
|
+
const s = await jt({ ...t, alg: r });
|
|
758
798
|
return a && Object.freeze(e), n ? n[r] = s : C.set(e, { [r]: s }), s;
|
|
759
|
-
},
|
|
799
|
+
}, Xt = (e, t) => {
|
|
760
800
|
var r;
|
|
761
801
|
C || (C = /* @__PURE__ */ new WeakMap());
|
|
762
802
|
let a = C.get(e);
|
|
@@ -842,26 +882,26 @@ const _e = async (e, t, r, a = !1) => {
|
|
|
842
882
|
if (!o)
|
|
843
883
|
throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
844
884
|
return a ? a[t] = o : C.set(e, { [t]: o }), o;
|
|
845
|
-
},
|
|
846
|
-
if (e instanceof Uint8Array ||
|
|
885
|
+
}, Zt = async (e, t) => {
|
|
886
|
+
if (e instanceof Uint8Array || je(e))
|
|
847
887
|
return e;
|
|
848
|
-
if (
|
|
888
|
+
if (Ve(e)) {
|
|
849
889
|
if (e.type === "secret")
|
|
850
890
|
return e.export();
|
|
851
891
|
if ("toCryptoKey" in e && typeof e.toCryptoKey == "function")
|
|
852
892
|
try {
|
|
853
|
-
return
|
|
893
|
+
return Xt(e, t);
|
|
854
894
|
} catch (a) {
|
|
855
895
|
if (a instanceof TypeError)
|
|
856
896
|
throw a;
|
|
857
897
|
}
|
|
858
898
|
let r = e.export({ format: "jwk" });
|
|
859
|
-
return
|
|
899
|
+
return Ie(e, r, t);
|
|
860
900
|
}
|
|
861
|
-
if (
|
|
862
|
-
return e.k ? F(e.k) :
|
|
901
|
+
if (we(e))
|
|
902
|
+
return e.k ? F(e.k) : Ie(e, e, t, !0);
|
|
863
903
|
throw new Error("unreachable");
|
|
864
|
-
}, Y = (e) => e?.[Symbol.toStringTag],
|
|
904
|
+
}, Y = (e) => e?.[Symbol.toStringTag], ge = (e, t, r) => {
|
|
865
905
|
var a, n;
|
|
866
906
|
if (t.use !== void 0) {
|
|
867
907
|
let s;
|
|
@@ -905,34 +945,34 @@ const _e = async (e, t, r, a = !1) => {
|
|
|
905
945
|
throw new TypeError(`Invalid key for this operation, its "key_ops" must include "${s}" when present`);
|
|
906
946
|
}
|
|
907
947
|
return !0;
|
|
908
|
-
},
|
|
948
|
+
}, er = (e, t, r) => {
|
|
909
949
|
if (!(t instanceof Uint8Array)) {
|
|
910
|
-
if (
|
|
911
|
-
if (
|
|
950
|
+
if (we(t)) {
|
|
951
|
+
if (Qt(t) && ge(e, t, r))
|
|
912
952
|
return;
|
|
913
953
|
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');
|
|
914
954
|
}
|
|
915
|
-
if (!
|
|
916
|
-
throw new TypeError(
|
|
955
|
+
if (!Be(t))
|
|
956
|
+
throw new TypeError(Me(e, t, "CryptoKey", "KeyObject", "JSON Web Key", "Uint8Array"));
|
|
917
957
|
if (t.type !== "secret")
|
|
918
958
|
throw new TypeError(`${Y(t)} instances for symmetric algorithms must be of type "secret"`);
|
|
919
959
|
}
|
|
920
|
-
},
|
|
921
|
-
if (
|
|
960
|
+
}, tr = (e, t, r) => {
|
|
961
|
+
if (we(t))
|
|
922
962
|
switch (r) {
|
|
923
963
|
case "decrypt":
|
|
924
964
|
case "sign":
|
|
925
|
-
if (
|
|
965
|
+
if (qt(t) && ge(e, t, r))
|
|
926
966
|
return;
|
|
927
967
|
throw new TypeError("JSON Web Key for this operation be a private JWK");
|
|
928
968
|
case "encrypt":
|
|
929
969
|
case "verify":
|
|
930
|
-
if (
|
|
970
|
+
if (zt(t) && ge(e, t, r))
|
|
931
971
|
return;
|
|
932
972
|
throw new TypeError("JSON Web Key for this operation be a public JWK");
|
|
933
973
|
}
|
|
934
|
-
if (!
|
|
935
|
-
throw new TypeError(
|
|
974
|
+
if (!Be(t))
|
|
975
|
+
throw new TypeError(Me(e, t, "CryptoKey", "KeyObject", "JSON Web Key"));
|
|
936
976
|
if (t.type === "secret")
|
|
937
977
|
throw new TypeError(`${Y(t)} instances for asymmetric algorithms must not be of type "secret"`);
|
|
938
978
|
if (t.type === "public")
|
|
@@ -949,9 +989,9 @@ const _e = async (e, t, r, a = !1) => {
|
|
|
949
989
|
case "encrypt":
|
|
950
990
|
throw new TypeError(`${Y(t)} instances for asymmetric algorithm encryption must be of type "public"`);
|
|
951
991
|
}
|
|
952
|
-
},
|
|
953
|
-
e.startsWith("HS") || e === "dir" || e.startsWith("PBES2") || /^A(?:128|192|256)(?:GCM)?(?:KW)?$/.test(e) || /^A(?:128|192|256)CBC-HS(?:256|384|512)$/.test(e) ?
|
|
954
|
-
},
|
|
992
|
+
}, rr = (e, t, r) => {
|
|
993
|
+
e.startsWith("HS") || e === "dir" || e.startsWith("PBES2") || /^A(?:128|192|256)(?:GCM)?(?:KW)?$/.test(e) || /^A(?:128|192|256)CBC-HS(?:256|384|512)$/.test(e) ? er(e, t, r) : tr(e, t, r);
|
|
994
|
+
}, ar = (e, t) => {
|
|
955
995
|
const r = `SHA-${e.slice(-3)}`;
|
|
956
996
|
switch (e) {
|
|
957
997
|
case "HS256":
|
|
@@ -974,100 +1014,100 @@ const _e = async (e, t, r, a = !1) => {
|
|
|
974
1014
|
case "EdDSA":
|
|
975
1015
|
return { name: "Ed25519" };
|
|
976
1016
|
default:
|
|
977
|
-
throw new
|
|
1017
|
+
throw new k(`alg ${e} is not supported either by JOSE or your javascript runtime`);
|
|
978
1018
|
}
|
|
979
|
-
},
|
|
1019
|
+
}, nr = async (e, t, r) => {
|
|
980
1020
|
if (t instanceof Uint8Array) {
|
|
981
1021
|
if (!e.startsWith("HS"))
|
|
982
|
-
throw new TypeError(
|
|
1022
|
+
throw new TypeError(Lt(t, "CryptoKey", "KeyObject", "JSON Web Key"));
|
|
983
1023
|
return crypto.subtle.importKey("raw", t, { hash: `SHA-${e.slice(-3)}`, name: "HMAC" }, !1, [r]);
|
|
984
1024
|
}
|
|
985
|
-
return
|
|
986
|
-
},
|
|
987
|
-
const n = await
|
|
988
|
-
|
|
989
|
-
const s =
|
|
1025
|
+
return Ht(t, e, r), t;
|
|
1026
|
+
}, sr = async (e, t, r, a) => {
|
|
1027
|
+
const n = await nr(e, t, "verify");
|
|
1028
|
+
Jt(e, n);
|
|
1029
|
+
const s = ar(e, n.algorithm);
|
|
990
1030
|
try {
|
|
991
1031
|
return await crypto.subtle.verify(s, n, r, a);
|
|
992
1032
|
} catch {
|
|
993
1033
|
return !1;
|
|
994
1034
|
}
|
|
995
1035
|
};
|
|
996
|
-
async function
|
|
1036
|
+
async function or(e, t, r) {
|
|
997
1037
|
if (!q(e))
|
|
998
|
-
throw new
|
|
1038
|
+
throw new w("Flattened JWS must be an object");
|
|
999
1039
|
if (e.protected === void 0 && e.header === void 0)
|
|
1000
|
-
throw new
|
|
1040
|
+
throw new w('Flattened JWS must have either of the "protected" or "header" members');
|
|
1001
1041
|
if (e.protected !== void 0 && typeof e.protected != "string")
|
|
1002
|
-
throw new
|
|
1042
|
+
throw new w("JWS Protected Header incorrect type");
|
|
1003
1043
|
if (e.payload === void 0)
|
|
1004
|
-
throw new
|
|
1044
|
+
throw new w("JWS Payload missing");
|
|
1005
1045
|
if (typeof e.signature != "string")
|
|
1006
|
-
throw new
|
|
1046
|
+
throw new w("JWS Signature missing or incorrect type");
|
|
1007
1047
|
if (e.header !== void 0 && !q(e.header))
|
|
1008
|
-
throw new
|
|
1048
|
+
throw new w("JWS Unprotected Header incorrect type");
|
|
1009
1049
|
let a = {};
|
|
1010
1050
|
if (e.protected)
|
|
1011
1051
|
try {
|
|
1012
1052
|
const U = F(e.protected);
|
|
1013
1053
|
a = JSON.parse(G.decode(U));
|
|
1014
1054
|
} catch {
|
|
1015
|
-
throw new
|
|
1055
|
+
throw new w("JWS Protected Header is invalid");
|
|
1016
1056
|
}
|
|
1017
|
-
if (
|
|
1018
|
-
throw new
|
|
1057
|
+
if (!$t(a, e.header))
|
|
1058
|
+
throw new w("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
|
|
1019
1059
|
const n = {
|
|
1020
1060
|
...a,
|
|
1021
1061
|
...e.header
|
|
1022
|
-
}, s =
|
|
1062
|
+
}, s = Bt(w, /* @__PURE__ */ new Map([["b64", !0]]), r?.crit, a, n);
|
|
1023
1063
|
let o = !0;
|
|
1024
1064
|
if (s.has("b64") && (o = a.b64, typeof o != "boolean"))
|
|
1025
|
-
throw new
|
|
1065
|
+
throw new w('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
|
|
1026
1066
|
const { alg: i } = n;
|
|
1027
1067
|
if (typeof i != "string" || !i)
|
|
1028
|
-
throw new
|
|
1029
|
-
const c = r &&
|
|
1068
|
+
throw new w('JWS "alg" (Algorithm) Header Parameter missing or invalid');
|
|
1069
|
+
const c = r && Ft("algorithms", r.algorithms);
|
|
1030
1070
|
if (c && !c.has(i))
|
|
1031
|
-
throw new
|
|
1071
|
+
throw new Ye('"alg" (Algorithm) Header Parameter value not allowed');
|
|
1032
1072
|
if (o) {
|
|
1033
1073
|
if (typeof e.payload != "string")
|
|
1034
|
-
throw new
|
|
1074
|
+
throw new w("JWS Payload must be a string");
|
|
1035
1075
|
} else if (typeof e.payload != "string" && !(e.payload instanceof Uint8Array))
|
|
1036
|
-
throw new
|
|
1037
|
-
let
|
|
1038
|
-
typeof t == "function" && (t = await t(a, e),
|
|
1039
|
-
const
|
|
1040
|
-
let
|
|
1076
|
+
throw new w("JWS Payload must be a string or an Uint8Array instance");
|
|
1077
|
+
let m = !1;
|
|
1078
|
+
typeof t == "function" && (t = await t(a, e), m = !0), rr(i, t, "verify");
|
|
1079
|
+
const d = Nt(Z.encode(e.protected ?? ""), Z.encode("."), typeof e.payload == "string" ? Z.encode(e.payload) : e.payload);
|
|
1080
|
+
let p;
|
|
1041
1081
|
try {
|
|
1042
|
-
|
|
1082
|
+
p = F(e.signature);
|
|
1043
1083
|
} catch {
|
|
1044
|
-
throw new
|
|
1084
|
+
throw new w("Failed to base64url decode the signature");
|
|
1045
1085
|
}
|
|
1046
|
-
const
|
|
1047
|
-
if (!await
|
|
1048
|
-
throw new
|
|
1049
|
-
let
|
|
1086
|
+
const E = await Zt(t, i);
|
|
1087
|
+
if (!await sr(i, E, p, d))
|
|
1088
|
+
throw new xe();
|
|
1089
|
+
let y;
|
|
1050
1090
|
if (o)
|
|
1051
1091
|
try {
|
|
1052
|
-
|
|
1092
|
+
y = F(e.payload);
|
|
1053
1093
|
} catch {
|
|
1054
|
-
throw new
|
|
1094
|
+
throw new w("Failed to base64url decode the payload");
|
|
1055
1095
|
}
|
|
1056
|
-
else typeof e.payload == "string" ?
|
|
1057
|
-
const
|
|
1058
|
-
return e.protected !== void 0 && (
|
|
1096
|
+
else typeof e.payload == "string" ? y = Z.encode(e.payload) : y = e.payload;
|
|
1097
|
+
const h = { payload: y };
|
|
1098
|
+
return e.protected !== void 0 && (h.protectedHeader = a), e.header !== void 0 && (h.unprotectedHeader = e.header), m ? { ...h, key: E } : h;
|
|
1059
1099
|
}
|
|
1060
|
-
async function
|
|
1100
|
+
async function ir(e, t, r) {
|
|
1061
1101
|
if (e instanceof Uint8Array && (e = G.decode(e)), typeof e != "string")
|
|
1062
|
-
throw new
|
|
1102
|
+
throw new w("Compact JWS must be a string or Uint8Array");
|
|
1063
1103
|
const { 0: a, 1: n, 2: s, length: o } = e.split(".");
|
|
1064
1104
|
if (o !== 3)
|
|
1065
|
-
throw new
|
|
1066
|
-
const i = await
|
|
1105
|
+
throw new w("Invalid Compact JWS");
|
|
1106
|
+
const i = await or({ payload: n, protected: a, signature: s }, t, r), c = { payload: i.payload, protectedHeader: i.protectedHeader };
|
|
1067
1107
|
return typeof t == "function" ? { ...c, key: i.key } : c;
|
|
1068
1108
|
}
|
|
1069
|
-
const
|
|
1070
|
-
const t =
|
|
1109
|
+
const cr = (e) => Math.floor(e.getTime() / 1e3), Fe = 60, qe = Fe * 60, Se = qe * 24, ur = Se * 7, lr = Se * 365.25, dr = /^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i, Oe = (e) => {
|
|
1110
|
+
const t = dr.exec(e);
|
|
1071
1111
|
if (!t || t[4] && t[1])
|
|
1072
1112
|
throw new TypeError("Invalid time period format");
|
|
1073
1113
|
const r = parseFloat(t[2]), a = t[3].toLowerCase();
|
|
@@ -1085,32 +1125,32 @@ const or = (e) => Math.floor(e.getTime() / 1e3), Be = 60, Fe = Be * 60, we = Fe
|
|
|
1085
1125
|
case "min":
|
|
1086
1126
|
case "mins":
|
|
1087
1127
|
case "m":
|
|
1088
|
-
n = Math.round(r *
|
|
1128
|
+
n = Math.round(r * Fe);
|
|
1089
1129
|
break;
|
|
1090
1130
|
case "hour":
|
|
1091
1131
|
case "hours":
|
|
1092
1132
|
case "hr":
|
|
1093
1133
|
case "hrs":
|
|
1094
1134
|
case "h":
|
|
1095
|
-
n = Math.round(r *
|
|
1135
|
+
n = Math.round(r * qe);
|
|
1096
1136
|
break;
|
|
1097
1137
|
case "day":
|
|
1098
1138
|
case "days":
|
|
1099
1139
|
case "d":
|
|
1100
|
-
n = Math.round(r *
|
|
1140
|
+
n = Math.round(r * Se);
|
|
1101
1141
|
break;
|
|
1102
1142
|
case "week":
|
|
1103
1143
|
case "weeks":
|
|
1104
1144
|
case "w":
|
|
1105
|
-
n = Math.round(r *
|
|
1145
|
+
n = Math.round(r * ur);
|
|
1106
1146
|
break;
|
|
1107
1147
|
default:
|
|
1108
|
-
n = Math.round(r *
|
|
1148
|
+
n = Math.round(r * lr);
|
|
1109
1149
|
break;
|
|
1110
1150
|
}
|
|
1111
1151
|
return t[1] === "-" || t[4] === "ago" ? -n : n;
|
|
1112
|
-
}, ve = (e) => e.toLowerCase().replace(/^application\//, ""),
|
|
1113
|
-
function
|
|
1152
|
+
}, ve = (e) => e.toLowerCase().replace(/^application\//, ""), hr = (e, t) => typeof e == "string" ? t.includes(e) : Array.isArray(e) ? t.some(Set.prototype.has.bind(new Set(e))) : !1;
|
|
1153
|
+
function yr(e, t, r = {}) {
|
|
1114
1154
|
let a;
|
|
1115
1155
|
try {
|
|
1116
1156
|
a = JSON.parse(G.decode(t));
|
|
@@ -1121,64 +1161,64 @@ function dr(e, t, r = {}) {
|
|
|
1121
1161
|
const { typ: n } = r;
|
|
1122
1162
|
if (n && (typeof e.typ != "string" || ve(e.typ) !== ve(n)))
|
|
1123
1163
|
throw new R('unexpected "typ" JWT header value', a, "typ", "check_failed");
|
|
1124
|
-
const { requiredClaims: s = [], issuer: o, subject: i, audience: c, maxTokenAge:
|
|
1125
|
-
|
|
1126
|
-
for (const
|
|
1127
|
-
if (!(
|
|
1128
|
-
throw new R(`missing required "${
|
|
1164
|
+
const { requiredClaims: s = [], issuer: o, subject: i, audience: c, maxTokenAge: m } = r, d = [...s];
|
|
1165
|
+
m !== void 0 && d.push("iat"), c !== void 0 && d.push("aud"), i !== void 0 && d.push("sub"), o !== void 0 && d.push("iss");
|
|
1166
|
+
for (const h of new Set(d.reverse()))
|
|
1167
|
+
if (!(h in a))
|
|
1168
|
+
throw new R(`missing required "${h}" claim`, a, h, "missing");
|
|
1129
1169
|
if (o && !(Array.isArray(o) ? o : [o]).includes(a.iss))
|
|
1130
1170
|
throw new R('unexpected "iss" claim value', a, "iss", "check_failed");
|
|
1131
1171
|
if (i && a.sub !== i)
|
|
1132
1172
|
throw new R('unexpected "sub" claim value', a, "sub", "check_failed");
|
|
1133
|
-
if (c && !
|
|
1173
|
+
if (c && !hr(a.aud, typeof c == "string" ? [c] : c))
|
|
1134
1174
|
throw new R('unexpected "aud" claim value', a, "aud", "check_failed");
|
|
1135
|
-
let
|
|
1175
|
+
let p;
|
|
1136
1176
|
switch (typeof r.clockTolerance) {
|
|
1137
1177
|
case "string":
|
|
1138
|
-
|
|
1178
|
+
p = Oe(r.clockTolerance);
|
|
1139
1179
|
break;
|
|
1140
1180
|
case "number":
|
|
1141
|
-
|
|
1181
|
+
p = r.clockTolerance;
|
|
1142
1182
|
break;
|
|
1143
1183
|
case "undefined":
|
|
1144
|
-
|
|
1184
|
+
p = 0;
|
|
1145
1185
|
break;
|
|
1146
1186
|
default:
|
|
1147
1187
|
throw new TypeError("Invalid clockTolerance option type");
|
|
1148
1188
|
}
|
|
1149
|
-
const { currentDate:
|
|
1150
|
-
if ((a.iat !== void 0 ||
|
|
1189
|
+
const { currentDate: E } = r, y = cr(E || /* @__PURE__ */ new Date());
|
|
1190
|
+
if ((a.iat !== void 0 || m) && typeof a.iat != "number")
|
|
1151
1191
|
throw new R('"iat" claim must be a number', a, "iat", "invalid");
|
|
1152
1192
|
if (a.nbf !== void 0) {
|
|
1153
1193
|
if (typeof a.nbf != "number")
|
|
1154
1194
|
throw new R('"nbf" claim must be a number', a, "nbf", "invalid");
|
|
1155
|
-
if (a.nbf >
|
|
1195
|
+
if (a.nbf > y + p)
|
|
1156
1196
|
throw new R('"nbf" claim timestamp check failed', a, "nbf", "check_failed");
|
|
1157
1197
|
}
|
|
1158
1198
|
if (a.exp !== void 0) {
|
|
1159
1199
|
if (typeof a.exp != "number")
|
|
1160
1200
|
throw new R('"exp" claim must be a number', a, "exp", "invalid");
|
|
1161
|
-
if (a.exp <=
|
|
1162
|
-
throw new
|
|
1201
|
+
if (a.exp <= y - p)
|
|
1202
|
+
throw new Ee('"exp" claim timestamp check failed', a, "exp", "check_failed");
|
|
1163
1203
|
}
|
|
1164
|
-
if (
|
|
1165
|
-
const
|
|
1166
|
-
if (
|
|
1167
|
-
throw new
|
|
1168
|
-
if (
|
|
1204
|
+
if (m) {
|
|
1205
|
+
const h = y - a.iat, U = typeof m == "number" ? m : Oe(m);
|
|
1206
|
+
if (h - p > U)
|
|
1207
|
+
throw new Ee('"iat" claim timestamp check failed (too far in the past)', a, "iat", "check_failed");
|
|
1208
|
+
if (h < 0 - p)
|
|
1169
1209
|
throw new R('"iat" claim timestamp check failed (it should be in the past)', a, "iat", "check_failed");
|
|
1170
1210
|
}
|
|
1171
1211
|
return a;
|
|
1172
1212
|
}
|
|
1173
|
-
async function
|
|
1213
|
+
async function pr(e, t, r) {
|
|
1174
1214
|
var a;
|
|
1175
|
-
const n = await
|
|
1215
|
+
const n = await ir(e, t, r);
|
|
1176
1216
|
if ((a = n.protectedHeader.crit) != null && a.includes("b64") && n.protectedHeader.b64 === !1)
|
|
1177
1217
|
throw new _("JWTs MUST NOT use unencoded payload");
|
|
1178
|
-
const s = { payload:
|
|
1218
|
+
const s = { payload: yr(n.protectedHeader, n.payload, r), protectedHeader: n.protectedHeader };
|
|
1179
1219
|
return typeof t == "function" ? { ...s, key: n.key } : s;
|
|
1180
1220
|
}
|
|
1181
|
-
function
|
|
1221
|
+
function fr(e) {
|
|
1182
1222
|
if (typeof e != "string")
|
|
1183
1223
|
throw new _("JWTs must use Compact JWS serialization, JWT must be a string");
|
|
1184
1224
|
const { 1: t, length: r } = e.split(".");
|
|
@@ -1206,94 +1246,94 @@ function hr(e) {
|
|
|
1206
1246
|
}
|
|
1207
1247
|
const M = async (e) => {
|
|
1208
1248
|
try {
|
|
1209
|
-
const t =
|
|
1210
|
-
return await
|
|
1211
|
-
issuer:
|
|
1249
|
+
const t = g.ALG, r = await Vt(Pt, t);
|
|
1250
|
+
return await pr(e, r, {
|
|
1251
|
+
issuer: g.ISSUER
|
|
1212
1252
|
});
|
|
1213
1253
|
} catch {
|
|
1214
1254
|
return;
|
|
1215
1255
|
}
|
|
1216
|
-
},
|
|
1256
|
+
}, Er = (e) => {
|
|
1217
1257
|
try {
|
|
1218
|
-
return
|
|
1258
|
+
return fr(e);
|
|
1219
1259
|
} catch {
|
|
1220
1260
|
return;
|
|
1221
1261
|
}
|
|
1222
|
-
},
|
|
1262
|
+
}, A = [];
|
|
1223
1263
|
for (let e = 0; e < 256; ++e)
|
|
1224
|
-
|
|
1225
|
-
function
|
|
1226
|
-
return (
|
|
1264
|
+
A.push((e + 256).toString(16).slice(1));
|
|
1265
|
+
function gr(e, t = 0) {
|
|
1266
|
+
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();
|
|
1227
1267
|
}
|
|
1228
|
-
let
|
|
1229
|
-
const
|
|
1230
|
-
function
|
|
1231
|
-
if (!
|
|
1268
|
+
let he;
|
|
1269
|
+
const mr = new Uint8Array(16);
|
|
1270
|
+
function wr() {
|
|
1271
|
+
if (!he) {
|
|
1232
1272
|
if (typeof crypto > "u" || !crypto.getRandomValues)
|
|
1233
1273
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
1234
|
-
|
|
1274
|
+
he = crypto.getRandomValues.bind(crypto);
|
|
1235
1275
|
}
|
|
1236
|
-
return
|
|
1276
|
+
return he(mr);
|
|
1237
1277
|
}
|
|
1238
|
-
const
|
|
1239
|
-
function
|
|
1278
|
+
const Sr = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), ke = { randomUUID: Sr };
|
|
1279
|
+
function Ce(e, t, r) {
|
|
1240
1280
|
var a;
|
|
1241
1281
|
if (ke.randomUUID && !e)
|
|
1242
1282
|
return ke.randomUUID();
|
|
1243
1283
|
e = e || {};
|
|
1244
|
-
const n = e.random ?? ((a = e.rng) == null ? void 0 : a.call(e)) ??
|
|
1284
|
+
const n = e.random ?? ((a = e.rng) == null ? void 0 : a.call(e)) ?? wr();
|
|
1245
1285
|
if (n.length < 16)
|
|
1246
1286
|
throw new Error("Random bytes length must be >= 16");
|
|
1247
|
-
return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128,
|
|
1287
|
+
return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, gr(n);
|
|
1248
1288
|
}
|
|
1249
|
-
const
|
|
1289
|
+
const Pe = globalThis.crypto, Ar = (e) => `${Ce()}${Ce()}`.slice(0, e), Tr = (e) => btoa(
|
|
1250
1290
|
[...new Uint8Array(e)].map((t) => String.fromCharCode(t)).join("")
|
|
1251
1291
|
);
|
|
1252
|
-
async function
|
|
1253
|
-
if (!
|
|
1292
|
+
async function br(e) {
|
|
1293
|
+
if (!Pe.subtle)
|
|
1254
1294
|
throw new Error(
|
|
1255
1295
|
"crypto.subtle is available only in secure contexts (HTTPS)."
|
|
1256
1296
|
);
|
|
1257
|
-
const t = new TextEncoder().encode(e), r = await
|
|
1258
|
-
return
|
|
1297
|
+
const t = new TextEncoder().encode(e), r = await Pe.subtle.digest("SHA-256", t);
|
|
1298
|
+
return Tr(r).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
1259
1299
|
}
|
|
1260
|
-
async function
|
|
1261
|
-
const r =
|
|
1300
|
+
async function Rr(e) {
|
|
1301
|
+
const r = Ar(43), a = await br(r);
|
|
1262
1302
|
return {
|
|
1263
1303
|
code_verifier: r,
|
|
1264
1304
|
code_challenge: a
|
|
1265
1305
|
};
|
|
1266
1306
|
}
|
|
1267
|
-
const
|
|
1307
|
+
const qr = async (e, t) => {
|
|
1268
1308
|
var r;
|
|
1269
1309
|
const a = await M(e);
|
|
1270
|
-
if (!a || !Array.isArray((r = a.payload) == null ? void 0 : r[
|
|
1310
|
+
if (!a || !Array.isArray((r = a.payload) == null ? void 0 : r[g.SCOPES_KEY]))
|
|
1271
1311
|
return !1;
|
|
1272
|
-
const n = a.payload[
|
|
1312
|
+
const n = a.payload[g.SCOPES_KEY];
|
|
1273
1313
|
return Array.isArray(t) ? t.every((s) => n.includes(s)) : Object.keys(t).some(
|
|
1274
1314
|
(s) => t[s].every((o) => n.includes(o))
|
|
1275
1315
|
);
|
|
1276
1316
|
};
|
|
1277
|
-
function
|
|
1317
|
+
function ze(e, t) {
|
|
1278
1318
|
window.dispatchEvent(new StorageEvent("storage", { key: e, newValue: t }));
|
|
1279
1319
|
}
|
|
1280
|
-
const
|
|
1320
|
+
const Ne = (e, t) => {
|
|
1281
1321
|
const r = JSON.stringify(
|
|
1282
1322
|
typeof t == "function" ? t() : t
|
|
1283
1323
|
);
|
|
1284
|
-
window.localStorage.setItem(e, r),
|
|
1285
|
-
},
|
|
1286
|
-
window.localStorage.removeItem(e),
|
|
1287
|
-
}, Ke = (e) => window.localStorage.getItem(e),
|
|
1324
|
+
window.localStorage.setItem(e, r), ze(e, r);
|
|
1325
|
+
}, _r = (e) => {
|
|
1326
|
+
window.localStorage.removeItem(e), ze(e, null);
|
|
1327
|
+
}, Ke = (e) => window.localStorage.getItem(e), Ir = (e) => (window.addEventListener("storage", e), () => window.removeEventListener("storage", e));
|
|
1288
1328
|
function ee({
|
|
1289
1329
|
key: e,
|
|
1290
1330
|
initialValue: t
|
|
1291
1331
|
}) {
|
|
1292
|
-
const r =
|
|
1332
|
+
const r = Et(Ir, () => Ke(e)), a = D(
|
|
1293
1333
|
(o) => {
|
|
1294
1334
|
try {
|
|
1295
1335
|
const i = typeof o == "function" ? o(JSON.parse(r)) : o;
|
|
1296
|
-
i == null ?
|
|
1336
|
+
i == null ? _r(e) : Ne(e, i);
|
|
1297
1337
|
} catch (i) {
|
|
1298
1338
|
console.warn(i);
|
|
1299
1339
|
}
|
|
@@ -1304,41 +1344,41 @@ function ee({
|
|
|
1304
1344
|
}, [t, a]), s = D(() => {
|
|
1305
1345
|
a(null);
|
|
1306
1346
|
}, [a]);
|
|
1307
|
-
return
|
|
1347
|
+
return Ue(() => {
|
|
1308
1348
|
try {
|
|
1309
|
-
Ke(e) === null && typeof t < "u" &&
|
|
1349
|
+
Ke(e) === null && typeof t < "u" && Ne(e, t);
|
|
1310
1350
|
} catch (o) {
|
|
1311
1351
|
console.warn(o);
|
|
1312
1352
|
}
|
|
1313
1353
|
}, [e, t]), [r ? JSON.parse(r) : null, a, n, s];
|
|
1314
1354
|
}
|
|
1315
|
-
const
|
|
1355
|
+
const T = [];
|
|
1316
1356
|
for (let e = 0; e < 256; ++e)
|
|
1317
|
-
|
|
1318
|
-
function
|
|
1319
|
-
return (
|
|
1357
|
+
T.push((e + 256).toString(16).slice(1));
|
|
1358
|
+
function Or(e, t = 0) {
|
|
1359
|
+
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();
|
|
1320
1360
|
}
|
|
1321
1361
|
let ye;
|
|
1322
|
-
const
|
|
1323
|
-
function
|
|
1362
|
+
const vr = new Uint8Array(16);
|
|
1363
|
+
function kr() {
|
|
1324
1364
|
if (!ye) {
|
|
1325
1365
|
if (typeof crypto > "u" || !crypto.getRandomValues)
|
|
1326
1366
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
1327
1367
|
ye = crypto.getRandomValues.bind(crypto);
|
|
1328
1368
|
}
|
|
1329
|
-
return ye(
|
|
1369
|
+
return ye(vr);
|
|
1330
1370
|
}
|
|
1331
|
-
const
|
|
1332
|
-
function
|
|
1333
|
-
if (
|
|
1334
|
-
return
|
|
1371
|
+
const Cr = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), De = { randomUUID: Cr };
|
|
1372
|
+
function pe(e, t, r) {
|
|
1373
|
+
if (De.randomUUID && !e)
|
|
1374
|
+
return De.randomUUID();
|
|
1335
1375
|
e = e || {};
|
|
1336
|
-
const a = e.random ?? e.rng?.() ??
|
|
1376
|
+
const a = e.random ?? e.rng?.() ?? kr();
|
|
1337
1377
|
if (a.length < 16)
|
|
1338
1378
|
throw new Error("Random bytes length must be >= 16");
|
|
1339
|
-
return a[6] = a[6] & 15 | 64, a[8] = a[8] & 63 | 128,
|
|
1379
|
+
return a[6] = a[6] & 15 | 64, a[8] = a[8] & 63 | 128, Or(a);
|
|
1340
1380
|
}
|
|
1341
|
-
const L = "Your session has expired. For your security, please log in again to continue.",
|
|
1381
|
+
const L = "Your session has expired. For your security, please log in again to continue.", Pr = "Your session has been successfully terminated.", fe = "Login failed. Please try again.", Nr = "Error getting access token, please re-authenticate.", Kr = "You forgot to wrap your component in <AuthProvider>.", te = "@@auth@@", B = "LOADING", ne = "LOGIN", Qe = "LOGOUT", z = "success", O = "failure", Xe = "include", Ze = "POST", et = "application/json", re = {
|
|
1342
1382
|
GET_REGISTRATION_OPTIONS: `mutation GetPasskeyRegistrationOptions(
|
|
1343
1383
|
$clientId: String!,
|
|
1344
1384
|
$username: String!,
|
|
@@ -1445,12 +1485,12 @@ const L = "Your session has expired. For your security, please log in again to c
|
|
|
1445
1485
|
}) => {
|
|
1446
1486
|
try {
|
|
1447
1487
|
const s = `Bearer ${e}`, o = await fetch(`${n}/graphql`, {
|
|
1448
|
-
credentials:
|
|
1449
|
-
method:
|
|
1488
|
+
credentials: Xe,
|
|
1489
|
+
method: Ze,
|
|
1450
1490
|
headers: {
|
|
1451
1491
|
authorization: s,
|
|
1452
|
-
"Content-Type":
|
|
1453
|
-
[
|
|
1492
|
+
"Content-Type": et,
|
|
1493
|
+
[Je.CLIENT_ID]: `${r}`
|
|
1454
1494
|
},
|
|
1455
1495
|
body: JSON.stringify({
|
|
1456
1496
|
query: t.schema,
|
|
@@ -1458,14 +1498,14 @@ const L = "Your session has expired. For your security, please log in again to c
|
|
|
1458
1498
|
})
|
|
1459
1499
|
});
|
|
1460
1500
|
if (o.status !== 200)
|
|
1461
|
-
return { status:
|
|
1501
|
+
return { status: O, data: [] };
|
|
1462
1502
|
const { data: i } = await o.json();
|
|
1463
1503
|
return {
|
|
1464
1504
|
status: z,
|
|
1465
1505
|
data: i[t.method]
|
|
1466
1506
|
};
|
|
1467
1507
|
} catch (s) {
|
|
1468
|
-
return console.error(s), { status:
|
|
1508
|
+
return console.error(s), { status: O, data: [] };
|
|
1469
1509
|
}
|
|
1470
1510
|
}, ie = async ({
|
|
1471
1511
|
type: e,
|
|
@@ -1475,39 +1515,39 @@ const L = "Your session has expired. For your security, please log in again to c
|
|
|
1475
1515
|
}) => {
|
|
1476
1516
|
try {
|
|
1477
1517
|
const n = await fetch(`${a}/${e}`, {
|
|
1478
|
-
credentials:
|
|
1479
|
-
method:
|
|
1518
|
+
credentials: Xe,
|
|
1519
|
+
method: Ze,
|
|
1480
1520
|
headers: {
|
|
1481
|
-
"Content-Type":
|
|
1482
|
-
[
|
|
1521
|
+
"Content-Type": et,
|
|
1522
|
+
[Je.CLIENT_ID]: `${t}`
|
|
1483
1523
|
},
|
|
1484
1524
|
body: JSON.stringify(r)
|
|
1485
1525
|
});
|
|
1486
1526
|
if (n.status !== 200)
|
|
1487
|
-
return { status:
|
|
1527
|
+
return { status: O, data: [] };
|
|
1488
1528
|
const { data: s } = await n.json();
|
|
1489
1529
|
return {
|
|
1490
1530
|
status: z,
|
|
1491
1531
|
data: s || []
|
|
1492
1532
|
};
|
|
1493
1533
|
} catch (n) {
|
|
1494
|
-
return console.error(n), { status:
|
|
1534
|
+
return console.error(n), { status: O, data: [] };
|
|
1495
1535
|
}
|
|
1496
|
-
},
|
|
1536
|
+
}, Dr = process.env.NODE_ENV === "production", Ur = !Dr, tt = {
|
|
1497
1537
|
isLoading: !0,
|
|
1498
1538
|
isAuthenticated: !1,
|
|
1499
1539
|
user: void 0,
|
|
1500
1540
|
logoutReason: "",
|
|
1501
1541
|
debug: !1,
|
|
1502
1542
|
authenticationType: ""
|
|
1503
|
-
},
|
|
1543
|
+
}, Hr = (e) => {
|
|
1504
1544
|
try {
|
|
1505
|
-
const t =
|
|
1506
|
-
return t ? t[
|
|
1545
|
+
const t = Er(e);
|
|
1546
|
+
return t ? t[g.USER_ID_KEY] : "";
|
|
1507
1547
|
} catch {
|
|
1508
1548
|
return "";
|
|
1509
1549
|
}
|
|
1510
|
-
},
|
|
1550
|
+
}, Lr = async ({
|
|
1511
1551
|
userId: e,
|
|
1512
1552
|
clientId: t,
|
|
1513
1553
|
domain: r,
|
|
@@ -1525,14 +1565,14 @@ const L = "Your session has expired. For your security, please log in again to c
|
|
|
1525
1565
|
domain: r,
|
|
1526
1566
|
idToken: a
|
|
1527
1567
|
}
|
|
1528
|
-
}))?.status ||
|
|
1568
|
+
}))?.status || O
|
|
1529
1569
|
};
|
|
1530
1570
|
} catch {
|
|
1531
1571
|
return {
|
|
1532
|
-
status:
|
|
1572
|
+
status: O
|
|
1533
1573
|
};
|
|
1534
1574
|
}
|
|
1535
|
-
},
|
|
1575
|
+
}, $r = async ({
|
|
1536
1576
|
username: e,
|
|
1537
1577
|
password: t,
|
|
1538
1578
|
clientId: r,
|
|
@@ -1542,12 +1582,12 @@ const L = "Your session has expired. For your security, please log in again to c
|
|
|
1542
1582
|
code: o,
|
|
1543
1583
|
code_verifier: i,
|
|
1544
1584
|
domain: c,
|
|
1545
|
-
ua:
|
|
1546
|
-
endpoint:
|
|
1585
|
+
ua: m,
|
|
1586
|
+
endpoint: d
|
|
1547
1587
|
}) => {
|
|
1548
1588
|
try {
|
|
1549
|
-
const
|
|
1550
|
-
endpoint:
|
|
1589
|
+
const p = await ie({
|
|
1590
|
+
endpoint: d,
|
|
1551
1591
|
type: oe.LOGIN,
|
|
1552
1592
|
clientId: r,
|
|
1553
1593
|
params: {
|
|
@@ -1559,15 +1599,15 @@ const L = "Your session has expired. For your security, please log in again to c
|
|
|
1559
1599
|
code: o,
|
|
1560
1600
|
code_verifier: i,
|
|
1561
1601
|
domain: c,
|
|
1562
|
-
ua:
|
|
1602
|
+
ua: m
|
|
1563
1603
|
}
|
|
1564
|
-
}),
|
|
1565
|
-
return
|
|
1566
|
-
idToken:
|
|
1567
|
-
accessToken:
|
|
1568
|
-
refreshToken:
|
|
1569
|
-
userId:
|
|
1570
|
-
email:
|
|
1604
|
+
}), E = await M(p?.data?.idToken);
|
|
1605
|
+
return E && E.payload[g.USER_ID_KEY] !== "" && E.payload[g.NONCE_KEY] === a ? {
|
|
1606
|
+
idToken: p.data.idToken,
|
|
1607
|
+
accessToken: p.data.accessToken,
|
|
1608
|
+
refreshToken: p.data.refreshToken,
|
|
1609
|
+
userId: E.payload[g.USER_ID_KEY],
|
|
1610
|
+
email: E.payload[g.EMAIL_KEY],
|
|
1571
1611
|
status: !0
|
|
1572
1612
|
} : {
|
|
1573
1613
|
status: !1
|
|
@@ -1577,7 +1617,7 @@ const L = "Your session has expired. For your security, please log in again to c
|
|
|
1577
1617
|
status: !1
|
|
1578
1618
|
};
|
|
1579
1619
|
}
|
|
1580
|
-
},
|
|
1620
|
+
}, Wr = async ({
|
|
1581
1621
|
nonce: e,
|
|
1582
1622
|
clientId: t,
|
|
1583
1623
|
code_challenge: r,
|
|
@@ -1598,16 +1638,16 @@ const L = "Your session has expired. For your security, please log in again to c
|
|
|
1598
1638
|
status: z,
|
|
1599
1639
|
data: n.data.code
|
|
1600
1640
|
} : {
|
|
1601
|
-
status:
|
|
1641
|
+
status: O,
|
|
1602
1642
|
data: ""
|
|
1603
1643
|
};
|
|
1604
1644
|
} catch {
|
|
1605
1645
|
return {
|
|
1606
|
-
status:
|
|
1646
|
+
status: O,
|
|
1607
1647
|
data: ""
|
|
1608
1648
|
};
|
|
1609
1649
|
}
|
|
1610
|
-
},
|
|
1650
|
+
}, Jr = async ({
|
|
1611
1651
|
clientId: e,
|
|
1612
1652
|
userId: t,
|
|
1613
1653
|
nonce: r,
|
|
@@ -1630,10 +1670,10 @@ const L = "Your session has expired. For your security, please log in again to c
|
|
|
1630
1670
|
domain: s
|
|
1631
1671
|
}
|
|
1632
1672
|
}), c = await M(i?.data?.accessToken);
|
|
1633
|
-
return c && c.payload[
|
|
1673
|
+
return c && c.payload[g.USER_ID_KEY] !== "" && c.payload[g.NONCE_KEY] === r ? {
|
|
1634
1674
|
accessToken: i.data.accessToken,
|
|
1635
1675
|
refreshToken: i.data.refreshToken,
|
|
1636
|
-
userId: c.payload[
|
|
1676
|
+
userId: c.payload[g.USER_ID_KEY],
|
|
1637
1677
|
status: !0
|
|
1638
1678
|
} : {
|
|
1639
1679
|
status: !1
|
|
@@ -1644,7 +1684,7 @@ const L = "Your session has expired. For your security, please log in again to c
|
|
|
1644
1684
|
};
|
|
1645
1685
|
}
|
|
1646
1686
|
};
|
|
1647
|
-
class
|
|
1687
|
+
class Yr {
|
|
1648
1688
|
constructor(t = null, r = null) {
|
|
1649
1689
|
X(this, "refreshTokenPromise", null);
|
|
1650
1690
|
X(this, "accessToken");
|
|
@@ -1679,8 +1719,8 @@ class Wr {
|
|
|
1679
1719
|
domain: s
|
|
1680
1720
|
}) {
|
|
1681
1721
|
const o = await M(this.refreshToken);
|
|
1682
|
-
if (o && o.payload[
|
|
1683
|
-
const i = await
|
|
1722
|
+
if (o && o.payload[g.USER_ID_KEY] !== "") {
|
|
1723
|
+
const i = await Jr({
|
|
1684
1724
|
endpoint: t,
|
|
1685
1725
|
clientId: r,
|
|
1686
1726
|
userId: a,
|
|
@@ -1694,22 +1734,22 @@ class Wr {
|
|
|
1694
1734
|
newAccessToken: i.accessToken,
|
|
1695
1735
|
newRefreshToken: i.refreshToken
|
|
1696
1736
|
}) : {
|
|
1697
|
-
status:
|
|
1737
|
+
status: O
|
|
1698
1738
|
};
|
|
1699
1739
|
} else
|
|
1700
1740
|
return {
|
|
1701
|
-
status:
|
|
1741
|
+
status: O
|
|
1702
1742
|
};
|
|
1703
1743
|
}
|
|
1704
1744
|
}
|
|
1705
|
-
const
|
|
1745
|
+
const xr = (e) => D(
|
|
1706
1746
|
(...t) => {
|
|
1707
1747
|
e && console.info(`==> [Auth ${Date.now()}]: `, ...t);
|
|
1708
1748
|
},
|
|
1709
1749
|
[e]
|
|
1710
1750
|
), J = () => {
|
|
1711
|
-
throw new Error(
|
|
1712
|
-
},
|
|
1751
|
+
throw new Error(Kr);
|
|
1752
|
+
}, rt = gt({
|
|
1713
1753
|
isAuthenticated: !1,
|
|
1714
1754
|
isLoading: !1,
|
|
1715
1755
|
login: J,
|
|
@@ -1720,11 +1760,11 @@ const Jr = (e) => D(
|
|
|
1720
1760
|
loginWithPasskey: J,
|
|
1721
1761
|
logoutReason: "",
|
|
1722
1762
|
authenticationType: ""
|
|
1723
|
-
}),
|
|
1724
|
-
state:
|
|
1763
|
+
}), Gr = ft.createContext({
|
|
1764
|
+
state: tt,
|
|
1725
1765
|
dispatch: () => {
|
|
1726
1766
|
}
|
|
1727
|
-
}),
|
|
1767
|
+
}), Mr = (e, t) => t?.type === B ? {
|
|
1728
1768
|
...e,
|
|
1729
1769
|
isLoading: t.payload.isLoading
|
|
1730
1770
|
} : t?.type === ne ? {
|
|
@@ -1734,41 +1774,41 @@ const Jr = (e) => D(
|
|
|
1734
1774
|
user: t.payload.user,
|
|
1735
1775
|
authenticationType: t.payload.authenticationType,
|
|
1736
1776
|
logoutReason: ""
|
|
1737
|
-
} : t?.type ===
|
|
1777
|
+
} : t?.type === Qe ? {
|
|
1738
1778
|
...e,
|
|
1739
1779
|
isLoading: !1,
|
|
1740
1780
|
isAuthenticated: !1,
|
|
1741
1781
|
user: void 0,
|
|
1742
1782
|
authenticationType: "",
|
|
1743
1783
|
logoutReason: t.payload.logoutReason
|
|
1744
|
-
} : e,
|
|
1784
|
+
} : e, zr = ({
|
|
1745
1785
|
children: e,
|
|
1746
1786
|
sessionExpiration: t,
|
|
1747
1787
|
clientId: r,
|
|
1748
1788
|
domain: a = "",
|
|
1749
1789
|
debug: n = !1,
|
|
1750
|
-
endpoint: s =
|
|
1790
|
+
endpoint: s = Ur ? "https://auth.gizmette.local.com:3003" : "https://mylogin.gizmette.com/auth"
|
|
1751
1791
|
}) => {
|
|
1752
|
-
const [o, i] = mt(
|
|
1753
|
-
...
|
|
1792
|
+
const [o, i] = mt(Mr, {
|
|
1793
|
+
...tt,
|
|
1754
1794
|
debug: n
|
|
1755
|
-
}), c =
|
|
1795
|
+
}), c = xr(n), m = wt(!1), [d, p, , E] = ee({
|
|
1756
1796
|
key: `${te}::${r}::@@user@@`
|
|
1757
|
-
}), [
|
|
1797
|
+
}), [y, h, , U] = ee({
|
|
1758
1798
|
key: `${te}::${r}::@@access@@`
|
|
1759
|
-
}), [
|
|
1799
|
+
}), [at, ce, , Ae] = ee(
|
|
1760
1800
|
{
|
|
1761
1801
|
key: `${te}::${r}::@@refresh@@`
|
|
1762
1802
|
}
|
|
1763
|
-
), [
|
|
1803
|
+
), [nt, Te, , be] = ee({
|
|
1764
1804
|
key: `${te}::${r}::@@nonce@@`
|
|
1765
|
-
}),
|
|
1766
|
-
c("removeLocalStorage: removing local storage"),
|
|
1805
|
+
}), st = new Yr(y, at), Q = D(() => {
|
|
1806
|
+
c("removeLocalStorage: removing local storage"), E(), U(), Ae(), be();
|
|
1767
1807
|
}, [
|
|
1768
1808
|
U,
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1809
|
+
E,
|
|
1810
|
+
be,
|
|
1811
|
+
Ae,
|
|
1772
1812
|
c
|
|
1773
1813
|
]), j = D(
|
|
1774
1814
|
(u) => {
|
|
@@ -1776,29 +1816,29 @@ const Jr = (e) => D(
|
|
|
1776
1816
|
"removeStateAndLocalStorage: removing state and local storage with reason: ",
|
|
1777
1817
|
u
|
|
1778
1818
|
), i({
|
|
1779
|
-
type:
|
|
1819
|
+
type: Qe,
|
|
1780
1820
|
payload: {
|
|
1781
1821
|
logoutReason: u || L
|
|
1782
1822
|
}
|
|
1783
1823
|
}), Q(), i({ type: B, payload: { isLoading: !1 } });
|
|
1784
1824
|
},
|
|
1785
1825
|
[Q, c]
|
|
1786
|
-
),
|
|
1826
|
+
), N = D(
|
|
1787
1827
|
async (u) => {
|
|
1788
1828
|
c("invalidateAndLogout: invalidating and logging out");
|
|
1789
|
-
const { user:
|
|
1829
|
+
const { user: S } = o, l = S?.userId || Hr(d);
|
|
1790
1830
|
l || c(
|
|
1791
1831
|
"invalidateAndLogout: user cannot be identified, logging out without userId"
|
|
1792
|
-
), await
|
|
1832
|
+
), await Lr({
|
|
1793
1833
|
userId: l,
|
|
1794
1834
|
clientId: r,
|
|
1795
1835
|
domain: a,
|
|
1796
|
-
idToken:
|
|
1836
|
+
idToken: d,
|
|
1797
1837
|
endpoint: s
|
|
1798
1838
|
}), j(u || L);
|
|
1799
1839
|
},
|
|
1800
1840
|
[
|
|
1801
|
-
|
|
1841
|
+
d,
|
|
1802
1842
|
o,
|
|
1803
1843
|
r,
|
|
1804
1844
|
a,
|
|
@@ -1807,56 +1847,56 @@ const Jr = (e) => D(
|
|
|
1807
1847
|
s
|
|
1808
1848
|
]
|
|
1809
1849
|
);
|
|
1810
|
-
|
|
1811
|
-
if (!
|
|
1812
|
-
return o.isLoading &&
|
|
1850
|
+
Ue(() => {
|
|
1851
|
+
if (!m.current)
|
|
1852
|
+
return o.isLoading && d !== null ? (async () => {
|
|
1813
1853
|
try {
|
|
1814
|
-
const u = await M(
|
|
1815
|
-
u && u.payload[
|
|
1854
|
+
const u = await M(d);
|
|
1855
|
+
u && u.payload[g.USER_ID_KEY] !== "" ? (c("useEffect: setting the authentication state"), i({
|
|
1816
1856
|
type: ne,
|
|
1817
1857
|
payload: {
|
|
1818
|
-
authenticationType: u.payload[
|
|
1858
|
+
authenticationType: u.payload[g.AUTH_TYPE_KEY],
|
|
1819
1859
|
user: {
|
|
1820
|
-
userId: u.payload[
|
|
1821
|
-
username: u.payload[
|
|
1822
|
-
email: u.payload[
|
|
1860
|
+
userId: u.payload[g.USER_ID_KEY],
|
|
1861
|
+
username: u.payload[g.USERNAME_KEY],
|
|
1862
|
+
email: u.payload[g.EMAIL_KEY]
|
|
1823
1863
|
}
|
|
1824
1864
|
}
|
|
1825
|
-
})) : (c("useEffect: invalid JWT, invalidating and logging out"), await
|
|
1865
|
+
})) : (c("useEffect: invalid JWT, invalidating and logging out"), await N(L));
|
|
1826
1866
|
} catch {
|
|
1827
1867
|
c(
|
|
1828
1868
|
"useEffect: exception validating JWT, invalidating and logging out"
|
|
1829
|
-
), await
|
|
1869
|
+
), await N(L);
|
|
1830
1870
|
}
|
|
1831
1871
|
})() : (c("useEffect: setting the loading state to false"), i({ type: B, payload: { isLoading: !1 } })), () => {
|
|
1832
|
-
|
|
1872
|
+
m.current = !0;
|
|
1833
1873
|
};
|
|
1834
|
-
}, [o.isLoading,
|
|
1835
|
-
const
|
|
1874
|
+
}, [o.isLoading, d, N, c]);
|
|
1875
|
+
const ot = async (u, S) => {
|
|
1836
1876
|
i({ type: B, payload: { isLoading: !0 } }), Q();
|
|
1837
|
-
const l =
|
|
1838
|
-
|
|
1839
|
-
const { code_verifier:
|
|
1877
|
+
const l = pe();
|
|
1878
|
+
Te(l), c("login: Logging in with password");
|
|
1879
|
+
const { code_verifier: K, code_challenge: ht } = await Rr(), Re = await Wr({
|
|
1840
1880
|
endpoint: s,
|
|
1841
1881
|
nonce: l,
|
|
1842
1882
|
clientId: r,
|
|
1843
|
-
code_challenge:
|
|
1883
|
+
code_challenge: ht
|
|
1844
1884
|
});
|
|
1845
|
-
if (
|
|
1846
|
-
const H = await
|
|
1885
|
+
if (Re.status) {
|
|
1886
|
+
const H = await $r({
|
|
1847
1887
|
endpoint: s,
|
|
1848
1888
|
username: u,
|
|
1849
|
-
password:
|
|
1889
|
+
password: S,
|
|
1850
1890
|
clientId: r,
|
|
1851
1891
|
sessionExpiration: t,
|
|
1852
1892
|
nonce: l,
|
|
1853
1893
|
type: x.CODE,
|
|
1854
|
-
code:
|
|
1855
|
-
code_verifier:
|
|
1894
|
+
code: Re.data,
|
|
1895
|
+
code_verifier: K,
|
|
1856
1896
|
domain: a,
|
|
1857
1897
|
ua: navigator.userAgent
|
|
1858
1898
|
});
|
|
1859
|
-
return H.status ? (
|
|
1899
|
+
return H.status ? (p(H.idToken), h(H.accessToken), ce(H.refreshToken), i({
|
|
1860
1900
|
type: ne,
|
|
1861
1901
|
payload: {
|
|
1862
1902
|
authenticationType: x.CODE,
|
|
@@ -1866,46 +1906,46 @@ const Jr = (e) => D(
|
|
|
1866
1906
|
email: H.email
|
|
1867
1907
|
}
|
|
1868
1908
|
}
|
|
1869
|
-
}), !0) : (j(
|
|
1909
|
+
}), !0) : (j(fe), !1);
|
|
1870
1910
|
}
|
|
1871
1911
|
return !1;
|
|
1872
|
-
},
|
|
1873
|
-
u?.preventDefault(), await
|
|
1874
|
-
},
|
|
1875
|
-
const { isAuthenticated: u, user:
|
|
1912
|
+
}, it = async (u) => {
|
|
1913
|
+
u?.preventDefault(), await N(Pr);
|
|
1914
|
+
}, ct = async () => {
|
|
1915
|
+
const { isAuthenticated: u, user: S } = o;
|
|
1876
1916
|
try {
|
|
1877
|
-
if (u &&
|
|
1878
|
-
if (
|
|
1917
|
+
if (u && S && S.userId) {
|
|
1918
|
+
if (y) {
|
|
1879
1919
|
c("getAccessToken");
|
|
1880
|
-
const
|
|
1881
|
-
if (
|
|
1882
|
-
return
|
|
1920
|
+
const K = await M(y);
|
|
1921
|
+
if (K && K.payload[g.USER_ID_KEY] !== "")
|
|
1922
|
+
return y;
|
|
1883
1923
|
}
|
|
1884
1924
|
c("getAccessToken: invalid access token, trying to refresh it");
|
|
1885
|
-
const l = await
|
|
1925
|
+
const l = await st.refreshtoken({
|
|
1886
1926
|
endpoint: s,
|
|
1887
1927
|
clientId: r,
|
|
1888
|
-
userId:
|
|
1889
|
-
nonce:
|
|
1928
|
+
userId: S.userId,
|
|
1929
|
+
nonce: nt,
|
|
1890
1930
|
domain: a
|
|
1891
1931
|
});
|
|
1892
|
-
return l.status && l.status === "success" && l.newAccessToken ? (
|
|
1932
|
+
return l.status && l.status === "success" && l.newAccessToken ? (h(l.newAccessToken), ce(l.newRefreshToken), l.newAccessToken) : (c(
|
|
1893
1933
|
"getAccessToken: invalid refresh token, need to re-authenticate"
|
|
1894
|
-
), await
|
|
1934
|
+
), await N(L), "");
|
|
1895
1935
|
}
|
|
1896
1936
|
return c(
|
|
1897
1937
|
"getAccessToken: user is not authenticated, cannot get access token"
|
|
1898
|
-
), await
|
|
1938
|
+
), await N(L), "";
|
|
1899
1939
|
} catch {
|
|
1900
1940
|
return c(
|
|
1901
1941
|
"getAccessToken: exception occurred, invalidating and logging out"
|
|
1902
|
-
), await
|
|
1942
|
+
), await N(Nr), "";
|
|
1903
1943
|
}
|
|
1904
|
-
},
|
|
1944
|
+
}, ut = () => o.isAuthenticated && d ? d : "", lt = async () => {
|
|
1905
1945
|
const { user: u } = o;
|
|
1906
|
-
let
|
|
1946
|
+
let S = await W({
|
|
1907
1947
|
endpoint: s,
|
|
1908
|
-
accessToken:
|
|
1948
|
+
accessToken: y,
|
|
1909
1949
|
clientId: r,
|
|
1910
1950
|
type: $.GET_REGISTRATION_OPTIONS,
|
|
1911
1951
|
params: {
|
|
@@ -1914,12 +1954,14 @@ const Jr = (e) => D(
|
|
|
1914
1954
|
username: u?.username
|
|
1915
1955
|
}
|
|
1916
1956
|
});
|
|
1917
|
-
if (
|
|
1957
|
+
if (S.status)
|
|
1918
1958
|
try {
|
|
1919
|
-
const l = await
|
|
1920
|
-
|
|
1959
|
+
const l = await _t({
|
|
1960
|
+
optionsJSON: S.data
|
|
1961
|
+
});
|
|
1962
|
+
return S = await W({
|
|
1921
1963
|
endpoint: s,
|
|
1922
|
-
accessToken:
|
|
1964
|
+
accessToken: y,
|
|
1923
1965
|
clientId: r,
|
|
1924
1966
|
type: $.VERIFY_REGISTRATION,
|
|
1925
1967
|
params: {
|
|
@@ -1928,11 +1970,11 @@ const Jr = (e) => D(
|
|
|
1928
1970
|
username: u?.username,
|
|
1929
1971
|
registration: l
|
|
1930
1972
|
}
|
|
1931
|
-
}), !!(
|
|
1973
|
+
}), !!(S.status && S.data.length > 0);
|
|
1932
1974
|
} catch {
|
|
1933
1975
|
return await W({
|
|
1934
1976
|
endpoint: s,
|
|
1935
|
-
accessToken:
|
|
1977
|
+
accessToken: y,
|
|
1936
1978
|
clientId: r,
|
|
1937
1979
|
type: $.VERIFY_REGISTRATION,
|
|
1938
1980
|
params: {
|
|
@@ -1944,39 +1986,41 @@ const Jr = (e) => D(
|
|
|
1944
1986
|
}), !1;
|
|
1945
1987
|
}
|
|
1946
1988
|
return !1;
|
|
1947
|
-
},
|
|
1989
|
+
}, dt = async () => {
|
|
1948
1990
|
i({ type: B, payload: { isLoading: !0 } }), Q();
|
|
1949
|
-
const u =
|
|
1950
|
-
|
|
1951
|
-
const
|
|
1991
|
+
const u = pe();
|
|
1992
|
+
Te(u), c("loginWithPasskey");
|
|
1993
|
+
const S = pe();
|
|
1952
1994
|
let l = await W({
|
|
1953
1995
|
endpoint: s,
|
|
1954
|
-
accessToken:
|
|
1996
|
+
accessToken: y,
|
|
1955
1997
|
clientId: r,
|
|
1956
1998
|
type: $.GET_AUTHENTICATION_OPTIONS,
|
|
1957
1999
|
params: {
|
|
1958
|
-
id:
|
|
2000
|
+
id: S,
|
|
1959
2001
|
clientId: r
|
|
1960
2002
|
}
|
|
1961
2003
|
});
|
|
1962
2004
|
if (l.status)
|
|
1963
2005
|
try {
|
|
1964
|
-
const
|
|
2006
|
+
const K = await vt({
|
|
2007
|
+
optionsJSON: l.data
|
|
2008
|
+
});
|
|
1965
2009
|
return l = await W({
|
|
1966
2010
|
endpoint: s,
|
|
1967
|
-
accessToken:
|
|
2011
|
+
accessToken: y,
|
|
1968
2012
|
clientId: r,
|
|
1969
2013
|
type: $.VERIFY_AUTHENTICATION,
|
|
1970
2014
|
params: {
|
|
1971
2015
|
clientId: r,
|
|
1972
|
-
id:
|
|
1973
|
-
authentication:
|
|
2016
|
+
id: S,
|
|
2017
|
+
authentication: K,
|
|
1974
2018
|
nonce: u,
|
|
1975
2019
|
domain: a,
|
|
1976
2020
|
sessionExpiration: t,
|
|
1977
2021
|
ua: navigator.userAgent
|
|
1978
2022
|
}
|
|
1979
|
-
}), l.data.status === z ? (
|
|
2023
|
+
}), l.data.status === z ? (p(l.data.idToken), h(l.data.accessToken), ce(l.data.refreshToken), i({
|
|
1980
2024
|
type: ne,
|
|
1981
2025
|
payload: {
|
|
1982
2026
|
authenticationType: x.PASSKEY,
|
|
@@ -1986,44 +2030,44 @@ const Jr = (e) => D(
|
|
|
1986
2030
|
email: l.data.email
|
|
1987
2031
|
}
|
|
1988
2032
|
}
|
|
1989
|
-
}), !0) : (j(
|
|
2033
|
+
}), !0) : (j(fe), !1);
|
|
1990
2034
|
} catch {
|
|
1991
2035
|
return await W({
|
|
1992
2036
|
endpoint: s,
|
|
1993
|
-
accessToken:
|
|
2037
|
+
accessToken: y,
|
|
1994
2038
|
clientId: r,
|
|
1995
2039
|
type: $.VERIFY_AUTHENTICATION,
|
|
1996
2040
|
params: {
|
|
1997
2041
|
clientId: r,
|
|
1998
|
-
id:
|
|
2042
|
+
id: S,
|
|
1999
2043
|
authentication: {},
|
|
2000
2044
|
nonce: u,
|
|
2001
2045
|
domain: a,
|
|
2002
2046
|
sessionExpiration: t
|
|
2003
2047
|
}
|
|
2004
|
-
}), j(
|
|
2048
|
+
}), j(fe), !1;
|
|
2005
2049
|
}
|
|
2006
2050
|
return !1;
|
|
2007
2051
|
};
|
|
2008
|
-
return /* @__PURE__ */
|
|
2009
|
-
|
|
2052
|
+
return /* @__PURE__ */ _e(Gr.Provider, { value: { state: o, dispatch: i }, children: /* @__PURE__ */ _e(
|
|
2053
|
+
rt.Provider,
|
|
2010
2054
|
{
|
|
2011
2055
|
value: {
|
|
2012
2056
|
...o,
|
|
2013
|
-
login:
|
|
2014
|
-
logout:
|
|
2015
|
-
getAccessToken:
|
|
2016
|
-
getIdToken:
|
|
2017
|
-
registeringForPasskey:
|
|
2018
|
-
loginWithPasskey:
|
|
2057
|
+
login: ot,
|
|
2058
|
+
logout: it,
|
|
2059
|
+
getAccessToken: ct,
|
|
2060
|
+
getIdToken: ut,
|
|
2061
|
+
registeringForPasskey: lt,
|
|
2062
|
+
loginWithPasskey: dt
|
|
2019
2063
|
},
|
|
2020
2064
|
children: e
|
|
2021
2065
|
}
|
|
2022
2066
|
) });
|
|
2023
|
-
},
|
|
2067
|
+
}, Qr = (e = rt) => St(e);
|
|
2024
2068
|
export {
|
|
2025
2069
|
x as AUTH_TYPES,
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2070
|
+
zr as AuthProvider,
|
|
2071
|
+
qr as isGranted,
|
|
2072
|
+
Qr as useAuth
|
|
2029
2073
|
};
|