@pellux/goodvibes-transport-http 1.8.0 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -19,5 +19,5 @@ export { DEFAULT_HTTP_RETRY_POLICY, applyPerMethodPolicy, getHttpRetryDelay, isR
19
19
  export type { StreamReconnectPolicy, ResolvedStreamReconnectPolicy } from './reconnect.js';
20
20
  export { DEFAULT_STREAM_RECONNECT_POLICY, getStreamReconnectDelay, normalizeStreamReconnectPolicy } from './reconnect.js';
21
21
  export type { TransportPaths } from './paths.js';
22
- export { buildUrl, createTransportPaths, normalizeBaseUrl } from './paths.js';
22
+ export { buildUrl, createTransportPaths, normalizeBaseUrl, isPrivateNetworkHost } from './paths.js';
23
23
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,qBAAqB,EACrB,uBAAuB,EACvB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,2BAA2B,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC/G,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACpH,YAAY,EACV,sBAAsB,EACtB,aAAa,EACb,oBAAoB,EACpB,UAAU,EACV,SAAS,EACT,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,qBAAqB,EACrB,uBAAuB,EACvB,YAAY,EACZ,cAAc,GACf,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,iB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B,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAClH,YAAY,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC5F,YAAY,EAAE,eAAe,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACjG,OAAO,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAClM,YAAY,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAC3F,OAAO,EAAE,+BAA+B,EAAE,uBAAuB,EAAE,8BAA8B,EAAE,MAAM,gBAAgB,CAAC;AAC1H,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -8,4 +8,4 @@ export { mergeHeaderRecord, mergeHeaders, normalizeAuthToken, resolveAuthToken,
8
8
  export { computeBackoffDelay, normalizeBackoffPolicy, sleepWithSignal } from './backoff.js';
9
9
  export { DEFAULT_HTTP_RETRY_POLICY, applyPerMethodPolicy, getHttpRetryDelay, isRetryableHttpStatus, isRetryableNetworkError, normalizeHttpRetryPolicy, resolveHttpRetryPolicy } from './retry.js';
10
10
  export { DEFAULT_STREAM_RECONNECT_POLICY, getStreamReconnectDelay, normalizeStreamReconnectPolicy } from './reconnect.js';
11
- export { buildUrl, createTransportPaths, normalizeBaseUrl } from './paths.js';
11
+ export { buildUrl, createTransportPaths, normalizeBaseUrl, isPrivateNetworkHost } from './paths.js';
package/dist/paths.d.ts CHANGED
@@ -30,6 +30,20 @@ export interface TransportPaths {
30
30
  */
31
31
  readonly controlUrl: string;
32
32
  }
33
+ /**
34
+ * Whether a URL hostname addresses a private network — loopback, an RFC 1918
35
+ * range (10/8, 172.16/12, 192.168/16), or an mDNS `.local` name.
36
+ *
37
+ * Plain-http origins on these hosts are a DELIBERATE, SUPPORTED posture (a
38
+ * phone on the same LAN talking to the daemon), not a mistake to wall off:
39
+ * TLS on a home network is the user's own responsibility and the daemon never
40
+ * mints certificates, so the transport must work over http here — in a browser
41
+ * bundle too, where no process.env escape hatch exists. Genuinely public http
42
+ * origins keep the insecure-transport wall.
43
+ *
44
+ * Accepts the hostname as URL.hostname yields it (IPv6 still in brackets).
45
+ */
46
+ export declare function isPrivateNetworkHost(hostname: string): boolean;
33
47
  export declare function normalizeBaseUrl(baseUrl: string): string;
34
48
  export declare function buildUrl(baseUrl: string, path: string): string;
35
49
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;IACvC,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAC;IACxC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,kBAAkB,EAAE,MAAM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E,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAU9D;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,GAAG,MAAM,CA6BnG;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,CA+BpE"}
package/dist/paths.js CHANGED
@@ -1,4 +1,37 @@
1
1
  import { ConfigurationError } from '@pellux/goodvibes-errors';
2
+ /**
3
+ * Whether a URL hostname addresses a private network — loopback, an RFC 1918
4
+ * range (10/8, 172.16/12, 192.168/16), or an mDNS `.local` name.
5
+ *
6
+ * Plain-http origins on these hosts are a DELIBERATE, SUPPORTED posture (a
7
+ * phone on the same LAN talking to the daemon), not a mistake to wall off:
8
+ * TLS on a home network is the user's own responsibility and the daemon never
9
+ * mints certificates, so the transport must work over http here — in a browser
10
+ * bundle too, where no process.env escape hatch exists. Genuinely public http
11
+ * origins keep the insecure-transport wall.
12
+ *
13
+ * Accepts the hostname as URL.hostname yields it (IPv6 still in brackets).
14
+ */
15
+ export function isPrivateNetworkHost(hostname) {
16
+ const host = hostname.toLowerCase().replace(/^\[|\]$/g, '');
17
+ if (host === 'localhost' || host === '::1' || host.endsWith('.localhost'))
18
+ return true;
19
+ if (host.endsWith('.local'))
20
+ return true; // mDNS
21
+ const ipv4 = host.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);
22
+ if (!ipv4)
23
+ return false;
24
+ const [a, b] = [Number(ipv4[1]), Number(ipv4[2])];
25
+ if (a === 127)
26
+ return true; // loopback
27
+ if (a === 10)
28
+ return true; // 10/8
29
+ if (a === 172 && b >= 16 && b <= 31)
30
+ return true; // 172.16/12
31
+ if (a === 192 && b === 168)
32
+ return true; // 192.168/16
33
+ return false;
34
+ }
2
35
  export function normalizeBaseUrl(baseUrl) {
3
36
  const normalized = baseUrl.trim();
4
37
  if (!normalized) {
@@ -21,18 +54,22 @@ export function normalizeBaseUrl(baseUrl) {
21
54
  throw new ConfigurationError(`Unsupported transport baseUrl protocol: ${protocol}`, {
22
55
  code: 'SDK_TRANSPORT_BASE_URL_PROTOCOL_UNSUPPORTED',
23
56
  source: 'transport',
24
- hint: 'Use https:// or wss://. http:// and ws:// are accepted only for local development or explicit insecure deployments.',
57
+ hint: 'Use https:// or wss://. http:// and ws:// are supported on private-network origins (localhost, RFC 1918, .local) and for explicit public-http deployments.',
25
58
  });
26
59
  }
27
- const host = parsed.hostname.toLowerCase();
28
- const local = host === 'localhost' || host === '::1' || host === '127.0.0.1' || host.startsWith('127.');
60
+ // Private-network origins (loopback, RFC 1918, .local mDNS) are a supported
61
+ // plain-http posture no throw, and no env escape hatch needed (which would
62
+ // not exist in a browser bundle anyway). Only a genuinely PUBLIC http origin
63
+ // keeps the wall; the server-side env override remains for an intentional
64
+ // public-http deployment.
65
+ const privateNetwork = isPrivateNetworkHost(parsed.hostname);
29
66
  const runtimeProcess = globalThis.process;
30
67
  const allowInsecure = runtimeProcess?.env?.GOODVIBES_ALLOW_INSECURE_TRANSPORT === 'true';
31
- if ((protocol === 'http:' || protocol === 'ws:') && !local && !allowInsecure) {
32
- throw new ConfigurationError('Refusing insecure non-local GoodVibes transport baseUrl.', {
68
+ if ((protocol === 'http:' || protocol === 'ws:') && !privateNetwork && !allowInsecure) {
69
+ throw new ConfigurationError('Refusing insecure PUBLIC GoodVibes transport baseUrl.', {
33
70
  code: 'SDK_TRANSPORT_INSECURE_BASE_URL',
34
71
  source: 'transport',
35
- hint: 'Use https:// or wss://, or set GOODVIBES_ALLOW_INSECURE_TRANSPORT=true for an intentional non-local development deployment.',
72
+ hint: 'Use https:// or wss:// for public origins. Plain http is supported on private-network origins (localhost, 10/8, 172.16/12, 192.168/16, .local). For an intentional public-http deployment set GOODVIBES_ALLOW_INSECURE_TRANSPORT=true (server-side only).',
36
73
  });
37
74
  }
38
75
  return normalized.replace(/\/+$/, '');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pellux/goodvibes-transport-http",
3
- "version": "1.8.0",
3
+ "version": "1.10.0",
4
4
  "engines": {
5
5
  "bun": "1.3.10",
6
6
  "node": ">=22.0.0"
@@ -81,9 +81,9 @@
81
81
  "transport"
82
82
  ],
83
83
  "dependencies": {
84
- "@pellux/goodvibes-contracts": "1.8.0",
85
- "@pellux/goodvibes-errors": "1.8.0",
86
- "@pellux/goodvibes-transport-core": "1.8.0",
84
+ "@pellux/goodvibes-contracts": "1.10.0",
85
+ "@pellux/goodvibes-errors": "1.10.0",
86
+ "@pellux/goodvibes-transport-core": "1.10.0",
87
87
  "zod": "^4.3.6"
88
88
  },
89
89
  "publishConfig": {