import { ReactNode } from 'react'; import { GrantClient } from '../grant-client'; import { GrantClientConfig } from '../types'; /** * Props for the GrantProvider component */ export interface GrantProviderProps { /** * Grant client configuration */ config: GrantClientConfig; /** * Pre-configured GrantClient instance (alternative to config) * If provided, config is ignored */ client?: GrantClient; /** * Child components */ children: ReactNode; } /** * Provider component that makes the Grant client available to child components * * @example * ```tsx * // Option 1: Pass config (cookie-based refresh) * localStorage.getItem('accessToken'), * onRefreshWithCredentials: async () => { * const res = await fetch('https://api.grant.com/api/auth/refresh', { method: 'POST', credentials: 'include' }); * if (!res.ok) return false; * const { data } = await res.json(); * if (data?.accessToken) { localStorage.setItem('accessToken', data.accessToken); return true; } * return false; * }, * onTokenRefresh: (tokens) => { localStorage.setItem('accessToken', tokens.accessToken); }, * onUnauthorized: () => { window.location.href = '/login'; }, * }} * > * * * * // Option 2: Pass pre-configured client * const grant = new GrantClient({ ... }); * * * * ``` */ export declare function GrantProvider({ config, client, children }: GrantProviderProps): import("react").JSX.Element; /** * Hook to access the Grant client from context * * @throws Error if used outside of GrantProvider * * @example * ```tsx * const grant = useGrantClient(); * const hasPermission = await grant.can('resource', 'action'); * ``` */ export declare function useGrantClient(): GrantClient; /** * Hook to optionally access the Grant client * Returns null if not in a GrantProvider context * * Use this when you want to gracefully handle missing provider */ export declare function useGrantClientOptional(): GrantClient | null; //# sourceMappingURL=context.d.ts.map