payments-stripe: retrofit into offchain pipeline conventions#37
Merged
mike-hanono merged 3 commits intoMay 25, 2026
Merged
Conversation
PR #32 introduced payments-stripe at the legacy `tools/` path with per-tool deploy workflows. Main has since restructured (#33) so all tools live under `offchain/tools/` and share a single CI matrix. This branch realigns payments-stripe so the new pipeline picks it up. Layout move: tools/payments-stripe/ → offchain/tools/payments-stripe/ Added (per .pre-commit/14-check-tool-conventions): - tools.json (tool_name, command, environment) - build.rs (byte-identical to other tools; threads TOOL_FQN_VERSION via cargo:rustc-env) - Cargo.toml [[bin]] + [build-dependencies] sections Removed (legacy per-tool deploy artifacts; the shared offchain-tools.{discover,deploy,prepare,register}.yml matrix replaces them): - tools/payments-stripe/deploy/{Dockerfile,cloud-run.*,register.sh} - tools/payments-stripe/paths.json (paths now come from each tool's --meta output) - .github/workflows/deploy-payments-stripe-{mainnet,testnet}.yml Source modifications: - 6 fqn!() macros across src/tools/*.rs threaded to fqn!(concat!("...@", env!("TOOL_FQN_VERSION"))) so the on-chain FQN version stays in sync with the content-hashed image tag produced by CI.
kouks
approved these changes
May 25, 2026
davidrotari19
approved these changes
May 25, 2026
Stacks on #37 (which already moved the crate to offchain/tools/ and added tools.json + build.rs). This PR is the security fix #37 deliberately left out: every endpoint's Input struct had `pub api_key: String`, which flowed through the Nexus DAG to Sui as plaintext on every invocation. Adopts the env-var credential pattern from offchain/tools/memory-memwal: - stripe_client.rs: `from_env()` reads STRIPE_API_KEY once at startup, wraps in `zeroize::Zeroizing<String>` (heap-zeroed on drop), validates the prefix (`sk_test_` / `sk_live_` / `rk_test_` / `rk_live_`). Hand- written `Debug` prints `<redacted>` — never `#[derive(Debug)]` on the credential-bearing type. Shared HTTP client lives in a `OnceLock` so the connection pool survives across `invoke` calls. `#[cfg(test)] for_testing(base_url, bearer)` constructor bypasses env validation for mockito tests. - main.rs: explicit multi-thread tokio runtime; `env_logger` init before anything else; `--meta` short-circuit so CI's prepare step can pull /meta from an image with no env; `load_dotenv_if_present()` and `validate_credentials_at_startup()` before `bootstrap!`. `main` is the only `process::exit` site. Exit 1 if STRIPE_API_KEY is unset, empty, or has an unrecognized prefix. - All six endpoint files: dropped `pub api_key: String` from Input. Dropped `.with_auth(&input.api_key)` from invoke(). NexusTool::new() calls `StripeClient::from_env().unwrap_or_else(|e| { log::error!(...); panic!(...) })` — startup-only panic, mirrors memwal. `idempotency_key` stays on Input (per-call dedup data, not a credential — explicit whitelist in the auditor). - Tests: every `StripeClient::new(Some(&server.url()))` → `StripeClient::for_testing(&server.url(), "sk_test_FAKE")`. Every `api_key:` field dropped from `test_input()` and from inline Input literals. `get-balance` Input is now empty (`{}`) — only the STRIPE_API_KEY env var matters; the `_input` arg in invoke is unused. - Cargo.toml: added workspace deps `anyhow`, `dotenvy`, `env_logger`, `log`, `zeroize` for the env-var path. - README.md: rewrote the credential section to document the env var. Dropped `api_key` from every per-FQN Input table. Added an env-vars table. Threaded `<TOOL_FQN_VERSION>` into each FQN heading (matching the actual `concat!(..., env!("TOOL_FQN_VERSION"))` in source). - .env.example: documents STRIPE_API_KEY for local dev. In production Cloud Run mounts it via `secretKeyRef` from GCP Secret Manager, configured by the operator out-of-band — the deploy pipeline does NOT provision the upstream API key. tools.json's `environment` block is RUST_LOG only (C10). - Regenerated AUDIT.md is deferred — run the auditor agent against the merged tree, or invoke it after this branch lands. Markdown linter fix: aligned 4 skill reference files' compact table separators (`|---|` → `| --- |`) to satisfy MD060. These same files are rewritten by PR #31; the conflict at merge is a no-op since both branches use `| --- |`. Touched only to unblock `just pre-commit::md-lint` on this branch. Verified locally: - bash <audit.sh from #31's tip> off-chain payments-stripe → PASS static:input-credential → PASS static:debug-on-credentials → PASS static:stateful → PASS tools-json:shape / secret-in-env → PASS conform:output-enum / description / fqn-versioned (cargo:check fails — sandbox is missing pkg-config/libssl-dev for openssl-sys; orthogonal to this change. PR #37 author noted the same in their PR description; verification happens via CI on push.) - npx markdownlint-cli2 '**/*.md' '!.git/' → 0 errors across 26 files. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
6 tasks
…ial-env payments-stripe: read STRIPE_API_KEY from env, drop api_key from Input
mike-hanono
approved these changes
May 25, 2026
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacks on top of #32 (Mike Hanono's payments-stripe addition). #32 landed at the pre-#33 layout (
tools/path, per-tool deploy workflows, rootCargo.lock); this PR realigns the tool to the offchain pipeline conventions introduced in #33 so the shared CI matrix picks it up automatically. Mike's tool code is unchanged in intent — this is purely a layout/convention conversion.This PR targets
add-payments-stripe-toolso its diff against #32's content is just the restructure — nomain-restructure noise.What changed
tools/payments-stripe/offchain/tools/payments-stripe/tools/payments-stripe/paths.json(hand-maintained)--metaoutput frombootstrap!()(auto)tools.json+build.rs(byte-identical to math's)Cargo.toml[[bin]]/[build-dependencies]fqn!()macrosfqn!("...@1")fqn!(concat!("...@", env!("TOOL_FQN_VERSION")))deploy-payments-stripe-{mainnet,testnet}.ymloffchain-tools.{discover,deploy,prepare,register}.ymlmatrixtools/payments-stripe/deploy/{Dockerfile,cloud-run.*,register.sh}offchain/Dockerfileis used by the matrixDiff is intentionally minimal
23 files changed, 89 insertions, 373 deletions — almost entirely path renames (R), removals (D) of legacy deploy artifacts, the new build.rs / tools.json, and the 6 FQN-threading edits in
src/tools/*.rs. Nomain-restructure noise because this PR targetsadd-payments-stripe-tooldirectly.Test plan
xyz.taluslabs.payments.stripe.<endpoint>@<version>form preserved)offchain/tools/and the shared CI matrix in place; CI build on this PR completestestnet-*tag frommainpost-merge to fire the full chain pipeline against testnetNote on local verification
Because this PR predates main's restructure in its base,
cargo check/ convention pre-commit hook can't run cleanly in isolation (offchain/workspace doesn't exist on this branch's base yet). Verified in a side-worktree where the base was rebased onto main:cargo check -p payments-stripe✓.pre-commit/14-check-tool-conventions✓Tool conventions OK🤖 Generated with Claude Code