/** * Abstract base for all sframe-ratchet domain errors. * `code` is a stable machine-readable identifier; `context` carries structured * fields so callers never need to parse `message`. */ declare abstract class SFrameError extends Error { readonly context?: Record | undefined; abstract readonly code: string; constructor(message: string, context?: Record | undefined); } /** * No key found for the given (epoch, peerIndex) pair. * Thrown by the decrypt path when the epoch is missing or the peer is not in * the epoch's key table. */ declare class KeyNotFoundError extends SFrameError { readonly context: { kid?: number; epoch?: number; peerIndex?: number; }; readonly code: "KEY_NOT_FOUND"; constructor(message: string, context: { kid?: number; epoch?: number; peerIndex?: number; }); } /** * Incoming frame carries an epoch older than the receiver's stale-epoch gate * (`currentMinValidEpoch`). The frame is discarded without any AEAD attempt. * Spec §7.4. */ declare class StaleEpochError extends SFrameError { readonly context: { frameEpoch: number; minValidEpoch: number; kid?: number; }; readonly code: "STALE_EPOCH"; constructor(message: string, context: { frameEpoch: number; minValidEpoch: number; kid?: number; }); } /** * AES-GCM authentication tag verification failed. * Thrown when WebCrypto rejects the ciphertext — key mismatch, corrupted frame, * or wrong nonce. The retry window in `tryDecryptWithRatchet` re-throws this * after exhausting all ratchet steps. */ declare class AEADAuthError extends SFrameError { readonly context: { kid?: number; epoch?: number; peerIndex?: number; ctr?: bigint; }; readonly code: "AEAD_AUTH_FAIL"; constructor(message: string, context: { kid?: number; epoch?: number; peerIndex?: number; ctr?: bigint; }); } /** * Forward ratchet retry window exhausted without a matching key. * Thrown after `ratchetWindowSize` unsuccessful AEAD attempts within the same epoch. */ declare class RatchetWindowExhaustedError extends SFrameError { readonly context: { epoch: number; peerIndex: number; attempts: number; }; readonly code: "RATCHET_WINDOW_EXHAUSTED"; constructor(message: string, context: { epoch: number; peerIndex: number; attempts: number; }); } /** * SFrame header parse failure — buffer too short, truncated KID/CTR field, or * KID value outside safe-integer range. */ declare class HeaderParseError extends SFrameError { readonly context?: { bufferLength?: number; } | undefined; readonly code: "HEADER_PARSE"; constructor(message: string, context?: { bufferLength?: number; } | undefined); } /** * Pre-epoch frame queue is full; the oldest queued frame was dropped to make * room for the incoming one. */ declare class QueueFullError extends SFrameError { readonly context?: Record | undefined; readonly code: "QUEUE_FULL"; constructor(message: string, context?: Record | undefined); } /** * A strict-FIPS policy violation. Thrown when an operation (cipher suite * selection, SimpleKex construction, etc.) violates the active * {@link enableStrictFips} configuration. * * Check `err.code === 'FIPS_VIOLATION'` or `err instanceof FipsModeViolationError`. */ declare class FipsModeViolationError extends SFrameError { readonly context?: Record | undefined; readonly code: "FIPS_VIOLATION"; constructor(message: string, context?: Record | undefined); } /** * Anti-replay window rejected a frame whose CTR was already seen within the * current (epoch, peerIndex) sliding window (RFC 9605 §9.3, issue #10). * * Thrown by `decodeFrame` / `drainPreEpochQueue` AFTER `parseHeader` succeeds * and the stale-epoch gate passes, but BEFORE any AEAD attempt — so a replayed * frame never consumes ratchet-retry budget and never touches WebCrypto. * `accept(ctr)` is only called after a successful AEAD decrypt, so a replayed * frame that fails the window check is never recorded as "seen" again. */ declare class ReplayError extends SFrameError { readonly context: { epoch: number; peerIndex: number; ctr: bigint; }; readonly code: "REPLAY"; constructor(message: string, context: { epoch: number; peerIndex: number; ctr: bigint; }); } /** * The key for (epoch, peerIndex) has been marked invalid after exceeding the * configured `failureTolerance` of consecutive AEAD failures (issue #14, * pattern from livekit/client-sdk-js ParticipantKeyHandler.ts:58). * * Thrown by `decodeFrame` / `drainPreEpochQueue` AFTER the replay check passes * but BEFORE any AEAD attempt — so a frame for an invalidated key is dropped * without consuming ratchet-retry budget or touching WebCrypto, saving CPU. * Subsequent frames at that index keep being dropped until a fresh key is * installed (which resets the failure count via `resetFailureCount`). */ declare class KeyInvalidError extends SFrameError { readonly context: { epoch: number; peerIndex: number; failures: number; }; readonly code: "KEY_INVALID"; constructor(message: string, context: { epoch: number; peerIndex: number; failures: number; }); } export { AEADAuthError as A, FipsModeViolationError as F, HeaderParseError as H, KeyInvalidError as K, QueueFullError as Q, RatchetWindowExhaustedError as R, SFrameError as S, KeyNotFoundError as a, ReplayError as b, StaleEpochError as c };