From 84ab3774edae648dd2ab1d883cd707e0d55dafaa Mon Sep 17 00:00:00 2001 From: jeff Date: Thu, 19 Oct 2017 15:29:36 -0700 Subject: [PATCH] Release 4.3.1. Fixed `secureConfig.fetchFromS3ByEnvVar` not taking bucket name by env var. --- dist/secureConfig/index.d.ts | 2 +- dist/secureConfig/index.js | 13 ++++++++----- dist/secureConfig/index.js.map | 2 +- package.json | 2 +- src/secureConfig/index.ts | 13 ++++++++----- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/dist/secureConfig/index.d.ts b/dist/secureConfig/index.d.ts index 8144852..f15856e 100644 --- a/dist/secureConfig/index.d.ts +++ b/dist/secureConfig/index.d.ts @@ -1,4 +1,4 @@ import "babel-polyfill"; export { AuthenticationConfig } from "./AuthenticationConfig"; export declare function fetchFromS3(bucket: string, key: string): Promise; -export declare function fetchFromS3ByEnvVar(bucket: string, envVar: string): Promise; +export declare function fetchFromS3ByEnvVar(bucketEnvVar: string, keyEnvVar: string): Promise; diff --git a/dist/secureConfig/index.js b/dist/secureConfig/index.js index e8bc0c6..c544d9a 100644 --- a/dist/secureConfig/index.js +++ b/dist/secureConfig/index.js @@ -35,14 +35,17 @@ function fetchFromS3(bucket, key) { }); } exports.fetchFromS3 = fetchFromS3; -function fetchFromS3ByEnvVar(bucket, envVar) { +function fetchFromS3ByEnvVar(bucketEnvVar, keyEnvVar) { return __awaiter(this, void 0, void 0, function* () { - if (!process || !process.env[envVar]) { - console.error(`${envVar} is not set. The secure config item cannot be fetched.`); + if (!process || !process.env[bucketEnvVar]) { + console.error(`${bucketEnvVar} is not set. The secure config item cannot be fetched.`); return null; } - console.log(`Secure config env var ${envVar} = ${process.env[envVar]}.`); - return yield fetchFromS3(bucket, process.env[envVar]); + if (!process || !process.env[keyEnvVar]) { + console.error(`${keyEnvVar} is not set. The secure config item cannot be fetched.`); + return null; + } + return yield fetchFromS3(process.env[bucketEnvVar], process.env[keyEnvVar]); }); } exports.fetchFromS3ByEnvVar = fetchFromS3ByEnvVar; diff --git a/dist/secureConfig/index.js.map b/dist/secureConfig/index.js.map index e27ecd4..ace46a4 100644 --- a/dist/secureConfig/index.js.map +++ b/dist/secureConfig/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/secureConfig/index.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,0BAAwB;AACxB,+BAA+B;AAG/B,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;AAE/C,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;AACpD,MAAM,EAAE,GAAG,IAAI,GAAG,CAAC,EAAE,CAAC;IAClB,UAAU,EAAE,YAAY;IACxB,WAAW,EAAE,KAAK;IAClB,gBAAgB,EAAE,IAAI;IACtB,MAAM,EAAE,MAAM;CACjB,CAAC,CAAC;AAEH,qBAAqC,MAAc,EAAE,GAAW;;QAC5D,OAAO,CAAC,GAAG,CAAC,+BAA+B,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC;QAC7D,IAAI,CAAC;YACD,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,SAAS,CAAC;gBAC5B,MAAM,EAAE,MAAM;gBACd,GAAG,EAAE,GAAG;aACX,CAAC,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC5C,CAAC;QAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,kCAAkC,MAAM,IAAI,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC;YACxE,MAAM,CAAC,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;CAAA;AAZD,kCAYC;AAED,6BAA6C,MAAc,EAAE,MAAc;;QACvE,EAAE,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,G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,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,kCAAkC,MAAM,IAAI,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC;YACxE,MAAM,CAAC,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;CAAA;AAZD,kCAYC;AAED,6BAA6C,YAAoB,EAAE,SAAiB;;QAChF,EAAE,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YACzC,OAAO,CAAC,KAAK,CAAC,GAAG,YAAY,yDAAyD,CAAC,CAAC;YACxF,MAAM,CAAC,IAAI,CAAC;QAChB,CAAC;QACD,EAAE,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YACtC,OAAO,CAAC,KAAK,CAAC,GAAG,SAAS,yDAAyD,CAAC,CAAC;YACrF,MAAM,CAAC,IAAI,CAAC;QAChB,CAAC;QAED,MAAM,CAAC,MAAM,WAAW,CAAI,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;IACnF,CAAC;CAAA;AAXD,kDAWC"} \ No newline at end of file diff --git a/package.json b/package.json index c0009ed..75b7dd6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "giftbit-cassava-routes", - "version": "4.3.0", + "version": "4.3.1", "description": "Private Giftbit routes for use with Cassava.", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/secureConfig/index.ts b/src/secureConfig/index.ts index 90ead5b..75df780 100644 --- a/src/secureConfig/index.ts +++ b/src/secureConfig/index.ts @@ -26,12 +26,15 @@ export async function fetchFromS3(bucket: string, key: string): Promise { } } -export async function fetchFromS3ByEnvVar(bucket: string, envVar: string): Promise { - if (!process || !process.env[envVar]) { - console.error(`${envVar} is not set. The secure config item cannot be fetched.`); +export async function fetchFromS3ByEnvVar(bucketEnvVar: string, keyEnvVar: string): Promise { + if (!process || !process.env[bucketEnvVar]) { + console.error(`${bucketEnvVar} is not set. The secure config item cannot be fetched.`); + return null; + } + if (!process || !process.env[keyEnvVar]) { + console.error(`${keyEnvVar} is not set. The secure config item cannot be fetched.`); return null; } - console.log(`Secure config env var ${envVar} = ${process.env[envVar]}.`); - return await fetchFromS3(bucket, process.env[envVar]); + return await fetchFromS3(process.env[bucketEnvVar], process.env[keyEnvVar]); }