diff --git a/.agents/product-marketing.md b/.agents/product-marketing.md index 9519eda..02e409d 100644 --- a/.agents/product-marketing.md +++ b/.agents/product-marketing.md @@ -98,7 +98,7 @@ B2C, single-actor product — skipped per skill guidance (no multi-stakeholder b ## Goals **Business goal:** none revenue-related — goal is working software, honest positioning, and (per user) a Product Hunt launch for visibility among developers. -**Conversion action:** `git clone`/`npm install` + first successful `hinge tier` call. +**Conversion action:** `git clone`/`cargo build --release` + first successful `hinge tier` call. **Current metrics:** 0 installs, 0 GitHub stars tracked at time of writing (repo just made public). ## Paid Ads diff --git a/.env.example b/.env.example index a303305..74ac7d0 100644 --- a/.env.example +++ b/.env.example @@ -9,7 +9,7 @@ HINGE_SESSION_FILE= # or bw://hinge-session. When set, nothing is written to disk. See docs/auth.md. HINGE_SESSION_REF= -# Only needed for `hinge inspect` (Appium/WebDriverAgent exploration), not for tier/limits/auth. +# Only needed for `hinge doctor` and `hinge inspect` (Appium/WebDriverAgent exploration), not for tier/limits/auth. HINGE_APPIUM_URL=http://127.0.0.1:4723 HINGE_UDID= HINGE_BUNDLE_ID=co.hinge.mobile.ios diff --git a/.github/assets/demo.gif b/.github/assets/demo.gif index 66d5e35..5c9560f 100644 Binary files a/.github/assets/demo.gif and b/.github/assets/demo.gif differ diff --git a/.github/assets/demo.tape b/.github/assets/demo.tape index 2109f39..8236af3 100644 --- a/.github/assets/demo.tape +++ b/.github/assets/demo.tape @@ -24,7 +24,7 @@ Wait Type 'BIN="$(mktemp -d)"' Enter Wait -Type `printf '#!/bin/sh\nexec node "%s/dist/cli.js" "$@"\n' "$REPO_ROOT" > "$BIN/hinge"` +Type `printf '#!/bin/sh\nexec "%s/target/release/hinge" "$@"\n' "$REPO_ROOT" > "$BIN/hinge"` Enter Wait Type 'chmod +x "$BIN/hinge"' diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 0c49346..e381a71 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,7 +5,7 @@ updates: directory: "/" schedule: interval: weekly - - package-ecosystem: npm + - package-ecosystem: cargo directory: "/" schedule: interval: weekly diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 33517e8..09d5651 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,9 +11,5 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - - uses: actions/setup-node@v7 - with: - node-version-file: .node-version - cache: npm - - run: npm ci + - run: rustup update stable --no-self-update - run: bash scripts/verify diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index 6bf1616..95162a5 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -18,12 +18,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - - uses: actions/setup-node@v7 - with: - node-version-file: .node-version - cache: npm - - run: npm ci - - run: npm audit --audit-level=high + - run: cargo install cargo-audit --locked + - run: cargo audit secret-scan: runs-on: ubuntu-latest @@ -44,5 +40,6 @@ jobs: - uses: actions/checkout@v7 - uses: github/codeql-action/init@v4 with: - languages: javascript-typescript + languages: rust + build-mode: none - uses: github/codeql-action/analyze@v4 diff --git a/.node-version b/.node-version deleted file mode 100644 index 0247ac7..0000000 --- a/.node-version +++ /dev/null @@ -1 +0,0 @@ -v26.10 diff --git a/AGENTS.md b/AGENTS.md index fd8ce5b..938d1ef 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -6,10 +6,11 @@ - Purpose and non-goals: `intent.md`. Architecture: `docs/architecture.md`. Decisions: `docs/adr/`. ## Stack -- Language-neutral repository; see README.md. +- Rust (edition 2024, Cargo). Single binary `hinge`; modules in `src/`, unit tests inline (`#[cfg(test)]`). ## Commands -- Verify everything: `scripts/verify` +- Verify everything: `scripts/verify` (`cargo fmt --check`, `cargo clippy -D warnings`, `cargo test`) +- Build: `cargo build --release` ## Verification - Run `scripts/verify` before handing work back; it must pass. CI runs the same command and is the authoritative gate. @@ -17,7 +18,7 @@ ## Constraints - Commit messages follow Conventional Commits (see `.gitmessage.txt`). Keep changes small and focused. -- Do not reformat unrelated code. Do not edit generated files, lockfiles by hand, or the single version source. +- Do not reformat unrelated code. Do not edit generated files or `Cargo.lock` by hand; the version lives only in `Cargo.toml`. - Never commit secrets or `.env` files. `.env.example` holds names and safe placeholders only. ## Approval boundaries diff --git a/CHANGELOG.md b/CHANGELOG.md index c5dc2bd..ac34449 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,22 @@ rather than editing several version sources by hand. Format: [Keep a Changelog]( ## [Unreleased] +## [0.2.0] - 2026-11-28 +### Changed +- **Rewritten in Rust** (edition 2024; clap, tokio, reqwest with rustls, serde). All commands and + output formats are preserved: `doctor`, `tier`, `limits`, `auth import|status|logout`, `inspect`, + `secret`, the global `--json` flag, `HINGE_*` environment variables and the `op://`, `bw://`, + `keychain://`, `cmd://`, `env://` secret references. Appium is now spoken over the W3C WebDriver HTTP + protocol directly. Build with `cargo build --release` (binary `target/release/hinge`); Node.js is no + longer needed. +- Every HTTP request now sends the user agent of a generic Android phone. The session's own + `user-agent` is no longer stored (`hinge_token.py` and `auth import` drop it). +- CI, the Security workflow (`cargo audit`, CodeQL for Rust), Dependabot (cargo), `CONTRIBUTING.md`, the + README, `AGENTS.md` and `docs/` updated for the Rust toolchain; the demo GIF was re-recorded. +- The version source is now `Cargo.toml` (was `package.json`). +### Removed +- The TypeScript sources, `package.json`, `package-lock.json`, `tsconfig*.json` and `.node-version`. + ## [0.1.6] - 2026-11-28 ### Added - `docs/index.html`: single-file landing page for GitHub Pages with an animated ASCII background diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 578dbe9..47670a0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,15 +17,15 @@ Enable the template once: `git config commit.template .gitmessage.txt`. - `scripts/verify` green; tests added or updated for changed behaviour. - Docs, ADR or changelog updated when behaviour, contracts or architecture change. - Dependency changes reviewed explicitly (new packages, version bumps, lockfile diff). -- **Every PR bumps `package.json`'s version per [SemVer 2.0.0](https://semver.org/):** patch for +- **Every PR bumps `Cargo.toml`'s version per [SemVer 2.0.0](https://semver.org/):** patch for fixes/docs/internal changes, minor for backward-compatible additions, major for breaking changes. - Use `npm version --no-git-tag-version` (never hand-edit the version field — - see AGENTS.md) and add a matching entry to `CHANGELOG.md`. Git tags are still created only at - actual npm publish time (`docs/deployment.md`'s Release steps), not on every PR. + Edit the `version` line in `Cargo.toml` (the single version source) and run `cargo build` so + `Cargo.lock` follows; add a matching entry to `CHANGELOG.md`. Git tags are still created only at + actual release time (`docs/deployment.md`'s Release steps), not on every PR. ## README demo GIF `.github/assets/demo.gif` is recorded, not hand-made. After a change to the CLI's output or -command list, re-record it with [VHS](https://github.com/charmbracelet/vhs): `npm run build && vhs +command list, re-record it with [VHS](https://github.com/charmbracelet/vhs): `cargo build --release && vhs .github/assets/demo.tape` (run from the repo root; the tape builds a throwaway `hinge` shim and a fake `$HOME`, so it never touches a real session or calls the live Hinge API). @@ -33,8 +33,8 @@ fake `$HOME`, so it never touches a real session or calls the live Hinge API). - Reviewer: @ifthenelse approves all changes; CODEOWNERS requires their review on every path, and on `.github/` and `docs/security/` specifically. - Single-maintainer repository: self-review follows the PR requirements above (verify green, tests - updated, docs/ADR updated) plus a 24h cooling-off before merging anything touching `src/secrets.ts`, - `src/session-store.ts`, `src/api.ts`, or `.github/workflows/`. + updated, docs/ADR updated) plus a 24h cooling-off before merging anything touching `src/secrets.rs`, + `src/session_store.rs`, `src/api.rs`, or `.github/workflows/`. ## Escalation Security concerns: see [SECURITY.md](SECURITY.md). Blocked reviews or anything else: open a GitHub diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..7c3c17c --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1704 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "anstream" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" + +[[package]] +name = "anstyle-parse" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.61.2", +] + +[[package]] +name = "anyhow" +version = "1.0.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cb931c189b85683d69a5cfad41d4d418671e1ac413dd209f3f2fc31e3cfd902" + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "aws-lc-rs" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "048006790404103c488e6c5616b3e7e702a71292aadda08e8f7698a9e0d2eb53" +dependencies = [ + "aws-lc-sys", + "zeroize", +] + +[[package]] +name = "aws-lc-sys" +version = "0.47.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bfbe32ac36b3c428696ce315464181bc4029d689fd58e3f2a4e58c252242f52" +dependencies = [ + "cc", + "cmake", + "dunce", + "fs_extra", + "pkg-config", +] + +[[package]] +name = "base64" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" + +[[package]] +name = "bumpalo" +version = "3.20.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87a0cf66fd1eb2fb7b822cb78370d82303750809bc6ba855f3f58e517d3238db" + +[[package]] +name = "bytes" +version = "1.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "776dfebd015e2d8732c684a2c71003674ccb49457b539b9e82151ba38e96dd7c" + +[[package]] +name = "cc" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95e45cf2980b2d467be49a9ed942c9179b701063a7ca3d037de7ee9bd67f8d66" +dependencies = [ + "find-msvc-tools", + "jobserver", + "libc", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "cfg_aliases" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" + +[[package]] +name = "chacha20" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06" +dependencies = [ + "cfg-if", + "cpufeatures", + "rand_core", +] + +[[package]] +name = "clap" +version = "4.6.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50066ca966813ca8957ee15361752f19424a8ff620dbe9c8993d9f99d99b04b3" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.6.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0ed97c96ef4efb3cc84e09fa388df4463e7cc3224ec38d7b1d9e45749333590" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4c174f11f949b9ca8c60580925e282b9cbd5454750e506f08648b2038080cd7" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "clap_lex" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0921b3876b3a1df8a1c9f912e7f94342458022c2e84288015893d83c4d62a79" + +[[package]] +name = "cmake" +version = "0.1.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0f78a02292a74a88ac736019ab962ece0bc380e3f977bf72e376c5d78ff0678" +dependencies = [ + "cc", +] + +[[package]] +name = "colorchoice" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570" + +[[package]] +name = "combine" +version = "4.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4356eba6976435498d05a311ee9fc486da3bc81c200d3f0d7dd9703b41913f92" +dependencies = [ + "bytes", + "memchr", +] + +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "cpufeatures" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566" +dependencies = [ + "libc", +] + +[[package]] +name = "displaydoc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "dunce" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" + +[[package]] +name = "equivalent" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" + +[[package]] +name = "find-msvc-tools" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e44f110d1777dc6559a51e7d45083945ded4f1bf3305494350f693b6d20b9c8" + +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + +[[package]] +name = "form_urlencoded" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afa489199eaffb1211795df1c6236ce1ad0d41a6fa45250add73e3b02420f06e" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + +[[package]] +name = "futures-channel" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" + +[[package]] +name = "futures-task" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" + +[[package]] +name = "futures-util" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "slab", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "r-efi", + "rand_core", + "wasm-bindgen", +] + +[[package]] +name = "hashbrown" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "735eaa21a6a5ffb2e84362faaeb90c05ba8e19797ca30428478cb6ea3a4921bc" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hinge-cli" +version = "0.2.0" +dependencies = [ + "anyhow", + "clap", + "reqwest", + "serde", + "serde_json", + "tokio", + "uuid", +] + +[[package]] +name = "http" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "918d3568bebf352712bc2ef3d46a8bcf1a75b373be6539de198e9105cbbf9ce0" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2a8f2913ee65f60facd6a5905613afaa448497a0230cc41ce022d93290bc2c" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23169fe34a5fbcdd3f3862e78fb9b6fccd5f02a6dc6f732547005d45631ce71c" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "hyper" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "229c6ff5584df4c6becbfe00567128bac768c8cd32ebc8a8366bd81ed072e8f3" +dependencies = [ + "atomic-waker", + "bytes", + "futures-core", + "http", + "http-body", + "httparse", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfa8e654703247911e29c23fbeaa261834bd9bb74efba2f9acddc37bfb127f53" +dependencies = [ + "http", + "hyper", + "hyper-util", + "rustls", + "tokio", + "tokio-rustls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddc03d96684f9226b8a787cdb71488417b53ab5ea8fdb1dac946cb9431cc8bff" +dependencies = [ + "base64", + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "httparse", + "hyper", + "ipnet", + "libc", + "percent-encoding", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", +] + +[[package]] +name = "icu_collections" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43" +dependencies = [ + "displaydoc", + "potential_utf", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" + +[[package]] +name = "icu_properties" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "020bfc02fe870ec3a66d93e677ccca0562506e5872c650f893269e08615d74ec" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "616c294cf8d725c6afcd8f55abc17c56464ef6211f9ed59cccffe534129c77af" + +[[package]] +name = "icu_provider" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "2.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "ipnet" +version = "2.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "791930b43c0d5973160d90a8f3894509f2b273430f5c5c73b668636d0287c5c0" + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" + +[[package]] +name = "itoa" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4" + +[[package]] +name = "jni" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5efd9a482cf3a427f00d6b35f14332adc7902ce91efb778580e180ff90fa3498" +dependencies = [ + "cfg-if", + "combine", + "jni-macros", + "jni-sys", + "log", + "simd_cesu8", + "thiserror", + "walkdir", + "windows-link", +] + +[[package]] +name = "jni-macros" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a00109accc170f0bdb141fed3e393c565b6f5e072365c3bd58f5b062591560a3" +dependencies = [ + "proc-macro2", + "quote", + "rustc_version", + "simd_cesu8", + "syn 2.0.119", +] + +[[package]] +name = "jni-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6377a88cb3910bee9b0fa88d4f42e1d2da8e79915598f65fb0c7ee14c878af2" +dependencies = [ + "jni-sys-macros", +] + +[[package]] +name = "jni-sys-macros" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38c0b942f458fe50cdac086d2f946512305e5631e720728f2a61aabcd47a6264" +dependencies = [ + "quote", + "syn 2.0.119", +] + +[[package]] +name = "jobserver" +version = "0.1.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3" +dependencies = [ + "getrandom 0.4.3", + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dc09d2154098bbf4ef54eab6b117a3c24cbbffe94046b16ee6d6d4510584d3a" +dependencies = [ + "cfg-if", + "futures-util", + "wasm-bindgen", +] + +[[package]] +name = "libc" +version = "0.2.191" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" + +[[package]] +name = "litemap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" + +[[package]] +name = "log" +version = "0.4.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c" + +[[package]] +name = "lru-slab" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4050469837a6ff301cd14c1f8f24f88549e6d548f24f64e2148eb0f72cebc51f" + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "mio" +version = "1.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20521a903f02b0a573cd6840e9d0a5a0cc043d361fe924092cd70f8556cc9c4a" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.61.2", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "once_cell_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" + +[[package]] +name = "openssl-probe" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e036b411754132fd6b74e94b74e9a13c5cf606fa93d1885c35860d3060820b1" + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pin-project-lite" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c938015719552d665fd0553b90d96cd7ff58e83e4c061ca99e6bb78865a72752" + +[[package]] +name = "pkg-config" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" + +[[package]] +name = "potential_utf" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" +dependencies = [ + "zerovec", +] + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quinn" +version = "0.11.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4051e23e9185c255a7e33ef59cdbca87a22d359052eecd22fc6b901fb37d9d11" +dependencies = [ + "bytes", + "cfg_aliases", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls", + "socket2", + "thiserror", + "tokio", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-proto" +version = "0.11.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e750cca55fe4f0439a15d0bb529da9651e79993e8e72c61a899a36d462befbe" +dependencies = [ + "aws-lc-rs", + "bytes", + "getrandom 0.4.3", + "lru-slab", + "rand", + "rand_pcg", + "ring", + "rustc-hash", + "rustls", + "rustls-pki-types", + "slab", + "thiserror", + "tinyvec", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-udp" +version = "0.5.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af66907df18639dcf4db56ca65490cabc4b27a97dbadd96f2926cca73298f016" +dependencies = [ + "cfg_aliases", + "libc", + "once_cell", + "socket2", + "tracing", + "windows-sys 0.61.2", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "rand" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f6fa277c67e6ea590466f04c3fe82cb509f0864fe470643e5570de9514a9b11" +dependencies = [ + "chacha20", + "getrandom 0.4.3", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" + +[[package]] +name = "rand_pcg" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb95882a1e14462c69aea9984bb261293ccfe6022ef8de0eda18bd5afb0052df" +dependencies = [ + "rand_core", +] + +[[package]] +name = "reqwest" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16a1cfa75cc186dd73d5818e510e042e40927bccc9c236b061cea97e1eb08029" +dependencies = [ + "base64", + "bytes", + "futures-core", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-util", + "js-sys", + "log", + "percent-encoding", + "pin-project-lite", + "quinn", + "rustls", + "rustls-pki-types", + "rustls-platform-verifier", + "serde", + "serde_json", + "sync_wrapper", + "tokio", + "tokio-rustls", + "tower", + "tower-http", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.17", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustc-hash" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "rustls" +version = "0.23.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf" +dependencies = [ + "aws-lc-rs", + "once_cell", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-native-certs" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a073f5dc7469f984c52ad2752b63b0807745133b6de880b7b64c1ac4c48aec4" +dependencies = [ + "openssl-probe", + "rustls-pki-types", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-pki-types" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "102f35f7de7b06d8c61f1cff6592f5253e0dea431c74867aad5dfd70f44663fb" +dependencies = [ + "web-time", + "zeroize", +] + +[[package]] +name = "rustls-platform-verifier" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1167586491e2b18b8bfbb293e8180ec17c201c4f076d7cb3070ca964e7598f98" +dependencies = [ + "core-foundation", + "core-foundation-sys", + "jni", + "log", + "once_cell", + "rustls", + "rustls-native-certs", + "rustls-platform-verifier-android", + "rustls-webpki", + "security-framework", + "security-framework-sys", + "webpki-root-certs", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls-platform-verifier-android" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eec689c0bc40ff2458a5977b6619cb718087084a18e02a131c599b62d05e1a5f" + +[[package]] +name = "rustls-webpki" +version = "0.103.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a0760a887c14823fca5a1c970b01d47c328c696c0c64829d1df50e8f853fd5" +dependencies = [ + "aws-lc-rs", + "ring", + "rustls-pki-types", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "schannel" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cb23c424d8ee841bb4d813677ca237e2a610067d594fec130f87d6093495ab5" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "security-framework" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "serde_json" +version = "1.0.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" +dependencies = [ + "foldhash", + "indexmap", + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "simd_cesu8" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11031e251abf8611c80f460e19dbdeb54a66db918e49c65a7065b46ac7aec520" +dependencies = [ + "rustc_version", + "simdutf8", +] + +[[package]] +name = "simdutf8" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.16.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3244542535d5de959d90ec55d1b5ff0fd2bb7b1310223907d5f11932847f7b59" + +[[package]] +name = "socket2" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] + +[[package]] +name = "synstructure" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "thiserror" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "tinystr" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abc840c238154d58f9e86b2792261edfde565a17696e1cda1a449de27979801a" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tinyvec" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee" + +[[package]] +name = "tokio" +version = "1.54.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3" +dependencies = [ + "bytes", + "libc", + "mio", + "pin-project-lite", + "socket2", + "tokio-macros", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-macros" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9cc2678c2cdd569ef8215e2afd7954ada2ae20b4fdd2c5fe6139a3b02d105db" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tower" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-http" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840" +dependencies = [ + "bitflags", + "bytes", + "futures-util", + "http", + "http-body", + "pin-project-lite", + "tower", + "tower-layer", + "tower-service", + "url", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "unicode-ident" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f00cd2407bb42c0ef17be88d4cf020f5cceffd121665bac9b8b9493a369b3b1a" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8_iter" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af3bd9d3e571c26fcce9d033b87ea5ab061b8d2ffe9b7a5675d810d68f03edf0" +dependencies = [ + "utf_types", +] + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "utf_types" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a3b425286980a367278453f3b6d28cdcb134b574e5a35824a6ff5eebad50bb6" + +[[package]] +name = "uuid" +version = "1.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ef6dac1e96601b4fb3acccccff2139741fcb757cb9a36089bf5be91cfb285ce" +dependencies = [ + "getrandom 0.4.3", + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "walkdir" +version = "2.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42e295b7452c4604982280d8586001fcad9b8b201cac67bca9771e7a7475403" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "want" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec4cdd0dd910afe868b7ef477227d8d538b46b3075031afee8a9f2acb0a2ed0b" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasm-bindgen" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0181c14ddd6c7b8b0b0132a5f1ea2f32be0d893cd3ea97b6e3b28886b8a3d1c" +dependencies = [ + "cfg-if", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e14e0327cb5368ad60ccb22d04a9827a693c95a926d8d125e9fa39e0baec501" +dependencies = [ + "js-sys", + "tokio", + "wasm-bindgen", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e931a02a39abdbf66966fc35902b5ed58344750a70885bed4ebb3d8eaf28ed9" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ca4b54280e455bd831e33a6b8e734baf432fe63fbc35c42ac14ce67a043a53a" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn 3.0.10", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b1f9c3798725016c6ee5f2f57869ec0831e8bbc0ab0310a86e787e97f41389e" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "web-sys" +version = "0.3.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7d179596ff5ec0f6de4db64d54011bde6289cc49603d3a6e4ce3f329207ab88" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki-root-certs" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "293198dcebfb821155b5092ab94b5a82ff180eddd7241df3bd6e66a4ffd1a585" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "writeable" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" + +[[package]] +name = "yoke" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "417ef3fcf6c300b7dbd25c85531a746931c02ad536f3cf4786ed1e88223340b3" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", + "synstructure", +] + +[[package]] +name = "zerofrom" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85ccff8a4805aba1eaa4cd4afcd49f7557dd2cf5fd79ffc37f8959466effc5aa" + +[[package]] +name = "zerotrie" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f58a2799cfe9a1670c7ea8edbd52ef8edb93cb37a7f83bf31ba9e35d9dae6a40" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3743ddbf47738d929cd1ae2e199d40d0162979dfe31aef8ae646d2bf00bf97a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..570856a --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "hinge-cli" +version = "0.2.0" +edition = "2024" +description = "Command-line client for your own Hinge account, built on its reverse-engineered HTTP API." +license = "MIT" +repository = "https://github.com/ifthenelse/hinge-cli" +rust-version = "1.85" + +[[bin]] +name = "hinge" +path = "src/main.rs" + +[dependencies] +anyhow = "1.0.105" +clap = { version = "4.6.10", features = ["derive"] } +reqwest = { version = "0.13.5", default-features = false, features = ["json", "rustls"] } +serde = { version = "1.0.229", features = ["derive"] } +serde_json = { version = "1.0.154", features = ["preserve_order"] } +tokio = { version = "1.54.1", features = ["rt-multi-thread", "macros"] } +uuid = { version = "1.26.1", features = ["v4"] } + +[dev-dependencies] +tokio = { version = "1.54.1", features = ["net", "io-util"] } diff --git a/README.md b/README.md index c514f59..ca512fb 100644 --- a/README.md +++ b/README.md @@ -35,13 +35,13 @@ non-goals (no bots, no bulk actions, no multi-account) live in [intent.md](inten ## Quickstart -Requires Node.js >=22.18. +Requires a Rust toolchain (1.85 or newer; install from [rustup.rs](https://rustup.rs)). ```sh git clone https://github.com/ifthenelse/hinge-cli.git cd hinge-cli -npm install -npm run build +cargo build --release # binary: target/release/hinge +cargo install --path . # optional: puts `hinge` on your PATH ``` Then capture a session from your own device ([docs/auth.md](docs/auth.md)), import it, and check @@ -56,8 +56,8 @@ hinge limits ## Usage -- Verify everything (typecheck + tests): `scripts/verify` -- Build: `npm run build` +- Verify everything (fmt, clippy, tests): `scripts/verify` +- Build: `cargo build --release` - Import a captured session: `hinge auth import ` - Check the stored session: `hinge auth status` - Read your account: `hinge tier`, `hinge limits` @@ -78,9 +78,10 @@ to import/use a real session. ## Architecture -A single local binary (`hinge`) calls `prod-api.hingeaws.net` directly with a member-supplied +A single local Rust binary (`hinge`) calls `prod-api.hingeaws.net` directly with a member-supplied session; there is no server component. Full summary: [docs/architecture.md](docs/architecture.md); -decisions: [docs/adr/](docs/adr/). +decisions: [docs/adr/](docs/adr/). Every request goes out with the user agent of a generic Android phone +(see [Request identity](docs/architecture.md#request-identity)). ## Deployment and recovery diff --git a/docs/architecture.md b/docs/architecture.md index 75f604a..cc22d12 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -3,7 +3,7 @@ One canonical location for the current architecture. Link to authoritative diagrams rather than copying them. ## System context -hinge-cli is a single Node.js/TypeScript binary (`hinge`) that a Hinge member runs locally. It makes +hinge-cli is a single Rust binary (`hinge`, built with Cargo) that a Hinge member runs locally. It makes direct HTTPS calls to Hinge's own backend (`prod-api.hingeaws.net`) using session headers the member captured from their own phone — it does not drive the Hinge app's UI and does not go through Appium at runtime. Appium/WebDriverAgent is a one-time exploration tool (`hinge inspect`), not part of the @@ -11,44 +11,51 @@ request path. There is no server component and no multi-user backend: each insta Hinge's API and to the member's own secret store. ``` -member's terminal ── hinge ──▶ src/cli.ts +member's terminal ── hinge ──▶ src/main.rs │ ┌─────────────┼─────────────┐ ▼ ▼ ▼ - session-store.ts api.ts session.ts (Appium, `inspect` only) + session_store.rs api.rs appium.rs (Appium, `doctor`/`inspect` only) │ │ ▼ ▼ - secrets.ts prod-api.hingeaws.net (Hinge's real API) + secrets.rs prod-api.hingeaws.net (Hinge's real API) (op:// bw:// keychain:// cmd:// env://) ``` ## Components and boundaries -- **`src/cli.ts`** — commander-based entrypoint; owns argument parsing, the `--json` flag, and the +- **`src/main.rs`** — clap-based entrypoint (tokio runtime); owns argument parsing, the `--json` flag, and the top-level error-to-exit-code mapping. No business logic lives here beyond wiring. -- **`src/api.ts`** — the only module that talks to Hinge. `call()` issues authenticated GETs and - normalizes 401/403/non-2xx into plain errors that never echo the token. `describeTier()` maps the +- **`src/api.rs`** — the only module that talks to Hinge. `call()` issues authenticated GETs and + normalizes 401/403/non-2xx into plain errors that never echo the token. `describe_tier()` maps the real `/store/v2/account` response shape into `TierInfo`. -- **`src/session-store.ts`** — owns where a session lives (file or password-manager reference), - validates untrusted JSON on import (`parseSession`, header allowlist, `authorization` required), +- **`src/session_store.rs`** — owns where a session lives (file or password-manager reference), + validates untrusted JSON on import (`parse_session`, header allowlist, `authorization` required), and the cross-platform config-path logic. -- **`src/secrets.ts`** — resolves `scheme://` references (`env://`, `op://`, `bw://`, `keychain://`, +- **`src/secrets.rs`** — resolves `scheme://` references (`env://`, `op://`, `bw://`, `keychain://`, `cmd://`) to a secret value. The only module allowed to shell out for credentials. -- **`src/session.ts`** — Appium/WebDriverAgent connection used solely by `hinge inspect`, the - exploration command used while reverse-engineering the API. Not used by `tier`/`limits`/`auth`. +- **`src/appium.rs`** — W3C WebDriver client for Appium/WebDriverAgent, used solely by `hinge doctor` + and `hinge inspect`, the exploration commands used while reverse-engineering the API. Not used by + `tier`/`limits`/`auth`. ## Data flows and integration contracts 1. **Capture (manual, one-time, outside the CLI):** member runs mitmproxy against their own phone with `tools/hinge_token.py` to extract session headers, per `docs/auth.md`. -2. **Import:** `hinge auth import ` → `session-store.parseSession` (validates/allowlists - headers) → `saveSession` (0600 file, or writes nothing if `HINGE_SESSION_REF` is set) → source +2. **Import:** `hinge auth import ` → `session_store::parse_session` (validates/allowlists + headers) → `save_session` (0600 file, or writes nothing if `HINGE_SESSION_REF` is set) → source file deleted by default. -3. **Authenticated call:** `hinge tier`/`limits` → `loadSession()` (file or `resolveSecret` via - `HINGE_SESSION_REF`) → `api.call(path, session)` → Hinge REST API → response mapped and printed. +3. **Authenticated call:** `hinge tier`/`limits` → `load_session()` (file or `resolve_secret` via + `HINGE_SESSION_REF`) → `api::call(path, session)` → Hinge REST API → response mapped and printed. Endpoint inventory, headers observed, and the (unimplemented) login/attestation sequence: [`docs/api-inventory.md`](api-inventory.md). +## Request identity +Every HTTP request (Hinge's API and the local Appium server) goes out with the user agent of a generic +Android phone, `api::USER_AGENT` (Chrome on a Pixel-class device). It replaces the `user-agent` of the +captured session, which is no longer stored. The other captured `x-device-*`/`x-os-version` headers are +sent unchanged, so they still describe the phone the session came from. + ## Trust boundaries The member's captured session header is the only secret in the system; everything downstream of -`loadSession()` treats it as sensitive and no code path logs or echoes it (see `secret` command, +`load_session()` treats it as sensitive and no code path logs or echoes it (see `secret` command, which reports length only). See the [threat model](security/threat-model.md). diff --git a/docs/auth.md b/docs/auth.md index 23957ac..23732ec 100644 --- a/docs/auth.md +++ b/docs/auth.md @@ -17,3 +17,8 @@ Hinge's terms may forbid this; automation can get an account flagged. Use your o ## Not done yet Phone-number + SMS login inside the CLI (needs the login traffic captured). + +## Note: user agent +`hinge auth import` keeps only an allow-list of headers and no longer stores `user-agent`: every request +the CLI sends identifies as a generic Android phone instead (`src/api.rs`). Sessions imported by an +older version still work; their stored `user-agent` is ignored. diff --git a/docs/deployment.md b/docs/deployment.md index 9bd891c..d263c10 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -1,32 +1,32 @@ # Deployment -hinge-cli has no server and no hosted environment — "deployment" means publishing a versioned npm -package that members install locally. There is no staging/production split for a local CLI. +hinge-cli has no server and no hosted environment — "deployment" means publishing a versioned Rust crate/binary +that members build or install locally. There is no staging/production split for a local CLI. ## Environments and promotion path | Environment | Purpose | Promotion from | Approval | | --- | --- | --- | --- | | local (dev) | member's own machine, running against the real Hinge API with their own session | n/a | n/a | -| npm registry | distributable, versioned release | `main` branch, tagged | maintainer (self-review; single-maintainer repo, see CONTRIBUTING.md) | +| source / crates.io | distributable, versioned release | `main` branch, tagged | maintainer (self-review; single-maintainer repo, see CONTRIBUTING.md) | ## Release -1. `npm version ` on `main` (bumps `package.json`, the single version source). -2. `npm run build` (`tsc -p tsconfig.build.json`) to produce `dist/`. +1. Bump `version` in `Cargo.toml` on `main` (the single version source) and run `cargo build` to refresh `Cargo.lock`. +2. `cargo build --release` to produce `target/release/hinge`. 3. `scripts/verify` must be green. -4. `git push --follow-tags`, then `npm publish` (not yet automated — no publish job exists in +4. `git tag vX.Y.Z && git push --follow-tags`, then `cargo publish` if releasing to crates.io (not yet automated — no publish job exists in `.github/workflows/`; this is a manual step today, tracked as an open item below). ## Smoke tests -After install (`npm install -g hinge-cli` or `npm link`): +After install (`cargo install --path .`, or `cargo install hinge-cli` once published): - `hinge doctor` — checks Appium reachability (only relevant if `inspect` will be used). - `hinge auth status` — confirms a session, once imported, is accepted by Hinge's API. - `hinge tier` — confirms a real authenticated call round-trips correctly. ## Rollback -There is nothing running to roll back (no server). If a published npm version is broken: -- `npm deprecate hinge-cli@ ""` to warn installers off it. -- Publish a patched version; members on the broken version re-run `npm install`. +There is nothing running to roll back (no server). If a published version is broken: +- `cargo yank --version ` to stop new installs resolving to it. +- Publish a patched version; members on the broken version re-run `cargo install hinge-cli --force`. ## Open item -No CI job publishes to npm yet, and CI/tests currently run on `ubuntu-latest` only even though the +No CI job publishes a release yet, and CI/tests currently run on `ubuntu-latest` only even though the tool targets Windows/macOS/Linux — a Windows/macOS matrix job is not yet in `.github/workflows/ci.yml`. diff --git a/docs/security/threat-model.md b/docs/security/threat-model.md index bab680e..b80d835 100644 --- a/docs/security/threat-model.md +++ b/docs/security/threat-model.md @@ -4,9 +4,9 @@ Update when architecture or exposure changes. | Asset | Actor | Entry point | Trust boundary | Abuse case | Mitigation | Residual risk | | --- | --- | --- | --- | --- | --- | --- | -| Hinge session header (bearer-equivalent) | Malware/other local process on the member's machine | Session file on disk / env var / password-manager process | OS file permissions and OS process boundary | Local process reads the session file and impersonates the member to Hinge | File written mode 0600, directory 0700 (`session-store.ts`); `HINGE_SESSION_REF` keeps the secret out of the filesystem entirely, resolved on demand via the member's password manager | Mode bits are a no-op on Windows (relies on per-user `%APPDATA%` ACL instead) — documented, not yet hardened to the OS credential store | -| Hinge session header | Shoulder-surfing / shell history / CI logs | `hinge secret `, error messages | CLI output boundary | Secret value printed to stdout/stderr or committed to logs | `secret` command reports length only, never the value; `api.ts` error paths are built to never interpolate the header | None known; relies on no future code path echoing the header — worth a lint rule if the codebase grows | +| Hinge session header (bearer-equivalent) | Malware/other local process on the member's machine | Session file on disk / env var / password-manager process | OS file permissions and OS process boundary | Local process reads the session file and impersonates the member to Hinge | File written mode 0600, directory 0700 (`session_store.rs`); `HINGE_SESSION_REF` keeps the secret out of the filesystem entirely, resolved on demand via the member's password manager | Mode bits are a no-op on Windows (relies on per-user `%APPDATA%` ACL instead) — documented, not yet hardened to the OS credential store | +| Hinge session header | Shoulder-surfing / shell history / CI logs | `hinge secret `, error messages | CLI output boundary | Secret value printed to stdout/stderr or committed to logs | `secret` command reports length only, never the value; `api.rs` error paths are built to never interpolate the header | None known; relies on no future code path echoing the header — worth a lint rule if the codebase grows | | Captured session file | The member, during capture | `tools/hinge_token.py` output file | Local filesystem | File left on disk after import, later committed or backed up | `hinge auth import` deletes the source file by default (`--keep` opts out); documented cleanup steps in `docs/auth.md` | Depends on the member actually using `auth import` rather than hand-copying the header elsewhere | | Other Hinge members' data | The CLI author, during API reverse-engineering | mitmproxy capture of the member's own app traffic | Hinge's platform boundary | Capture incidentally includes another member's profile/message content relayed through the member's own session | Captures were deleted after use; `docs/api-inventory.md` records only endpoints/headers/ordering, no bodies, tokens or third-party content | None for past captures (deleted); future captures must follow the same discipline — not yet enforced by tooling, only by process | | Hinge's production API | This project's own CI | GitHub Actions runners | Network boundary to a third party | An automated "pentest" workflow sends attack traffic to Hinge's live infrastructure | No such job exists; `security.yml` explicitly scopes to static/dependency scanning instead (see comment at the top of that file) | None — this is a closed decision, not a residual risk | -| npm dependencies | Supply chain | `package.json` / lockfile | Build boundary | A compromised or vulnerable transitive dependency ships in a release | Dependabot (npm + actions, weekly), `npm audit --audit-level=high` in CI, CodeQL static analysis | Standard supply-chain residual risk; mitigated, not eliminated | +| Cargo dependencies | Supply chain | `Cargo.toml` / `Cargo.lock` | Build boundary | A compromised or vulnerable transitive dependency ships in a release | Dependabot (cargo + actions, weekly), `cargo audit` in CI, CodeQL static analysis, rustls (no system OpenSSL) | Standard supply-chain residual risk; mitigated, not eliminated | diff --git a/docs/testing.md b/docs/testing.md index 48bd966..35e00cc 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -3,24 +3,24 @@ ## Strategy Unit tests cover the modules that don't need a live Hinge session or a real phone: secret resolution, session parsing/storage, and the API client's response mapping (success, 401, 500, free-tier fallback) -against fake `fetch` implementations. Nothing in CI calls Hinge's real API or Appium — those require +against a one-shot local HTTP server (which also asserts the Android `user-agent` header). Nothing in CI calls Hinge's real API or Appium — those require live, member-specific state (a captured session, a connected iPhone) that isn't safe or reproducible in CI. ## Suites | Suite | Location | Speed | Run with | | --- | --- | --- | --- | -| unit | `test/*.test.ts` | fast (<1s) | `npm test` / `scripts/verify` | +| unit | `#[cfg(test)]` modules in `src/*.rs` | fast (<1s) | `cargo test` / `scripts/verify` | | integration (live Hinge API) | none yet | — | manual: `hinge tier` against a real imported session | | e2e (Appium/`hinge inspect`) | none | slow, opt-in | manual, requires a connected iPhone + WebDriverAgent | ## Fixtures and environments Unit tests use literal fixture objects (fake sessions, fake `Account` JSON shapes) inline in -`test/core.test.ts` — no fixtures touch a real captured session file. Tests that would touch a live +the `tests` modules of `src/*.rs` — no fixtures touch a real captured session file. Tests that would touch a live or state-changing system (a real Hinge session, a real phone) are intentionally not automated; they are manual smoke checks (see `docs/deployment.md`). ## Definition of a passing release -`scripts/verify` green in CI (typecheck + `node --test`), plus: a manual `hinge auth status` / +`scripts/verify` green in CI (`cargo fmt --check`, `cargo clippy -D warnings`, `cargo test`), plus: a manual `hinge auth status` / `hinge tier` check against one real account before publishing, since no automated test exercises the real API contract. diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index 022b2ee..0000000 --- a/package-lock.json +++ /dev/null @@ -1,1408 +0,0 @@ -{ - "name": "hinge-cli", - "version": "0.1.6", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "hinge-cli", - "version": "0.1.6", - "license": "MIT", - "dependencies": { - "commander": "^15.1.0", - "webdriver": "^10.2.0" - }, - "bin": { - "hinge": "dist/cli.js" - }, - "devDependencies": { - "@types/node": "^26.6.6", - "typescript": "^7.0.2" - }, - "engines": { - "node": ">=22.18" - } - }, - "node_modules/@isaacs/nonrecursive-glob-match": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@isaacs/nonrecursive-glob-match/-/nonrecursive-glob-match-1.1.0.tgz", - "integrity": "sha512-GPm/Dbvk5RLmhRnxXIa7nTpK0xtl4E0wj0MslsuNiJ1FIROU+2+9lgUC/dgF7Ey4QCWhfEsgxilMRMCdHPfDfw==", - "license": "BlueOak-1.0.0" - }, - "node_modules/@promptbook/utils": { - "version": "0.69.5", - "resolved": "https://registry.npmjs.org/@promptbook/utils/-/utils-0.69.5.tgz", - "integrity": "sha512-xm5Ti/Hp3o4xHrsK9Yy3MS6KbDxYbq485hDsFvxqaNA7equHLPdo8H8faTitTeb14QCDfLW4iwCxdVYu5sn6YQ==", - "funding": [ - { - "type": "individual", - "url": "https://buymeacoffee.com/hejny" - }, - { - "type": "github", - "url": "https://github.com/webgptorg/promptbook/blob/main/README.md#%EF%B8%8F-contributing" - } - ], - "license": "CC-BY-4.0", - "dependencies": { - "spacetrim": "0.11.59" - } - }, - "node_modules/@puppeteer/browsers": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-3.2.7.tgz", - "integrity": "sha512-B3C/v8OEEaJYcN1IzzgbPmt+GbFANr4Mf/NrqNuGk/dIchrv6quNqxgT+A6qE0Ge0MN95NjKUddcR1JMpYRMWA==", - "license": "Apache-2.0", - "dependencies": { - "modern-tar": "^0.8.6", - "yargs": "^18.0.0" - }, - "bin": { - "browsers": "lib/main-cli.js" - }, - "engines": { - "node": ">=22.12.0" - }, - "peerDependencies": { - "proxy-agent": ">=8.0.1", - "yauzl": "^2.10.0 || ^3.4.0" - }, - "peerDependenciesMeta": { - "proxy-agent": { - "optional": true - }, - "yauzl": { - "optional": true - } - } - }, - "node_modules/@types/node": { - "version": "26.6.6", - "resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.6.tgz", - "integrity": "sha512-MzQj+8Kx3XI40OmUAE6Qoh58ZMNstNNMwn2nfd3qWsfe7nDNSqJNzes4njhz6AHwrSHOffSLwXU6yb474Q4aog==", - "license": "MIT", - "dependencies": { - "undici-types": "~8.9.0" - } - }, - "node_modules/@types/split2": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/@types/split2/-/split2-4.2.3.tgz", - "integrity": "sha512-59OXIlfUsi2k++H6CHgUQKEb2HKRokUA39HY1i1dS8/AIcqVjtAAFdf8u+HxTWK/4FUHMJQlKSZ4I6irCBJ1Zw==", - "license": "MIT", - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/@types/ws": { - "version": "8.18.2", - "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.18.2.tgz", - "integrity": "sha512-67MQl+fpWKVTT1NYdnmo3U4sc/xPo/zQBncVnI74qmQa0z/b+1g6iYqNmGCPbxO+zz2aklb08a0oHfegiVd0/w==", - "license": "MIT", - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/@typescript/typescript-aix-ppc64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-aix-ppc64/-/typescript-aix-ppc64-7.0.2.tgz", - "integrity": "sha512-MTKKkWB7p/0E9xi1d1tHtZ5PiLkGEMIq88pK2CubZjOsLtYTLqhgIgi6zepFa+9GHZ6h05NMCkQxGKiPXMxXtQ==", - "cpu": [ - "ppc64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "aix" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-darwin-arm64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-darwin-arm64/-/typescript-darwin-arm64-7.0.2.tgz", - "integrity": "sha512-gowzar9MwS/aRWp6f3a4KUqzRjAZjOsmGNCM6LcTgXum+dBfgsBVMN+AgvOCCbguXyick6LJhpBszxMebJ8syA==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-darwin-x64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-darwin-x64/-/typescript-darwin-x64-7.0.2.tgz", - "integrity": "sha512-SZ9xZInqApNlNGc9s0W1VSsktYSOe9cFqNOIqmN1Gs8SmkjKZYFt017G4VwPxASInODuAdbTW7sXiFUf893RgA==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-freebsd-arm64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-freebsd-arm64/-/typescript-freebsd-arm64-7.0.2.tgz", - "integrity": "sha512-W5NH4y/J0plIIS5b2xvTEkU7JFxyqdMAOgf+Ilhl0vHQXKO5dZoxd+C/jEtq56c4F3wk71RB4BMRQ2XdI+bwYQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-freebsd-x64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-freebsd-x64/-/typescript-freebsd-x64-7.0.2.tgz", - "integrity": "sha512-UMGDx5sTpzNw3WiPebH7l90IWfJggEd+egHt/q6p7/Cm3zqoV7VxkGXt+3DxPIw8CcmvAB0j3sVVfbhX+M4Tpw==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-linux-arm": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-arm/-/typescript-linux-arm-7.0.2.tgz", - "integrity": "sha512-gffT3xPz9sR7j/YJExkyPntrI0P2EP9XbOyWzth2/Gs0RstK+90RBcO0ncXoXy/beYll1SXw846Nf2zdnEz0QQ==", - "cpu": [ - "arm" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-linux-arm64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-arm64/-/typescript-linux-arm64-7.0.2.tgz", - "integrity": "sha512-Qh4eU4/y3yDjnfjjyPYihMj5/ODIlmt+Bzu17OI+fiSRDW57QmU5SiN63exPRNJPKUzcc1INa1NXdrJ+MqHjUQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-linux-loong64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-loong64/-/typescript-linux-loong64-7.0.2.tgz", - "integrity": "sha512-uEHck9i8hoAzXPiYRib1O7miOnz23SxIeVl6F4LXox+qov1K35jHcEW6VHKvZI+pyvl7fZEP4MCU5LYvIq1GuQ==", - "cpu": [ - "loong64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-linux-mips64el": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-mips64el/-/typescript-linux-mips64el-7.0.2.tgz", - "integrity": "sha512-R4KvAMnE43W5Qeqb0Ly56O3mWMWIAgsMyz36DCaycd5nbg/9kzm0liw3JocfRqyJY0KPmzFjbswozXyW0DnIYA==", - "cpu": [ - "mips64el" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-linux-ppc64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-ppc64/-/typescript-linux-ppc64-7.0.2.tgz", - "integrity": "sha512-DORx5b3sd/4S7eayxm4FQv+A7CrkUIGRaHiwI8oiHTAI1fAPWhF4J0vAlkC8biAlHSVVwxMQ3tjZ2/DVbnQiiA==", - "cpu": [ - "ppc64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-linux-riscv64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-riscv64/-/typescript-linux-riscv64-7.0.2.tgz", - "integrity": "sha512-wf0jqEDOjrPRnKwYRyyJDRo11KMbvMFrU+q4zqKyChODBzvlkbhNQfKvLxQCcwTpdDaXSHZTVuh0JoCrKCUMHQ==", - "cpu": [ - "riscv64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-linux-s390x": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-s390x/-/typescript-linux-s390x-7.0.2.tgz", - "integrity": "sha512-IkwJc3L7yhytWd/ewjyxNDfOmswCm9GWMJT/ue/dU4aZNbwZeYAetq42VyLmsmSjvoX7z74X6ZaYCtzAr0EuGw==", - "cpu": [ - "s390x" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-linux-x64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-x64/-/typescript-linux-x64-7.0.2.tgz", - "integrity": "sha512-EYdf2cNg7rgCWJnxCdJ+F3V39O8ihb37eHAu1LK8oAFizgTQbPOK7zHHXbPt8rX24COqODXeI3sIf0fCXG7H/A==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-netbsd-arm64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-netbsd-arm64/-/typescript-netbsd-arm64-7.0.2.tgz", - "integrity": "sha512-+polYF4MF04aPpO5FTkHran9yUQDSXqy5GiSDKpsll5jy3l3+g9QLhpf39T+ePtefhXLOGrLl0QIjkQP6VnelA==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "netbsd" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-netbsd-x64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-netbsd-x64/-/typescript-netbsd-x64-7.0.2.tgz", - "integrity": "sha512-8YIT0EHM/3dq10ZOVF/A7pc/YSMtbcecct4rWtexrnSCHOPcpC2KTLXfTCR6vDpnSiY12heNb1GiN/wu+T/FyA==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "netbsd" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-openbsd-arm64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-openbsd-arm64/-/typescript-openbsd-arm64-7.0.2.tgz", - "integrity": "sha512-APT8+ClYnuYm1u9+kgGXoMj2VzWzcymwh2gNSQVySHfkRDGOTVkoWLjCmOQSaO+PoqQ57B0flRp9SA+7GnnkzQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "openbsd" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-openbsd-x64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-openbsd-x64/-/typescript-openbsd-x64-7.0.2.tgz", - "integrity": "sha512-yX7s+Q0Dln0Dt9tEzZsAjXXR/+ytBM7AlglaqyeMPxQszJ1JhlJdZ6jLA+IzldHtflX81em7lDao1xXu+aRRkg==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "openbsd" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-sunos-x64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-sunos-x64/-/typescript-sunos-x64-7.0.2.tgz", - "integrity": "sha512-dLJDGaLZ1D4HPQn62u1n8mBDkJREwMsAkCdkwd4Ieqw+x3TUyTsqY0YiBCtE6H6OzzgGk3iuZ3vFWRS+E8/d1g==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "sunos" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-win32-arm64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-win32-arm64/-/typescript-win32-arm64-7.0.2.tgz", - "integrity": "sha512-Gyl1Vy6OsWesLzmq+EP0Fb7b4Nid5232AvcA2SFcdYreldpNtYFFofPjnt62y9hQy7VTaZp65ICJjuAQRaVcIQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-win32-x64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-win32-x64/-/typescript-win32-x64-7.0.2.tgz", - "integrity": "sha512-0BQ3HkAHHlKLSp1qRvf3SUhGpGsDuhB/jgFw75guyqbxJqEaS0Cw/VFO8i2nHglJUzQCRtMMR/IBAKE3ETMC4g==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@wdio/config": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/@wdio/config/-/config-10.2.0.tgz", - "integrity": "sha512-dCsMVpgmyL8fLRQVcxVyYXBG/pgtJeY897+LUxU/Vw+JvJOV2iTycHn5xUD5EehbNsstfxgJwkLCVunhJcbXdg==", - "license": "MIT", - "dependencies": { - "@wdio/logger": "10.2.0", - "@wdio/types": "10.2.0", - "@wdio/utils": "10.2.0", - "deepmerge-ts": "^8.0.0", - "glob": "^14.0.2", - "import-meta-resolve": "^4.0.0", - "jiti": "^2.6.1" - }, - "engines": { - "node": ">=22.23.4 <23 || >=24.22.1 <25 || >=26.12.1" - } - }, - "node_modules/@wdio/logger": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/@wdio/logger/-/logger-10.2.0.tgz", - "integrity": "sha512-C7qpFSA+Zuu/6xbx+ALoEeOiyIWlD02/Llb8ufjypCOpe9rAy77JgAHeQlKYWg7aitRQRt7aG2oeix0mNhTk5A==", - "license": "MIT", - "dependencies": { - "chalk": "^6.0.1", - "loglevel": "^1.6.0", - "loglevel-plugin-prefix": "^0.8.4", - "safe-regex2": "^5.0.0", - "strip-ansi": "^7.1.0" - }, - "engines": { - "node": ">=22.23.4 <23 || >=24.22.1 <25 || >=26.12.1" - } - }, - "node_modules/@wdio/protocols": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/@wdio/protocols/-/protocols-10.2.0.tgz", - "integrity": "sha512-HuSsvpv7hV8hbhFdlMraz7c+Bpu9O4FiKg2XdztZupj59wx0c7n7YPnZRGEY5yW3/wRt9PfqWkBI0EO81Y+Zqw==", - "license": "MIT", - "engines": { - "node": ">=22.23.4 <23 || >=24.22.1 <25 || >=26.12.1" - } - }, - "node_modules/@wdio/types": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/@wdio/types/-/types-10.2.0.tgz", - "integrity": "sha512-a9qwqHzf0t2ctrXs+qUEhobH/VK0PmeoErCBWdN6DRxhTP8YiXQco4wjTj1z7H4k5xwZYxMT0KC0QzN/e4B73Q==", - "license": "MIT", - "dependencies": { - "@types/node": "^22.20.4" - }, - "engines": { - "node": ">=22.23.4 <23 || >=24.22.1 <25 || >=26.12.1" - } - }, - "node_modules/@wdio/types/node_modules/@types/node": { - "version": "22.20.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.5.tgz", - "integrity": "sha512-U2+DNr+wSjpsTS/wZGYHq7GcwfuSmKiKvoPvK22zwTlRhU91yOniN4qRR5KhIjvif7ysw/dz/hKmfDH0Ris4aA==", - "license": "MIT", - "dependencies": { - "undici-types": "~6.21.0" - } - }, - "node_modules/@wdio/types/node_modules/undici-types": { - "version": "6.21.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", - "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", - "license": "MIT" - }, - "node_modules/@wdio/utils": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/@wdio/utils/-/utils-10.2.0.tgz", - "integrity": "sha512-C4ok/WatCBV3gHmIYGjj4Aa43tQTD53eTFs3okpKxuc1wmFy/1zDFOYLDjeTq4xSFygoRBI+ZMyc9LBEiok3ng==", - "license": "MIT", - "dependencies": { - "@puppeteer/browsers": "^3.2.1", - "@types/split2": "^4.2.3", - "@wdio/logger": "10.2.0", - "@wdio/types": "10.2.0", - "aria-query": "^5.3.2", - "decamelize": "^7.0.0", - "deepmerge-ts": "^8.0.0", - "edgedriver": "^8.0.0", - "electron-to-chromium": "^1.5.439", - "geckodriver": "^8.0.0", - "get-port": "^7.0.0", - "import-meta-resolve": "^4.0.0", - "locate-app": "^2.2.24", - "mitt": "^3.0.1", - "safaridriver": "^3.0.0", - "split2": "^4.2.0", - "wait-port": "^1.1.0" - }, - "engines": { - "node": ">=22.23.4 <23 || >=24.22.1 <25 || >=26.12.1" - } - }, - "node_modules/@zip.js/zip.js": { - "version": "2.25.0", - "resolved": "https://registry.npmjs.org/@zip.js/zip.js/-/zip.js-2.25.0.tgz", - "integrity": "sha512-oNRqUuU1XFu6G5d7Z0jufJ9dS9WteO0xiU/PNxsUrb4itZCsSbn191jpJzU00Gmc6S680X3DPZeF5EV4zAEMAg==", - "license": "BSD-3-Clause", - "engines": { - "bun": ">=0.7.0", - "deno": ">=1.0.0", - "node": ">=18.0.0" - } - }, - "node_modules/agent-base": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-9.0.0.tgz", - "integrity": "sha512-TQf59BsZnytt8GdJKLPfUZ54g/iaUL2OWDSFCCvMOhsHduDQxO8xC4PNeyIkVcA5KwL2phPSv0douC0fgWzmnA==", - "license": "MIT", - "engines": { - "node": ">= 20" - } - }, - "node_modules/ansi-regex": { - "version": "6.6.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.6.0.tgz", - "integrity": "sha512-XZ5apbzreCbXSKwPjJstu8R0zOi247w3XYwWxtwBXgpZrCyc1Ka7p9/xY0A9/diMewmHbEKz+FIraWaEWjlN5g==", - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-regex?sponsor=1" - } - }, - "node_modules/ansi-styles": { - "version": "6.2.3", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz", - "integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==", - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/aria-query": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.2.tgz", - "integrity": "sha512-COROpnaoap1E2F000S62r6A60uHZnmlvomhfyT2DlTcrY1OrBKn2UhH7qn5wTC9zMvD0AY7csdPSNwKP+7WiQw==", - "license": "Apache-2.0", - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/balanced-match": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", - "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", - "license": "MIT", - "engines": { - "node": "18 || 20 || >=22" - } - }, - "node_modules/brace-expansion": { - "version": "5.0.13", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.13.tgz", - "integrity": "sha512-Vh3dmFbc4wZeox7M9I/0L9GfFd83Su4+yCck/OF9Gi/P/dAHn0RT7X4K9R7gMNMhDck3DvhR6QXsnQdjjgwNvQ==", - "license": "MIT", - "dependencies": { - "balanced-match": "^4.0.2" - }, - "engines": { - "node": "20 || >=22" - } - }, - "node_modules/chalk": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-6.0.1.tgz", - "integrity": "sha512-/Ce6KNm3vIbWdMlNna6RVIZ/ICQxnJxCicet5LBKK9ZffBkqzDw0xh9EiKSljdRtiIQ1S1z4YgcscUUGzNCWrA==", - "license": "MIT", - "engines": { - "node": ">=22" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/cliui": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-9.0.1.tgz", - "integrity": "sha512-k7ndgKhwoQveBL+/1tqGJYNz097I7WOvwbmmU2AR5+magtbjPWQTS1C5vzGkBC8Ym8UWRzfKUzUUqFLypY4Q+w==", - "license": "ISC", - "dependencies": { - "string-width": "^7.2.0", - "strip-ansi": "^7.1.0", - "wrap-ansi": "^9.0.0" - }, - "engines": { - "node": ">=20" - } - }, - "node_modules/cliui/node_modules/string-width": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", - "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", - "license": "MIT", - "dependencies": { - "emoji-regex": "^10.3.0", - "get-east-asian-width": "^1.0.0", - "strip-ansi": "^7.1.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "license": "MIT", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "license": "MIT" - }, - "node_modules/commander": { - "version": "15.1.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-15.1.0.tgz", - "integrity": "sha512-cgnQ88TRrWcC7pVq46RzJVRMktu3W2RcbnoidnfBsl1bmDCBwJS/udcIZpKoCrbAYYaCqsz1yZCVIgbIaU3ddQ==", - "license": "MIT", - "engines": { - "node": ">=22.12.0" - } - }, - "node_modules/debug": { - "version": "4.4.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", - "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", - "license": "MIT", - "dependencies": { - "ms": "^2.1.3" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/decamelize": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-7.0.0.tgz", - "integrity": "sha512-uT/0KzZIx9u4b5vW3HLWtSYwjLTuY2QFVY3xNmfXXUmTqnfgzfT8DEA2gY93go5sXEjnbqP66KcURdVxm0rDXA==", - "license": "MIT", - "engines": { - "node": ">=22" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/deepmerge-ts": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/deepmerge-ts/-/deepmerge-ts-8.0.2.tgz", - "integrity": "sha512-uqbvqLUMrc6p0MO+WBRtTxY55hmyh94WRwI5a++PZe54X+bfVh59FSN7uWCBCW1CCVjzjnrwzfI8zidE2obMMw==", - "funding": [ - { - "type": "ko-fi", - "url": "https://ko-fi.com/rebeccastevens" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/deepmerge-ts" - } - ], - "license": "BSD-3-Clause", - "engines": { - "node": ">=16.9.0" - } - }, - "node_modules/edgedriver": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/edgedriver/-/edgedriver-8.0.0.tgz", - "integrity": "sha512-h4twAKTFILvpjrxfeN1gslvnggztA6Cgb4iHQdLzEq3TivaHHlf6qEETpCgU7+iw9JIWjcveeckrDlbcY28a/A==", - "hasInstallScript": true, - "license": "MIT", - "dependencies": { - "@zip.js/zip.js": "^2.23.0", - "decamelize": "^6.0.1", - "undici": "^8.11.2" - }, - "bin": { - "edgedriver": "bin/edgedriver.js" - }, - "engines": { - "node": ">=22.19.0" - }, - "peerDependencies": { - "@wdio/logger": "^9.29.1 || ^10.0.0" - } - }, - "node_modules/edgedriver/node_modules/decamelize": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-6.0.1.tgz", - "integrity": "sha512-G7Cqgaelq68XHJNGlZ7lrNQyhZGsFqpwtGFexqUv4IQdjKoSYF7ipZ9UuTJZUSQXFj/XaoBLuEVIVqr8EJngEQ==", - "license": "MIT", - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/electron-to-chromium": { - "version": "1.5.492", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.492.tgz", - "integrity": "sha512-4uMs7omhajKiud0GqALLTazS/zyvHLTLmDWVTR+e6BnyJo5bSNrph/JoRWEFJJmY75ct9hCiSGsbFF9fLe5gDw==", - "license": "ISC" - }, - "node_modules/emoji-regex": { - "version": "10.6.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.6.0.tgz", - "integrity": "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==", - "license": "MIT" - }, - "node_modules/escalade": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", - "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/geckodriver": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/geckodriver/-/geckodriver-8.0.0.tgz", - "integrity": "sha512-2jGCA6deI5MAjODxmHljPqvaUccGbeeqMUHXlW4k3FNDp4YDpxSI+P5QG+w5KIsnCeuGEfTTNi2euKqHI1eD6Q==", - "hasInstallScript": true, - "license": "MIT", - "dependencies": { - "@zip.js/zip.js": "^2.23.0", - "decamelize": "^6.0.1", - "modern-tar": "^0.8.5", - "undici": "^8.11.2" - }, - "bin": { - "geckodriver": "bin/geckodriver.js" - }, - "engines": { - "node": ">=22.19.0" - }, - "peerDependencies": { - "@wdio/logger": "^9.18.0 || ^10.0.0" - } - }, - "node_modules/geckodriver/node_modules/decamelize": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-6.0.1.tgz", - "integrity": "sha512-G7Cqgaelq68XHJNGlZ7lrNQyhZGsFqpwtGFexqUv4IQdjKoSYF7ipZ9UuTJZUSQXFj/XaoBLuEVIVqr8EJngEQ==", - "license": "MIT", - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "license": "ISC", - "engines": { - "node": "6.* || 8.* || >= 10.*" - } - }, - "node_modules/get-east-asian-width": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.7.0.tgz", - "integrity": "sha512-XjH1AECxf0giL2V1aU8vKyRR2ppRUb5c0EvT7zuJTokQ74bNo52zOtghqdWIqrhUD79fo3x0WfKZdOqxF6LG1Q==", - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/get-port": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/get-port/-/get-port-7.2.0.tgz", - "integrity": "sha512-afP4W205ONCuMoPBqcR6PSXnzX35KTcJygfJfcp+QY+uwm3p20p1YczWXhlICIzGMCxYBQcySEcOgsJcrkyobg==", - "license": "MIT", - "engines": { - "node": ">=16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/glob": { - "version": "14.0.6", - "resolved": "https://registry.npmjs.org/glob/-/glob-14.0.6.tgz", - "integrity": "sha512-OwXjVP2svY5EyLY75Vek96C8qK43gqrt4xsZ+qSILdnaEiJPXkd62mcfUSNx/TQErQRdu5uM5kF67sfONragKw==", - "license": "BlueOak-1.0.0", - "dependencies": { - "minimatch": "^11.0.5", - "minipass": "^7.1.3", - "path-scurry": "^3.0.0" - }, - "engines": { - "node": "18 || 20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/https-proxy-agent": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-9.1.0.tgz", - "integrity": "sha512-ag87y7cJJ9/3+GxFr8Oy4O5faDsGRGnBGsJj/YjOSsSx/5eadKLYTMPlzuR6obgoCDDm0abAAZitXXQkMOPSpA==", - "license": "MIT", - "dependencies": { - "agent-base": "9.0.0", - "debug": "^4.3.4", - "proxy-agent-negotiate": "1.1.0" - }, - "engines": { - "node": ">= 20" - } - }, - "node_modules/import-meta-resolve": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/import-meta-resolve/-/import-meta-resolve-4.2.0.tgz", - "integrity": "sha512-Iqv2fzaTQN28s/FwZAoFq0ZSs/7hMAHJVX+w8PZl3cY19Pxk6jFFalxQoIfW2826i/fDLXv8IiEZRIT0lDuWcg==", - "license": "MIT", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/jiti": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.7.0.tgz", - "integrity": "sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ==", - "license": "MIT", - "bin": { - "jiti": "lib/jiti-cli.mjs" - } - }, - "node_modules/locate-app": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/locate-app/-/locate-app-2.5.0.tgz", - "integrity": "sha512-xIqbzPMBYArJRmPGUZD9CzV9wOqmVtQnaAn3wrj3s6WYW0bQvPI7x+sPYUGmDTYMHefVK//zc6HEYZ1qnxIK+Q==", - "funding": [ - { - "type": "individual", - "url": "https://buymeacoffee.com/hejny" - }, - { - "type": "github", - "url": "https://github.com/hejny/locate-app/blob/main/README.md#%EF%B8%8F-contributing" - } - ], - "license": "Apache-2.0", - "dependencies": { - "@promptbook/utils": "0.69.5", - "type-fest": "4.26.0", - "userhome": "1.0.1" - } - }, - "node_modules/loglevel": { - "version": "1.9.2", - "resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.9.2.tgz", - "integrity": "sha512-HgMmCqIJSAKqo68l0rS2AanEWfkxaZ5wNiEFb5ggm08lDs9Xl2KxBlX3PTcaD2chBM1gXAYf491/M2Rv8Jwayg==", - "license": "MIT", - "engines": { - "node": ">= 0.6.0" - }, - "funding": { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/loglevel" - } - }, - "node_modules/loglevel-plugin-prefix": { - "version": "0.8.4", - "resolved": "https://registry.npmjs.org/loglevel-plugin-prefix/-/loglevel-plugin-prefix-0.8.4.tgz", - "integrity": "sha512-WpG9CcFAOjz/FtNht+QJeGpvVl/cdR6P0z6OcXSkr8wFJOsV2GRj2j10JLfjuA4aYkcKCNIEqRGCyTife9R8/g==", - "license": "MIT" - }, - "node_modules/lru-cache": { - "version": "11.5.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz", - "integrity": "sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==", - "license": "BlueOak-1.0.0", - "engines": { - "node": "20 || >=22" - } - }, - "node_modules/minimatch": { - "version": "11.0.9", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-11.0.9.tgz", - "integrity": "sha512-KCFkfyjqerNlSstjlhIGNXIKZGA/6O4V4RlhZ+Dsr621SPPw0mzlypE9D9ZOoPiVefHID+j7/XuMMlqfD/F60Q==", - "license": "BlueOak-1.0.0", - "dependencies": { - "@isaacs/nonrecursive-glob-match": "^1.1.0", - "brace-expansion": "^5.0.12" - }, - "engines": { - "node": "20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/minipass": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.3.tgz", - "integrity": "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==", - "license": "BlueOak-1.0.0", - "engines": { - "node": ">=16 || 14 >=14.17" - } - }, - "node_modules/mitt": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/mitt/-/mitt-3.0.1.tgz", - "integrity": "sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==", - "license": "MIT" - }, - "node_modules/modern-tar": { - "version": "0.8.6", - "resolved": "https://registry.npmjs.org/modern-tar/-/modern-tar-0.8.6.tgz", - "integrity": "sha512-LYSks0tNVqbtez/9OB0YFP6qLRSqkdAxJWOQpVaR67lNTbj2zNLyYpowkRMia5lXLCZKzxwoxkxH2MbbBR2aEg==", - "license": "MIT", - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "license": "MIT" - }, - "node_modules/path-scurry": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-3.0.0.tgz", - "integrity": "sha512-1pTbQqH1wIwMi/eleQ5leFTTCkzFsPcgXNjwOA8YGGW/W4/kHT3dssE7Z6NH+zuqNLOzOB0uaD61yl7cAcVhgg==", - "license": "BlueOak-1.0.0", - "dependencies": { - "lru-cache": "^11.0.0", - "minipass": "^7.1.2" - }, - "engines": { - "node": "18 || 20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/proxy-agent-negotiate": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/proxy-agent-negotiate/-/proxy-agent-negotiate-1.1.0.tgz", - "integrity": "sha512-N8IBcM3UgCVzz2L2Lqv8DVntDnnC8/hiV4nEDUPkqq72TPUgYWjQc+bdZlBPZK9LzPAvOY//gAt0S0DApoOXWQ==", - "license": "MIT", - "engines": { - "node": ">= 20" - }, - "peerDependencies": { - "kerberos": "^2.0.0" - }, - "peerDependenciesMeta": { - "kerberos": { - "optional": true - } - } - }, - "node_modules/ret": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/ret/-/ret-0.5.1.tgz", - "integrity": "sha512-Z/nyvABwcRnRD2mMP7Kz6G1dFZZqX1mNErOnxF42OCQKE07b9k9hK9SQxHL3LFEZUdzQaLM4dId1E/E6Vm4WhA==", - "license": "MIT", - "engines": { - "node": ">=10" - } - }, - "node_modules/safaridriver": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/safaridriver/-/safaridriver-3.0.0.tgz", - "integrity": "sha512-NJSsR0tgn5j4fhg7vj4kD5mQ+t2ZRH3GX1jdUYraEjej9j8ZtBXEe4WZh2/89i7S9+GO3cZKWhUisWb7gyjRwA==", - "license": "MIT", - "engines": { - "node": ">=22.19.0" - } - }, - "node_modules/safe-regex2": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-regex2/-/safe-regex2-5.1.2.tgz", - "integrity": "sha512-tAtCGFPPP02VroDVzp4daGi6bC7jWG+41D47GKf18FeH/ubvKQHT9VmhAkvtjNOmJwqtApzWeUpEhkyEYULvmw==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/fastify" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/fastify" - } - ], - "license": "MIT", - "dependencies": { - "ret": "~0.5.0" - }, - "bin": { - "safe-regex2": "bin/safe-regex2.js" - } - }, - "node_modules/spacetrim": { - "version": "0.11.59", - "resolved": "https://registry.npmjs.org/spacetrim/-/spacetrim-0.11.59.tgz", - "integrity": "sha512-lLYsktklSRKprreOm7NXReW8YiX2VBjbgmXYEziOoGf/qsJqAEACaDvoTtUOycwjpaSh+bT8eu0KrJn7UNxiCg==", - "funding": [ - { - "type": "individual", - "url": "https://buymeacoffee.com/hejny" - }, - { - "type": "github", - "url": "https://github.com/hejny/spacetrim/blob/main/README.md#%EF%B8%8F-contributing" - } - ], - "license": "Apache-2.0" - }, - "node_modules/split2": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz", - "integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==", - "license": "ISC", - "engines": { - "node": ">= 10.x" - } - }, - "node_modules/string-width": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-8.3.0.tgz", - "integrity": "sha512-ZbmZM0JCihQN91dWnxoipT2KOEyHqEyfRXUyjuRhW8b/xnqPDoq4gWEVApTVa9db2wN8mmoikgFBbjh71+cGeQ==", - "license": "MIT", - "dependencies": { - "get-east-asian-width": "^1.5.0", - "strip-ansi": "^7.1.2" - }, - "engines": { - "node": ">=20" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/strip-ansi": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz", - "integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==", - "license": "MIT", - "dependencies": { - "ansi-regex": "^6.2.2" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/strip-ansi?sponsor=1" - } - }, - "node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "license": "MIT", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/type-fest": { - "version": "4.26.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.26.0.tgz", - "integrity": "sha512-OduNjVJsFbifKb57UqZ2EMP1i4u64Xwow3NYXUtBbD4vIwJdQd4+xl8YDou1dlm4DVrtwT/7Ky8z8WyCULVfxw==", - "license": "(MIT OR CC0-1.0)", - "engines": { - "node": ">=16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/typescript": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-7.0.2.tgz", - "integrity": "sha512-8FYau96o3NKOhbjKi/qNvG/W5jhzxkbdm5sj9AbZ/5T5sWqn3hJgLfGx27sRKZWTvyzCP8dLRBTf5tBTSRVUNA==", - "dev": true, - "license": "Apache-2.0", - "bin": { - "tsc": "bin/tsc" - }, - "engines": { - "node": ">=16.20.0" - }, - "optionalDependencies": { - "@typescript/typescript-aix-ppc64": "7.0.2", - "@typescript/typescript-darwin-arm64": "7.0.2", - "@typescript/typescript-darwin-x64": "7.0.2", - "@typescript/typescript-freebsd-arm64": "7.0.2", - "@typescript/typescript-freebsd-x64": "7.0.2", - "@typescript/typescript-linux-arm": "7.0.2", - "@typescript/typescript-linux-arm64": "7.0.2", - "@typescript/typescript-linux-loong64": "7.0.2", - "@typescript/typescript-linux-mips64el": "7.0.2", - "@typescript/typescript-linux-ppc64": "7.0.2", - "@typescript/typescript-linux-riscv64": "7.0.2", - "@typescript/typescript-linux-s390x": "7.0.2", - "@typescript/typescript-linux-x64": "7.0.2", - "@typescript/typescript-netbsd-arm64": "7.0.2", - "@typescript/typescript-netbsd-x64": "7.0.2", - "@typescript/typescript-openbsd-arm64": "7.0.2", - "@typescript/typescript-openbsd-x64": "7.0.2", - "@typescript/typescript-sunos-x64": "7.0.2", - "@typescript/typescript-win32-arm64": "7.0.2", - "@typescript/typescript-win32-x64": "7.0.2" - } - }, - "node_modules/undici": { - "version": "8.13.1", - "resolved": "https://registry.npmjs.org/undici/-/undici-8.13.1.tgz", - "integrity": "sha512-Kt7EaPjh0s93lJH/PmW3d5rhkcpUa6fS3jqZ7+YGxNd9L7Xy/i827xe4C2uhhq+pJebM4tQOl5AgHmW11G5Skg==", - "license": "MIT", - "engines": { - "node": ">=22.19.0" - } - }, - "node_modules/undici-types": { - "version": "8.9.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.9.0.tgz", - "integrity": "sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg==", - "license": "MIT" - }, - "node_modules/userhome": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/userhome/-/userhome-1.0.1.tgz", - "integrity": "sha512-5cnLm4gseXjAclKowC4IjByaGsjtAoV6PrOQOljplNB54ReUYJP8HdAFq2muHinSDAh09PPX/uXDPfdxRHvuSA==", - "license": "MIT", - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/wait-port": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/wait-port/-/wait-port-1.1.0.tgz", - "integrity": "sha512-3e04qkoN3LxTMLakdqeWth8nih8usyg+sf1Bgdf9wwUkp05iuK1eSY/QpLvscT/+F/gA89+LpUmmgBtesbqI2Q==", - "license": "MIT", - "dependencies": { - "chalk": "^4.1.2", - "commander": "^9.3.0", - "debug": "^4.3.4" - }, - "bin": { - "wait-port": "bin/wait-port.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/wait-port/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "license": "MIT", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/wait-port/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "license": "MIT", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/wait-port/node_modules/commander": { - "version": "9.5.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz", - "integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==", - "license": "MIT", - "engines": { - "node": "^12.20.0 || >=14" - } - }, - "node_modules/webdriver": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/webdriver/-/webdriver-10.2.0.tgz", - "integrity": "sha512-RV2+j+CAgJgJb59QliIqMik2DmP4l9dW38tDSmzWdilonCAxM5fKZAydpBt6CNlToG0jqpZ9nL3Mo6YnQh/xqw==", - "license": "MIT", - "dependencies": { - "@types/node": "^22.20.4", - "@types/ws": "^8.5.3", - "@wdio/config": "10.2.0", - "@wdio/logger": "10.2.0", - "@wdio/protocols": "10.2.0", - "@wdio/types": "10.2.0", - "@wdio/utils": "10.2.0", - "deepmerge-ts": "^8.0.0", - "https-proxy-agent": "^9.1.0", - "undici": "^8.12.3", - "ws": "^8.21.0" - }, - "engines": { - "node": ">=22.23.4 <23 || >=24.22.1 <25 || >=26.12.1" - } - }, - "node_modules/webdriver/node_modules/@types/node": { - "version": "22.20.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.5.tgz", - "integrity": "sha512-U2+DNr+wSjpsTS/wZGYHq7GcwfuSmKiKvoPvK22zwTlRhU91yOniN4qRR5KhIjvif7ysw/dz/hKmfDH0Ris4aA==", - "license": "MIT", - "dependencies": { - "undici-types": "~6.21.0" - } - }, - "node_modules/webdriver/node_modules/undici-types": { - "version": "6.21.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", - "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", - "license": "MIT" - }, - "node_modules/wrap-ansi": { - "version": "9.0.2", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.2.tgz", - "integrity": "sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww==", - "license": "MIT", - "dependencies": { - "ansi-styles": "^6.2.1", - "string-width": "^7.0.0", - "strip-ansi": "^7.1.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/wrap-ansi/node_modules/string-width": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", - "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", - "license": "MIT", - "dependencies": { - "emoji-regex": "^10.3.0", - "get-east-asian-width": "^1.0.0", - "strip-ansi": "^7.1.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/ws": { - "version": "8.23.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.23.0.tgz", - "integrity": "sha512-wCkmX8QMOrKjgO8HW2WyDbTSGeqkocxgDzS9iR79rEAexty6/2qzilx3Ag8Tqf9ykop3irLKle0MtVn5qjVnoQ==", - "license": "MIT", - "engines": { - "node": ">=10.0.0" - }, - "peerDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": ">=5.0.2" - }, - "peerDependenciesMeta": { - "bufferutil": { - "optional": true - }, - "utf-8-validate": { - "optional": true - } - } - }, - "node_modules/y18n": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "license": "ISC", - "engines": { - "node": ">=10" - } - }, - "node_modules/yargs": { - "version": "18.2.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-18.2.0.tgz", - "integrity": "sha512-9OpKOLeaoNFecEp7P6iYbzze/5CqWoH7N3SMs/6y1XF4nMvFMspEGZzJ6uFi9MmQwXhyzqYoSEKO3tvA3Z/o2w==", - "license": "MIT", - "dependencies": { - "cliui": "^9.0.1", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "string-width": "^8.2.1", - "y18n": "^5.0.5", - "yargs-parser": "^22.0.0" - }, - "engines": { - "node": "^20.19.0 || ^22.12.0 || >=23" - } - }, - "node_modules/yargs-parser": { - "version": "22.0.0", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-22.0.0.tgz", - "integrity": "sha512-rwu/ClNdSMpkSrUb+d6BRsSkLUq1fmfsY6TOpYzTwvwkg1/NRG85KBy3kq++A8LKQwX6lsu+aWad+2khvuXrqw==", - "license": "ISC", - "engines": { - "node": "^20.19.0 || ^22.12.0 || >=23" - } - } - } -} diff --git a/package.json b/package.json deleted file mode 100644 index b7d66ab..0000000 --- a/package.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "hinge-cli", - "version": "0.1.6", - "description": "Command-line client for your own Hinge account, built on its reverse-engineered HTTP API.", - "type": "module", - "license": "MIT", - "bin": { - "hinge": "dist/cli.js" - }, - "files": [ - "dist" - ], - "engines": { - "node": ">=22.18" - }, - "scripts": { - "build": "tsc -p tsconfig.build.json", - "typecheck": "tsc --noEmit", - "test": "node --test \"test/*.test.ts\"" - }, - "dependencies": { - "commander": "^15.1.0", - "webdriver": "^10.2.0" - }, - "devDependencies": { - "@types/node": "^26.6.6", - "typescript": "^7.0.2" - } -} diff --git a/src/api.rs b/src/api.rs new file mode 100644 index 0000000..6fcdf20 --- /dev/null +++ b/src/api.rs @@ -0,0 +1,158 @@ +use crate::session_store::Session; +use anyhow::{Result, bail}; +use serde::Serialize; +use serde_json::Value; +use uuid::Uuid; + +pub const BASE: &str = "https://prod-api.hingeaws.net"; + +/// Every HTTP request this tool makes identifies as a generic Android phone (Chrome on a Pixel-class +/// device). It replaces any `user-agent` the captured session carried. +pub const USER_AGENT: &str = "Mozilla/5.0 (Linux; Android 14; Pixel 8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Mobile Safari/537.36"; + +pub fn client() -> Result { + Ok(reqwest::Client::builder().user_agent(USER_AGENT).build()?) +} + +pub async fn call(http: &reqwest::Client, base: &str, path: &str, s: &Session) -> Result { + let mut req = http.get(format!("{base}{path}")); + for (k, v) in &s.headers { + req = req.header(k, v); + } + let res = req + .header("accept", "application/json") + .header("x-hinge-request-id", Uuid::new_v4().to_string()) + .send() + .await?; + let status = res.status(); + if status.as_u16() == 401 || status.as_u16() == 403 { + bail!("Session expired or rejected: capture a new one and run `hinge auth import`"); + } + if !status.is_success() { + bail!("Hinge API {path} returned HTTP {}", status.as_u16()); + } + Ok(res.json().await?) +} + +#[derive(Debug, PartialEq, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct TierInfo { + pub tier: Option, + pub name: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub end: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub auto_renew: Option, +} + +/// `/store/v2/account` → tier. Only the free/paid split is verified; the tier integer is passed through as-is. +pub fn describe_tier(account: &Value) -> TierInfo { + let sub = &account["subscription"]; + let Some(tier) = sub["tier"].as_i64() else { + return TierInfo { + tier: None, + name: "free".into(), + end: None, + auto_renew: None, + }; + }; + TierInfo { + tier: Some(tier), + name: sub["name"] + .as_str() + .map_or_else(|| format!("tier {tier}"), String::from), + end: sub["end"].as_str().map(String::from), + auto_renew: sub["autoRenew"].as_bool(), + } +} + +#[cfg(test)] +mod tests { + use super::*; + use serde_json::json; + use std::collections::BTreeMap; + use tokio::io::{AsyncReadExt, AsyncWriteExt}; + use tokio::net::TcpListener; + + /// One-shot local HTTP server: answers with `status`, returns the raw request it received. + async fn serve(status: u16) -> (String, tokio::task::JoinHandle) { + let l = TcpListener::bind("127.0.0.1:0").await.unwrap(); + let base = format!("http://{}", l.local_addr().unwrap()); + let h = tokio::spawn(async move { + let (mut sock, _) = l.accept().await.unwrap(); + let mut buf = vec![0u8; 8192]; + let n = sock.read(&mut buf).await.unwrap(); + let reply = format!( + "HTTP/1.1 {status} X\r\ncontent-type: application/json\r\ncontent-length: 2\r\nconnection: close\r\n\r\n{{}}" + ); + sock.write_all(reply.as_bytes()).await.unwrap(); + String::from_utf8_lossy(&buf[..n]).to_lowercase() + }); + (base, h) + } + + fn session() -> Session { + Session { + headers: BTreeMap::from([ + ("authorization".into(), "t".into()), + ("x-device-id".into(), "d".into()), + ]), + } + } + + #[test] + fn tier_is_free_unless_a_tier_number_is_present() { + assert_eq!( + describe_tier(&json!({})), + TierInfo { + tier: None, + name: "free".into(), + end: None, + auto_renew: None + } + ); + assert_eq!( + describe_tier(&json!({"subscription": {"tier": 2, "name": "Hinge+"}})).name, + "Hinge+" + ); + assert_eq!( + describe_tier(&json!({"subscription": {"tier": 3}})).name, + "tier 3" + ); + } + + #[tokio::test] + async fn api_errors_and_android_user_agent() { + let http = client().unwrap(); + for (status, want) in [ + (401, "Session expired"), + (403, "Session expired"), + (500, "HTTP 500"), + ] { + let (base, _) = serve(status).await; + let e = call(&http, &base, "/x", &session()) + .await + .unwrap_err() + .to_string(); + assert!(e.contains(want), "{e}"); + } + let (base, req) = serve(200).await; + assert_eq!( + call(&http, &base, "/x", &session()).await.unwrap(), + json!({}) + ); + let req = req.await.unwrap(); + assert!( + req.contains("user-agent: mozilla/5.0 (linux; android"), + "{req}" + ); + assert!( + !req.contains("iphone") && !req.contains("cfnetwork"), + "{req}" + ); + assert!( + req.contains("authorization: t") && req.contains("x-hinge-request-id: "), + "{req}" + ); + } +} diff --git a/src/api.ts b/src/api.ts deleted file mode 100644 index 90a613c..0000000 --- a/src/api.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { randomUUID } from "node:crypto"; -import type { Session } from "./session-store.ts"; - -const BASE = "https://prod-api.hingeaws.net"; - -export async function call(path: string, s: Session, fetchFn: typeof fetch = fetch): Promise { - const res = await fetchFn(BASE + path, { headers: { ...s.headers, accept: "application/json", "x-hinge-request-id": randomUUID() } }); - if (res.status === 401 || res.status === 403) throw new Error("Session expired or rejected: capture a new one and run `hinge auth import`"); - if (!res.ok) throw new Error(`Hinge API ${path} returned HTTP ${res.status}`); - return res.json(); -} - -export interface TierInfo { tier: number | null; name: string; end?: string; autoRenew?: boolean } - -/** /store/v2/account → tier. Only the free/paid split is verified; the tier integer is passed through as-is. */ -export function describeTier(account: any): TierInfo { - const sub = account?.subscription; - if (!sub || typeof sub.tier !== "number") return { tier: null, name: "free" }; - return { tier: sub.tier, name: String(sub.name ?? `tier ${sub.tier}`), end: sub.end, autoRenew: sub.autoRenew }; -} diff --git a/src/appium.rs b/src/appium.rs new file mode 100644 index 0000000..bbe4ae6 --- /dev/null +++ b/src/appium.rs @@ -0,0 +1,203 @@ +//! Appium / WebDriverAgent client over the W3C WebDriver HTTP protocol. Used only by `hinge doctor` and +//! `hinge inspect` (exploration of the iOS app); `tier`, `limits` and `auth` never touch it. +use crate::api::client; +use anyhow::{Result, anyhow, bail}; +use reqwest::{Client, Url}; +use serde_json::{Value, json}; + +pub struct Config { + pub server: Url, + pub udid: Option, + pub bundle_id: String, + pub team_id: Option, +} + +pub fn config_from_env(env: &dyn Fn(&str) -> Option) -> Result { + Ok(Config { + server: Url::parse( + &env("HINGE_APPIUM_URL").unwrap_or_else(|| "http://127.0.0.1:4723".into()), + )?, + udid: env("HINGE_UDID"), + // shortcut: bundle id not verified against the App Store build; override with HINGE_BUNDLE_ID. + bundle_id: env("HINGE_BUNDLE_ID").unwrap_or_else(|| "co.hinge.mobile.ios".into()), + team_id: env("HINGE_TEAM_ID"), + }) +} + +fn endpoint(server: &Url, path: &str) -> Result { + let mut base = server.clone(); + if !base.path().ends_with('/') { + base.set_path(&format!("{}/", base.path())); + } + Ok(base.join(path)?) +} + +/// `GET /status`: is an Appium server reachable? Returns the HTTP status. +pub async fn status(c: &Config) -> Result { + let res = client()? + .get(endpoint(&c.server, "status")?) + .send() + .await + .map_err(|e| { + anyhow!( + "Appium not reachable at {}: {:#}", + c.server, + anyhow::Error::from(e) + ) + })?; + Ok(res.status().as_u16()) +} + +pub struct Device { + http: Client, + server: Url, + id: String, +} + +async fn send(req: reqwest::RequestBuilder) -> Result { + let res = req.send().await?; + let ok = res.status().is_success(); + let status = res.status().as_u16(); + let body: Value = res.json().await.unwrap_or(Value::Null); + if !ok { + bail!( + "Appium: {}", + body["value"]["message"] + .as_str() + .map_or_else(|| format!("HTTP {status}"), String::from) + ); + } + Ok(body["value"].clone()) +} + +pub async fn connect(c: &Config) -> Result { + let mut caps = json!({ + "platformName": "iOS", + "appium:automationName": "XCUITest", + "appium:bundleId": c.bundle_id, + "appium:noReset": true, + }); + if let Some(u) = &c.udid { + caps["appium:udid"] = json!(u); + } + if let Some(t) = &c.team_id { + caps["appium:xcodeOrgId"] = json!(t); + caps["appium:xcodeSigningId"] = json!("iPhone Developer"); + } + let http = client()?; + let v = send( + http.post(endpoint(&c.server, "session")?) + .json(&json!({ "capabilities": { "alwaysMatch": caps } })), + ) + .await?; + let id = v["sessionId"] + .as_str() + .ok_or_else(|| anyhow!("Appium returned no session id"))? + .to_string(); + Ok(Device { + http, + server: c.server.clone(), + id, + }) +} + +fn element_id(el: &Value) -> Result { + el.as_object() + .and_then(|o| o.values().next()) + .and_then(Value::as_str) + .map(String::from) + .ok_or_else(|| anyhow!("Appium returned a malformed element")) +} + +impl Device { + fn url(&self, rest: &str) -> Result { + endpoint(&self.server, &format!("session/{}/{rest}", self.id)) + } + + /// Every visible text label on the current screen (label of StaticText and Button elements). + pub async fn visible_labels(&self) -> Result> { + let predicate = + r#"type IN {"XCUIElementTypeStaticText","XCUIElementTypeButton"} AND visible == 1"#; + let els = send( + self.http + .post(self.url("elements")?) + .json(&json!({ "using": "-ios predicate string", "value": predicate })), + ) + .await?; + let mut out = vec![]; + for el in els.as_array().into_iter().flatten() { + let label = send( + self.http + .get(self.url(&format!("element/{}/attribute/label", element_id(el)?))?), + ) + .await?; + if let Some(l) = label.as_str().filter(|l| !l.is_empty()) { + out.push(l.to_string()); + } + } + Ok(out) + } + + #[allow(dead_code)] // exploration helper kept from the TypeScript version; no command uses it yet + pub async fn tap(&self, label: &str) -> Result<()> { + let el = send( + self.http + .post(self.url("element")?) + .json(&json!({ "using": "accessibility id", "value": label })), + ) + .await?; + send( + self.http + .post(self.url(&format!("element/{}/click", element_id(&el)?))?) + .json(&json!({})), + ) + .await?; + Ok(()) + } + + pub async fn close(self) -> Result<()> { + send( + self.http + .delete(endpoint(&self.server, &format!("session/{}", self.id))?), + ) + .await?; + Ok(()) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn config_defaults_and_overrides() { + let c = config_from_env(&|_| None).unwrap(); + assert_eq!( + (c.server.as_str(), c.bundle_id.as_str(), c.udid), + ("http://127.0.0.1:4723/", "co.hinge.mobile.ios", None) + ); + let c = config_from_env(&|k| (k == "HINGE_UDID").then(|| "U".to_string())).unwrap(); + assert_eq!(c.udid.as_deref(), Some("U")); + assert!( + config_from_env(&|k| (k == "HINGE_APPIUM_URL").then(|| "nope".to_string())).is_err() + ); + } + + #[test] + fn endpoints_keep_a_base_path() { + let u = Url::parse("http://h:4723/wd/hub").unwrap(); + assert_eq!( + endpoint(&u, "session").unwrap().as_str(), + "http://h:4723/wd/hub/session" + ); + } + + #[test] + fn element_ids_come_from_the_w3c_element_key() { + assert_eq!( + element_id(&json!({"element-6066-11e4-a52e-4f735466cecf": "abc"})).unwrap(), + "abc" + ); + assert!(element_id(&json!(1)).is_err()); + } +} diff --git a/src/cli.ts b/src/cli.ts deleted file mode 100644 index 796e96b..0000000 --- a/src/cli.ts +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env node -import { Command } from "commander"; -import { resolveSecret } from "./secrets.ts"; -import { configFromEnv, connect, tap, visibleLabels } from "./session.ts"; -import { call, describeTier } from "./api.ts"; -import { clearSession, loadSession, parseSession, saveSession, sessionPath } from "./session-store.ts"; -import { readFile, rm } from "node:fs/promises"; - -const program = new Command("hinge").description("CLI for your own Hinge account, via its reverse-engineered HTTP API").option("--json", "machine-readable output"); -const out = (data: unknown, text: string) => console.log(program.opts().json ? JSON.stringify(data) : text); - -async function withDevice(fn: (d: Awaited>) => Promise): Promise { - const d = await connect(configFromEnv()); - try { return await fn(d); } finally { await d.deleteSession(); } -} - -program.command("doctor").description("check the Appium server and the connected device").action(async () => { - const c = configFromEnv(); - const res = await fetch(new URL("status", c.server)).catch((e) => { throw new Error(`Appium not reachable at ${c.server}: ${e.cause?.code ?? e.message}`); }); - out({ appium: res.ok, udid: c.udid ?? null }, `Appium ${res.ok ? "OK" : "HTTP " + res.status} at ${c.server}; device: ${c.udid ?? "(first available)"}`); -}); - -program.command("tier").description("show your subscription tier").action(async () => { - const t = describeTier(await call("/store/v2/account", await loadSession())); - out(t, t.tier === null ? "free" : `${t.name} (tier ${t.tier})${t.end ? `, ends ${t.end}` : ""}`); -}); - -program.command("limits").description("likes, superlikes, snoozes and undos left").action(async () => { - const l = await call("/likelimit", await loadSession()); - out(l, Object.entries(l).map(([k, v]) => `${k}: ${v}`).join(", ")); -}); - -const auth = program.command("auth").description("manage the saved Hinge session"); -auth.command("import").description("import a session captured with tools/hinge_token.py").argument("").option("--keep", "keep the source file").action(async (file, o) => { - await saveSession(parseSession(await readFile(file, "utf8"))); - if (!o.keep) await rm(file); - out({ ok: true }, `session saved to ${sessionPath()}${o.keep ? "" : "; source file deleted"}`); -}); -auth.command("status").description("check that the saved session works").action(async () => { - await call("/store/v2/account", await loadSession()); - out({ ok: true }, "session OK"); -}); -auth.command("logout").description("delete the saved session").action(async () => { await clearSession(); out({ ok: true }, "session deleted"); }); - -program.command("inspect").description("print the visible labels on the current screen (use it to learn selectors)").action(async () => { - const labels = await withDevice(visibleLabels); - out({ labels }, labels.join("\n")); -}); - -program.command("secret").description("resolve a secret reference and check it works (value is hidden)").argument("", "env://, op://, bw://, keychain://, cmd://").action(async (ref) => { - const v = await resolveSecret(ref); - out({ ok: true, length: v.length }, `resolved (${v.length} chars)`); -}); - -program.parseAsync().catch((e) => { console.error(`error: ${e.message}`); process.exit(1); }); diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..f7e2086 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,205 @@ +mod api; +mod appium; +mod secrets; +mod session_store; + +use anyhow::Result; +use clap::{Parser, Subcommand}; +use serde::Serialize; +use serde_json::{Value, json}; +use session_store::{ + clear_session, load_session, parse_session, real_env, save_session, session_path, +}; +use std::path::PathBuf; + +#[derive(Parser)] +#[command( + name = "hinge", + version, + about = "CLI for your own Hinge account, via its reverse-engineered HTTP API" +)] +struct Cli { + /// machine-readable output + #[arg(long, global = true)] + json: bool, + #[command(subcommand)] + cmd: Cmd, +} + +#[derive(Subcommand)] +enum Cmd { + /// check the Appium server and the connected device + Doctor, + /// show your subscription tier + Tier, + /// likes, superlikes, snoozes and undos left + Limits, + /// manage the saved Hinge session + Auth { + #[command(subcommand)] + cmd: AuthCmd, + }, + /// print the visible labels on the current screen (use it to learn selectors) + Inspect, + /// resolve a secret reference and check it works (value is hidden) + Secret { + /// env://, op://, bw://, keychain://, cmd:// + #[arg(value_name = "ref")] + reference: String, + }, +} + +#[derive(Subcommand)] +enum AuthCmd { + /// import a session captured with tools/hinge_token.py + Import { + file: PathBuf, + /// keep the source file + #[arg(long)] + keep: bool, + }, + /// check that the saved session works + Status, + /// delete the saved session + Logout, +} + +fn out(json: bool, data: &T, text: String) -> Result<()> { + println!( + "{}", + if json { + serde_json::to_string(data)? + } else { + text + } + ); + Ok(()) +} + +fn show(v: &Value) -> String { + v.as_str().map_or_else(|| v.to_string(), String::from) +} + +async fn run(cli: Cli) -> Result<()> { + let j = cli.json; + match cli.cmd { + Cmd::Doctor => { + let c = appium::config_from_env(&real_env)?; + let code = appium::status(&c).await?; + let ok = (200..300).contains(&code); + let udid = c.udid.as_deref().unwrap_or("(first available)"); + out( + j, + &json!({ "appium": ok, "udid": c.udid }), + format!( + "Appium {} at {}; device: {udid}", + if ok { + "OK".into() + } else { + format!("HTTP {code}") + }, + c.server + ), + ) + } + Cmd::Tier => { + let account = api::call( + &api::client()?, + api::BASE, + "/store/v2/account", + &load_session()?, + ) + .await?; + let t = api::describe_tier(&account); + let text = match t.tier { + None => "free".to_string(), + Some(n) => format!( + "{} (tier {n}){}", + t.name, + t.end + .as_ref() + .map(|e| format!(", ends {e}")) + .unwrap_or_default() + ), + }; + out(j, &t, text) + } + Cmd::Limits => { + let l = api::call(&api::client()?, api::BASE, "/likelimit", &load_session()?).await?; + let text = l + .as_object() + .map(|o| { + o.iter() + .map(|(k, v)| format!("{k}: {}", show(v))) + .collect::>() + .join(", ") + }) + .unwrap_or_default(); + out(j, &l, text) + } + Cmd::Auth { + cmd: AuthCmd::Import { file, keep }, + } => { + let path = session_path(&real_env, std::env::consts::OS); + save_session(&parse_session(&std::fs::read_to_string(&file)?)?, &path)?; + if !keep { + std::fs::remove_file(&file)?; + } + out( + j, + &json!({ "ok": true }), + format!( + "session saved to {}{}", + path.display(), + if keep { "" } else { "; source file deleted" } + ), + ) + } + Cmd::Auth { + cmd: AuthCmd::Status, + } => { + api::call( + &api::client()?, + api::BASE, + "/store/v2/account", + &load_session()?, + ) + .await?; + out(j, &json!({ "ok": true }), "session OK".into()) + } + Cmd::Auth { + cmd: AuthCmd::Logout, + } => { + clear_session(&session_path(&real_env, std::env::consts::OS))?; + out(j, &json!({ "ok": true }), "session deleted".into()) + } + Cmd::Inspect => { + let d = appium::connect(&appium::config_from_env(&real_env)?).await?; + let labels = d.visible_labels().await; + d.close().await.ok(); // always release the Appium session, even when reading labels failed + let labels = labels?; + out(j, &json!({ "labels": labels }), labels.join("\n")) + } + Cmd::Secret { reference } => { + let v = secrets::resolve_secret( + &reference, + &secrets::default_runner, + std::env::consts::OS, + &real_env, + )?; + out( + j, + &json!({ "ok": true, "length": v.chars().count() }), + format!("resolved ({} chars)", v.chars().count()), + ) + } + } +} + +#[tokio::main] +async fn main() { + if let Err(e) = run(Cli::parse()).await { + eprintln!("error: {e}"); + std::process::exit(1); + } +} diff --git a/src/secrets.rs b/src/secrets.rs new file mode 100644 index 0000000..64d7773 --- /dev/null +++ b/src/secrets.rs @@ -0,0 +1,151 @@ +use anyhow::{Result, bail}; +use std::process::{Command, Stdio}; +use std::time::{Duration, Instant}; + +pub type Runner<'a> = &'a dyn Fn(&str, &[&str]) -> Result; + +/// Runs a program (no shell) and returns its stdout; killed after 30 s. +pub fn default_runner(cmd: &str, args: &[&str]) -> Result { + let mut child = Command::new(cmd) + .args(args) + .stdout(Stdio::piped()) + .stderr(Stdio::null()) + .spawn() + .map_err(|e| anyhow::anyhow!("could not run `{cmd}`: {e}"))?; + let start = Instant::now(); + // shortcut: polls instead of reading concurrently, fine for the few bytes a secret is; use a reader thread if outputs grow. + while child.try_wait()?.is_none() { + if start.elapsed() > Duration::from_secs(30) { + child.kill().ok(); + bail!("`{cmd}` timed out"); + } + std::thread::sleep(Duration::from_millis(25)); + } + let out = child.wait_with_output()?; + if !out.status.success() { + bail!("`{cmd}` failed ({})", out.status); + } + Ok(String::from_utf8_lossy(&out.stdout).into_owned()) +} + +/// Resolve a secret reference without ever storing it. Supported schemes: +/// env://NAME environment variable +/// op://vault/item/field 1Password CLI (`op read`) +/// bw://item-name[/field] Bitwarden CLI (`bw get`); field = password|username|totp +/// keychain://service/account macOS Keychain, Linux libsecret (secret-tool) +/// KeePassXC, Dashlane, pass etc.: use `cmd:// `, run without a shell. +pub fn resolve_secret( + reference: &str, + runner: Runner, + os: &str, + env: &dyn Fn(&str) -> Option, +) -> Result { + let parsed = reference.split_once("://").filter(|(s, p)| { + !s.is_empty() && s.bytes().all(|b| b.is_ascii_lowercase()) && !p.is_empty() + }); + let Some((scheme, path)) = parsed else { + bail!( + "Invalid secret reference \"{}://…\": expected scheme://path", + reference.split("://").next().unwrap_or("") + ); + }; + let out = match scheme { + "env" => { + return env(path) + .ok_or_else(|| anyhow::anyhow!("Environment variable {path} is not set")); + } + "op" => runner("op", &["read", reference])?, + "bw" => { + let mut parts = path.split('/'); + let item = parts.next().unwrap_or(""); + let field = parts.next().unwrap_or("password"); + if !["password", "username", "totp"].contains(&field) { + bail!("Unsupported bw field \"{field}\""); + } + runner("bw", &["get", field, item])? + } + "keychain" => { + let mut parts = path.split('/'); + let (Some(service), Some(account)) = ( + parts.next().filter(|s| !s.is_empty()), + parts.next().filter(|s| !s.is_empty()), + ) else { + bail!("keychain:// needs service/account"); + }; + match os { + "macos" => runner( + "security", + &["find-generic-password", "-s", service, "-a", account, "-w"], + )?, + "linux" => runner( + "secret-tool", + &["lookup", "service", service, "account", account], + )?, + _ => bail!("keychain:// is not supported on this OS; use op://, bw:// or cmd://"), + } + } + "cmd" => { + let mut words = path.split(' ').filter(|w| !w.is_empty()); + let Some(prog) = words.next() else { + bail!("cmd:// needs a program") + }; + runner(prog, &words.collect::>())? + } + _ => bail!("Unknown secret scheme \"{scheme}\""), + }; + Ok(out + .strip_suffix('\n') + .map(|s| s.strip_suffix('\r').unwrap_or(s)) + .unwrap_or(&out) + .to_string()) +} + +#[cfg(test)] +mod tests { + use super::*; + use std::cell::RefCell; + + fn no_env(_: &str) -> Option { + None + } + + #[test] + fn env_op_bw_and_keychain_references() { + let calls = RefCell::new(Vec::::new()); + let fake = |cmd: &str, _: &[&str]| { + calls.borrow_mut().push(cmd.to_string()); + Ok("s3cret\n".to_string()) + }; + let env = |k: &str| (k == "X").then(|| "v".to_string()); + assert_eq!( + resolve_secret("env://X", &fake, "linux", &env).unwrap(), + "v" + ); + assert_eq!( + resolve_secret("op://v/i/f", &fake, "linux", &no_env).unwrap(), + "s3cret" + ); + assert_eq!( + resolve_secret("bw://hinge/totp", &fake, "linux", &no_env).unwrap(), + "s3cret" + ); + resolve_secret("keychain://svc/me", &fake, "macos", &no_env).unwrap(); + resolve_secret("keychain://svc/me", &fake, "linux", &no_env).unwrap(); + assert_eq!(*calls.borrow(), ["op", "bw", "security", "secret-tool"]); + } + + #[test] + fn bad_references_fail_without_leaking_the_reference_path() { + let fake = |_: &str, _: &[&str]| Ok(String::new()); + let err = |r: &str, os: &str| { + resolve_secret(r, &fake, os, &no_env) + .unwrap_err() + .to_string() + }; + assert!(err("nope", "linux").contains("Invalid secret reference")); + assert!(err("zz://a", "linux").contains("Unknown secret scheme")); + assert!(err("env://MISSING_VAR_XYZ", "linux").contains("not set")); + assert!(err("keychain://a/b", "windows").contains("not supported")); + assert!(!err("zz://secretpath", "linux").contains("secretpath")); + } +} diff --git a/src/secrets.ts b/src/secrets.ts deleted file mode 100644 index 4a888cd..0000000 --- a/src/secrets.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { execFile } from "node:child_process"; -import { promisify } from "node:util"; - -const run = promisify(execFile); -export type Runner = (cmd: string, args: string[]) => Promise; - -const defaultRunner: Runner = async (cmd, args) => (await run(cmd, args, { timeout: 30_000 })).stdout; - -/** - * Resolve a secret reference without ever storing it. Supported schemes: - * env://NAME environment variable - * op://vault/item/field 1Password CLI (`op read`) - * bw://item-name[/field] Bitwarden CLI (`bw get`); field = password|username|totp - * keychain://service/account macOS Keychain, Linux libsecret (secret-tool) - * KeePassXC, Dashlane, pass etc.: use `cmd:// `, run without a shell. - */ -export async function resolveSecret(ref: string, runner: Runner = defaultRunner, platform = process.platform, env = process.env): Promise { - const m = /^([a-z]+):\/\/(.+)$/.exec(ref); - if (!m) throw new Error(`Invalid secret reference "${ref.split("://")[0]}://…": expected scheme://path`); - const [, scheme, path] = m; - let out: string; - switch (scheme) { - case "env": { - const v = env[path]; - if (v === undefined) throw new Error(`Environment variable ${path} is not set`); - return v; - } - case "op": - out = await runner("op", ["read", ref]); - break; - case "bw": { - const [item, field = "password"] = path.split("/"); - if (!["password", "username", "totp"].includes(field)) throw new Error(`Unsupported bw field "${field}"`); - out = await runner("bw", ["get", field, item]); - break; - } - case "keychain": { - const [service, account] = path.split("/"); - if (!service || !account) throw new Error("keychain:// needs service/account"); - if (platform === "darwin") out = await runner("security", ["find-generic-password", "-s", service, "-a", account, "-w"]); - else if (platform === "linux") out = await runner("secret-tool", ["lookup", "service", service, "account", account]); - else throw new Error("keychain:// is not supported on this OS; use op://, bw:// or cmd://"); - break; - } - case "cmd": { - const [prog, ...args] = path.split(" ").filter(Boolean); - out = await runner(prog, args); - break; - } - default: - throw new Error(`Unknown secret scheme "${scheme}"`); - } - return out.replace(/\r?\n$/, ""); -} diff --git a/src/session-store.ts b/src/session-store.ts deleted file mode 100644 index 04c363c..0000000 --- a/src/session-store.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { mkdir, readFile, rm, writeFile } from "node:fs/promises"; -import { homedir } from "node:os"; -import { dirname, join } from "node:path"; -import { resolveSecret } from "./secrets.ts"; - -export interface Session { headers: Record } - -const KEEP = new Set(["authorization", "user_id", "user-agent", "accept-language", "x-app-identifier", "x-app-version", "x-build-number", "x-device-id", "x-device-model", "x-device-model-code", "x-device-platform", "x-device-region", "x-install-id", "x-os-version", "x-session-id"]); - -export function sessionPath(env = process.env, platform = process.platform): string { - if (env.HINGE_SESSION_FILE) return env.HINGE_SESSION_FILE; - const base = platform === "win32" ? (env.APPDATA ?? join(homedir(), "AppData", "Roaming")) : (env.XDG_CONFIG_HOME ?? join(homedir(), ".config")); - return join(base, "hinge-cli", "session.json"); -} - -/** Validate untrusted JSON and keep only allow-listed headers. Never echoes values in errors. */ -export function parseSession(text: string): Session { - let raw: unknown; - try { raw = JSON.parse(text); } catch { throw new Error("Session is not valid JSON"); } - const h = (raw as { headers?: Record } | null)?.headers; - if (!h || typeof h !== "object") throw new Error('Session has no "headers" object'); - const headers: Record = {}; - for (const [k, v] of Object.entries(h)) if (KEEP.has(k.toLowerCase()) && typeof v === "string") headers[k.toLowerCase()] = v; - if (!headers.authorization) throw new Error("Session has no authorization header"); - return { headers }; -} - -export async function loadSession(env = process.env): Promise { - const ref = env.HINGE_SESSION_REF; - try { - return parseSession(ref ? await resolveSecret(ref) : await readFile(sessionPath(env), "utf8")); - } catch (e) { - if ((e as NodeJS.ErrnoException).code === "ENOENT") throw new Error("Not signed in: run `hinge auth import ` (see docs/auth.md)"); - throw e; - } -} - -// shortcut: mode 0600/0700 is a no-op on Windows (relies on the per-user %APPDATA% ACL); move to the OS credential store if that matters. -export async function saveSession(s: Session, path = sessionPath()): Promise { - await mkdir(dirname(path), { recursive: true, mode: 0o700 }); - await writeFile(path, JSON.stringify(s), { mode: 0o600 }); -} - -export const clearSession = (path = sessionPath()) => rm(path, { force: true }); diff --git a/src/session.ts b/src/session.ts deleted file mode 100644 index 520e32c..0000000 --- a/src/session.ts +++ /dev/null @@ -1,54 +0,0 @@ -import WebDriver from "webdriver"; - -export interface Config { - server: URL; - udid?: string; - bundleId: string; - teamId?: string; -} - -export function configFromEnv(env = process.env): Config { - return { - server: new URL(env.HINGE_APPIUM_URL ?? "http://127.0.0.1:4723"), - udid: env.HINGE_UDID, - // shortcut: bundle id not verified against the App Store build; override with HINGE_BUNDLE_ID. - bundleId: env.HINGE_BUNDLE_ID ?? "co.hinge.mobile.ios", - teamId: env.HINGE_TEAM_ID, - }; -} - -export type Client = Awaited>; - -export async function connect(c: Config): Promise { - return WebDriver.newSession({ - protocol: c.server.protocol.replace(":", ""), - hostname: c.server.hostname, - port: Number(c.server.port || (c.server.protocol === "https:" ? 443 : 80)), - path: c.server.pathname, - capabilities: { - platformName: "iOS", - "appium:automationName": "XCUITest", - "appium:bundleId": c.bundleId, - "appium:noReset": true, - ...(c.udid && { "appium:udid": c.udid }), - ...(c.teamId && { "appium:xcodeOrgId": c.teamId, "appium:xcodeSigningId": "iPhone Developer" }), - }, - }); -} - -/** Every visible text label on the current screen (name/label/value of StaticText, Button, Cell). */ -export async function visibleLabels(d: Client): Promise { - const els = await d.findElements("-ios predicate string", 'type IN {"XCUIElementTypeStaticText","XCUIElementTypeButton"} AND visible == 1'); - const out: string[] = []; - for (const el of els) { - const id = Object.values(el)[0] as string; - const label = (await d.getElementAttribute(id, "label")) as string | null; - if (label) out.push(label); - } - return out; -} - -export async function tap(d: Client, label: string): Promise { - const el = await d.findElement("accessibility id", label); - await d.elementClick(Object.values(el)[0] as string); -} diff --git a/src/session_store.rs b/src/session_store.rs new file mode 100644 index 0000000..706759e --- /dev/null +++ b/src/session_store.rs @@ -0,0 +1,200 @@ +use crate::secrets::{default_runner, resolve_secret}; +use anyhow::{Result, bail}; +use serde::{Deserialize, Serialize}; +use serde_json::Value; +use std::collections::BTreeMap; +use std::fs; +use std::path::{Path, PathBuf}; + +#[derive(Debug, Serialize, Deserialize)] +pub struct Session { + pub headers: BTreeMap, +} + +/// `user-agent` is deliberately absent: requests always send the generic Android one from `api::USER_AGENT`. +const KEEP: [&str; 14] = [ + "authorization", + "user_id", + "accept-language", + "x-app-identifier", + "x-app-version", + "x-build-number", + "x-device-id", + "x-device-model", + "x-device-model-code", + "x-device-platform", + "x-device-region", + "x-install-id", + "x-os-version", + "x-session-id", +]; + +pub type Env<'a> = &'a dyn Fn(&str) -> Option; +pub fn real_env(k: &str) -> Option { + std::env::var(k).ok() +} + +pub fn session_path(env: Env, os: &str) -> PathBuf { + if let Some(f) = env("HINGE_SESSION_FILE").filter(|f| !f.is_empty()) { + return f.into(); + } + let home = || { + PathBuf::from( + env("HOME") + .or_else(|| env("USERPROFILE")) + .unwrap_or_default(), + ) + }; + let base = if os == "windows" { + env("APPDATA").map_or_else(|| home().join("AppData").join("Roaming"), PathBuf::from) + } else { + env("XDG_CONFIG_HOME").map_or_else(|| home().join(".config"), PathBuf::from) + }; + base.join("hinge-cli").join("session.json") +} + +/// Validate untrusted JSON and keep only allow-listed headers. Never echoes values in errors. +pub fn parse_session(text: &str) -> Result { + let Ok(raw) = serde_json::from_str::(text) else { + bail!("Session is not valid JSON") + }; + let Some(h) = raw["headers"].as_object() else { + bail!("Session has no \"headers\" object") + }; + let headers: BTreeMap = h + .iter() + .filter_map(|(k, v)| Some((k.to_lowercase(), v.as_str()?.to_string()))) + .filter(|(k, _)| KEEP.contains(&k.as_str())) + .collect(); + if !headers.contains_key("authorization") { + bail!("Session has no authorization header"); + } + Ok(Session { headers }) +} + +pub fn load_session() -> Result { + if let Some(r) = real_env("HINGE_SESSION_REF").filter(|r| !r.is_empty()) { + return parse_session(&resolve_secret( + &r, + &default_runner, + std::env::consts::OS, + &real_env, + )?); + } + match fs::read_to_string(session_path(&real_env, std::env::consts::OS)) { + Ok(text) => parse_session(&text), + Err(e) if e.kind() == std::io::ErrorKind::NotFound => { + bail!("Not signed in: run `hinge auth import ` (see docs/auth.md)") + } + Err(e) => Err(e.into()), + } +} + +// shortcut: mode 0600/0700 is a no-op on Windows (relies on the per-user %APPDATA% ACL); move to the OS credential store if that matters. +pub fn save_session(s: &Session, path: &Path) -> Result<()> { + if let Some(dir) = path.parent() { + let mut b = fs::DirBuilder::new(); + b.recursive(true); + #[cfg(unix)] + std::os::unix::fs::DirBuilderExt::mode(&mut b, 0o700); + b.create(dir)?; + } + let mut o = fs::OpenOptions::new(); + o.write(true).create(true).truncate(true); + #[cfg(unix)] + std::os::unix::fs::OpenOptionsExt::mode(&mut o, 0o600); + std::io::Write::write_all(&mut o.open(path)?, serde_json::to_string(s)?.as_bytes())?; + Ok(()) +} + +pub fn clear_session(path: &Path) -> Result<()> { + match fs::remove_file(path) { + Err(e) if e.kind() != std::io::ErrorKind::NotFound => Err(e.into()), + _ => Ok(()), + } +} + +#[cfg(test)] +mod tests { + use super::*; + + fn env<'a>(pairs: &'a [(&'a str, &'a str)]) -> impl Fn(&str) -> Option + 'a { + move |k| { + pairs + .iter() + .find(|(n, _)| *n == k) + .map(|(_, v)| v.to_string()) + } + } + + #[test] + fn parsing_keeps_only_allow_listed_headers_and_requires_authorization() { + let s = parse_session(r#"{"headers":{"Authorization":"Bearer x","cookie":"no","user-agent":"iOS","x-device-id":"d"}}"#).unwrap(); + assert_eq!( + s.headers.keys().collect::>(), + ["authorization", "x-device-id"] + ); + assert!( + parse_session("{") + .unwrap_err() + .to_string() + .contains("not valid JSON") + ); + assert!( + parse_session(r#"{"headers":{"x-device-id":"d"}}"#) + .unwrap_err() + .to_string() + .contains("no authorization") + ); + assert!( + parse_session("{}") + .unwrap_err() + .to_string() + .contains("no \"headers\"") + ); + } + + #[test] + fn path_per_os() { + assert!( + session_path(&env(&[("APPDATA", "C:\\A")]), "windows") + .to_string_lossy() + .contains("hinge-cli") + ); + assert_eq!( + session_path(&env(&[("HINGE_SESSION_FILE", "/f")]), "linux"), + PathBuf::from("/f") + ); + assert_eq!( + session_path(&env(&[("XDG_CONFIG_HOME", "/x")]), "linux"), + PathBuf::from("/x/hinge-cli/session.json") + ); + assert_eq!( + session_path(&env(&[("HOME", "/h")]), "macos"), + PathBuf::from("/h/.config/hinge-cli/session.json") + ); + } + + #[test] + fn save_then_clear_round_trip_is_private() { + let dir = std::env::temp_dir().join(format!("hinge-cli-test-{}", std::process::id())); + let path = dir.join("nested").join("session.json"); + let s = parse_session(r#"{"headers":{"authorization":"t"}}"#).unwrap(); + save_session(&s, &path).unwrap(); + assert_eq!( + parse_session(&fs::read_to_string(&path).unwrap()) + .unwrap() + .headers["authorization"], + "t" + ); + #[cfg(unix)] + assert_eq!( + std::os::unix::fs::PermissionsExt::mode(&fs::metadata(&path).unwrap().permissions()) + & 0o777, + 0o600 + ); + clear_session(&path).unwrap(); + clear_session(&path).unwrap(); + fs::remove_dir_all(dir).ok(); + } +} diff --git a/test/core.test.ts b/test/core.test.ts deleted file mode 100644 index d9b92c2..0000000 --- a/test/core.test.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { test } from "node:test"; -import assert from "node:assert/strict"; -import { resolveSecret } from "../src/secrets.ts"; -import { call, describeTier } from "../src/api.ts"; -import { parseSession, sessionPath } from "../src/session-store.ts"; - -const fake = (calls: string[][]) => async (cmd: string, args: string[]) => { calls.push([cmd, ...args]); return "s3cret\n"; }; - -test("env, op, bw and keychain references", async () => { - const calls: string[][] = []; - assert.equal(await resolveSecret("env://X", fake(calls), "linux", { X: "v" }), "v"); - assert.equal(await resolveSecret("op://v/i/f", fake(calls)), "s3cret"); - assert.equal(await resolveSecret("bw://hinge/totp", fake(calls)), "s3cret"); - await resolveSecret("keychain://svc/me", fake(calls), "darwin"); - await resolveSecret("keychain://svc/me", fake(calls), "linux"); - assert.deepEqual(calls.map((c) => c[0]), ["op", "bw", "security", "secret-tool"]); -}); - -test("bad references fail without leaking the reference path", async () => { - await assert.rejects(resolveSecret("nope"), /Invalid secret reference/); - await assert.rejects(resolveSecret("zz://a"), /Unknown secret scheme/); - await assert.rejects(resolveSecret("env://MISSING_VAR_XYZ", undefined, "linux", {}), /not set/); - await assert.rejects(resolveSecret("keychain://a/b", fake([]), "win32"), /not supported/); -}); - -test("session parsing keeps only allow-listed headers and requires authorization", () => { - const s = parseSession(JSON.stringify({ headers: { Authorization: "Bearer x", cookie: "no", "x-device-id": "d" } })); - assert.deepEqual(Object.keys(s.headers).sort(), ["authorization", "x-device-id"]); - assert.throws(() => parseSession("{"), /not valid JSON/); - assert.throws(() => parseSession('{"headers":{"x-device-id":"d"}}'), /no authorization/); -}); - -test("session path per OS", () => { - assert.match(sessionPath({ APPDATA: "C:\\A" }, "win32"), /hinge-cli/); - assert.equal(sessionPath({ HINGE_SESSION_FILE: "/f" }, "linux"), "/f"); - assert.match(sessionPath({ XDG_CONFIG_HOME: "/x" }, "linux"), /^\/x\/hinge-cli/); -}); - -test("tier and API errors", async () => { - assert.deepEqual(describeTier({}), { tier: null, name: "free" }); - assert.equal(describeTier({ subscription: { tier: 2, name: "Hinge+" } }).name, "Hinge+"); - const s = { headers: { authorization: "t" } }; - const f = (status: number) => (async () => new Response("{}", { status })) as typeof fetch; - await assert.rejects(call("/x", s, f(401)), /Session expired/); - await assert.rejects(call("/x", s, f(500)), /HTTP 500/); - assert.deepEqual(await call("/x", s, f(200)), {}); -}); diff --git a/tools/hinge_token.py b/tools/hinge_token.py index e8f7ce5..b5b512d 100644 --- a/tools/hinge_token.py +++ b/tools/hinge_token.py @@ -9,7 +9,7 @@ import os KEEP = { - "authorization", "user_id", "user-agent", "accept-language", "x-app-identifier", "x-app-version", + "authorization", "user_id", "accept-language", "x-app-identifier", "x-app-version", "x-build-number", "x-device-id", "x-device-model", "x-device-model-code", "x-device-platform", "x-device-region", "x-install-id", "x-os-version", "x-session-id", } diff --git a/tsconfig.build.json b/tsconfig.build.json deleted file mode 100644 index 2ccdc5f..0000000 --- a/tsconfig.build.json +++ /dev/null @@ -1 +0,0 @@ -{ "extends": "./tsconfig.json", "compilerOptions": { "noEmit": false, "outDir": "dist", "rootDir": "src" }, "include": ["src"] } diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index 4f315e3..0000000 --- a/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2023", "module": "NodeNext", "moduleResolution": "NodeNext", - "strict": true, "noEmit": true, "skipLibCheck": true, - "allowImportingTsExtensions": true, "rewriteRelativeImportExtensions": true, - "erasableSyntaxOnly": true, "verbatimModuleSyntax": true, "types": ["node"] - }, - "include": ["src", "test"] -}