|
| 1 | +import { ChildProcess } from 'child_process'; |
| 2 | + |
| 3 | +export interface TunnelOptions { |
| 4 | + /** TestingBot API key */ |
| 5 | + apiKey?: string; |
| 6 | + /** TestingBot API secret */ |
| 7 | + apiSecret?: string; |
| 8 | + /** Enable verbose output */ |
| 9 | + verbose?: boolean; |
| 10 | + /** Port for the Selenium relay (default: 4445) */ |
| 11 | + 'se-port'?: number; |
| 12 | + /** Upstream proxy host and port (e.g. "localhost:1234") */ |
| 13 | + proxy?: string; |
| 14 | + /** Comma-separated list of domains to bypass the tunnel */ |
| 15 | + 'fast-fail-regexps'?: string; |
| 16 | + /** Path to write log output */ |
| 17 | + logfile?: string; |
| 18 | + /** Specific tunnel version to use */ |
| 19 | + tunnelVersion?: string; |
| 20 | + /** Unique identifier for this tunnel */ |
| 21 | + tunnelIdentifier?: string; |
| 22 | + /** Share tunnel with team members */ |
| 23 | + shared?: boolean; |
| 24 | + /** Timeout in seconds for tunnel to start (default: 90) */ |
| 25 | + timeout?: number; |
| 26 | + /** Disable SSL bumping/rewriting */ |
| 27 | + noBump?: boolean; |
| 28 | + /** Disable caching */ |
| 29 | + noCache?: boolean; |
| 30 | +} |
| 31 | + |
| 32 | +export interface TunnelProcess extends ChildProcess { |
| 33 | + /** Close the tunnel */ |
| 34 | + close(callback?: () => void): void; |
| 35 | + /** Error message if tunnel failed to start */ |
| 36 | + error?: string; |
| 37 | +} |
| 38 | + |
| 39 | +export interface JavaVersionResult { |
| 40 | + version: number | null; |
| 41 | +} |
| 42 | + |
| 43 | +export interface JavaValidationResult { |
| 44 | + valid: boolean; |
| 45 | + version: number | null; |
| 46 | + error: string | null; |
| 47 | +} |
| 48 | + |
| 49 | +/** |
| 50 | + * Download and launch the TestingBot Tunnel (callback version) |
| 51 | + */ |
| 52 | +declare function downloadAndRun( |
| 53 | + options: TunnelOptions, |
| 54 | + callback: (err: Error | null, tunnel?: TunnelProcess) => void |
| 55 | +): void; |
| 56 | + |
| 57 | +declare namespace downloadAndRun { |
| 58 | + /** |
| 59 | + * Kill the active tunnel (callback version) |
| 60 | + */ |
| 61 | + export function kill(callback?: (err: Error | null) => void): void; |
| 62 | + |
| 63 | + /** |
| 64 | + * Download and launch the TestingBot Tunnel (async version) |
| 65 | + */ |
| 66 | + export function downloadAndRunAsync(options?: TunnelOptions): Promise<TunnelProcess>; |
| 67 | + |
| 68 | + /** |
| 69 | + * Kill the active tunnel (async version) |
| 70 | + */ |
| 71 | + export function killAsync(): Promise<void>; |
| 72 | + |
| 73 | + /** |
| 74 | + * Download the tunnel JAR file |
| 75 | + */ |
| 76 | + export function downloadAsync(options?: TunnelOptions): Promise<void>; |
| 77 | + |
| 78 | + /** |
| 79 | + * Start the tunnel process (requires JAR to be downloaded first) |
| 80 | + */ |
| 81 | + export function startTunnelAsync(options?: TunnelOptions): Promise<TunnelProcess>; |
| 82 | + |
| 83 | + /** |
| 84 | + * Check if Java is installed and meets minimum version requirement |
| 85 | + */ |
| 86 | + export function checkJava(): Promise<JavaVersionResult>; |
| 87 | + |
| 88 | + /** |
| 89 | + * Parse Java version from version output string |
| 90 | + */ |
| 91 | + export function parseJavaVersion(versionOutput: string): number | null; |
| 92 | + |
| 93 | + /** |
| 94 | + * Validate Java version meets minimum requirement |
| 95 | + */ |
| 96 | + export function validateJavaVersion(versionOutput: string): JavaValidationResult; |
| 97 | + |
| 98 | + /** |
| 99 | + * Validate options object |
| 100 | + * @throws {Error} If options are invalid |
| 101 | + */ |
| 102 | + export function validateOptions(options: TunnelOptions): void; |
| 103 | + |
| 104 | + /** |
| 105 | + * Create command line arguments from options |
| 106 | + */ |
| 107 | + export function createArgs(options: TunnelOptions): string[]; |
| 108 | +} |
| 109 | + |
| 110 | +export = downloadAndRun; |
0 commit comments