MCPcopy Create free account
hub / github.com/Noumena-Network/code / fetchProfileInfo

Function fetchProfileInfo

src/services/oauth/client.ts:491–556  ·  view source on GitHub ↗
(accessToken: string, timeout = 10000)

Source from the content-addressed store, hash-verified

489}
490
491export async function fetchProfileInfo(accessToken: string, timeout = 10000): Promise<{
492 subscriptionType: SubscriptionType | null
493 displayName?: string
494 rateLimitTier: RateLimitTier | null
495 hasExtraUsageEnabled: boolean | null
496 billingType: BillingType | null
497 accountCreatedAt?: string
498 subscriptionCreatedAt?: string
499 rawProfile?: OAuthProfileResponse
500}> {
501 const profile = await getOauthProfileFromOauthToken(accessToken, timeout)
502 const orgType = profile?.organization?.organization_type
503
504 // Reuse the logic from fetchSubscriptionType
505 let subscriptionType: SubscriptionType | null = null
506 switch (orgType) {
507 case 'claude_max':
508 subscriptionType = 'max'
509 break
510 case 'claude_pro':
511 subscriptionType = 'pro'
512 break
513 case 'claude_enterprise':
514 subscriptionType = 'enterprise'
515 break
516 case 'claude_team':
517 subscriptionType = 'team'
518 break
519 default:
520 // Return null for unknown organization types
521 subscriptionType = null
522 break
523 }
524
525 const result: {
526 subscriptionType: SubscriptionType | null
527 displayName?: string
528 rateLimitTier: RateLimitTier | null
529 hasExtraUsageEnabled: boolean | null
530 billingType: BillingType | null
531 accountCreatedAt?: string
532 subscriptionCreatedAt?: string
533 } = {
534 subscriptionType,
535 rateLimitTier: profile?.organization?.rate_limit_tier ?? null,
536 hasExtraUsageEnabled:
537 profile?.organization?.has_extra_usage_enabled ?? null,
538 billingType: profile?.organization?.billing_type ?? null,
539 }
540
541 if (profile?.account?.display_name) {
542 result.displayName = profile.account.display_name
543 }
544
545 if (profile?.account?.created_at) {
546 result.accountCreatedAt = profile.account.created_at
547 }
548

Callers 1

refreshOAuthTokenFunction · 0.85

Calls 2

logEventFunction · 0.50

Tested by

no test coverage detected