Files
billing/lib/auth.ts
zeekay e375f00306 Add multi-org billing accounts + fix IAM auth
- Add BillingAccount/BillingAccountMember types with owner/admin/viewer roles
- Add account switcher dropdown + member management components
- Add 7 billing account API methods to Commerce client
- Add Team tab (12th) to billing workspace
- Fix IAM client ID: app-hanzo (was placeholder hanzo-app-client-id)
- Fix app name in auth config to match Casdoor registration
- Relabel payment sections (no processor-specific references)
2026-02-27 10:28:21 -08:00

25 lines
774 B
TypeScript

import type { IamAuthConfig } from './iam-auth'
import type { BillingOrgConfig } from './config'
function getBasePath(): string {
if (typeof window === 'undefined') return ''
// Detect basePath from current URL (handles GitHub Pages /billing/ prefix)
const path = window.location.pathname
// If path starts with /billing, we're on GitHub Pages
if (path.startsWith('/billing')) return '/billing'
return ''
}
export function makeAuthConf(org: BillingOrgConfig): IamAuthConfig {
const basePath = getBasePath()
return {
iamServerUrl: org.iamServerUrl,
clientId: org.iamClientId,
redirectUri: typeof window !== 'undefined'
? `${window.location.origin}${basePath}/auth/callback`
: '',
orgName: org.id,
appName: 'app-hanzo',
}
}