Skip to content

Normalized Profile

All providers return a consistent NormalizedProfile object.

Interface

typescript
interface NormalizedProfile {
  /** Authentication provider */
  provider: "google" | "facebook" | "telegram";

  /** Unique user ID from the provider */
  providerUserId: string;

  /** User's email (not available for Telegram) */
  email?: string;

  /** User's display name */
  name?: string;

  /** Profile picture URL */
  avatarUrl?: string;

  /** Original provider response */
  raw: unknown;
}

Provider Data

Google

FieldSource
providerUserIdID token sub claim
emailID token email claim
nameID token name claim
avatarUrlID token picture claim
rawFull ID token

Facebook

FieldSource
providerUserIdGraph API id
emailGraph API email
nameGraph API name
avatarUrlGraph API picture.data.url
rawFull Graph API response

Telegram

FieldSource
providerUserIdinitData user.id
emailNot available
namefirst_name + last_name
avatarUrlinitData user.photo_url
rawFull initData

Usage Example

typescript
createAuthRouter({
  async onLogin(profile) {
    // Create or update user
    const user = await db.users.upsert({
      where: {
        provider: profile.provider,
        providerUserId: profile.providerUserId,
      },
      create: {
        email: profile.email,
        name: profile.name,
        avatar: profile.avatarUrl,
      },
      update: {
        name: profile.name,
        avatar: profile.avatarUrl,
      },
    });

    return { token: createToken(user.id) };
  },
});

Released under the MIT License.