cf-envsync 0.3.4 → 0.3.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.
Files changed (2) hide show
  1. package/dist/index.js +18 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -13110,7 +13110,15 @@ function decryptValue(token, password) {
13110
13110
  function decryptEnvMap(envMap, password) {
13111
13111
  const result = {};
13112
13112
  for (const [key, value] of Object.entries(envMap)) {
13113
- result[key] = isEnvsyncEncrypted(value) ? decryptValue(value, password) : value;
13113
+ if (isEnvsyncEncrypted(value)) {
13114
+ try {
13115
+ result[key] = decryptValue(value, password);
13116
+ } catch {
13117
+ throw new Error(`Failed to decrypt ${key}: wrong password or corrupted data. ` + `Check ENVSYNC_PASSWORD or .env.password`);
13118
+ }
13119
+ } else {
13120
+ result[key] = value;
13121
+ }
13114
13122
  }
13115
13123
  return result;
13116
13124
  }
@@ -14934,6 +14942,15 @@ var init_encrypt = __esm(() => {
14934
14942
  }
14935
14943
  const content = await readFile(envFilePath);
14936
14944
  const lines = parseLines(content);
14945
+ const firstEncrypted = lines.find((l2) => l2.key && l2.value && isEnvsyncEncrypted(l2.value.trim()));
14946
+ if (firstEncrypted) {
14947
+ try {
14948
+ decryptValue(firstEncrypted.value.trim(), password);
14949
+ } catch {
14950
+ consola.error(`Password mismatch: cannot decrypt existing value for ${firstEncrypted.key}. ` + `The current password differs from the one used to encrypt existing values.`);
14951
+ process.exit(1);
14952
+ }
14953
+ }
14937
14954
  let encryptedCount = 0;
14938
14955
  let skippedCount = 0;
14939
14956
  const outputLines = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cf-envsync",
3
- "version": "0.3.4",
3
+ "version": "0.3.6",
4
4
  "description": "Sync .env files to Cloudflare Workers secrets, .dev.vars, and more",
5
5
  "type": "module",
6
6
  "exports": {