Skip to content

feat: refuse payment actions, signal security checks, add page_request - #31

Merged
gcharang merged 8 commits into
devfrom
u3-payment-stop
Dec 3, 2026
Merged

gcharang merged 8 commits into
devfrom
u3-payment-stop

Conversation

@gcharang

@gcharang gcharang commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Three additions the Smart Compliance Platform's browser agents need, usable by Understudy's own sessions too:

  • Payment stop. The CDP driver refuses click, Enter, NumpadEnter, Space, and type with submit: true on an order-placement control or its form (English and Arabic labels, cash on delivery included, with or without card fields), and any type into a cc-* autocomplete field or a recognised payment-provider frame. Each ends ok: false, reason: "payment_refused" before any input event is dispatched. A target that changes after pointer movement or text insertion ends target_changed before activation. The classifier (apps/extension/src/driver/payment-guard.ts) is reimplemented from Nanobrowser's design (Apache-2.0, credited in its header).
  • Security-check signal. Semantic capture and live input checks report CAPTCHA and verification-code pages with the new reason security_check, so a caller stops instead of trying to solve them.
  • page_request. A read command that makes one packaged, credentialed, same-origin fetch inside the lease's allowed origins and returns JSON (capped at 32 KiB, redirects refused). GET by default; POST, PUT, PATCH and DELETE need prepare/grant and an exact origin, method and path listed in the lease policy (pageRequestWrites). The command carries data only; all executable logic is packaged in the extension.

Protocol: ActionFailureReasonSchema gains payment_refused and security_check; CommandSchema gains page_request; new capability page-request-v1. Understudy's backend accepts the new reasons and capability. Changeset included.

Release order

This changes the protocol, so the Smart Compliance Platform's vendored copy of @understudy/protocol must be re-forked and live before a store build carrying it ships: this PR merged to dev → SCP re-fork deployed → dev → master → store submission (RUNBOOK.md).

Test plan

  • CI (ci.yml)
  • Classifier tests: each signal in English and Arabic, card autocomplete values, provider frame, Enter on a focused order-placement control, cash-on-delivery "Confirm order" with no card field
  • page_request: cross-origin and off-policy refusal, redirect refusal, size cap

🤖 Generated with Claude Code

gcharang and others added 8 commits December 3, 2026 00:17
The driver refuses click, Enter, NumpadEnter, Space and type with
submit on the final order-placement control or its form (cash on
delivery included, English and Arabic), and typing into cc-* fields or
payment-provider frames, before any input event (payment_refused).
Captures and input checks report CAPTCHA and verification-code pages
as security_check. page_request makes one packaged, credentialed,
same-origin fetch inside the lease's origins: GET by default, writes
only where the lease policy lists the exact origin, method and path,
redirects refused, JSON capped at 32 KiB.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The protocol package compiles against ES2022 alone, so the global URL
type is missing there. It takes the runtime's WHATWG URL from globalThis
through a local type and returns only the fields callers read.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cloudflare's Durable Object RPC types expand a recursive type alias
without bound, so the backend typecheck hit TS2589 once Event carried
the z.json() body. Named interfaces keep the same JSON shape and leave
runtime validation by z.json() unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The driver hit-tests the click point, checks every clickable role the
capture offers, matches more English and Arabic order and pay labels
after normalising digits and invisible characters, refuses any key on a
card field and modifier chords outside a navigation allowlist, and
reports only visible challenges as security checks. A page_request write
that may have reached the site ends unknown and unsafe to retry; write
rules bind origin, path and query; credentialed GET needs act approval.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The capture stores names with bidi controls stripped, so the fixture
seeds the same normalised name the live check compares against.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@gcharang
gcharang merged commit ad2a6b2 into dev Dec 3, 2026
1 check passed
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