pinggy 0.6.4 → 0.6.5
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 +37 -22
- package/CLAUDE.md +8 -5
- package/README.md +5 -5
- package/dist/{TunnelManager-NGSUBZYI.js → TunnelManager-DXNXIH5W.js} +3 -3
- package/dist/{TunnelTui-UCG2YSLX.js → TunnelTui-K7KESRTQ.js} +3 -3
- package/dist/{chunk-CIOYQU7F.js → chunk-3PTLHLFL.js} +32 -9
- package/dist/{chunk-QNUVQ6KD.js → chunk-EMCDDH3B.js} +2 -2
- package/dist/{chunk-MV56U3E6.js → chunk-IRKMUV37.js} +2 -2
- package/dist/{chunk-UVJYL2ZN.js → chunk-K5QHR5KU.js} +648 -238
- package/dist/{chunk-AFMTIELL.js → chunk-N5WE4DYD.js} +8 -0
- package/dist/{chunk-Y435RMHQ.js → chunk-QZJGTQZC.js} +2 -2
- package/dist/{chunk-PD7HXVQ3.js → chunk-X6TZN5CT.js} +18 -1
- package/dist/{configStore-RR5ZU4E3.js → configStore-DXC6WMYO.js} +3 -3
- package/dist/{daemonChild-WHS676G4.js → daemonChild-HZ27YJKQ.js} +7 -11
- package/dist/daemonConfig-MCAKZHY2.js +17 -0
- package/dist/index.cjs +768 -253
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +6 -6
- package/dist/{main-JRVKAIHH.js → main-TDQB5ZB4.js} +7 -7
- package/dist/workers/file_serve_worker.js +1 -1
- package/package.json +1 -1
- package/scripts/install/install.ps1 +46 -4
- package/scripts/install/install.sh +65 -6
- package/dist/daemonConfig-QVXQ47XH.js +0 -9
package/dist/index.d.cts
CHANGED
|
@@ -1167,6 +1167,14 @@ declare class TunnelClient {
|
|
|
1167
1167
|
private shimListenerSeq;
|
|
1168
1168
|
constructor(options?: TunnelClientOptions);
|
|
1169
1169
|
ensureDaemon(): Promise<void>;
|
|
1170
|
+
/**
|
|
1171
|
+
* Connects to the daemon that runs now, and never starts one. For commands that only read state.
|
|
1172
|
+
* Throws when that daemon speaks another IPC version, as ensureDaemon() does.
|
|
1173
|
+
*
|
|
1174
|
+
* @returns false when no daemon runs
|
|
1175
|
+
*/
|
|
1176
|
+
connectIfRunning(): boolean;
|
|
1177
|
+
private bindDaemon;
|
|
1170
1178
|
static forRemoteManagement(): Promise<TunnelClient>;
|
|
1171
1179
|
/**
|
|
1172
1180
|
* Close the WebSocket connection and cleanup.
|
package/dist/index.d.ts
CHANGED
|
@@ -1167,6 +1167,14 @@ declare class TunnelClient {
|
|
|
1167
1167
|
private shimListenerSeq;
|
|
1168
1168
|
constructor(options?: TunnelClientOptions);
|
|
1169
1169
|
ensureDaemon(): Promise<void>;
|
|
1170
|
+
/**
|
|
1171
|
+
* Connects to the daemon that runs now, and never starts one. For commands that only read state.
|
|
1172
|
+
* Throws when that daemon speaks another IPC version, as ensureDaemon() does.
|
|
1173
|
+
*
|
|
1174
|
+
* @returns false when no daemon runs
|
|
1175
|
+
*/
|
|
1176
|
+
connectIfRunning(): boolean;
|
|
1177
|
+
private bindDaemon;
|
|
1170
1178
|
static forRemoteManagement(): Promise<TunnelClient>;
|
|
1171
1179
|
/**
|
|
1172
1180
|
* Close the WebSocket connection and cleanup.
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
initiateRemoteManagement,
|
|
12
12
|
isDaemonRunning,
|
|
13
13
|
startRemoteManagement
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-3PTLHLFL.js";
|
|
15
15
|
import {
|
|
16
16
|
DeviceAgentState
|
|
17
17
|
} from "./chunk-7EQKHVQX.js";
|
|
@@ -32,24 +32,24 @@ import {
|
|
|
32
32
|
validateName,
|
|
33
33
|
validateNameForStorage,
|
|
34
34
|
validateNameStrict
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-QZJGTQZC.js";
|
|
36
36
|
import {
|
|
37
37
|
TunnelErrorCodeType,
|
|
38
38
|
TunnelManager,
|
|
39
39
|
TunnelStateType,
|
|
40
40
|
TunnelWarningCode,
|
|
41
41
|
printer_default
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-EMCDDH3B.js";
|
|
43
43
|
import "./chunk-UB26QJ4T.js";
|
|
44
44
|
import {
|
|
45
45
|
enablePackageLogging
|
|
46
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-IRKMUV37.js";
|
|
47
47
|
import {
|
|
48
48
|
ensureTunnelConfigDir,
|
|
49
49
|
getDaemonInfoPath,
|
|
50
50
|
getPinggyConfigDir,
|
|
51
51
|
getTunnelConfigDir
|
|
52
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-N5WE4DYD.js";
|
|
53
53
|
|
|
54
54
|
// src/utils/detect_vc_redist_on_windows.ts
|
|
55
55
|
import fs from "fs";
|
|
@@ -141,7 +141,7 @@ async function verifyAndLoad() {
|
|
|
141
141
|
process.exit(1);
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
-
await import("./main-
|
|
144
|
+
await import("./main-TDQB5ZB4.js");
|
|
145
145
|
}
|
|
146
146
|
verifyAndLoad().catch((err) => {
|
|
147
147
|
printer_default.fatal(`Failed to start CLI:, ${err}`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
runDaemonChild
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-K5QHR5KU.js";
|
|
5
5
|
import {
|
|
6
6
|
RemoteManagementUnauthorizedError,
|
|
7
7
|
TunnelOperations,
|
|
@@ -13,21 +13,21 @@ import {
|
|
|
13
13
|
getRemoteManagementState,
|
|
14
14
|
initiateRemoteManagement,
|
|
15
15
|
isDaemonRunning
|
|
16
|
-
} from "./chunk-
|
|
17
|
-
import "./chunk-
|
|
16
|
+
} from "./chunk-3PTLHLFL.js";
|
|
17
|
+
import "./chunk-X6TZN5CT.js";
|
|
18
18
|
import {
|
|
19
19
|
DaemonHost
|
|
20
20
|
} from "./chunk-7EQKHVQX.js";
|
|
21
|
-
import "./chunk-
|
|
21
|
+
import "./chunk-QZJGTQZC.js";
|
|
22
22
|
import "./chunk-XZ64ZAGO.js";
|
|
23
23
|
import {
|
|
24
24
|
TunnelManager
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-EMCDDH3B.js";
|
|
26
26
|
import "./chunk-UB26QJ4T.js";
|
|
27
27
|
import {
|
|
28
28
|
enablePackageLogging
|
|
29
|
-
} from "./chunk-
|
|
30
|
-
import "./chunk-
|
|
29
|
+
} from "./chunk-IRKMUV37.js";
|
|
30
|
+
import "./chunk-N5WE4DYD.js";
|
|
31
31
|
export {
|
|
32
32
|
DaemonHost,
|
|
33
33
|
RemoteManagementUnauthorizedError,
|
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
# Installs or updates the Pinggy CLI on Windows, then
|
|
1
|
+
# Installs or updates the Pinggy CLI on Windows, then asks whether to sign this machine in as a Pinggy device.
|
|
2
|
+
# Once the device connects, it asks whether to start pinggy at login, unless that task is already registered.
|
|
2
3
|
#
|
|
3
4
|
# irm https://pinggy.io/install.ps1 | iex
|
|
4
5
|
# $env:DEVICE_AGENT_TOKEN='<token>'; irm https://pinggy.io/install.ps1 | iex
|
|
@@ -34,6 +35,8 @@ function Install-Pinggy {
|
|
|
34
35
|
$installDir = Join-Path $env:LOCALAPPDATA 'Pinggy\bin'
|
|
35
36
|
$installPath = Join-Path $installDir 'pinggy.exe'
|
|
36
37
|
$versionPattern = 'Pinggy CLI version:\s*(\S+)'
|
|
38
|
+
# The task `pinggy daemon service-install` registers. Its name lives in src/daemon/lifecycle/serviceInstaller.ts.
|
|
39
|
+
$loginTaskName = 'PinggyDaemon'
|
|
37
40
|
$cpuArchitectureX64 = 9
|
|
38
41
|
$cpuArchitectureArm64 = 12
|
|
39
42
|
|
|
@@ -97,7 +100,7 @@ function Install-Pinggy {
|
|
|
97
100
|
}
|
|
98
101
|
|
|
99
102
|
# Enter, or no terminal, means yes. Only an answer starting with n means no.
|
|
100
|
-
function Confirm-
|
|
103
|
+
function Confirm-Question([string] $question) {
|
|
101
104
|
if (-not (Test-Interactive)) { return $true }
|
|
102
105
|
$answer = Read-Host $question
|
|
103
106
|
return -not ($answer -match '^\s*n')
|
|
@@ -177,7 +180,7 @@ function Install-Pinggy {
|
|
|
177
180
|
# An older CLI ignores DEVICE_AGENT_TOKEN, so keeping it would leave the machine unconnected.
|
|
178
181
|
Write-Host "Updating pinggy $installedVersion to $targetVersion."
|
|
179
182
|
Install-Binary $tag $cpu
|
|
180
|
-
} elseif (Confirm-
|
|
183
|
+
} elseif (Confirm-Question "pinggy $installedVersion is installed. Update to $($targetVersion)? [Y/n]") {
|
|
181
184
|
Install-Binary $tag $cpu
|
|
182
185
|
} else {
|
|
183
186
|
Write-Host "Keeping pinggy $installedVersion."
|
|
@@ -214,6 +217,36 @@ function Install-Pinggy {
|
|
|
214
217
|
}
|
|
215
218
|
}
|
|
216
219
|
|
|
220
|
+
# The task counts only when it runs the binary this script installs. A task left by a pinggy elsewhere gets the
|
|
221
|
+
# question, and service-install replaces it. Get-ScheduledTask, because schtasks prints field names in the
|
|
222
|
+
# language of Windows.
|
|
223
|
+
function Test-LoginTask {
|
|
224
|
+
try {
|
|
225
|
+
$task = Get-ScheduledTask -TaskName $loginTaskName -ErrorAction Stop
|
|
226
|
+
} catch {
|
|
227
|
+
return $false
|
|
228
|
+
}
|
|
229
|
+
return @($task.Actions | Where-Object { $_.Execute -ieq $installPath }).Count -gt 0
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
# Asks once the device connects, so the agent starts again after a restart. Leaves a registered task as it is.
|
|
233
|
+
function Invoke-LoginServiceOffer {
|
|
234
|
+
if (Test-LoginTask) { return }
|
|
235
|
+
if (-not (Test-Interactive)) {
|
|
236
|
+
Write-Host 'To start pinggy when this computer starts, run: pinggy daemon service-install'
|
|
237
|
+
return
|
|
238
|
+
}
|
|
239
|
+
Write-Host ''
|
|
240
|
+
if (-not (Confirm-Question 'Start pinggy automatically when this computer starts? [Y/n]')) {
|
|
241
|
+
Write-Host 'To start pinggy when this computer starts, run: pinggy daemon service-install'
|
|
242
|
+
return
|
|
243
|
+
}
|
|
244
|
+
& $installPath daemon service-install
|
|
245
|
+
if ($LASTEXITCODE -ne 0) {
|
|
246
|
+
Write-Host 'Could not set up the login service. To try again, run: pinggy daemon service-install'
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
217
250
|
# Runs the installed file by its full path, so an npm-installed pinggy earlier on PATH does not answer. -b is the
|
|
218
251
|
# default now. It is passed anyway, so an older pinggy the user kept runs the agent in its daemon too.
|
|
219
252
|
function Invoke-DeviceLogin {
|
|
@@ -227,16 +260,25 @@ function Install-Pinggy {
|
|
|
227
260
|
return
|
|
228
261
|
}
|
|
229
262
|
Write-Host ''
|
|
263
|
+
if (-not (Confirm-Question 'Connect this device to Pinggy? [Y/n]')) {
|
|
264
|
+
Write-Host "Installed. To connect this device later, run: pinggy $($loginArguments -join ' ')"
|
|
265
|
+
return
|
|
266
|
+
}
|
|
230
267
|
& $installPath @loginArguments -b
|
|
268
|
+
if ($LASTEXITCODE -eq 0) { Invoke-LoginServiceOffer }
|
|
231
269
|
}
|
|
232
270
|
|
|
233
271
|
# Runs the installed file by its full path, with -b, as Invoke-DeviceLogin does. connect reads DEVICE_AGENT_TOKEN
|
|
234
|
-
# from the environment it inherits, and reads no key, so it runs the same with no console.
|
|
272
|
+
# from the environment it inherits, and reads no key, so it runs the same with no console. The token leaves the
|
|
273
|
+
# environment before the service question, so no later command inherits it.
|
|
235
274
|
function Invoke-DeviceConnect {
|
|
236
275
|
$connectArguments = @('device', 'connect', '-b')
|
|
237
276
|
if ($env:PINGGY_MANAGE) { $connectArguments += @('--manage', $env:PINGGY_MANAGE) }
|
|
238
277
|
Write-Host ''
|
|
239
278
|
& $installPath @connectArguments
|
|
279
|
+
$connectExitCode = $LASTEXITCODE
|
|
280
|
+
Remove-Item -Path Env:\DEVICE_AGENT_TOKEN -ErrorAction SilentlyContinue
|
|
281
|
+
if ($connectExitCode -eq 0) { Invoke-LoginServiceOffer }
|
|
240
282
|
}
|
|
241
283
|
|
|
242
284
|
# Older Windows PowerShell 5.1 setups offer less than TLS 1.2, and GitHub refuses them.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/bin/sh
|
|
2
|
-
# Installs or updates the Pinggy CLI on macOS and Linux, then
|
|
2
|
+
# Installs or updates the Pinggy CLI on macOS and Linux, then asks whether to sign this machine in as a Pinggy device.
|
|
3
|
+
# Once the device connects, it asks whether to start pinggy at login, unless that service is already installed.
|
|
3
4
|
#
|
|
4
5
|
# curl -fsSL https://pinggy.io/install.sh | sh
|
|
5
6
|
# curl -fsSL https://pinggy.io/install.sh | DEVICE_AGENT_TOKEN=<token> sh
|
|
@@ -333,17 +334,64 @@ add_link_dir_to_rc_file() {
|
|
|
333
334
|
say "In this terminal, run: source $(shown "$rc_file")"
|
|
334
335
|
}
|
|
335
336
|
|
|
337
|
+
# The service file `pinggy daemon service-install` writes. Its paths live in src/daemon/lifecycle/serviceInstaller.ts.
|
|
338
|
+
# The service counts only when it runs the binary this script installs. A service left by a pinggy elsewhere gets the
|
|
339
|
+
# question, and service-install replaces it.
|
|
340
|
+
login_service_installed() {
|
|
341
|
+
case "$os" in
|
|
342
|
+
macos) service_file="$HOME/Library/LaunchAgents/io.pinggy.agent.plist" ;;
|
|
343
|
+
linux) service_file="$HOME/.config/systemd/user/pinggy.service" ;;
|
|
344
|
+
esac
|
|
345
|
+
[ -f "$service_file" ] && grep -qF "$INSTALL_PATH" "$service_file"
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
# A container or a session with no systemd user manager cannot run the Linux service.
|
|
349
|
+
login_service_supported() {
|
|
350
|
+
if [ "$os" = macos ]; then
|
|
351
|
+
return 0
|
|
352
|
+
fi
|
|
353
|
+
has_command systemctl && systemctl --user show-environment >/dev/null 2>&1
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
# Asks once the device connects, so the agent starts again after a restart. Leaves an installed service as it is.
|
|
357
|
+
offer_login_service() {
|
|
358
|
+
if login_service_installed || ! login_service_supported; then
|
|
359
|
+
return 0
|
|
360
|
+
fi
|
|
361
|
+
if ! has_terminal; then
|
|
362
|
+
say "To start pinggy when this computer starts, run: pinggy daemon service-install"
|
|
363
|
+
return 0
|
|
364
|
+
fi
|
|
365
|
+
|
|
366
|
+
say ""
|
|
367
|
+
if ! confirm "Start pinggy automatically when this computer starts? [Y/n] "; then
|
|
368
|
+
say "To start pinggy when this computer starts, run: pinggy daemon service-install"
|
|
369
|
+
return 0
|
|
370
|
+
fi
|
|
371
|
+
if ! "$INSTALL_PATH" daemon service-install </dev/null; then
|
|
372
|
+
say "Could not set up the login service. To try again, run: pinggy daemon service-install"
|
|
373
|
+
fi
|
|
374
|
+
}
|
|
375
|
+
|
|
336
376
|
# Runs the installed file by its full path, so an npm-installed pinggy earlier on PATH does not answer. connect reads
|
|
337
377
|
# DEVICE_AGENT_TOKEN from the environment this script passes on, and reads no key, so it runs the same with no
|
|
338
378
|
# terminal. -b is the default now. It is passed anyway, so an older pinggy the user kept runs the agent in its daemon
|
|
339
|
-
# too.
|
|
379
|
+
# too. The token leaves the environment before the service question, so no later command inherits it.
|
|
340
380
|
connect_with_device_token() {
|
|
341
381
|
export DEVICE_AGENT_TOKEN
|
|
342
382
|
say ""
|
|
383
|
+
status=0
|
|
343
384
|
if [ -n "${PINGGY_MANAGE:-}" ]; then
|
|
344
|
-
|
|
385
|
+
"$INSTALL_PATH" device connect -b --manage "$PINGGY_MANAGE" </dev/null || status=$?
|
|
386
|
+
else
|
|
387
|
+
"$INSTALL_PATH" device connect -b </dev/null || status=$?
|
|
345
388
|
fi
|
|
346
|
-
|
|
389
|
+
unset DEVICE_AGENT_TOKEN
|
|
390
|
+
if [ "$status" -ne 0 ]; then
|
|
391
|
+
exit "$status"
|
|
392
|
+
fi
|
|
393
|
+
offer_login_service
|
|
394
|
+
exit 0
|
|
347
395
|
}
|
|
348
396
|
|
|
349
397
|
# Runs the installed file by its full path, so an npm-installed pinggy earlier on PATH does not answer. -b as above.
|
|
@@ -361,10 +409,21 @@ start_sign_in() {
|
|
|
361
409
|
fi
|
|
362
410
|
|
|
363
411
|
say ""
|
|
412
|
+
if ! confirm "Connect this device to Pinggy? [Y/n] "; then
|
|
413
|
+
say "Installed. To connect this device later, run: $login_command"
|
|
414
|
+
return 0
|
|
415
|
+
fi
|
|
416
|
+
|
|
417
|
+
status=0
|
|
364
418
|
if [ -n "${PINGGY_MANAGE:-}" ]; then
|
|
365
|
-
|
|
419
|
+
"$INSTALL_PATH" device login -b --manage "$PINGGY_MANAGE" </dev/tty || status=$?
|
|
420
|
+
else
|
|
421
|
+
"$INSTALL_PATH" device login -b </dev/tty || status=$?
|
|
422
|
+
fi
|
|
423
|
+
if [ "$status" -ne 0 ]; then
|
|
424
|
+
exit "$status"
|
|
366
425
|
fi
|
|
367
|
-
|
|
426
|
+
offer_login_service
|
|
368
427
|
}
|
|
369
428
|
|
|
370
429
|
main() {
|