import { default as React } from 'react'; import { UseCSRFTokenResult } from '../types'; /** * Options for the useCSRFToken hook */ export interface UseCSRFTokenOptions { /** Auto-refresh token at this interval (ms) */ refreshInterval?: number; /** Whether to auto-initialize CSRF protection */ autoInitialize?: boolean; } /** * Hook for CSRF token management * * Provides CSRF token values, headers for fetch requests, * and form input props for traditional form submissions. * * @param options - Hook options * @returns CSRF token operations and values * * @example * ```tsx * function SecureForm() { * const { token, formInputProps, headers, regenerate } = useCSRFToken(); * * const handleSubmit = async (e: FormEvent) => { * e.preventDefault(); * const formData = new FormData(e.currentTarget); * * await fetch('/api/submit', { * method: 'POST', * headers, * body: formData, * }); * }; * * return ( *
* ); * } * ``` */ export declare function useCSRFToken(options?: UseCSRFTokenOptions): UseCSRFTokenResult; /** * Hook for creating secure fetch with automatic CSRF token injection * * Note: This hook intentionally returns a raw fetch wrapper because: * 1. This IS the CSRF security layer that wraps fetch with token injection * 2. Users may need drop-in fetch replacement for existing code * 3. The apiClient already has CSRF protection built-in * * For new API calls, prefer using apiClient which has CSRF built-in. * @see {@link @/lib/api/api-client} for the recommended API client * * @example * ```tsx * function DataFetcher() { * const secureFetch = useSecureFetch(); * * const submitData = async (data: object) => { * const response = await secureFetch('/api/data', { * method: 'POST', * body: JSON.stringify(data), * headers: { * 'Content-Type': 'application/json', * }, * }); * * return response.json(); * }; * * // ... * } * ``` */ export declare function useSecureFetch(): typeof fetch; /** * Hook for creating a secure form submission handler * * @example * ```tsx * function ContactForm() { * const { handleSubmit, isSubmitting, error } = useSecureFormSubmit({ * action: '/api/contact', * onSuccess: () => console.log('Submitted!'), * }); * * return ( * * ); * } * ``` */ export declare function useSecureFormSubmit(options: { action: string; method?: 'POST' | 'PUT' | 'PATCH' | 'DELETE'; onSuccess?: (response: Response) => void; onError?: (error: Error) => void; }): { handleSubmit: (event: React.FormEvent