Skip to content

fix(plugin-auth): the phone-number password-reset request answers without waiting for the SMS send, as the emailed reset does - #29973

Merged
objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/sec-hardening-m
Nov 3, 2026
Merged

objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/sec-hardening-m

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:手机号重置密码请求(POST /api/v1/auth/phone-number/request-password-reset)不再在请求内等待短信发送;重置短信在响应之后构建并发送,与邮件重置一致。
  • 为什么改:让手机号重置这扇门与邮件重置遵守同一条规则(请求即答、不等发送),沿用同一个 helper sendAfterResponseOnPublicDoor,不新增机制。
  • 风险与回滚:答复的状态与正文不变;发送失败改由服务端 logger 以 error 级记录(与邮件门同形),不再经 better-auth 自己的日志。回滚 = 撤销本 PR,无数据或配置迁移。
  • 先看:① packages/plugins/plugin-auth/src/auth-manager-plugin-list.ts 的 sendPasswordResetOTP 一行(取 ctx?.request 交给 helper);② run-after-response.ts 的日志措辞(what 自带介质,邮件那行字节不变);③ reset-request-mail-after-response.test.ts 新增的 phone describe。
  • 两分钟验证:pnpm --filter @objectstack/plugin-auth exec vitest run src/reset-request-mail-after-response.test.ts,预期 9/9 通过,其中 phone describe 三条全绿。
  • 需要你做的:无,席位落地。

What changes

The phone-number password-reset request answers without waiting for the SMS send, as the emailed reset does.

  • sendPasswordResetOTP (auth-manager-plugin-list.ts) now goes through sendAfterResponseOnPublicDoor, the helper the emailed reset's sendResetPassword already uses. A call that carries a Request (the public door) resolves at once; the text is built and sent after the response; a failed send goes to logAfterResponseSendFailure at error.
  • better-auth 1.7.12 calls this callback as sendPasswordResetOTP(data, ctx) — the endpoint context, not the Request the emailed reset is handed (plugins/phone-number/routes.mjs). The callback therefore passes ctx?.request, the very value sendResetPassword receives (routes/password.mjs). The helper's rule is unchanged: a Request present means the public door; none means a server-side auth.api.* call, which still awaits its send.
  • logAfterResponseSendFailure takes the medium inside what: the email door passes password-reset email and prints the same bytes as before; the phone door prints phone password-reset text was not delivered: …. The line carries the transport's error, never the one-time code.
  • Unchanged: the answer's status and body (200 {"status":true}), the per-number cooldown and hourly cap in the before-hook, the per-IP limit on the route, the text itself, and sendOTP (sign-in OTP), which still awaits its send so its 429/400 refusals reach the caller.

Tests

New top-level describe in the existing harness file src/reset-request-mail-after-response.test.ts (real AuthManager.handleRequest over ObjectQL + better-sqlite3):

  • answers a number with an account and a number without one alike, while the reset text is still being sent: the SMS stub's send waits on a deferred the case resolves by hand. Both answers arrive, equal, while that send is still open; then the case resolves it and the text goes out to the number (control). No wall-clock threshold.
  • logs a reset text whose send fails on the server, without its code, and answers as for a text that is sent.
  • the server-side phone reset call (no Request) still awaits its send.

src/phone-otp-no-sms-service-refusal.test.ts: the existing pin that the refusing send is reached now waits for it with vi.waitFor, since it runs after the response. The two phone pins in password-reset-ends-sessions.test.ts (which already use vi.waitFor) pass unchanged.

Results at af6b561
pnpm --filter @objectstack/plugin-auth test   (under os-verify-lock)
 Test Files  219 passed (219)
      Tests  3769 passed | 10 skipped (3779)
os-verify-lock: VERDICT command-exit 0

pnpm --filter @objectstack/plugin-auth typecheck   (after building plugin-auth)
check:test-typecheck: OK — 10 file(s) / 88 error(s) / 23 pinned signature(s) held in test-typecheck-debt.json
os-verify-lock: VERDICT command-exit 0
One-shot ablation (committed fix first; mutation through scripts/ablation-replace.mjs; restore proven blob == HEAD, git diff HEAD empty)
Leg A — wrapper removed (callback back to an inline awaited deliverPhoneOtp):
  anchor x1 -> x0, replacement x0 -> x1, blob 811bf7cbc613 -> c1d2e587542b
  x answers a number with an account and a number without one alike, ... — Test timed out in 60000ms (the answer never arrives while the send is open)
  x logs a reset text whose send fails on the server, ... — expected [] to have a length of 1
  ✓ the server-side phone reset call (no Request) still awaits its send   (control)
  ✓ all four emailed-reset cases, and the no-SMS-service file
  restore: blob 811bf7cbc613 == HEAD, git diff HEAD empty

Leg B — the whole ctx handed to the helper instead of ctx?.request:
  x the server-side phone reset call (no Request) still awaits its send — expected [] to deeply equal [ '+15550161' ]
  ✓ the two public-door phone cases
  restore: blob 811bf7cbc613 == HEAD, git diff HEAD empty

Acceptance notes

  • No server-side caller of the phone reset exists in this repository: git grep -n requestPasswordResetPhoneNumber hits only the new test, and the identity import calls the emailed requestPasswordReset. The no-Request branch is kept anyway and pinned (leg B above).
  • The rejected alternative, better-auth's global advanced.backgroundTasks.handler, stays unset: it would also stop the identity import's server-side reset from awaiting the delivery receipt it reads.
  • The deferred-gate case fails in the ablated world by the harness's per-case timeout (60 s): with the wrapper gone the answer cannot arrive while the send is open, so the case can never pass; it asserts no duration.

