@testsprite/testsprite-cli 0.7.0 → 0.9.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.
Files changed (74) hide show
  1. package/README.md +62 -45
  2. package/dist/commands/agent.d.ts +3 -0
  3. package/dist/commands/agent.js +79 -10
  4. package/dist/commands/ci.d.ts +88 -0
  5. package/dist/commands/ci.js +432 -0
  6. package/dist/commands/doctor.js +100 -1
  7. package/dist/commands/init.d.ts +45 -2
  8. package/dist/commands/init.js +198 -29
  9. package/dist/commands/project.d.ts +78 -0
  10. package/dist/commands/project.js +439 -5
  11. package/dist/commands/test.d.ts +193 -4
  12. package/dist/commands/test.js +1948 -398
  13. package/dist/commands/testlist.js +15 -9
  14. package/dist/commands/tunnel.d.ts +72 -0
  15. package/dist/commands/tunnel.js +367 -0
  16. package/dist/index.js +107 -38
  17. package/dist/lib/agent-detect.d.ts +53 -0
  18. package/dist/lib/agent-detect.js +198 -0
  19. package/dist/lib/dry-run/samples.d.ts +9 -0
  20. package/dist/lib/dry-run/samples.js +116 -0
  21. package/dist/lib/gh-output.d.ts +7 -0
  22. package/dist/lib/gh-output.js +50 -7
  23. package/dist/lib/http.d.ts +104 -0
  24. package/dist/lib/http.js +126 -7
  25. package/dist/lib/interrupt.d.ts +38 -13
  26. package/dist/lib/interrupt.js +130 -15
  27. package/dist/lib/local-target.d.ts +95 -0
  28. package/dist/lib/local-target.js +184 -0
  29. package/dist/lib/plan-poll.d.ts +171 -0
  30. package/dist/lib/plan-poll.js +442 -0
  31. package/dist/lib/plans.types.d.ts +130 -0
  32. package/dist/lib/plans.types.js +31 -0
  33. package/dist/lib/poll-support.d.ts +26 -0
  34. package/dist/lib/poll-support.js +65 -0
  35. package/dist/lib/poll.d.ts +1 -0
  36. package/dist/lib/poll.js +2 -40
  37. package/dist/lib/response-schemas.d.ts +13 -0
  38. package/dist/lib/response-schemas.js +46 -0
  39. package/dist/lib/run-progress.d.ts +41 -0
  40. package/dist/lib/run-progress.js +56 -0
  41. package/dist/lib/runs.types.d.ts +50 -0
  42. package/dist/lib/skill-nudge.d.ts +13 -5
  43. package/dist/lib/skill-nudge.js +40 -14
  44. package/dist/lib/target-url-preflight.js +3 -3
  45. package/dist/lib/target-url.d.ts +54 -8
  46. package/dist/lib/target-url.js +274 -68
  47. package/dist/lib/telemetry.d.ts +11 -0
  48. package/dist/lib/telemetry.js +1 -0
  49. package/dist/lib/ticker.d.ts +8 -0
  50. package/dist/lib/ticker.js +3 -0
  51. package/dist/lib/tunnel-session.d.ts +138 -0
  52. package/dist/lib/tunnel-session.js +249 -0
  53. package/dist/lib/tunnel.types.d.ts +54 -0
  54. package/dist/lib/tunnel.types.js +8 -0
  55. package/dist/vendor/tunnel-client/client.d.ts +82 -0
  56. package/dist/vendor/tunnel-client/client.js +924 -0
  57. package/dist/vendor/tunnel-client/config.d.ts +49 -0
  58. package/dist/vendor/tunnel-client/config.js +50 -0
  59. package/dist/vendor/tunnel-client/index.d.ts +9 -0
  60. package/dist/vendor/tunnel-client/index.js +9 -0
  61. package/dist/vendor/tunnel-client/lodash-lite.d.ts +14 -0
  62. package/dist/vendor/tunnel-client/lodash-lite.js +24 -0
  63. package/dist/vendor/tunnel-client/protocol.d.ts +60 -0
  64. package/dist/vendor/tunnel-client/protocol.js +143 -0
  65. package/dist/vendor/tunnel-client/types.d.ts +101 -0
  66. package/dist/vendor/tunnel-client/types.js +10 -0
  67. package/dist/vendor/tunnel-client/ws-compat.d.ts +206 -0
  68. package/dist/vendor/tunnel-client/ws-compat.js +316 -0
  69. package/dist/version.d.ts +1 -1
  70. package/dist/version.js +1 -1
  71. package/package.json +2 -1
  72. package/skills/testsprite-onboard.skill.md +60 -4
  73. package/skills/testsprite-verify.codex.md +22 -16
  74. package/skills/testsprite-verify.skill.md +27 -18
