Skip to content

Extract credential fill from the worker into credential-fill.ts - #223

Merged
CuriosityOS merged 1 commit into
mainfrom
extract-credential-fill
Sep 21, 2026
Merged

CuriosityOS merged 1 commit into
mainfrom
extract-credential-fill

Conversation

@CuriosityOS

Copy link
Copy Markdown
Collaborator

Why

src/worker.ts was 8,808 lines with ~234 top-level functions. The credential fill path (vault RPC, form detection, trusted typing, generate/rotate/pending) was the largest self-contained slice, ~1,300 lines, and already had its own test file that exercised it only through the worker.

What

  • New src/credential-fill.ts: createCredentialFill(deps) returning buildCredentials, performCredentialFill, finalizePendingCredential, recoveryFromError, vaultCall, vaultCallAtOrigin. Imports its pure helpers (credential-constants, credential-target-scan, untrusted-value, vault-capture) directly; takes only worker-owned state as deps (rpc, trackSecret, trackCredentialWriteSecrets, redactDeep, ensureSessionPage, humanClickTarget, actionTimeoutMs).
  • src/worker.ts: 8,808 → 7,489 lines. Keeps buildEnvelope and the credentialFill / credentialPending message handlers, which are execution-lifecycle glue rather than credential logic.
  • Code moved verbatim and re-indented. The four spec interfaces were hoisted to module level. No public API change; types/ untouched.

Verification

  • bun run lint, bun run typecheck, bun run check:build: clean
  • bun run test:unit: 1295 pass. One failure (local-ai custom endpoint validation) reproduces on main with this change stashed.
  • bun test --timeout 120000 tests/node/credential-fill.test.ts: 17 pass, including the real-Chromium detection/rotation/pending-commit test.
  • bun test --timeout 120000 tests/node/browser.test.ts: 129 pass.

Follow-ups planned as separate PRs: live-view/handoff RPC handlers, CAPTCHA action dispatcher, challenge scan.

src/worker.ts had grown to 8.8k lines; the credential fill flow was the
largest self-contained slice of it. This moves the vault RPC helpers, the
model-callable credentials.* API (buildCredentials), form detection and
target preparation, trusted field typing and performCredentialFill into
src/credential-fill.ts behind a createCredentialFill(deps) factory.

The worker keeps what is worker lifecycle rather than credential logic:
buildEnvelope and the credentialFill / credentialPending message handlers
(execution ref-counting, launch-state warnings, redaction-capacity
restarts). It hands the module the host rpc channel, the secret tracker,
the redaction net, ensureSessionPage and humanClickTarget as deps, so the
module reaches into no worker globals.

Code moved verbatim, re-indented; the four request interfaces were hoisted
to module level. No public API change, so types/ is untouched.

Verified: lint, typecheck, check:build, test:unit (1295 pass, one
pre-existing local-ai failure unrelated to this change),
credential-fill.test.ts with the harness timeout (17 pass, including the
real-browser detection/rotation/pending test), and browser.test.ts
(129 pass).
@greptile-apps

greptile-apps Bot commented Sep 21, 2026

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

Safe to merge: no actionable issues were found, and the covered credential behavior remained unchanged.

What we checked:

  • Ran the credential-fill-runtime-validation.sh script to exercise the runtime validation for credential filling. T-Rex
  • Reviewed the parent runtime capture to establish a baseline before the extraction step. T-Rex
  • Reviewed the extracted-runtime capture to verify the post-run state after the credential fill validation. T-Rex
  • Verified worker integration was exercised through the built public API rather than importing the worker source. T-Rex
  • Linked the evidence script and two runtime captures as artifacts to support review. T-Rex

Summary

Credential-management logic is now isolated in src/credential-fill.ts while src/worker.ts retains its execution and message lifecycle responsibilities. The built public runtime preserved the covered credential flows before and after the extraction.

