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

Function getManagedIdentityValidationError

src/cli/handlers/auth.ts:70–101  ·  view source on GitHub ↗
(
  tokens: OAuthTokens,
  profile: OAuthTokens['profile'],
  mode: OAuthInstallMode,
)

Source from the content-addressed store, hash-verified

68}
69
70function getManagedIdentityValidationError(
71 tokens: OAuthTokens,
72 profile: OAuthTokens['profile'],
73 mode: OAuthInstallMode,
74): string | null {
75 if (!usesManagedInstallMode(tokens, mode)) {
76 return null
77 }
78
79 const accountUuid = profile?.account?.uuid ?? tokens.tokenAccount?.uuid
80 const emailAddress =
81 profile?.account?.email ?? tokens.tokenAccount?.emailAddress
82 const organizationUuid =
83 profile?.organization?.uuid ?? tokens.tokenAccount?.organizationUuid
84
85 if (
86 !isPresentIdentityValue(accountUuid) ||
87 !isPresentIdentityValue(emailAddress) ||
88 !isPresentIdentityValue(organizationUuid)
89 ) {
90 return 'Managed OAuth login did not yield a usable Noumena account identity. The issuer returned incomplete account information, so remote sessions cannot be created.'
91 }
92
93 if (
94 accountUuid === STUB_ACCOUNT_UUID ||
95 organizationUuid === STUB_ORGANIZATION_UUID
96 ) {
97 return 'Managed OAuth login returned a stub Noumena identity. Remote sessions require a real account and organization binding.'
98 }
99
100 return null
101}
102
103export async function installOAuthTokens(
104 tokens: OAuthTokens,

Callers 1

installOAuthTokensFunction · 0.85

Calls 2

usesManagedInstallModeFunction · 0.85
isPresentIdentityValueFunction · 0.85

Tested by

no test coverage detected