///
import { AuthState } from "../AuthProvider";
interface UseAuthOptions {
/** Optional service name. Only required if multiple services are used */
serviceName?: string;
/** Initial data */
data?: R;
}
interface UseAuthCallback {
(authData: unknown): Promise;
}
interface UseAuthState extends Omit {
/** The data returned by the callback. Will be null until loaded */
data: R | null;
/** True once authed is true while the data is loading */
loading: boolean;
/** Force authentication and fetching the data */
fetchData(): Promise;
}
/**
* When this hook is called, if the user has already authenticated with the
* remote service then the callback is run immediately to populate the data.
*
* If the user has not yet authenticated then the callback will not be run. The
* authed flag will be false. The component can force the user to authenticate
* by calling fetchData()
*
* @param callback Async function that is given the authData once the user has
* authenticated and returns the data for the component
* @param options
* @param deps Dependencies for the callback function. The data will be
* refetched each time these change IF the user is authenticated
*/
export declare function useAuth(callback: UseAuthCallback, options?: UseAuthOptions, deps?: React.DependencyList): UseAuthState;
export {};