import type { AccountInfo, OIDCProvider, ProviderOptions } from "../types";
const issuer = new URL("https://accounts.google.com");

export function GoogleAuthProvider(options: ProviderOptions): OIDCProvider {
  return {
    ...options,
    issuer,
    protocol: "OIDC",
    id: "google",
    name: "Google",
    scope: "openid email profile",
    profileCallback: (profile): AccountInfo => {
      return {
        sub: profile.sub as string,
        name: profile.name as string,
        email: profile.email as string,
        picture: profile.picture as string,
      };
    },
  };
}
