Skip to content

fix(plugin-auth): an invitation mail sent outside a better-auth endpoint still carries the mailbox proof - #35226

Merged
objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/project-thread-3baxvp
Nov 18, 2026
Merged

objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/project-thread-3baxvp

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Bill · project thread

repo:objectstack#5 · os-bill · session_01Utp6CZNxUcd9g6ABZNVZKs

Fixes #35107

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:宿主自己代码里直接调用组织插件的 sendInvitationEmail(不在任何 better-auth 端点内)时,邀请邮件现在也带上邮箱证明,受邀人可以一步接受邀请。
  • 为什么改:云端环境代成员发出的邀请走的就是这条路,此前只带普通链接,cloud#4470 卡在这里。
  • 风险与回滚:只在「没有端点上下文」时多读一次管理器自己的 auth 上下文;端点内的发送路径不变。回滚即 revert 本 PR,退回只带普通链接。
  • 先看:auth-manager-organization-plugin.ts 的 mintProofForSend;invitation-one-step-acceptance-34257.test.ts 末尾的 plugin-auth: an invitation mail sent outside a better-auth endpoint still carries the mailbox proof (mint from the manager's own auth context; blocks cloud#4470) #35107 三条用例;auth-manager-plugin-list.ts / auth-manager.ts 各一行接线。
  • 两分钟验证:pnpm --filter @objectstack/plugin-auth exec vitest run src/invitation-one-step-acceptance-34257.test.ts -t 35107,预期 3 条全绿。
  • 需要你做的:无,席位落地。

What changes

  • mintProofForSend reads the endpoint context with the non-throwing tryGetCurrentAuthEndpointContext. With no endpoint context it mints through the auth manager's own context (getAuthContext().internalAdapter), the card's ask; inside an endpoint it mints through the endpoint's store as before.
  • The manager's getAuthContext is handed to the organization plugin's factory through the two existing host objects (PluginListHost, OrganizationPluginHost); it is read at send time only, never while the plugin is built.
  • The proof is still deliver-only and never stored in clear; the door and its closing rule are untouched.
  • One changeset, @objectstack/plugin-auth patch.

Tests

Three cases appended to invitation-one-step-acceptance-34257.test.ts (it owns the engine double and the door helpers; no new double):

  1. A host-style send (plugin sendInvitationEmail called directly, tryGetCurrentAuthEndpointContext() asserted undefined at the call) delivers a mail whose link carries a proof; the template data and every stored row hold no proof; the one-step door redeems it (accepted, address verified, invitation accepted).
  2. CONTROL: the console invite inside the endpoint mints a proof and never reads the manager context; the out-of-endpoint send reads it exactly once.
  3. Construction-order pin: building the auth instance reads the manager context zero times, so the send cannot wait on its own build.
Ablation (head 6269ad7)

node scripts/ablation-replace.mjs replaced the fallback (: (await managerContext())?.internalAdapter; to : undefined;, anchor 1 to 0, blob 5761479e to a1805a14): cases 1 and 2 red (the mail's link carries no proof, expected getAuthContext to be called 1 times, but got 0), case 3 green (it pins the build order, not the fix). Restored: blob == HEAD, git diff HEAD empty. The suite imports src/ directly, so no dist leg.

Acceptance notes

  • Premise reading A1: before this change the out-of-endpoint send did not reach the !store return. getCurrentAuthEndpointContext in @better-auth/core 1.7.12 throws outside runWithEndpointContext; the throw landed in the catch, which warned and sent the plain link. Same outcome as the card says, different line.
  • auth.api.* calls already run inside runWithEndpointContext (vendor api/dispatch.mjs), so a host using auth.api.createInvitation was never affected; this covers a direct call of the plugin option.

Verification

Local gates (head 6269ad7)
  • pnpm --filter @objectstack/plugin-auth build && pnpm --filter @objectstack/plugin-auth typecheck: lock VERDICT command-exit 0 (typecheck includes check:test-typecheck).
  • pnpm --filter @objectstack/plugin-auth test: lock VERDICT command-exit 0, Test Files 285 passed (285), Tests 6000 passed, 10 skipped (6010).
  • node scripts/pm/dispatch-gates.mjs --commands: 75 derived commands, run locally; the reconciliation goes in the seat report.
  • CI families: read from this PR's check-runs.

Generated by Claude Code

…int still carries the mailbox proof

A host calling the organization plugin's sendInvitationEmail from its own
code (no endpoint context) now mints the proof through the auth manager's
own context, read at send time only. In-endpoint sends are unchanged.

Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/plugin-auth, touching 5 documentable anchor(s).

⛔ 1 release-owned page(s) name something this change touched. These are read-only:

  • content/docs/releases/v18/18-2.mdx (via getAuthContext (symbol, a field of interface OrganizationPluginHost; a field of interface PluginListHost), getAuthContext (literal, a string literal in getAuthContext))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 123 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 21 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json ec227fc7b18dbaea7ea635677db39063fb803206 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from a85e2ddd66410aa167efa00399bc456e3aa52f47 — the merge of head 6269ad7e1a49fd009539646500d80929b78e5185 into base ec227fc7b18dbaea7ea635677db39063fb803206, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin a85e2ddd66410aa167efa00399bc456e3aa52f47 && git checkout a85e2ddd66410aa167efa00399bc456e3aa52f47
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin ec227fc7b18dbaea7ea635677db39063fb803206 6269ad7e1a49fd009539646500d80929b78e5185 && git checkout -B drift-repro ec227fc7b18dbaea7ea635677db39063fb803206 && git merge --no-ff 6269ad7e1a49fd009539646500d80929b78e5185

node scripts/docs-audit/affected-docs.mjs --json ec227fc7b18dbaea7ea635677db39063fb803206

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs ec227fc7b18dbaea7ea635677db39063fb803206 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CbUb7TcZK1XUAddUmQ

维护者速读

  • 改了什么:宿主在自己代码里直接调用组织插件的 sendInvitationEmail(不在任何 better-auth 端点内)时,邀请邮件也带上邮箱证明,受邀人可一步接受。端点内的发送不变。
  • 为什么改:云端代成员发邀请走的就是这条路,此前只发普通链接,cloud#4470 卡在这里。
  • 风险与回滚:只在「没有端点上下文」时,发送那一刻多读一次管理器自己的 auth 上下文;证明仍只进邮件、不明文入库。回滚即 revert 本 PR,退回普通链接。
  • 先看:auth-manager-organization-plugin.ts 的 mintProofForSend;测试文件末尾 plugin-auth: an invitation mail sent outside a better-auth endpoint still carries the mailbox proof (mint from the manager's own auth context; blocks cloud#4470) #35107 三条用例。
  • 两分钟验证:pnpm --filter @objectstack/plugin-auth exec vitest run src/invitation-one-step-acceptance-34257.test.ts -t 35107,3 条全绿。
  • 需要你做的:无,席位落地(非受管面、153 行)。席位意见:修法对准真实成因(vendor 的 get… 在端点外抛错落入 catch),回退走同一个 internalAdapter,构建期零读取已钉住,可落。

席位核对 — ACCEPT · repo:objectstack#5 · head 6269ad7e1a49fd009539646500d80929b78e5185 · 2026-11-18T17:30Z

  • 形态: 5 files, +146/−7; check-governed-merges --pr 35226: 0 of 5 paths governed, 153 lines ≤ 3000 → ordinary queue landing. Fixes #35107 on the body's first content line, no other card number beside a keyword. Changeset @objectstack/plugin-auth patch present (published package). Author relay pr_create; report 6986198628: mcp_calls 2 reads, 0 MCP writes.
  • 前提实测: A1 partly disproved by the dev and accepted: on @better-auth/core 1.7.12 getCurrentAuthEndpointContext throws outside runWithEndpointContext, so the old send fell into the catch (warn, plain link), not the !store return. Same outcome as the card. A2 holds (getAuthContext() returns auth.$context, seat read auth-manager.ts getAuthContext). A3: no recursion, pinned.
  • 差异由席位读过: mintProofForSend now takes managerContext; with no endpoint context the store is (await managerContext())?.internalAdapter, inside an endpoint it is the endpoint's store as before. getAuthContext wired through PluginListHost and OrganizationPluginHost as lambdas (read at call time). Comment explains the try/get split.
  • Pins: three cases in the existing 34257 harness: host-style send redeems through the one-step door with no proof in template data or stored rows; CONTROL (in-endpoint never reads the manager context, out-of-endpoint reads it once); build-order pin (0 reads while building). Ablation (fallback → undefined): cases 1 and 2 red, case 3 green by design; restored blob == HEAD.
  • 门禁: check-runs on head 6269ad7e: 37 success, 16 skipped, 0 failure; Lint & Repo Gates success, TypeScript Type Check success, Test Core success. Dev local: plugin-auth 6000 passed; dispatch-gates 75 accounted, 1 NOT MEASURED (check:dual-build-cjs-loads, covered by CI Build Core).
  • 接受的偏差: none beyond the A1 correction above.
  • 范围外去向: none reported; seat found none.
  • 落地条款: K = 0 first-parent commits on main since PRBASE ec227fc7 (< 15). Seat lands: pr_ready + automerge_enable in this stroke. On MERGED: close-out on plugin-auth: an invitation mail sent outside a better-auth endpoint still carries the mailbox proof (mint from the manager's own auth context; blocks cloud#4470) #35107 (pm:dispatched off), unsubscribe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants