@digitalocean/functions-deployer 5.0.21 → 5.0.22

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/lib/index.js CHANGED
@@ -723,26 +723,41 @@ async function loadProjectConfig(configFile, envPath, buildEnvPath, filePath, re
723
723
  }
724
724
  function encryptProjectConfig(config) {
725
725
  const key = crypto.randomBytes(32);
726
- const iv = Buffer.alloc(16).fill(0);
727
- const cipher = crypto.createCipheriv("aes256", key, iv);
728
- const encrypted = cipher.update(config, "utf8", "hex") + cipher.final("hex");
729
- return {
730
- config: encrypted,
731
- key: key.toString("hex")
732
- };
733
- }
734
- function decryptProjectConfig(config, key) {
735
- const iv = Buffer.alloc(16).fill(0);
736
- const decipher = crypto.createDecipheriv(
737
- "aes256",
738
- Buffer.from(key, "hex"),
739
- iv
740
- );
741
- const decryptedMessage = Buffer.concat([
742
- decipher.update(config, "hex"),
726
+ const iv = crypto.randomBytes(12);
727
+ const cipher = crypto.createCipheriv("aes-256-gcm", key, iv);
728
+ const encrypted = Buffer.concat([
729
+ cipher.update(config, "utf8"),
730
+ cipher.final()
731
+ ]);
732
+ const authTag = cipher.getAuthTag();
733
+ const final = `v2:${iv.toString("hex")}:${authTag.toString(
734
+ "hex"
735
+ )}:${encrypted.toString("hex")}`;
736
+ return { config: final, key: key.toString("hex") };
737
+ }
738
+ function decryptProjectConfig(encrypted, keyHex) {
739
+ const key = Buffer.from(keyHex, "hex");
740
+ if (encrypted.startsWith("v2:")) {
741
+ const [_v, ivHex, tagHex, encryptedHex] = encrypted.split(":");
742
+ const decipher2 = crypto.createDecipheriv(
743
+ "aes-256-gcm",
744
+ key,
745
+ Buffer.from(ivHex, "hex")
746
+ );
747
+ decipher2.setAuthTag(Buffer.from(tagHex, "hex"));
748
+ const decrypted2 = Buffer.concat([
749
+ decipher2.update(Buffer.from(encryptedHex, "hex")),
750
+ decipher2.final()
751
+ ]);
752
+ return decrypted2.toString("utf8");
753
+ }
754
+ const iv = Buffer.alloc(16, 0);
755
+ const decipher = crypto.createDecipheriv("aes-256-cbc", key, iv);
756
+ const decrypted = Buffer.concat([
757
+ decipher.update(Buffer.from(encrypted, "hex")),
743
758
  decipher.final()
744
759
  ]);
745
- return decryptedMessage.toString("utf8");
760
+ return decrypted.toString("utf8");
746
761
  }
747
762
  function renameFunctionsToActions(config) {
748
763
  if (config.packages) {
@@ -4445,7 +4460,7 @@ var import_http = require("http");
4445
4460
  var import_debug12 = __toESM(require("debug"));
4446
4461
 
4447
4462
  // src/version.ts
4448
- var version = "5.0.21";
4463
+ var version = "5.0.22";
4449
4464
 
4450
4465
  // src/main.ts
4451
4466
  var verboseError = (0, import_debug12.default)("nim:error");