bun-ws-router
Version:
Lightweight client/server WebSocket router for Bun with type-safe Zod/Valibot validation.
23 lines • 915 B
TypeScript
/**
* Validates that extended meta schema does not define reserved keys.
*
* This check occurs in messageSchema() factory to fail fast at design time.
*
* @throws {Error} If meta schema contains reserved keys
*/
export declare function validateMetaSchema(meta?: Record<string, unknown>): void;
/**
* Normalizes inbound message before validation (security boundary).
*
* MUST be called before schema validation to:
* - Strip reserved server-only keys (prevents spoofing)
* - Ensure meta exists (allows optional client meta)
*
* Mutates in place for performance (hot path, every message).
* O(k) complexity where k = RESERVED_META_KEYS.size (currently 2).
*
* @param raw - Raw parsed message from client
* @returns Normalized message (same reference, mutated in place)
*/
export declare function normalizeInboundMessage(raw: unknown): Record<string, unknown>;
//# sourceMappingURL=normalize.d.ts.map