Skip to content

feat(macos): sign in with OpenClaw ID and approve this Mac as your device - #197630

Merged
jalehman merged 14 commits into
mainfrom
feat/ocid-mac-sign-in-first
Nov 13, 2026
Merged

jalehman merged 14 commits into
mainfrom
feat/ocid-mac-sign-in-first

Conversation

@jalehman

@jalehman jalehman commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

A Mac can join an OpenClaw ID claw only as a node with a separate invite, and nobody signs in. That isn't how a person uses their own Mac. Josh approved sign-in-first enrollment on 2026-11-11: the person signs in and the Mac becomes their own device.

User Impact

  • Sign in with OpenClaw ID in onboarding (and Settings for an existing Tailscale/token/SSH Mac) now does this:
    1. Signs in natively.
    2. Lists the person's claws.
    3. Makes this Mac an owner device of the chosen claw, either by comparing six digits with a device that already has access or by entering the recovery kit.
  • The Mac then reaches chat and the dashboard over OpenClaw ID with its own key and runs tools through its bound node. There's no VPN and no Gateway token.
  • Settings → Connection gets an OpenClaw ID section with these actions:
    • Stop using this Mac for tools, or use it again.
    • Remove this Mac.
    • Sign in again, shown when a tools-off Mac's Discovery session has ended.
    • Switch to OpenClaw ID (migration from a Tailscale, token or SSH connection).
  • Migration replaces the existing connection and clears its saved Gateway token and password. Tailscale itself is untouched, and going back means Change connection… with a new setup code.
  • The headless node-invite path (feat(macos): enroll Mac nodes through OpenClaw ID invitations, with native hosting onboarding #196759) is unchanged and is still offered as "Use a node invitation".

Not live-testable yet:

  • The staging Mac OAuth client is registered (DulSrXtaYtPaLEnzEyHGuAHpVNWmaNbf), but Discovery staging only accepts its tokens after openclaw/discovery#14 is deployed.
  • The node binding in start and add_owner_device needs openclaw/discovery#13 and this protocol stack (feat(openclaw-id): approve an app's node together with its owner device #197573) deployed.
  • Until then, sign-in reaches the issuer, and every Discovery call is refused.

Stacking: stacked on #197585 (feat/ocid-mac-ocid-connection). The protocol side is #197573 (node on the SAS start and on add_owner_device, and the approver UI).

Member invite join is not in this PR. It goes in a second stacked PR to keep this one reviewable. A member account that picks a claw here gets "Ask for an invite" instead.

Why This Change Was Made

The Mac follows the protocol's "Owner device node" design (enrollment.md). It holds three keys, each in its own Keychain service, and none of them ever goes over the node bridge:

  • D_mac signs.
  • W_mac is its owner peer key, used for chat and the dashboard.
  • W_node is the only key the node worker sees, and it never carries human authority.

Enrollment works like this:

  • SAS. The Mac is the new-device side of the owner-browser SAS. start carries node {peer_key: W_node, description}, so the compared digits bind all three keys and the tool surface. Before the Mac opens the sealed handoff, the person must confirm the digits on the Mac too. The handoff's binding must then verify under its root for this claw and hostname, and its cert must name this D and W.
  • Recovery kit. R is derived in-process from the typed code or a kit file. If fp(R) isn't the descriptor's root, nothing is signed. R signs OwnerDeviceCert and add_owner_device {cert, node} at snapshot seq + 1, and they're sent as a root_statement. A seq_conflict notice is answered by re-signing at the re-read verified snapshot's seq + 1 (up to 3 times).
    • R is dropped when the attempt ends: admitted, refused, cancelled or after 2 minutes. The deadline is checked again right before every signature.
    • R is never stored, logged or sent. CryptoKit-held key bytes can't be explicitly zeroed (the same limit as the browser's WebCrypto key); the seed and decoded secret are zeroed. The typed String can't be zeroed either.
  • Admission. The Mac is admitted only when the claw's K_gw-signed snapshot lists W_mac as an owner peer key and W_node in node_peer_keys. The existing join-completion owner then switches the primary connection and opens the dashboard.

The Swift ports (JCS statements, kit decode, R derivation, SAS commitment, transcript, code, AES-GCM handoff and peer-key proof) are checked byte for byte against vectors generated from the TypeScript protocol at #197573.

Evidence

