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