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

Function buildSdkAccountInfo

src/cli/sdkAccountSession.ts:25–68  ·  view source on GitHub ↗
(params: {
  apiProvider: string
  session: SdkAccountSessionInput
})

Source from the content-addressed store, hash-verified

23>
24
25export function buildSdkAccountInfo(params: {
26 apiProvider: string
27 session: SdkAccountSessionInput
28}): SdkAccountInfo | undefined {
29 if (params.apiProvider !== 'firstParty') {
30 return undefined
31 }
32
33 const { session } = params
34 const accountInfo: SdkAccountInfo = {}
35
36 if (session.principalSource === 'managed_oauth') {
37 accountInfo.subscription =
38 session.subscription.subscriptionName ?? 'Noumena Managed'
39 } else {
40 accountInfo.tokenSource = session.rawAuthTokenSource ?? 'none'
41 }
42
43 if (session.hasUsableApiKey && session.rawApiKeySource) {
44 accountInfo.apiKeySource = session.rawApiKeySource
45 }
46
47 if (
48 session.principalSource === 'managed_oauth' &&
49 session.sessionState === 'expired'
50 ) {
51 accountInfo.authTokenExpired = true
52 }
53
54 const hasManagedAccountContext =
55 session.principalSource === 'managed_oauth' ||
56 session.principalSource === 'console_api_key'
57
58 if (hasManagedAccountContext) {
59 if (session.identity.organizationName) {
60 accountInfo.organization = session.identity.organizationName
61 }
62 if (session.identity.email) {
63 accountInfo.email = session.identity.email
64 }
65 }
66
67 return accountInfo
68}
69
70export function getCurrentSdkAccountInfo(): SdkAccountInfo | undefined {
71 return buildSdkAccountInfo({

Callers 2

getCurrentSdkAccountInfoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected