Added content-certificates support;

Fixed problem with supported options
This commit is contained in:
Alexander Cerutti
2019-01-29 20:23:10 +01:00
parent a9f71f113d
commit 34d4879438
2 changed files with 11 additions and 5 deletions

View File

@@ -671,7 +671,7 @@ class Pass {
let modelPath = path.resolve(options.model) + (!!options.model && !path.extname(options.model) ? ".pass" : ""); let modelPath = path.resolve(options.model) + (!!options.model && !path.extname(options.model) ? ".pass" : "");
const filteredOpts = schema.getValidated(options.overrides, "supportedOptions"); const filteredOpts = schema.getValidated(options.overrides, "supportedOptions");
if (!Object.keys(filteredOpts).length) { if (!filteredOpts) {
throw new Error(formatMessage("OVV_KEYS_BADFORMAT")) throw new Error(formatMessage("OVV_KEYS_BADFORMAT"))
} }
@@ -714,10 +714,16 @@ function readCertificates(certificates) {
const optCertsNames = Object.keys(raw); const optCertsNames = Object.keys(raw);
const certPaths = optCertsNames.map((val) => { const certPaths = optCertsNames.map((val) => {
const cert = raw[val]; const cert = raw[val];
const filePath = !(cert instanceof Object) ? cert : cert["keyFile"]; // realRawValue exists as signerKey might be an object
const resolvedPath = path.resolve(filePath); const realRawValue = !(cert instanceof Object) ? cert : cert["keyFile"];
// We are checking if the string is a path or a content
if (!!path.parse(realRawValue).ext) {
const resolvedPath = path.resolve(realRawValue);
return readFile(resolvedPath); return readFile(resolvedPath);
} else {
return Promise.resolve(realRawValue);
}
}); });
return Promise.all(certPaths) return Promise.all(certPaths)

View File

@@ -146,7 +146,7 @@ function getValidated(opts, schemaName) {
if (validation.error) { if (validation.error) {
debug(`Validation failed in getValidated due to error: ${validation.error.message}`); debug(`Validation failed in getValidated due to error: ${validation.error.message}`);
return {}; return null;
} }
return validation.value; return validation.value;