@harnessa-fe/protocol
Advanced tools
+17
-0
@@ -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", |
+40
-1
@@ -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 |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
94623
3.43%2364
3.5%