@xkwdstore/agent 2.1.5 → 2.1.7

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/README.md CHANGED
@@ -1,281 +1,282 @@
1
- # @xkwdstore/agent
2
-
3
- Terminal-only, cryptographically authenticated CLI for XKWDStore browser automation.
4
-
5
- ## Installation
6
-
7
- > **@xkwdstore/agent 2.1.4 is the last version published on npm.**
8
- > **The source tree is prepared as 2.1.5 and is NOT published yet.**
9
- >
10
- > The current source version is **2.1.5** (machine-wide hardening). It is
11
- > NOT claimed to be published unless the release workflow has published it — see
12
- > `reports/` for the authoritative publication state.
13
-
14
- End users install by downloading the installer file first, then running it
15
- (the installer explicitly forbids piping a remote script directly into
16
- execution). This creates a desktop launcher pinned to this version:
17
-
18
- ```powershell
19
- $installer = "$env:TEMP\xkwdstore-install.ps1"
20
- Invoke-WebRequest -Uri "https://raw.githubusercontent.com/EssaGhazwani/TW-manager-install/main/install.ps1" -OutFile $installer
21
- powershell.exe -NoProfile -ExecutionPolicy Bypass -File $installer
22
- ```
23
-
24
- Or, from CMD:
25
-
26
- ```cmd
27
- curl -L -o "%TEMP%\xkwdstore-install.ps1" https://raw.githubusercontent.com/EssaGhazwani/TW-manager-install/main/install.ps1 && powershell -NoProfile -ExecutionPolicy Bypass -File "%TEMP%\xkwdstore-install.ps1"
28
- ```
29
-
30
- The generated launcher runs the pinned command:
31
-
32
- ```powershell
33
- npx --yes @xkwdstore/agent@2.1.5 start
34
- ```
35
-
36
- Automated installer tests use `-NoLaunch` or a mocked `npx` command so the
37
- real pinned package is never executed from the public registry during
38
- installation validation.
39
-
40
- ## Platform Support
41
-
42
- | Platform | Status |
43
- |----------|--------|
44
- | **Windows** | Implementation present. ACL hardening awaits real Windows runner CI. |
45
- | **Linux (with Secret Service / libsecret)** | Implementation present. Pending platform verification on CI. |
46
- | **macOS** | **Unsupported.** Fails closed with an explicit error. No macOS Keychain integration is implemented. |
47
-
48
- ## Requirements
49
-
50
- - **Node.js 22 or later** — check with `node --version`
51
- - **Google Chrome** installed on your computer
52
- - A terminal (PowerShell, Windows Terminal, or Linux shell)
53
- - **Linux**: `gnome-keyring` or `seahorse` (provides `libsecret` / `secret-tool`)
54
-
55
- ## First Run
56
-
57
- On first run, the agent will:
58
-
59
- 1. Generate an Ed25519 key pair locally on your computer.
60
- 2. Open your browser to x.kwdstore.com for authorization.
61
- 3. Wait for you to sign in and approve the computer.
62
- 4. Connect securely after approval.
63
-
64
- **No pairing code. No email prompt. No API key. No download. No installer.**
65
-
66
- The private key is stored using your operating system's secure credential storage:
67
- - **Windows**: DPAPI (current-user scope) — pending ACL hardening CI verification
68
- - **Linux**: Secret Service / libsecret
69
- - **macOS**: Not supported — fails with an explicit error
70
-
71
- The private key **never leaves your computer**, never appears in logs, and never
72
- appears in command-line arguments.
73
-
74
- ## Subsequent Runs
75
-
76
- After first authorization, the agent connects automatically.
77
-
78
- No browser approval is needed unless:
79
- - The device key was deleted
80
- - The device was revoked from the dashboard
81
- - Secure storage was reset
82
- - The server no longer recognizes the public key
83
-
84
- ## Commands
85
-
86
- | Command | Description |
87
- |---------|-------------|
88
- | `start` | Start the agent (connect, run browser sessions) |
89
- | `status` | Show device and connection status |
90
- | `recover` | Re-authorize this device after replacement (owner approval; preserves profiles) |
91
- | `logout` | Delete local device identity (requires re-authorization) |
92
- | `revoke-local` | Delete local device identity and credentials |
93
- | `doctor` | Run diagnostic checks |
94
- | `version` | Print version information |
95
- | `help` | Show help |
96
-
97
- ### Options
98
-
99
- - `--server=<url>` — Server URL (default: `https://x.kwdstore.com`)
100
- - `--replace` — Replace a running instance (safe takeover)
101
-
102
- ## Stopping the Agent
103
-
104
- Press **Ctrl+C** in the terminal. The agent closes all browser sessions and
105
- disconnects cleanly. No background process remains.
106
-
107
- ## Machine-wide broker + interactive worker (2.1.0)
108
-
109
- The agent can run as a **machine-wide broker** (`xkwd-agent service`, hosted by a
110
- Windows Service) plus a per-session **interactive browser worker**:
111
-
112
- - the **broker** owns the machine identity, the device private key, the server
113
- WebSocket, leases, and the session registry — and never launches a browser;
114
- - the **worker** runs in the active interactive Windows session, launches
115
- Chromium, and accepts only typed browser commands over a loopback-only channel
116
- with a one-time token. It cannot read the private key or enroll the device.
117
-
118
- One broker per machine is enforced by a Windows named mutex
119
- (`Global\XKWDStoreAgentMachineBroker-v1`). Silent startup is installed by
120
- `scripts/install-machine-agent.ps1` (elevated). See
121
- [`docs/MACHINE-AGENT-2.1.0.md`](../../docs/MACHINE-AGENT-2.1.0.md).
122
-
123
- ## Data Storage
124
-
125
- The agent stores runtime data in a **machine-wide** directory, so one physical
126
- computer keeps one device identity across Windows users and reboots:
127
-
128
- | Platform | Location |
129
- |----------|----------|
130
- | Windows | `%ProgramData%\XKWDStore\Agent\` (config, identity, credentials, logs, runtime, state, launcher) |
131
- | Linux | `${XDG_DATA_HOME:-~/.local/share}/xkwdstore/` (dev/CI; overridable) |
132
-
133
- This directory contains:
134
- - Chrome profiles (persistent cookies and browser storage), namespaced by
135
- `serverUuid/tenantUuid/accountUuid/deviceUuid` under `state\profiles\`
136
- - Bounded logs (no cookies, tokens, private keys, or secrets)
137
- - Non-secret device metadata (deviceId, publicKey, fingerprint)
138
- - Per-session runtime dirs (temp/downloads/crash/ipc) under `state\sessions\`
139
- - An Agent-local session registry (non-secret metadata only) in `runtime\`
140
-
141
- Sensitive files are ACL-restricted to the owning user, Administrators, and
142
- SYSTEM. Credentials are DPAPI-protected; they are not world-readable.
143
-
144
- **Migration:** a pre-2.1.0 per-user install (`%LOCALAPPDATA%\XKWDStore\`) is
145
- adopted **once**, by copy — the existing `deviceId` and pairing are preserved
146
- exactly, and the old tree is left intact for rollback. See
147
- [`docs/MACHINE-AGENT-2.1.0.md`](../../docs/MACHINE-AGENT-2.1.0.md).
148
-
149
- **Nothing is written to Desktop, Documents, Downloads, or OneDrive.**
150
-
151
- ## Security
152
-
153
- ### Device Identity
154
-
155
- The device identity is an **Ed25519 key pair** generated locally. The server
156
- authenticates the computer by verifying signatures made by the private key.
157
- Hardware attributes (hostname, OS, architecture) are collected for display and
158
- anomaly detection only — they are **not** authentication credentials.
159
-
160
- ### WebSocket Authentication
161
-
162
- Every WebSocket connection uses **Ed25519 challenge-response**:
163
- 1. Server sends a challenge with a random nonce.
164
- 2. Client signs the challenge with its private key.
165
- 3. Server verifies the signature against the registered public key.
166
-
167
- No HTTP credential exchange. No in-memory ticket. No bearer token in the URL.
168
-
169
- ### Revocation
170
-
171
- A device can be revoked from the dashboard. Revocation immediately prevents all
172
- future challenge-response authentication. Active connections are closed when
173
- the server processes the revocation event — this requires the
174
- `protocolV2Revocation` integration test to pass.
175
-
176
- ### Windows Private Key Storage
177
-
178
- 1. Key is DPAPI-protected through stdin.
179
- 2. Encrypted envelope is written to disk.
180
- 3. A restricted DACL is applied via PowerShell.
181
- 4. ACL application is verified (not best-effort): the write **fails** if the
182
- ACL cannot be applied or verified.
183
-
184
- **Status**: Implementation present. ACL fail-closed tests require a real
185
- Windows runner (pending CI billing restoration).
186
-
187
- ## What This Agent Does NOT Do
188
-
189
- - ❌ Download or install a browser (uses your system Chrome)
190
- - ❌ Run a self-updater (you pin the version in the command)
191
- - ❌ Poll GitHub for manifests
192
- - ❌ Require a pairing code
193
- - ❌ Require an email in the terminal
194
- - ❌ Keep a tray application running
195
- - ❌ Install a Windows service
196
- - ❌ Create a Scheduled Task
197
- - ❌ Write to Desktop, Documents, Downloads, or OneDrive
198
- - ❌ Store private keys in plaintext
199
- - ❌ Use `curl | sh` or `Invoke-WebRequest | Invoke-Expression`
200
- - ❌ Support macOS (fails closed)
201
-
202
- ## Version Management
203
-
204
- The agent does NOT update itself. To use a newer version, change the version
205
- number in the command. The pinned command for this release is:
206
-
207
- ```powershell
208
- npx --yes @xkwdstore/agent@2.1.5 start
209
- ```
210
-
211
- > 2.1.0 is the current local agent version (machine-wide hardening).
212
- > 2.0.3 was the last published release.
213
- >
214
- > The server checks compatibility at startup and displays a clear message if
215
- > the agent version is no longer supported.
216
-
217
- ## Privacy
218
-
219
- The agent collects and sends the following non-secret information to the server:
220
- - Hostname (for display)
221
- - Operating system and version
222
- - CPU architecture
223
- - Current OS username
224
- - Chrome version
225
- - A locally-salted hash of machine identifiers (for anomaly detection, not
226
- authentication)
227
-
228
- The agent does **not** send:
229
- - Raw motherboard serial numbers
230
- - Raw disk serial numbers
231
- - Raw machine GUIDs
232
- - Private keys
233
- - Cookies or browser storage
234
- - Passwords or tokens
235
-
236
- ## Troubleshooting
237
-
238
- Run `xkwd-agent doctor` to check:
239
- - Node.js version
240
- - Chrome installation
241
- - Secure storage availability
242
- - Data directory
243
- - Device enrollment status
244
- - Server connectivity
245
-
246
- ### Chrome Not Found
247
-
248
- ```
249
- Google Chrome was not found.
250
- Install Chrome and run the command again.
251
- No browser was downloaded or installed automatically.
252
- ```
253
-
254
- Install Google Chrome from https://www.google.com/chrome/ and run the command again.
255
-
256
- ### Secure Storage Unavailable (Linux)
257
-
258
- ```
259
- Secure key storage is unavailable on this system.
260
- ```
261
-
262
- Install `gnome-keyring` or `seahorse` (provides `libsecret` / `secret-tool`).
263
-
264
- ### macOS Not Supported
265
-
266
- ```
267
- macOS is not supported. The agent fails closed on macOS.
268
- ```
269
-
270
- The agent does not implement macOS Keychain integration. Use a Linux or Windows computer.
271
-
272
- ### Already Running
273
-
274
- ```
275
- XKWDStore Agent is already running on this computer.
276
- PID: ...
277
- Started: ...
278
- Device: ...
279
- ```
280
-
1
+ # @xkwdstore/agent
2
+
3
+ Terminal-only, cryptographically authenticated CLI for XKWDStore browser automation.
4
+
5
+ ## Installation
6
+
7
+ > **@xkwdstore/agent 2.1.7 is the current published version on npm.**
8
+ >
9
+ > The current source version is **2.1.7** (browser connectivity: bounded
10
+ > navigation + capability-based proxy health, bounded authentication retries and
11
+ > same-device recovery; an authenticated HTTP CONNECT proxy now pins HTTP/1.1 so
12
+ > Google properties load instead of stalling on `about:blank`). See `reports/`
13
+ > for the authoritative publication state.
14
+
15
+ End users install by downloading the installer file first, then running it
16
+ (the installer explicitly forbids piping a remote script directly into
17
+ execution). This creates a desktop launcher pinned to this version:
18
+
19
+ ```powershell
20
+ $installer = "$env:TEMP\xkwdstore-install.ps1"
21
+ Invoke-WebRequest -Uri "https://raw.githubusercontent.com/EssaGhazwani/TW-manager-install/main/install.ps1" -OutFile $installer
22
+ powershell.exe -NoProfile -ExecutionPolicy Bypass -File $installer
23
+ ```
24
+
25
+ Or, from CMD:
26
+
27
+ ```cmd
28
+ curl -L -o "%TEMP%\xkwdstore-install.ps1" https://raw.githubusercontent.com/EssaGhazwani/TW-manager-install/main/install.ps1 && powershell -NoProfile -ExecutionPolicy Bypass -File "%TEMP%\xkwdstore-install.ps1"
29
+ ```
30
+
31
+ The generated launcher runs the pinned command:
32
+
33
+ ```powershell
34
+ npx --yes @xkwdstore/agent@2.1.7 start
35
+ ```
36
+
37
+ Automated installer tests use `-NoLaunch` or a mocked `npx` command so the
38
+ real pinned package is never executed from the public registry during
39
+ installation validation.
40
+
41
+ ## Platform Support
42
+
43
+ | Platform | Status |
44
+ |----------|--------|
45
+ | **Windows** | Implementation present. ACL hardening awaits real Windows runner CI. |
46
+ | **Linux (with Secret Service / libsecret)** | Implementation present. Pending platform verification on CI. |
47
+ | **macOS** | **Unsupported.** Fails closed with an explicit error. No macOS Keychain integration is implemented. |
48
+
49
+ ## Requirements
50
+
51
+ - **Node.js 22 or later** — check with `node --version`
52
+ - **Google Chrome** installed on your computer
53
+ - A terminal (PowerShell, Windows Terminal, or Linux shell)
54
+ - **Linux**: `gnome-keyring` or `seahorse` (provides `libsecret` / `secret-tool`)
55
+
56
+ ## First Run
57
+
58
+ On first run, the agent will:
59
+
60
+ 1. Generate an Ed25519 key pair locally on your computer.
61
+ 2. Open your browser to x.kwdstore.com for authorization.
62
+ 3. Wait for you to sign in and approve the computer.
63
+ 4. Connect securely after approval.
64
+
65
+ **No pairing code. No email prompt. No API key. No download. No installer.**
66
+
67
+ The private key is stored using your operating system's secure credential storage:
68
+ - **Windows**: DPAPI (current-user scope) — pending ACL hardening CI verification
69
+ - **Linux**: Secret Service / libsecret
70
+ - **macOS**: Not supported — fails with an explicit error
71
+
72
+ The private key **never leaves your computer**, never appears in logs, and never
73
+ appears in command-line arguments.
74
+
75
+ ## Subsequent Runs
76
+
77
+ After first authorization, the agent connects automatically.
78
+
79
+ No browser approval is needed unless:
80
+ - The device key was deleted
81
+ - The device was revoked from the dashboard
82
+ - Secure storage was reset
83
+ - The server no longer recognizes the public key
84
+
85
+ ## Commands
86
+
87
+ | Command | Description |
88
+ |---------|-------------|
89
+ | `start` | Start the agent (connect, run browser sessions) |
90
+ | `status` | Show device and connection status |
91
+ | `recover` | Re-authorize this device after replacement (owner approval; preserves profiles) |
92
+ | `logout` | Delete local device identity (requires re-authorization) |
93
+ | `revoke-local` | Delete local device identity and credentials |
94
+ | `doctor` | Run diagnostic checks |
95
+ | `version` | Print version information |
96
+ | `help` | Show help |
97
+
98
+ ### Options
99
+
100
+ - `--server=<url>` — Server URL (default: `https://x.kwdstore.com`)
101
+ - `--replace` — Replace a running instance (safe takeover)
102
+
103
+ ## Stopping the Agent
104
+
105
+ Press **Ctrl+C** in the terminal. The agent closes all browser sessions and
106
+ disconnects cleanly. No background process remains.
107
+
108
+ ## Machine-wide broker + interactive worker (2.1.0)
109
+
110
+ The agent can run as a **machine-wide broker** (`xkwd-agent service`, hosted by a
111
+ Windows Service) plus a per-session **interactive browser worker**:
112
+
113
+ - the **broker** owns the machine identity, the device private key, the server
114
+ WebSocket, leases, and the session registry — and never launches a browser;
115
+ - the **worker** runs in the active interactive Windows session, launches
116
+ Chromium, and accepts only typed browser commands over a loopback-only channel
117
+ with a one-time token. It cannot read the private key or enroll the device.
118
+
119
+ One broker per machine is enforced by a Windows named mutex
120
+ (`Global\XKWDStoreAgentMachineBroker-v1`). Silent startup is installed by
121
+ `scripts/install-machine-agent.ps1` (elevated). See
122
+ [`docs/MACHINE-AGENT-2.1.0.md`](../../docs/MACHINE-AGENT-2.1.0.md).
123
+
124
+ ## Data Storage
125
+
126
+ The agent stores runtime data in a **machine-wide** directory, so one physical
127
+ computer keeps one device identity across Windows users and reboots:
128
+
129
+ | Platform | Location |
130
+ |----------|----------|
131
+ | Windows | `%ProgramData%\XKWDStore\Agent\` (config, identity, credentials, logs, runtime, state, launcher) |
132
+ | Linux | `${XDG_DATA_HOME:-~/.local/share}/xkwdstore/` (dev/CI; overridable) |
133
+
134
+ This directory contains:
135
+ - Chrome profiles (persistent cookies and browser storage), namespaced by
136
+ `serverUuid/tenantUuid/accountUuid/deviceUuid` under `state\profiles\`
137
+ - Bounded logs (no cookies, tokens, private keys, or secrets)
138
+ - Non-secret device metadata (deviceId, publicKey, fingerprint)
139
+ - Per-session runtime dirs (temp/downloads/crash/ipc) under `state\sessions\`
140
+ - An Agent-local session registry (non-secret metadata only) in `runtime\`
141
+
142
+ Sensitive files are ACL-restricted to the owning user, Administrators, and
143
+ SYSTEM. Credentials are DPAPI-protected; they are not world-readable.
144
+
145
+ **Migration:** a pre-2.1.0 per-user install (`%LOCALAPPDATA%\XKWDStore\`) is
146
+ adopted **once**, by copy — the existing `deviceId` and pairing are preserved
147
+ exactly, and the old tree is left intact for rollback. See
148
+ [`docs/MACHINE-AGENT-2.1.0.md`](../../docs/MACHINE-AGENT-2.1.0.md).
149
+
150
+ **Nothing is written to Desktop, Documents, Downloads, or OneDrive.**
151
+
152
+ ## Security
153
+
154
+ ### Device Identity
155
+
156
+ The device identity is an **Ed25519 key pair** generated locally. The server
157
+ authenticates the computer by verifying signatures made by the private key.
158
+ Hardware attributes (hostname, OS, architecture) are collected for display and
159
+ anomaly detection only — they are **not** authentication credentials.
160
+
161
+ ### WebSocket Authentication
162
+
163
+ Every WebSocket connection uses **Ed25519 challenge-response**:
164
+ 1. Server sends a challenge with a random nonce.
165
+ 2. Client signs the challenge with its private key.
166
+ 3. Server verifies the signature against the registered public key.
167
+
168
+ No HTTP credential exchange. No in-memory ticket. No bearer token in the URL.
169
+
170
+ ### Revocation
171
+
172
+ A device can be revoked from the dashboard. Revocation immediately prevents all
173
+ future challenge-response authentication. Active connections are closed when
174
+ the server processes the revocation event — this requires the
175
+ `protocolV2Revocation` integration test to pass.
176
+
177
+ ### Windows Private Key Storage
178
+
179
+ 1. Key is DPAPI-protected through stdin.
180
+ 2. Encrypted envelope is written to disk.
181
+ 3. A restricted DACL is applied via PowerShell.
182
+ 4. ACL application is verified (not best-effort): the write **fails** if the
183
+ ACL cannot be applied or verified.
184
+
185
+ **Status**: Implementation present. ACL fail-closed tests require a real
186
+ Windows runner (pending CI billing restoration).
187
+
188
+ ## What This Agent Does NOT Do
189
+
190
+ - ❌ Download or install a browser (uses your system Chrome)
191
+ - ❌ Run a self-updater (you pin the version in the command)
192
+ - ❌ Poll GitHub for manifests
193
+ - ❌ Require a pairing code
194
+ - ❌ Require an email in the terminal
195
+ - ❌ Keep a tray application running
196
+ - ❌ Install a Windows service
197
+ - ❌ Create a Scheduled Task
198
+ - ❌ Write to Desktop, Documents, Downloads, or OneDrive
199
+ - ❌ Store private keys in plaintext
200
+ - ❌ Use `curl | sh` or `Invoke-WebRequest | Invoke-Expression`
201
+ - ❌ Support macOS (fails closed)
202
+
203
+ ## Version Management
204
+
205
+ The agent does NOT update itself. To use a newer version, change the version
206
+ number in the command. The pinned command for this release is:
207
+
208
+ ```powershell
209
+ npx --yes @xkwdstore/agent@2.1.7 start
210
+ ```
211
+
212
+ > 2.1.0 is the current local agent version (machine-wide hardening).
213
+ > 2.0.3 was the last published release.
214
+ >
215
+ > The server checks compatibility at startup and displays a clear message if
216
+ > the agent version is no longer supported.
217
+
218
+ ## Privacy
219
+
220
+ The agent collects and sends the following non-secret information to the server:
221
+ - Hostname (for display)
222
+ - Operating system and version
223
+ - CPU architecture
224
+ - Current OS username
225
+ - Chrome version
226
+ - A locally-salted hash of machine identifiers (for anomaly detection, not
227
+ authentication)
228
+
229
+ The agent does **not** send:
230
+ - Raw motherboard serial numbers
231
+ - Raw disk serial numbers
232
+ - Raw machine GUIDs
233
+ - Private keys
234
+ - Cookies or browser storage
235
+ - Passwords or tokens
236
+
237
+ ## Troubleshooting
238
+
239
+ Run `xkwd-agent doctor` to check:
240
+ - Node.js version
241
+ - Chrome installation
242
+ - Secure storage availability
243
+ - Data directory
244
+ - Device enrollment status
245
+ - Server connectivity
246
+
247
+ ### Chrome Not Found
248
+
249
+ ```
250
+ Google Chrome was not found.
251
+ Install Chrome and run the command again.
252
+ No browser was downloaded or installed automatically.
253
+ ```
254
+
255
+ Install Google Chrome from https://www.google.com/chrome/ and run the command again.
256
+
257
+ ### Secure Storage Unavailable (Linux)
258
+
259
+ ```
260
+ Secure key storage is unavailable on this system.
261
+ ```
262
+
263
+ Install `gnome-keyring` or `seahorse` (provides `libsecret` / `secret-tool`).
264
+
265
+ ### macOS Not Supported
266
+
267
+ ```
268
+ macOS is not supported. The agent fails closed on macOS.
269
+ ```
270
+
271
+ The agent does not implement macOS Keychain integration. Use a Linux or Windows computer.
272
+
273
+ ### Already Running
274
+
275
+ ```
276
+ XKWDStore Agent is already running on this computer.
277
+ PID: ...
278
+ Started: ...
279
+ Device: ...
280
+ ```
281
+
281
282
  Use `xkwd-agent start --replace` to safely replace the running instance.