feat: add one-step gateway setup pairing#98263
Conversation
|
Codex review: stale review; fresh review needed. Summary Next step |
There was a problem hiding this comment.
Pull request overview
Adds a one-step mobile pairing path by introducing gateway-local setup short codes that redeem into the existing setup-code payload, and extending the setup-code bootstrap flow to auto-approve baseline mobile device + first node pairing.
Changes:
- Add a core plugin-state–backed short-code issuer/redeemer and expose a pre-auth HTTP redeem endpoint.
- Extend gateway WS connect handling to auto-approve baseline mobile node pairing during setup-code bootstrap (and add suite coverage for the approval boundary).
- Update
openclaw qroutput (text + JSON) and docs to include the short code and the new one-step behavior.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/pairing/setup-short-code.ts | Implements short-code issuance, normalization/formatting, and single-use redemption backed by plugin state. |
| src/pairing/setup-short-code.test.ts | Adds unit tests for issuing/redeeming, expiry behavior, and input normalization. |
| src/gateway/pairing-setup-short-code-http.ts | Adds the pre-auth HTTP handler for redeeming short codes into the setup payload with rate limiting. |
| src/gateway/server-http.ts | Routes /api/v1/pairing/setup-code/redeem to the new handler via lazy import. |
| src/gateway/auth-rate-limit.ts | Adds a dedicated rate-limit scope for setup short-code redemption attempts. |
| src/gateway/hooks-test-helpers.ts | Extends the HTTP request test fixture to support request bodies for JSON endpoints. |
| src/gateway/server-http.test-harness.ts | Plumbs request bodies through the gateway HTTP in-memory test harness. |
| src/gateway/server-http.probe.test.ts | Adds probe tests covering the redeem endpoint (success, one-time semantics, method checks, rate limiting). |
| src/gateway/server/ws-connection/message-handler.ts | Adds setup-code bootstrap-driven auto-approval for baseline mobile node pairing on connect. |
| src/gateway/server.auth.control-ui.suite.ts | Extends control-ui suite to cover node auto-approval for baseline mobile surfaces and pending behavior for upgrades. |
| src/cli/qr-cli.ts | Prints/registers short codes (where appropriate) and extends JSON output with optional short-code fields. |
| src/cli/qr-cli.test.ts | Covers CLI behavior for short-code registration, output rendering, and JSON field omission when unavailable. |
| docs/gateway/protocol.md | Documents one-step mobile bootstrap behavior and the short-code redeem endpoint contract. |
| docs/cli/qr.md | Documents new openclaw qr JSON fields, short-code semantics, and updated approval guidance. |
| docs/channels/pairing.md | Updates channel pairing docs to reflect one-step baseline mobile auto-approval and upgrade approval flow. |
623f361 to
2325294
Compare
|
Updated this PR at What changed:
Proof on the pushed SHA:
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
2325294 to
45941ea
Compare
|
Updated this PR again at Delta since the previous review-response push:
Current proof on the final local patch:
The PR is still Setup Code / QR first; setup short code is the optional gateway-local typing helper. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
Related: #98242
Supersedes the gateway half of #98243.
What Problem This Solves
Users setting up OpenClaw Mobile had to scan or paste a long setup code and then complete separate device/node approval steps. That made QR/setup-code onboarding feel like many steps instead of the intended one-step mobile setup.
Why This Change Was Made
This makes Setup Code and QR onboarding the primary one-step path: the app receives the Gateway URL/bootstrap auth from the setup-code payload, connects, and the Gateway silently approves only fresh baseline mobile device/node surfaces. The setup short code is a gateway-local convenience for typing the same setup-code payload on reachable local/co-resident Gateway flows; the long setup-code QR remains the durable fallback.
The node approval boundary is platform-specific for current iOS and Android app-declared capabilities/commands/permissions. Cross-platform, plugin, arbitrary, upgraded, or dangerous node command surfaces remain pending unless the Gateway owner explicitly allows them.
User Impact
A fresh mobile app can scan the QR or enter the setup code, save the Gateway URL/bootstrap auth, connect, receive bounded node/operator handoff tokens, and land connected without a separate manual approval step. Operators still get explicit pending approval flows for non-baseline or upgraded node surfaces.
Evidence
node scripts/run-vitest.mjs src/gateway/server.auth.control-ui.test.ts --testNamePattern "qr setup code"passed: 7 tests, 33 skipped.node scripts/run-vitest.mjs src/plugins/contracts/deprecated-internal-config-api.test.tspassed.node scripts/run-vitest.mjs src/pairing/setup-short-code.test.ts src/gateway/server-http.probe.test.ts src/cli/qr-cli.test.tspassed: 3 shards, 4 + 28 + 25 tests.node scripts/format-docs.mjs --check docs/cli/qr.md docs/channels/pairing.md docs/gateway/protocol.md docs/docs_map.md && node scripts/check-docs-mdx.mjs docs/cli/qr.md docs/channels/pairing.md docs/gateway/protocol.md docs/docs_map.md && node scripts/docs-link-audit.mjs docs/cli/qr.md docs/channels/pairing.md docs/gateway/protocol.md docs/docs_map.md && node scripts/generate-docs-map.mjs --checkpassed.git diff --check && node scripts/run-oxlint.mjs src/pairing/setup-short-code.ts src/gateway/pairing-setup-short-code-http.ts src/gateway/server.auth.control-ui.suite.ts src/gateway/server/ws-connection/message-handler.ts && node scripts/check-deprecated-api-usage.mjspassed.node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.test.src.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/test-src.gateway-comments.tsbuildinfopassed..agents/skills/autoreview/scripts/autoreview --mode local --prompt "Review the PR #98263 final comment-response patch only..."clean: no accepted/actionable findings.