import { User } from "../user.js";
import { AuthError, Result } from "./utils.js";

//#region src/auth/methods/social.d.ts

/**
 * Signs a visitor in with a Google token the browser obtained, creating their
 * account the first time.
 *
 * Pass the id token Google Identity Services handed the page. An access token
 * is rejected, and so is a token minted for another app. `fullName` names a
 * first-time visitor and does nothing for one who already has an account.
 *
 * A `signedIn` result means the visitor is signed in. An app that also asks for
 * an authenticator app answers `authenticatorRequired` instead, naming the step
 * to send them to next.
 */
declare function signInWithGoogle(credentials: {
  email: string;
  token: string;
  fullName?: string;
}): Promise<Result<{
  status: "signedIn";
  user: User;
} | {
  status: "authenticatorRequired";
  /**
   * `verify`: they have an authenticator app and owe a code.
   * `setup`: the app requires one and they have none yet.
   * `setupOptional`: same, except they may skip it instead.
   */
  step: "verify" | "setup" | "setupOptional";
}, AuthError>>;
//#endregion
export { signInWithGoogle };