Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@harnessa-fe/protocol

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@harnessa-fe/protocol - npm Package Compare versions

Comparing version
1.0.2
to
2.0.0
+17
-0
dist/index.d.ts

@@ -11,2 +11,4 @@ /**

export declare const PROTOCOL_VERSION = "0.0.1";
/** Default host for the local MCP server WebSocket bridge. */
export declare const DEFAULT_HOST = "127.0.0.1";
/** Default port for the local MCP server WebSocket bridge. */

@@ -16,3 +18,18 @@ export declare const DEFAULT_WS_PORT = 47729;

export declare const DEFAULT_WS_URL = "ws://127.0.0.1:47729";
/** Hosts that don't require token auth — local loopback only. */
export declare function isLoopbackHost(host: string): boolean;
export interface UrlParts {
host: string;
port: number;
token?: string;
path?: string;
}
/**
* Build a ws://host:port[/path][?token=…] URL. Centralised so plugin, runtime,
* CLI banner, and tests stay in sync on token query string formatting.
*/
export declare function buildWsUrl(parts: UrlParts): string;
/** Build an http://host:port[/path][?token=…] URL. */
export declare function buildHttpUrl(parts: UrlParts): string;
/**
* Parse a `ws://host:port` (or `wss://host:port[/path]`) URL into host + port.

@@ -19,0 +36,0 @@ * Used by mcp-server's CLI to listen on the URL the user requested. Falls

+31
-1

@@ -11,7 +11,37 @@ /**

export const PROTOCOL_VERSION = '0.0.1';
/** Default host for the local MCP server WebSocket bridge. */
export const DEFAULT_HOST = '127.0.0.1';
/** Default port for the local MCP server WebSocket bridge. */
export const DEFAULT_WS_PORT = 47729;
/** Default WebSocket URL — what every layer falls back to when no override is configured. */
export const DEFAULT_WS_URL = `ws://127.0.0.1:${DEFAULT_WS_PORT}`;
export const DEFAULT_WS_URL = `ws://${DEFAULT_HOST}:${DEFAULT_WS_PORT}`;
/** Hosts that don't require token auth — local loopback only. */
export function isLoopbackHost(host) {
const h = host.toLowerCase();
if (h === 'localhost' || h === '::1' || h === '0:0:0:0:0:0:0:1')
return true;
if (h.startsWith('127.'))
return true;
return false;
}
/**
* Build a ws://host:port[/path][?token=…] URL. Centralised so plugin, runtime,
* CLI banner, and tests stay in sync on token query string formatting.
*/
export function buildWsUrl(parts) {
return buildUrl('ws', parts);
}
/** Build an http://host:port[/path][?token=…] URL. */
export function buildHttpUrl(parts) {
return buildUrl('http', parts);
}
function buildUrl(scheme, { host, port, token, path }) {
const hostPart = host.includes(':') && !host.startsWith('[') ? `[${host}]` : host;
const base = `${scheme}://${hostPart}:${port}${path ?? ''}`;
if (!token)
return base;
const sep = base.includes('?') ? '&' : '?';
return `${base}${sep}token=${encodeURIComponent(token)}`;
}
/**
* Parse a `ws://host:port` (or `wss://host:port[/path]`) URL into host + port.

@@ -18,0 +48,0 @@ * Used by mcp-server's CLI to listen on the URL the user requested. Falls

+1
-1
{
"name": "@harnessa-fe/protocol",
"version": "1.0.2",
"version": "2.0.0",
"description": "Shared types + Zod schemas across mcp-server, vite-plugin, runtime-client.",

@@ -5,0 +5,0 @@ "type": "module",

@@ -14,2 +14,5 @@ /**

/** Default host for the local MCP server WebSocket bridge. */
export const DEFAULT_HOST = '127.0.0.1';
/** Default port for the local MCP server WebSocket bridge. */

@@ -19,5 +22,41 @@ export const DEFAULT_WS_PORT = 47729;

/** Default WebSocket URL — what every layer falls back to when no override is configured. */
export const DEFAULT_WS_URL = `ws://127.0.0.1:${DEFAULT_WS_PORT}`;
export const DEFAULT_WS_URL = `ws://${DEFAULT_HOST}:${DEFAULT_WS_PORT}`;
/** Hosts that don't require token auth — local loopback only. */
export function isLoopbackHost(host: string): boolean {
const h = host.toLowerCase();
if (h === 'localhost' || h === '::1' || h === '0:0:0:0:0:0:0:1') return true;
if (h.startsWith('127.')) return true;
return false;
}
export interface UrlParts {
host: string;
port: number;
token?: string;
path?: string;
}
/**
* Build a ws://host:port[/path][?token=…] URL. Centralised so plugin, runtime,
* CLI banner, and tests stay in sync on token query string formatting.
*/
export function buildWsUrl(parts: UrlParts): string {
return buildUrl('ws', parts);
}
/** Build an http://host:port[/path][?token=…] URL. */
export function buildHttpUrl(parts: UrlParts): string {
return buildUrl('http', parts);
}
function buildUrl(scheme: 'ws' | 'http', { host, port, token, path }: UrlParts): string {
const hostPart = host.includes(':') && !host.startsWith('[') ? `[${host}]` : host;
const base = `${scheme}://${hostPart}:${port}${path ?? ''}`;
if (!token) return base;
const sep = base.includes('?') ? '&' : '?';
return `${base}${sep}token=${encodeURIComponent(token)}`;
}
/**
* Parse a `ws://host:port` (or `wss://host:port[/path]`) URL into host + port.

@@ -24,0 +63,0 @@ * Used by mcp-server's CLI to listen on the URL the user requested. Falls