Files
orca/cloud/apps/billing/src/cloud-setup-urls.ts
T
Neil c14d5856f2 feat(billing): cloud setup sessions (N1) and team-first Checkout (N4/O1)
Setup session API on the billing Worker: the desktop creates a session after
sign-in and polls its steps (account, team, plan/trial, github); the setup pages
on Orca Cloud auth redeem a one-time browser ticket, bind the team (granting the
trial through a port np4-trial's module plugs into), open Checkout that returns
to the setup pages, and ask the control plane for the GitHub install URL. The
control plane flips the GitHub step via POST /v1/internal/cloud-setup/github.

Checkout now refuses personal accounts with 409 team_required: a user: plan
could never move to a team later.
2026-11-10 06:07:27 -08:00

23 lines
927 B
TypeScript

// URLs of the cloud setup pages on Orca Cloud auth (auth.onorca.dev/cloud/setup/...).
import type { Env } from './env'
function pagesOrigin(env: Env): string {
return (env.CLOUD_SETUP_PAGES_URL ?? 'https://auth.onorca.dev').replace(/\/$/, '')
}
export function setupPageUrl(env: Env, path: string, params: Record<string, string>): string {
const url = new URL(`${pagesOrigin(env)}/cloud/setup${path}`)
for (const [key, value] of Object.entries(params)) {
url.searchParams.set(key, value)
}
return url.toString()
}
/** Checkout return URLs for a setup session: success continues the chain, cancel goes back to T3. */
export function setupCheckoutReturnUrls(env: Env, id: string): { success: string; cancel: string } {
return {
success: setupPageUrl(env, '/next', { session: id, from: 'checkout', checkout: 'success' }),
cancel: setupPageUrl(env, '/plan', { session: id, checkout: 'canceled' })
}
}