@@ -0,0 +1,49 @@
1
+ /**
2
+ * VENDOR DELTA (not upstream). Upstream's `config.ts` reads `TSTUN_*`
3
+ * environment variables and falls back to **hard-coded TestSprite dev
4
+ * ALB/NLB hostnames**. Neither belongs in a package published to the public
5
+ * npm registry:
6
+ *
7
+ * - the endpoints are internal infrastructure names, and a default value is
8
+ * still a value that ships;
9
+ * - a default endpoint is the failure mode the facade exists to prevent.
10
+ * `POST /api/cli/v1/tunnel` returns `controlUrl` and `tunnelAddr` for the
11
+ * environment the caller authenticated against, and those are the ONLY
12
+ * endpoints this client may dial. A default would let a
13
+ * misconfigured/partially-constructed client silently connect somewhere
14
+ * else and fail in a way that reads like an auth problem.
15
+ *
16
+ * So the endpoint defaults are gone and `TunnelClientOptions.controlUrl` /
17
+ * `.tunnelAddr` are required by the caller (`lib/tunnel-session.ts` passes
18
+ * the mint response through verbatim). The timing constants below are
19
+ * upstream's values.
20
+ */
21
+ /** Heartbeat cadence on the control WebSocket. Upstream default. */
22
+ export declare const DEFAULT_HEARTBEAT_MS = 10000;
23
+ /**
24
+ * Maximum time `start()` waits for the server's authentication Ack.
25
+ *
26
+ * VENDOR DELTA: matches the existing 10-second heartbeat and target-connect
27
+ * windows, so a control socket cannot look ready indefinitely when the server
28
+ * accepted the transport but never authenticated it.
29
+ */
30
+ export declare const DEFAULT_AUTH_TIMEOUT_MS = 10000;
31
+ /** Delay between control/tunnel reconnect attempts. Upstream default. */
32
+ export declare const DEFAULT_RECONNECT_MS = 3000;
33
+ /** Log verbosity floor. Upstream default. */
34
+ export declare const DEFAULT_LOG_LEVEL: "info";
35
+ /** Per-attempt dial timeout when connecting to the proxied target. Upstream default. */
36
+ export declare const DEFAULT_TARGET_CONNECT_TIMEOUT_MS = 10000;
37
+ /**
38
+ * Whether a proxied target may resolve into private address space.
39
+ *
40
+ * Upstream reads `TS_TUNNEL_ALLOW_PRIVATE_NETWORK_TARGET`. This CLI hard-codes
41
+ * `false` and exposes no flag for it: the whole point of `--local` is to reach
42
+ * the caller's own loopback, and a run that pivots into the rest of their
43
+ * network is the failure this rail exists to stop. Loopback and public targets
44
+ * are unaffected — the browser under test proxies every request, so a page
45
+ * pulling a font or calling a third-party API is normal traffic (verified on
46
+ * dev 2026-08-24: `accounts.google.com` and `cf.browser-use.com` both crossed
47
+ * the same client during a real run).
48
+ */
49
+ export declare const DEFAULT_ALLOW_PRIVATE_NETWORK_TARGET = false;
@@ -0,0 +1,50 @@
1
+ /**
2
+ * VENDOR DELTA (not upstream). Upstream's `config.ts` reads `TSTUN_*`
3
+ * environment variables and falls back to **hard-coded TestSprite dev
4
+ * ALB/NLB hostnames**. Neither belongs in a package published to the public
5
+ * npm registry:
6
+ *
7
+ * - the endpoints are internal infrastructure names, and a default value is
8
+ * still a value that ships;
9
+ * - a default endpoint is the failure mode the facade exists to prevent.
10
+ * `POST /api/cli/v1/tunnel` returns `controlUrl` and `tunnelAddr` for the
11
+ * environment the caller authenticated against, and those are the ONLY
12
+ * endpoints this client may dial. A default would let a
13
+ * misconfigured/partially-constructed client silently connect somewhere
14
+ * else and fail in a way that reads like an auth problem.
15
+ *
16
+ * So the endpoint defaults are gone and `TunnelClientOptions.controlUrl` /
17
+ * `.tunnelAddr` are required by the caller (`lib/tunnel-session.ts` passes
18
+ * the mint response through verbatim). The timing constants below are
19
+ * upstream's values.
20
+ */
21
+ /** Heartbeat cadence on the control WebSocket. Upstream default. */
22
+ export const DEFAULT_HEARTBEAT_MS = 10_000;
23
+ /**
24
+ * Maximum time `start()` waits for the server's authentication Ack.
25
+ *
26
+ * VENDOR DELTA: matches the existing 10-second heartbeat and target-connect
27
+ * windows, so a control socket cannot look ready indefinitely when the server
28
+ * accepted the transport but never authenticated it.
29
+ */
30
+ export const DEFAULT_AUTH_TIMEOUT_MS = 10_000;
31
+ /** Delay between control/tunnel reconnect attempts. Upstream default. */
32
+ export const DEFAULT_RECONNECT_MS = 3_000;
33
+ /** Log verbosity floor. Upstream default. */
34
+ export const DEFAULT_LOG_LEVEL = 'info';
35
+ /** Per-attempt dial timeout when connecting to the proxied target. Upstream default. */
36
+ export const DEFAULT_TARGET_CONNECT_TIMEOUT_MS = 10_000;
37
+ /**
38
+ * Whether a proxied target may resolve into private address space.
39
+ *
40
+ * Upstream reads `TS_TUNNEL_ALLOW_PRIVATE_NETWORK_TARGET`. This CLI hard-codes
41
+ * `false` and exposes no flag for it: the whole point of `--local` is to reach
42
+ * the caller's own loopback, and a run that pivots into the rest of their
43
+ * network is the failure this rail exists to stop. Loopback and public targets
44
+ * are unaffected — the browser under test proxies every request, so a page
45
+ * pulling a font or calling a third-party API is normal traffic (verified on
46
+ * dev 2026-08-24: `accounts.google.com` and `cf.browser-use.com` both crossed
47
+ * the same client during a real run).
48
+ */
49
+ export const DEFAULT_ALLOW_PRIVATE_NETWORK_TARGET = false;
50
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * VENDOR DELTA (not upstream). Upstream's `index.ts` re-exports only
3
+ * `TunnelClient` / `BlockedTargetError`; this adds the two dial helpers,
4
+ * which the CLI's port preflight reuses so the pre-charge probe dials the
5
+ * SAME candidate set the client will dial at run time.
6
+ */
7
+ export { TunnelClient, BlockedTargetError, resolveDialCandidates, blockedTargetReason, } from './client.js';
8
+ export type { TunnelClientOptions, StreamOpenRequestFrame, LogLevel } from './types.js';
9
+ export { ErrCode } from './types.js';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * VENDOR DELTA (not upstream). Upstream's `index.ts` re-exports only
3
+ * `TunnelClient` / `BlockedTargetError`; this adds the two dial helpers,
4
+ * which the CLI's port preflight reuses so the pre-charge probe dials the
5
+ * SAME candidate set the client will dial at run time.
6
+ */
7
+ export { TunnelClient, BlockedTargetError, resolveDialCandidates, blockedTargetReason, } from './client.js';
8
+ export { ErrCode } from './types.js';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,14 @@
1
+ /**
2
+ * VENDOR DELTA (not upstream). Upstream's `client.ts` pulls `isNumber`,
3
+ * `isPlainObject` and `isString` from `lodash`; this CLI ships three runtime
4
+ * dependencies on purpose, and these three predicates are a handful of lines.
5
+ *
6
+ * Semantics match lodash's for every value this code path can see (JSON
7
+ * parsed off the wire): `isNumber` accepts the `number` primitive — lodash
8
+ * also accepts `Number` objects and `NaN`, neither of which `JSON.parse`
9
+ * ever produces — and `isPlainObject` accepts an object literal or a
10
+ * null-prototype object, rejecting arrays and `null`.
11
+ */
12
+ export declare function isString(value: unknown): value is string;
13
+ export declare function isNumber(value: unknown): value is number;
14
+ export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * VENDOR DELTA (not upstream). Upstream's `client.ts` pulls `isNumber`,
3
+ * `isPlainObject` and `isString` from `lodash`; this CLI ships three runtime
4
+ * dependencies on purpose, and these three predicates are a handful of lines.
5
+ *
6
+ * Semantics match lodash's for every value this code path can see (JSON
7
+ * parsed off the wire): `isNumber` accepts the `number` primitive — lodash
8
+ * also accepts `Number` objects and `NaN`, neither of which `JSON.parse`
9
+ * ever produces — and `isPlainObject` accepts an object literal or a
10
+ * null-prototype object, rejecting arrays and `null`.
11
+ */
12
+ export function isString(value) {
13
+ return typeof value === 'string';
14
+ }
15
+ export function isNumber(value) {
16
+ return typeof value === 'number';
17
+ }
18
+ export function isPlainObject(value) {
19
+ if (typeof value !== 'object' || value === null)
20
+ return false;
21
+ const proto = Object.getPrototypeOf(value);
22
+ return proto === null || proto === Object.prototype;
23
+ }
24
+ //# sourceMappingURL=lodash-lite.js.map
@@ -0,0 +1,60 @@
1
+ import { Duplex } from "node:stream";
2
+ /**
3
+ * Hard upper bound on a single length-prefixed tunnel protocol frame. Checked BEFORE
4
+ * `readExactly(stream, bodyLen)` runs, because `bodyLen` is a big-endian u32 read straight off
5
+ * the wire from a peer that has not authenticated yet — without a cap, a malicious/garbled length
6
+ * makes `readExactly` buffer an unbounded number of chunks trying to reach it. This is exactly how
7
+ * dev crashed on 2026-08-14: a stray HTTP request landed on the tunnel port, and its first four
8
+ * bytes (`b"GET "`), interpreted as a length prefix, decoded to 1_195_725_856.
9
+ *
10
+ * Real payloads are a few hundred bytes of JSON (a UUID, a short secret, a couple of prefixed ids
11
+ * and a hostname) — 64 KiB leaves well over 100x headroom. Mirrors the Rust side's
12
+ * `MAX_TUNNEL_FRAME` (`src/protocol/tunnel.rs`); the two must stay in sync.
13
+ */
14
+ export declare const MAX_TUNNEL_FRAME: number;
15
+ /**
16
+ * How long a peer gets to finish sending one length-prefixed frame, counted from when we start
17
+ * waiting for its length prefix. Bounds a "length prefix is valid and small, but the body trickles
18
+ * in one byte every 30 seconds" (slowloris-style) connection from pinning a read forever. Mirrors
19
+ * the Rust side's `FRAME_READ_TIMEOUT`.
20
+ */
21
+ export declare const FRAME_READ_TIMEOUT_MS = 10000;
22
+ export declare enum ControlClientMsgType {
23
+ Auth = "Auth",
24
+ Heartbeat = "Heartbeat"
25
+ }
26
+ export interface ControlClientMsgAuth {
27
+ type: ControlClientMsgType.Auth;
28
+ payload: {
29
+ secret: string;
30
+ };
31
+ }
32
+ export interface ControlClientMsgHeartbeat {
33
+ type: ControlClientMsgType.Heartbeat;
34
+ }
35
+ export type ControlClientMsg = ControlClientMsgAuth;
36
+ export declare enum ControlServerMsgType {
37
+ Ack = "Ack",
38
+ CloseTunnel = "CloseTunnel",
39
+ RequestTunnel = "RequestTunnel"
40
+ }
41
+ export interface ControlServerMessageAck {
42
+ type: ControlServerMsgType.Ack;
43
+ }
44
+ export interface ControlServerMessageCloseTunnel {
45
+ type: ControlServerMsgType.CloseTunnel;
46
+ payload: {
47
+ reason?: string;
48
+ };
49
+ }
50
+ export interface ControlServerMessageRequestTunnel {
51
+ type: ControlServerMsgType.RequestTunnel;
52
+ payload: {
53
+ tunnel_connection_id: string;
54
+ };
55
+ }
56
+ export type ControlServerMsg = ControlServerMessageAck | ControlServerMessageRequestTunnel | ControlServerMessageCloseTunnel;
57
+ export declare function encodeFrame(obj: unknown): Buffer;
58
+ export declare function readFrame(stream: Duplex): Promise<unknown>;
59
+ export declare function readTypedFrame<T>(stream: Duplex, validator: (value: unknown) => value is T): Promise<T>;
60
+ export declare function readExactly(stream: Duplex, bytes: number, signal?: AbortSignal): Promise<Buffer>;
@@ -0,0 +1,143 @@
1
+ /**
2
+ * Hard upper bound on a single length-prefixed tunnel protocol frame. Checked BEFORE
3
+ * `readExactly(stream, bodyLen)` runs, because `bodyLen` is a big-endian u32 read straight off
4
+ * the wire from a peer that has not authenticated yet — without a cap, a malicious/garbled length
5
+ * makes `readExactly` buffer an unbounded number of chunks trying to reach it. This is exactly how
6
+ * dev crashed on 2026-08-14: a stray HTTP request landed on the tunnel port, and its first four
7
+ * bytes (`b"GET "`), interpreted as a length prefix, decoded to 1_195_725_856.
8
+ *
9
+ * Real payloads are a few hundred bytes of JSON (a UUID, a short secret, a couple of prefixed ids
10
+ * and a hostname) — 64 KiB leaves well over 100x headroom. Mirrors the Rust side's
11
+ * `MAX_TUNNEL_FRAME` (`src/protocol/tunnel.rs`); the two must stay in sync.
12
+ */
13
+ export const MAX_TUNNEL_FRAME = 64 * 1024;
14
+ /**
15
+ * How long a peer gets to finish sending one length-prefixed frame, counted from when we start
16
+ * waiting for its length prefix. Bounds a "length prefix is valid and small, but the body trickles
17
+ * in one byte every 30 seconds" (slowloris-style) connection from pinning a read forever. Mirrors
18
+ * the Rust side's `FRAME_READ_TIMEOUT`.
19
+ */
20
+ export const FRAME_READ_TIMEOUT_MS = 10_000;
21
+ export var ControlClientMsgType;
22
+ (function (ControlClientMsgType) {
23
+ ControlClientMsgType["Auth"] = "Auth";
24
+ ControlClientMsgType["Heartbeat"] = "Heartbeat";
25
+ })(ControlClientMsgType || (ControlClientMsgType = {}));
26
+ export var ControlServerMsgType;
27
+ (function (ControlServerMsgType) {
28
+ ControlServerMsgType["Ack"] = "Ack";
29
+ ControlServerMsgType["CloseTunnel"] = "CloseTunnel";
30
+ ControlServerMsgType["RequestTunnel"] = "RequestTunnel";
31
+ })(ControlServerMsgType || (ControlServerMsgType = {}));
32
+ export function encodeFrame(obj) {
33
+ const body = Buffer.from(JSON.stringify(obj), "utf8");
34
+ const header = Buffer.allocUnsafe(4);
35
+ header.writeUInt32BE(body.length, 0);
36
+ return Buffer.concat([header, body]);
37
+ }
38
+ export async function readFrame(stream) {
39
+ const controller = new AbortController();
40
+ const timer = setTimeout(() => {
41
+ controller.abort(new Error(`timed out after ${FRAME_READ_TIMEOUT_MS}ms reading tunnel frame`));
42
+ }, FRAME_READ_TIMEOUT_MS);
43
+ try {
44
+ const lenBuf = await readExactly(stream, 4, controller.signal);
45
+ const bodyLen = lenBuf.readUInt32BE(0);
46
+ // Checked BEFORE the body read, which is what would otherwise buffer an unbounded number
47
+ // of chunks trying to reach `bodyLen` — see `MAX_TUNNEL_FRAME`'s doc comment.
48
+ if (bodyLen > MAX_TUNNEL_FRAME) {
49
+ throw new Error(`tunnel frame length ${bodyLen} exceeds the ${MAX_TUNNEL_FRAME}-byte limit`);
50
+ }
51
+ const body = await readExactly(stream, bodyLen, controller.signal);
52
+ const jsonText = body.toString("utf8");
53
+ return JSON.parse(jsonText);
54
+ }
55
+ finally {
56
+ clearTimeout(timer);
57
+ }
58
+ }
59
+ export async function readTypedFrame(stream, validator) {
60
+ const value = await readFrame(stream);
61
+ if (!validator(value)) {
62
+ throw new Error("Invalid frame payload");
63
+ }
64
+ return value;
65
+ }
66
+ // Exported so a test can call it directly: with `bytes === 0`, `onReadable`'s
67
+ // `while (total < bytes)` loop body never runs (`0 < 0` is false), so without this
68
+ // special case the promise below would never settle on its own -- unlike Rust's
69
+ // `read_exact`, which returns `Ok(())` immediately for a zero-length read. In production this
70
+ // surfaces as a 0-length frame (an in-range but never-realistic length prefix) hanging for the
71
+ // full `FRAME_READ_TIMEOUT` instead of resolving at once.
72
+ export function readExactly(stream, bytes, signal) {
73
+ if (bytes <= 0) {
74
+ return Promise.resolve(Buffer.alloc(0));
75
+ }
76
+ return new Promise((resolve, reject) => {
77
+ let chunks = [];
78
+ let total = 0;
79
+ const cleanup = () => {
80
+ stream.off("readable", onReadable);
81
+ stream.off("error", onError);
82
+ stream.off("end", onEnd);
83
+ stream.off("close", onClose);
84
+ signal?.removeEventListener("abort", onAbort);
85
+ };
86
+ const finish = () => {
87
+ const merged = Buffer.concat(chunks, total);
88
+ const wanted = merged.subarray(0, bytes);
89
+ const remaining = merged.subarray(bytes);
90
+ if (remaining.length > 0) {
91
+ stream.unshift(remaining);
92
+ }
93
+ cleanup();
94
+ resolve(wanted);
95
+ };
96
+ const onReadable = () => {
97
+ while (total < bytes) {
98
+ const chunk = stream.read(bytes - total);
99
+ if (!chunk) {
100
+ return;
101
+ }
102
+ chunks.push(chunk);
103
+ total += chunk.length;
104
+ if (total >= bytes) {
105
+ finish();
106
+ return;
107
+ }
108
+ }
109
+ };
110
+ const onError = (err) => {
111
+ cleanup();
112
+ reject(err);
113
+ };
114
+ const onEnd = () => {
115
+ cleanup();
116
+ reject(new Error("Stream ended before enough bytes were read"));
117
+ };
118
+ const onClose = () => {
119
+ cleanup();
120
+ reject(new Error("Stream closed before enough bytes were read"));
121
+ };
122
+ // Lets `readFrame`'s timeout actually stop this read (removing all listeners) instead of
123
+ // just racing it: without this, a slowloris peer that never sends enough bytes leaves
124
+ // this promise — and its listeners on `stream` — alive forever after the caller times out.
125
+ const onAbort = () => {
126
+ cleanup();
127
+ reject(signal?.reason ?? new Error("aborted"));
128
+ };
129
+ if (signal) {
130
+ if (signal.aborted) {
131
+ onAbort();
132
+ return;
133
+ }
134
+ signal.addEventListener("abort", onAbort);
135
+ }
136
+ stream.on("readable", onReadable);
137
+ stream.on("error", onError);
138
+ stream.on("end", onEnd);
139
+ stream.on("close", onClose);
140
+ onReadable();
141
+ });
142
+ }
143
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1,101 @@
1
+ export type LogLevel = "debug" | "info" | "warn" | "error";
2
+ export declare enum ErrCode {
3
+ AuthFailed = "0001",
4
+ ControlDisconnected = "0002",
5
+ TunnelDisconnected = "0003",
6
+ TargetConnectFailed = "0004",
7
+ StreamFailed = "0005",
8
+ BlockedTargetRejected = "0006"
9
+ }
10
+ export interface TunnelClientError {
11
+ code: ErrCode;
12
+ message: string;
13
+ }
14
+ export interface TunnelClientOptions {
15
+ clientId: string;
16
+ secret: string;
17
+ /**
18
+ * VENDOR DELTA: required, not optional. The endpoint defaults upstream
19
+ * carries are hard-coded TestSprite dev hostnames; they are gone here and
20
+ * both values come from `POST /api/cli/v1/tunnel`. See ./config.ts.
21
+ */
22
+ controlUrl: string;
23
+ /** VENDOR DELTA: required. `host:port` of the tunnel DATA plane. */
24
+ tunnelAddr: string;
25
+ /**
26
+ * VENDOR DELTA: maximum time `start()` waits for the current control
27
+ * connection's first Ack, which is the server's authentication acknowledgement.
28
+ */
29
+ authTimeoutMs?: number;
30
+ heartbeatMs?: number;
31
+ reconnectMs?: number;
32
+ logLevel?: LogLevel;
33
+ /**
34
+ * Allow a proxied target to resolve into the private address space (RFC1918, CGNAT,
35
+ * link-local incl. cloud metadata, IPv6 ULA/link-local). Off by default.
36
+ *
37
+ * Loopback and public targets are always allowed and are NOT gated by this flag: the browser
38
+ * under test proxies every request through this tunnel (Chromium `bypass='<-loopback>'`), so a
39
+ * page pulling a web font or calling a third-party API is normal traffic, not abuse. What this
40
+ * gates is the pivot — `target_host`/`target_port` are relayed verbatim from the inbound proxy
41
+ * request on the internet-facing proxy port, so nothing otherwise stops a crafted request from
42
+ * steering this client at hosts it can only reach from inside your network. Mirrors the Rust
43
+ * client's `--allow-private-network-target` / `TS_TUNNEL_ALLOW_PRIVATE_NETWORK_TARGET`;
44
+ * enabling it removes a safety rail, it is not a network sandbox.
45
+ */
46
+ allowPrivateNetworkTarget?: boolean;
47
+ onError?(e: TunnelClientError): void;
48
+ /**
49
+ * VENDOR DELTA (not upstream): where log lines go. Upstream writes them to
50
+ * `console.log`/`console.warn`, i.e. STDOUT, which would corrupt this CLI's
51
+ * `--output json` contract. Absent -> stderr.
52
+ */
53
+ logSink?(level: LogLevel, line: string): void;
54
+ }
55
+ export type ClientToServerControlMessage = {
56
+ type: "Auth";
57
+ payload: {
58
+ secret: string;
59
+ };
60
+ } | {
61
+ type: "Hello";
62
+ payload: {
63
+ client_id: string;
64
+ version: string;
65
+ };
66
+ } | {
67
+ type: "Heartbeat";
68
+ } | {
69
+ type: "Status";
70
+ payload: {
71
+ status: "Offline" | "Online";
72
+ };
73
+ };
74
+ export type ServerToClientControlMessage = {
75
+ type: "Ack";
76
+ } | {
77
+ type: "RequestTunnel";
78
+ payload: {
79
+ tunnel_connection_id: string;
80
+ target_host: string;
81
+ target_port: number;
82
+ };
83
+ } | {
84
+ type: "CloseTunnel";
85
+ payload: {
86
+ reason: string;
87
+ };
88
+ };
89
+ export interface TunnelHelloFrame {
90
+ client_id: string;
91
+ secret: string;
92
+ tunnel_connection_id: string;
93
+ }
94
+ export interface StreamOpenRequestFrame {
95
+ request_id: string;
96
+ inbound_request_id: string;
97
+ tunnel_connection_id: string;
98
+ mux_stream_id: number;
99
+ target_host: string;
100
+ target_port: number;
101
+ }
@@ -0,0 +1,10 @@
1
+ export var ErrCode;
2
+ (function (ErrCode) {
3
+ ErrCode["AuthFailed"] = "0001";
4
+ ErrCode["ControlDisconnected"] = "0002";
5
+ ErrCode["TunnelDisconnected"] = "0003";
6
+ ErrCode["TargetConnectFailed"] = "0004";
7
+ ErrCode["StreamFailed"] = "0005";
8
+ ErrCode["BlockedTargetRejected"] = "0006";
9
+ })(ErrCode || (ErrCode = {}));
10
+ //# sourceMappingURL=types.js.map