All build and test runs were on the Mac Studio in a separate checkout, built with OPENCLAW_IROH_NATIVE=1.

  • Builds: swift build --build-tests for apps/shared/OpenClawKit and for apps/macos (both green).
  • Shared tests: OpenClawID filter, 45 tests in 6 suites, 8 consecutive green runs at 3d4dabcb9221.
    • OpenClawIDOwnerEnrollmentTests checks the kit, root, SAS and statement vectors.
    • It also covers: the handoff must name this claw and device; kit seq_conflict re-sign; wrong kit or invalid code signs nothing; SAS opens the handoff only after the code is confirmed on the Mac (a mismatch aborts and pins nothing); a declined request.
  • App tests: 45 tests in 9 suites green, run in the sandbox (sandbox-exec: no network or Keychain).
    • Includes the new OnboardingOpenClawIDSignInTests: build config, the callback's state and issuer checks, claw routing by relationship, no claws, cancelled sign-in, invalid kit installs nothing, the automatic approval wait, and switching to the kit cancels the wait.
  • scripts/format-swift.sh macos and scripts/lint-swift.sh macos are clean. The native i18n baseline was regenerated.
  • Inherited from the base: OnboardingPageTests "verified node setup…" hangs in the sandbox inside DashboardManager.shared init. It hangs the same way on feat(macos): OpenClaw ID primary connection + dashboard proxy #197585's head.
  • Review:
    • pr-simplify: no architecture removed. One owner per responsibility: crypto port, Discovery account calls, enrollment client, route refresh, owner actions, sign-in, device store, Settings model.
    • Astra autoreview: 5 findings, all verified and fixed. P0: confirm the SAS code on the Mac before opening the handoff. P1: reconcile a self-removal whose answer is lost. P1: Sign in again for a tools-off Mac. P2: the route re-reads the node key and session on every verification. P2: kit deadline across awaits.

Renders are real views with fixture data from the sandboxed render harness; screenshots: #197630 (comment) (local copies: ~/.openclaw/workspace/reports/ocid-mac-sign-in-first-mockups/impl/). Recovery-kit entry can't be rendered there: NSSecureTextField blocks on the window-server lookup the sandbox denies. Its render is the mockup of the same view.

