@digitalocean/functions-deployer 5.0.21 → 5.0.23

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/README.md CHANGED
@@ -16,10 +16,10 @@ The `internalRelease.sh` script can also be run with a `--test` flag, in which c
16
16
 
17
17
  ### Testing changes locally
18
18
 
19
- To test changes locally
19
+ To test changes locally. make sure to add --ignore-scripts flag during install.
20
20
 
21
21
  ```
22
- npm install
22
+ npm install --ignore-scripts
23
23
  npm run build
24
24
  ```
25
25
  after which the deployer shell can be run as `/path/to/repo/bin/run`. It is often convenient to make a symbolic link in your path pointing to that location (e.g. as `dosls`). Then, you can test with
@@ -21,3 +21,4 @@ export declare function getApiHosts(persister: Persister): Promise<string[]>;
21
21
  export declare function getCredentialList(): Promise<CredentialRow[]>;
22
22
  export declare function getNamespace(host: string, auth: string): Promise<string>;
23
23
  export declare function getCurrentNamespace(): Promise<string | undefined>;
24
+ export declare function omitAccountTokenFromRemoteSlice(credentials: Credentials | undefined): Credentials | undefined;
@@ -177,7 +177,7 @@ export interface CredentialEntry {
177
177
  export interface Credentials {
178
178
  namespace: string | undefined;
179
179
  ow: OWOptions;
180
- do_token: string;
180
+ do_token?: string;
181
181
  }
182
182
  export interface CredentialRow {
183
183
  namespace: string;
@@ -1,8 +1,9 @@
1
- import { DeployStructure, PackageSpec, ProjectReader } from './deploy-struct';
1
+ import { DeployStructure, ActionSpec, PackageSpec, ProjectReader } from './deploy-struct';
2
2
  export declare const BUILDER_NAMESPACE: string;
3
3
  export declare function getBuildForAction(filepath: string, reader: ProjectReader): Promise<string>;
4
4
  export declare function buildAllActions(spec: DeployStructure): Promise<PackageSpec[]>;
5
5
  export declare function getBuildForLib(filepath: string, reader: ProjectReader): Promise<string>;
6
6
  export declare function maybeBuildLib(spec: DeployStructure): Promise<void>;
7
7
  export declare function checkIncludeItems(items: string[]): string;
8
+ export declare function makeConfigFromActionSpec(action: ActionSpec, spec: DeployStructure, pkgName: string): DeployStructure;
8
9
  export declare function getRemoteBuildName(): string;
package/lib/index.js CHANGED
@@ -348,6 +348,15 @@ function getUniqueCredentials(namespace, apihost, store) {
348
348
  do_token: process.env.DO_API_KEY
349
349
  };
350
350
  }
351
+ function omitAccountTokenFromRemoteSlice(credentials) {
352
+ if (!credentials) {
353
+ return credentials;
354
+ }
355
+ return {
356
+ namespace: credentials.namespace,
357
+ ow: credentials.ow
358
+ };
359
+ }
351
360
 
352
361
  // src/runtimes.ts
353
362
  var import_axios = __toESM(require("axios"));
@@ -723,26 +732,41 @@ async function loadProjectConfig(configFile, envPath, buildEnvPath, filePath, re
723
732
  }
724
733
  function encryptProjectConfig(config) {
725
734
  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"),
735
+ const iv = crypto.randomBytes(12);
736
+ const cipher = crypto.createCipheriv("aes-256-gcm", key, iv);
737
+ const encrypted = Buffer.concat([
738
+ cipher.update(config, "utf8"),
739
+ cipher.final()
740
+ ]);
741
+ const authTag = cipher.getAuthTag();
742
+ const final = `v2:${iv.toString("hex")}:${authTag.toString(
743
+ "hex"
744
+ )}:${encrypted.toString("hex")}`;
745
+ return { config: final, key: key.toString("hex") };
746
+ }
747
+ function decryptProjectConfig(encrypted, keyHex) {
748
+ const key = Buffer.from(keyHex, "hex");
749
+ if (encrypted.startsWith("v2:")) {
750
+ const [_v, ivHex, tagHex, encryptedHex] = encrypted.split(":");
751
+ const decipher2 = crypto.createDecipheriv(
752
+ "aes-256-gcm",
753
+ key,
754
+ Buffer.from(ivHex, "hex")
755
+ );
756
+ decipher2.setAuthTag(Buffer.from(tagHex, "hex"));
757
+ const decrypted2 = Buffer.concat([
758
+ decipher2.update(Buffer.from(encryptedHex, "hex")),
759
+ decipher2.final()
760
+ ]);
761
+ return decrypted2.toString("utf8");
762
+ }
763
+ const iv = Buffer.alloc(16, 0);
764
+ const decipher = crypto.createDecipheriv("aes-256-cbc", key, iv);
765
+ const decrypted = Buffer.concat([
766
+ decipher.update(Buffer.from(encrypted, "hex")),
743
767
  decipher.final()
744
768
  ]);
745
- return decryptedMessage.toString("utf8");
769
+ return decrypted.toString("utf8");
746
770
  }
747
771
  function renameFunctionsToActions(config) {
748
772
  if (config.packages) {
@@ -3090,7 +3114,7 @@ function makeConfigFromActionSpec(action, spec, pkgName) {
3090
3114
  targetNamespace,
3091
3115
  parameters,
3092
3116
  environment: globalEnv,
3093
- credentials,
3117
+ credentials: omitAccountTokenFromRemoteSlice(credentials),
3094
3118
  flags,
3095
3119
  deployerAnnotation,
3096
3120
  buildEnv,
@@ -3551,7 +3575,7 @@ function npmBuilder(filepath, displayPath, flags, buildEnv, slice, feedback) {
3551
3575
  debug7("Performing npm build for %s", filepath);
3552
3576
  const cmd = flags.yarn ? "yarn" : "npm";
3553
3577
  const npmRunBuild = buildScriptExists(filepath);
3554
- const args = npmRunBuild ? ["install", "&&", cmd, "run", "build"] : ["install", "--production"];
3578
+ const args = npmRunBuild ? ["install", "--ignore-scripts", "&&", cmd, "run", "build"] : ["install", "--ignore-scripts", "--production"];
3555
3579
  const infoMsg = [cmd, ...args].join(" ");
3556
3580
  if (flags.incremental) {
3557
3581
  debug7("Detected incremental build");
@@ -3578,7 +3602,7 @@ function npmBuilder(filepath, displayPath, flags, buildEnv, slice, feedback) {
3578
3602
  filepath,
3579
3603
  displayPath,
3580
3604
  infoMsg,
3581
- `${cmd} install`,
3605
+ `${cmd} install --ignore-scripts`,
3582
3606
  flags.verboseBuild,
3583
3607
  buildEnv,
3584
3608
  slice,
@@ -4445,7 +4469,7 @@ var import_http = require("http");
4445
4469
  var import_debug12 = __toESM(require("debug"));
4446
4470
 
4447
4471
  // src/version.ts
4448
- var version = "5.0.21";
4472
+ var version = "5.0.23";
4449
4473
 
4450
4474
  // src/main.ts
4451
4475
  var verboseError = (0, import_debug12.default)("nim:error");