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