@elding/cli 0.9.1 → 0.9.3
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 +30 -28
- package/dist/commands/proxy.js +12 -3
- package/dist/commands/run.js +10 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,47 +1,49 @@
|
|
|
1
1
|
# @elding/cli
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
The Elding CLI. Run your app locally with your API keys injected by a proxy:
|
|
4
|
+
the real key never enters your app's memory.
|
|
5
5
|
|
|
6
6
|
```bash
|
|
7
7
|
npm install -g @elding/cli
|
|
8
8
|
```
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
> ⚠️ **Elding warning:** always use the **scoped** name `@elding/cli`. `npm install -g elding` (without the `@elding/` scope) installs an unrelated third-party package, not Elding.
|
|
11
|
+
|
|
12
|
+
## Getting started
|
|
11
13
|
|
|
12
14
|
```bash
|
|
13
|
-
elding login #
|
|
14
|
-
elding init #
|
|
15
|
-
elding proxy -- npm run dev #
|
|
15
|
+
elding login # sign in (opens the browser)
|
|
16
|
+
elding init # link the current folder to a secret set
|
|
17
|
+
elding proxy -- npm run dev # run your app with the proxy active
|
|
16
18
|
```
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
(`configure()`
|
|
20
|
+
In your code, use [`@elding/sdk`](https://www.npmjs.com/package/@elding/sdk)
|
|
21
|
+
(`configure()` for HTTP keys, `secret()` for the rest).
|
|
20
22
|
|
|
21
|
-
##
|
|
23
|
+
## Commands
|
|
22
24
|
|
|
23
|
-
|
|
|
25
|
+
| Command | Role |
|
|
24
26
|
|---|---|
|
|
25
|
-
| `elding login` / `logout` |
|
|
26
|
-
| `elding init` |
|
|
27
|
-
| `elding proxy -- <cmd>` |
|
|
28
|
-
| `elding run -- <cmd>` |
|
|
29
|
-
| `elding keys` / `sets` |
|
|
30
|
-
| `elding use` |
|
|
31
|
-
| `elding status` / `whoami` |
|
|
32
|
-
| `elding doctor` |
|
|
33
|
-
| `elding open` |
|
|
27
|
+
| `elding login` / `logout` | Sign in / out (token in the OS keychain) |
|
|
28
|
+
| `elding init` | Link the project to an organisation + a set |
|
|
29
|
+
| `elding proxy -- <cmd>` | Run `<cmd>` with the local proxy (key out of process) |
|
|
30
|
+
| `elding run -- <cmd>` | Inject secrets as env variables (if allowed by the org) |
|
|
31
|
+
| `elding keys` / `sets` | List keys / sets |
|
|
32
|
+
| `elding use` | Switch the active set |
|
|
33
|
+
| `elding status` / `whoami` | Current state / signed-in user |
|
|
34
|
+
| `elding doctor` | Diagnose the local config |
|
|
35
|
+
| `elding open` | Open the web dashboard |
|
|
34
36
|
|
|
35
37
|
## `proxy` vs `run`
|
|
36
38
|
|
|
37
|
-
- **`proxy`** (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
- **`run
|
|
41
|
-
|
|
39
|
+
- **`proxy`** (recommended): your app receives a placeholder, the proxy injects the
|
|
40
|
+
real key into the outgoing request and locks it to its domain. The key never
|
|
41
|
+
enters `process.env`. For **HTTP API keys** only.
|
|
42
|
+
- **`run`**: injects secrets in clear text into `process.env` (all types, all
|
|
43
|
+
languages). Disabled by default at the organisation level, enable it explicitly.
|
|
42
44
|
|
|
43
|
-
##
|
|
45
|
+
## Security
|
|
44
46
|
|
|
45
|
-
- Token
|
|
46
|
-
-
|
|
47
|
-
-
|
|
47
|
+
- Token stored in the **OS keychain**, never in clear text on disk.
|
|
48
|
+
- The proxy binds `127.0.0.1` only, anti-SSRF, secret values never logged.
|
|
49
|
+
- Each key can be locked to a domain (`allowedHost`) and cut off (`INACTIVE`).
|
package/dist/commands/proxy.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.proxy = proxy;
|
|
4
7
|
const child_process_1 = require("child_process");
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
5
9
|
const config_js_1 = require("../lib/config.js");
|
|
6
10
|
const api_js_1 = require("../lib/api.js");
|
|
7
11
|
const proxyServer_js_1 = require("../lib/proxyServer.js");
|
|
@@ -46,16 +50,21 @@ async function proxy(cmd, args, options = {}) {
|
|
|
46
50
|
console.log(chalk.dim("Logs cloud proxy désactivés (--no-report-logs)."));
|
|
47
51
|
else
|
|
48
52
|
console.log(chalk.dim("Métadonnées de requêtes envoyées au vault (jamais les valeurs). Couper avec --no-report-logs."));
|
|
53
|
+
// Résout les binaires locaux (next, vite...) comme le ferait npm, en
|
|
54
|
+
// cross-platform : path.delimiter = ";" sur Windows, ":" sur POSIX.
|
|
55
|
+
const localBin = path_1.default.join(process.cwd(), "node_modules", ".bin");
|
|
56
|
+
// Sur Windows, les binaires sont des shims `.cmd` : il faut un shell pour les
|
|
57
|
+
// exécuter (sinon `next` échoue en ENOENT). Sur POSIX, on respecte --shell.
|
|
58
|
+
const useShell = process.platform === "win32" ? true : !!options.shell;
|
|
49
59
|
const child = (0, child_process_1.spawn)(cmd, args, {
|
|
50
60
|
env: {
|
|
51
61
|
...process.env,
|
|
52
|
-
|
|
53
|
-
PATH: `${process.cwd()}/node_modules/.bin:${process.env.PATH ?? ""}`,
|
|
62
|
+
PATH: `${localBin}${path_1.default.delimiter}${process.env.PATH ?? ""}`,
|
|
54
63
|
ELDING_PROXY_URL: server.url,
|
|
55
64
|
ELDING_PROXY_TOKEN: server.token,
|
|
56
65
|
},
|
|
57
66
|
stdio: "inherit",
|
|
58
|
-
shell:
|
|
67
|
+
shell: useShell,
|
|
59
68
|
});
|
|
60
69
|
const shutdown = async () => {
|
|
61
70
|
server.close();
|
package/dist/commands/run.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.run = run;
|
|
4
7
|
const child_process_1 = require("child_process");
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
5
9
|
const config_js_1 = require("../lib/config.js");
|
|
6
10
|
const api_js_1 = require("../lib/api.js");
|
|
7
11
|
const env_js_1 = require("../lib/env.js");
|
|
@@ -41,16 +45,19 @@ async function run(cmd, args, options = {}) {
|
|
|
41
45
|
if (rejected.length > 0) {
|
|
42
46
|
throw new Error(`Secrets refuses car leurs noms sont dangereux pour l'environnement: ${rejected.map((name) => (0, terminal_js_1.safeText)(name, 80)).join(", ")}`);
|
|
43
47
|
}
|
|
48
|
+
// Résout les binaires locaux (next, vite...) en cross-platform.
|
|
49
|
+
const localBin = path_1.default.join(process.cwd(), "node_modules", ".bin");
|
|
44
50
|
const env = {
|
|
45
51
|
...process.env,
|
|
46
|
-
|
|
47
|
-
PATH: `${process.cwd()}/node_modules/.bin:${process.env.PATH ?? ""}`,
|
|
52
|
+
PATH: `${localBin}${path_1.default.delimiter}${process.env.PATH ?? ""}`,
|
|
48
53
|
...safeSecrets,
|
|
49
54
|
};
|
|
55
|
+
// Sur Windows, les binaires locaux sont des shims `.cmd` : shell requis.
|
|
56
|
+
const useShell = process.platform === "win32" ? true : !!options.shell;
|
|
50
57
|
const result = (0, child_process_1.spawnSync)(cmd, args, {
|
|
51
58
|
env,
|
|
52
59
|
stdio: "inherit",
|
|
53
|
-
shell:
|
|
60
|
+
shell: useShell,
|
|
54
61
|
});
|
|
55
62
|
if (result.error) {
|
|
56
63
|
console.error(chalk.red(`Impossible de lancer la commande : ${result.error.message}`));
|