INNER CODE UNIT · TypeScript

MAX_BODY_BYTES

yvgude/lean-ctx · packages/vscode-lean-ctx/src/bridge/server.ts:10

const MAX_BODY_BYTES = 64 * 1024;

export interface BridgeServer {
  port: number;
  close(): Promise<void>;
}

function tokenMatches(expected: Buffer, got: string | string[] | undefined): boolean {
  if (typeof got !== "string") return false;
  const actual = Buffer.from(got);
  return actual.length === expected.length && timingSafeEqual(actual, expected);
}

function send(res: http.ServerResponse, status: number, body: unknown): void {
  const text = JSON.stringify(body);
  res.writeHead(status, {
    "Content-Type": "application/json",
    "Content-Length": Buffer.byteLength(text),

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…