@agenticprimitives/connect-auth

中文文档
1.0.0-alpha.46发布于 2026/10/26MITTypeScriptES Module近 30 天下载 7301

User authentication (passkey + SIWE + Google OAuth), JWT sessions, and pluggable signer interfaces.

原始使用文档
文档目录12 节
  1. Use This When
  2. Do Not Use This For
  3. Install
  4. 60-Second Quickstart
  5. Main Concepts
  6. Auth Method Subpaths (Tree-Shakable)
  7. How it's different from Privy, Dynamic, and Web3Auth
  8. Security Invariants
  9. Documentation Map
  10. Status
  11. Validation
  12. License

@agenticprimitives/connect-auth

Part of Agentic Primitives — the open-source trust substrate for agentic applications: identity that can sign, authority checked at act time, evidence the owner carries. Developer kit · All packages

Credential ceremonies that resolve to a canonical identity — not the other way around.

Most auth SDKs make the credential the identity: lose the passkey, lose the account. connect-auth inverts that. Passkey, SIWE, and OAuth are ceremonies that prove control; the identity they resolve to is the Smart Agent address (ADR-0010). Session JWTs carry the SA address as primary subject — the credential is a signer claim only. So when a credential rotates (ADR-0011), the user signs back in as the same agent, with the same delegations, the same name, the same reputation. Identity persists; credentials rotate.

This package also defines the Signer interfaces (Signer, PasskeySigner, EOASigner, KMSSigner) that agent-account and delegation consume — the architectural contract that lets the whole stack swap signing backends without touching account or delegation code. Custodian add/remove belongs to custody, not here: this package never mutates a credential set, only resolves credential → SA.

Part of agenticprimitives — the trust substrate for the agent economy: one canonical Smart Agent identity with custody, delegation, naming, credentials, and audit evidence designed as one system.

Use This When

  • You implement passkey signup/login (WebAuthn).
  • You implement SIWE or Google OAuth sign-in.
  • You mint or verify JWT cookie sessions and CSRF tokens.
  • You need Signer interfaces for agent-account or delegation.
  • You derive CREATE2 salt from stable user scope (deriveSaltFromEmail, etc.).

Do Not Use This For

  • Smart Agent deploy, UserOps, or ERC-1271 account logic → agent-account.
  • Enrolling / rotating custodians on an SA → custody.
  • .agent names → agent-naming.
  • Public AgentCard profiles → agent-profile.
  • Delegation tokens or encrypted session rows → delegation.
  • KMS backends → key-custody (implements KMSSigner).

Install

pnpm add @agenticprimitives/connect-auth

60-Second Quickstart

import { mintSession, verifySession } from '@agenticprimitives/connect-auth';
import * as passkey from '@agenticprimitives/connect-auth/passkey';

// In your HTTP handler (app wires cookies):
const { sessionClaims } = await passkey.completeSignup(req);
const cookieValue = mintSession(sessionClaims);
// sessionClaims MUST include canonical Smart Agent address as primary subject
import { deriveSaltFromEmail } from '@agenticprimitives/connect-auth';
import { AgentAccountClient } from '@agenticprimitives/agent-account';

// Salt from user scope — NOT from .agent name.
const salt = deriveSaltFromEmail(user.email, 0);

Main Concepts

  • Credential: passkey, SIWE EOA, or OAuth identity — control facet, not the SA.
  • Canonical SA: resolved after auth (custodian lookup); JWT primary subject.
  • Signer: interface consumed by agent-account / delegation.
  • JWT session: signed cookie session (distinct from delegation SessionRow).

See docs/concepts.md.

Auth Method Subpaths (Tree-Shakable)

  • @agenticprimitives/connect-auth/passkey
  • @agenticprimitives/connect-auth/siwe
  • @agenticprimitives/connect-auth/google

How it's different from Privy, Dynamic, and Web3Auth

Hosted auth vendors give you login plus an embedded key, and the identity lives in their database — your users exist because the vendor's account table says so. Here the identity is an on-chain address that no auth provider can revoke, and this package is one composable layer over it:

  • Framework-agnostic and stateless. No hosted dashboard, no database, no cookie I/O — your app wires HTTP routes and storage; this package handles the cryptographic ceremonies and JWT mint/verify.
  • No key custody. It defines the KMSSigner interface; concrete signing backends live in key-custody. The auth layer never holds material it could lose.
  • Login is not authority. A session JWT proves who signed in. What the agent may do is the delegation layer's job — scoped, revocable, on-chain-enforceable — not a side effect of holding a session.

Security Invariants

  • JWT secrets never logged; CSRF origin exact-match.
  • WebAuthn challenges one-shot.
  • Salt derivation deterministic (keccak).

See docs/security.md and AUDIT.md.

Documentation Map

Status

Testnet/pilot-ready. Production launch is gated on the public checklist in the root README — including third-party contract audit and governance key rotation. Track every security finding live in docs/audits/findings.yaml.

Validation

pnpm check:connect-auth
pnpm check:forbidden-terms

License

UNLICENSED.

版本与发布记录

@agenticprimitives/connect-auth 共发布 45 个版本,首次发布于 2026/06/01;过去 12 个月发布了 45 个版本。

版本发布日期距今
1.0.0-alpha.46latest2026/10/2610 天前
1.0.0-alpha.452026/10/2610 天前
1.0.0-alpha.442026/10/1720 天前
1.0.0-alpha.432026/10/1720 天前
1.0.0-alpha.422026/10/1620 天前
1.0.0-alpha.412026/10/1620 天前

其他发布通道:alpha → 0.1.0-alpha.2。

关于 @agenticprimitives/connect-auth 的常见问题

@agenticprimitives/connect-auth 是什么?

User authentication (passkey + SIWE + Google OAuth), JWT sessions, and pluggable signer interfaces.

如何安装 @agenticprimitives/connect-auth?

在项目目录运行 npm install @agenticprimitives/connect-auth,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:viem(^2.52.2)、@agenticprimitives/types(^1.0.0-alpha.46)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@agenticprimitives/connect-auth 支持 TypeScript 吗?

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

@agenticprimitives/connect-auth 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@agenticprimitives/connect-auth 可以商用吗?

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

@agenticprimitives/connect-auth 的下载量有多少?

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

@agenticprimitives/connect-auth 还在维护吗?

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