Skip to content

feat(auth): connect OpenRouter accounts and free route#127

Merged
tcballard merged 2 commits into
mainfrom
codex/ios-openrouter-account-free
Jul 25, 2026
Merged

feat(auth): connect OpenRouter accounts and free route#127
tcballard merged 2 commits into
mainfrom
codex/ios-openrouter-account-free

Conversation

@tcballard

Copy link
Copy Markdown
Contributor

Summary

Adds the first approved native iOS account provider: OpenRouter OAuth PKCE, plus an explicit rate-limited OpenRouter Free destination.

Scope

  • adds WF-QUAL-0002 against OpenRouter's official OAuth and free-router contracts
  • connects through ASWebAuthenticationSession with Apple's HTTPS callback matcher
  • encodes unguessable state in the exact HTTPS callback path
  • exchanges only the documented code, verifier, and S256 method
  • stores OpenRouter's user-controlled key under the existing device-only OpenRouter Keychain credential
  • adds Accounts settings with connect, readiness, and disconnect states
  • adds the pinned openrouter/free destination alongside openrouter/auto
  • covers provider contract, credential lifecycle, route eligibility, and sign-out

Product / Architecture Decisions

  • Account auth and manual API-key setup converge on one credential; no second credential broker or token store is introduced.
  • OpenRouter Auto is labelled as credit-backed.
  • OpenRouter Free is labelled no-cost and rate-limited, retains the existing accounting class, and cannot silently fall back to a paid destination.
  • Connecting OpenRouter readies its destinations but does not mutate or enter Automatic.
  • ChatGPT/Codex remains paired-Mac-only; Kimi account auth remains blocked pending provider approval.

User-Facing Contract

Settings now has a distinct Accounts screen. A user can select “Continue with OpenRouter,” authenticate in the system web sheet, then explicitly choose either OpenRouter Auto or OpenRouter Free in Chat. Disconnect removes the issued credential from this device.

Verification

  • XcodeBuildMCP signed iPhone 17 simulator suite: 66 passed, 0 failed, 0 skipped
  • official HTTPS callback constraint verified against current OpenRouter documentation
  • exact OpenRouter authorization/exchange fixture coverage
  • account connection and disconnect update destination readiness without changing Automatic
  • free destination asserts openrouter/free, rate-limited copy, pinned-only eligibility, and shared credential custody
  • git diff --check

Review Path

  1. docs/qualifications/WF-QUAL-0002-openrouter-account-auth.md
  2. ios/WayfinderIOS/WayfinderIOS/OpenRouterAccount.swift
  3. ios/WayfinderIOS/WayfinderIOS/AccountsView.swift
  4. ios/WayfinderIOS/WayfinderIOS/AppModel.swift
  5. ios/WayfinderIOS/WayfinderIOSTests/OpenRouterAccountTests.swift

Notes For Reviewer

This is stacked on PR #126. Review and merge the earlier mobile provider stack before this layer.

AI-assisted implementation; tests, provider documentation, and repository state were verified locally.

@tcballard
tcballard force-pushed the codex/ios-account-auth-engine branch from e6c3e19 to be1b619 Compare July 25, 2026 19:55
@tcballard
tcballard force-pushed the codex/ios-openrouter-account-free branch from c377ec4 to 8e4bee3 Compare July 25, 2026 19:55
@tcballard
tcballard force-pushed the codex/ios-account-auth-engine branch from be1b619 to 49dd7b9 Compare July 25, 2026 20:27
@tcballard
tcballard force-pushed the codex/ios-openrouter-account-free branch from 8e4bee3 to 870d475 Compare July 25, 2026 20:27
@tcballard
tcballard force-pushed the codex/ios-account-auth-engine branch from 49dd7b9 to 208a1d3 Compare July 25, 2026 20:36
@tcballard
tcballard force-pushed the codex/ios-openrouter-account-free branch from 870d475 to 10acd99 Compare July 25, 2026 20:36
@tcballard
tcballard force-pushed the codex/ios-openrouter-account-free branch from 10acd99 to 4b8eca7 Compare July 25, 2026 20:43
@tcballard
tcballard changed the base branch from codex/ios-account-auth-engine to main July 25, 2026 20:43
@tcballard
tcballard marked this pull request as ready for review July 25, 2026 20:43
@tcballard
tcballard merged commit 94f0e47 into main Jul 25, 2026
7 of 8 checks passed
@tcballard
tcballard deleted the codex/ios-openrouter-account-free branch July 25, 2026 20:59
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