Repository navigation
fix(plugin-auth): an invitation mail sent outside a better-auth endpoint still carries the mailbox proof - #35226
Conversation
…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>
📓 Docs Drift CheckThis PR changes 1 package(s): ⛔ 1 release-owned page(s) name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 21 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # 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
|
|
repo:objectstack#5 · os-bill · session_01Utp6CbUb7TcZK1XUAddUmQ 维护者速读
席位核对 — ACCEPT · repo:objectstack#5 · head
|
Requested by Bill · project thread
repo:objectstack#5 · os-bill · session_01Utp6CZNxUcd9g6ABZNVZKs
Fixes #35107
Clause-②: no
Metadata-protocol: none
维护者速读
sendInvitationEmail(不在任何 better-auth 端点内)时,邀请邮件现在也带上邮箱证明,受邀人可以一步接受邀请。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
mintProofForSendreads the endpoint context with the non-throwingtryGetCurrentAuthEndpointContext. 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.getAuthContextis 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.@objectstack/plugin-authpatch.Tests
Three cases appended to
invitation-one-step-acceptance-34257.test.ts(it owns the engine double and the door helpers; no new double):sendInvitationEmailcalled directly,tryGetCurrentAuthEndpointContext()assertedundefinedat 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).Ablation (head 6269ad7)
node scripts/ablation-replace.mjsreplaced 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 HEADempty. The suite importssrc/directly, so no dist leg.Acceptance notes
!storereturn.getCurrentAuthEndpointContextin@better-auth/core1.7.12 throws outsiderunWithEndpointContext; 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 insiderunWithEndpointContext(vendorapi/dispatch.mjs), so a host usingauth.api.createInvitationwas 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 includescheck: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.Generated by Claude Code