Skip to main content

Shipped Routes

Package: @nauth-toolkit/core Type: Route manifest

nauth-toolkit ships every auth endpoint as a framework-agnostic manifest. Mount it instead of hand-writing controllers; exclude individual keys where you need your own behaviour.

Mount options​

interface NAuthRouteMountOptions {
enabled?: boolean;
prefix?: string;
groups?: readonly NAuthRouteGroup[];
exclude?: readonly NAuthRouteKey[];
delivery?: 'json' | 'cookies';
guards?: readonly GuardLike[];
adminGuards?: readonly GuardLike[];
routeGuards?: Partial<Record<NAuthRouteKey, readonly GuardLike[]>>;
}
OptionTypeDefaultDescription
adminGuardsGuardLike[][]Guards applied only to routes with access: 'admin'.
delivery'json' | 'cookies'inheritForces one transport for the bundle. Requires tokenDelivery.method: 'hybrid' unless it matches the configured method.
enabledbooleantrueSet false to mount nothing.
excludeNAuthRouteKey[][]Individual routes to leave out. An unknown key throws at mount time.
groupsNAuthRouteGroup[]all except admin, apiKeysAdminWhich bundles to mount.
guardsGuardLike[][]Guards applied to every route in the bundle.
prefixstring'auth'Path prefix, relative to any framework-wide prefix.
routeGuardsPartial<Record<NAuthRouteKey, GuardLike[]>>{}Guards for named routes, merged with the above.

A GuardLike is a guard class, guard instance, or DI token on NestJS; a middleware function on Express and Fastify. DI tokens only mean anything to NestJS — on Express and Fastify a guard is pushed straight into the middleware chain, so pass a function there.

Groups​

groups selects which bundles to mount. Omit it and every group except admin and apiKeysAdmin is registered.

GroupRoutesDefaultPurpose
core12YesSign-up, sign-in, refresh, sign-out, password recovery, and the challenge responses that complete them
profile3YesThe caller's own profile and password
mfa7YesThe caller's own MFA enrolment and devices
social10YesOAuth sign-in, linking, and credentials for social-origin users
device4YesSessions and device trust
audit1YesThe caller's own sign-in history
apiKeys5YesThe caller's own API keys
admin25NoOperations on other users' accounts
apiKeysAdmin5NoAPI keys on another user's behalf

Route Groups lists every route in each group, with its method, path and access level.

Admin groups require an authorization provider

Mounting admin or apiKeysAdmin without one is refused at startup. The toolkit ships no role model, so those endpoints would otherwise be reachable by any authenticated caller. See Authorization.

Mount functions​

Configured declaratively — AuthModule.forRoot() builds the controllers.

src/config/auth.config.ts
export const authConfig: NAuthModuleConfig = {
// ...jwt, providers, and the rest of your configuration
tokenDelivery: { method: 'hybrid' },
routes: [
{ prefix: 'auth', delivery: 'cookies' },
{ prefix: 'mobile/auth', delivery: 'json', groups: ['core', 'social'] },
],
};

createNAuthRoutesController(mount) is also exported for registering a bundle in your own module.

Self-service routes​

Paths are relative to the bundle prefix. Where a route has a client-SDK counterpart, its key matches the corresponding defaultEndpoints key — a few shipped routes have no SDK key (see NAuthEndpoints).

