@fonderie/auth 2.0.0 → 2.1.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/brain/signatures.md +1 -0
- package/dist/index.cjs +25 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +25 -27
- package/dist/index.js.map +1 -1
- package/dist/middlewares/index.d.cts +1 -1
- package/dist/middlewares/index.d.ts +1 -1
- package/dist/{session-DbtCnbiG.d.cts → session-BoJjRB7t.d.cts} +6 -0
- package/dist/{session-DbtCnbiG.d.ts → session-BoJjRB7t.d.ts} +6 -0
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -2,8 +2,8 @@ export { IMfaChallenge, ISession, IUser } from './types.cjs';
|
|
|
2
2
|
import { IFonderieModule, IFonderieApp } from '@fonderie/core';
|
|
3
3
|
import { IStoreAdapter } from '@fonderie/store';
|
|
4
4
|
import { EventBus } from '@fonderie/events';
|
|
5
|
-
import { I as IAuthConfig } from './session-
|
|
6
|
-
export { A as AUTH_CONFIG_KEYS, a as AuthLimitedRoute, b as AuthMessageKey, c as IAuthRateLimitConfig, d as IAuthRuntimeConfig, e as IAuthSecrets, M as MESSAGE_KEYS, f as buildAuthAccountLimiter, g as buildAuthIpLimiter, w as withSession } from './session-
|
|
5
|
+
import { I as IAuthConfig } from './session-BoJjRB7t.cjs';
|
|
6
|
+
export { A as AUTH_CONFIG_KEYS, a as AuthLimitedRoute, b as AuthMessageKey, c as IAuthRateLimitConfig, d as IAuthRuntimeConfig, e as IAuthSecrets, M as MESSAGE_KEYS, f as buildAuthAccountLimiter, g as buildAuthIpLimiter, w as withSession } from './session-BoJjRB7t.cjs';
|
|
7
7
|
export { IUserDTO, toUserDTO } from './dtos/user.cjs';
|
|
8
8
|
export { requireAuth, validate } from '@fonderie/core/middlewares';
|
|
9
9
|
import { z } from 'zod';
|
package/dist/index.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ export { IMfaChallenge, ISession, IUser } from './types.js';
|
|
|
2
2
|
import { IFonderieModule, IFonderieApp } from '@fonderie/core';
|
|
3
3
|
import { IStoreAdapter } from '@fonderie/store';
|
|
4
4
|
import { EventBus } from '@fonderie/events';
|
|
5
|
-
import { I as IAuthConfig } from './session-
|
|
6
|
-
export { A as AUTH_CONFIG_KEYS, a as AuthLimitedRoute, b as AuthMessageKey, c as IAuthRateLimitConfig, d as IAuthRuntimeConfig, e as IAuthSecrets, M as MESSAGE_KEYS, f as buildAuthAccountLimiter, g as buildAuthIpLimiter, w as withSession } from './session-
|
|
5
|
+
import { I as IAuthConfig } from './session-BoJjRB7t.js';
|
|
6
|
+
export { A as AUTH_CONFIG_KEYS, a as AuthLimitedRoute, b as AuthMessageKey, c as IAuthRateLimitConfig, d as IAuthRuntimeConfig, e as IAuthSecrets, M as MESSAGE_KEYS, f as buildAuthAccountLimiter, g as buildAuthIpLimiter, w as withSession } from './session-BoJjRB7t.js';
|
|
7
7
|
export { IUserDTO, toUserDTO } from './dtos/user.js';
|
|
8
8
|
export { requireAuth, validate } from '@fonderie/core/middlewares';
|
|
9
9
|
import { z } from 'zod';
|
package/dist/index.js
CHANGED
|
@@ -1904,44 +1904,42 @@ function buildAuthRoutes(store, config, bus) {
|
|
|
1904
1904
|
const passthrough = (_ctx, next) => next();
|
|
1905
1905
|
const ipLimit = (route) => buildAuthIpLimiter(route, store, config.rateLimit) ?? passthrough;
|
|
1906
1906
|
const acctLimit = (route) => buildAuthAccountLimiter(route, store, config.rateLimit) ?? passthrough;
|
|
1907
|
+
const R = (id, method, path, ...handlers) => {
|
|
1908
|
+
const o = config.routes?.[id];
|
|
1909
|
+
if (!o) return [method, path, ...handlers];
|
|
1910
|
+
if (typeof o === "string") return [method, o, ...handlers];
|
|
1911
|
+
return [o.method ?? method, o.path ?? path, ...handlers];
|
|
1912
|
+
};
|
|
1907
1913
|
const routes = [
|
|
1908
1914
|
// Registration & Login (Public)
|
|
1909
|
-
|
|
1910
|
-
|
|
1915
|
+
R("register", "POST", "/auth/register", ipLimit("register"), validate(registerSchema), auth.register),
|
|
1916
|
+
R("login", "POST", "/auth/login", ipLimit("login"), validate(loginSchema), acctLimit("login"), auth.login),
|
|
1911
1917
|
// Token Management (Public)
|
|
1912
|
-
|
|
1918
|
+
R("refresh", "POST", "/auth/refresh", validate(refreshSchema), auth.refresh),
|
|
1913
1919
|
// Email — Password Recovery (Public)
|
|
1914
|
-
|
|
1915
|
-
|
|
1920
|
+
R("forgotPassword", "POST", "/auth/email/forgot", ipLimit("forgot"), validate(forgotPasswordSchema), acctLimit("forgot"), auth.forgotPassword),
|
|
1921
|
+
R("resetPassword", "POST", "/auth/email/reset", validate(resetPasswordSchema), auth.resetPassword),
|
|
1916
1922
|
// Verification (Protected — email or phone, determined by loginMethod)
|
|
1917
|
-
|
|
1918
|
-
|
|
1923
|
+
R("verifyEmail", "POST", "/auth/verify", requireAuth, validate(verifySchema), auth.verify),
|
|
1924
|
+
R("sendVerification", "GET", "/auth/send-verification", requireAuth, auth.sendVerification),
|
|
1919
1925
|
// Account Management (Protected)
|
|
1920
|
-
|
|
1926
|
+
R("logout", "POST", "/auth/logout", requireAuth, validate(refreshSchema), auth.logout),
|
|
1921
1927
|
// User Profile (Protected; writes also gate on requireVerification)
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1928
|
+
R("me", "GET", "/users", requireAuth, user.me),
|
|
1929
|
+
R("updateProfile", "PUT", "/users/profile", requireAuth, verifyGate, validate(updateProfileSchema), user.updateProfile),
|
|
1930
|
+
R("updatePreferences", "PUT", "/users/preferences", requireAuth, verifyGate, validate(updatePreferencesSchema), user.updatePreferences),
|
|
1931
|
+
R("updateEmail", "PUT", "/users/email", requireAuth, verifyGate, validate(updateEmailSchema), user.updateEmail),
|
|
1932
|
+
R("updatePhone", "PUT", "/users/phone", requireAuth, verifyGate, validate(updatePhoneSchema), user.updatePhone),
|
|
1933
|
+
R("changePassword", "PUT", "/users/password", requireAuth, validate(changePasswordSchema), user.changePassword),
|
|
1934
|
+
R("deleteMe", "DELETE", "/users", requireAuth, verifyGate, user.deleteMe),
|
|
1929
1935
|
// MFA (email sessions only — requireVerified is always enforced here
|
|
1930
1936
|
// because MFA is a security feature and email verification is meaningful)
|
|
1931
|
-
|
|
1937
|
+
R("mfaSetup", "POST", "/auth/mfa/setup", requireAuth, requireEmailLogin, requireVerified, mfa.setup),
|
|
1932
1938
|
// /auth/mfa/verify accepts both mfaPending tokens (TOTP/backup-code login)
|
|
1933
1939
|
// and full tokens (setup confirmation), so requireAnyAuth is used here.
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
"POST",
|
|
1938
|
-
"/auth/mfa/backup-codes",
|
|
1939
|
-
requireAuth,
|
|
1940
|
-
requireEmailLogin,
|
|
1941
|
-
requireVerified,
|
|
1942
|
-
validate(mfaTokenSchema),
|
|
1943
|
-
mfa.regenerateBackupCodes
|
|
1944
|
-
]
|
|
1940
|
+
R("mfaVerify", "POST", "/auth/mfa/verify", ipLimit("mfaVerify"), requireAnyAuth, requireEmailLogin, requireVerified, validate(mfaTokenSchema), mfa.verify),
|
|
1941
|
+
R("mfaDisable", "POST", "/auth/mfa/disable", requireAuth, requireEmailLogin, requireVerified, validate(mfaTokenSchema), mfa.disable),
|
|
1942
|
+
R("mfaBackupCodes", "POST", "/auth/mfa/backup-codes", requireAuth, requireEmailLogin, requireVerified, validate(mfaTokenSchema), mfa.regenerateBackupCodes)
|
|
1945
1943
|
];
|
|
1946
1944
|
if (config.providers.includes("google")) {
|
|
1947
1945
|
routes.push(
|