pinggy 0.6.10 → 0.6.11
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 +9 -4
- package/CLAUDE.md +5 -3
- package/README.md +12 -0
- package/dist/{chunk-AYU3GM4D.js → chunk-RYO5T2JT.js} +35 -19
- package/dist/{chunk-G3NF35JY.js → chunk-W47AYOH2.js} +2819 -278
- package/dist/{daemonChild-4ZZ3YQDL.js → daemonChild-GGG34AOT.js} +2 -2
- package/dist/index.cjs +3070 -378
- package/dist/index.js +3 -3
- package/dist/{main-3D7R75PR.js → main-FCIOVX5I.js} +2 -2
- package/dist/{updateChild-ZOC3VGJL.js → updateChild-RNCLN24C.js} +1 -1
- package/package.json +1 -1
- package/scripts/install/install.ps1 +3 -2
- package/scripts/install/install.sh +13 -7
package/ARCHITECTURE.md
CHANGED
|
@@ -516,7 +516,7 @@ The one long-lived surface that is not a tunnel. `pinggy device connect` enrols
|
|
|
516
516
|
|
|
517
517
|
**A downloaded binary installs itself.** `offerSelfInstall()` in `src/install/selfInstall.ts` runs in `main.ts` before the background update. A packaged binary that is not the installed copy (`UnixLayout` or `UnixPlainFile`, or on Windows any file in `%LOCALAPPDATA%\Pinggy\bin`) asks 1 question when stdin and stdout are terminals. With nothing installed, or when `pinggy` runs a copy it cannot remove (`npm link`, pnpm, yarn, bun, another binary): "Install this pinggy, X, to ~/.pinggy/bin/pinggy? [Y/n]". With the scripts' binary installed, whatever its version: "pinggy X is installed in ~/.pinggy/bin/pinggy. Replace it with this pinggy, Y? [Y/n]". When `pinggy` runs an npm copy, whatever its version: "pinggy X is installed with npm. Remove it, and install this pinggy, Y, to ~/.pinggy/bin/pinggy? [Y/n]". The versions are printed and never compared, so an older file can replace a newer install, and the same version asks again. `src/install/pinggyOnPath.ts` finds the copy with the scripts' npm rules and never counts the current folder. No question for `--version`, `--help` or `pinggy update`, under sudo, in a container, while `update.lock` is held, when `update.json` cannot be written, or for a file and version the user said `n` to (`declinedInstallPath`, `declinedInstallVersion`). Yes copies the install script the binary carries in `pkg.assets` to a private temp folder and runs it with `PINGGY_BINARY_URL` naming this file and `PINGGY_INSTALL_ONLY=1`, which ends the script after the install, with no sign-in and no PATH warning. So the files match the scripts' layout exactly. `install.ps1` runs through `iex`, so an execution policy that blocks script files does not block it. For an npm copy the binary installs first, then runs `npm uninstall -g --prefix <prefix> pinggy`, and prints the `sudo` command for a folder it cannot write. It prints the PATH warning itself, then runs the user's command in the same process. A daemon that command starts runs from the installed copy (`startDaemonFromInstalledBinary()`). The installed binary's version comes from its link target, with no process. A plain file's or the Windows binary's `--version` output is kept in `update.json` with the file's size and modified time. Ctrl+D answers nothing, and a failed install counts as `n`. A double-clicked `pinggy.exe` ends with "Press Enter to close.", and the Windows updater moves a remembered `n` to the new version when it replaces that file in place. In the scripts' own case 7, after `n`, sign-in runs the user's binary, which can ask its own question once.
|
|
518
518
|
|
|
519
|
-
**The token command.** The dashboard shows `curl -fsSL https://pinggy.io/install.sh | DEVICE_AGENT_TOKEN=<token> sh`, and `$env:DEVICE_AGENT_TOKEN='<token>'; irm https://pinggy.io/install.ps1 | iex` on Windows. With the variable set, both scripts still ask every update question, then run `pinggy device connect -b` by full path, with `--manage` when `PINGGY_MANAGE` is set. The token reaches the CLI in its environment, never on a command line, where `ps` would show it. `install.sh` gives `connect` `/dev/
|
|
519
|
+
**The token command.** The dashboard shows `curl -fsSL https://pinggy.io/install.sh | DEVICE_AGENT_TOKEN=<token> sh`, and `$env:DEVICE_AGENT_TOKEN='<token>'; irm https://pinggy.io/install.ps1 | iex` on Windows. With the variable set, both scripts still ask every update question, then run `pinggy device connect -b` by full path, with `--manage` when `PINGGY_MANAGE` is set. The token reaches the CLI in its environment, never on a command line, where `ps` would show it. `install.sh` gives `connect` `/dev/tty` as stdin when it has a terminal, so `connect` can ask the file access question (`device.json` below), and `/dev/null` otherwise. Never its own stdin, which under `curl | sh` holds the rest of the script. `install.ps1` leaves `connect` the console. `install.ps1` removes the variable in a `finally`, because `iex` runs in the user's own window. `handleDevice()` reads `DEVICE_AGENT_TOKEN` and deletes it from `process.env` before any verb runs, so no shell, daemon or other child inherits it (`takeEnvironmentToken()` in `deviceCommand.ts`). `connect` then picks the token from `--token`, else the variable, else `device.json`, and the server from `--manage`, else `dashboard.pinggy.io` for a token from the variable, else the server in `device.json` (`resolveConnectTarget()`). An empty variable counts as unset. A pinggy older than 0.6.2 ignores the variable, so a user who keeps one at the update question gets no connection.
|
|
520
520
|
|
|
521
521
|
The design lives in the `pinggy_backend` repo under `docs/pinggy-devices/`: `cli.md` is the CLI contract. The wire format is `src/devices/envelope.ts` and the zod schemas under `src/devices/`. This section records what the CLI implements today.
|
|
522
522
|
|
|
@@ -573,7 +573,8 @@ The daemon's run differs from the foreground one in 3 dependencies, passed throu
|
|
|
573
573
|
| --- | --- |
|
|
574
574
|
| `src/devices/envelope.ts` | The versioned frame wrapper. `request()`, `event()`, `parseEnvelope()`, channel and op constants |
|
|
575
575
|
| `src/devices/device_schema.ts` | Zod schemas for `welcome`, error, and `disconnect` payloads. Types for `hello`, `heartbeat`, `device/info`, `device/metrics`, and `device/tunnels` |
|
|
576
|
-
| `src/devices/deviceIdentity.ts` | `device.json` read, write, clear, and token masking |
|
|
576
|
+
| `src/devices/deviceIdentity.ts` | `device.json` read, write, clear, and token masking. A write with no `file_manager` keeps the stored one for the same token |
|
|
577
|
+
| `src/devices/fileAccess.ts` | The file access question, `--files`, `fileAccessAllowed()` for the file handler, and the `Files` line of `device status` |
|
|
577
578
|
| `src/devices/deviceAgent.ts` | URL build, connect loop, frame dispatch, heartbeat and metrics timers. `startDeviceAgent()` returns a run with `stop()` and `done`; `runDeviceAgent()` is the foreground entry with the SIGINT handler |
|
|
578
579
|
| `src/devices/deviceAgentReporter.ts` | `DeviceAgentReporter`, the run's events. `printingReporter`: the foreground's terminal output. `printConnected()` |
|
|
579
580
|
| `src/devices/backgroundAgent.ts` | The CLI's half of the background agent: verify a new target, print the manage commands, start the daemon's agent, wait for `connected`. `device stop`, the `status` line, the stop before `remove`, the foreground refusal |
|
|
@@ -592,7 +593,7 @@ The daemon's run differs from the foreground one in 3 dependencies, passed throu
|
|
|
592
593
|
| `src/devices/terminal/ptySession.ts` | Lazy `node-pty` load, `isTerminalSupported()` (false unless the addon loads and, on macOS, `spawn-helper` can be exec'd), `spawnPty()`, the `spawn-helper` execute-bit repair, `signalForeground()` to the tty's foreground process group |
|
|
593
594
|
| `src/devices/terminal/nodePtyRuntime.ts` | `resolveNodePtyRoot()`: where `node-pty` loads from. Unpacks it onto real disk inside a `pkg` binary or an Electron `.asar` archive, into a directory named by the addon's hash. `hasExecutableSpawnHelper()`, true off macOS |
|
|
594
595
|
| `src/devices/terminal/shellAllowlist.ts` | `resolveShell()`: exact match against `/etc/shells`, or `powershell.exe` and `cmd.exe` on Windows |
|
|
595
|
-
| `src/cli/subcommand/handlers/deviceCommand.ts` | The `login`, `connect`, `stop`, `status`, `remove` verbs, and `--
|
|
596
|
+
| `src/cli/subcommand/handlers/deviceCommand.ts` | The `login`, `connect`, `stop`, `status`, `remove` verbs, `--foreground` and `--files`. `refuseDevicesSpelling()` for the old spelling |
|
|
596
597
|
| `src/utils/helpMessages.ts` | `printDeviceHelp()` |
|
|
597
598
|
|
|
598
599
|
`Subcommand.Device` in `src/cli/configStore.ts` puts `device` in `SUBCOMMANDS` and `RESERVED_NAMES`, so no new saved tunnel config can be named `device`. `Subcommand.Devices` keeps the old spelling in both. `pinggy devices` prints `"pinggy devices" is now "pinggy device". Run: pinggy device <verb>` and exits 1. It names the verb only when it is 1 of the 5, else `--help`, and never repeats the other arguments, which can hold a token. Without it, `devices` would fall to legacy tunnel mode, where `--token` is the tunnel token, and a device token would reach the tunnel server.
|
|
@@ -792,9 +793,13 @@ Retry sleeps an exponential backoff with full jitter: 1 s doubling to a 60 s cap
|
|
|
792
793
|
|
|
793
794
|
```json
|
|
794
795
|
{"device_agent_id": "0a7d3f6c-2b41-4e8a-9c5d-1e2f3a4b5c6d", "token": "...",
|
|
795
|
-
"server": "dashboard.pinggy.io", "enrolled_at": "2026-09-05T09:22:10Z"}
|
|
796
|
+
"server": "dashboard.pinggy.io", "enrolled_at": "2026-09-05T09:22:10Z", "file_manager": true}
|
|
796
797
|
```
|
|
797
798
|
|
|
799
|
+
**`file_manager` is the answer to the file access question**, "Allow file access from the Pinggy dashboard? Your account can browse, copy, move and delete this machine's files from the browser. [Y/n]" (`src/devices/fileAccess.ts`). `connect`, `start` and `login` ask it once per device token, in a terminal, before the agent starts. Only an answer that starts with `n` means no. `--files on|off` answers it with no question, and any other value exits 1. With no terminal, nothing is asked or saved, and absent counts as allowed, so the next run in a terminal asks. For the token `device.json` holds, the answer is written at once. A new token's answer rides on the run (`DeviceAgentOptions.fileManager`): the verify of a background `connect`, or the foreground run, writes it with the token at `welcome`. Ctrl+C at the question changes nothing in `connect`. In `login`, after the sign-in, it keeps the new credential with no answer and runs no agent. `device status` prints `Files on`, `Files off` or `Files on, not asked yet`.
|
|
800
|
+
|
|
801
|
+
The file handler reads the answer on every request (`fileAccessAllowed()`) and refuses with `file_access_off` while it is no, after the `file_manager_disabled` check. `file_manager` stays in `hello`'s capabilities, and the dashboard passes the agent's code and message to the tab. A new answer applies to the next request with no restart, so open terminals stay open. A run copies `device.json` at start and rewrites it on every `welcome`: `identityForRun()` drops the stored `file_manager` from that copy, and `writeDeviceIdentity()` keeps the one on disk for the same token when the identity it writes has none. Without both, a `--files off` given while the agent runs turns back on at the next reconnect.
|
|
802
|
+
|
|
798
803
|
`getDeviceConfigPath()` puts it beside `tunnels/`, not inside it: a device is not a tunnel config. `device_agent_id` is minted by the dashboard and read from `welcome`; the agent never invents one. A token from `--token` or `DEVICE_AGENT_TOKEN` always beats the stored value. When it differs from the stored token, `identityForRun()` starts a new identity, with no old `device_agent_id` and no old `enrolled_at`. At the 1st `welcome`, and not before, the run reports "This machine was device <old id>. That device stays in the dashboard, offline." A token the dashboard refuses replaces nothing, so it reports nothing.
|
|
799
804
|
|
|
800
805
|
**Written 0600, then chmodded again on every rewrite**, because `writeFileSync` applies `mode` only when it creates the file. This diverges from `configStore.ts`, which writes tunnel tokens at 0644 under a normal umask. Do not copy that pattern into anything new.
|
package/CLAUDE.md
CHANGED
|
@@ -57,7 +57,7 @@ Single daemon per user. State lives under `~/.config/pinggy/` on Linux/macOS or
|
|
|
57
57
|
- `daemon-config.json`: settings that survive a clean shutdown (`src/daemon/lifecycle/daemonConfig.ts`): the log level, and `deviceAgent`, set while the background device agent should run. Every daemon start runs that agent. `pinggy device remove` deletes it. `pinggy device stop` keeps it, so the agent starts again with the next daemon.
|
|
58
58
|
- `daemon.log`: SDK + daemon logs. CLI logs stay separate.
|
|
59
59
|
- `tunnels/<name>_<configId>.json`: saved tunnel configs from `pinggy config save`.
|
|
60
|
-
- `device.json`: device agent id and token from `pinggy device connect` (`src/devices/deviceIdentity.ts`). Written 0600, unlike the tunnel configs beside it.
|
|
60
|
+
- `device.json`: device agent id and token from `pinggy device connect` (`src/devices/deviceIdentity.ts`), and `file_manager`, the answer to the file access question. Written 0600, unlike the tunnel configs beside it.
|
|
61
61
|
- `device-agent.json`: `{pid, started_at, boot_id}` of a device agent started with `--foreground`, while it runs (`src/devices/foregroundAgent.ts`). `pinggy device remove` deletes it, and the agent stops within 1 s. No credential.
|
|
62
62
|
|
|
63
63
|
### Foreground vs detached tunnels
|
|
@@ -77,11 +77,13 @@ Single daemon per user. State lives under `~/.config/pinggy/` on Linux/macOS or
|
|
|
77
77
|
|
|
78
78
|
It owns no tunnel. It reads the daemon's `GET /tunnels` through `IPCClient` and the saved configs, to send `device/tunnels` (`src/devices/tunnels/tunnelList.ts`), and listing never starts a daemon. It stops, restarts and starts tunnels when the dashboard asks (`src/devices/tunnels/tunnelActions.ts`), through `IPCClient` with the `device` origin; only a start of a config may call `ensureDaemonRunning()`. It also applies an updated dashboard config to the tunnel running it, through the daemon's `update-config-v2`, and it rewrites a saved config's file when the dashboard edits it (`upsertConfig()`, no daemon). `pinggy device login` signs the machine in by email over plain HTTPS (`src/devices/login/`), writes `device.json`, then runs the same agent; the sign-in can also be approved from the email's link, and the poll collects it. No `TunnelManager`. It also does not reuse `src/remote_management/`, which is a tunnel controller keyed by an API key rather than the machine keyed by a device token. Frames use a versioned envelope (`src/devices/envelope.ts`) validated with zod (`src/devices/device_schema.ts`); an unknown `ch` or `op` is ignored, never fatal.
|
|
79
79
|
|
|
80
|
+
`connect`, `start` and `login` ask once per device token, in a terminal, "Allow file access from the Pinggy dashboard?" (`src/devices/fileAccess.ts`). `--files on|off` answers it with no question. `device.json` holds the answer as `file_manager`. With no terminal nothing is asked or saved, and file access stays on. The file handler reads the answer on every request and refuses with `file_access_off` while it is no, so a new answer applies with no restart. A run rewrites `device.json` on every `welcome` from what it read at start, so `identityForRun()` drops the stored answer and `writeDeviceIdentity()` keeps the one on disk for the same token. Any new writer of `device.json` keeps that rule, or a `--files off` given while the agent runs turns back on at the next reconnect.
|
|
81
|
+
|
|
80
82
|
`pinggy device connect` and `login` run the agent in the daemon, as `pinggy start -b` runs a tunnel there, so it outlives the terminal. `pinggy device start` is the same verb as `connect`. `--foreground` runs it in the CLI process instead, until Ctrl+C. `-b` still parses and changes nothing; `-b` with `--foreground` exits 1. `--foreground` sits hidden in `cliOptions`, because `main.ts` parses the whole command line with it, strict, before it dispatches. Whoever hosts the daemon, the CLI's child or the Pinggy app, hosts the agent (`src/daemon/deviceAgentHost.ts`, `src/devices/backgroundAgent.ts`). `GET /device`, `POST /device/start` and `POST /device/stop` reach it, and `TunnelClient` exposes them for the app. No IPC route takes or returns a token or a server: the daemon reads both from `device.json`, and a new token is checked in the CLI with 1 handshake before the daemon sees it. Once the daemon starts the agent, the CLI prints the commands that manage it (`status`, `stop`, `start`, `connect`, `remove`). `pinggy device stop` stops it. A `--foreground` `connect` or `login` refuses while it runs. The loop prints nothing itself: it calls a `DeviceAgentReporter`, and the foreground's prints the same lines as before.
|
|
81
83
|
|
|
82
84
|
1 invocation runs 1 subcommand: `isSubcommand()` reads `rawArgs[0]` only, so `pinggy device connect start my-tunnel` runs the agent and drops the rest, and tunnel flags on a `device` line parse and are ignored, except `-b` and `--foreground`.
|
|
83
85
|
|
|
84
|
-
`scripts/install/install.sh` installs into `~/.pinggy/versions/<version>/` and points the link `~/.pinggy/bin/pinggy` at it. `install.sh` and `install.ps1` install or update the binary, put it on PATH, then ask "Connect this device to Pinggy? [Y/n]" and run `pinggy device login -b` unless the answer starts with `n`. `-b` is the default, and the scripts pass it so an older binary the user kept also runs the agent in its daemon. pinggy.io serves copies that `website-cli-download-links-pr.yml` writes at each release tag. The scripts read the version to install from `https://pinggy.io/cli/version.json`, which the website builds from the `data/cli_releases.yaml` that the same PR updates, and they exit 1 when it does not answer. They download the binary from the GitHub release. The updater in `src/update/` still reads GitHub's `/releases/latest`. Copies of the scripts stay in use, so that URL and its `version` field never change. Renaming a release asset, changing the `Pinggy CLI version:` line, or changing `device login`'s `--manage` or `-b` flag means changing both scripts in the same commit. `DEVICE_AGENT_TOKEN` on either script still gets every update question, then runs `pinggy device connect -b` instead, with the token in the environment, never on a command line. `handleDevice()` deletes the variable from `process.env` before any verb runs, so no shell or daemon the agent starts inherits it. Renaming the variable or `connect`'s `--manage` or `-b` flag also changes both scripts in the same commit. Both scripts update the copy the `pinggy` command runs: an npm copy with `npm install -g --prefix`, the binary otherwise. A copy from `npm link`, pnpm, yarn or bun stops them, and a binary they did not install gets a question first (ARCHITECTURE.md, "Which copy the scripts update"). They tell an npm copy by the `lib/node_modules/pinggy/` path that npm writes. A packaged binary run from anywhere else offers to install itself by running the script it carries, with `PINGGY_BINARY_URL` and `PINGGY_INSTALL_ONLY=1` (`src/install/selfInstall.ts`). It finds the copy `pinggy` runs in `src/install/pinggyOnPath.ts`, so a change to how either script tells an npm copy changes that file in the same commit. `pinggy daemon service-install` runs only from the path the scripts install to (`installerBinaryPath()` in `src/daemon/lifecycle/serviceInstaller.ts`), so changing either script's install directory changes that function in the same commit. Once the device connects, both scripts offer `pinggy daemon service-install` unless the service exists. They look for the task name, plist or unit file that `serviceInstaller.ts` writes, and the installed binary's path in it, so renaming any of them changes both scripts in the same commit. Before the sign-in, both scripts offer to restart a daemon that runs another version (ARCHITECTURE.md section 17, "Install scripts."). They read `pid`, `host` and `cliVersion` from `daemon.json`, look for `--_daemon-child` in the daemon's command line, and `install.sh` restarts through the launchd label or the systemd unit as `serviceRestartInstruction()` does. Renaming any of those fields, the flag, the label or the unit changes both scripts in the same commit.
|
|
86
|
+
`scripts/install/install.sh` installs into `~/.pinggy/versions/<version>/` and points the link `~/.pinggy/bin/pinggy` at it. `install.sh` and `install.ps1` install or update the binary, put it on PATH, then ask "Connect this device to Pinggy? [Y/n]" and run `pinggy device login -b` unless the answer starts with `n`. `-b` is the default, and the scripts pass it so an older binary the user kept also runs the agent in its daemon. pinggy.io serves copies that `website-cli-download-links-pr.yml` writes at each release tag. The scripts read the version to install from `https://pinggy.io/cli/version.json`, which the website builds from the `data/cli_releases.yaml` that the same PR updates, and they exit 1 when it does not answer. They download the binary from the GitHub release. The updater in `src/update/` still reads GitHub's `/releases/latest`. Copies of the scripts stay in use, so that URL and its `version` field never change. Renaming a release asset, changing the `Pinggy CLI version:` line, or changing `device login`'s `--manage` or `-b` flag means changing both scripts in the same commit. `DEVICE_AGENT_TOKEN` on either script still gets every update question, then runs `pinggy device connect -b` instead, with the token in the environment, never on a command line. `install.sh` gives `connect` `/dev/tty` as stdin when it has a terminal, so `connect` can ask the file access question, and `/dev/null` otherwise; never its own stdin, which under `curl | sh` holds the rest of the script. `handleDevice()` deletes the variable from `process.env` before any verb runs, so no shell or daemon the agent starts inherits it. Renaming the variable or `connect`'s `--manage` or `-b` flag also changes both scripts in the same commit. Both scripts update the copy the `pinggy` command runs: an npm copy with `npm install -g --prefix`, the binary otherwise. A copy from `npm link`, pnpm, yarn or bun stops them, and a binary they did not install gets a question first (ARCHITECTURE.md, "Which copy the scripts update"). They tell an npm copy by the `lib/node_modules/pinggy/` path that npm writes. A packaged binary run from anywhere else offers to install itself by running the script it carries, with `PINGGY_BINARY_URL` and `PINGGY_INSTALL_ONLY=1` (`src/install/selfInstall.ts`). It finds the copy `pinggy` runs in `src/install/pinggyOnPath.ts`, so a change to how either script tells an npm copy changes that file in the same commit. `pinggy daemon service-install` runs only from the path the scripts install to (`installerBinaryPath()` in `src/daemon/lifecycle/serviceInstaller.ts`), so changing either script's install directory changes that function in the same commit. Once the device connects, both scripts offer `pinggy daemon service-install` unless the service exists. They look for the task name, plist or unit file that `serviceInstaller.ts` writes, and the installed binary's path in it, so renaming any of them changes both scripts in the same commit. Before the sign-in, both scripts offer to restart a daemon that runs another version (ARCHITECTURE.md section 17, "Install scripts."). They read `pid`, `host` and `cliVersion` from `daemon.json`, look for `--_daemon-child` in the daemon's command line, and `install.sh` restarts through the launchd label or the systemd unit as `serviceRestartInstruction()` does. Renaming any of those fields, the flag, the label or the unit changes both scripts in the same commit.
|
|
85
87
|
|
|
86
88
|
Section 17 of `ARCHITECTURE.md` has the protocol, the retry and terminal outcome table, the `device.json` rules, and the full composition table. The design docs are in the `pinggy_backend` repo under `docs/pinggy-devices/`; read `cli.md` there before changing anything in `src/devices/`.
|
|
87
89
|
|
|
@@ -98,7 +100,7 @@ Section 17 of `ARCHITECTURE.md` has the protocol, the retry and terminal outcome
|
|
|
98
100
|
| `pinggy attach <name\|id>` | Re-attach TUI to a running tunnel |
|
|
99
101
|
| `pinggy daemon start \| stop \| status \| service-install \| service-uninstall` (alias `d`) | Daemon lifecycle and system-service installation |
|
|
100
102
|
| `pinggy update [--check \| --rollback]` | Update to the latest release now, print the latest version and change nothing, or go back to the previous version. A background check starts on its own; `PINGGY_AUTO_UPDATE=false` turns it off |
|
|
101
|
-
| `pinggy device login \| connect \| start [--foreground] \| stop \| status \| remove [-f]` | Sign this machine in by email, or enrol it with a token, as a Pinggy device (`start` is the same as `connect`); the agent runs in the daemon, or in this terminal with `--foreground`, and `stop` stops the daemon's; show whether the agent runs, the enrolment and the background agent; show the device and its connection, ask, then stop every agent and forget the credential (`-f` skips the question) |
|
|
103
|
+
| `pinggy device login \| connect \| start [--foreground] [--files on\|off] \| stop \| status \| remove [-f]` | Sign this machine in by email, or enrol it with a token, as a Pinggy device (`start` is the same as `connect`); the agent runs in the daemon, or in this terminal with `--foreground`, and `stop` stops the daemon's; `--files` answers the file access question, which a terminal run otherwise asks once; show whether the agent runs, the enrolment and the background agent; show the device and its connection, ask, then stop every agent and forget the credential (`-f` skips the question) |
|
|
102
104
|
|
|
103
105
|
### Auto-update
|
|
104
106
|
|
package/README.md
CHANGED
|
@@ -265,6 +265,18 @@ pinggy device connect --token <TOKEN> --manage dashboard.pinggy.io
|
|
|
265
265
|
|
|
266
266
|
`--token` here is the device token, not the tunnel token of the same flag name in [Options](#options). The 2 credentials are unrelated and the device agent never reads the tunnel one.
|
|
267
267
|
|
|
268
|
+
### Allow or refuse file access
|
|
269
|
+
|
|
270
|
+
The first `pinggy device connect`, `start` or `login` in a terminal asks "Allow file access from the Pinggy dashboard? Your account can browse, copy, move and delete this machine's files from the browser. [Y/n]". Enter allows it. The answer is saved, so later runs do not ask. With no terminal, nothing is asked and file access stays on.
|
|
271
|
+
|
|
272
|
+
Change the answer at any time. A running agent applies it to the next file request:
|
|
273
|
+
```bash
|
|
274
|
+
pinggy device connect --files off
|
|
275
|
+
pinggy device connect --files on
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
While file access is off, the dashboard's file manager shows "File access is off on this device." `pinggy device status` prints the answer on its `Files` line. The browser terminal does not read this answer.
|
|
279
|
+
|
|
268
280
|
### Show the device and whether it runs
|
|
269
281
|
```bash
|
|
270
282
|
pinggy device status
|
|
@@ -758,7 +758,7 @@ async function downloadAndVerify(request, dependencies = defaultDownloadDependen
|
|
|
758
758
|
|
|
759
759
|
// src/update/windowsSwap.ts
|
|
760
760
|
import fs8 from "fs";
|
|
761
|
-
import
|
|
761
|
+
import path7 from "path";
|
|
762
762
|
|
|
763
763
|
// src/daemon/lifecycle/daemonManager.ts
|
|
764
764
|
import os4 from "os";
|
|
@@ -768,11 +768,13 @@ import { spawn } from "child_process";
|
|
|
768
768
|
// src/daemon/lifecycle/serviceInstaller.ts
|
|
769
769
|
import os3 from "os";
|
|
770
770
|
import fs6 from "fs";
|
|
771
|
-
import
|
|
771
|
+
import path6 from "path";
|
|
772
772
|
import { execSync, execFileSync as execFileSync2 } from "child_process";
|
|
773
|
+
|
|
774
|
+
// src/daemon/lifecycle/servicePaths.ts
|
|
775
|
+
import path5 from "path";
|
|
773
776
|
var SERVICE_LABEL = "io.pinggy.agent";
|
|
774
777
|
var SYSTEMD_SERVICE_NAME = "pinggy";
|
|
775
|
-
var SERVICE_ANY_LOCATION_ENV = "PINGGY_SERVICE_ANY_LOCATION";
|
|
776
778
|
function installerBinaryPath(platform, home, env) {
|
|
777
779
|
if (platform === "win32") {
|
|
778
780
|
const localAppData = env.LOCALAPPDATA || path5.win32.join(home, "AppData", "Local");
|
|
@@ -780,6 +782,20 @@ function installerBinaryPath(platform, home, env) {
|
|
|
780
782
|
}
|
|
781
783
|
return path5.posix.join(home, ".pinggy", "bin", "pinggy");
|
|
782
784
|
}
|
|
785
|
+
function systemdServicePath(home) {
|
|
786
|
+
return path5.posix.join(home, ".config", "systemd", "user", `${SYSTEMD_SERVICE_NAME}.service`);
|
|
787
|
+
}
|
|
788
|
+
function launchdPlistPath(home) {
|
|
789
|
+
return path5.posix.join(home, "Library", "LaunchAgents", `${SERVICE_LABEL}.plist`);
|
|
790
|
+
}
|
|
791
|
+
function autostartFilePath(platform, home) {
|
|
792
|
+
if (platform === "linux") return systemdServicePath(home);
|
|
793
|
+
if (platform === "darwin") return launchdPlistPath(home);
|
|
794
|
+
return null;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
// src/daemon/lifecycle/serviceInstaller.ts
|
|
798
|
+
var SERVICE_ANY_LOCATION_ENV = "PINGGY_SERVICE_ANY_LOCATION";
|
|
783
799
|
function realPath(p) {
|
|
784
800
|
try {
|
|
785
801
|
return fs6.realpathSync(p);
|
|
@@ -852,8 +868,7 @@ function toolError(err) {
|
|
|
852
868
|
return stderr ? stderr.replace(/^ERROR:\s*/i, "") : errorMessage(err);
|
|
853
869
|
}
|
|
854
870
|
function getSystemdServicePath() {
|
|
855
|
-
|
|
856
|
-
return path5.join(dir, `${SYSTEMD_SERVICE_NAME}.service`);
|
|
871
|
+
return systemdServicePath(os3.homedir());
|
|
857
872
|
}
|
|
858
873
|
function generateSystemdUnit(program) {
|
|
859
874
|
const execStart = `${program} --_daemon-child`;
|
|
@@ -874,7 +889,7 @@ WantedBy=default.target
|
|
|
874
889
|
}
|
|
875
890
|
function installSystemd(program) {
|
|
876
891
|
const servicePath = getSystemdServicePath();
|
|
877
|
-
const dir =
|
|
892
|
+
const dir = path6.dirname(servicePath);
|
|
878
893
|
fs6.mkdirSync(dir, { recursive: true });
|
|
879
894
|
fs6.writeFileSync(servicePath, generateSystemdUnit(program), "utf-8");
|
|
880
895
|
execSync("systemctl --user daemon-reload", QUIET);
|
|
@@ -922,7 +937,7 @@ function uninstallSystemd() {
|
|
|
922
937
|
}
|
|
923
938
|
}
|
|
924
939
|
function getLaunchdPlistPath() {
|
|
925
|
-
return
|
|
940
|
+
return launchdPlistPath(os3.homedir());
|
|
926
941
|
}
|
|
927
942
|
function generateLaunchdPlist(program) {
|
|
928
943
|
const allArgs = [program, "--_daemon-child"];
|
|
@@ -948,7 +963,7 @@ ${programArgs}
|
|
|
948
963
|
}
|
|
949
964
|
function installLaunchd(program) {
|
|
950
965
|
const plistPath = getLaunchdPlistPath();
|
|
951
|
-
const dir =
|
|
966
|
+
const dir = path6.dirname(plistPath);
|
|
952
967
|
fs6.mkdirSync(dir, { recursive: true });
|
|
953
968
|
fs6.writeFileSync(plistPath, generateLaunchdPlist(program), "utf-8");
|
|
954
969
|
const uid = process.getuid?.() ?? 501;
|
|
@@ -1036,7 +1051,7 @@ function generateTaskXml(program, userId) {
|
|
|
1036
1051
|
}
|
|
1037
1052
|
function createWindowsTask(program) {
|
|
1038
1053
|
const xml = generateTaskXml(program, getWindowsUserId());
|
|
1039
|
-
const tmpPath =
|
|
1054
|
+
const tmpPath = path6.join(os3.tmpdir(), `${WINDOWS_TASK_NAME}.xml`);
|
|
1040
1055
|
fs6.writeFileSync(tmpPath, "\uFEFF" + xml, "utf16le");
|
|
1041
1056
|
try {
|
|
1042
1057
|
execFileSync2("schtasks", ["/Create", "/TN", WINDOWS_TASK_NAME, "/XML", tmpPath, "/F"], QUIET);
|
|
@@ -1309,7 +1324,7 @@ async function ensureDaemonRunning() {
|
|
|
1309
1324
|
return info;
|
|
1310
1325
|
}
|
|
1311
1326
|
if (process.versions.electron) {
|
|
1312
|
-
const { runDaemonChild } = await import("./daemonChild-
|
|
1327
|
+
const { runDaemonChild } = await import("./daemonChild-GGG34AOT.js");
|
|
1313
1328
|
const handle = await runDaemonChild({
|
|
1314
1329
|
installSignalHandlers: false,
|
|
1315
1330
|
exitOnFailure: false,
|
|
@@ -1423,7 +1438,7 @@ async function waitForExit(pid, timeoutMs) {
|
|
|
1423
1438
|
}
|
|
1424
1439
|
|
|
1425
1440
|
// src/update/windowsSwap.ts
|
|
1426
|
-
var WINDOWS_PATH =
|
|
1441
|
+
var WINDOWS_PATH = path7.win32;
|
|
1427
1442
|
var BACKUP_MARKER = ".prev";
|
|
1428
1443
|
var NEW_FILE_SUFFIX = ".new.exe";
|
|
1429
1444
|
var OLD_FILE_SUFFIX = ".old";
|
|
@@ -1654,7 +1669,7 @@ function releaseUpdateLock() {
|
|
|
1654
1669
|
|
|
1655
1670
|
// src/update/unixLinkSwap.ts
|
|
1656
1671
|
import fs10 from "fs";
|
|
1657
|
-
import
|
|
1672
|
+
import path8 from "path";
|
|
1658
1673
|
var BINARY_NAME = "pinggy";
|
|
1659
1674
|
var DOWNLOAD_PREFIX = "pinggy.download.";
|
|
1660
1675
|
var CONVERT_PREFIX = "pinggy.convert.";
|
|
@@ -1676,17 +1691,17 @@ var realUnixSwapEnvironment = {
|
|
|
1676
1691
|
isAlive: isProcessAlive
|
|
1677
1692
|
};
|
|
1678
1693
|
function unixDownloadPath(layout) {
|
|
1679
|
-
return
|
|
1694
|
+
return path8.posix.join(layout.versionsDirectory, `${DOWNLOAD_PREFIX}${process.pid}`);
|
|
1680
1695
|
}
|
|
1681
1696
|
function versionDirectory(layout, version) {
|
|
1682
|
-
return
|
|
1697
|
+
return path8.posix.join(layout.versionsDirectory, version);
|
|
1683
1698
|
}
|
|
1684
1699
|
function versionBinaryPath(layout, version) {
|
|
1685
|
-
return
|
|
1700
|
+
return path8.posix.join(versionDirectory(layout, version), BINARY_NAME);
|
|
1686
1701
|
}
|
|
1687
1702
|
function readLinkVersion(layout) {
|
|
1688
1703
|
try {
|
|
1689
|
-
const version =
|
|
1704
|
+
const version = path8.posix.basename(path8.posix.dirname(fs10.readlinkSync(layout.link)));
|
|
1690
1705
|
return parseVersion(version) ? version : null;
|
|
1691
1706
|
} catch {
|
|
1692
1707
|
return null;
|
|
@@ -1701,14 +1716,14 @@ function highestVersionBelow(layout, ceiling) {
|
|
|
1701
1716
|
}
|
|
1702
1717
|
function moveLink(layout, version, environment) {
|
|
1703
1718
|
fs10.mkdirSync(layout.binDirectory, { recursive: true });
|
|
1704
|
-
const temporaryLink =
|
|
1719
|
+
const temporaryLink = path8.posix.join(layout.binDirectory, `${LINK_TEMP_PREFIX}${process.pid}`);
|
|
1705
1720
|
fs10.rmSync(temporaryLink, { force: true });
|
|
1706
1721
|
fs10.symlinkSync(versionBinaryPath(layout, version), temporaryLink);
|
|
1707
1722
|
fs10.renameSync(temporaryLink, layout.link);
|
|
1708
1723
|
environment.fsyncDirectory(layout.binDirectory);
|
|
1709
1724
|
}
|
|
1710
1725
|
function convertPlainFile(layout, execPath, runningVersion, environment) {
|
|
1711
|
-
const temporaryPath =
|
|
1726
|
+
const temporaryPath = path8.posix.join(layout.versionsDirectory, `${CONVERT_PREFIX}${process.pid}`);
|
|
1712
1727
|
fs10.copyFileSync(execPath, temporaryPath);
|
|
1713
1728
|
fs10.chmodSync(temporaryPath, EXECUTABLE_MODE3);
|
|
1714
1729
|
environment.fsyncFile(temporaryPath);
|
|
@@ -1723,7 +1738,7 @@ function removeDeadProcessTemp(directory, prefix, environment) {
|
|
|
1723
1738
|
for (const name of fs10.readdirSync(directory)) {
|
|
1724
1739
|
const pidText = name.startsWith(prefix) ? name.slice(prefix.length) : "";
|
|
1725
1740
|
if (/^\d+$/.test(pidText) && !environment.isAlive(Number(pidText))) {
|
|
1726
|
-
fs10.rmSync(
|
|
1741
|
+
fs10.rmSync(path8.posix.join(directory, name), { force: true });
|
|
1727
1742
|
}
|
|
1728
1743
|
}
|
|
1729
1744
|
}
|
|
@@ -1885,6 +1900,7 @@ export {
|
|
|
1885
1900
|
installCommandFor,
|
|
1886
1901
|
createInstallProbe,
|
|
1887
1902
|
installerBinaryPath,
|
|
1903
|
+
autostartFilePath,
|
|
1888
1904
|
installService,
|
|
1889
1905
|
uninstallService,
|
|
1890
1906
|
currentBootId,
|