Repository navigation
Add interactive macOS helper for Roborock iOS authentication - #149
Conversation
Documents a macOS-assisted workflow for authenticating the official Roborock iOS app with local_roborock_server. Covers mitmproxy certificate setup via AirDrop, WireGuard onboarding, verification-code login, authentication handoff, reverse-proxy requirements, validation, cleanup, and troubleshooting.
Adds an interactive Bash wrapper for the existing Roborock iOS MITM authentication workflow on macOS. The helper validates the local server endpoint, manages the mitmproxy CA certificate and temporary MITM process, guides WireGuard and verification-code authentication, verifies the local authentication handoff, and performs cleanup.
Prevent locally generated onboarding configuration, PID, and log files from being committed. The configuration file may contain the user's local server domain and protocol sync secret.
Enhances the Bash onboarding wizard with ANSI colors, Unicode progress indicators, improved instructions, authenticated MITM browser navigation, and extensive developer-facing comments.
|
Substantial revision: V2 |
Update `docs/ios_mitm_onboarding.md` for the V2 onboarding helper. - Document the nine-step terminal wizard, ANSI colors, Unicode panels, and `NO_COLOR` support. - Clarify saving the verification code for manual entry after enabling WireGuard. - Require a fresh Roborock MITM WireGuard tunnel for each session. - Explain authenticated mitmweb URLs and `web_open_browser=false`. - Add troubleshooting for authentication errors, duplicate browser tabs, and startup failures. - Preserve the existing installation, reverse-proxy, and security guidance. - Compare implementation claims against the available script and retain conservative testing caveats. Validation: `bash -n` passed for the available helper. Full end-to-end onboarding testing remains outstanding.
Lash-L
left a comment
There was a problem hiding this comment.
Automated review: changes requested
Thanks for this. A guided wizard for the iOS MITM login is useful, and the script itself is careful about some things that matter: it uses no sudo, makes no keychain or trust changes on the Mac (it only reveals the existing ~/.mitmproxy/mitmproxy-ca-cert.cer in Finder), creates the config with umask 077 + chmod 600, creates the log with mode 0600, never echoes the secret, and only opens a mitmweb token URL after it checks that URL against the live /flows endpoint. --set web_open_browser=false does reach mitmweb, because mitm_redirect.py appends the unknown args it collects with parse_known_args() to the mitmweb command (mitm_redirect.py:693,763). The iPhone-side steps (AirDrop profile install, Full Trust, the code-entry screen not allowing paste, WireGuard tunnel reuse) could not be checked here. They are iOS behaviour, which isn't in the decompiled sources.
Blocking
-
roborock_onboard.sh:514,579: the port is hardcoded to 443. The preflight goes tohttps://${ROBOROCK_DOMAIN}/...and the launcher is always given--local-api https://${ROBOROCK_DOMAIN}:443. The default stack serves HTTPS on :555 (mitm_redirect.pyDEFAULT_LOCAL_API_PORT = 555,docs/roborock_app.md), so on a default install without a reverse proxy the wizard fails at Step 3 and can't be used. If someone typeshost:555, the result ishttps://host:555:443. Fix: accepthost[:port], check it (for example^[A-Za-z0-9.-]+(:[0-9]+)?$), and pass it to--local-apiunchanged somitm_redirect.pyapplies its own :555 default. Use the same authority for the curl preflight, or drop that preflight entirely:mitm_redirect.pyalready runs the same preflight and refuses to start if it fails (mitm_redirect.py:737-742). -
roborock_onboard.sh:692,713: "Confirm the Saros 10R appears" is the author's own model. Say "your robot(s)" instead. -
docs/ios_mitm_onboarding.md: several sections are notes to the author, not to users, and they contradict the PR:- "Developer notes and testing status" says the copy it reviewed "does not contain extensive commentary" and "Do not describe the final revision as independently end-to-end tested". Meanwhile the PR body says end-to-end testing is done.
- The Quick start says to "Add
.roborock_onboard.conf… to.gitignorebefore publishing the helper". This PR already does that. - The Files tree says "Community helper; add this file".
- "Contributing upstream" asks whether "the maintainer would like this included".
- "Requirements" says to rename
mitm_redirect_fixed_v2.py.
Please remove these, keep the user-facing content, use relative links instead of absolute GitHub URLs, and add the page to
mkdocs.ymlnav and link it from the iPhone section ofdocs/roborock_app.md. As it stands the page is orphaned and doesn't appear in the published docs.
Should fix
roborock_onboard.sh:516,580: the sync secret goes on the command line twice, once as the curl-H "X-Local-Sync-Secret: …"argument and once as--sync-secret "$SYNC_SECRET". Any local user can read it withpswhile the commands run, and the doc's own caveat already says so. Fix:MITM_LOCAL_SYNC_SECRET="$SYNC_SECRET" uv run "$MITM_SCRIPT" …, which the launcher already reads (mitm_redirect.py:721). If you keep the curl preflight, send the header through stdin (curl -H @- … <<<"X-Local-Sync-Secret: $SYNC_SECRET").roborock_onboard.sh:90-93,104: the config is written asKEY='$VALUE'and later loaded withsource. If a value contains a', the config breaks: the next run fails with a syntax error, or runs the rest of the line as shell code. Fix: write it withprintf 'ROBOROCK_DOMAIN=%q\n' "$ROBOROCK_DOMAIN", or read it back withwhile IFS='=' read -r k vinstead ofsource.roborock_onboard.sh:127:pgrep -f 'mitmweb.*mitm_redirect.py' | head -n 1matches amitm_redirect.pymitmweb started from any checkout, and only the first match.stop, Step 8 and the abort handler can therefore kill an unrelated MITM session. If theuv→python→uvx→mitmweb chain leaves more than one matching process, the others survive. Thekill -9fallback on theuvPID (lines 143, 224) also does not reach the mitmweb grandchild. Fix: match the absolute"$MITM_SCRIPT"path and loop over every match (pkill -TERM -f -- "-s $MITM_SCRIPT", then wait, then-KILL).roborock_onboard.sh:321: the fallbackuv run mitmdumpcannot work. mitmproxy is not a project dependency (pyproject.toml), so the command fails silently (its output goes to/dev/null) and the user only sees "mitmproxy did not create …". Useuvx --from mitmproxy mitmdump, the same waymitm_redirect.pydoes.- Neither the docs nor Step 9 mention
mitm_logs/<session>/.mitm_redirect.py_log_flowwrites the full request and response headers and bodies there, including the Roborock cloud login response with the user's token andrriotkeys. Tell users to delete that directory after onboarding, or offer to do it in Step 9.
Nits
roborock_onboard.sh:537: the preflight never sendsuser_data, so the server cannot return 2xx (server.py_handle_protocol_sync_route). A 2xx here would most likely come from a proxy or captive page. Treat it as a failure.roborock_onboard.sh:765-767: "✓ WireGuard is OFF" and "✓ Full Trust is OFF" are printed as successes, but nothing checks them. Word them as reminders.roborock_onboard.sh:170: on Ctrl+C,$?is the status of the last command, so an aborted run can exit 0.roborock_onboard.sh:111: onlyhttps://is stripped from the domain, nothttp://.
Checks: bash -n passes, the merge into main is clean, and the full test suite passes (uv run --extra dev pytest -q: 295 passed; the PR adds no tests). The helper itself was not run.
I've converted this PR to draft while these are addressed. Mark it ready for review again once they're fixed and it will go through another review.
This is an automated review by Claude Code, checked against the decompiled Roborock app (APK + device plugin bundles), python-roborock and a vacuum firmware dump. It can be incorrect, so please reply if any finding looks wrong.
Improve server verification, credential handling, authenticated MITM startup, process ownership, session management, and recovery behavior. Complete user-facing documentation, MkDocs integration, and runtime file exclusions.
Substantial revision V3 addressing maintainer feedbackI've substantially revised the macOS iOS onboarding wizard in commit The revision includes:
The user guide now matches the implementation and addresses the requested documentation corrections, including relative links, MkDocs navigation, and a link from the existing iPhone instructions. The wording also explains connection settings and temporary proxy shutdown more clearly for beginners. The branch has been synchronized with upstream. Existing upstream content, including plugin-refresh documentation, the manual onboarding alternative, and all navigation entries, has been preserved. Testing claims now reflect the available evidence: Bash syntax and static documentation checks passed. The author tested this script on his setup. Thank you for the detailed review and feedback. |
Lash-L
left a comment
There was a problem hiding this comment.
Automated review: passed (nits)
Now that this has passed the automated review, I'll do a human review and then either request changes or merge it.
Thanks for the V3 rework. The process supervisor, the literal config format and the preflight that matches the launcher are a solid improvement.
Earlier items
- Hardcoded :443: fixed.
normalize_endpointacceptshost[:port]and--local-api "$ROBOROCK_DOMAIN"is passed unchanged, somitm_redirect.pyapplies its own :555 default (mitm_redirect.py:694-701). The curl preflight drops an explicit:443the same way the launcher'slocal_api_httpdoes. - "Saros 10R": fixed. It now says "your robot(s)".
- Notes to the author in the docs: fixed. The developer-notes, contributing and
_fixed_v2text is gone, links are relative, the page is in themkdocs.ymlnav androborock_app.mdlinks to it. - Secret in argv: fixed. It goes in through
MITM_LOCAL_SYNC_SECRET(mitm_redirect.py:721), and the curl header is read from stdin. - Sourced config: fixed. A v2 literal key=value file is written atomically and never sourced.
pgrepmatching: fixed. Shutdown now only signals a process group whose supervisor is checked by start time and argv. Scan matches are only reported, never killed.uv run mitmdump: fixed. It now usesuvx --from mitmproxy mitmdump.mitm_logs/<session>/: fixed.capture_cleanup_guidancefinds the session from the[LOG] Rewrittenline (mitm_redirect.py:216) and the docs warn about it.- Nits: all fixed. A 2xx is rejected (it needs 400 +
missing_user_data, which matchesserver.py:937). The phone-state messages are now reminders. Signals exit 130/143/129.http://is stripped.
New nits (non-blocking)
roborock_onboard.sh:341-342:command -v python3always finds/usr/bin/python3on macOS, including the Command Line Tools stub on Macs without CLT. Theuv python findfallback then never runs, andcheck_requirementsreports "Python 3.8 or newer is required" even though uv is installed. Fix: check that the candidate actually runs ("$candidate" -c 'import sys') before you accept it, otherwise fall back touv python find.roborock_onboard.sh:234: a malformed v2 line returns 1 without a message, sostartexits silently. Print the same "Run '$0 config'" hint as the other branches.roborock_onboard.sh:304-310: the secret prompt only gives the Home Assistant path. Docker users need "admin page → Protocol Auth" (docs/home_assistant.md:61). The rest of the repo also says "add-on", not "Apps".roborock_onboard.sh:1507:stop_mitmprints its own "STOP MITM SERVER" box straight after the Step 8 header. Pass a flag to skip it.roborock_onboard.sh:1262: the mitmweb token ends up inopen's argv. This is minor and probably unavoidable, but the comments promise "out of process arguments", so a short note would help.
Unverifiable
The iPhone side can't be checked from the app sources: AirDrop install of the .cer, the profile under VPN & Device Management, Full Trust, the app not allowing a pasted code, and a code requested with WireGuard off still working when submitted through the tunnel. The manual iPhone procedure uses mitm.it instead of AirDrop. Both should work, but only the author's testing backs this route.
Checks
shellcheck (shellcheck-py, -S style) is clean and bash -n passes. The merge into main is clean and the full test suite passes (uv run --extra dev pytest -q: 785 passed; the PR adds no tests). The wizard itself was not run.
This is an automated review by Claude Code, checked against the decompiled Roborock app (APK + device plugin bundles), python-roborock and a vacuum firmware dump. It can be incorrect, so please reply if any finding looks wrong.

