@absolutejs/auth 0.59.3 → 0.61.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/server.js CHANGED
@@ -6109,6 +6109,9 @@ var credentialsEmailVerification = ({
6109
6109
  if (!consumed) {
6110
6110
  return status("Bad Request", "Invalid or expired verification token");
6111
6111
  }
6112
+ if (consumed.expiresAt < Date.now()) {
6113
+ return status("Bad Request", "Invalid or expired verification token");
6114
+ }
6112
6115
  await credentialStore.setEmailVerified(consumed.email);
6113
6116
  await onEmailVerified?.({ email: consumed.email });
6114
6117
  return status("OK", { status: "email_verified" });
@@ -6326,6 +6329,8 @@ var evaluatePassword = async (password, policy = {}) => {
6326
6329
  var isPasswordCompromised = (password) => isPasswordBreached(password);
6327
6330
 
6328
6331
  // src/credentials/login.ts
6332
+ var dummyPasswordHashPromise;
6333
+ var dummyPasswordHash = () => dummyPasswordHashPromise ??= hashPassword("absolutejs-auth-timing-equalizer");
6329
6334
  var credentialsLogin = ({
6330
6335
  authSessionStore,
6331
6336
  checkBreachesOnLogin,
@@ -6367,7 +6372,13 @@ var credentialsLogin = ({
6367
6372
  const credential = await credentialStore.getCredentialByEmail(normalizedEmail);
6368
6373
  const user = await getUserByEmail(normalizedEmail);
6369
6374
  const verifyHash = passwordVerifier ?? verifyPassword;
6370
- const passwordValid = credential === undefined ? false : await verifyHash(password, credential.passwordHash);
6375
+ let passwordValid;
6376
+ if (credential === undefined) {
6377
+ await verifyPassword(password, await dummyPasswordHash());
6378
+ passwordValid = false;
6379
+ } else {
6380
+ passwordValid = await verifyHash(password, credential.passwordHash);
6381
+ }
6371
6382
  if (!credential || !user || credential.status !== "active" || !passwordValid) {
6372
6383
  await lockoutGuard?.recordFailure(normalizedEmail);
6373
6384
  await onCredentialsLoginError?.({
@@ -6462,6 +6473,9 @@ var credentialsPasswordReset = ({
6462
6473
  if (!consumed) {
6463
6474
  return status("Bad Request", "Invalid or expired reset token");
6464
6475
  }
6476
+ if (consumed.expiresAt < Date.now()) {
6477
+ return status("Bad Request", "Invalid or expired reset token");
6478
+ }
6465
6479
  const policy = await evaluatePassword(password, passwordPolicy);
6466
6480
  if (!policy.ok) {
6467
6481
  return status("Bad Request", {
@@ -11499,7 +11513,7 @@ var callback = ({
11499
11513
  if (requiresPKCE && verifier === undefined) {
11500
11514
  return status("Bad Request", "Code verifier not found and is required");
11501
11515
  }
11502
- const originUrl = origin_url?.value ?? "/";
11516
+ const originUrl = toSafeLocalPath(origin_url?.value);
11503
11517
  let tokenResponse2;
11504
11518
  try {
11505
11519
  tokenResponse2 = await providerInstance.validateAuthorizationCode(requiresPKCE ? { code, codeVerifier: verifier } : { code });
@@ -38313,6 +38327,9 @@ var buildAuthApplications = async (configuration) => {
38313
38327
  await webhookDispatch?.(event);
38314
38328
  }
38315
38329
  }) : undefined;
38330
+ if (auditEmit === undefined) {
38331
+ console.warn("[@absolutejs/auth] No audit sink configured (pass `audit` or `webhooks`). " + "Privileged flows (impersonation, role/permission changes, sign-out) will " + "run WITHOUT an audit trail.");
38332
+ }
38316
38333
  const lockoutGuard = lockout ? createLockoutGuard(lockout) : undefined;
38317
38334
  const resolvedAgentAuth = agentAuth === undefined ? undefined : {
38318
38335
  ...agentAuth,
@@ -38706,5 +38723,5 @@ export {
38706
38723
  VerificationProviderError
38707
38724
  };
38708
38725
 
38709
- //# debugId=D7D259888A27730164756E2164756E21
38726
+ //# debugId=D218332195145BB664756E2164756E21
38710
38727
  //# sourceMappingURL=server.js.map