pinggy 0.6.4 → 0.6.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.
- package/ARCHITECTURE.md +126 -57
- package/CLAUDE.md +25 -12
- package/README.md +5 -5
- package/dist/{TunnelManager-NGSUBZYI.js → TunnelManager-JRVEADS4.js} +4 -3
- package/dist/{TunnelTui-UCG2YSLX.js → TunnelTui-6H4NPUNF.js} +4 -3
- package/dist/{chunk-Y435RMHQ.js → chunk-2GIJXE4K.js} +3 -2
- package/dist/{chunk-QNUVQ6KD.js → chunk-3WMTTJHI.js} +11 -299
- package/dist/chunk-4XXAHYCJ.js +927 -0
- package/dist/{chunk-PD7HXVQ3.js → chunk-CZOKR73F.js} +18 -1
- package/dist/chunk-FQ22KFVV.js +882 -0
- package/dist/{chunk-UVJYL2ZN.js → chunk-HAFTH5MX.js} +933 -576
- package/dist/chunk-HTIWY3O5.js +293 -0
- package/dist/{chunk-MV56U3E6.js → chunk-LWCVB42S.js} +2 -2
- package/dist/{chunk-AFMTIELL.js → chunk-MAK5R4WQ.js} +20 -0
- package/dist/{chunk-7EQKHVQX.js → chunk-MHQ3CVEB.js} +4 -51
- package/dist/chunk-MKGD2QAI.js +51 -0
- package/dist/{chunk-CIOYQU7F.js → chunk-Q5NCTGNS.js} +49 -233
- package/dist/{configStore-RR5ZU4E3.js → configStore-JJUWT2YO.js} +3 -3
- package/dist/{daemonChild-WHS676G4.js → daemonChild-Q6WGYKYX.js} +14 -14
- package/dist/daemonConfig-VWK4TXVS.js +17 -0
- package/dist/index.cjs +3214 -935
- package/dist/index.d.cts +150 -129
- package/dist/index.d.ts +150 -129
- package/dist/index.js +18 -13
- package/dist/{ipcClient-XGF2KCQO.js → ipcClient-IZ5R6TPN.js} +2 -1
- package/dist/{main-JRVKAIHH.js → main-BI7ACRHS.js} +19 -14
- package/dist/updateChild-Z3SIRYO5.js +237 -0
- package/dist/workers/file_serve_worker.js +1 -1
- package/package.json +2 -1
- package/scripts/install/install.ps1 +49 -5
- package/scripts/install/install.sh +99 -12
- package/dist/daemonConfig-QVXQ47XH.js +0 -9
package/dist/index.d.cts
CHANGED
|
@@ -1032,6 +1032,136 @@ declare class IPCClient {
|
|
|
1032
1032
|
private request;
|
|
1033
1033
|
}
|
|
1034
1034
|
|
|
1035
|
+
interface SavedTunnelConfig {
|
|
1036
|
+
name: string;
|
|
1037
|
+
configId: string;
|
|
1038
|
+
autoStart: boolean;
|
|
1039
|
+
createdAt: string;
|
|
1040
|
+
updatedAt: string;
|
|
1041
|
+
tunnelConfig: TunnelConfigurationV1;
|
|
1042
|
+
/**
|
|
1043
|
+
* App-owned UI state (e.g. `regioncode`, `isServerAddress`). The CLI
|
|
1044
|
+
* and daemon never read this;
|
|
1045
|
+
*/
|
|
1046
|
+
uiMetadata?: Record<string, unknown>;
|
|
1047
|
+
}
|
|
1048
|
+
/**
|
|
1049
|
+
* Minimal logger interface for the storage module. Defaults to the cli-js
|
|
1050
|
+
* winston logger (silent unless the CLI configures it). Non-CLI consumers
|
|
1051
|
+
* (e.g. the Electron app) override it via {@link configureStorageLogger} to
|
|
1052
|
+
* route storage logs into their own logging pipeline
|
|
1053
|
+
*/
|
|
1054
|
+
interface StorageLogger {
|
|
1055
|
+
info: (message: string, ...meta: unknown[]) => void;
|
|
1056
|
+
warn: (message: string, ...meta: unknown[]) => void;
|
|
1057
|
+
error: (message: string, ...meta: unknown[]) => void;
|
|
1058
|
+
}
|
|
1059
|
+
declare function configureStorageLogger(l: StorageLogger): void;
|
|
1060
|
+
/**
|
|
1061
|
+
* Sanitizes a tunnel name to be filesystem-safe.
|
|
1062
|
+
* Allows alphanumeric, hyphens, underscores only.
|
|
1063
|
+
*/
|
|
1064
|
+
declare function sanitizeName(name: string): string;
|
|
1065
|
+
/**
|
|
1066
|
+
* Strict name validation used by the CLI's own save path: alphanumeric +
|
|
1067
|
+
* `_`/`-`, ≤128 chars, no reserved subcommand names.
|
|
1068
|
+
*/
|
|
1069
|
+
declare function validateNameStrict(name: string): Error | null;
|
|
1070
|
+
/**
|
|
1071
|
+
* Relaxed name validation used by app-driven writes (`{ strict: false }`). The
|
|
1072
|
+
* app allows spaces/unicode in display names, so this only rejects what would
|
|
1073
|
+
* break the filesystem layout or collide with a CLI subcommand: path
|
|
1074
|
+
* separators, NUL/control characters, empty/whitespace-only names, and reserved
|
|
1075
|
+
* subcommand names. The JSON `name` keeps the original; the filename is always
|
|
1076
|
+
* sanitized via {@link sanitizeName}.
|
|
1077
|
+
*/
|
|
1078
|
+
declare function validateNameForStorage(name: string): Error | null;
|
|
1079
|
+
/**
|
|
1080
|
+
* Backwards-compatible alias for {@link validateNameStrict}. Existing CLI
|
|
1081
|
+
* callers (`subcommands.ts`, `buildAndStartTunnel.ts`) import `validateName`.
|
|
1082
|
+
*/
|
|
1083
|
+
declare const validateName: typeof validateNameStrict;
|
|
1084
|
+
/**
|
|
1085
|
+
* List all saved tunnel configs from the config directory.
|
|
1086
|
+
*/
|
|
1087
|
+
declare function listSavedConfigs(): SavedTunnelConfig[];
|
|
1088
|
+
/**
|
|
1089
|
+
* Find a config by its exact display name (the JSON `name`). Exact on purpose:
|
|
1090
|
+
* `sanitizeName` is many-to-one (`"My Tunnel"`/`"My_Tunnel"` → `My_Tunnel`), so
|
|
1091
|
+
* it builds filenames, never decides identity. Narrows by sanitized prefix then
|
|
1092
|
+
* confirms the exact `name`; on a same-name/different-`configId` tie, newest wins.
|
|
1093
|
+
*/
|
|
1094
|
+
declare function findConfigByName(name: string): SavedTunnelConfig | null;
|
|
1095
|
+
/**
|
|
1096
|
+
* Find a config by name or configId (supports partial configId match).
|
|
1097
|
+
*/
|
|
1098
|
+
declare function findConfig(nameOrId: string): SavedTunnelConfig | null;
|
|
1099
|
+
/**
|
|
1100
|
+
* Save a tunnel config to the config store.
|
|
1101
|
+
* Rejects duplicate names.
|
|
1102
|
+
*
|
|
1103
|
+
* @param options.strict When `true` (default) names are validated with
|
|
1104
|
+
* {@link validateNameStrict}; when `false` (app-driven writes) with the
|
|
1105
|
+
* relaxed {@link validateNameForStorage}.
|
|
1106
|
+
*/
|
|
1107
|
+
declare function saveConfig(name: string, configId: string, tunnelConfig: TunnelConfigurationV1, autoStart?: boolean, options?: {
|
|
1108
|
+
strict?: boolean;
|
|
1109
|
+
}): SavedTunnelConfig;
|
|
1110
|
+
/**
|
|
1111
|
+
* Insert or update a full saved record, keyed by `configId` (the stable
|
|
1112
|
+
* identity). If a record with the same `configId` exists under a different
|
|
1113
|
+
* filename — because its `name` changed — the old file is deleted before the
|
|
1114
|
+
* new one is written, so there is never a stale duplicate on disk. Only
|
|
1115
|
+
* validates the name when creating a brand-new record;
|
|
1116
|
+
*/
|
|
1117
|
+
declare function upsertConfig(saved: SavedTunnelConfig, options?: {
|
|
1118
|
+
strict?: boolean;
|
|
1119
|
+
}): SavedTunnelConfig;
|
|
1120
|
+
/**
|
|
1121
|
+
* Replace a *bounded* set of configs in one pass. Every config in `configs` is
|
|
1122
|
+
* upserted;
|
|
1123
|
+
*/
|
|
1124
|
+
declare function bulkReplace(configs: SavedTunnelConfig[], knownConfigIds: Set<string>, options?: {
|
|
1125
|
+
strict?: boolean;
|
|
1126
|
+
}): {
|
|
1127
|
+
written: string[];
|
|
1128
|
+
deleted: string[];
|
|
1129
|
+
};
|
|
1130
|
+
/**
|
|
1131
|
+
* Load a saved tunnel config by name.
|
|
1132
|
+
*/
|
|
1133
|
+
declare function loadConfigByName(name: string): SavedTunnelConfig | null;
|
|
1134
|
+
/**
|
|
1135
|
+
* Delete a saved tunnel config by name or configId.
|
|
1136
|
+
* Returns the deleted config's name if found, null otherwise.
|
|
1137
|
+
*/
|
|
1138
|
+
declare function deleteConfig(nameOrId: string): string | null;
|
|
1139
|
+
/**
|
|
1140
|
+
* Update the autoStart flag on a saved config.
|
|
1141
|
+
* Returns the updated config, or null if not found.
|
|
1142
|
+
*/
|
|
1143
|
+
declare function updateConfigAutoStart(nameOrId: string, autoStart: boolean): SavedTunnelConfig | null;
|
|
1144
|
+
/**
|
|
1145
|
+
* Update the tunnel configuration of a saved config.
|
|
1146
|
+
* Returns the updated config, or null if not found.
|
|
1147
|
+
*/
|
|
1148
|
+
declare function updateTunnelConfig(nameOrId: string, tunnelConfig: TunnelConfigurationV1): SavedTunnelConfig | null;
|
|
1149
|
+
/**
|
|
1150
|
+
* Get all configs marked for auto-start.
|
|
1151
|
+
*/
|
|
1152
|
+
declare function getAutoStartConfigs(): SavedTunnelConfig[];
|
|
1153
|
+
|
|
1154
|
+
interface DaemonInfo {
|
|
1155
|
+
pid: number;
|
|
1156
|
+
port: number;
|
|
1157
|
+
startedAt: string;
|
|
1158
|
+
host?: DaemonHost;
|
|
1159
|
+
/** IPC protocol version the daemon speaks. Absent in daemon.json written by older builds. */
|
|
1160
|
+
ipcVersion?: number;
|
|
1161
|
+
/** The version this daemon started with. It never follows the installed binary. Absent in older builds. */
|
|
1162
|
+
cliVersion?: string;
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1035
1165
|
type StatsCallback = (tunnelId: string, stats: TunnelUsageType) => void;
|
|
1036
1166
|
type DisconnectCallback = (tunnelId: string, error: string, messages: string[]) => void;
|
|
1037
1167
|
type ReconnectingCallback = (tunnelId: string, retryCnt: number) => void;
|
|
@@ -1155,6 +1285,8 @@ declare class DaemonHealth {
|
|
|
1155
1285
|
|
|
1156
1286
|
interface TunnelClientOptions {
|
|
1157
1287
|
origin?: ClientOrigin;
|
|
1288
|
+
/** Replaces the "daemon runs an older version" line. */
|
|
1289
|
+
printVersionNotice?: (info: DaemonInfo) => void;
|
|
1158
1290
|
}
|
|
1159
1291
|
declare class TunnelClient {
|
|
1160
1292
|
private ipc;
|
|
@@ -1165,8 +1297,25 @@ declare class TunnelClient {
|
|
|
1165
1297
|
private shimDisconnectListeners;
|
|
1166
1298
|
private shimSubscribedTunnels;
|
|
1167
1299
|
private shimListenerSeq;
|
|
1300
|
+
private boundDaemon;
|
|
1301
|
+
private readonly printVersionNotice;
|
|
1168
1302
|
constructor(options?: TunnelClientOptions);
|
|
1169
|
-
|
|
1303
|
+
/**
|
|
1304
|
+
* @param options.holdVersionNotice leaves the "daemon runs an older version" line for `printHeldVersionNotice()`.
|
|
1305
|
+
* A caller with a spinner running uses this, so the line does not land on the spinner.
|
|
1306
|
+
*/
|
|
1307
|
+
ensureDaemon(options?: {
|
|
1308
|
+
holdVersionNotice?: boolean;
|
|
1309
|
+
}): Promise<void>;
|
|
1310
|
+
printHeldVersionNotice(): void;
|
|
1311
|
+
/**
|
|
1312
|
+
* Connects to the daemon that runs now, and never starts one. For commands that only read state.
|
|
1313
|
+
* Throws when that daemon speaks another IPC version, as ensureDaemon() does.
|
|
1314
|
+
*
|
|
1315
|
+
* @returns false when no daemon runs
|
|
1316
|
+
*/
|
|
1317
|
+
connectIfRunning(): boolean;
|
|
1318
|
+
private bindDaemon;
|
|
1170
1319
|
static forRemoteManagement(): Promise<TunnelClient>;
|
|
1171
1320
|
/**
|
|
1172
1321
|
* Close the WebSocket connection and cleanup.
|
|
@@ -1230,134 +1379,6 @@ declare class TunnelClient {
|
|
|
1230
1379
|
private assertClient;
|
|
1231
1380
|
}
|
|
1232
1381
|
|
|
1233
|
-
interface SavedTunnelConfig {
|
|
1234
|
-
name: string;
|
|
1235
|
-
configId: string;
|
|
1236
|
-
autoStart: boolean;
|
|
1237
|
-
createdAt: string;
|
|
1238
|
-
updatedAt: string;
|
|
1239
|
-
tunnelConfig: TunnelConfigurationV1;
|
|
1240
|
-
/**
|
|
1241
|
-
* App-owned UI state (e.g. `regioncode`, `isServerAddress`). The CLI
|
|
1242
|
-
* and daemon never read this;
|
|
1243
|
-
*/
|
|
1244
|
-
uiMetadata?: Record<string, unknown>;
|
|
1245
|
-
}
|
|
1246
|
-
/**
|
|
1247
|
-
* Minimal logger interface for the storage module. Defaults to the cli-js
|
|
1248
|
-
* winston logger (silent unless the CLI configures it). Non-CLI consumers
|
|
1249
|
-
* (e.g. the Electron app) override it via {@link configureStorageLogger} to
|
|
1250
|
-
* route storage logs into their own logging pipeline
|
|
1251
|
-
*/
|
|
1252
|
-
interface StorageLogger {
|
|
1253
|
-
info: (message: string, ...meta: unknown[]) => void;
|
|
1254
|
-
warn: (message: string, ...meta: unknown[]) => void;
|
|
1255
|
-
error: (message: string, ...meta: unknown[]) => void;
|
|
1256
|
-
}
|
|
1257
|
-
declare function configureStorageLogger(l: StorageLogger): void;
|
|
1258
|
-
/**
|
|
1259
|
-
* Sanitizes a tunnel name to be filesystem-safe.
|
|
1260
|
-
* Allows alphanumeric, hyphens, underscores only.
|
|
1261
|
-
*/
|
|
1262
|
-
declare function sanitizeName(name: string): string;
|
|
1263
|
-
/**
|
|
1264
|
-
* Strict name validation used by the CLI's own save path: alphanumeric +
|
|
1265
|
-
* `_`/`-`, ≤128 chars, no reserved subcommand names.
|
|
1266
|
-
*/
|
|
1267
|
-
declare function validateNameStrict(name: string): Error | null;
|
|
1268
|
-
/**
|
|
1269
|
-
* Relaxed name validation used by app-driven writes (`{ strict: false }`). The
|
|
1270
|
-
* app allows spaces/unicode in display names, so this only rejects what would
|
|
1271
|
-
* break the filesystem layout or collide with a CLI subcommand: path
|
|
1272
|
-
* separators, NUL/control characters, empty/whitespace-only names, and reserved
|
|
1273
|
-
* subcommand names. The JSON `name` keeps the original; the filename is always
|
|
1274
|
-
* sanitized via {@link sanitizeName}.
|
|
1275
|
-
*/
|
|
1276
|
-
declare function validateNameForStorage(name: string): Error | null;
|
|
1277
|
-
/**
|
|
1278
|
-
* Backwards-compatible alias for {@link validateNameStrict}. Existing CLI
|
|
1279
|
-
* callers (`subcommands.ts`, `buildAndStartTunnel.ts`) import `validateName`.
|
|
1280
|
-
*/
|
|
1281
|
-
declare const validateName: typeof validateNameStrict;
|
|
1282
|
-
/**
|
|
1283
|
-
* List all saved tunnel configs from the config directory.
|
|
1284
|
-
*/
|
|
1285
|
-
declare function listSavedConfigs(): SavedTunnelConfig[];
|
|
1286
|
-
/**
|
|
1287
|
-
* Find a config by its exact display name (the JSON `name`). Exact on purpose:
|
|
1288
|
-
* `sanitizeName` is many-to-one (`"My Tunnel"`/`"My_Tunnel"` → `My_Tunnel`), so
|
|
1289
|
-
* it builds filenames, never decides identity. Narrows by sanitized prefix then
|
|
1290
|
-
* confirms the exact `name`; on a same-name/different-`configId` tie, newest wins.
|
|
1291
|
-
*/
|
|
1292
|
-
declare function findConfigByName(name: string): SavedTunnelConfig | null;
|
|
1293
|
-
/**
|
|
1294
|
-
* Find a config by name or configId (supports partial configId match).
|
|
1295
|
-
*/
|
|
1296
|
-
declare function findConfig(nameOrId: string): SavedTunnelConfig | null;
|
|
1297
|
-
/**
|
|
1298
|
-
* Save a tunnel config to the config store.
|
|
1299
|
-
* Rejects duplicate names.
|
|
1300
|
-
*
|
|
1301
|
-
* @param options.strict When `true` (default) names are validated with
|
|
1302
|
-
* {@link validateNameStrict}; when `false` (app-driven writes) with the
|
|
1303
|
-
* relaxed {@link validateNameForStorage}.
|
|
1304
|
-
*/
|
|
1305
|
-
declare function saveConfig(name: string, configId: string, tunnelConfig: TunnelConfigurationV1, autoStart?: boolean, options?: {
|
|
1306
|
-
strict?: boolean;
|
|
1307
|
-
}): SavedTunnelConfig;
|
|
1308
|
-
/**
|
|
1309
|
-
* Insert or update a full saved record, keyed by `configId` (the stable
|
|
1310
|
-
* identity). If a record with the same `configId` exists under a different
|
|
1311
|
-
* filename — because its `name` changed — the old file is deleted before the
|
|
1312
|
-
* new one is written, so there is never a stale duplicate on disk. Only
|
|
1313
|
-
* validates the name when creating a brand-new record;
|
|
1314
|
-
*/
|
|
1315
|
-
declare function upsertConfig(saved: SavedTunnelConfig, options?: {
|
|
1316
|
-
strict?: boolean;
|
|
1317
|
-
}): SavedTunnelConfig;
|
|
1318
|
-
/**
|
|
1319
|
-
* Replace a *bounded* set of configs in one pass. Every config in `configs` is
|
|
1320
|
-
* upserted;
|
|
1321
|
-
*/
|
|
1322
|
-
declare function bulkReplace(configs: SavedTunnelConfig[], knownConfigIds: Set<string>, options?: {
|
|
1323
|
-
strict?: boolean;
|
|
1324
|
-
}): {
|
|
1325
|
-
written: string[];
|
|
1326
|
-
deleted: string[];
|
|
1327
|
-
};
|
|
1328
|
-
/**
|
|
1329
|
-
* Load a saved tunnel config by name.
|
|
1330
|
-
*/
|
|
1331
|
-
declare function loadConfigByName(name: string): SavedTunnelConfig | null;
|
|
1332
|
-
/**
|
|
1333
|
-
* Delete a saved tunnel config by name or configId.
|
|
1334
|
-
* Returns the deleted config's name if found, null otherwise.
|
|
1335
|
-
*/
|
|
1336
|
-
declare function deleteConfig(nameOrId: string): string | null;
|
|
1337
|
-
/**
|
|
1338
|
-
* Update the autoStart flag on a saved config.
|
|
1339
|
-
* Returns the updated config, or null if not found.
|
|
1340
|
-
*/
|
|
1341
|
-
declare function updateConfigAutoStart(nameOrId: string, autoStart: boolean): SavedTunnelConfig | null;
|
|
1342
|
-
/**
|
|
1343
|
-
* Update the tunnel configuration of a saved config.
|
|
1344
|
-
* Returns the updated config, or null if not found.
|
|
1345
|
-
*/
|
|
1346
|
-
declare function updateTunnelConfig(nameOrId: string, tunnelConfig: TunnelConfigurationV1): SavedTunnelConfig | null;
|
|
1347
|
-
/**
|
|
1348
|
-
* Get all configs marked for auto-start.
|
|
1349
|
-
*/
|
|
1350
|
-
declare function getAutoStartConfigs(): SavedTunnelConfig[];
|
|
1351
|
-
|
|
1352
|
-
interface DaemonInfo {
|
|
1353
|
-
pid: number;
|
|
1354
|
-
port: number;
|
|
1355
|
-
startedAt: string;
|
|
1356
|
-
host?: DaemonHost;
|
|
1357
|
-
/** IPC protocol version the daemon speaks. Absent in daemon.json written by older builds. */
|
|
1358
|
-
ipcVersion?: number;
|
|
1359
|
-
}
|
|
1360
|
-
|
|
1361
1382
|
/**
|
|
1362
1383
|
* Read and validate daemon.json.
|
|
1363
1384
|
* Returns null if file doesn't exist, is malformed, or PID is stale.
|
package/dist/index.d.ts
CHANGED
|
@@ -1032,6 +1032,136 @@ declare class IPCClient {
|
|
|
1032
1032
|
private request;
|
|
1033
1033
|
}
|
|
1034
1034
|
|
|
1035
|
+
interface SavedTunnelConfig {
|
|
1036
|
+
name: string;
|
|
1037
|
+
configId: string;
|
|
1038
|
+
autoStart: boolean;
|
|
1039
|
+
createdAt: string;
|
|
1040
|
+
updatedAt: string;
|
|
1041
|
+
tunnelConfig: TunnelConfigurationV1;
|
|
1042
|
+
/**
|
|
1043
|
+
* App-owned UI state (e.g. `regioncode`, `isServerAddress`). The CLI
|
|
1044
|
+
* and daemon never read this;
|
|
1045
|
+
*/
|
|
1046
|
+
uiMetadata?: Record<string, unknown>;
|
|
1047
|
+
}
|
|
1048
|
+
/**
|
|
1049
|
+
* Minimal logger interface for the storage module. Defaults to the cli-js
|
|
1050
|
+
* winston logger (silent unless the CLI configures it). Non-CLI consumers
|
|
1051
|
+
* (e.g. the Electron app) override it via {@link configureStorageLogger} to
|
|
1052
|
+
* route storage logs into their own logging pipeline
|
|
1053
|
+
*/
|
|
1054
|
+
interface StorageLogger {
|
|
1055
|
+
info: (message: string, ...meta: unknown[]) => void;
|
|
1056
|
+
warn: (message: string, ...meta: unknown[]) => void;
|
|
1057
|
+
error: (message: string, ...meta: unknown[]) => void;
|
|
1058
|
+
}
|
|
1059
|
+
declare function configureStorageLogger(l: StorageLogger): void;
|
|
1060
|
+
/**
|
|
1061
|
+
* Sanitizes a tunnel name to be filesystem-safe.
|
|
1062
|
+
* Allows alphanumeric, hyphens, underscores only.
|
|
1063
|
+
*/
|
|
1064
|
+
declare function sanitizeName(name: string): string;
|
|
1065
|
+
/**
|
|
1066
|
+
* Strict name validation used by the CLI's own save path: alphanumeric +
|
|
1067
|
+
* `_`/`-`, ≤128 chars, no reserved subcommand names.
|
|
1068
|
+
*/
|
|
1069
|
+
declare function validateNameStrict(name: string): Error | null;
|
|
1070
|
+
/**
|
|
1071
|
+
* Relaxed name validation used by app-driven writes (`{ strict: false }`). The
|
|
1072
|
+
* app allows spaces/unicode in display names, so this only rejects what would
|
|
1073
|
+
* break the filesystem layout or collide with a CLI subcommand: path
|
|
1074
|
+
* separators, NUL/control characters, empty/whitespace-only names, and reserved
|
|
1075
|
+
* subcommand names. The JSON `name` keeps the original; the filename is always
|
|
1076
|
+
* sanitized via {@link sanitizeName}.
|
|
1077
|
+
*/
|
|
1078
|
+
declare function validateNameForStorage(name: string): Error | null;
|
|
1079
|
+
/**
|
|
1080
|
+
* Backwards-compatible alias for {@link validateNameStrict}. Existing CLI
|
|
1081
|
+
* callers (`subcommands.ts`, `buildAndStartTunnel.ts`) import `validateName`.
|
|
1082
|
+
*/
|
|
1083
|
+
declare const validateName: typeof validateNameStrict;
|
|
1084
|
+
/**
|
|
1085
|
+
* List all saved tunnel configs from the config directory.
|
|
1086
|
+
*/
|
|
1087
|
+
declare function listSavedConfigs(): SavedTunnelConfig[];
|
|
1088
|
+
/**
|
|
1089
|
+
* Find a config by its exact display name (the JSON `name`). Exact on purpose:
|
|
1090
|
+
* `sanitizeName` is many-to-one (`"My Tunnel"`/`"My_Tunnel"` → `My_Tunnel`), so
|
|
1091
|
+
* it builds filenames, never decides identity. Narrows by sanitized prefix then
|
|
1092
|
+
* confirms the exact `name`; on a same-name/different-`configId` tie, newest wins.
|
|
1093
|
+
*/
|
|
1094
|
+
declare function findConfigByName(name: string): SavedTunnelConfig | null;
|
|
1095
|
+
/**
|
|
1096
|
+
* Find a config by name or configId (supports partial configId match).
|
|
1097
|
+
*/
|
|
1098
|
+
declare function findConfig(nameOrId: string): SavedTunnelConfig | null;
|
|
1099
|
+
/**
|
|
1100
|
+
* Save a tunnel config to the config store.
|
|
1101
|
+
* Rejects duplicate names.
|
|
1102
|
+
*
|
|
1103
|
+
* @param options.strict When `true` (default) names are validated with
|
|
1104
|
+
* {@link validateNameStrict}; when `false` (app-driven writes) with the
|
|
1105
|
+
* relaxed {@link validateNameForStorage}.
|
|
1106
|
+
*/
|
|
1107
|
+
declare function saveConfig(name: string, configId: string, tunnelConfig: TunnelConfigurationV1, autoStart?: boolean, options?: {
|
|
1108
|
+
strict?: boolean;
|
|
1109
|
+
}): SavedTunnelConfig;
|
|
1110
|
+
/**
|
|
1111
|
+
* Insert or update a full saved record, keyed by `configId` (the stable
|
|
1112
|
+
* identity). If a record with the same `configId` exists under a different
|
|
1113
|
+
* filename — because its `name` changed — the old file is deleted before the
|
|
1114
|
+
* new one is written, so there is never a stale duplicate on disk. Only
|
|
1115
|
+
* validates the name when creating a brand-new record;
|
|
1116
|
+
*/
|
|
1117
|
+
declare function upsertConfig(saved: SavedTunnelConfig, options?: {
|
|
1118
|
+
strict?: boolean;
|
|
1119
|
+
}): SavedTunnelConfig;
|
|
1120
|
+
/**
|
|
1121
|
+
* Replace a *bounded* set of configs in one pass. Every config in `configs` is
|
|
1122
|
+
* upserted;
|
|
1123
|
+
*/
|
|
1124
|
+
declare function bulkReplace(configs: SavedTunnelConfig[], knownConfigIds: Set<string>, options?: {
|
|
1125
|
+
strict?: boolean;
|
|
1126
|
+
}): {
|
|
1127
|
+
written: string[];
|
|
1128
|
+
deleted: string[];
|
|
1129
|
+
};
|
|
1130
|
+
/**
|
|
1131
|
+
* Load a saved tunnel config by name.
|
|
1132
|
+
*/
|
|
1133
|
+
declare function loadConfigByName(name: string): SavedTunnelConfig | null;
|
|
1134
|
+
/**
|
|
1135
|
+
* Delete a saved tunnel config by name or configId.
|
|
1136
|
+
* Returns the deleted config's name if found, null otherwise.
|
|
1137
|
+
*/
|
|
1138
|
+
declare function deleteConfig(nameOrId: string): string | null;
|
|
1139
|
+
/**
|
|
1140
|
+
* Update the autoStart flag on a saved config.
|
|
1141
|
+
* Returns the updated config, or null if not found.
|
|
1142
|
+
*/
|
|
1143
|
+
declare function updateConfigAutoStart(nameOrId: string, autoStart: boolean): SavedTunnelConfig | null;
|
|
1144
|
+
/**
|
|
1145
|
+
* Update the tunnel configuration of a saved config.
|
|
1146
|
+
* Returns the updated config, or null if not found.
|
|
1147
|
+
*/
|
|
1148
|
+
declare function updateTunnelConfig(nameOrId: string, tunnelConfig: TunnelConfigurationV1): SavedTunnelConfig | null;
|
|
1149
|
+
/**
|
|
1150
|
+
* Get all configs marked for auto-start.
|
|
1151
|
+
*/
|
|
1152
|
+
declare function getAutoStartConfigs(): SavedTunnelConfig[];
|
|
1153
|
+
|
|
1154
|
+
interface DaemonInfo {
|
|
1155
|
+
pid: number;
|
|
1156
|
+
port: number;
|
|
1157
|
+
startedAt: string;
|
|
1158
|
+
host?: DaemonHost;
|
|
1159
|
+
/** IPC protocol version the daemon speaks. Absent in daemon.json written by older builds. */
|
|
1160
|
+
ipcVersion?: number;
|
|
1161
|
+
/** The version this daemon started with. It never follows the installed binary. Absent in older builds. */
|
|
1162
|
+
cliVersion?: string;
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1035
1165
|
type StatsCallback = (tunnelId: string, stats: TunnelUsageType) => void;
|
|
1036
1166
|
type DisconnectCallback = (tunnelId: string, error: string, messages: string[]) => void;
|
|
1037
1167
|
type ReconnectingCallback = (tunnelId: string, retryCnt: number) => void;
|
|
@@ -1155,6 +1285,8 @@ declare class DaemonHealth {
|
|
|
1155
1285
|
|
|
1156
1286
|
interface TunnelClientOptions {
|
|
1157
1287
|
origin?: ClientOrigin;
|
|
1288
|
+
/** Replaces the "daemon runs an older version" line. */
|
|
1289
|
+
printVersionNotice?: (info: DaemonInfo) => void;
|
|
1158
1290
|
}
|
|
1159
1291
|
declare class TunnelClient {
|
|
1160
1292
|
private ipc;
|
|
@@ -1165,8 +1297,25 @@ declare class TunnelClient {
|
|
|
1165
1297
|
private shimDisconnectListeners;
|
|
1166
1298
|
private shimSubscribedTunnels;
|
|
1167
1299
|
private shimListenerSeq;
|
|
1300
|
+
private boundDaemon;
|
|
1301
|
+
private readonly printVersionNotice;
|
|
1168
1302
|
constructor(options?: TunnelClientOptions);
|
|
1169
|
-
|
|
1303
|
+
/**
|
|
1304
|
+
* @param options.holdVersionNotice leaves the "daemon runs an older version" line for `printHeldVersionNotice()`.
|
|
1305
|
+
* A caller with a spinner running uses this, so the line does not land on the spinner.
|
|
1306
|
+
*/
|
|
1307
|
+
ensureDaemon(options?: {
|
|
1308
|
+
holdVersionNotice?: boolean;
|
|
1309
|
+
}): Promise<void>;
|
|
1310
|
+
printHeldVersionNotice(): void;
|
|
1311
|
+
/**
|
|
1312
|
+
* Connects to the daemon that runs now, and never starts one. For commands that only read state.
|
|
1313
|
+
* Throws when that daemon speaks another IPC version, as ensureDaemon() does.
|
|
1314
|
+
*
|
|
1315
|
+
* @returns false when no daemon runs
|
|
1316
|
+
*/
|
|
1317
|
+
connectIfRunning(): boolean;
|
|
1318
|
+
private bindDaemon;
|
|
1170
1319
|
static forRemoteManagement(): Promise<TunnelClient>;
|
|
1171
1320
|
/**
|
|
1172
1321
|
* Close the WebSocket connection and cleanup.
|
|
@@ -1230,134 +1379,6 @@ declare class TunnelClient {
|
|
|
1230
1379
|
private assertClient;
|
|
1231
1380
|
}
|
|
1232
1381
|
|
|
1233
|
-
interface SavedTunnelConfig {
|
|
1234
|
-
name: string;
|
|
1235
|
-
configId: string;
|
|
1236
|
-
autoStart: boolean;
|
|
1237
|
-
createdAt: string;
|
|
1238
|
-
updatedAt: string;
|
|
1239
|
-
tunnelConfig: TunnelConfigurationV1;
|
|
1240
|
-
/**
|
|
1241
|
-
* App-owned UI state (e.g. `regioncode`, `isServerAddress`). The CLI
|
|
1242
|
-
* and daemon never read this;
|
|
1243
|
-
*/
|
|
1244
|
-
uiMetadata?: Record<string, unknown>;
|
|
1245
|
-
}
|
|
1246
|
-
/**
|
|
1247
|
-
* Minimal logger interface for the storage module. Defaults to the cli-js
|
|
1248
|
-
* winston logger (silent unless the CLI configures it). Non-CLI consumers
|
|
1249
|
-
* (e.g. the Electron app) override it via {@link configureStorageLogger} to
|
|
1250
|
-
* route storage logs into their own logging pipeline
|
|
1251
|
-
*/
|
|
1252
|
-
interface StorageLogger {
|
|
1253
|
-
info: (message: string, ...meta: unknown[]) => void;
|
|
1254
|
-
warn: (message: string, ...meta: unknown[]) => void;
|
|
1255
|
-
error: (message: string, ...meta: unknown[]) => void;
|
|
1256
|
-
}
|
|
1257
|
-
declare function configureStorageLogger(l: StorageLogger): void;
|
|
1258
|
-
/**
|
|
1259
|
-
* Sanitizes a tunnel name to be filesystem-safe.
|
|
1260
|
-
* Allows alphanumeric, hyphens, underscores only.
|
|
1261
|
-
*/
|
|
1262
|
-
declare function sanitizeName(name: string): string;
|
|
1263
|
-
/**
|
|
1264
|
-
* Strict name validation used by the CLI's own save path: alphanumeric +
|
|
1265
|
-
* `_`/`-`, ≤128 chars, no reserved subcommand names.
|
|
1266
|
-
*/
|
|
1267
|
-
declare function validateNameStrict(name: string): Error | null;
|
|
1268
|
-
/**
|
|
1269
|
-
* Relaxed name validation used by app-driven writes (`{ strict: false }`). The
|
|
1270
|
-
* app allows spaces/unicode in display names, so this only rejects what would
|
|
1271
|
-
* break the filesystem layout or collide with a CLI subcommand: path
|
|
1272
|
-
* separators, NUL/control characters, empty/whitespace-only names, and reserved
|
|
1273
|
-
* subcommand names. The JSON `name` keeps the original; the filename is always
|
|
1274
|
-
* sanitized via {@link sanitizeName}.
|
|
1275
|
-
*/
|
|
1276
|
-
declare function validateNameForStorage(name: string): Error | null;
|
|
1277
|
-
/**
|
|
1278
|
-
* Backwards-compatible alias for {@link validateNameStrict}. Existing CLI
|
|
1279
|
-
* callers (`subcommands.ts`, `buildAndStartTunnel.ts`) import `validateName`.
|
|
1280
|
-
*/
|
|
1281
|
-
declare const validateName: typeof validateNameStrict;
|
|
1282
|
-
/**
|
|
1283
|
-
* List all saved tunnel configs from the config directory.
|
|
1284
|
-
*/
|
|
1285
|
-
declare function listSavedConfigs(): SavedTunnelConfig[];
|
|
1286
|
-
/**
|
|
1287
|
-
* Find a config by its exact display name (the JSON `name`). Exact on purpose:
|
|
1288
|
-
* `sanitizeName` is many-to-one (`"My Tunnel"`/`"My_Tunnel"` → `My_Tunnel`), so
|
|
1289
|
-
* it builds filenames, never decides identity. Narrows by sanitized prefix then
|
|
1290
|
-
* confirms the exact `name`; on a same-name/different-`configId` tie, newest wins.
|
|
1291
|
-
*/
|
|
1292
|
-
declare function findConfigByName(name: string): SavedTunnelConfig | null;
|
|
1293
|
-
/**
|
|
1294
|
-
* Find a config by name or configId (supports partial configId match).
|
|
1295
|
-
*/
|
|
1296
|
-
declare function findConfig(nameOrId: string): SavedTunnelConfig | null;
|
|
1297
|
-
/**
|
|
1298
|
-
* Save a tunnel config to the config store.
|
|
1299
|
-
* Rejects duplicate names.
|
|
1300
|
-
*
|
|
1301
|
-
* @param options.strict When `true` (default) names are validated with
|
|
1302
|
-
* {@link validateNameStrict}; when `false` (app-driven writes) with the
|
|
1303
|
-
* relaxed {@link validateNameForStorage}.
|
|
1304
|
-
*/
|
|
1305
|
-
declare function saveConfig(name: string, configId: string, tunnelConfig: TunnelConfigurationV1, autoStart?: boolean, options?: {
|
|
1306
|
-
strict?: boolean;
|
|
1307
|
-
}): SavedTunnelConfig;
|
|
1308
|
-
/**
|
|
1309
|
-
* Insert or update a full saved record, keyed by `configId` (the stable
|
|
1310
|
-
* identity). If a record with the same `configId` exists under a different
|
|
1311
|
-
* filename — because its `name` changed — the old file is deleted before the
|
|
1312
|
-
* new one is written, so there is never a stale duplicate on disk. Only
|
|
1313
|
-
* validates the name when creating a brand-new record;
|
|
1314
|
-
*/
|
|
1315
|
-
declare function upsertConfig(saved: SavedTunnelConfig, options?: {
|
|
1316
|
-
strict?: boolean;
|
|
1317
|
-
}): SavedTunnelConfig;
|
|
1318
|
-
/**
|
|
1319
|
-
* Replace a *bounded* set of configs in one pass. Every config in `configs` is
|
|
1320
|
-
* upserted;
|
|
1321
|
-
*/
|
|
1322
|
-
declare function bulkReplace(configs: SavedTunnelConfig[], knownConfigIds: Set<string>, options?: {
|
|
1323
|
-
strict?: boolean;
|
|
1324
|
-
}): {
|
|
1325
|
-
written: string[];
|
|
1326
|
-
deleted: string[];
|
|
1327
|
-
};
|
|
1328
|
-
/**
|
|
1329
|
-
* Load a saved tunnel config by name.
|
|
1330
|
-
*/
|
|
1331
|
-
declare function loadConfigByName(name: string): SavedTunnelConfig | null;
|
|
1332
|
-
/**
|
|
1333
|
-
* Delete a saved tunnel config by name or configId.
|
|
1334
|
-
* Returns the deleted config's name if found, null otherwise.
|
|
1335
|
-
*/
|
|
1336
|
-
declare function deleteConfig(nameOrId: string): string | null;
|
|
1337
|
-
/**
|
|
1338
|
-
* Update the autoStart flag on a saved config.
|
|
1339
|
-
* Returns the updated config, or null if not found.
|
|
1340
|
-
*/
|
|
1341
|
-
declare function updateConfigAutoStart(nameOrId: string, autoStart: boolean): SavedTunnelConfig | null;
|
|
1342
|
-
/**
|
|
1343
|
-
* Update the tunnel configuration of a saved config.
|
|
1344
|
-
* Returns the updated config, or null if not found.
|
|
1345
|
-
*/
|
|
1346
|
-
declare function updateTunnelConfig(nameOrId: string, tunnelConfig: TunnelConfigurationV1): SavedTunnelConfig | null;
|
|
1347
|
-
/**
|
|
1348
|
-
* Get all configs marked for auto-start.
|
|
1349
|
-
*/
|
|
1350
|
-
declare function getAutoStartConfigs(): SavedTunnelConfig[];
|
|
1351
|
-
|
|
1352
|
-
interface DaemonInfo {
|
|
1353
|
-
pid: number;
|
|
1354
|
-
port: number;
|
|
1355
|
-
startedAt: string;
|
|
1356
|
-
host?: DaemonHost;
|
|
1357
|
-
/** IPC protocol version the daemon speaks. Absent in daemon.json written by older builds. */
|
|
1358
|
-
ipcVersion?: number;
|
|
1359
|
-
}
|
|
1360
|
-
|
|
1361
1382
|
/**
|
|
1362
1383
|
* Read and validate daemon.json.
|
|
1363
1384
|
* Returns null if file doesn't exist, is malformed, or PID is stale.
|
package/dist/index.js
CHANGED
|
@@ -6,15 +6,11 @@ import {
|
|
|
6
6
|
TunnelConfigV1Schema,
|
|
7
7
|
TunnelOperations,
|
|
8
8
|
closeRemoteManagement,
|
|
9
|
-
getDaemonInfo,
|
|
10
9
|
getRemoteManagementState,
|
|
11
10
|
initiateRemoteManagement,
|
|
12
|
-
isDaemonRunning,
|
|
13
11
|
startRemoteManagement
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import
|
|
16
|
-
DeviceAgentState
|
|
17
|
-
} from "./chunk-7EQKHVQX.js";
|
|
12
|
+
} from "./chunk-Q5NCTGNS.js";
|
|
13
|
+
import "./chunk-MHQ3CVEB.js";
|
|
18
14
|
import {
|
|
19
15
|
bulkReplace,
|
|
20
16
|
configureStorageLogger,
|
|
@@ -32,24 +28,33 @@ import {
|
|
|
32
28
|
validateName,
|
|
33
29
|
validateNameForStorage,
|
|
34
30
|
validateNameStrict
|
|
35
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-2GIJXE4K.js";
|
|
32
|
+
import {
|
|
33
|
+
TunnelManager
|
|
34
|
+
} from "./chunk-3WMTTJHI.js";
|
|
35
|
+
import "./chunk-UB26QJ4T.js";
|
|
36
|
+
import {
|
|
37
|
+
getDaemonInfo,
|
|
38
|
+
isDaemonRunning
|
|
39
|
+
} from "./chunk-4XXAHYCJ.js";
|
|
40
|
+
import {
|
|
41
|
+
DeviceAgentState
|
|
42
|
+
} from "./chunk-MKGD2QAI.js";
|
|
36
43
|
import {
|
|
37
44
|
TunnelErrorCodeType,
|
|
38
|
-
TunnelManager,
|
|
39
45
|
TunnelStateType,
|
|
40
46
|
TunnelWarningCode,
|
|
41
47
|
printer_default
|
|
42
|
-
} from "./chunk-
|
|
43
|
-
import "./chunk-UB26QJ4T.js";
|
|
48
|
+
} from "./chunk-HTIWY3O5.js";
|
|
44
49
|
import {
|
|
45
50
|
enablePackageLogging
|
|
46
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-LWCVB42S.js";
|
|
47
52
|
import {
|
|
48
53
|
ensureTunnelConfigDir,
|
|
49
54
|
getDaemonInfoPath,
|
|
50
55
|
getPinggyConfigDir,
|
|
51
56
|
getTunnelConfigDir
|
|
52
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-MAK5R4WQ.js";
|
|
53
58
|
|
|
54
59
|
// src/utils/detect_vc_redist_on_windows.ts
|
|
55
60
|
import fs from "fs";
|
|
@@ -141,7 +146,7 @@ async function verifyAndLoad() {
|
|
|
141
146
|
process.exit(1);
|
|
142
147
|
}
|
|
143
148
|
}
|
|
144
|
-
await import("./main-
|
|
149
|
+
await import("./main-BI7ACRHS.js");
|
|
145
150
|
}
|
|
146
151
|
verifyAndLoad().catch((err) => {
|
|
147
152
|
printer_default.fatal(`Failed to start CLI:, ${err}`);
|