@runeya/runeya 2.0.5 → 2.0.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.
|
@@ -10889,21 +10889,68 @@ var PullEnvError = class extends Error {
|
|
|
10889
10889
|
this.name = "PullEnvError";
|
|
10890
10890
|
}
|
|
10891
10891
|
};
|
|
10892
|
-
async function
|
|
10892
|
+
async function promptPassword() {
|
|
10893
|
+
process.stderr.write("Master password: ");
|
|
10894
|
+
return new Promise((resolve5) => {
|
|
10895
|
+
const stdin = process.stdin;
|
|
10896
|
+
const wasRaw = stdin.isRaw;
|
|
10897
|
+
if (stdin.isTTY) stdin.setRawMode(true);
|
|
10898
|
+
stdin.resume();
|
|
10899
|
+
stdin.setEncoding("utf-8");
|
|
10900
|
+
let input = "";
|
|
10901
|
+
const onData = (ch) => {
|
|
10902
|
+
if (ch === "\r" || ch === "\n") {
|
|
10903
|
+
if (stdin.isTTY) stdin.setRawMode(wasRaw ?? false);
|
|
10904
|
+
stdin.pause();
|
|
10905
|
+
stdin.removeListener("data", onData);
|
|
10906
|
+
process.stderr.write("\n");
|
|
10907
|
+
resolve5(input);
|
|
10908
|
+
} else if (ch === "") {
|
|
10909
|
+
process.exit(1);
|
|
10910
|
+
} else if (ch === "\x7F" || ch === "\b") {
|
|
10911
|
+
input = input.slice(0, -1);
|
|
10912
|
+
} else {
|
|
10913
|
+
input += ch;
|
|
10914
|
+
}
|
|
10915
|
+
};
|
|
10916
|
+
stdin.on("data", onData);
|
|
10917
|
+
});
|
|
10918
|
+
}
|
|
10919
|
+
async function unlockIfNeeded() {
|
|
10893
10920
|
await ensureEncryptionKey();
|
|
10921
|
+
if (hasEncryptionKey()) return;
|
|
10922
|
+
if (await loadFromEnv()) return;
|
|
10923
|
+
if (!await hasEncryptedKeyFile(env.DATA_DIR)) {
|
|
10924
|
+
return;
|
|
10925
|
+
}
|
|
10926
|
+
const masterPassword = process.env["RUNEYA_MASTER_PASSWORD"] || await promptPassword();
|
|
10927
|
+
if (!masterPassword) {
|
|
10928
|
+
throw new PullEnvError("Master password required to decrypt data", 1);
|
|
10929
|
+
}
|
|
10930
|
+
try {
|
|
10931
|
+
const encKey = await readEncryptedKey(env.DATA_DIR, masterPassword);
|
|
10932
|
+
setEncryptionKeyInMemory(encKey);
|
|
10933
|
+
} catch {
|
|
10934
|
+
throw new PullEnvError("Master password incorrect", 1);
|
|
10935
|
+
}
|
|
10936
|
+
}
|
|
10937
|
+
async function pullEnv(opts) {
|
|
10938
|
+
await unlockIfNeeded();
|
|
10894
10939
|
const services = await serviceStore.list();
|
|
10895
10940
|
const service = services.find(
|
|
10896
10941
|
(s) => s.id === opts.service || s.name === opts.service
|
|
10897
10942
|
);
|
|
10898
10943
|
if (!service) {
|
|
10899
|
-
|
|
10944
|
+
const available = services.map((s) => s.name).join(", ");
|
|
10945
|
+
throw new PullEnvError(`service "${opts.service}" not found. Available: ${available || "(none)"}`, 1);
|
|
10900
10946
|
}
|
|
10901
10947
|
const globalEnvs = await environmentStore.listAllGlobal();
|
|
10902
10948
|
const globalEnv = globalEnvs.find(
|
|
10903
10949
|
(e) => e.id === opts.environment || e.name === opts.environment
|
|
10904
10950
|
);
|
|
10905
10951
|
if (!globalEnv) {
|
|
10906
|
-
|
|
10952
|
+
const available = globalEnvs.map((e) => e.name).join(", ");
|
|
10953
|
+
throw new PullEnvError(`environment "${opts.environment}" not found. Available: ${available || "(none)"}`, 1);
|
|
10907
10954
|
}
|
|
10908
10955
|
const { env: env2 } = await environmentResolver.resolveForService({
|
|
10909
10956
|
serviceId: service.id,
|
|
@@ -10981,4 +11028,4 @@ export {
|
|
|
10981
11028
|
createLocalServer,
|
|
10982
11029
|
pullEnv
|
|
10983
11030
|
};
|
|
10984
|
-
//# sourceMappingURL=dist-
|
|
11031
|
+
//# sourceMappingURL=dist-RZD3EUA3.js.map
|