/**
 * API adapter types for the SSO auth SDK.
 * Consumers implement AuthApiAdapter to connect the SDK to their central auth service.
 */
import type { AuthenticateWithProviderParams, CompleteProfileParams, SendOtpResponse, SSOSession, UserType, VerifyOtpResponse } from './auth-types';
import type { LinkOrMergeOtpTarget } from './flow';
/** Parameters for sending OTP to phone or email. */
export interface SendOtpParams {
    type: 'phone' | 'email';
    value: string;
}
/** Parameters for verifying OTP. */
export interface VerifyOtpParams {
    type: 'phone' | 'email';
    value: string;
    otp: string;
}
/** Optional lookup to branch flows before sending OTP (e.g. foreign existing user). */
export interface CheckIdentifierParams {
    type: 'phone' | 'email';
    value: string;
}
/** Optional lookup response used by the provider to choose the next step. */
export interface CheckIdentifierResponse {
    exists: boolean;
    userType?: UserType;
}
interface LinkOrMergeBaseParams {
    isLinking: boolean;
    name: string;
}
export type LinkOrMergeAccountParams = (LinkOrMergeBaseParams & {
    conflictField: 'email';
    oldEmail: string;
    newEmail: string;
}) | (LinkOrMergeBaseParams & {
    conflictField: 'phone';
    oldCountryCode: string;
    oldPhone: string;
    newCountryCode: string;
    newPhone: string;
});
export type LinkOrMergeAccountResponse = SSOSession | {
    otpTarget: LinkOrMergeOtpTarget;
} | void;
export interface VerifyLinkOrMergeOtpParams extends LinkOrMergeOtpTarget {
    otp: string;
    conflictField: 'email' | 'phone';
}
/**
 * Adapter implemented by the consumer to talk to the central auth service.
 * All methods return promises; the SDK handles loading/error state.
 */
export interface AuthApiAdapter {
    /** Send OTP to the given phone or email. */
    sendOtp(params: SendOtpParams): Promise<SendOtpResponse>;
    /**
     * Verify OTP. Returns session if existing user, or isNewUser flag for profile completion.
     * May return conflict error when identifier is linked to another account.
     */
    verifyOtp(params: VerifyOtpParams): Promise<VerifyOtpResponse>;
    /** Complete profile for new users; returns SSO session. */
    completeProfile(params: CompleteProfileParams): Promise<SSOSession>;
    /** Authenticate with a third-party provider (Google/Apple) credential. */
    authenticateWithProvider(params: AuthenticateWithProviderParams): Promise<VerifyOtpResponse>;
    /** Validate an existing SSO session token; called on SDK mount. Returns null if invalid/expired. */
    validateSession(token: string): Promise<SSOSession | null>;
    /**
     * Optional: validate session using server-read cookie (no token from client).
     * Required when using serverCookieTokenStorage. Client sends credentials;
     * server reads cookie from the request and returns session or null.
     */
    validateSessionFromCookie?(): Promise<SSOSession | null>;
    /** Optional: refresh an expired SSO session using refresh token. */
    refreshSession?(refreshToken: string): Promise<SSOSession | null>;
    /** Optional: check identifier existence before OTP routing decisions. */
    checkIdentifier?(params: CheckIdentifierParams): Promise<CheckIdentifierResponse>;
    /**
     * Optional: link or merge an account after profile completion reports a
     * duplicate new email/mobile. Implementations should only send the fields
     * for `params.conflictField`.
     */
    linkOrMergeAccount?(params: LinkOrMergeAccountParams): Promise<LinkOrMergeAccountResponse>;
    /**
     * Optional: verify the OTP sent by linkOrMergeAccount. Called after the
     * user enters the OTP received on the existing/old email or mobile.
     */
    verifyLinkOrMergeOtp?(params: VerifyLinkOrMergeOtpParams): Promise<SSOSession>;
    /** Optional: clear server-side cookie/session on sign out. */
    logout?(): Promise<void>;
}
export {};
