Files
orca/cloud/apps/billing/src/env.ts
T
Neil ff64af20b0 fix(cloud-setup): the composer follows its setup session; billing reaches the control plane for GitHub
- The composer read the setup session with a bare readCloudSetupSession() call in render. The React
  Compiler memoizes that on the session id, so the panel kept its first (empty) read: rows never
  moved past 'In browser', the finished session never auto-started the workspace, and the GitHub
  row stayed 'Needed' after the browser said 'You're all set'. Read it through
  useCloudSetupSession (useSyncExternalStore with a per-poll cached snapshot) instead.
- Billing asked the control plane for the GitHub install URL with a plain fetch to its workers.dev
  origin. Same-account Workers can't do that (Cloudflare error 1042), so every setup GitHub step
  showed 'Orca Cloud setup is unavailable'. Bind the control plane as a service (SANDBOX_CONTROL)
  in the dev config and send the request through it when bound.

Found by the NP-4 end-to-end run (np4-e2e) on m4air against staging.
2026-11-10 14:32:37 -08:00

74 lines
3.9 KiB
TypeScript

// Billing Worker bindings. Secrets are set with `wrangler secret put` (stdin), never in
// wrangler.jsonc or git. Deployed environments live in the private deploy config.
export type Env = {
BILLING_DB: D1Database
// Stripe. Use a RESTRICTED key (rk_test_...) scoped to: Customers write, Checkout Sessions
// write, Customer portal write, Subscriptions read, Billing meter events write. Nothing else.
STRIPE_SECRET_KEY: string
// Webhook endpoint signing secret(s), comma-separated during rotation (whsec_...).
STRIPE_WEBHOOK_SECRET: string
// Pinned so a dashboard default-version bump cannot change payload shapes under us.
STRIPE_API_VERSION?: string
// Must be exactly 'true' to accept live-mode keys or events. Unset everywhere until launch.
STRIPE_ALLOW_LIVEMODE?: string
// Overrides the Stripe API origin (tests and stripe-mock only).
STRIPE_API_BASE?: string
// Team seat prices (price_...), quantity = seats.
STRIPE_PRICE_TEAM_MONTHLY: string
STRIPE_PRICE_TEAM_ANNUAL: string
// Monthly metered price on the sandbox-seconds meter, added to a subscription when an admin
// opts in to overage (see overage.ts, usage.ts).
STRIPE_PRICE_OVERAGE: string
// Billing meter event_name the overage price aggregates.
STRIPE_METER_EVENT_NAME: string
// Customer portal configuration (bpc_...) allowing seat changes, monthly<->annual and cancel.
STRIPE_PORTAL_CONFIGURATION?: string
// 'true' turns on Stripe Tax in Checkout (automatic_tax + tax id collection). Requires Stripe Tax
// to be activated with an origin address and registrations in the dashboard. Default off.
STRIPE_AUTOMATIC_TAX?: string
// Optional JSON overriding any field of the default plan catalog (src/plans.ts), e.g.
// {"pro":{"priceLabel":"$20/mo","includedHoursPerSeat":40}}. Malformed JSON fails closed (503).
BILLING_PLANS?: string
// Where Checkout and the portal send the browser back (a page that deep-links into Orca).
BILLING_RETURN_URL: string
// Desktop tokens: short-lived ES256 JWTs minted by Orca Cloud auth with aud=BILLING_JWT_AUDIENCE.
// BILLING_JWKS (inline set) is for local dev and tests only.
BILLING_JWKS_URL?: string
BILLING_JWKS?: string
BILLING_AUTH_ISSUER?: string
BILLING_JWT_AUDIENCE: string
// 'dev' | 'prod'. Dev may also accept BILLING_DEV_JWKS (issuer 'orca-billing-dev-test', a secret
// operator key set for e2e runs before auth mints billing tokens); prod never does.
BILLING_ENV?: string
BILLING_DEV_JWKS?: string
// Dev only: also trust Orca Cloud auth STAGING (its JWKS URL + issuer) so team/billing flows can be
// exercised against a non-production auth. Both must be set; ignored when BILLING_ENV is 'prod'.
BILLING_STAGING_JWKS_URL?: string
BILLING_STAGING_AUTH_ISSUER?: string
// Sandbox control plane -> billing (usage reports, start checks). Secret; >= 32 chars.
// Comma-separated during rotation. Replace with a service binding once the control plane is a Worker.
CONTROL_PLANE_TOKEN: string
// Shared secret between Orca Cloud auth and billing for membership: auth pushes member counts to
// POST /v1/internal/seats, billing pulls them from AUTH_INTERNAL_URL. >= 32 chars; comma-separated
// during rotation (billing sends the first).
MEMBERSHIP_SYNC_TOKEN?: string
// Auth origin serving POST /v1/internal/billing/org-members. Unset: seats come from pushes and the
// Checkout request only (local dev).
AUTH_INTERNAL_URL?: string
// Cloud setup sessions (cloud-setup.ts). Origin of the setup pages on Orca Cloud auth
// (https://auth.onorca.dev, staging https://auth-staging.onorca.dev); Checkout returns there.
CLOUD_SETUP_PAGES_URL?: string
// Control plane origin billing asks for a repository's GitHub install URL (CONTROL_PLANE_TOKEN).
SANDBOX_CONTROL_URL?: string
// Service binding to that control plane. Same-account Workers can't fetch each other over
// workers.dev (Cloudflare error 1042), so when bound the request goes through it instead.
SANDBOX_CONTROL?: Fetcher
}