@xkwdstore/agent 2.0.7 → 2.1.1

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,253 +1,279 @@
1
- # @xkwdstore/agent
2
-
3
- Terminal-only, cryptographically authenticated CLI for XKWDStore browser automation.
4
-
5
- ## Installation
6
-
7
- > **@xkwdstore/agent 2.0.3 is the last version published on npm.**
8
- >
9
- > The current source version is **2.0.7** (robust post-action confirmation). 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.0.7 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
- ## Data Storage
106
-
107
- The agent stores runtime data in your operating system's standard application-data
108
- directory:
109
-
110
- | Platform | Location |
111
- |----------|----------|
112
- | Windows | `%LOCALAPPDATA%\XKWDStore\` |
113
- | Linux | `${XDG_DATA_HOME:-~/.local/share}/xkwdstore/` |
114
-
115
- This directory contains:
116
- - Chrome profiles (persistent cookies and browser storage)
117
- - Bounded logs (no cookies, tokens, private keys, or secrets)
118
- - Non-secret device metadata (deviceId, publicKey, fingerprint)
119
- - Temporary runtime files
120
-
121
- **Nothing is written to Desktop, Documents, Downloads, or OneDrive.**
122
-
123
- ## Security
124
-
125
- ### Device Identity
126
-
127
- The device identity is an **Ed25519 key pair** generated locally. The server
128
- authenticates the computer by verifying signatures made by the private key.
129
- Hardware attributes (hostname, OS, architecture) are collected for display and
130
- anomaly detection only — they are **not** authentication credentials.
131
-
132
- ### WebSocket Authentication
133
-
134
- Every WebSocket connection uses **Ed25519 challenge-response**:
135
- 1. Server sends a challenge with a random nonce.
136
- 2. Client signs the challenge with its private key.
137
- 3. Server verifies the signature against the registered public key.
138
-
139
- No HTTP credential exchange. No in-memory ticket. No bearer token in the URL.
140
-
141
- ### Revocation
142
-
143
- A device can be revoked from the dashboard. Revocation immediately prevents all
144
- future challenge-response authentication. Active connections are closed when
145
- the server processes the revocation event — this requires the
146
- `protocolV2Revocation` integration test to pass.
147
-
148
- ### Windows Private Key Storage
149
-
150
- 1. Key is DPAPI-protected through stdin.
151
- 2. Encrypted envelope is written to disk.
152
- 3. A restricted DACL is applied via PowerShell.
153
- 4. ACL application is verified (not best-effort): the write **fails** if the
154
- ACL cannot be applied or verified.
155
-
156
- **Status**: Implementation present. ACL fail-closed tests require a real
157
- Windows runner (pending CI billing restoration).
158
-
159
- ## What This Agent Does NOT Do
160
-
161
- - ❌ Download or install a browser (uses your system Chrome)
162
- - ❌ Run a self-updater (you pin the version in the command)
163
- - ❌ Poll GitHub for manifests
164
- - ❌ Require a pairing code
165
- - ❌ Require an email in the terminal
166
- - ❌ Keep a tray application running
167
- - ❌ Install a Windows service
168
- - ❌ Create a Scheduled Task
169
- - ❌ Write to Desktop, Documents, Downloads, or OneDrive
170
- - ❌ Store private keys in plaintext
171
- - ❌ Use `curl | sh` or `Invoke-WebRequest | Invoke-Expression`
172
- - ❌ Support macOS (fails closed)
173
-
174
- ## Version Management
175
-
176
- The agent does NOT update itself. To use a newer version, change the version
177
- number in the command. The pinned command for this release is:
178
-
179
- ```powershell
180
- npx --yes @xkwdstore/agent@2.0.7 start
181
- ```
182
-
183
- > 2.0.7 is the current local agent version (robust post-action confirmation).
184
- > 2.0.3 was the previous release.
185
- >
186
- > The server checks compatibility at startup and displays a clear message if
187
- > the agent version is no longer supported.
188
-
189
- ## Privacy
190
-
191
- The agent collects and sends the following non-secret information to the server:
192
- - Hostname (for display)
193
- - Operating system and version
194
- - CPU architecture
195
- - Current OS username
196
- - Chrome version
197
- - A locally-salted hash of machine identifiers (for anomaly detection, not
198
- authentication)
199
-
200
- The agent does **not** send:
201
- - Raw motherboard serial numbers
202
- - Raw disk serial numbers
203
- - Raw machine GUIDs
204
- - Private keys
205
- - Cookies or browser storage
206
- - Passwords or tokens
207
-
208
- ## Troubleshooting
209
-
210
- Run `xkwd-agent doctor` to check:
211
- - Node.js version
212
- - Chrome installation
213
- - Secure storage availability
214
- - Data directory
215
- - Device enrollment status
216
- - Server connectivity
217
-
218
- ### Chrome Not Found
219
-
220
- ```
221
- Google Chrome was not found.
222
- Install Chrome and run the command again.
223
- No browser was downloaded or installed automatically.
224
- ```
225
-
226
- Install Google Chrome from https://www.google.com/chrome/ and run the command again.
227
-
228
- ### Secure Storage Unavailable (Linux)
229
-
230
- ```
231
- Secure key storage is unavailable on this system.
232
- ```
233
-
234
- Install `gnome-keyring` or `seahorse` (provides `libsecret` / `secret-tool`).
235
-
236
- ### macOS Not Supported
237
-
238
- ```
239
- macOS is not supported. The agent fails closed on macOS.
240
- ```
241
-
242
- The agent does not implement macOS Keychain integration. Use a Linux or Windows computer.
243
-
244
- ### Already Running
245
-
246
- ```
247
- XKWDStore Agent is already running on this computer.
248
- PID: ...
249
- Started: ...
250
- Device: ...
251
- ```
252
-
1
+ # @xkwdstore/agent
2
+
3
+ Terminal-only, cryptographically authenticated CLI for XKWDStore browser automation.
4
+
5
+ ## Installation
6
+
7
+ > **@xkwdstore/agent 2.1.1 is the last version published on npm.**
8
+ >
9
+ > The current source version is **2.1.1** (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.1 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.1 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
+
253
279
  Use `xkwd-agent start --replace` to safely replace the running instance.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xkwdstore/agent",
3
- "version": "2.0.7",
4
- "description": "XKWDStore Agent — terminal-only, cryptographically authenticated CLI for browser automation",
3
+ "version": "2.1.1",
4
+ "description": "XKWDStore Agent — machine-wide, cryptographically authenticated CLI for isolated browser automation",
5
5
  "main": "src/cli.js",
6
6
  "bin": {
7
7
  "xkwd-agent": "src/cli.js"
@@ -18,12 +18,19 @@
18
18
  "files": [
19
19
  "src/cli.js",
20
20
  "src/deviceKeyStore.js",
21
+ "src/machineState.js",
22
+ "src/machineLock.js",
23
+ "src/legacyStartup.js",
24
+ "src/brokerWorkerBridge.js",
25
+ "src/worker.js",
21
26
  "src/chromeDetector.js",
22
27
  "src/enrollmentClient.js",
23
28
  "src/processLock.js",
24
29
  "src/wsClient.js",
25
30
  "src/challengeCodec.js",
26
31
  "src/sessionHandler.js",
32
+ "src/sessionRegistry.js",
33
+ "src/browserIsolation.js",
27
34
  "src/fingerprint.js",
28
35
  "src/fingerprintStore.js",
29
36
  "src/profilePath.js",
@@ -34,6 +41,10 @@
34
41
  "src/configStore.js",
35
42
  "src/secretStore.js",
36
43
  "src/actions/",
44
+ "scripts/worker-entry.js",
45
+ "scripts/install-machine-agent.ps1",
46
+ "scripts/broker-service-host.cs",
47
+ "scripts/session-launcher.cs",
37
48
  "README.md",
38
49
  "LICENSE"
39
50
  ],