Live-proof checklist (blocked on discovery#13 + #14 deploy)

  • Sign in on staging; the claw picker lists the owned claw.
  • SAS approve from the original local Control UI. The approval dialog shows "will also be able to run tools", the codes match on both screens, and the Mac pins and connects.
  • Expected chat attribution: on main every OpenClaw ID owner device maps to the shared Owner profile (gateway-owner-profile.ts, openclawIdOwner). The Mac's chat should land there with owner/admin scopes, not as an accountless person. Personal-profile mapping is OCF-510, out of scope.
  • The node connects with W_node, and Access shows it as this device's node.
  • Recovery-kit enrollment works. Owners see "Recovery kit used". A wrong kit shows "That recovery code didn't work".
  • Settings: stop tools, then use tools again; remove the Mac (connection ends, keys and primary cleared).
  • Migration from a Tailscale connection: the token is cleared and Tailscale is still running.

Known gaps

  • Member invite join comes in the stacked follow-up PR.
  • A Mac with tools off reads the claw with the person's 12-hour Discovery session. After it ends, Settings offers Sign in again; chat reconnects fail until then.
  • Self-removal whose answer is lost is reconciled from Discovery's snapshot. If that also can't be read, Settings shows an error rather than guessing.
  • The token is kept only as a Discovery session in the Keychain. The ID token itself is never stored.

Screenshots: inspected before/after comparison.

@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@jalehman

Copy link
Copy Markdown
Contributor Author

Renders (real SwiftUI views, fixture data, sandboxed render harness; not live)

mac-b01 is the mockup render of the same recovery-kit entry view: NSSecureTextField cannot lay out in the render sandbox.

mac-a02-where

mac-a02-where

mac-a03-sign-in

mac-a03-sign-in

mac-a04-signing-in

mac-a04-signing-in

mac-a05-claw-picker

mac-a05-claw-picker

mac-a06-choose-approval

mac-a06-choose-approval

mac-a07-compare-code

mac-a07-compare-code

mac-a08-compare-code-confirmed

mac-a08-compare-code-confirmed

mac-a09-owner-connected

mac-a09-owner-connected

mac-b01-kit-entry-light (mockup)

mac-b01-kit-entry-light (mockup)

mac-b02-kit-connected

mac-b02-kit-connected

mac-d01-settings-migrate

mac-d01-settings-migrate

mac-d02-migrate-confirm

mac-d02-migrate-confirm

mac-e01-settings-owner

mac-e01-settings-owner

mac-e02-stop-tools-confirm

mac-e02-stop-tools-confirm

mac-e03-remove-mac-confirm

mac-e03-remove-mac-confirm

mac-e04-settings-owner-tools-off

mac-e04-settings-owner-tools-off

mac-e05-start-tools-confirm

mac-e05-start-tools-confirm

mac-f01-claw-offline

mac-f01-claw-offline

mac-f02-denied

mac-f02-denied

mac-f03-expired

mac-f03-expired

mac-f04-kit-invalid

mac-f04-kit-invalid

mac-f05-no-claws

mac-f05-no-claws

mac-f06-member-needs-invite

mac-f06-member-needs-invite

mac-f07-sign-in-failed

mac-f07-sign-in-failed

@jalehman
jalehman force-pushed the feat/ocid-mac-ocid-connection branch from 92649f3 to b64a0ad Compare November 12, 2026 08:14
@jalehman
jalehman force-pushed the feat/ocid-mac-sign-in-first branch from 3d4dabc to 605dc4a Compare November 12, 2026 08:23
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 12, 2026
@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head 605dc4a58b2ab79e5ad8eec8a265b9e48ad87106, but the PR head is now f45062439dc23168ab43b5888ec8c9bc1d409332. Its old verdict and PR readiness labels are no longer current.

Next step
Comment @clawsweeper re-review when the current head is ready; pushes after the first review are not reviewed automatically.

Review history (1 earlier review cycle)
  • reviewed 2026-11-12T08:39:59.937Z sha 605dc4a58b2ab79e5ad8eec8a265b9e48ad87106 :: blocked before merge. :: [P1] Preserve the existing device expiry when enabling tools | [P1] Clear the primary connection only when it belongs to this enrollment | [P2] Propagate a failed primary-connection migration | [P2] Offer sign-in recovery after the node is disabled remotely

@jalehman
jalehman force-pushed the feat/ocid-mac-ocid-connection branch from b64a0ad to 989fb2e Compare November 12, 2026 10:01
@jalehman
jalehman force-pushed the feat/ocid-mac-sign-in-first branch from 605dc4a to f450624 Compare November 12, 2026 10:01
@clawsweeper clawsweeper Bot removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Nov 12, 2026
@jalehman
jalehman force-pushed the feat/ocid-mac-ocid-connection branch from 989fb2e to 59b3f23 Compare November 12, 2026 11:46
@jalehman
jalehman force-pushed the feat/ocid-mac-sign-in-first branch from f450624 to 3def66d Compare November 12, 2026 11:47
@jalehman
jalehman force-pushed the feat/ocid-mac-ocid-connection branch from 59b3f23 to c65af21 Compare November 12, 2026 12:18
@jalehman
jalehman force-pushed the feat/ocid-mac-sign-in-first branch from 3def66d to ec30bb0 Compare November 12, 2026 12:18
@jalehman
jalehman force-pushed the feat/ocid-mac-ocid-connection branch from c65af21 to eae42e5 Compare November 12, 2026 12:40
@jalehman
jalehman force-pushed the feat/ocid-mac-sign-in-first branch from ec30bb0 to 2028e51 Compare November 12, 2026 12:40
@jalehman
jalehman force-pushed the feat/ocid-mac-ocid-connection branch from eae42e5 to 44f9a99 Compare November 12, 2026 13:11
@jalehman
jalehman force-pushed the feat/ocid-mac-sign-in-first branch from 2028e51 to 33297cd Compare November 12, 2026 13:11
@jalehman
jalehman force-pushed the feat/ocid-mac-ocid-connection branch from 44f9a99 to cdd5423 Compare November 12, 2026 13:45
@jalehman
jalehman force-pushed the feat/ocid-mac-sign-in-first branch from 33297cd to 468ad34 Compare November 12, 2026 13:45
…emoval, renew the Discovery session

- open the sealed SAS handoff only after the person confirms the six digits on this Mac; a mismatch aborts
- finish local removal when the revocation's answer is lost but the claw no longer lists this Mac
- offer Sign in again when a tools-off Mac's Discovery session ended
- read the node key and session on every route verification
- check the recovery-kit deadline right before each signature
@jalehman
jalehman force-pushed the feat/ocid-mac-sign-in-first branch from e38f39d to a1df6f4 Compare November 13, 2026 21:50
@jalehman
jalehman marked this pull request as ready for review November 13, 2026 21:52
@jalehman

Copy link
Copy Markdown
Contributor Author

Before/after screenshots — sign-in-first macOS enrollment

After: a8cde34563bad25279deb333b38dcf0d28984fc8. Before: main at b74fa8348ffc27bdc4211e3f9739f7afd0e0e9cf. These are presentation fixtures, not live enrollment evidence. Images were individually inspected; only synthetic .test accounts/hosts and a fixed sample comparison code are shown.

Baseline sheets were captured on macOS from the exact main OnboardingOpenClawID model/view source using an isolated, sandboxed fixture harness. The new sheets use the exact PR content view; Settings uses its unchanged production view with an inert observable fixture model (no action execution). Existing repair-render outputs supply sign-in and the save-failure screen. The source-only harness avoids changing the occupied build checkout and avoids the personal-looking labels/non-reserved domains in older fixtures. No app, operator profile, login Keychain, or live enrollment was used.

Entry point / state Before — main After — this PR
Sign in Main sign-in sheet Sign-in-first sheet
Claw picker Main fixture claw picker Owner enrollment claw picker
Compare six digits Main node-only comparison Owner-device comparison with explicit match confirmation
Recovery option (closest main fixture, not the same operation) Main save-recovery-kit fixture Choose another device or recovery kit
Connected result Main separate node and chat completion fixture Owner-device completion after recovery-kit approval
Settings — owner device No isolated main Settings render path was found. Main has no OpenClaw ID section; its full Connection view reaches live singleton owners, so it was not launched. OpenClaw ID owner Settings including Open Dashboard and device actions
Settings — migrate existing connection Same baseline limitation; no fabricated Settings screenshot. Sign in and switch an existing connection

Dark appearance

Before After
Main picker dark PR picker dark

Latest repair: failed primary-connection save

Failed migration offers Try again instead of false completion

Capture gaps: the secure recovery-kit entry itself has no working path in the enabled sandbox render fixture (NSSecureTextField layout is excluded there). The recovery-choice and recovery-success screens above are real views; no mockup is substituted for entry. Full native Settings baseline and menu captures are unavailable in the isolated fixtures. These screenshots do not prove OAuth, admission, or recovery round trips.

@jalehman
jalehman enabled auto-merge (squash) November 13, 2026 22:26
@jalehman
jalehman merged commit 697d366 into main Nov 13, 2026
77 checks passed
@jalehman
jalehman deleted the feat/ocid-mac-sign-in-first branch November 13, 2026 22:34
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 14, 2026
…vice (openclaw#197630)

* wip: sign-in-first OpenClaw ID enrollment on macOS

* wip: tests and renders for sign-in-first enrollment

* test(macos): keep the render fixture's approval wait pending

* style(macos): wrap sign-in-first OpenClaw ID code within Swift lint limits

* style(apple): apply SwiftFormat to sign-in-first OpenClaw ID code

* test(apple): unnest the handoff vector lookup

* test(apple): unwrap before the throwing field reads

* fix(macos): confirm the OpenClaw ID code on the Mac, reconcile self-removal, renew the Discovery session

- open the sealed SAS handoff only after the person confirms the six digits on this Mac; a mismatch aborts
- finish local removal when the revocation's answer is lost but the claw no longer lists this Mac
- offer Sign in again when a tools-off Mac's Discovery session ended
- read the node key and session on every route verification
- check the recovery-kit deadline right before each signature

* test(apple): long-poll the scripted mailbox; wrap the tools re-add call

* fix(apple): pass the OpenClaw ID pin and listed key as tuples in device trust checks

* style(apple): satisfy strict iOS SwiftLint in OpenClaw ID device enrollment

* fix(macos): keep the OpenClaw ID sign-in callback off the main actor

* fix(macos): preserve atomic OpenClaw ID enrollment completion

* fix(macos): show migration failure without success copy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: macos App: macos P2 Normal backlog priority with limited blast radius. size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant