(accessToken: string)
| 353 | } |
| 354 | |
| 355 | export async function fetchProfileInfo(accessToken: string): Promise<{ |
| 356 | subscriptionType: SubscriptionType | null |
| 357 | displayName?: string |
| 358 | rateLimitTier: RateLimitTier | null |
| 359 | hasExtraUsageEnabled: boolean | null |
| 360 | billingType: BillingType | null |
| 361 | accountCreatedAt?: string |
| 362 | subscriptionCreatedAt?: string |
| 363 | rawProfile?: OAuthProfileResponse |
| 364 | }> { |
| 365 | const profile = await getOauthProfileFromOauthToken(accessToken) |
| 366 | const orgType = profile?.organization?.organization_type |
| 367 | |
| 368 | // Reuse the logic from fetchSubscriptionType |
| 369 | let subscriptionType: SubscriptionType | null = null |
| 370 | switch (orgType) { |
| 371 | case 'claude_max': |
| 372 | subscriptionType = 'max' |
| 373 | break |
| 374 | case 'claude_pro': |
| 375 | subscriptionType = 'pro' |
| 376 | break |
| 377 | case 'claude_enterprise': |
| 378 | subscriptionType = 'enterprise' |
| 379 | break |
| 380 | case 'claude_team': |
| 381 | subscriptionType = 'team' |
| 382 | break |
| 383 | default: |
| 384 | // Return null for unknown organization types |
| 385 | subscriptionType = null |
| 386 | break |
| 387 | } |
| 388 | |
| 389 | const result: { |
| 390 | subscriptionType: SubscriptionType | null |
| 391 | displayName?: string |
| 392 | rateLimitTier: RateLimitTier | null |
| 393 | hasExtraUsageEnabled: boolean | null |
| 394 | billingType: BillingType | null |
| 395 | accountCreatedAt?: string |
| 396 | subscriptionCreatedAt?: string |
| 397 | } = { |
| 398 | subscriptionType, |
| 399 | rateLimitTier: profile?.organization?.rate_limit_tier ?? null, |
| 400 | hasExtraUsageEnabled: |
| 401 | profile?.organization?.has_extra_usage_enabled ?? null, |
| 402 | billingType: profile?.organization?.billing_type ?? null, |
| 403 | } |
| 404 | |
| 405 | if (profile?.account?.display_name) { |
| 406 | result.displayName = profile.account.display_name |
| 407 | } |
| 408 | |
| 409 | if (profile?.account?.created_at) { |
| 410 | result.accountCreatedAt = profile.account.created_at |
| 411 | } |
| 412 |
no test coverage detected