bln-squrl-tool
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -42,5 +42,4 @@ 'use strict'; | ||
commandObj | ||
.option('-i, --input-file <file>', 'input file, takes precendence over --file argument') | ||
// eslint-disable-next-line max-len | ||
.option('-o, --output-file <file>', 'output file, overwrites existing, takes precendence over --file argument') | ||
.option('-i, --input-file <file>', 'input file, takes priority over --file argument') | ||
.option('-o, --output-file <file>', 'output file, overwrites existing, takes priority over --file argument') | ||
.option('-f, --file <file>', 'file to replace'); | ||
@@ -72,3 +71,3 @@ }, | ||
} | ||
throw new Error('Vault not specified. please specifiy vault on your secret store.'); | ||
throw new Error('Vault not specified. please specify vault on your secret store.'); | ||
}, | ||
@@ -75,0 +74,0 @@ |
{ | ||
"name": "bln-squrl-tool", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "engines": { |
@@ -5,2 +5,4 @@ 'use strict'; | ||
const INVALID_SS_KEY = /[^a-zA-Z0-9-/_+=.@!]/u; | ||
class AWSSecretsManagerStore { | ||
@@ -15,2 +17,14 @@ constructor(options = {}) { | ||
async get(key, vault, throwOnNotFound = false) { | ||
if (INVALID_SS_KEY.test(key)) { | ||
if (throwOnNotFound) { | ||
throw new Error(`key "${key}" contains characters not supported by AWS Secret Store`); | ||
} | ||
return undefined; | ||
} | ||
if (INVALID_SS_KEY.test(vault)) { | ||
if (throwOnNotFound) { | ||
throw new Error(`vault "${vault}" contains characters not supported by AWS Secret Store`); | ||
} | ||
return undefined; | ||
} | ||
try { | ||
@@ -26,6 +40,3 @@ const data = await this.secretsmanager.getSecretValue({SecretId: `${vault}/${key}`}).promise(); | ||
catch (err) { | ||
if (err.message.includes('can\'t find')) { | ||
if (throwOnNotFound) { | ||
throw new Error(`secret ${key} in vault ${vault} was not found by 1Password`); | ||
} | ||
if (err.message.includes('can\'t find') && !throwOnNotFound) { | ||
return undefined; | ||
@@ -32,0 +43,0 @@ } |
@@ -5,2 +5,4 @@ 'use strict'; | ||
const INVALID_SSM_KEY = /[^a-zA-Z0-9-/_.]/u; | ||
class SystemsManagerStore { | ||
@@ -16,2 +18,14 @@ constructor(options = {}) { | ||
let decodedValue; | ||
if (INVALID_SSM_KEY.test(key)) { | ||
if (throwOnNotFound) { | ||
throw new Error(`key "${key}" contains characters not supported by AWS Systems Managers Store`); | ||
} | ||
return undefined; | ||
} | ||
if (INVALID_SSM_KEY.test(vault)) { | ||
if (throwOnNotFound) { | ||
throw new Error(`vault "${vault}" contains characters not supported by AWS Systems Managers Store`); | ||
} | ||
return undefined; | ||
} | ||
try { | ||
@@ -30,8 +44,6 @@ const {Parameter: {Value}} = await this.ssm.getParameter({ | ||
catch (e) { | ||
if (e.code && e.code === 'ParameterNotFound') { | ||
if (e.code && e.code === 'ParameterNotFound' && !throwOnNotFound) { | ||
return undefined; | ||
} | ||
if (throwOnNotFound) { | ||
throw new Error(`error from AWS SDK in SystemsManagerStore - ${e.message}`); | ||
} | ||
throw new Error(`error from AWS Systems Manager Store - ${e.message}`); | ||
} | ||
@@ -38,0 +50,0 @@ return decodedValue; |
@@ -18,3 +18,3 @@ 'use strict'; | ||
const value = await squrl.retrieve({key: secretKey, vault}); | ||
if (value) { | ||
if (value !== undefined) { | ||
return {value, secretKey, vault}; | ||
@@ -21,0 +21,0 @@ } |
Sorry, the diff of this file is too big to display
214816
5714