@absolutejs/agent-exchange-email

中文文档
0.6.1发布于 2026/09/26Apache-2.0TypeScriptES Module近 30 天下载 1697

Deterministic, model-blind email verification-code source for @absolutejs/agent-exchange.

原始使用文档

@absolutejs/agent-exchange-email

Email one-time codes are bearer credentials. This source accepts either the explicit policy + bearer + purpose-bound profile or webauthn-verifier-bound + token-confined-broker + purpose-bound. The latter confines provider credentials and OTP processing to a trusted broker but does not make the upstream bearer credential phishing-resistant.

The 0.5.x line also accepts an exact, passkey-enrolled standing-mandate with the same token-confined and purpose-bound requirements. The signed mandate never broadens the host-owned mailbox profile.

An interchangeable, deterministic email source for @absolutejs/agent-exchange. It uses @absolutejs/email/verification to locate one exact verification message and returns the protected value directly to Agent Exchange for encryption.

Gmail and Microsoft Graph lookups are browser-safe. IMAP is server-only and is created from @absolutejs/email/verification/imap before being passed here.

bun add @absolutejs/agent-exchange @absolutejs/agent-exchange-email @absolutejs/email
import { createEmailVerificationCodeSource } from "@absolutejs/agent-exchange-email";
import { createGmailVerificationMessageLookup } from "@absolutejs/email/verification";

const source = createEmailVerificationCodeSource({
  lookup: createGmailVerificationMessageLookup({ accountEmail, client: gmail }),
  profiles: [
    {
      bodyMarkers: ["verification code"],
      correlation: { mode: "challenge-text" },
      id: "accounts-example-six-digit-v1",
      operations: ["verification.submit"],
      origins: ["https://accounts.example.com"],
      providers: ["gmail"],
      senderAddresses: ["[email protected]"],
      senderAuthentication: {
        allowedHeaderFromDomains: ["example.com"],
        trustedAuthservIds: ["mx.mailbox.example"],
      },
      subjectIncludesAny: ["sign in"],
    },
  ],
  resolveAccountEmail: (request) =>
    mailboxDirectory.get(request.resource.accountRef),
});

Pass source to createAgentExchangeSender. Do not register it as an MCP, A2A, manifest, or general agent tool. The source deliberately returns no string API; Agent Exchange encrypts its mutable byte result and clears it after delivery.

Fail-closed rules

  • Only tool-confined, single-use, email-one-time-code requests are accepted.
  • The request's exact provider, HTTPS origin, and operation must select exactly one profile.
  • challenge-text correlation is the default-safe profile mode: the request's challengeId must occur exactly in the selected message body.
  • temporal-only profiles require both an explicit profile mode and allowTemporalOnlyCorrelation: true; use this weaker mode only when an upstream email cannot echo a challenge.
  • The visible sender must have exactly one aligned DMARC pass from a configured, mailbox-trusted RFC 8601 authserv-id.
  • The mailbox account reference is resolved through a host-owned directory; it is never assumed to be an email address.
  • The default lookup window begins 30 seconds before the Agency request and ends at the earlier of execution time or request expiry. Future clock skew must be enabled explicitly.
  • Multiple messages, multiple marker-bound codes, untrusted senders, stale mail, wrong subjects, and lookup failures all become the same safe source_failed error.

Email OTPs remain bearer credentials and are not phishing-resistant. Prefer OAuth, passkeys, service accounts, or provider-native delegated actions whenever possible.

This release uses Email 0.6.0 for explicit standalone-after-marker code layouts and preserved HTML block boundaries. Existing immediate-marker profiles retain their behavior. Temporal-only correlation still requires explicit opt-in and does not prove a cryptographic binding between a provider email and a browser session; callers must serialize attempts and bind the destination separately.

selection: "newest" (with @absolutejs/email 0.7) uses the most recent sender-authenticated match instead of failing when several messages match, and allows maxLookbackMs up to 24 hours. It is meant for temporal-only services whose emails carry no per-request challenge, where the mailbox owner has chosen "use the latest code". The default unique selection keeps the two-minute cap.

createEmailVerificationCodeSource accepts an optional onFailure observer. It receives only a fixed category (no_match, ambiguous_match, candidate_limit, invalid_profile, lookup_failed, or source_rejected). It never receives the caught exception, code, message body, provider response, or source evidence. Observer failures are ignored and retrieval continues to fail closed. Hosts may record these categories for operational diagnosis without exposing secrets.

版本与发布记录

@absolutejs/agent-exchange-email 共发布 12 个版本,首次发布于 2026/08/26;过去 12 个月发布了 12 个版本。

版本发布日期距今
0.6.1latest2026/09/261 个月前
0.6.02026/09/261 个月前
0.5.22026/09/261 个月前
0.5.12026/09/251 个月前
0.5.02026/08/272 个月前
0.4.12026/08/262 个月前

关于 @absolutejs/agent-exchange-email 的常见问题

@absolutejs/agent-exchange-email 是什么?

Deterministic, model-blind email verification-code source for @absolutejs/agent-exchange.

如何安装 @absolutejs/agent-exchange-email?

在项目目录运行 npm install @absolutejs/agent-exchange-email,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@absolutejs/agent-exchange(>=0.5.0 <0.6)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@absolutejs/agent-exchange-email 支持 TypeScript 吗?

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

@absolutejs/agent-exchange-email 支持 ESM 还是 CommonJS?

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

@absolutejs/agent-exchange-email 可以商用吗?

@absolutejs/agent-exchange-email 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@absolutejs/agent-exchange-email 的下载量有多少?

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

@absolutejs/agent-exchange-email 还在维护吗?

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