import { type UseQueryResult } from '@tanstack/react-query';
import { RequestError } from '@darajs/ui-utils';
import { type User, type UserData } from '../types';
export declare enum AuthenticationErrorReason {
    BAD_REQUEST = "bad_request",
    EXPIRED_TOKEN = "expired",
    INVALID_CREDENTIALS = "invalid_credentials",
    INVALID_TOKEN = "invalid_token",
    OTHER = "other",
    UNAUTHORIZED = "unauthorized"
}
export type AuthenticationFailureRedirect = 'login' | 'error';
export interface HandleAuthErrorsOptions {
    /**
     * Where to route authentication failures such as expired or invalid tokens.
     * Authorization, bad request, and provider failures always route to the error page.
     */
    authenticationFailureRedirect?: AuthenticationFailureRedirect;
    ignoreErrors?: Array<AuthenticationErrorReason>;
}
export type VerifySessionTokenResult = 'handled_auth_error' | 'login_required' | 'verified';
interface RedirectResponse {
    redirect_uri: string;
}
interface SuccessResponse {
    success: boolean;
}
/**
 * Revoke the current session
 */
export declare function revokeSession(): Promise<RedirectResponse | SuccessResponse | null>;
/**
 * Resolve the referrer url to be passed back to login, adjusted for the base path.
 */
export declare function resolveReferrer(): string;
/**
 * Helper function to handle auth errors in a response
 *
 * @param res the response object to check
 * @param options auth error handling options
 */
export declare function handleAuthErrors(res: Response, options?: HandleAuthErrorsOptions): Promise<boolean>;
/**
 * Api call to get user data from the backend
 */
export declare function useUser(): UseQueryResult<UserData, RequestError>;
/** Api call to create a session with the backend */
export declare function requestSessionToken(body?: User): Promise<boolean>;
/** Api call to create a session with the backend */
export declare function useSession(body?: User): UseQueryResult<boolean, RequestError>;
/** Api call to verify the session token from the backend */
export declare function verifySessionToken(): Promise<VerifySessionTokenResult>;
export {};
//# sourceMappingURL=auth.d.ts.map