( tokens: OAuthTokens, profile: OAuthTokens['profile'], mode: OAuthInstallMode, )
| 68 | } |
| 69 | |
| 70 | function 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 | |
| 103 | export async function installOAuthTokens( |
| 104 | tokens: OAuthTokens, |
no test coverage detected