varcrypt 0.1.2 → 0.1.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/index.mjs +26 -4
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -6,7 +6,27 @@ import * as readline from "readline/promises";
|
|
|
6
6
|
|
|
7
7
|
const CONFIG_DIR = join(homedir(), ".varcrypt");
|
|
8
8
|
const CONFIG_FILE = join(CONFIG_DIR, "config.json");
|
|
9
|
-
|
|
9
|
+
|
|
10
|
+
// Official VarCrypt service. --host overrides this for self-hosted deployments.
|
|
11
|
+
const DEFAULT_HOST = "https://varcrypt.vercel.app";
|
|
12
|
+
// Only path this CLI ever contacts on the target host.
|
|
13
|
+
const SECRETS_PATH = "/api/secrets";
|
|
14
|
+
|
|
15
|
+
function resolveHost(override) {
|
|
16
|
+
const raw = override ?? DEFAULT_HOST;
|
|
17
|
+
let parsed;
|
|
18
|
+
try {
|
|
19
|
+
parsed = new URL(raw);
|
|
20
|
+
} catch {
|
|
21
|
+
console.error(`Invalid host: ${raw}`);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
if (parsed.protocol !== "https:" && parsed.hostname !== "localhost") {
|
|
25
|
+
console.error("Host must use HTTPS");
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
return parsed.origin; // strips any stray path/query from the host value
|
|
29
|
+
}
|
|
10
30
|
|
|
11
31
|
function loadConfig() {
|
|
12
32
|
try {
|
|
@@ -45,8 +65,10 @@ async function pull(project, env, opts) {
|
|
|
45
65
|
process.exit(1);
|
|
46
66
|
}
|
|
47
67
|
|
|
48
|
-
const
|
|
49
|
-
const url =
|
|
68
|
+
const origin = resolveHost(opts.host ?? config.host);
|
|
69
|
+
const url = new URL(SECRETS_PATH, origin);
|
|
70
|
+
url.searchParams.set("project", project);
|
|
71
|
+
url.searchParams.set("env", env);
|
|
50
72
|
|
|
51
73
|
const res = await fetch(url, {
|
|
52
74
|
headers: { Authorization: `Bearer ${config.token}` },
|
|
@@ -79,7 +101,7 @@ Commands:
|
|
|
79
101
|
login Save your API token
|
|
80
102
|
pull <project> <env> Print secrets as KEY=value
|
|
81
103
|
--output export Print as export KEY="value" instead
|
|
82
|
-
--host <url> Override API host (default:
|
|
104
|
+
--host <url> Override API host (default: https://varcrypt.vercel.app)
|
|
83
105
|
`);
|
|
84
106
|
}
|
|
85
107
|
|