KeyGroupMethodPathAccess
signupcorePOSTsignuppublic
logincorePOSTloginpublic
refreshcorePOSTrefreshpublic
logoutcoreGETlogoutauthenticated
logoutAllcorePOSTlogout/allauthenticated
forgotPasswordcorePOSTforgot-passwordpublic
confirmForgotPasswordcorePOSTforgot-password/confirmpublic
confirmAdminResetPasswordcorePOSTreset-password/confirmpublic
respondChallengechallengePOSTrespond-challengepublic
resendCodechallengePOSTchallenge/resendpublic
getSetupDatachallengePOSTchallenge/setup-datapublic
getChallengeDatachallengePOSTchallenge/challenge-datapublic
profileprofileGETprofileauthenticated
updateProfileprofilePUTprofileauthenticated
changePasswordprofilePOSTchange-passwordauthenticated
mfaStatusmfaGETmfa/statusauthenticated
mfaAvailableMethodsmfaGETmfa/available-methodsauthenticated
mfaSetupDatamfaPOSTmfa/setup-dataauthenticated
mfaVerifySetupmfaPOSTmfa/verify-setupauthenticated
mfaBackupCodesmfaPOSTmfa/backup-codes/generateauthenticated
mfaDevicesmfaGETmfa/devicesauthenticated
mfaPreferredmfaPOSTmfa/devices/:deviceId/preferredauthenticated
mfaRemoveDevicemfaDELETEmfa/devices/:deviceIdauthenticated
socialLinkedsocialGETsocial/linkedauthenticated
socialLinksocialPOSTsocial/linkauthenticated
socialUnlinksocialPOSTsocial/unlinkauthenticated
socialCanSetPasswordsocialGETsocial/can-set-passwordauthenticated
socialSetPasswordsocialPOSTsocial/set-passwordauthenticated
socialExchangesocialPOSTsocial/exchangepublic
socialRedirectStartsocialGETsocial/:provider/redirectpublic
socialCallbacksocialGETsocial/:provider/callbackpublic
socialCallbackPostsocialPOSTsocial/:provider/callbackpublic
socialVerifysocialPOSTsocial/:provider/verifypublic
sessionsdeviceGETsessionsauthenticated
logoutSessiondeviceDELETEsessions/:sessionIdauthenticated
trustDevicedevicePOSTtrust-deviceauthenticated
isTrustedDevicedeviceGETis-trusted-deviceauthenticated
trustedDevicesdeviceGETtrusted-devicesauthenticated
revokeAllTrustedDevicesdeviceDELETEtrusted-devicesauthenticated
revokeTrustedDevicedeviceDELETEtrusted-devices/:deviceIdauthenticated
auditHistoryauditGETaudit/historyauthenticated
apiKeyCreateapiKeysPOSTapi-keysauthenticated
apiKeyListapiKeysGETapi-keysauthenticated
apiKeyUpdateapiKeysPATCHapi-keys/:keyIdauthenticated
apiKeyRevokeapiKeysPOSTapi-keys/:keyId/revokeauthenticated
apiKeyDeleteapiKeysDELETEapi-keys/:keyIdauthenticated

Administrative routes​

KeyGroupMethodPathAccess
adminSignupadminPOSTsignupadmin
adminSignupSocialadminPOSTsignup-socialadmin
adminSetPasswordadminPOSTset-passwordadmin
adminResetPasswordInitiateadminPOSTreset-password/initiateadmin
adminGetUserByEmailadminGETusers/by-emailadmin
adminGetUsersadminGETusersadmin
adminGetUseradminGETusers/:subadmin
adminUpdateUseradminPUTusers/:subadmin
adminDeleteUseradminDELETEusers/:subadmin
adminDisableUseradminPOSTusers/:sub/disableadmin
adminEnableUseradminPOSTusers/:sub/enableadmin
adminForcePasswordChangeadminPOSTusers/:sub/force-password-changeadmin
adminUpdateVerifiedStatusadminPOSTusers/:sub/verified-statusadmin
adminGetUserTrustedDevicesadminGETusers/:sub/trusted-devicesadmin
adminRevokeAllUserTrustedDevicesadminDELETEusers/:sub/trusted-devicesadmin
adminRevokeUserTrustedDeviceadminDELETEusers/:sub/trusted-devices/:deviceIdadmin
adminGetUserSessionsadminGETusers/:sub/sessionsadmin
adminRevokeUserSessionadminDELETEusers/:sub/sessions/:sessionIdadmin
adminLogoutAlladminPOSTusers/:sub/logout-alladmin
adminSetMfaExemptionadminPOSTmfa/exemptionadmin
adminRemoveMfaDeviceadminDELETEmfa/devices/:deviceIdadmin
adminGetMfaStatusadminGETusers/:sub/mfa/statusadmin
adminGetMfaDevicesadminGETusers/:sub/mfa/devicesadmin
adminSetPreferredMfaDeviceadminPOSTusers/:sub/mfa/devices/:deviceId/preferredadmin
adminGetEventsByTypeadminGETaudit/eventsadmin
adminGetSuspiciousActivityadminGETaudit/suspiciousadmin
adminGetRiskAssessmentHistoryadminGETaudit/riskadmin
adminGetAuditHistoryadminGETaudit/historyadmin
adminApiKeyCreateapiKeysAdminPOSTapi-keysadmin
adminApiKeyListapiKeysAdminGETapi-keysadmin
adminApiKeyUpdateapiKeysAdminPATCHapi-keys/:keyIdadmin
adminApiKeyRevokeapiKeysAdminPOSTapi-keys/:keyId/revokeadmin
adminApiKeyDeleteapiKeysAdminDELETEapi-keys/:keyIdadmin