(
session: Pick<
ResolvedAuthSession,
'principalKind' | 'providerAuthKind' | 'subscription'
>,
roles: {
organizationRole: string | null | undefined
workspaceRole: string | null | undefined
},
)
| 4 | import { isEnvTruthy } from './envUtils.js' |
| 5 | |
| 6 | export function hasConsoleBillingAccessForSession( |
| 7 | session: Pick< |
| 8 | ResolvedAuthSession, |
| 9 | 'principalKind' | 'providerAuthKind' | 'subscription' |
| 10 | >, |
| 11 | roles: { |
| 12 | organizationRole: string | null | undefined |
| 13 | workspaceRole: string | null | undefined |
| 14 | }, |
| 15 | ): boolean { |
| 16 | if (session.providerAuthKind !== 'noumena_first_party') { |
| 17 | return false |
| 18 | } |
| 19 | |
| 20 | if (session.principalKind === 'none' || session.principalKind === 'third_party_provider') { |
| 21 | return false |
| 22 | } |
| 23 | |
| 24 | if (session.subscription.subscriptionType !== null) { |
| 25 | return false |
| 26 | } |
| 27 | |
| 28 | if (!roles.organizationRole && !roles.workspaceRole) { |
| 29 | return false |
| 30 | } |
| 31 | |
| 32 | return ( |
| 33 | ['admin', 'billing'].includes(roles.organizationRole) || |
| 34 | ['workspace_admin', 'workspace_billing'].includes(roles.workspaceRole) |
| 35 | ) |
| 36 | } |
| 37 | |
| 38 | export function hasManagedPlanBillingAccessForSession( |
| 39 | session: Pick<ResolvedAuthSession, 'principalSource' | 'sessionState' | 'subscription'>, |
no outgoing calls
no test coverage detected