@workover/cli 0.4.0 → 0.5.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 +4 -2
- package/bin/workover.mjs +22 -3
- package/lib.mjs +18 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @workover/cli
|
|
2
2
|
|
|
3
|
-
The command line for [Workover](https://workover.
|
|
3
|
+
The command line for [Workover](https://workover.io) — sign in from your terminal so tools like Claude Code can read and cowork on your documents.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -121,7 +121,9 @@ Either surface, same operations, same permissions.
|
|
|
121
121
|
|
|
122
122
|
## Configuration
|
|
123
123
|
|
|
124
|
-
- `WORKOVER_API` — point the CLI at a different Workover API
|
|
124
|
+
- `WORKOVER_API` — point the CLI at a different Workover API. Defaults to `https://api.workover.io`.
|
|
125
|
+
`workover login` prints the environment it signed into, because there is only one stored token and
|
|
126
|
+
signing in replaces it.
|
|
125
127
|
|
|
126
128
|
---
|
|
127
129
|
|
package/bin/workover.mjs
CHANGED
|
@@ -24,8 +24,20 @@ import {
|
|
|
24
24
|
contentCommitted,
|
|
25
25
|
} from '../lib.mjs';
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
/*
|
|
28
|
+
* PRODUCTION is the default, because this package is published to npm and everyone who installs it
|
|
29
|
+
* is a customer.
|
|
30
|
+
*
|
|
31
|
+
* It defaulted to `api.workover.dev` — staging — which is ours, internal, and behind Cloudflare
|
|
32
|
+
* Access. So every command an outside user ran went to an environment they cannot reach, and the
|
|
33
|
+
* only people for whom the CLI worked out of the box were us. It also meant `workover login` from a
|
|
34
|
+
* production checkout silently signed into staging and replaced whatever token was there, which is
|
|
35
|
+
* visible only by running `whoami` afterwards.
|
|
36
|
+
*
|
|
37
|
+
* Point at anything else with WORKOVER_API (https://api.workover.dev for staging,
|
|
38
|
+
* https://api.workover.test for local dev).
|
|
39
|
+
*/
|
|
40
|
+
const API = normalizeApi(process.env.WORKOVER_API || 'https://api.workover.io');
|
|
29
41
|
const CONFIG_DIR = join(homedir(), '.workover');
|
|
30
42
|
const CONFIG_FILE = join(CONFIG_DIR, 'config.json');
|
|
31
43
|
|
|
@@ -156,7 +168,14 @@ async function login() {
|
|
|
156
168
|
const decision = pollDecision(res);
|
|
157
169
|
if (decision === 'complete') {
|
|
158
170
|
saveConfig({ api: API, token: res.access_token });
|
|
159
|
-
|
|
171
|
+
/*
|
|
172
|
+
* NAME THE ENVIRONMENT. There is one token, so signing in REPLACES whichever one was there,
|
|
173
|
+
* and the only way to notice you have swapped environments used to be running `whoami`
|
|
174
|
+
* afterwards. Someone working on production who runs a bare `login` — or who has WORKOVER_API
|
|
175
|
+
* exported from an earlier command — ends up authenticated somewhere else entirely, and the
|
|
176
|
+
* next read fails in a way that looks like missing data rather than the wrong server.
|
|
177
|
+
*/
|
|
178
|
+
console.log(`\n\n \x1b[32m✓\x1b[0m Signed in to ${API}\n`);
|
|
160
179
|
return;
|
|
161
180
|
}
|
|
162
181
|
if (decision === 'denied') {
|
package/lib.mjs
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
1
|
// Pure helpers for the Workover CLI, split out so they can be unit-tested without importing
|
|
2
2
|
// bin/workover.mjs (which runs a command + calls process.exit on load).
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Strip trailing slashes from the API base URL (so `${API}${path}` never doubles up).
|
|
6
|
+
*
|
|
7
|
+
* A LOOP, not `/\/+$/`. That pattern is quadratic when the anchor fails — the engine matches the
|
|
8
|
+
* run of slashes from every starting position before discovering there is no end-of-string. On a
|
|
9
|
+
* run of '/' followed by one other character, measured: 10k chars 30ms, 50k chars 747ms, 200k chars
|
|
10
|
+
* 12,008ms. Five times the input, twenty-five times the work (CodeQL js/polynomial-redos).
|
|
11
|
+
*
|
|
12
|
+
* A CLI is unlikely to be handed a 200k-character API base, so this is not an exploit so much as a
|
|
13
|
+
* pattern worth not shipping in a published package. The loop is linear, obvious, and faster on
|
|
14
|
+
* every input.
|
|
15
|
+
*/
|
|
16
|
+
export const normalizeApi = (raw) => {
|
|
17
|
+
const s = raw || '';
|
|
18
|
+
let end = s.length;
|
|
19
|
+
while (end > 0 && s[end - 1] === '/') end -= 1;
|
|
20
|
+
return s.slice(0, end);
|
|
21
|
+
};
|
|
6
22
|
|
|
7
23
|
/** Map a platform + URL to the browser-open command used to approve the device login. */
|
|
8
24
|
export const browserCommand = (platform, url) => {
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workover/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Workover command line — sign in and cowork on your documents from the terminal.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "ScaleMath",
|
|
7
|
-
"homepage": "https://workover.
|
|
7
|
+
"homepage": "https://workover.io",
|
|
8
8
|
"bugs": {
|
|
9
|
-
"url": "https://workover.
|
|
9
|
+
"url": "https://workover.io"
|
|
10
10
|
},
|
|
11
11
|
"keywords": [
|
|
12
12
|
"workover",
|