Skip to content

feat: port Client and loopback OAuth from wavekat-cli#2

Merged
wavekat-eason merged 4 commits into
mainfrom
feat/initial-client-port
May 14, 2026
Merged

feat: port Client and loopback OAuth from wavekat-cli#2
wavekat-eason merged 4 commits into
mainfrom
feat/initial-client-port

Conversation

@wavekat-eason
Copy link
Copy Markdown
Contributor

Summary

Lands the v0.0.1 surface from docs/01-initial-port.md (which is included in this PR — supersedes #1 after the branch rename).

  • Storage-agnostic Client::new(base_url, token) + whoami() / revoke_current_token() and the lower-level get_json / post_json / delete / put_proxy_bytes / put_presigned_bytes / get_stream_to helpers.
  • Two-phase loopback OAuth: loopback_handshake returns a PendingHandshake { url(), state(), wait().await }. The crate does not open browsers — caller decides (webbrowser::open for CLI, shell.openExternal for desktop, println! for remote).
  • Token newtype with redacted Debug (keeps wkcli_ prefix, hides the rest), no Display.
  • thiserror typed Error (Http / Network / Decode / StateMismatch / Cancelled / Timeout / BadRequest / Io) + Result alias.
  • Public Me { id, login, name, email, role }.
  • examples/smoke.rs for the manual smoke test (login / whoami / revoke).
  • Deps per the plan — only one fresh add vs the CLI's vetted set: thiserror. MSRV pinned to 1.75.

Test plan

  • cargo check --workspace --all-targets
  • cargo test --workspace — 14 unit tests + 1 doctest pass (includes base64url_rfc_vectors, random_state_shape, html_escape_handles_metacharacters ported verbatim from wavekat-cli, plus new tests for Token redaction, Error::Http format, HandshakeOptions::default, and loopback_handshake URL shape).
  • cargo clippy --workspace --all-targets -- -D warnings clean.
  • cargo fmt --all -- --check clean.
  • cargo doc --no-deps -p wavekat-platform-client --all-features builds.
  • Manual smoke against platform.wavekat.com per the plan:
    • cargo run --example smoke -- login
    • cargo run --example smoke -- whoami --token \$TOKEN
    • cargo run --example smoke -- revoke --token \$TOKEN

🤖 Generated with Claude Code

e10101 and others added 4 commits May 14, 2026 16:20
Work plan for getting from the empty scaffold on main to a usable
v0.0.1 on crates.io: what to port from wavekat-cli, the public
surface, dep set, file layout, test plan, and the open design
questions to settle before code lands. Companion to
wavekat-voice/docs/13-platform-login-and-client.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Land the v0.0.1 surface from docs/01-initial-port.md: storage-agnostic
Client, two-phase loopback OAuth handshake (crate returns the URL,
caller opens it), Token newtype with redacted Debug, thiserror-typed
Error, and the Me/whoami + revoke_current_token typed methods.

Carries over the unit tests verbatim from wavekat-cli (base64url RFC
vectors, random_state shape, html_escape) and adds tests for Token
redaction, Error::Http format, HandshakeOptions::default, and the
loopback_handshake URL shape. Includes examples/smoke.rs for the
manual smoke test against a live platform.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Mirror the prefix rename happening in wavekat-platform PR #116. The
crate doesn't hardcode the prefix in functional code (the Token
newtype splits on `_` for its redacted Debug), but tests, docs, and
examples all referenced the old prefix.

The CLAUDE.md guidance is also updated — it previously said "don't
rename, the prefix is just a string"; that's true once users have
stored credentials in the wild, but we're explicitly doing it now
because there are no real users yet.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Mirror the wire-format change in wavekat-platform: the loopback flow
now sends `?client=<short>[&source=<host>]` instead of a single
`?name=<short> on <host>`. Lets the platform's consent UI render the
two parts separately and lets future token-management UIs sort or
group by app independent of which machine the token was minted from.

API changes (breaking, but nothing has consumed v0.0.1 yet):

- `HandshakeOptions::client_name: Option<String>` →
    `HandshakeOptions::client: Option<String>` (defaults to
    `"wavekat-platform-client"`)
  + `HandshakeOptions::source: Option<String>` (defaults to the
    machine hostname)
  + `HandshakeOptions::omit_source: bool` (privacy escape hatch for
    desktop apps that don't want to disclose the hostname).

Tests: explicit client+source override, omit-source path, default-
falls-back-to-hostname. All 16 unit tests + 1 doctest pass; clippy
+ fmt clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@wavekat-eason wavekat-eason merged commit ab4a1e9 into main May 14, 2026
1 check passed
@github-actions github-actions Bot mentioned this pull request May 14, 2026
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.

2 participants