@ackplus/nest-auth-contracts

中文文档
2.18.0发布于 2026/11/03TypeScriptESM + CJS零依赖近 30 天下载 2626

npm version [npm downloads](https://www.npmjs.com/package/@a

原始使用文档
文档目录14 节
  1. Why this package exists
  2. Install
  3. What's exported
  4. Enums
  5. Request DTOs
  6. Response DTOs
  7. Credential type unions
  8. Domain interfaces
  9. Configuration interfaces
  10. Common imports
  11. Naming conventions
  12. Companion packages
  13. Links
  14. License

@ackplus/nest-auth-contracts

npm version npm downloads license

Shared TypeScript types and enums for the @ackplus/nest-auth ecosystem. Types-only — zero runtime code, zero bundle cost.

📚 Browse every type at ack-solutions.github.io/nest-auth/docs/api-reference/types


Why this package exists

Backend, JS client, and React layer all need the same types — DTOs, enums, domain interfaces. This package is the single source of truth so a change to a request/response shape on the server breaks the client at compile time, not at runtime.

It is consumed by:

You usually don't install it directly — it's a transitive dependency of all three. Install it explicitly when you want to type-check code that consumes the auth API without pulling in the full backend or client package.

Install

pnpm add @ackplus/nest-auth-contracts

Both ESM and CommonJS builds ship in the package. No peer dependencies.

What's exported

Enums

import {
  NestAuthMFAMethodEnum,   // 'email' | 'sms' | 'totp'
  NestAuthOTPTypeEnum,     // 'passwordless_login' | 'magic_link_login' | 'password_reset' | 'email_verification' | 'phone_verification' | 'mfa'
  TenantModeEnum,          // 'isolated' | 'shared'
} from '@ackplus/nest-auth-contracts';

Request DTOs

ILoginRequest, ISignupRequest, IRefreshRequest, ISwitchTenantRequest, IVerify2faRequest, IToggleMfaRequest, IVerifyTotpSetupRequest, IForgotPasswordRequest, IResetPasswordWithTokenRequest, IChangePasswordRequest, IVerifyForgotPasswordOtpRequest, IVerifyEmailRequest, IVerifyPhoneRequest, IPasswordlessSendRequest, IInitializeAdminRequest, ICreateRoleInput, IUpdateRoleInput, IUpdatePermissionInput …

Response DTOs

IAuthResponse, ITokenPair, IUserResponse, ISessionUserData, IMessageResponse, IVerify2faResponse, IMfaStatusResponse, IMfaDevice, ITotpSetupResponse, IVerifyOtpResponse, ISessionVerifyResponse …

Credential type unions

ILoginCredentials = IEmailCredentials | IPhoneCredentials | ISocialCredentials | IPasswordlessOtpLoginCredentials

Domain interfaces

INestAuthUser, INestAuthIdentity, INestAuthSession, INestAuthAccessKey, INestAuthOTP, INestAuthMFASecret, INestAuthTrustedDevice, INestAuthRole, INestAuthPermission, INestAuthTenant, INestAuthUserAccess

Configuration interfaces

IEmailAuthConfig, IPhoneAuthConfig, IMfaConfig, IRegistrationConfig, INestAuthTenantOptions, ITenantsConfig, ISsoConfig, IUiConfig …

Full type reference →

Common imports

import {
  // Enums
  NestAuthMFAMethodEnum,
  NestAuthOTPTypeEnum,
  TenantModeEnum,

  // Request/response DTOs
  ILoginRequest,
  ISignupRequest,
  IAuthResponse,
  IMfaStatusResponse,
  ISessionUserData,

  // Domain interfaces
  INestAuthUser,
  INestAuthSession,
  INestAuthRole,
  INestAuthTenant,
} from '@ackplus/nest-auth-contracts';

async function login(req: ILoginRequest): Promise<IAuthResponse> {
  return fetch('/auth/login', { method: 'POST', body: JSON.stringify(req) }).then((r) => r.json());
}

Naming conventions

  • Domain entities → INestAuth{Entity} (e.g. INestAuthUser, INestAuthRole)
  • Enums → NestAuth{Name}Enum (e.g. NestAuthMFAMethodEnum)
  • Request DTOs → I{Feature}Request
  • Response DTOs → I{Feature}Response
  • Configuration → I{Feature}Config or I{Feature}Options

Companion packages

PackagePurpose
@ackplus/nest-authNestJS backend module
@ackplus/nest-auth-clientFramework-agnostic JS/TS client
@ackplus/nest-auth-reactReact provider, hooks, guards

All four packages release together with the same version number. Pin them all to the same version.

License

MIT

版本与发布记录

@ackplus/nest-auth-contracts 共发布 110 个版本,首次发布于 2025/12/27;过去 12 个月发布了 110 个版本。

版本发布日期距今
2.18.0latest2026/11/034 天前
2.16.02026/10/2711 天前
2.15.02026/10/2612 天前
2.14.12026/10/2414 天前
2.14.02026/10/1226 天前
2.13.12026/10/1028 天前

其他发布通道:beta → 2.0.0-beta.26。

关于 @ackplus/nest-auth-contracts 的常见问题

@ackplus/nest-auth-contracts 是什么?

[](https://www.npmjs.com/package/@a

如何安装 @ackplus/nest-auth-contracts?

在项目目录运行 npm install @ackplus/nest-auth-contracts,或使用 pnpm add / yarn add / bun add。

@ackplus/nest-auth-contracts 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@ackplus/nest-auth-contracts 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@ackplus/nest-auth-contracts 可以商用吗?

@ackplus/nest-auth-contracts 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@ackplus/nest-auth-contracts 的下载量有多少?

根据 npm 官方下载统计,@ackplus/nest-auth-contracts 在 2026/10/05 – 2026/11/03 这 30 天内被下载 2,626 次,日均约 88 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@ackplus/nest-auth-contracts 还在维护吗?

最新版本 2.18.0 发布于 2026/11/03(4 天前);至今共发布 110 个版本,其中过去 12 个月发布了 110 个;首次发布于 2025/12/27。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。