Skip to content

feat(native): complete T3 Connect Clerk Native auth, DPoP relay connect, and Connect i18n (#93) - #472

Merged
rynfar merged 2 commits into
nativefrom
nw/h5-standalone-relay-93
Nov 20, 2026
Merged

rynfar merged 2 commits into
nativefrom
nw/h5-standalone-relay-93

Conversation

@rynfar

@rynfar rynfar commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Closes #93

Completes CN-RELAY purely client-side inside apps/native/** with zero upstream T3 changes:

Summary

  1. Fix GET /v1/environments 404: Updated Cloud::discover (apps/native/crates/client/src/connect.rs) from /v1/client/environments to the contract endpoint GET /v1/environments with 401 invalid_bearer retry on Clerk sessions.
  2. Pure client-side Clerk Native Frontend API (_is_native=1) auth:
    • Added ClerkClient (apps/native/crates/client/src/connect.rs) and pure parsers/models (apps/native/crates/core/src/connect.rs) supporting:
      • Social OAuth (oauth_google, oauth_github, oauth_apple, oauth_microsoft) targeting com.t3tools.t3code://callback via native macOS ASWebAuthenticationSession (apps/native/crates/app/src/auth_session_macos.rs, AuthenticationServices.framework + objc2/block2 anchored to the active NSWindow with clean cancellation on ASWebAuthenticationSessionErrorCodeCanceledLogin).
      • Inline email sign-in (email_code or password) plus needs_second_factor (totp / backup_code) directly inside the Connect card.
      • Owner-only 0o600 cloud-clerk.json session persistence with rotated Authorization header tracking on every response, t3-relay JWT minting & caching (until 15s before exp), and best-effort DELETE /v1/client/sessions/{id}?_is_native=1 + clearing both cloud-clerk.json and cloud-oauth.json on sign-out.
      • Legacy cloud-oauth.json compatibility showing "Sign in with T3 Connect to enable direct relay connections." only when a legacy OAuth token is present without a Clerk session.
  3. Full RFC 9449 DPoP exchange, live /status, and /connect relay connections:
    • Implemented POST /v1/client/dpop-token (t3-web, environment:connect environment:status), POST /v1/environments/{id}/status, and POST /v1/environments/{id}/connect (clientProofKeyThumbprint) with 401 invalid_bearer 1x retry and RFC 3339 expiresAt -> epoch ms conversion.
    • Added dpop::register_relay_credential (binding both httpBaseUrl and normalized wsBaseUrl origins while preserving seed_token across renewals) and store.rs relay-managed tracking (relay-managed.json + SavedEnvironments::upsert_relay) without altering SavedEnvironment's struct fields.
    • Wired clicking Connect on discovered T3 Connect environments to mint & register the credential, upsert/activate the saved environment, and attach a supervisor Prepare hook that refreshes the relay credential (and handles PrepareError::Moved endpoint relocation) before reconnecting.
  4. Connect screen i18n & parity ledger:
    • Routed user-facing strings in apps/native/crates/app/src/connect.rs through crate::i18n::t / t_fmt.
    • Updated row CN-RELAY in apps/native/parity/LEDGER.md to done.

Verification

  • vp fmt --check apps/native/parity/LEDGER.md: PASS
  • CARGO_INCREMENTAL=0 cargo clippy --manifest-path apps/native/Cargo.toml --workspace --all-targets -- -D warnings: PASS (0 warnings)
  • T3_NATIVE_HOME=$(mktemp -d) CARGO_INCREMENTAL=0 cargo test --manifest-path apps/native/Cargo.toml -p t3-core --lib: 1,895 passed, 0 failed
  • T3_NATIVE_HOME=$(mktemp -d) CARGO_INCREMENTAL=0 cargo test --manifest-path apps/native/Cargo.toml -p t3-client --lib: 175 passed, 0 failed (includes mock HTTP server tests for GET /v1/environments, Clerk Native OAuth + email/2FA + header rotation, DPoP exchange/proof verification/401 retry, /status, /connect credential registration)
  • T3_NATIVE_HOME=$(mktemp -d) CARGO_INCREMENTAL=0 cargo test --manifest-path apps/native/Cargo.toml -p t3-native --features snapshot -- --test-threads=1 connect::tests: 6 passed, 0 failed

Built with Antigravity.

@rynfar
rynfar merged commit cd48b9f into native Nov 20, 2026
@rynfar
rynfar deleted the nw/h5-standalone-relay-93 branch November 20, 2026 18:28
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