What does this PR do?
Adds an interactive macOS Bash wizard for connecting the official Roborock iOS app to an already configured Roborock Local Server.
The existing MITM login procedure requires carefully ordered certificate, email-code, and WireGuard steps.
roborock_onboard.shguides users through that process, checks configuration early, manages the temporary MITM proxy, and provides clear recovery instructions.It builds on the existing
mitm_redirect.pyworkflow. It does not install the server, provision robot Wi-Fi, or replace the project's robot onboarding procedure.Guided onboarding workflow
Before the numbered steps, the wizard verifies the server connection and Protocol Sync Secret. Users can correct configuration problems before changing iPhone trust settings or requesting a short-lived verification code.
The wizard then guides users through these nine steps:
Phone settings, login, maps, and controls require user confirmation. Manual checkpoints have no startup timeout.
Terminal interface and usability
NO_COLOR.config,status, andstopcommands for configuration and recovery.Server verification and address handling
400with structured JSONdata.reasonequal tomissing_user_data; JSON spacing and key order do not matter.555and preserves explicit ports, including reverse-proxy port443.http://andhttps://prefixes while retaining HTTPS connections.Credential handling and authenticated browser access
/flowsendpoint.Process management and cleanup
8081without stopping its listener or overwriting the existing startup log.sudoor macOS Keychain changes.Captures can contain complete request and response data, including login tokens, credentials, and
rriotkeys. The guide explicitly instructs users to delete only the identified session's captures after successful onboarding and remove the separate startup log when troubleshooting is finished. Capture deletion remains manual.Documentation and maintainability
Extensive inline Bash comments explain configuration parsing, credential transport, verification, certificate generation, process ownership, browser authentication, cleanup, and the required login sequence.
The user guide has been rewritten to match the implementation and address maintainer feedback. Development notes, publishing instructions, obsolete behavior, and unsupported testing claims have been removed.
The guide is linked from the iPhone section and MkDocs navigation. Shared-file changes are minimal and preserve upstream's manual procedure, plugin-refresh documentation, and all existing navigation entries.
Runtime ignore rules cover saved configuration, session state, locks, certificate diagnostics, and startup logs. Traffic captures retain their existing ignore coverage.
Proof that it works
Tested by author on:
3.2.57; Python3.12.11for static checks.What I did and what happened:
/bin/bash -n roborock_onboard.shpassed.git diff --check upstream/mainpassed.The strict MkDocs build could not start because
mkdocswas unavailable. Relevant launcher and onboarding-preflight tests could not start becausepytestwas unavailable.The author previously reported 64 regression methods and disposable-process and HTTPS/curl smoke tests. The complete harness and execution results were unavailable during review, so these are not listed as independently verified passes. The earlier upstream 295-test result is not evidence for this revised helper.
Successful end-to-end onboarding of the final revision on a real iPhone and Roborock remains unverified.
Compatibility and remaining limitations
uv,uvx,curl, and macOSopen..roborock_config.*and.roborock_pid.*still need ignore coverage.