@envsave/cli 1.0.37 → 1.0.38
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/dist/cli.js +12 -31
- package/dist/index.js +3 -10
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -274,7 +274,7 @@ __export(exports_vault, {
|
|
|
274
274
|
configureRateLimit: () => configureRateLimit,
|
|
275
275
|
changePassword: () => changePassword
|
|
276
276
|
});
|
|
277
|
-
import { readFileSync as readFileSync3, writeFileSync as writeFileSync2, existsSync as existsSync2, mkdirSync as mkdirSync2, chmodSync, appendFileSync
|
|
277
|
+
import { readFileSync as readFileSync3, writeFileSync as writeFileSync2, existsSync as existsSync2, mkdirSync as mkdirSync2, chmodSync, appendFileSync } from "node:fs";
|
|
278
278
|
import { join as join2 } from "node:path";
|
|
279
279
|
import { homedir as homedir2 } from "node:os";
|
|
280
280
|
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
@@ -304,12 +304,12 @@ function guardRealVault() {
|
|
|
304
304
|
}
|
|
305
305
|
function readConfig() {
|
|
306
306
|
if (!existsSync2(getConfigFile())) {
|
|
307
|
-
return { maxGetsPerMinute: DEFAULT_RATE_LIMIT_MAX
|
|
307
|
+
return { maxGetsPerMinute: DEFAULT_RATE_LIMIT_MAX };
|
|
308
308
|
}
|
|
309
309
|
try {
|
|
310
310
|
return JSON.parse(readFileSync3(getConfigFile(), "utf8"));
|
|
311
311
|
} catch {
|
|
312
|
-
return { maxGetsPerMinute: DEFAULT_RATE_LIMIT_MAX
|
|
312
|
+
return { maxGetsPerMinute: DEFAULT_RATE_LIMIT_MAX };
|
|
313
313
|
}
|
|
314
314
|
}
|
|
315
315
|
function writeConfig(config) {
|
|
@@ -321,8 +321,6 @@ function configureRateLimit(password, options) {
|
|
|
321
321
|
const config = readConfig();
|
|
322
322
|
if (options.maxGetsPerMinute !== undefined)
|
|
323
323
|
config.maxGetsPerMinute = options.maxGetsPerMinute;
|
|
324
|
-
if (options.sessionTtlHours !== undefined)
|
|
325
|
-
config.sessionTtlHours = options.sessionTtlHours;
|
|
326
324
|
writeConfig(config);
|
|
327
325
|
return config;
|
|
328
326
|
}
|
|
@@ -459,12 +457,6 @@ function readSessionCache() {
|
|
|
459
457
|
if (!existsSync2(getSessionFile()) || !existsSync2(getCacheFile()))
|
|
460
458
|
return null;
|
|
461
459
|
try {
|
|
462
|
-
const sessionStat = statSync(getSessionFile());
|
|
463
|
-
const age = Date.now() - sessionStat.mtimeMs;
|
|
464
|
-
const config = readConfig();
|
|
465
|
-
if (age > config.sessionTtlHours * 3600000) {
|
|
466
|
-
return null;
|
|
467
|
-
}
|
|
468
460
|
const sessionKeyHex = readFileSync3(getSessionFile(), "utf8").trim();
|
|
469
461
|
const sessionKey = Buffer.from(sessionKeyHex, "hex");
|
|
470
462
|
const payload = readFileSync3(getCacheFile());
|
|
@@ -689,12 +681,11 @@ function hasSecretWithSession(opaqueKey) {
|
|
|
689
681
|
return false;
|
|
690
682
|
}
|
|
691
683
|
}
|
|
692
|
-
var FREE_TIER_MAX_SECRETS = 5,
|
|
684
|
+
var FREE_TIER_MAX_SECRETS = 5, DEFAULT_RATE_LIMIT_WINDOW_MS, DEFAULT_RATE_LIMIT_MAX = 30, BASE_CHARS_V3 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@$&*=-!", BASE_CHARS_V4 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", BASE_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
|
|
693
685
|
var init_vault = __esm(() => {
|
|
694
686
|
init_crypto();
|
|
695
687
|
init_env_parser();
|
|
696
688
|
init_license();
|
|
697
|
-
DEFAULT_SESSION_TTL_MS = 4 * 60 * 60 * 1000;
|
|
698
689
|
DEFAULT_RATE_LIMIT_WINDOW_MS = 60 * 1000;
|
|
699
690
|
});
|
|
700
691
|
|
|
@@ -703,7 +694,7 @@ var exports_scanner = {};
|
|
|
703
694
|
__export(exports_scanner, {
|
|
704
695
|
scanProject: () => scanProject
|
|
705
696
|
});
|
|
706
|
-
import { readdirSync, readFileSync as readFileSync4, statSync
|
|
697
|
+
import { readdirSync, readFileSync as readFileSync4, statSync } from "node:fs";
|
|
707
698
|
import { join as join3, relative } from "node:path";
|
|
708
699
|
function walkDir(dir, base, results) {
|
|
709
700
|
let entries;
|
|
@@ -718,7 +709,7 @@ function walkDir(dir, base, results) {
|
|
|
718
709
|
const fullPath = join3(dir, entry);
|
|
719
710
|
let stat;
|
|
720
711
|
try {
|
|
721
|
-
stat =
|
|
712
|
+
stat = statSync(fullPath);
|
|
722
713
|
} catch {
|
|
723
714
|
continue;
|
|
724
715
|
}
|
|
@@ -860,7 +851,7 @@ var init_scanner = __esm(() => {
|
|
|
860
851
|
init_vault();
|
|
861
852
|
init_license();
|
|
862
853
|
import { createInterface } from "node:readline";
|
|
863
|
-
import { existsSync as existsSync3, readFileSync as readFileSync5, writeFileSync as writeFileSync3, mkdirSync as mkdirSync3, readdirSync as readdirSync2, statSync as
|
|
854
|
+
import { existsSync as existsSync3, readFileSync as readFileSync5, writeFileSync as writeFileSync3, mkdirSync as mkdirSync3, readdirSync as readdirSync2, statSync as statSync2 } from "node:fs";
|
|
864
855
|
import { spawnSync } from "node:child_process";
|
|
865
856
|
import { createHash } from "node:crypto";
|
|
866
857
|
import { join as join4 } from "node:path";
|
|
@@ -908,7 +899,6 @@ Usage:
|
|
|
908
899
|
envsave passwd Change master password
|
|
909
900
|
envsave config Show rate limit config
|
|
910
901
|
envsave config --max-gets <n> Set max gets per minute (password required)
|
|
911
|
-
envsave config --session-ttl <hours> Set session TTL in hours (password required)
|
|
912
902
|
envsave list List clean key names (password required)
|
|
913
903
|
envsave import <file> Import from .env file (password required)
|
|
914
904
|
envsave export Export as .env format (password required)
|
|
@@ -1144,32 +1134,23 @@ Use 'envsave reveal <KEY>' to get the opaque key for each secret.`);
|
|
|
1144
1134
|
}
|
|
1145
1135
|
case "config": {
|
|
1146
1136
|
const maxGets = getFlag("--max-gets");
|
|
1147
|
-
|
|
1148
|
-
if (!maxGets && !sessionTtl) {
|
|
1137
|
+
if (!maxGets) {
|
|
1149
1138
|
const config2 = getRateLimitConfig();
|
|
1150
1139
|
console.log(`Rate limit config:`);
|
|
1151
1140
|
console.log(` Max gets per minute: ${config2.maxGetsPerMinute}`);
|
|
1152
|
-
console.log(` Session TTL: ${config2.sessionTtlHours} hours`);
|
|
1153
1141
|
break;
|
|
1154
1142
|
}
|
|
1155
1143
|
const password = await requirePassword();
|
|
1156
|
-
const options = {
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
if (sessionTtl)
|
|
1160
|
-
options.sessionTtlHours = parseFloat(sessionTtl);
|
|
1144
|
+
const options = {
|
|
1145
|
+
maxGetsPerMinute: parseInt(maxGets, 10)
|
|
1146
|
+
};
|
|
1161
1147
|
if (options.maxGetsPerMinute !== undefined && (isNaN(options.maxGetsPerMinute) || options.maxGetsPerMinute < 1)) {
|
|
1162
1148
|
console.error("--max-gets must be a positive number.");
|
|
1163
1149
|
process.exit(1);
|
|
1164
1150
|
}
|
|
1165
|
-
if (options.sessionTtlHours !== undefined && (isNaN(options.sessionTtlHours) || options.sessionTtlHours <= 0)) {
|
|
1166
|
-
console.error("--session-ttl must be a positive number.");
|
|
1167
|
-
process.exit(1);
|
|
1168
|
-
}
|
|
1169
1151
|
const config = configureRateLimit(password, options);
|
|
1170
1152
|
console.log(`Config updated:`);
|
|
1171
1153
|
console.log(` Max gets per minute: ${config.maxGetsPerMinute}`);
|
|
1172
|
-
console.log(` Session TTL: ${config.sessionTtlHours} hours`);
|
|
1173
1154
|
break;
|
|
1174
1155
|
}
|
|
1175
1156
|
case "passwd": {
|
|
@@ -1468,7 +1449,7 @@ Use 'envsave list' to verify your secrets.`);
|
|
|
1468
1449
|
break;
|
|
1469
1450
|
}
|
|
1470
1451
|
if (cloudStatus.hasBackup && hasLocal && cloudStatus.checksum !== localChecksum) {
|
|
1471
|
-
const localMtime =
|
|
1452
|
+
const localMtime = statSync2(vaultFile).mtimeMs;
|
|
1472
1453
|
const cloudDate = cloudStatus.updatedAt ? new Date(cloudStatus.updatedAt).getTime() : 0;
|
|
1473
1454
|
console.log("Local and cloud vaults differ:");
|
|
1474
1455
|
console.log(` Local: ${localSize} bytes, modified ${new Date(localMtime).toISOString()}`);
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/vault.ts
|
|
2
|
-
import { readFileSync, writeFileSync, existsSync, mkdirSync, chmodSync, appendFileSync
|
|
2
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync, chmodSync, appendFileSync } from "node:fs";
|
|
3
3
|
import { join as join2 } from "node:path";
|
|
4
4
|
import { homedir as homedir2 } from "node:os";
|
|
5
5
|
|
|
@@ -40,7 +40,6 @@ function getRateFile() {
|
|
|
40
40
|
function getAccessLog() {
|
|
41
41
|
return join2(getEnvsaveDir(), "access.log");
|
|
42
42
|
}
|
|
43
|
-
var DEFAULT_SESSION_TTL_MS = 4 * 60 * 60 * 1000;
|
|
44
43
|
var DEFAULT_RATE_LIMIT_WINDOW_MS = 60 * 1000;
|
|
45
44
|
var DEFAULT_RATE_LIMIT_MAX = 30;
|
|
46
45
|
function getConfigFile() {
|
|
@@ -51,12 +50,12 @@ function guardRealVault() {
|
|
|
51
50
|
}
|
|
52
51
|
function readConfig() {
|
|
53
52
|
if (!existsSync(getConfigFile())) {
|
|
54
|
-
return { maxGetsPerMinute: DEFAULT_RATE_LIMIT_MAX
|
|
53
|
+
return { maxGetsPerMinute: DEFAULT_RATE_LIMIT_MAX };
|
|
55
54
|
}
|
|
56
55
|
try {
|
|
57
56
|
return JSON.parse(readFileSync(getConfigFile(), "utf8"));
|
|
58
57
|
} catch {
|
|
59
|
-
return { maxGetsPerMinute: DEFAULT_RATE_LIMIT_MAX
|
|
58
|
+
return { maxGetsPerMinute: DEFAULT_RATE_LIMIT_MAX };
|
|
60
59
|
}
|
|
61
60
|
}
|
|
62
61
|
function ensureDir() {
|
|
@@ -69,12 +68,6 @@ function readSessionCache() {
|
|
|
69
68
|
if (!existsSync(getSessionFile()) || !existsSync(getCacheFile()))
|
|
70
69
|
return null;
|
|
71
70
|
try {
|
|
72
|
-
const sessionStat = statSync(getSessionFile());
|
|
73
|
-
const age = Date.now() - sessionStat.mtimeMs;
|
|
74
|
-
const config = readConfig();
|
|
75
|
-
if (age > config.sessionTtlHours * 3600000) {
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
71
|
const sessionKeyHex = readFileSync(getSessionFile(), "utf8").trim();
|
|
79
72
|
const sessionKey = Buffer.from(sessionKeyHex, "hex");
|
|
80
73
|
const payload = readFileSync(getCacheFile());
|