Add bool.secrets — call external APIs with a server-side secret - #11
Closed
HomemadeToast57 wants to merge 1 commit into
Closed
HomemadeToast57 wants to merge 1 commit into
HomemadeToast57 wants to merge 1 commit into
Conversation
bool.secrets.fetch(name, path, init) routes an external API call through the Bool gateway's secret plane (/_bool/v1/secret/<name>/*), which injects the real secret server-side and forwards to the destination the secret is bound to. The value never reaches the client — a static Bool can call a paid API (OpenAI, Stripe, …) without shipping the key. Mirrors the db/users planes: credentials included, viewer/eu-session identity headers replayed for the preview. - src/client.ts: BoolSecrets type + secrets on BoolClient + implementation. - src/client.test.ts: routing (cross-origin + same-origin), path normalization, name encoding, identity headers. - README + CHANGELOG; version 0.2.0-next.10 (additive, canary channel). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HA2XB7REb3M4PxrJmj8GPp
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.
What & why
Adds the client half of the gateway "escape hatch": a way for a Bool app to call an external API that needs a secret key without the key ever reaching the client.
fetch(name, path, init)routes the call to the gateway secret plane (/_bool/v1/secret/<name>/*), which resolves the named secret, injects the real value server-side, and forwards to the destination the secret is bound to. The value is never in the bundle.nameis the secret's name (configured in the app's Secrets dashboard);pathis the sub-path under the bound destination;initis a normalfetchinit. Returns the destination's rawResponse.Mirrors the existing db/users planes:
credentials: "include"so the same-origin live-gate cookie flows when deployed, and the viewer / eu-session identity headers are replayed for the cross-origin preview.Changes
src/client.ts:BoolSecretstype,secretsonBoolClient, and the implementation (uses the existing runtime-resolved gateway base, so it's same-origin when deployed and cross-origin in preview automatically).src/client.test.ts: routing (cross-origin + same-origin), leading-slash normalization, name URL-encoding, and identity-header replay.README.md+CHANGELOG.md; version bumped to0.2.0-next.10(additive → minor; on the canary channel).Testing
bun test(66 pass),bun run typecheck, andbun run buildall green.Notes
Publishing is tag-driven/manual (OIDC trusted publishing) per the README, so this PR only prepares the version + changelog — it does not publish. Pairs with the platform PR (
codehs/bool) that adds the/_bool/v1/secretplane, the encrypted store, and the Secrets dashboard.🤖 Generated with Claude Code
https://claude.ai/code/session_01HA2XB7REb3M4PxrJmj8GPp
Generated by Claude Code