// Body shape for tessera's social sign-in wrapper at POST /api/sign-in/social. // Factored out of sign-in.tsx so the `oauth_query` forwarding logic can be // unit-tested without DOM. // // `oauth_query` is the signed query string from /authorize (sig + exp // included). The wrapper attaches it to Better Auth's `additionalData` so // oauth-provider's before-hook captures it into oAuthState and the user // resumes the signed RP flow after the IdP round-trip. export type SocialProvider = "github" | "google"; export interface SocialSignInRequest { provider: SocialProvider; callbackURL: string; errorCallbackURL: string; turnstileToken: string; oauth_query?: string; } export const buildSocialSignInRequest = (input: { provider: SocialProvider; callbackURL: string; errorCallbackURL: string; turnstileToken: string; oauthQuery: string | null; }): SocialSignInRequest => { const body: SocialSignInRequest = { provider: input.provider, callbackURL: input.callbackURL, errorCallbackURL: input.errorCallbackURL, turnstileToken: input.turnstileToken, }; if (input.oauthQuery) { body.oauth_query = input.oauthQuery; } return body; };