export interface AuthCallbackState {
/** Whether this is a callback page (has code or error in URL) */
isCallback: boolean;
/** Whether callback processing is in progress */
isProcessing: boolean;
/** Whether authentication completed successfully */
isSuccess: boolean;
/** Error that occurred during authentication */
error: Error | null;
/** URL to return to after authentication */
returnUrl: string | null;
/** Authorization code from IdP (if available) */
code: string | null;
/** Error code from IdP (if auth was denied) */
idpError: string | null;
/** Error description from IdP */
idpErrorDescription: string | null;
}
export interface UseAuthCallbackOptions {
/**
* Whether to automatically process the callback.
* Set to false for manual control.
* @default true
*/
autoProcess?: boolean;
/**
* Called when authentication succeeds.
* Typically used to navigate to returnUrl.
*/
onSuccess?: (returnUrl: string | null) => void;
/**
* Called when authentication fails.
*/
onError?: (error: Error) => void;
/**
* Override the redirect URI (useful when config isn't loaded yet).
*/
redirectUri?: string;
/**
* URL to redirect to if PKCE verifier is missing (e.g., page refresh).
* Typically the login page.
*/
onMissingVerifierRedirectTo?: string;
}
/**
* Hook for handling OAuth callback pages in hybrid mode.
*
* Automatically detects if the current page is an OAuth callback and processes it.
*
* @example
* ```tsx
* function OAuthCallback() {
* const { isProcessing, isSuccess, error, returnUrl } = useAuthCallback({
* onSuccess: (url) => navigate(url || '/'),
* onError: (err) => console.error(err),
* });
*
* if (isProcessing) return ;
* if (error) return ;
* return null;
* }
* ```
*/
export declare function useAuthCallback(options?: UseAuthCallbackOptions): AuthCallbackState & {
/** Manually trigger callback processing */
processCallback: () => Promise;
};
/**
* Parse OAuth callback data from URL without using IAMService.
* Useful for manual token exchange flows.
*/
export declare function parseCallbackUrl(): {
code: string | null;
state: string | null;
verifier: string | null;
returnUrl: string | null;
error: string | null;
errorDescription: string | null;
};
//# sourceMappingURL=useAuthCallback.d.ts.map