@volter/tunnel-core
v0.1.3
Published
Shared wire-protocol contract for volter-tunnel: control-message types, frame codec, and DTOs. Pure, dependency-free, runtime-agnostic.
Downloads
3,580
Readme
@volter/tunnel-core
The shared wire-protocol contract for volter-tunnel: the control-channel message types, a frame codec, and the DTOs that cross the wire.
Pure, dependency-free, and runtime-agnostic — imported by both the client and the relay so the two sides can never drift. Held to 100% test coverage.
import {
type ControlMessage,
type RelayToClient,
encodeFrame,
decodeFrame,
isControlMessage,
MESSAGE_TYPES,
} from '@volter/tunnel-core';
const raw = encodeFrame({ type: 'response-end', reqId: 'abc' });
const msg = decodeFrame(raw); // ControlMessage | null (null on junk/unknown type)What's in here
protocol.ts— every control message as a discriminated union (ClientToRelay,RelayToClient,ControlMessage), theMESSAGE_TYPESregistry, and theisControlMessageguard.frame.ts—encodeFrame/decodeFrame(JSON framing today; isolated so the transport can evolve without touching call sites).dto.ts—HeaderMap,RateWindow,UsageLevel,AccountSnapshot,UsageWindow,AccountUsage, andCorrelationId(string | number— the CF relay uses UUID strings; clients treat it opaquely).
Develop
cd packages/core && bun test # runs the 100% coverage gate (bunfig.toml)Licensed under Apache-2.0.
