/**
 * OAuth types for SmartAuth — Google, Microsoft, Apple id_token verification.
 */

import { z } from 'zod';

export const OAuthGoogleSchema = z.object({
  idToken: z.string().min(1),
  productId: z.string().min(1),
});

export const OAuthMicrosoftSchema = z.object({
  idToken: z.string().min(1),
  productId: z.string().min(1),
});

export const OAuthAppleSchema = z.object({
  idToken: z.string().min(1),
  productId: z.string().min(1),
  /** Apple only sends user name on first sign-in — client must forward it */
  displayName: z.string().optional(),
});

export type OAuthGoogleInput = z.infer<typeof OAuthGoogleSchema>;
export type OAuthMicrosoftInput = z.infer<typeof OAuthMicrosoftSchema>;
export type OAuthAppleInput = z.infer<typeof OAuthAppleSchema>;

export interface OAuthVerifiedIdentity {
  provider: 'google' | 'microsoft' | 'apple';
  providerUserId: string;
  email: string;
  emailVerified: boolean;
  displayName?: string;
}
