Files
WRNexusJS/packages/auth/src/routes/definitions.ts
T
2026-07-30 13:36:29 +05:30

178 lines
4.3 KiB
TypeScript

import type { createAuthHttpHandlers } from "../http/index.ts";
export type AuthHandlerName = keyof ReturnType<typeof createAuthHttpHandlers>;
export type AuthRouteGroup =
| "registration"
| "login"
| "verification"
| "password"
| "invitations"
| "magicLink"
| "otp"
| "mfa"
| "sessions"
| "impersonation"
| "passkeys";
export interface AuthRouteDefinition {
path: string;
group: AuthRouteGroup;
handler: AuthHandlerName;
methods: readonly ("GET" | "POST")[];
}
/** Single source of truth for package-contributed auth endpoints. */
export const AUTH_ROUTE_DEFINITIONS = [
{
path: "/api/auth/session/verify",
group: "sessions",
handler: "verifySession",
methods: ["GET"],
},
{ path: "/api/auth/register", group: "registration", handler: "register", methods: ["POST"] },
{ path: "/api/auth/login", group: "login", handler: "login", methods: ["POST"] },
{ path: "/api/auth/logout", group: "login", handler: "logout", methods: ["POST"] },
{
path: "/api/auth/verification/request",
group: "verification",
handler: "requestVerification",
methods: ["POST"],
},
{
path: "/api/auth/verify/email",
group: "verification",
handler: "verifyEmail",
methods: ["GET", "POST"],
},
{
path: "/api/auth/verify/phone",
group: "verification",
handler: "verifyPhone",
methods: ["POST"],
},
{
path: "/api/auth/password/request",
group: "password",
handler: "requestPasswordReset",
methods: ["POST"],
},
{
path: "/api/auth/password/reset",
group: "password",
handler: "resetPassword",
methods: ["POST"],
},
{
path: "/api/auth/password/change",
group: "password",
handler: "changePassword",
methods: ["POST"],
},
{
path: "/api/auth/invitations/accept",
group: "invitations",
handler: "acceptInvitation",
methods: ["POST"],
},
{
path: "/api/auth/magic-link/request",
group: "magicLink",
handler: "requestMagicLink",
methods: ["POST"],
},
{
path: "/api/auth/magic-link",
group: "magicLink",
handler: "consumeMagicLink",
methods: ["GET", "POST"],
},
{
path: "/api/auth/otp/login/request",
group: "otp",
handler: "requestOtpLogin",
methods: ["POST"],
},
{
path: "/api/auth/otp/login/complete",
group: "otp",
handler: "completeOtpLogin",
methods: ["POST"],
},
{ path: "/api/auth/otp", group: "otp", handler: "issueOtp", methods: ["POST"] },
{
path: "/api/auth/otp/verify",
group: "otp",
handler: "verifyOtp",
methods: ["POST"],
},
{ path: "/api/auth/totp/setup", group: "mfa", handler: "beginTotp", methods: ["POST"] },
{
path: "/api/auth/totp/confirm",
group: "mfa",
handler: "confirmTotp",
methods: ["POST"],
},
{
path: "/api/auth/totp/disable",
group: "mfa",
handler: "disableTotp",
methods: ["POST"],
},
{
path: "/api/auth/recovery-codes",
group: "mfa",
handler: "recoveryCodes",
methods: ["POST"],
},
{ path: "/api/auth/mfa/otp", group: "mfa", handler: "beginMfaOtp", methods: ["POST"] },
{
path: "/api/auth/mfa/complete",
group: "mfa",
handler: "completeMfa",
methods: ["POST"],
},
{ path: "/api/auth/sessions", group: "sessions", handler: "sessions", methods: ["GET"] },
{
path: "/api/auth/sessions/revoke",
group: "sessions",
handler: "revokeSession",
methods: ["POST"],
},
{
path: "/api/auth/impersonation/start",
group: "impersonation",
handler: "startImpersonation",
methods: ["POST"],
},
{
path: "/api/auth/impersonation/stop",
group: "impersonation",
handler: "stopImpersonation",
methods: ["POST"],
},
{
path: "/api/auth/passkeys/register/options",
group: "passkeys",
handler: "passkeyRegistrationOptions",
methods: ["POST"],
},
{
path: "/api/auth/passkeys/register/verify",
group: "passkeys",
handler: "passkeyRegistrationVerify",
methods: ["POST"],
},
{
path: "/api/auth/passkeys/login/options",
group: "passkeys",
handler: "passkeyAuthenticationOptions",
methods: ["POST"],
},
{
path: "/api/auth/passkeys/login/verify",
group: "passkeys",
handler: "passkeyAuthenticationVerify",
methods: ["POST"],
},
] as const satisfies readonly AuthRouteDefinition[];