@objectstack/service-settings 10.2.0 → 10.3.0
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/index.cjs +16 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -916,6 +916,7 @@ var import_node_path = require("path");
|
|
|
916
916
|
var SECRET_KEY_ENV = "OS_SECRET_KEY";
|
|
917
917
|
var DEV_KEY_ENV = "OS_DEV_CRYPTO_KEY";
|
|
918
918
|
var DEV_KEY_LEGACY_ENV = "OBJECTSTACK_DEV_CRYPTO_KEY";
|
|
919
|
+
var AUTOKEY_ENV = "OS_CRYPTO_AUTOKEY";
|
|
919
920
|
var processEnv = () => globalThis.process?.env ?? {};
|
|
920
921
|
var detectMode = (env) => {
|
|
921
922
|
if (env.VITEST || env.NODE_ENV === "test") return "test";
|
|
@@ -939,6 +940,10 @@ var parseKey = (raw) => {
|
|
|
939
940
|
}
|
|
940
941
|
return void 0;
|
|
941
942
|
};
|
|
943
|
+
var parseBool = (raw) => {
|
|
944
|
+
const v = raw?.trim().toLowerCase();
|
|
945
|
+
return v === "1" || v === "true" || v === "yes";
|
|
946
|
+
};
|
|
942
947
|
var loadExistingKey = (path) => {
|
|
943
948
|
try {
|
|
944
949
|
if (!(0, import_node_fs.existsSync)(path)) return void 0;
|
|
@@ -1012,6 +1017,17 @@ function resolveDataKey(opts) {
|
|
|
1012
1017
|
);
|
|
1013
1018
|
return { key: existing, source: "file" };
|
|
1014
1019
|
}
|
|
1020
|
+
if (parseBool(env[AUTOKEY_ENV])) {
|
|
1021
|
+
const persisted2 = loadOrCreateKey(path);
|
|
1022
|
+
if (persisted2) {
|
|
1023
|
+
if (persisted2.generated) {
|
|
1024
|
+
warn(
|
|
1025
|
+
`[LocalCryptoProvider] No ${SECRET_KEY_ENV} set \u2014 minted a new AES-256-GCM key and persisted it to ${path} (mode 0600). Restarts on this host reuse it automatically. For containers, CI, or multi-node, set ${SECRET_KEY_ENV} so every node shares one key.`
|
|
1026
|
+
);
|
|
1027
|
+
}
|
|
1028
|
+
return { key: persisted2.key, source: persisted2.generated ? "generated-file" : "file" };
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1015
1031
|
throw new Error(MISSING_PROD_KEY_MSG(path));
|
|
1016
1032
|
}
|
|
1017
1033
|
const persisted = loadOrCreateKey(path);
|