package com.peachpasswords.sync import java.io.IOException /** * Cloudflare Workers caps one WebSocket message at 32 MiB. Keep a generous * margin for the Noise authentication tag and platform framing overhead. */ const val MAX_SYNC_FRAME_BYTES: Int = 24 * 1024 * 1024 class SyncFrameTooLargeException( message: String = "sync frame too large (WebSocket close 1009)", ) : IOException(message) fun requireSyncFrameSize(size: Int) { if (size > MAX_SYNC_FRAME_BYTES) { throw SyncFrameTooLargeException("sync frame exceeds $MAX_SYNC_FRAME_BYTES bytes") } }