import { SecurityContextValue, SecurityViolation, SecurityConfiguration } from '../types';
/**
* Hook for accessing the security context
*
* Provides access to security state, CSP nonces, CSRF tokens,
* violation reporting, and security configuration.
*
* @returns Security context value
* @throws Error if used outside SecurityProvider
*
* @example
* ```tsx
* function SecureComponent() {
* const {
* cspNonce,
* csrfToken,
* isInitialized,
* violations,
* reportViolation,
* } = useSecurityContext();
*
* if (!isInitialized) {
* return ;
* }
*
* return (
*
*
Security violations: {violations.length}
*
*
* );
* }
* ```
*/
export declare function useSecurityContext(): SecurityContextValue;
/**
* Hook for security state only (no actions)
*
* Useful when you only need to read security state.
*
* @example
* ```tsx
* function SecurityStatus() {
* const { isInitialized, violations } = useSecurityState();
*
* return (
*
* Status: {isInitialized ? 'Ready' : 'Initializing'}
* Violations: {violations.length}
*
* );
* }
* ```
*/
export declare function useSecurityState(): {
cspNonce: string;
csrfToken: string;
isInitialized: boolean;
secureStorageAvailable: boolean;
violations: readonly SecurityViolation[];
lastEventAt: number;
};
/**
* Hook for security actions only
*
* Useful when you only need security actions without state.
*
* @example
* ```tsx
* function SecurityControls() {
* const {
* regenerateNonce,
* regenerateCsrfToken,
* clearViolations,
* } = useSecurityActions();
*
* return (
*
* Regenerate Nonce
* regenerateCsrfToken()}>
* Regenerate CSRF Token
*
* Clear Violations
*
* );
* }
* ```
*/
export declare function useSecurityActions(): {
regenerateNonce: () => string;
regenerateCsrfToken: () => Promise;
reportViolation: (violation: Omit) => void;
clearViolations: () => void;
updateConfig: (partial: Partial) => void;
};
/**
* Hook for security configuration
*
* @example
* ```tsx
* function SecuritySettings() {
* const config = useSecurityConfig();
*
* return (
* {JSON.stringify(config, null, 2)}
* );
* }
* ```
*/
export declare function useSecurityConfig(): SecurityConfiguration;
/**
* Hook for violation reporting
*
* @example
* ```tsx
* function SecureInput() {
* const reportViolation = useViolationReporter();
*
* const handleSuspiciousInput = (input: string) => {
* reportViolation({
* type: 'xss',
* details: `Suspicious input detected: ${input.slice(0, 50)}`,
* severity: 'medium',
* blocked: true,
* });
* };
*
* // ...
* }
* ```
*/
export declare function useViolationReporter(): (violation: Omit) => void;
/**
* Hook for monitoring violations
*
* @example
* ```tsx
* function ViolationMonitor() {
* const { violations, hasViolations, criticalCount } = useViolations();
*
* useEffect(() => {
* if (criticalCount > 0) {
* notifySecurityTeam(violations);
* }
* }, [criticalCount, violations]);
*
* return (
*
* {hasViolations && (
*
* {violations.length} security violations detected
*
* )}
*
* );
* }
* ```
*/
export declare function useViolations(): {
violations: readonly SecurityViolation[];
hasViolations: boolean;
criticalCount: number;
highCount: number;
clearViolations: () => void;
};
/**
* Hook for security initialization status
*
* @example
* ```tsx
* function App() {
* const { isReady, isSecureStorageAvailable } = useSecurityStatus();
*
* if (!isReady) {
* return ;
* }
*
* return ;
* }
* ```
*/
export declare function useSecurityStatus(): {
isReady: boolean;
isSecureStorageAvailable: boolean;
};
/**
* Hook that waits for security initialization
*
* Returns null until security is initialized, then returns the context.
* Useful for conditional rendering.
*
* @example
* ```tsx
* function SecureFeature() {
* const security = useSecurityReady();
*
* if (!security) {
* return ;
* }
*
* return ;
* }
* ```
*/
export declare function useSecurityReady(): SecurityContextValue | null;
/**
* Hook for creating secure event handlers
*
* Wraps event handlers with security checks.
*
* @example
* ```tsx
* function SecureForm() {
* const createSecureHandler = useSecureHandler();
*
* const handleSubmit = createSecureHandler(async (data: FormData) => {
* await submitForm(data);
* });
*
* return ;
* }
* ```
*/
export declare function useSecureHandler(): unknown>(handler: T, options?: {
validateCsrf?: boolean;
reportOnError?: boolean;
}) => T;