Verification

All readings at af6b561239 (the head of this PR); origin/main had not moved from the merge base 3b8c724cf2 when they were taken.

  • Derived gate list: node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack named 59 commands for this diff; each was run with its exit code captured before any pipe, then reconciled; in the final record every one answered exit 0 (the list and its codes are in the seat report).
  • node scripts/pm/dispatch-gates.mjs --ran → Run reconciliation — 59 derived, 59 run, 0 NOT-MEASURED, 0 UNRUN.
  • pnpm check:dual-build-cjs-loads first answered exit 3 (PREREQUISITE NOT MET: unbuilt packages, nothing measured); after a full workspace build (turbo run build --filter=!@objectstack/docs, 119/119 tasks) it answered exit 0: 116 published require entry point(s) across 71 package(s) load.
  • Full @objectstack/plugin-auth suite and typecheck: see Tests above.
  • Not run locally: test:repo (the vitest repo project, which CI's Test Core runs) and the full CI farm; CI's check-runs on this PR are the reading for those.

CI note (seat)

  • Build Core on af6b561239 first failed before compiling anything: @objectstack/spec's build could not fetch the deletion-check anchor commit 7eb613c39fb8, and the remote did not serve it during that run. The commit exists on the remote, and this PR touches no file under packages/spec. Treated as a transient fetch flake; re-run once through the relay, and the re-run is success.
  • Check Changeset on this head was cancelled without a newer run superseding it. This body edit re-triggers it.

…hout waiting for the SMS send, as the emailed reset does

On the public door the reset text is built and sent after the response,
through the same helper the emailed reset uses; a send that fails is
logged on the server at error. A server-side call that carries no
request still awaits its send.

Claude-Session: https://claude.ai/code/session_01QSeKYn5CmmdShCJifm6WYj
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 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

3 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run.

What this run could not see
  • the SDK route bridge reached 61 of 219 client-bound route-ledger rows — the other 158 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 158: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 55 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 103 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 — 22 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 04cbdf78b602261054368c16e075b299eaa69ade → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 4d41b89e1d6e9a56a51a3cf5c314aa0e7d14c730 — the merge of head af6b561239528146bd89745a61b371bc7358e6cc into base 04cbdf78b602261054368c16e075b299eaa69ade, 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 4d41b89e1d6e9a56a51a3cf5c314aa0e7d14c730 && git checkout 4d41b89e1d6e9a56a51a3cf5c314aa0e7d14c730
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 04cbdf78b602261054368c16e075b299eaa69ade af6b561239528146bd89745a61b371bc7358e6cc && git checkout -B drift-repro 04cbdf78b602261054368c16e075b299eaa69ade && git merge --no-ff af6b561239528146bd89745a61b371bc7358e6cc

node scripts/docs-audit/affected-docs.mjs --json 04cbdf78b602261054368c16e075b299eaa69ade

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

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 3, 2026 20:31
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#1 · os-justin · session_01QSeKYn5CmmdShCJifm6WYj

席位核对

ACCEPT · head af6b561239528146bd89745a61b371bc7358e6cc · 2026-11-03T20:50Z

  • Shape: 6 files, +171/−17. Not governed (0 of 6 paths hit the register). Under 3000. Patch for plugin-auth. Clause-②: no, Metadata-protocol: none.
  • Review: no contract face is touched (no published schema, no governed rule text, no narrowing declaration), so this is the seat's own read at TIER_DEFAULT; no second agent.
  • Rule held (the maintainer's ruling on the reset request: the send leaves the request path): the phone-number reset request now answers at once, the same way for any number. Its reset text is sent after the response through the existing sendAfterResponseOnPublicDoor helper, the same one the emailed reset uses. A failed send is logged on the server. A server-side call, which carries no request, still awaits its send. No new mechanism.
  • Changeset prose (checked sentence by sentence against the diff):
    • "answers at once, the same way for any number": the helper is wired with the endpoint context's request.
    • "logged on the server, at error": logAfterResponseSendFailure with the medium in what; the emailed reset's line keeps its bytes.
    • "Unchanged … a server-side call … still awaits": the helper's no-request branch.
    • Rule level only, per §6.
  • Check-runs at this head (latest per name): 15 skipped, 33 success. Skips were judged by name: opt-in jobs and no UI change. check-expected-skips.mjs was NOT MEASURED. mergeable_state read before arming: clean.
  • CI note: Build Core first failed on a transient fetch of the spec deletion-check anchor commit. The commit exists on the remote and this PR touches no spec file. It was re-run once through the relay, with the flake reason recorded in the PR body, and passed. Check Changeset was cancelled with no superseding run; it was re-triggered by that body edit and passed.
  • Local gates: dispatch-gates --ran reports 59 derived, 59 run, 0 NOT MEASURED. Full plugin-auth suite: 3769 passed. Ablation: two legs, each red then restored green.
  • Landing: auto-merge.

@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 3, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 3, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#1 · os-justin · session_01QSeKYn5CmmdShCJifm6WYj

Re-queue · head af6b561239528146bd89745a61b371bc7358e6cc · 2026-11-03T21:33Z

The merge group on base 18112bfa77 left the queue because Checkout repository timed out after 20 minutes in two lint/type-check lanes (run 41719580038). No step ran on the code. The previous group on 7cfb38b2be passed every check. The PR head and its check-runs are unchanged, so it is re-queued once.

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

Development

Successfully merging this pull request may close these issues.

1 participant