( callbackUrlCookieValue: string | undefined )
| 375 | (profile.given_name && profile.family_name |
| 376 | ? `${profile.given_name} ${profile.family_name}`.trim() |
| 377 | : profile.given_name || profile.family_name || 'LinkedIn User') |
| 378 | ); |
| 379 | } |
| 380 | |
| 381 | /** |
| 382 | * An OAuth/OIDC sign-in proves ownership of its email only when the provider |
| 383 | * asserts the `email_verified` claim in the raw profile. Apple delivers the |
| 384 | * claim as the string "true"; treat that as verified. Providers without the |
| 385 | * claim (GitHub, GitLab, Discord) never prove the email here. |
| 386 | */ |
| 387 | export function profileProvesEmailOwnership(profile: unknown): boolean { |
| 388 | const emailVerified = (profile as { email_verified?: unknown } | undefined)?.email_verified; |
| 389 | return emailVerified === true || emailVerified === 'true'; |
| 390 | } |
| 391 | |
| 392 | function createEmailAccountInfo( |
| 393 | account: Account, |
| 394 | user: NextUser | AdapterUser |
| 395 | ): CreateOrUpdateUserArgs | null { |
| 396 | if (account.provider !== 'email') return null; |
| 397 | assert(user.email, 'User email is required for email auth'); |
| 398 | |
| 399 | // Extract the actual domain from the email address |
| 400 | // This ensures admin detection works correctly for @kilocode.ai emails |
| 401 | const emailDomain = user.email.split('@')[1]; |
| 402 | const hosted_domain = emailDomain || hosted_domain_specials.email; |
no test coverage detected