feat(client): add authenticated origin requests#30
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Add a public Effect client for structured, schema-decoded JSON requests authenticated by the live browser page. Applications can atomically ensure a named Browser Control session, bind it to an exact origin, and issue same-origin requests without exporting cookies or generating execute scripts.
Sensitive responses use Effect
Redacted, bypass execute journals, setCache-Control: no-store, and fail closed while session network capture is active.The packaged agent skill is also reorganized around an inspect-act-verify golden path with explicit completion criteria.
Before / After
Before: Application integrations had to invoke the CLI, embed JavaScript strings, parse execute envelopes, and use out-of-band private files to keep short-lived credentials out of journals. When imported from Bun, managed relay startup also reused Bun as the relay runtime, causing Playwright CDP checkout to time out.
After: Applications call the typed
BrowserControlClientandAuthenticatedOrigin.jsoninterface. Browser authentication stays inwindow.fetch, responses are schema-decoded, mutation ambiguity is explicit, and imported clients always launch the relay with Node even when the consumer runs under Bun.How
src/browser-control-client.tsexposes the Effect service, session capability, typed errors, sensitive decoding,reveal, and session reset.src/authenticated-origin.tsvalidates origins and paths, performs bounded page-context fetches, blocks redirects, and classifies request outcomes.src/session-manager.tsatomically ensures sessions and serializes authenticated requests with existing lifecycle permits.src/http-api.ts,src/relay-client.ts, andsrc/relay-schema.tsdefine the two typed relay routes and wire contracts.scripts/build-cli.ts,src/index.ts, andtsconfig.build.jsonbuild and publish the ESM library entrypoint with declarations.src/relay-lifecycle.tsmaps the library entrypoint to the packaged CLI and allows Bun consumers to launch the relay explicitly with Node.Scope
This does not serialize multi-request application workflows under one relay-owned transaction. Destructive workflows that require cross-process exclusivity, verification, and rollback should remain a single execute until that capability exists.
Saved authentication profiles remain an explicit, separate adapter. Authenticated-origin requests never read captured credentials or Secret Profiles.
Testing
pnpm typecheckpnpm test(361tests passed)pnpm build:clipnpm pack --dry-rungit diff --checknode .../dist/cli.js serveas the managed processFlow