@absolutejs/auth 0.56.18 → 0.57.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/agents/index.js +44 -37
- package/dist/agents/index.js.map +7 -7
- package/dist/audit/postgresAuditStore.d.ts +1 -1
- package/dist/audit/types.d.ts +2 -0
- package/dist/audit/wrap.d.ts +4 -2
- package/dist/cli/import/auth0.d.ts +1 -1
- package/dist/cli/import/clerk.d.ts +1 -1
- package/dist/cli/import/lucia.d.ts +1 -1
- package/dist/cli/import/nextauth.d.ts +1 -1
- package/dist/cli/import/types.d.ts +1 -0
- package/dist/cli/migrate.js +91 -47
- package/dist/cli/migrate.js.map +14 -13
- package/dist/client/createAuthClient.d.ts +3 -2
- package/dist/client/index.js +9 -498
- package/dist/client/index.js.map +5 -20
- package/dist/client/react.d.ts +21 -21
- package/dist/client/react.js +40 -531
- package/dist/client/react.js.map +8 -23
- package/dist/client/solid.d.ts +21 -21
- package/dist/client/solid.js +29 -518
- package/dist/client/solid.js.map +5 -20
- package/dist/client/svelte.d.ts +21 -21
- package/dist/client/svelte.js +30 -519
- package/dist/client/svelte.js.map +5 -20
- package/dist/client/vue.d.ts +21 -21
- package/dist/client/vue.js +37 -526
- package/dist/client/vue.js.map +5 -20
- package/dist/credentials/import.d.ts +16 -1
- package/dist/credentials/register.d.ts +1 -1
- package/dist/credentials/routes.d.ts +1 -1
- package/dist/fingerprint-client/index.js +4 -3
- package/dist/fingerprint-client/index.js.map +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +6416 -262
- package/dist/index.js.map +166 -26
- package/dist/manifest.js +343 -2674
- package/dist/manifest.js.map +57 -31
- package/dist/manifest.json +3 -2
- package/dist/oidc/clientIdMetadata.d.ts +1 -5
- package/dist/oidc/index.js.map +2 -2
- package/dist/oidc/vci.d.ts +1 -1
- package/dist/routes/callback.d.ts +1 -1
- package/dist/server.js +6412 -261
- package/dist/server.js.map +166 -26
- package/dist/session/neonStore.d.ts +2 -2
- package/dist/session/redisStore.d.ts +2 -2
- package/dist/session/types.d.ts +2 -0
- package/dist/stores/postgres.d.ts +2 -2
- package/dist/types.d.ts +2 -1
- package/dist/vault/index.js.map +2 -2
- package/dist/webauthn.js +27 -1
- package/dist/webauthn.js.map +3 -3
- package/docs/MIGRATE-FROM-LUCIA.md +19 -2
- package/package.json +15 -6
package/dist/client/react.js
CHANGED
|
@@ -46,500 +46,11 @@ var __export = (target, all) => {
|
|
|
46
46
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
47
47
|
var __require = import.meta.require;
|
|
48
48
|
|
|
49
|
-
// node_modules/@simplewebauthn/browser/esm/helpers/bufferToBase64URLString.js
|
|
50
|
-
function bufferToBase64URLString(buffer) {
|
|
51
|
-
const bytes = new Uint8Array(buffer);
|
|
52
|
-
let str = "";
|
|
53
|
-
for (const charCode of bytes) {
|
|
54
|
-
str += String.fromCharCode(charCode);
|
|
55
|
-
}
|
|
56
|
-
const base64String = btoa(str);
|
|
57
|
-
return base64String.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// node_modules/@simplewebauthn/browser/esm/helpers/base64URLStringToBuffer.js
|
|
61
|
-
function base64URLStringToBuffer(base64URLString) {
|
|
62
|
-
const base64 = base64URLString.replace(/-/g, "+").replace(/_/g, "/");
|
|
63
|
-
const padLength = (4 - base64.length % 4) % 4;
|
|
64
|
-
const padded = base64.padEnd(base64.length + padLength, "=");
|
|
65
|
-
const binary = atob(padded);
|
|
66
|
-
const buffer = new ArrayBuffer(binary.length);
|
|
67
|
-
const bytes = new Uint8Array(buffer);
|
|
68
|
-
for (let i = 0;i < binary.length; i++) {
|
|
69
|
-
bytes[i] = binary.charCodeAt(i);
|
|
70
|
-
}
|
|
71
|
-
return buffer;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// node_modules/@simplewebauthn/browser/esm/helpers/browserSupportsWebAuthn.js
|
|
75
|
-
function browserSupportsWebAuthn() {
|
|
76
|
-
return _browserSupportsWebAuthnInternals.stubThis(globalThis?.PublicKeyCredential !== undefined && typeof globalThis.PublicKeyCredential === "function");
|
|
77
|
-
}
|
|
78
|
-
var _browserSupportsWebAuthnInternals;
|
|
79
|
-
var init_browserSupportsWebAuthn = __esm(() => {
|
|
80
|
-
_browserSupportsWebAuthnInternals = {
|
|
81
|
-
stubThis: (value) => value
|
|
82
|
-
};
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
// node_modules/@simplewebauthn/browser/esm/helpers/toPublicKeyCredentialDescriptor.js
|
|
86
|
-
function toPublicKeyCredentialDescriptor(descriptor) {
|
|
87
|
-
const { id } = descriptor;
|
|
88
|
-
return {
|
|
89
|
-
...descriptor,
|
|
90
|
-
id: base64URLStringToBuffer(id),
|
|
91
|
-
transports: descriptor.transports
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
var init_toPublicKeyCredentialDescriptor = () => {};
|
|
95
|
-
|
|
96
|
-
// node_modules/@simplewebauthn/browser/esm/helpers/isValidDomain.js
|
|
97
|
-
function isValidDomain(hostname) {
|
|
98
|
-
return hostname === "localhost" || /^((xn--[a-z0-9-]+|[a-z0-9]+(-[a-z0-9]+)*)\.)+([a-z]{2,}|xn--[a-z0-9-]+)$/i.test(hostname);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// node_modules/@simplewebauthn/browser/esm/helpers/webAuthnError.js
|
|
102
|
-
var WebAuthnError;
|
|
103
|
-
var init_webAuthnError = __esm(() => {
|
|
104
|
-
WebAuthnError = class WebAuthnError extends Error {
|
|
105
|
-
constructor({ message, code, cause, name }) {
|
|
106
|
-
super(message, { cause });
|
|
107
|
-
Object.defineProperty(this, "code", {
|
|
108
|
-
enumerable: true,
|
|
109
|
-
configurable: true,
|
|
110
|
-
writable: true,
|
|
111
|
-
value: undefined
|
|
112
|
-
});
|
|
113
|
-
this.name = name ?? cause.name;
|
|
114
|
-
this.code = code;
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
// node_modules/@simplewebauthn/browser/esm/helpers/identifyRegistrationError.js
|
|
120
|
-
function identifyRegistrationError({ error, options }) {
|
|
121
|
-
const { publicKey } = options;
|
|
122
|
-
if (!publicKey) {
|
|
123
|
-
throw Error("options was missing required publicKey property");
|
|
124
|
-
}
|
|
125
|
-
if (error.name === "AbortError") {
|
|
126
|
-
if (options.signal instanceof AbortSignal) {
|
|
127
|
-
return new WebAuthnError({
|
|
128
|
-
message: "Registration ceremony was sent an abort signal",
|
|
129
|
-
code: "ERROR_CEREMONY_ABORTED",
|
|
130
|
-
cause: error
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
} else if (error.name === "ConstraintError") {
|
|
134
|
-
if (publicKey.authenticatorSelection?.requireResidentKey === true) {
|
|
135
|
-
return new WebAuthnError({
|
|
136
|
-
message: "Discoverable credentials were required but no available authenticator supported it",
|
|
137
|
-
code: "ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",
|
|
138
|
-
cause: error
|
|
139
|
-
});
|
|
140
|
-
} else if (options.mediation === "conditional" && publicKey.authenticatorSelection?.userVerification === "required") {
|
|
141
|
-
return new WebAuthnError({
|
|
142
|
-
message: "User verification was required during automatic registration but it could not be performed",
|
|
143
|
-
code: "ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",
|
|
144
|
-
cause: error
|
|
145
|
-
});
|
|
146
|
-
} else if (publicKey.authenticatorSelection?.userVerification === "required") {
|
|
147
|
-
return new WebAuthnError({
|
|
148
|
-
message: "User verification was required but no available authenticator supported it",
|
|
149
|
-
code: "ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",
|
|
150
|
-
cause: error
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
} else if (error.name === "InvalidStateError") {
|
|
154
|
-
return new WebAuthnError({
|
|
155
|
-
message: "The authenticator was previously registered",
|
|
156
|
-
code: "ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",
|
|
157
|
-
cause: error
|
|
158
|
-
});
|
|
159
|
-
} else if (error.name === "NotAllowedError") {
|
|
160
|
-
return new WebAuthnError({
|
|
161
|
-
message: error.message,
|
|
162
|
-
code: "ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",
|
|
163
|
-
cause: error
|
|
164
|
-
});
|
|
165
|
-
} else if (error.name === "NotSupportedError") {
|
|
166
|
-
const validPubKeyCredParams = publicKey.pubKeyCredParams.filter((param) => param.type === "public-key");
|
|
167
|
-
if (validPubKeyCredParams.length === 0) {
|
|
168
|
-
return new WebAuthnError({
|
|
169
|
-
message: 'No entry in pubKeyCredParams was of type "public-key"',
|
|
170
|
-
code: "ERROR_MALFORMED_PUBKEYCREDPARAMS",
|
|
171
|
-
cause: error
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
return new WebAuthnError({
|
|
175
|
-
message: "No available authenticator supported any of the specified pubKeyCredParams algorithms",
|
|
176
|
-
code: "ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",
|
|
177
|
-
cause: error
|
|
178
|
-
});
|
|
179
|
-
} else if (error.name === "SecurityError") {
|
|
180
|
-
const effectiveDomain = globalThis.location.hostname;
|
|
181
|
-
if (!isValidDomain(effectiveDomain)) {
|
|
182
|
-
return new WebAuthnError({
|
|
183
|
-
message: `${globalThis.location.hostname} is an invalid domain`,
|
|
184
|
-
code: "ERROR_INVALID_DOMAIN",
|
|
185
|
-
cause: error
|
|
186
|
-
});
|
|
187
|
-
} else if (publicKey.rp.id !== effectiveDomain) {
|
|
188
|
-
return new WebAuthnError({
|
|
189
|
-
message: `The RP ID "${publicKey.rp.id}" is invalid for this domain`,
|
|
190
|
-
code: "ERROR_INVALID_RP_ID",
|
|
191
|
-
cause: error
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
} else if (error.name === "TypeError") {
|
|
195
|
-
if (publicKey.user.id.byteLength < 1 || publicKey.user.id.byteLength > 64) {
|
|
196
|
-
return new WebAuthnError({
|
|
197
|
-
message: "User ID was not between 1 and 64 characters",
|
|
198
|
-
code: "ERROR_INVALID_USER_ID_LENGTH",
|
|
199
|
-
cause: error
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
} else if (error.name === "UnknownError") {
|
|
203
|
-
return new WebAuthnError({
|
|
204
|
-
message: "The authenticator was unable to process the specified options, or could not create a new credential",
|
|
205
|
-
code: "ERROR_AUTHENTICATOR_GENERAL_ERROR",
|
|
206
|
-
cause: error
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
return error;
|
|
210
|
-
}
|
|
211
|
-
var init_identifyRegistrationError = __esm(() => {
|
|
212
|
-
init_webAuthnError();
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
// node_modules/@simplewebauthn/browser/esm/helpers/webAuthnAbortService.js
|
|
216
|
-
class BaseWebAuthnAbortService {
|
|
217
|
-
constructor() {
|
|
218
|
-
Object.defineProperty(this, "controller", {
|
|
219
|
-
enumerable: true,
|
|
220
|
-
configurable: true,
|
|
221
|
-
writable: true,
|
|
222
|
-
value: undefined
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
createNewAbortSignal() {
|
|
226
|
-
if (this.controller) {
|
|
227
|
-
const abortError = new Error("Cancelling existing WebAuthn API call for new one");
|
|
228
|
-
abortError.name = "AbortError";
|
|
229
|
-
this.controller.abort(abortError);
|
|
230
|
-
}
|
|
231
|
-
const newController = new AbortController;
|
|
232
|
-
this.controller = newController;
|
|
233
|
-
return newController.signal;
|
|
234
|
-
}
|
|
235
|
-
cancelCeremony() {
|
|
236
|
-
if (this.controller) {
|
|
237
|
-
const abortError = new Error("Manually cancelling existing WebAuthn API call");
|
|
238
|
-
abortError.name = "AbortError";
|
|
239
|
-
this.controller.abort(abortError);
|
|
240
|
-
this.controller = undefined;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
var WebAuthnAbortService;
|
|
245
|
-
var init_webAuthnAbortService = __esm(() => {
|
|
246
|
-
WebAuthnAbortService = new BaseWebAuthnAbortService;
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
// node_modules/@simplewebauthn/browser/esm/helpers/toAuthenticatorAttachment.js
|
|
250
|
-
function toAuthenticatorAttachment(attachment) {
|
|
251
|
-
if (!attachment) {
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
if (attachments.indexOf(attachment) < 0) {
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
return attachment;
|
|
258
|
-
}
|
|
259
|
-
var attachments;
|
|
260
|
-
var init_toAuthenticatorAttachment = __esm(() => {
|
|
261
|
-
attachments = ["cross-platform", "platform"];
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
// node_modules/@simplewebauthn/browser/esm/methods/startRegistration.js
|
|
265
|
-
async function startRegistration(options) {
|
|
266
|
-
if (!options.optionsJSON && options.challenge) {
|
|
267
|
-
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.");
|
|
268
|
-
options = { optionsJSON: options };
|
|
269
|
-
}
|
|
270
|
-
const { optionsJSON, useAutoRegister = false } = options;
|
|
271
|
-
if (!browserSupportsWebAuthn()) {
|
|
272
|
-
throw new Error("WebAuthn is not supported in this browser");
|
|
273
|
-
}
|
|
274
|
-
const publicKey = {
|
|
275
|
-
...optionsJSON,
|
|
276
|
-
challenge: base64URLStringToBuffer(optionsJSON.challenge),
|
|
277
|
-
user: {
|
|
278
|
-
...optionsJSON.user,
|
|
279
|
-
id: base64URLStringToBuffer(optionsJSON.user.id)
|
|
280
|
-
},
|
|
281
|
-
excludeCredentials: optionsJSON.excludeCredentials?.map(toPublicKeyCredentialDescriptor)
|
|
282
|
-
};
|
|
283
|
-
const createOptions = {};
|
|
284
|
-
if (useAutoRegister) {
|
|
285
|
-
createOptions.mediation = "conditional";
|
|
286
|
-
}
|
|
287
|
-
createOptions.publicKey = publicKey;
|
|
288
|
-
createOptions.signal = WebAuthnAbortService.createNewAbortSignal();
|
|
289
|
-
let credential;
|
|
290
|
-
try {
|
|
291
|
-
credential = await navigator.credentials.create(createOptions);
|
|
292
|
-
} catch (err) {
|
|
293
|
-
throw identifyRegistrationError({ error: err, options: createOptions });
|
|
294
|
-
}
|
|
295
|
-
if (!credential) {
|
|
296
|
-
throw new Error("Registration was not completed");
|
|
297
|
-
}
|
|
298
|
-
const { id, rawId, response, type } = credential;
|
|
299
|
-
let transports = undefined;
|
|
300
|
-
if (typeof response.getTransports === "function") {
|
|
301
|
-
transports = response.getTransports();
|
|
302
|
-
}
|
|
303
|
-
let responsePublicKeyAlgorithm = undefined;
|
|
304
|
-
if (typeof response.getPublicKeyAlgorithm === "function") {
|
|
305
|
-
try {
|
|
306
|
-
responsePublicKeyAlgorithm = response.getPublicKeyAlgorithm();
|
|
307
|
-
} catch (error) {
|
|
308
|
-
warnOnBrokenImplementation("getPublicKeyAlgorithm()", error);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
let responsePublicKey = undefined;
|
|
312
|
-
if (typeof response.getPublicKey === "function") {
|
|
313
|
-
try {
|
|
314
|
-
const _publicKey = response.getPublicKey();
|
|
315
|
-
if (_publicKey !== null) {
|
|
316
|
-
responsePublicKey = bufferToBase64URLString(_publicKey);
|
|
317
|
-
}
|
|
318
|
-
} catch (error) {
|
|
319
|
-
warnOnBrokenImplementation("getPublicKey()", error);
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
let responseAuthenticatorData;
|
|
323
|
-
if (typeof response.getAuthenticatorData === "function") {
|
|
324
|
-
try {
|
|
325
|
-
responseAuthenticatorData = bufferToBase64URLString(response.getAuthenticatorData());
|
|
326
|
-
} catch (error) {
|
|
327
|
-
warnOnBrokenImplementation("getAuthenticatorData()", error);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
return {
|
|
331
|
-
id,
|
|
332
|
-
rawId: bufferToBase64URLString(rawId),
|
|
333
|
-
response: {
|
|
334
|
-
attestationObject: bufferToBase64URLString(response.attestationObject),
|
|
335
|
-
clientDataJSON: bufferToBase64URLString(response.clientDataJSON),
|
|
336
|
-
transports,
|
|
337
|
-
publicKeyAlgorithm: responsePublicKeyAlgorithm,
|
|
338
|
-
publicKey: responsePublicKey,
|
|
339
|
-
authenticatorData: responseAuthenticatorData
|
|
340
|
-
},
|
|
341
|
-
type,
|
|
342
|
-
clientExtensionResults: credential.getClientExtensionResults(),
|
|
343
|
-
authenticatorAttachment: toAuthenticatorAttachment(credential.authenticatorAttachment)
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
function warnOnBrokenImplementation(methodName, cause) {
|
|
347
|
-
console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${methodName}. You should report this error to them.
|
|
348
|
-
`, cause);
|
|
349
|
-
}
|
|
350
|
-
var init_startRegistration = __esm(() => {
|
|
351
|
-
init_browserSupportsWebAuthn();
|
|
352
|
-
init_toPublicKeyCredentialDescriptor();
|
|
353
|
-
init_identifyRegistrationError();
|
|
354
|
-
init_webAuthnAbortService();
|
|
355
|
-
init_toAuthenticatorAttachment();
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
// node_modules/@simplewebauthn/browser/esm/helpers/browserSupportsWebAuthnAutofill.js
|
|
359
|
-
function browserSupportsWebAuthnAutofill() {
|
|
360
|
-
if (!browserSupportsWebAuthn()) {
|
|
361
|
-
return _browserSupportsWebAuthnAutofillInternals.stubThis(new Promise((resolve) => resolve(false)));
|
|
362
|
-
}
|
|
363
|
-
const globalPublicKeyCredential = globalThis.PublicKeyCredential;
|
|
364
|
-
if (globalPublicKeyCredential?.isConditionalMediationAvailable === undefined) {
|
|
365
|
-
return _browserSupportsWebAuthnAutofillInternals.stubThis(new Promise((resolve) => resolve(false)));
|
|
366
|
-
}
|
|
367
|
-
return _browserSupportsWebAuthnAutofillInternals.stubThis(globalPublicKeyCredential.isConditionalMediationAvailable());
|
|
368
|
-
}
|
|
369
|
-
var _browserSupportsWebAuthnAutofillInternals;
|
|
370
|
-
var init_browserSupportsWebAuthnAutofill = __esm(() => {
|
|
371
|
-
init_browserSupportsWebAuthn();
|
|
372
|
-
_browserSupportsWebAuthnAutofillInternals = {
|
|
373
|
-
stubThis: (value) => value
|
|
374
|
-
};
|
|
375
|
-
});
|
|
376
|
-
|
|
377
|
-
// node_modules/@simplewebauthn/browser/esm/helpers/identifyAuthenticationError.js
|
|
378
|
-
function identifyAuthenticationError({ error, options }) {
|
|
379
|
-
const { publicKey } = options;
|
|
380
|
-
if (!publicKey) {
|
|
381
|
-
throw Error("options was missing required publicKey property");
|
|
382
|
-
}
|
|
383
|
-
if (error.name === "AbortError") {
|
|
384
|
-
if (options.signal instanceof AbortSignal) {
|
|
385
|
-
return new WebAuthnError({
|
|
386
|
-
message: "Authentication ceremony was sent an abort signal",
|
|
387
|
-
code: "ERROR_CEREMONY_ABORTED",
|
|
388
|
-
cause: error
|
|
389
|
-
});
|
|
390
|
-
}
|
|
391
|
-
} else if (error.name === "NotAllowedError") {
|
|
392
|
-
return new WebAuthnError({
|
|
393
|
-
message: error.message,
|
|
394
|
-
code: "ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",
|
|
395
|
-
cause: error
|
|
396
|
-
});
|
|
397
|
-
} else if (error.name === "SecurityError") {
|
|
398
|
-
const effectiveDomain = globalThis.location.hostname;
|
|
399
|
-
if (!isValidDomain(effectiveDomain)) {
|
|
400
|
-
return new WebAuthnError({
|
|
401
|
-
message: `${globalThis.location.hostname} is an invalid domain`,
|
|
402
|
-
code: "ERROR_INVALID_DOMAIN",
|
|
403
|
-
cause: error
|
|
404
|
-
});
|
|
405
|
-
} else if (publicKey.rpId !== effectiveDomain) {
|
|
406
|
-
return new WebAuthnError({
|
|
407
|
-
message: `The RP ID "${publicKey.rpId}" is invalid for this domain`,
|
|
408
|
-
code: "ERROR_INVALID_RP_ID",
|
|
409
|
-
cause: error
|
|
410
|
-
});
|
|
411
|
-
}
|
|
412
|
-
} else if (error.name === "UnknownError") {
|
|
413
|
-
return new WebAuthnError({
|
|
414
|
-
message: "The authenticator was unable to process the specified options, or could not create a new assertion signature",
|
|
415
|
-
code: "ERROR_AUTHENTICATOR_GENERAL_ERROR",
|
|
416
|
-
cause: error
|
|
417
|
-
});
|
|
418
|
-
}
|
|
419
|
-
return error;
|
|
420
|
-
}
|
|
421
|
-
var init_identifyAuthenticationError = __esm(() => {
|
|
422
|
-
init_webAuthnError();
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
// node_modules/@simplewebauthn/browser/esm/methods/startAuthentication.js
|
|
426
|
-
async function startAuthentication(options) {
|
|
427
|
-
if (!options.optionsJSON && options.challenge) {
|
|
428
|
-
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.");
|
|
429
|
-
options = { optionsJSON: options };
|
|
430
|
-
}
|
|
431
|
-
const { optionsJSON, useBrowserAutofill = false, verifyBrowserAutofillInput = true } = options;
|
|
432
|
-
if (!browserSupportsWebAuthn()) {
|
|
433
|
-
throw new Error("WebAuthn is not supported in this browser");
|
|
434
|
-
}
|
|
435
|
-
let allowCredentials;
|
|
436
|
-
if (optionsJSON.allowCredentials?.length !== 0) {
|
|
437
|
-
allowCredentials = optionsJSON.allowCredentials?.map(toPublicKeyCredentialDescriptor);
|
|
438
|
-
}
|
|
439
|
-
const publicKey = {
|
|
440
|
-
...optionsJSON,
|
|
441
|
-
challenge: base64URLStringToBuffer(optionsJSON.challenge),
|
|
442
|
-
allowCredentials
|
|
443
|
-
};
|
|
444
|
-
const getOptions = {};
|
|
445
|
-
if (useBrowserAutofill) {
|
|
446
|
-
if (!await browserSupportsWebAuthnAutofill()) {
|
|
447
|
-
throw Error("Browser does not support WebAuthn autofill");
|
|
448
|
-
}
|
|
449
|
-
const eligibleInputs = document.querySelectorAll("input[autocomplete$='webauthn']");
|
|
450
|
-
if (eligibleInputs.length < 1 && verifyBrowserAutofillInput) {
|
|
451
|
-
throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');
|
|
452
|
-
}
|
|
453
|
-
getOptions.mediation = "conditional";
|
|
454
|
-
publicKey.allowCredentials = [];
|
|
455
|
-
}
|
|
456
|
-
getOptions.publicKey = publicKey;
|
|
457
|
-
getOptions.signal = WebAuthnAbortService.createNewAbortSignal();
|
|
458
|
-
let credential;
|
|
459
|
-
try {
|
|
460
|
-
credential = await navigator.credentials.get(getOptions);
|
|
461
|
-
} catch (err) {
|
|
462
|
-
throw identifyAuthenticationError({ error: err, options: getOptions });
|
|
463
|
-
}
|
|
464
|
-
if (!credential) {
|
|
465
|
-
throw new Error("Authentication was not completed");
|
|
466
|
-
}
|
|
467
|
-
const { id, rawId, response, type } = credential;
|
|
468
|
-
let userHandle = undefined;
|
|
469
|
-
if (response.userHandle) {
|
|
470
|
-
userHandle = bufferToBase64URLString(response.userHandle);
|
|
471
|
-
}
|
|
472
|
-
return {
|
|
473
|
-
id,
|
|
474
|
-
rawId: bufferToBase64URLString(rawId),
|
|
475
|
-
response: {
|
|
476
|
-
authenticatorData: bufferToBase64URLString(response.authenticatorData),
|
|
477
|
-
clientDataJSON: bufferToBase64URLString(response.clientDataJSON),
|
|
478
|
-
signature: bufferToBase64URLString(response.signature),
|
|
479
|
-
userHandle
|
|
480
|
-
},
|
|
481
|
-
type,
|
|
482
|
-
clientExtensionResults: credential.getClientExtensionResults(),
|
|
483
|
-
authenticatorAttachment: toAuthenticatorAttachment(credential.authenticatorAttachment)
|
|
484
|
-
};
|
|
485
|
-
}
|
|
486
|
-
var init_startAuthentication = __esm(() => {
|
|
487
|
-
init_browserSupportsWebAuthn();
|
|
488
|
-
init_browserSupportsWebAuthnAutofill();
|
|
489
|
-
init_toPublicKeyCredentialDescriptor();
|
|
490
|
-
init_identifyAuthenticationError();
|
|
491
|
-
init_webAuthnAbortService();
|
|
492
|
-
init_toAuthenticatorAttachment();
|
|
493
|
-
});
|
|
494
|
-
|
|
495
|
-
// node_modules/@simplewebauthn/browser/esm/helpers/platformAuthenticatorIsAvailable.js
|
|
496
|
-
function platformAuthenticatorIsAvailable() {
|
|
497
|
-
if (!browserSupportsWebAuthn()) {
|
|
498
|
-
return new Promise((resolve) => resolve(false));
|
|
499
|
-
}
|
|
500
|
-
return PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable();
|
|
501
|
-
}
|
|
502
|
-
var init_platformAuthenticatorIsAvailable = __esm(() => {
|
|
503
|
-
init_browserSupportsWebAuthn();
|
|
504
|
-
});
|
|
505
|
-
|
|
506
|
-
// node_modules/@simplewebauthn/browser/esm/types/index.js
|
|
507
|
-
var init_types = () => {};
|
|
508
|
-
|
|
509
|
-
// node_modules/@simplewebauthn/browser/esm/index.js
|
|
510
|
-
var exports_esm = {};
|
|
511
|
-
__export(exports_esm, {
|
|
512
|
-
startRegistration: () => startRegistration,
|
|
513
|
-
startAuthentication: () => startAuthentication,
|
|
514
|
-
platformAuthenticatorIsAvailable: () => platformAuthenticatorIsAvailable,
|
|
515
|
-
bufferToBase64URLString: () => bufferToBase64URLString,
|
|
516
|
-
browserSupportsWebAuthnAutofill: () => browserSupportsWebAuthnAutofill,
|
|
517
|
-
browserSupportsWebAuthn: () => browserSupportsWebAuthn,
|
|
518
|
-
base64URLStringToBuffer: () => base64URLStringToBuffer,
|
|
519
|
-
_browserSupportsWebAuthnInternals: () => _browserSupportsWebAuthnInternals,
|
|
520
|
-
_browserSupportsWebAuthnAutofillInternals: () => _browserSupportsWebAuthnAutofillInternals,
|
|
521
|
-
WebAuthnError: () => WebAuthnError,
|
|
522
|
-
WebAuthnAbortService: () => WebAuthnAbortService
|
|
523
|
-
});
|
|
524
|
-
var init_esm = __esm(() => {
|
|
525
|
-
init_startRegistration();
|
|
526
|
-
init_startAuthentication();
|
|
527
|
-
init_browserSupportsWebAuthn();
|
|
528
|
-
init_platformAuthenticatorIsAvailable();
|
|
529
|
-
init_browserSupportsWebAuthnAutofill();
|
|
530
|
-
init_webAuthnAbortService();
|
|
531
|
-
init_webAuthnError();
|
|
532
|
-
init_types();
|
|
533
|
-
});
|
|
534
|
-
|
|
535
49
|
// src/client/react.ts
|
|
536
50
|
import { useCallback, useEffect, useRef, useState as useState4 } from "react";
|
|
537
51
|
|
|
538
52
|
// src/client/passkeyHelpers.ts
|
|
539
|
-
var loadBrowser =
|
|
540
|
-
const mod = await Promise.resolve().then(() => (init_esm(), exports_esm));
|
|
541
|
-
return mod;
|
|
542
|
-
};
|
|
53
|
+
var loadBrowser = () => import("@simplewebauthn/browser");
|
|
543
54
|
var errorFor = (caught) => ({
|
|
544
55
|
body: null,
|
|
545
56
|
message: caught instanceof Error ? caught.message : "webauthn_failed",
|
|
@@ -556,8 +67,8 @@ var runConditionalAuthentication = async (client) => {
|
|
|
556
67
|
if (options.error)
|
|
557
68
|
return { data: null, error: options.error };
|
|
558
69
|
try {
|
|
559
|
-
const { startAuthentication
|
|
560
|
-
const credential = await
|
|
70
|
+
const { startAuthentication } = await loadBrowser();
|
|
71
|
+
const credential = await startAuthentication({
|
|
561
72
|
optionsJSON: options.data,
|
|
562
73
|
useBrowserAutofill: true
|
|
563
74
|
});
|
|
@@ -577,8 +88,8 @@ var runPasskeyRegistration = async (client) => {
|
|
|
577
88
|
if (options.error)
|
|
578
89
|
return { data: null, error: options.error };
|
|
579
90
|
try {
|
|
580
|
-
const { startRegistration
|
|
581
|
-
const credential = await
|
|
91
|
+
const { startRegistration } = await loadBrowser();
|
|
92
|
+
const credential = await startRegistration({
|
|
582
93
|
optionsJSON: options.data
|
|
583
94
|
});
|
|
584
95
|
return client.passkeys.registerVerify(credential);
|
|
@@ -588,8 +99,7 @@ var runPasskeyRegistration = async (client) => {
|
|
|
588
99
|
};
|
|
589
100
|
|
|
590
101
|
// src/client/components/react/SignIn.ts
|
|
591
|
-
import { createElement } from "react";
|
|
592
|
-
import { useState } from "react";
|
|
102
|
+
import { createElement, useState } from "react";
|
|
593
103
|
var SignIn = ({
|
|
594
104
|
client,
|
|
595
105
|
classNames,
|
|
@@ -638,19 +148,19 @@ var SignIn = ({
|
|
|
638
148
|
autoComplete: "username webauthn",
|
|
639
149
|
className: classNames?.input,
|
|
640
150
|
name: "email",
|
|
641
|
-
onChange: (event) => setEmail(event.currentTarget.value),
|
|
642
151
|
required: true,
|
|
643
152
|
type: "email",
|
|
644
|
-
value: email
|
|
153
|
+
value: email,
|
|
154
|
+
onChange: (event) => setEmail(event.currentTarget.value)
|
|
645
155
|
})), createElement("label", { className: classNames?.field, "data-abs-auth": "password-field" }, createElement("span", { className: classNames?.label }, passwordLabel), createElement("input", {
|
|
646
156
|
autoComplete: "current-password",
|
|
647
157
|
className: classNames?.input,
|
|
648
158
|
minLength: 12,
|
|
649
159
|
name: "password",
|
|
650
|
-
onChange: (event) => setPassword(event.currentTarget.value),
|
|
651
160
|
required: true,
|
|
652
161
|
type: "password",
|
|
653
|
-
value: password
|
|
162
|
+
value: password,
|
|
163
|
+
onChange: (event) => setPassword(event.currentTarget.value)
|
|
654
164
|
})), errorBanner, createElement("button", {
|
|
655
165
|
className: classNames?.button,
|
|
656
166
|
"data-abs-auth": "submit",
|
|
@@ -659,8 +169,7 @@ var SignIn = ({
|
|
|
659
169
|
}, isPending ? "Signing in\u2026" : submitLabel));
|
|
660
170
|
};
|
|
661
171
|
// src/client/components/react/SignUp.ts
|
|
662
|
-
import { createElement as createElement2 } from "react";
|
|
663
|
-
import { useState as useState2 } from "react";
|
|
172
|
+
import { createElement as createElement2, useState as useState2 } from "react";
|
|
664
173
|
var SignUp = ({
|
|
665
174
|
client,
|
|
666
175
|
classNames,
|
|
@@ -696,19 +205,19 @@ var SignUp = ({
|
|
|
696
205
|
autoComplete: "email",
|
|
697
206
|
className: classNames?.input,
|
|
698
207
|
name: "email",
|
|
699
|
-
onChange: (event) => setEmail(event.currentTarget.value),
|
|
700
208
|
required: true,
|
|
701
209
|
type: "email",
|
|
702
|
-
value: email
|
|
210
|
+
value: email,
|
|
211
|
+
onChange: (event) => setEmail(event.currentTarget.value)
|
|
703
212
|
})), createElement2("label", { className: classNames?.field, "data-abs-auth": "password-field" }, createElement2("span", { className: classNames?.label }, passwordLabel), createElement2("input", {
|
|
704
213
|
autoComplete: "new-password",
|
|
705
214
|
className: classNames?.input,
|
|
706
215
|
minLength: 12,
|
|
707
216
|
name: "password",
|
|
708
|
-
onChange: (event) => setPassword(event.currentTarget.value),
|
|
709
217
|
required: true,
|
|
710
218
|
type: "password",
|
|
711
|
-
value: password
|
|
219
|
+
value: password,
|
|
220
|
+
onChange: (event) => setPassword(event.currentTarget.value)
|
|
712
221
|
})), errorBanner, createElement2("button", {
|
|
713
222
|
className: classNames?.button,
|
|
714
223
|
"data-abs-auth": "submit",
|
|
@@ -751,12 +260,12 @@ var UserButton = ({
|
|
|
751
260
|
}, item.label)), createElement3("button", {
|
|
752
261
|
className: classNames?.signOut,
|
|
753
262
|
"data-abs-auth": "sign-out",
|
|
263
|
+
type: "button",
|
|
754
264
|
onClick: async () => {
|
|
755
265
|
await mutate(undefined);
|
|
756
266
|
setOpen(false);
|
|
757
267
|
onSignOut?.();
|
|
758
|
-
}
|
|
759
|
-
type: "button"
|
|
268
|
+
}
|
|
760
269
|
}, signOutLabel)) : null;
|
|
761
270
|
const avatar = user.avatarUrl === undefined ? createElement3("span", {
|
|
762
271
|
className: classNames?.avatar,
|
|
@@ -775,8 +284,8 @@ var UserButton = ({
|
|
|
775
284
|
"aria-expanded": open,
|
|
776
285
|
className: classNames?.toggle,
|
|
777
286
|
"data-abs-auth": "user-toggle",
|
|
778
|
-
|
|
779
|
-
|
|
287
|
+
type: "button",
|
|
288
|
+
onClick: () => setOpen((prev) => !prev)
|
|
780
289
|
}, avatar, createElement3("span", { className: classNames?.email, "data-abs-auth": "user-email" }, user.givenName ?? user.email ?? "Account")), menu);
|
|
781
290
|
};
|
|
782
291
|
|
|
@@ -808,6 +317,7 @@ var useMutation = (run) => {
|
|
|
808
317
|
return { data, error, isPending, mutate, reset };
|
|
809
318
|
};
|
|
810
319
|
var useMagicLink = (client) => useMutation(client.passwordless.requestMagicLink);
|
|
320
|
+
var useMfaChallenge = (client) => useMutation(client.mfa.challenge);
|
|
811
321
|
var usePasskeyAutofill = (client) => {
|
|
812
322
|
const [data, setData] = useState4(null);
|
|
813
323
|
const [error, setError] = useState4(null);
|
|
@@ -831,8 +341,9 @@ var usePasskeyAutofill = (client) => {
|
|
|
831
341
|
}, []);
|
|
832
342
|
return { cancel, data, error, isPending, start };
|
|
833
343
|
};
|
|
834
|
-
var
|
|
835
|
-
|
|
344
|
+
var usePasswordReset = (client) => useMutation(client.passwordReset.request);
|
|
345
|
+
var useSessions = (client) => {
|
|
346
|
+
const [data, setData] = useState4(null);
|
|
836
347
|
const [error, setError] = useState4(null);
|
|
837
348
|
const [isPending, setIsPending] = useState4(true);
|
|
838
349
|
const mountedRef = useRef(true);
|
|
@@ -841,9 +352,9 @@ var useUpgradeToPasskey = (client) => {
|
|
|
841
352
|
}, []);
|
|
842
353
|
const refetch = useCallback(async () => {
|
|
843
354
|
setIsPending(true);
|
|
844
|
-
const result = await client.
|
|
355
|
+
const result = await client.sessions.list();
|
|
845
356
|
if (mountedRef.current) {
|
|
846
|
-
|
|
357
|
+
setData(result.data);
|
|
847
358
|
setError(result.error);
|
|
848
359
|
setIsPending(false);
|
|
849
360
|
}
|
|
@@ -851,19 +362,19 @@ var useUpgradeToPasskey = (client) => {
|
|
|
851
362
|
useEffect(() => {
|
|
852
363
|
refetch();
|
|
853
364
|
}, [refetch]);
|
|
854
|
-
const
|
|
855
|
-
const result = await
|
|
365
|
+
const revoke = useCallback(async (sessionId) => {
|
|
366
|
+
const result = await client.sessions.revoke(sessionId);
|
|
856
367
|
if (result.error === null)
|
|
857
368
|
await refetch();
|
|
858
369
|
return result;
|
|
859
370
|
}, [client, refetch]);
|
|
860
|
-
|
|
861
|
-
return { error, isPending, passkeys, refetch, register, shouldPrompt };
|
|
371
|
+
return { data, error, isPending, refetch, revoke };
|
|
862
372
|
};
|
|
863
|
-
var
|
|
864
|
-
var
|
|
865
|
-
var
|
|
866
|
-
|
|
373
|
+
var useSignIn = (client) => useMutation(client.signIn.email);
|
|
374
|
+
var useSignOut = (client) => useMutation(client.signOut);
|
|
375
|
+
var useSignUp = (client) => useMutation(client.signUp.email);
|
|
376
|
+
var useUpgradeToPasskey = (client) => {
|
|
377
|
+
const [passkeys, setPasskeys] = useState4(null);
|
|
867
378
|
const [error, setError] = useState4(null);
|
|
868
379
|
const [isPending, setIsPending] = useState4(true);
|
|
869
380
|
const mountedRef = useRef(true);
|
|
@@ -872,9 +383,9 @@ var useSessions = (client) => {
|
|
|
872
383
|
}, []);
|
|
873
384
|
const refetch = useCallback(async () => {
|
|
874
385
|
setIsPending(true);
|
|
875
|
-
const result = await client.
|
|
386
|
+
const result = await client.passkeys.list();
|
|
876
387
|
if (mountedRef.current) {
|
|
877
|
-
|
|
388
|
+
setPasskeys(result.data);
|
|
878
389
|
setError(result.error);
|
|
879
390
|
setIsPending(false);
|
|
880
391
|
}
|
|
@@ -882,17 +393,15 @@ var useSessions = (client) => {
|
|
|
882
393
|
useEffect(() => {
|
|
883
394
|
refetch();
|
|
884
395
|
}, [refetch]);
|
|
885
|
-
const
|
|
886
|
-
const result = await client
|
|
396
|
+
const register = useCallback(async () => {
|
|
397
|
+
const result = await runPasskeyRegistration(client);
|
|
887
398
|
if (result.error === null)
|
|
888
399
|
await refetch();
|
|
889
400
|
return result;
|
|
890
401
|
}, [client, refetch]);
|
|
891
|
-
|
|
402
|
+
const shouldPrompt = passkeys !== null && passkeys.length === 0;
|
|
403
|
+
return { error, isPending, passkeys, refetch, register, shouldPrompt };
|
|
892
404
|
};
|
|
893
|
-
var useSignIn = (client) => useMutation(client.signIn.email);
|
|
894
|
-
var useSignOut = (client) => useMutation(client.signOut);
|
|
895
|
-
var useSignUp = (client) => useMutation(client.signUp.email);
|
|
896
405
|
export {
|
|
897
406
|
useUpgradeToPasskey,
|
|
898
407
|
useSignUp,
|
|
@@ -908,5 +417,5 @@ export {
|
|
|
908
417
|
SignIn
|
|
909
418
|
};
|
|
910
419
|
|
|
911
|
-
//# debugId=
|
|
420
|
+
//# debugId=BD77ABF59C4B6DD264756E2164756E21
|
|
912
421
|
//# sourceMappingURL=react.js.map
|