Reviews (1) · Last reviewed commit: "Extract credential fill from the worker ..."

@CuriosityOS
CuriosityOS merged commit bab9a5b into main Sep 21, 2026
10 checks passed
@CuriosityOS
CuriosityOS deleted the extract-credential-fill branch September 21, 2026 10:02
@devin-ai-integration

devin-ai-integration Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

E2E review — PR #223 @ 69afb6d7

Verdict: no defects found. Code moved verbatim (every line removed from src/worker.ts is present in src/credential-fill.ts; only the createSecretsRedactor import differs), all deps passed to createCredentialFill are hoisted function declarations or consts defined above the call site, and the real credential flows behave identically end to end.

Environment: Ubuntu 22.04 x64 · Bun 1.4.0 · BetterChromium 153.0.8010.36-r2 (betterwright setup, checksum OK) · patchright-core 1.61.1 · base main = 9c4d4bbb.

What actually ran

Layer Command / flow Result
Lint / typecheck bun run lint, bun run typecheck passed (pre-existing lint warnings only)
Unit suite bun run test:unit 1287 pass, 2 fail — both native (win/linux) archive … packager tests, env-only (hashlib.file_digest needs Python ≥3.11; box has 3.10). Not related to this PR.
Focused suite bun test --timeout 120000 tests/node/credential-fill.test.ts 17 pass incl. the real-Chromium detection/rotation/pending test
SDK + real vault + real browser Disposable script: BETTERWRIGHT_HOME=/tmp/…, built-in LocalCredentialVault, local HTTP login/signup fixture, headed + headless BetterChromium 18/18 passed — credentials.save, inspect, fillCredential({submit:true}) (server received the exact stored secret, page shows "Welcome back"), typed DOM value redacted to [REDACTED_PASSWORD] in the envelope, ambiguous two-form page fails closed, generateAndFillCredential → server accepted 20-char matching new/confirm → commitGeneratedCredential → pending list cleared → committed record logs in, about:blank refused
CLI betterwright vault list on the disposable home shows both records created by the flows (persistence)
MCP betterwright mcp over stdio: initialize → tools/list (browser_login present) → browser navigate → browser_login {submit:true} login server-verified, "Welcome back", no secret in MCP output

Not applicable: no UI / types / docs changes; native artifacts untouched.

Video (headed BetterChromium, real-time, 2m06s)

Both scripted runs of the SDK flow: fill+submit login, redaction probe, ambiguous refusal, generate+fill+commit signup, re-login with the committed record.

Account created after generateAndFill; commit follows

Observations (not defects in this PR)

  • In headed mode BetterChromium's own "Save password?" bubble pops up after the trusted fill submits (visible in the video). This is browser-level password-manager behaviour untouched by this diff; I did not re-verify it against main, so treat it as an optional hardening note (e.g. credentials_enable_service: false pref / --password-store=basic), not a regression.

No fix PR needed.

Evidence-link limitation: GitHub direct video upload is not available from this tooling, so the MP4s are hosted as presigned Devin attachment links (token valid ~7 days from posting). The review sandbox's network allowlist blocks app.devin.ai, so I could not fetch the posted links back from inside the sandbox to confirm they resolve; the same files are also attached to the automation session log.

@devin-ai-integration

Copy link
Copy Markdown
Contributor

PR #223 @ 69afb6d reviewed E2E: no defects, no fix PR needed. Report posted at #223 (comment) (lint/typecheck, unit suite, focused suite, SDK+real vault+BetterChromium 18/18, CLI vault list, MCP browser_login; 2 unit failures are env-only Python 3.10 packager tests).

Limitation: MP4s are presigned Devin attachment links (~7-day token); the sandbox allowlist blocks app.devin.ai so I couldn't re-fetch the posted links to confirm they resolve — files attached here too.

This response includes attachments — view them in Devin

@CuriosityOS CuriosityOS mentioned this pull request Sep 21, 2026
9 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant