pinggy 0.3.4 → 0.3.6

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 (68) hide show
  1. package/README.md +1 -1
  2. package/dist/chunk-65R2GMKQ.js +2101 -0
  3. package/dist/index.cjs +1814 -1362
  4. package/dist/index.d.cts +616 -0
  5. package/dist/index.d.ts +616 -0
  6. package/dist/index.js +38 -55
  7. package/dist/{main-CZY6GID4.js → main-2QDG7PWL.js} +229 -1726
  8. package/package.json +3 -4
  9. package/.github/workflows/npm-publish-github-packages.yml +0 -34
  10. package/.github/workflows/publish-binaries.yml +0 -223
  11. package/Makefile +0 -4
  12. package/caxa_build.js +0 -24
  13. package/dist/chunk-T5ESYDJY.js +0 -121
  14. package/ent.plist +0 -14
  15. package/jest.config.js +0 -19
  16. package/src/_tests_/build_config.test.ts +0 -91
  17. package/src/cli/buildConfig.ts +0 -475
  18. package/src/cli/defaults.ts +0 -20
  19. package/src/cli/extendedOptions.ts +0 -153
  20. package/src/cli/help.ts +0 -43
  21. package/src/cli/options.ts +0 -50
  22. package/src/cli/starCli.ts +0 -229
  23. package/src/index.ts +0 -30
  24. package/src/logger.ts +0 -138
  25. package/src/main.ts +0 -87
  26. package/src/remote_management/handler.ts +0 -244
  27. package/src/remote_management/remoteManagement.ts +0 -226
  28. package/src/remote_management/remote_schema.ts +0 -176
  29. package/src/remote_management/websocket_handlers.ts +0 -180
  30. package/src/tui/blessed/TunnelTui.ts +0 -340
  31. package/src/tui/blessed/components/DisplayUpdaters.ts +0 -189
  32. package/src/tui/blessed/components/KeyBindings.ts +0 -236
  33. package/src/tui/blessed/components/Modals.ts +0 -302
  34. package/src/tui/blessed/components/UIComponents.ts +0 -306
  35. package/src/tui/blessed/components/index.ts +0 -4
  36. package/src/tui/blessed/config.ts +0 -53
  37. package/src/tui/blessed/headerFetcher.ts +0 -42
  38. package/src/tui/blessed/index.ts +0 -2
  39. package/src/tui/blessed/qrCodeGenerator.ts +0 -20
  40. package/src/tui/blessed/webDebuggerConnection.ts +0 -128
  41. package/src/tui/ink/asciArt.ts +0 -7
  42. package/src/tui/ink/hooks/useQrCodes.ts +0 -27
  43. package/src/tui/ink/hooks/useReqResHeaders.ts +0 -27
  44. package/src/tui/ink/hooks/useTerminalSize.ts +0 -26
  45. package/src/tui/ink/hooks/useTerminalStats.ts +0 -24
  46. package/src/tui/ink/hooks/useWebDebugger.ts +0 -98
  47. package/src/tui/ink/index.tsx +0 -243
  48. package/src/tui/ink/layout/Borders.tsx +0 -15
  49. package/src/tui/ink/layout/Container.tsx +0 -15
  50. package/src/tui/ink/sections/DebuggerDetailModal.tsx +0 -53
  51. package/src/tui/ink/sections/KeyBindings.tsx +0 -58
  52. package/src/tui/ink/sections/QrCodeSection.tsx +0 -28
  53. package/src/tui/ink/sections/StatsSection.tsx +0 -20
  54. package/src/tui/ink/sections/URLsSection.tsx +0 -53
  55. package/src/tui/ink/utils/utils.ts +0 -35
  56. package/src/tui/spinner/spinner.ts +0 -64
  57. package/src/tunnel_manager/TunnelManager.ts +0 -1212
  58. package/src/types.ts +0 -255
  59. package/src/utils/FileServer.ts +0 -112
  60. package/src/utils/detect_vc_redist_on_windows.ts +0 -167
  61. package/src/utils/getFreePort.ts +0 -41
  62. package/src/utils/htmlTemplates.ts +0 -146
  63. package/src/utils/parseArgs.ts +0 -79
  64. package/src/utils/printer.ts +0 -81
  65. package/src/utils/util.ts +0 -18
  66. package/src/workers/file_serve_worker.ts +0 -33
  67. package/tsconfig.json +0 -17
  68. package/tsup.config.ts +0 -12
package/dist/index.d.ts CHANGED
@@ -1 +1,617 @@
1
1
  #!/usr/bin/env node
2
+ import { PinggyOptions, TunnelUsageType, TunnelInstance, TunnelType } from '@pinggy/pinggy';
3
+ import { Worker } from 'node:worker_threads';
4
+ import { z } from 'zod';
5
+ import winston from 'winston';
6
+
7
+ interface AdditionalForwarding {
8
+ localDomain: string;
9
+ localPort: number;
10
+ remoteDomain?: string;
11
+ remotePort?: number;
12
+ protocol?: 'http' | 'tcp' | 'udp' | 'tls';
13
+ }
14
+ interface TunnelStatus {
15
+ tunnelid: string;
16
+ remoteurls: string[];
17
+ tunnelconfig: PinggyOptions;
18
+ status: Status;
19
+ stats: TunnelUsageType;
20
+ }
21
+ declare enum TunnelStateType {
22
+ New = "idle",
23
+ Starting = "starting",
24
+ Running = "running",
25
+ Live = "live",
26
+ Closed = "closed",
27
+ Exited = "exited"
28
+ }
29
+ declare enum TunnelErrorCodeType {
30
+ NonResponsive = "non_responsive",
31
+ FailedToConnect = "failed_to_connect",
32
+ ErrorInAdditionalForwarding = "additional_forwarding_error",
33
+ WebdebuggerError = "webdebugger_error",
34
+ NoError = ""
35
+ }
36
+ declare enum TunnelWarningCode {
37
+ InvalidTunnelServePath = "INVALID_TUNNEL_SERVE_PATH",
38
+ UnknownWarning = "UNKNOWN_WARNING"
39
+ }
40
+ interface Warning {
41
+ code: TunnelWarningCode;
42
+ message: string;
43
+ }
44
+ interface Status {
45
+ state: TunnelStateType;
46
+ errorcode: TunnelErrorCodeType;
47
+ errormsg: string;
48
+ createdtimestamp: string;
49
+ starttimestamp: string;
50
+ endtimestamp: string;
51
+ warnings: Warning[];
52
+ }
53
+ type FinalConfig = (PinggyOptions & {
54
+ configid: string;
55
+ }) & {
56
+ tunnelType: string[];
57
+ conf?: string;
58
+ saveconf?: string;
59
+ serve?: string;
60
+ remoteManagement?: string;
61
+ additionalForwarding?: AdditionalForwarding[];
62
+ manage?: string;
63
+ version?: boolean;
64
+ NoTUI?: boolean;
65
+ qrCode?: boolean;
66
+ };
67
+ type ErrorCodeType = "INVALID_REQUEST_METHOD" | "COULD_NOT_READ_BODY" | "INTERNAL_SERVER_ERROR" | "INVALID_DATA_FORMAT" | "ERROR_STARTING_TUNNEL" | "TUNNEL_WITH_ID_OR_CONFIG_ID_NOT_FOUND" | "TUNNEL_WITH_ID_OR_CONFIG_ID_ALREADY_RUNNING" | "WEBSOCKET_UPGRADE_FAILED" | "REMOTE_MANAGEMENT_ALREADY_RUNNING" | "REMOTE_MANAGEMENT_NOT_RUNNING" | "REMOTE_MANAGEMENT_DESERIALIZATION_FAILED";
68
+ interface ErrorResponse {
69
+ code: ErrorCodeType;
70
+ message: string;
71
+ }
72
+ type RemoteManagementStatusType = "CONNECTING" | "DISCONNECTING" | "RECONNECTING" | "RUNNING" | "NOT_RUNNING" | "ERROR";
73
+ interface RemoteManagementState {
74
+ status: RemoteManagementStatusType;
75
+ errorMessage: string;
76
+ }
77
+
78
+ /**
79
+ * Manages the lifecycle and state of multiple tunnel instances.
80
+ * Implements the Singleton pattern to ensure only one tunnel manager exists in the application.
81
+ *
82
+ * @remarks
83
+ * This class provides comprehensive tunnel management capabilities including:
84
+ * - Creation and initialization of tunnels
85
+ * - Starting and stopping tunnels
86
+ * - Managing tunnel configurations and states
87
+ * - Handling additional forwarding rules
88
+ * - Monitoring tunnel status
89
+ *
90
+ * @sealed
91
+ * @singleton
92
+ */
93
+
94
+ interface ManagedTunnel {
95
+ tunnelid: string;
96
+ configid: string;
97
+ tunnelName?: string;
98
+ instance: TunnelInstance;
99
+ tunnelConfig?: PinggyOptions;
100
+ configWithForwarding?: PinggyOptions;
101
+ additionalForwarding?: AdditionalForwarding[];
102
+ serveWorker?: Worker | null;
103
+ warnings?: Warning[];
104
+ serve?: string;
105
+ isStopped?: boolean;
106
+ createdAt?: string;
107
+ startedAt?: string | null;
108
+ stoppedAt?: string | null;
109
+ autoReconnect?: boolean;
110
+ }
111
+ interface TunnelList {
112
+ tunnelid: string;
113
+ configid: string;
114
+ tunnelName?: string;
115
+ tunnelConfig: PinggyOptions;
116
+ remoteurls: string[];
117
+ additionalForwarding?: AdditionalForwarding[];
118
+ serve?: string;
119
+ }
120
+ type StatsListener = (tunnelId: string, stats: TunnelUsageType) => void;
121
+ type ErrorListener = (tunnelId: string, errorMsg: string, isFatal: boolean) => void;
122
+ type DisconnectListener = (tunnelId: string, error: string, messages: string[]) => void;
123
+ type TunnelWorkerErrorListner = (tunnelid: string, error: Error) => void;
124
+ type StartListener = (tunnelId: string, urls: string[]) => void;
125
+ type WillReconnectListener = (tunnelId: string, error: string, messages: string[]) => void;
126
+ type ReconnectingListener = (tunnelId: string, retryCnt: number) => void;
127
+ type ReconnectionCompletedListener = (tunnelId: string, urls: string[]) => void;
128
+ type ReconnectionFailedListener = (tunnelId: string, retryCnt: number) => void;
129
+ interface ITunnelManager {
130
+ createTunnel(config: (PinggyOptions & {
131
+ configid: string;
132
+ tunnelid?: string;
133
+ tunnelName?: string;
134
+ }) & {
135
+ additionalForwarding?: AdditionalForwarding[];
136
+ }): Promise<ManagedTunnel>;
137
+ startTunnel(tunnelId: string): Promise<string[]>;
138
+ stopTunnel(tunnelId: string): {
139
+ configid: string;
140
+ tunnelid: string;
141
+ };
142
+ stopAllTunnels(): void;
143
+ getTunnelUrls(tunnelId: string): Promise<string[]>;
144
+ getAllTunnels(): Promise<TunnelList[]>;
145
+ getTunnelStatus(tunnelId: string): Promise<string>;
146
+ getTunnelInstance(configId?: string, tunnelId?: string): TunnelInstance;
147
+ getTunnelConfig(configId?: string, tunnelId?: string): Promise<PinggyOptions>;
148
+ restartTunnel(tunnelId: string): Promise<void>;
149
+ updateConfig(newConfig: PinggyOptions & {
150
+ configid: string;
151
+ additionalForwarding?: AdditionalForwarding[];
152
+ tunnelName?: string;
153
+ }): Promise<ManagedTunnel>;
154
+ getManagedTunnel(configId?: string, tunnelId?: string): ManagedTunnel;
155
+ getTunnelGreetMessage(tunnelId: string): Promise<string | null>;
156
+ getTunnelStats(tunnelId: string): TunnelUsageType[] | null;
157
+ getLatestTunnelStats(tunnelId: string): TunnelUsageType | null;
158
+ registerStatsListener(tunnelId: string, listener: StatsListener): Promise<[string, string]>;
159
+ registerErrorListener(tunnelId: string, listener: ErrorListener): Promise<string>;
160
+ registerWorkerErrorListner(tunnelId: string, listener: TunnelWorkerErrorListner): void;
161
+ registerStartListener(tunnelId: string, listener: StartListener): Promise<string>;
162
+ deregisterErrorListener(tunnelId: string, listenerId: string): void;
163
+ registerDisconnectListener(tunnelId: string, listener: DisconnectListener): Promise<string>;
164
+ deregisterDisconnectListener(tunnelId: string, listenerId: string): void;
165
+ deregisterStatsListener(tunnelId: string, listenerId: string): void;
166
+ getLocalserverTlsInfo(tunnelId: string): Promise<string | boolean>;
167
+ removeStoppedTunnelByTunnelId(tunnelId: string): boolean;
168
+ removeStoppedTunnelByConfigId(configId: string): boolean;
169
+ registerWillReconnectListener(tunnelId: string, listener: WillReconnectListener): Promise<string>;
170
+ deregisterWillReconnectListener(tunnelId: string, listenerId: string): void;
171
+ registerReconnectingListener(tunnelId: string, listener: ReconnectingListener): Promise<string>;
172
+ deregisterReconnectingListener(tunnelId: string, listenerId: string): void;
173
+ registerReconnectionCompletedListener(tunnelId: string, listener: ReconnectionCompletedListener): Promise<string>;
174
+ deregisterReconnectionCompletedListener(tunnelId: string, listenerId: string): void;
175
+ registerReconnectionFailedListener(tunnelId: string, listener: ReconnectionFailedListener): Promise<string>;
176
+ deregisterReconnectionFailedListener(tunnelId: string, listenerId: string): void;
177
+ }
178
+ declare class TunnelManager implements ITunnelManager {
179
+ private static instance;
180
+ private tunnelsByTunnelId;
181
+ private tunnelsByConfigId;
182
+ private tunnelStats;
183
+ private tunnelStatsListeners;
184
+ private tunnelErrorListeners;
185
+ private tunnelDisconnectListeners;
186
+ private tunnelWorkerErrorListeners;
187
+ private tunnelStartListeners;
188
+ private tunnelWillReconnectListeners;
189
+ private tunnelReconnectingListeners;
190
+ private tunnelReconnectionCompletedListeners;
191
+ private tunnelReconnectionFailedListeners;
192
+ private constructor();
193
+ static getInstance(): TunnelManager;
194
+ /**
195
+ * Creates a new managed tunnel instance with the given configuration.
196
+ * Builds the config with forwarding rules and creates the tunnel instance.
197
+ *
198
+ * @param config - The tunnel configuration options
199
+ * @param config.configid - Unique identifier for the tunnel configuration
200
+ * @param config.tunnelid - Optional custom tunnel identifier. If not provided, a random UUID will be generated
201
+ * @param config.additionalForwarding - Optional array of additional forwarding configurations
202
+ *
203
+ * @throws {Error} When configId is invalid or empty
204
+ * @throws {Error} When a tunnel with the given configId already exists
205
+ *
206
+ * @returns {ManagedTunnel} A new managed tunnel instance containing the tunnel details,
207
+ * status information, and statistics
208
+ */
209
+ createTunnel(config: (PinggyOptions & {
210
+ tunnelType: string[] | undefined;
211
+ } & {
212
+ configid: string;
213
+ tunnelid?: string;
214
+ tunnelName?: string;
215
+ }) & {
216
+ additionalForwarding?: AdditionalForwarding[];
217
+ } & {
218
+ serve?: string;
219
+ }): Promise<ManagedTunnel>;
220
+ /**
221
+ * Internal method to create a tunnel with an already-processed configuration.
222
+ * This is used by createTunnel, restartTunnel, and updateConfig to avoid config processing.
223
+ *
224
+ * @param params - Configuration parameters with already-processed forwarding rules
225
+ * @returns The created ManagedTunnel instance
226
+ * @private
227
+ */
228
+ private _createTunnelWithProcessedConfig;
229
+ /**
230
+ * Builds the Pinggy configuration by merging the default forwarding rule
231
+ * with additional forwarding rules from additionalForwarding array.
232
+ *
233
+ * @param config - The base Pinggy configuration
234
+ * @param additionalForwarding - Optional array of additional forwarding rules
235
+ * @returns Modified PinggyOptions
236
+ */
237
+ private buildPinggyConfig;
238
+ /**
239
+ * Start a tunnel that was created but not yet started
240
+ */
241
+ startTunnel(tunnelId: string): Promise<string[]>;
242
+ /**
243
+ * Stops a running tunnel and updates its status.
244
+ *
245
+ * @param tunnelId - The unique identifier of the tunnel to stop
246
+ * @throws {Error} If the tunnel with the given tunnelId is not found
247
+ * @remarks
248
+ * - Clears the tunnel's remote URLs
249
+ * - Updates the tunnel's state to Exited if stopped successfully
250
+ * - Logs the stop operation with tunnelId and configId
251
+ */
252
+ stopTunnel(tunnelId: string): {
253
+ configid: string;
254
+ tunnelid: string;
255
+ };
256
+ /**
257
+ * Get all public URLs for a tunnel
258
+ */
259
+ getTunnelUrls(tunnelId: string): Promise<string[]>;
260
+ /**
261
+ * Get all TunnelStatus currently managed by this TunnelManager
262
+ * @returns An array of all TunnelStatus objects
263
+ */
264
+ getAllTunnels(): Promise<TunnelList[]>;
265
+ /**
266
+ * Get status of a tunnel
267
+ */
268
+ getTunnelStatus(tunnelId: string): Promise<string>;
269
+ /**
270
+ * Stop all tunnels
271
+ */
272
+ stopAllTunnels(): void;
273
+ /**
274
+ * Remove a stopped tunnel's records so it will no longer be returned by list methods.
275
+ *
276
+ *
277
+ * @param tunnelId - the tunnel id to remove
278
+ * @returns true if the record was removed, false otherwise
279
+ */
280
+ removeStoppedTunnelByTunnelId(tunnelId: string): boolean;
281
+ /**
282
+ * Remove a stopped tunnel by its config id.
283
+ * @param configId - the config id to remove
284
+ * @returns true if the record was removed, false otherwise
285
+ */
286
+ removeStoppedTunnelByConfigId(configId: string): boolean;
287
+ private _cleanupTunnelRecords;
288
+ /**
289
+ * Get tunnel instance by either configId or tunnelId
290
+ * @param configId - The configuration ID of the tunnel
291
+ * @param tunnelId - The tunnel ID
292
+ * @returns The tunnel instance
293
+ * @throws Error if neither configId nor tunnelId is provided, or if tunnel is not found
294
+ */
295
+ getTunnelInstance(configId?: string, tunnelId?: string): TunnelInstance;
296
+ /**
297
+ * Get tunnel config by either configId or tunnelId
298
+ * @param configId - The configuration ID of the tunnel
299
+ * @param tunnelId - The tunnel ID
300
+ * @returns The tunnel config
301
+ * @throws Error if neither configId nor tunnelId is provided, or if tunnel is not found
302
+ */
303
+ getTunnelConfig(configId?: string, tunnelId?: string): Promise<PinggyOptions>;
304
+ /**
305
+ * Restarts a tunnel with its current configuration.
306
+ * This function will stop the tunnel if it's running and start it again.
307
+ * All configurations including additional forwarding rules are preserved.
308
+ */
309
+ restartTunnel(tunnelid: string): Promise<void>;
310
+ /**
311
+ * Updates the configuration of an existing tunnel.
312
+ *
313
+ * This method handles the process of updating a tunnel's configuration while preserving
314
+ * its state. If the tunnel is running, it will be stopped, updated, and restarted.
315
+ * In case of failure, it attempts to restore the original configuration.
316
+ *
317
+ * @param newConfig - The new configuration to apply, including configid and optional additional forwarding
318
+ *
319
+ * @returns Promise resolving to the updated ManagedTunnel
320
+ * @throws Error if the tunnel is not found or if the update process fails
321
+ */
322
+ updateConfig(newConfig: PinggyOptions & {
323
+ tunnelType: string[] | undefined;
324
+ } & {
325
+ configid: string;
326
+ additionalForwarding?: AdditionalForwarding[];
327
+ tunnelName?: string;
328
+ serve?: string;
329
+ }): Promise<ManagedTunnel>;
330
+ /**
331
+ * Retrieve the ManagedTunnel object by either configId or tunnelId.
332
+ * Throws an error if neither id is provided or the tunnel is not found.
333
+ */
334
+ getManagedTunnel(configId?: string, tunnelId?: string): ManagedTunnel;
335
+ getTunnelGreetMessage(tunnelId: string): Promise<string | null>;
336
+ getTunnelStats(tunnelId: string): TunnelUsageType[] | null;
337
+ getLatestTunnelStats(tunnelId: string): TunnelUsageType | null;
338
+ /**
339
+ * Registers a listener function to receive tunnel statistics updates.
340
+ * The listener will be called whenever any tunnel's stats are updated.
341
+ *
342
+ * @param tunnelId - The tunnel ID to listen to stats for
343
+ * @param listener - Function that receives tunnelId and stats when updates occur
344
+ * @returns A unique listener ID that can be used to deregister the listener and tunnelId
345
+ *
346
+ * @throws {Error} When the specified tunnelId does not exist
347
+ */
348
+ registerStatsListener(tunnelId: string, listener: StatsListener): Promise<[string, string]>;
349
+ registerErrorListener(tunnelId: string, listener: ErrorListener): Promise<string>;
350
+ registerDisconnectListener(tunnelId: string, listener: DisconnectListener): Promise<string>;
351
+ registerWorkerErrorListner(tunnelId: string, listener: TunnelWorkerErrorListner): Promise<void>;
352
+ registerStartListener(tunnelId: string, listener: StartListener): Promise<string>;
353
+ registerWillReconnectListener(tunnelId: string, listener: WillReconnectListener): Promise<string>;
354
+ registerReconnectingListener(tunnelId: string, listener: ReconnectingListener): Promise<string>;
355
+ registerReconnectionCompletedListener(tunnelId: string, listener: ReconnectionCompletedListener): Promise<string>;
356
+ registerReconnectionFailedListener(tunnelId: string, listener: ReconnectionFailedListener): Promise<string>;
357
+ /**
358
+ * Removes a previously registered stats listener.
359
+ *
360
+ * @param tunnelId - The tunnel ID the listener was registered for
361
+ * @param listenerId - The unique ID returned when the listener was registered
362
+ */
363
+ deregisterStatsListener(tunnelId: string, listenerId: string): void;
364
+ deregisterErrorListener(tunnelId: string, listenerId: string): void;
365
+ deregisterDisconnectListener(tunnelId: string, listenerId: string): void;
366
+ deregisterWillReconnectListener(tunnelId: string, listenerId: string): void;
367
+ deregisterReconnectingListener(tunnelId: string, listenerId: string): void;
368
+ deregisterReconnectionCompletedListener(tunnelId: string, listenerId: string): void;
369
+ deregisterReconnectionFailedListener(tunnelId: string, listenerId: string): void;
370
+ getLocalserverTlsInfo(tunnelId: string): Promise<string | false>;
371
+ /**
372
+ * Sets up the stats callback for a tunnel during creation.
373
+ * This callback will update stored stats and notify all registered listeners.
374
+ */
375
+ private setupStatsCallback;
376
+ private notifyErrorListeners;
377
+ private setupErrorCallback;
378
+ private setupDisconnectCallback;
379
+ /**
380
+ * Called when the tunnel disconnects and the SDK is about to start reconnecting.
381
+ * Notifies registered will-reconnect listeners.
382
+ */
383
+ private setupWillReconnectCallback;
384
+ /**
385
+ * Called for each reconnection attempt with the current retry count.
386
+ * Notifies registered reconnecting listeners.
387
+ */
388
+ private setupReconnectingCallback;
389
+ /**
390
+ * Called when reconnection succeeds. Updates tunnel state back to active,
391
+ * and notifies registered reconnection-completed and start listeners with new URLs.
392
+ */
393
+ private setupReconnectionCompletedCallback;
394
+ /**
395
+ * Called when all reconnection attempts are exhausted.
396
+ * Marks the tunnel as stopped and notifies registered reconnection-failed listeners.
397
+ */
398
+ private setupReconnectionFailedCallback;
399
+ private setUpTunnelWorkerErrorCallback;
400
+ /**
401
+ * Updates the stored stats for a tunnel and notifies all registered listeners.
402
+ */
403
+ private updateStats;
404
+ /**
405
+ * Normalizes raw usage data from the SDK into a consistent TunnelStats format.
406
+ */
407
+ private normalizeStats;
408
+ private parseNumber;
409
+ private startStaticFileServer;
410
+ }
411
+
412
+ declare const TunnelConfigSchema: z.ZodPipe<z.ZodObject<{
413
+ allowPreflight: z.ZodOptional<z.ZodBoolean>;
414
+ allowpreflight: z.ZodOptional<z.ZodBoolean>;
415
+ autoreconnect: z.ZodBoolean;
416
+ basicauth: z.ZodNullable<z.ZodArray<z.ZodObject<{
417
+ username: z.ZodString;
418
+ password: z.ZodString;
419
+ }, z.core.$strip>>>;
420
+ bearerauth: z.ZodNullable<z.ZodString>;
421
+ configid: z.ZodString;
422
+ configname: z.ZodString;
423
+ greetmsg: z.ZodOptional<z.ZodString>;
424
+ force: z.ZodBoolean;
425
+ forwardedhost: z.ZodString;
426
+ fullRequestUrl: z.ZodBoolean;
427
+ headermodification: z.ZodArray<z.ZodObject<{
428
+ key: z.ZodString;
429
+ value: z.ZodOptional<z.ZodArray<z.ZodString>>;
430
+ type: z.ZodEnum<{
431
+ add: "add";
432
+ remove: "remove";
433
+ update: "update";
434
+ }>;
435
+ }, z.core.$strip>>;
436
+ httpsOnly: z.ZodBoolean;
437
+ internalwebdebuggerport: z.ZodNumber;
438
+ ipwhitelist: z.ZodNullable<z.ZodArray<z.ZodString>>;
439
+ localport: z.ZodNumber;
440
+ localsservertls: z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>;
441
+ localservertlssni: z.ZodNullable<z.ZodString>;
442
+ regioncode: z.ZodString;
443
+ noReverseProxy: z.ZodBoolean;
444
+ serveraddress: z.ZodString;
445
+ serverport: z.ZodNumber;
446
+ statusCheckInterval: z.ZodNumber;
447
+ token: z.ZodString;
448
+ tunnelTimeout: z.ZodNumber;
449
+ type: z.ZodEnum<{
450
+ http: TunnelType.Http;
451
+ tcp: TunnelType.Tcp;
452
+ tls: TunnelType.Tls;
453
+ udp: TunnelType.Udp;
454
+ tlstcp: TunnelType.TlsTcp;
455
+ }>;
456
+ webdebuggerport: z.ZodNumber;
457
+ xff: z.ZodString;
458
+ additionalForwarding: z.ZodOptional<z.ZodArray<z.ZodObject<{
459
+ remoteDomain: z.ZodOptional<z.ZodString>;
460
+ remotePort: z.ZodOptional<z.ZodNumber>;
461
+ localDomain: z.ZodString;
462
+ localPort: z.ZodNumber;
463
+ }, z.core.$strip>>>;
464
+ serve: z.ZodOptional<z.ZodString>;
465
+ }, z.core.$strip>, z.ZodTransform<{
466
+ allowPreflight: boolean | undefined;
467
+ allowpreflight: boolean | undefined;
468
+ autoreconnect: boolean;
469
+ basicauth: {
470
+ username: string;
471
+ password: string;
472
+ }[] | null;
473
+ bearerauth: string | null;
474
+ configid: string;
475
+ configname: string;
476
+ force: boolean;
477
+ forwardedhost: string;
478
+ fullRequestUrl: boolean;
479
+ headermodification: {
480
+ key: string;
481
+ type: "add" | "remove" | "update";
482
+ value?: string[] | undefined;
483
+ }[];
484
+ httpsOnly: boolean;
485
+ internalwebdebuggerport: number;
486
+ ipwhitelist: string[] | null;
487
+ localport: number;
488
+ localsservertls: string | boolean;
489
+ localservertlssni: string | null;
490
+ regioncode: string;
491
+ noReverseProxy: boolean;
492
+ serveraddress: string;
493
+ serverport: number;
494
+ statusCheckInterval: number;
495
+ token: string;
496
+ tunnelTimeout: number;
497
+ type: TunnelType;
498
+ webdebuggerport: number;
499
+ xff: string;
500
+ greetmsg?: string | undefined;
501
+ additionalForwarding?: {
502
+ localDomain: string;
503
+ localPort: number;
504
+ remoteDomain?: string | undefined;
505
+ remotePort?: number | undefined;
506
+ }[] | undefined;
507
+ serve?: string | undefined;
508
+ }, {
509
+ autoreconnect: boolean;
510
+ basicauth: {
511
+ username: string;
512
+ password: string;
513
+ }[] | null;
514
+ bearerauth: string | null;
515
+ configid: string;
516
+ configname: string;
517
+ force: boolean;
518
+ forwardedhost: string;
519
+ fullRequestUrl: boolean;
520
+ headermodification: {
521
+ key: string;
522
+ type: "add" | "remove" | "update";
523
+ value?: string[] | undefined;
524
+ }[];
525
+ httpsOnly: boolean;
526
+ internalwebdebuggerport: number;
527
+ ipwhitelist: string[] | null;
528
+ localport: number;
529
+ localsservertls: string | boolean;
530
+ localservertlssni: string | null;
531
+ regioncode: string;
532
+ noReverseProxy: boolean;
533
+ serveraddress: string;
534
+ serverport: number;
535
+ statusCheckInterval: number;
536
+ token: string;
537
+ tunnelTimeout: number;
538
+ type: TunnelType;
539
+ webdebuggerport: number;
540
+ xff: string;
541
+ allowPreflight?: boolean | undefined;
542
+ allowpreflight?: boolean | undefined;
543
+ greetmsg?: string | undefined;
544
+ additionalForwarding?: {
545
+ localDomain: string;
546
+ localPort: number;
547
+ remoteDomain?: string | undefined;
548
+ remotePort?: number | undefined;
549
+ }[] | undefined;
550
+ serve?: string | undefined;
551
+ }>>;
552
+ type TunnelConfig = z.infer<typeof TunnelConfigSchema>;
553
+
554
+ interface TunnelResponse {
555
+ tunnelid: string;
556
+ remoteurls: string[];
557
+ tunnelconfig: TunnelConfig;
558
+ status: Status;
559
+ stats: TunnelUsageType;
560
+ }
561
+ interface TunnelHandler {
562
+ handleStart(config: TunnelConfig): Promise<TunnelResponse | ErrorResponse>;
563
+ handleUpdateConfig(config: TunnelConfig): Promise<TunnelResponse | ErrorResponse>;
564
+ handleList(): Promise<TunnelResponse[] | ErrorResponse>;
565
+ handleStop(tunnelid: string): Promise<TunnelResponse | ErrorResponse>;
566
+ handleGet(tunnelid: string): Promise<TunnelResponse | ErrorResponse>;
567
+ handleRestart(tunnelid: string): Promise<TunnelResponse | ErrorResponse>;
568
+ handleRegisterStatsListener(tunnelid: string, listener: (tunnelId: string, stats: TunnelUsageType) => void): void;
569
+ handleUnregisterStatsListener(tunnelid: string, listnerId: string): void;
570
+ handleGetTunnelStats(tunnelid: string): TunnelUsageType[] | ErrorResponse;
571
+ handleRegisterDisconnectListener(tunnelid: string, listener: DisconnectListener): void;
572
+ handleRemoveStoppedTunnelByTunnelId(tunnelId: string): boolean | ErrorResponse;
573
+ handleRemoveStoppedTunnelByConfigId(configId: string): boolean | ErrorResponse;
574
+ }
575
+ declare class TunnelOperations implements TunnelHandler {
576
+ private tunnelManager;
577
+ constructor();
578
+ private buildStatus;
579
+ private buildTunnelResponse;
580
+ private error;
581
+ handleStart(config: TunnelConfig): Promise<TunnelResponse | ErrorResponse>;
582
+ handleUpdateConfig(config: TunnelConfig): Promise<TunnelResponse | ErrorResponse>;
583
+ handleList(): Promise<TunnelResponse[] | ErrorResponse>;
584
+ handleStop(tunnelid: string): Promise<TunnelResponse | ErrorResponse>;
585
+ handleGet(tunnelid: string): Promise<TunnelResponse | ErrorResponse>;
586
+ handleRestart(tunnelid: string): Promise<TunnelResponse | ErrorResponse>;
587
+ handleRegisterStatsListener(tunnelid: string, listener: (tunnelId: string, stats: TunnelUsageType) => void): void;
588
+ handleUnregisterStatsListener(tunnelid: string, listnerId: string): void;
589
+ handleGetTunnelStats(tunnelid: string): TunnelUsageType[] | ErrorResponse;
590
+ handleRegisterDisconnectListener(tunnelid: string, listener: DisconnectListener): void;
591
+ handleRemoveStoppedTunnelByConfigId(configId: string): boolean | ErrorResponse;
592
+ handleRemoveStoppedTunnelByTunnelId(tunnelId: string): boolean | ErrorResponse;
593
+ }
594
+
595
+ interface BaseLogConfig {
596
+ level?: string;
597
+ filePath?: string;
598
+ stdout?: boolean;
599
+ source?: boolean;
600
+ silent?: boolean;
601
+ enableSdkLog?: boolean;
602
+ }
603
+ type BaseLogConfigType = BaseLogConfig;
604
+ declare function enablePackageLogging(opts?: BaseLogConfigType): winston.Logger;
605
+
606
+ /**
607
+ * Initiate remote management mode with a WebSocket connection.
608
+ * - Connect with Authorization: Bearer <token>
609
+ * - On HTTP 401: print Unauthorized and exit
610
+ * - On other failures: retry every 15 seconds
611
+ * - Keep running until closed or SIGINT
612
+ */
613
+ declare function initiateRemoteManagement(token: string, manage?: string): Promise<RemoteManagementState>;
614
+ declare function closeRemoteManagement(timeoutMs?: number): Promise<RemoteManagementState>;
615
+ declare function getRemoteManagementState(): RemoteManagementState;
616
+
617
+ export { type AdditionalForwarding, type DisconnectListener, type ErrorListener, type FinalConfig, type ITunnelManager, type ManagedTunnel, type ReconnectingListener, type ReconnectionCompletedListener, type ReconnectionFailedListener, type StartListener, type StatsListener, type Status, TunnelErrorCodeType, type TunnelList, TunnelManager, TunnelOperations, type TunnelResponse, TunnelStateType, type TunnelStatus, TunnelWarningCode, type TunnelWorkerErrorListner, type Warning, type WillReconnectListener, closeRemoteManagement, enablePackageLogging, getRemoteManagementState, initiateRemoteManagement };