/**
 * @module plugins/validation
 * Validation plugin for xBind plugin system
 *
 * Validates payloads, envelopes, and ensures data integrity before processing.
 */
import type { Result } from '@private.me/shared';
import type { Plugin, PluginContext, HookResult } from '../plugin-system.js';
import type { AnyTransportEnvelope } from '../envelope.js';
/**
 * Validation rule.
 */
export interface ValidationRule {
    /** Rule name */
    name: string;
    /** Validate function - returns error message on failure, null on success */
    validate: (value: unknown, context: PluginContext) => string | null;
    /** Apply to send operations */
    appliesTo?: ('send' | 'receive' | 'encrypt' | 'decrypt')[];
}
/**
 * Validation plugin options.
 */
export interface ValidationPluginOptions {
    /** Maximum payload size in bytes (default: 10MB) */
    maxPayloadSize?: number;
    /** Maximum envelope size in bytes (default: 15MB) */
    maxEnvelopeSize?: number;
    /** Allowed scopes (empty = all allowed) */
    allowedScopes?: string[];
    /** Custom validation rules */
    customRules?: ValidationRule[];
    /** Strict mode - reject any validation warning (default: false) */
    strictMode?: boolean;
    /** Enable payload schema validation (default: false) */
    validateSchema?: boolean;
}
/**
 * Validation plugin implementation.
 * Validates all data before processing to ensure integrity and compliance.
 */
export declare class ValidationPlugin implements Plugin {
    readonly name = "validation";
    readonly version = "1.0.0";
    readonly description = "Validates payloads and envelopes before processing";
    readonly priority = 5;
    private options;
    private validationErrors;
    constructor(options?: ValidationPluginOptions);
    onInit(): Result<void, string>;
    onDestroy(): Result<void, string>;
    onSend(payload: unknown, context: PluginContext): Result<HookResult<unknown>, string>;
    onReceive(envelope: AnyTransportEnvelope, context: PluginContext): Result<HookResult<AnyTransportEnvelope>, string>;
    onEncrypt(plaintext: Uint8Array, context: PluginContext): Result<HookResult<Uint8Array>, string>;
    onDecrypt(plaintext: Uint8Array, context: PluginContext): Result<HookResult<Uint8Array>, string>;
    /**
     * Get all validation errors.
     */
    getValidationErrors(): ReadonlyArray<{
        timestamp: number;
        rule: string;
        error: string;
    }>;
    /**
     * Clear validation errors.
     */
    clearErrors(): void;
    /**
     * Add a custom validation rule.
     */
    addRule(rule: ValidationRule): void;
    /**
     * Remove a custom validation rule by name.
     */
    removeRule(name: string): boolean;
    private validatePayloadSize;
    private validateEnvelopeSize;
    private validateScope;
    private validatePayloadStructure;
    private validateEnvelopeStructure;
    private estimateSize;
    private recordError;
}
/**
 * Create a validation plugin with options.
 */
export declare function createValidationPlugin(options?: ValidationPluginOptions): ValidationPlugin;
/**
 * Common validation rules.
 */
export declare const CommonRules: {
    /**
     * Validate payload contains required fields.
     */
    requireFields(fields: string[]): ValidationRule;
    /**
     * Validate DID format.
     */
    validateDIDFormat(): ValidationRule;
    /**
     * Validate timestamp is recent.
     */
    validateTimestamp(maxAgeMs?: number): ValidationRule;
};
