@aooth/idp

中文文档
0.2.6发布于 2026/11/07MITTypeScriptESM + CJS近 30 天下载 2436

Framework-agnostic OAuth2 / OIDC federated-login core for aoothjs (provider registry, PKCE/state, ID-token verification, account resolution)

原始使用文档
文档目录3 节
  1. What's here
  2. Install
  3. Security

@aooth/idp

Framework-agnostic OAuth2 / OIDC federated-login core for aoothjs.

This is the phase 2 layer of the External IdP RFC: the portable pieces that have no framework dependency — provider clients, PKCE/state primitives, ID-token verification, and the account-resolution algorithm. The moost wiring (OAuthController, the provider-login workflow, DI binding) lives in @aooth/auth-moost (phase 3).

What's here

  • IdentityProvider — the provider abstraction (authorizationUrl / exchange).
  • OidcProvider — generic OpenID Connect: discovery, remote JWKS, and the full OIDC Core 3.1.3.7 ID-token validation (pinned algs, iss/aud/azp, exp/iat/nbf with clock skew, nonce, at_hash). Fails closed on JWKS/discovery errors.
  • GoogleProvider — OidcProvider pinned to Google's issuer + RS256.
  • FakeIdentityProvider — deterministic, network-free, for unit + e2e tests.
  • OAuthProviderRegistry — holds the providers + FederatedPolicy + shared signing/verification config; resolves :provider; builds the fixed redirect_uri.
  • PKCE / state — createPkcePair, generateNonce, and signState/verifyState (a compact HS256 JWT binding random + provider + redirect + optional verifier/nonce).
  • FederatedLoginService — resolveUser(profile) (known → email-match → new) and linkIdentity (interactive-link completion with the cross-user guard).

Install

pnpm add @aooth/idp @aooth/user @aooth/auth

@aooth/idp depends on the concrete UserService (@aooth/user) and the shared Clock (@aooth/auth), and uses jose for all JWT/JWKS work.

Security

Account matching by email is account-takeover sensitive — the default FederatedPolicy.emailMatch is require-interactive-link (never silently merge). See IDP.md §4 / §7 for the full posture.

版本与发布记录

@aooth/idp 共发布 85 个版本,首次发布于 2026/06/06;过去 12 个月发布了 85 个版本。

版本发布日期距今
0.2.6latest2026/11/07今天
0.2.52026/11/061 天前
0.2.42026/11/043 天前
0.2.32026/11/043 天前
0.2.22026/11/034 天前
0.2.12026/11/034 天前

关于 @aooth/idp 的常见问题

@aooth/idp 是什么?

Framework-agnostic OAuth2 / OIDC federated-login core for aoothjs (provider registry, PKCE/state, ID-token verification, account resolution)

如何安装 @aooth/idp?

在项目目录运行 npm install @aooth/idp,或使用 pnpm add / yarn add / bun add。

@aooth/idp 支持 TypeScript 吗?

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

@aooth/idp 支持 ESM 还是 CommonJS?

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

@aooth/idp 可以商用吗?

@aooth/idp 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@aooth/idp 的下载量有多少?

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

@aooth/idp 还在维护吗?

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