From 34d4879438fb392ab50ed6e69cbbd48999626154 Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Tue, 29 Jan 2019 20:23:10 +0100 Subject: [PATCH] Added content-certificates support; Fixed problem with supported options --- src/pass.js | 14 ++++++++++---- src/schema.js | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/pass.js b/src/pass.js index 1182ad0..7de2422 100644 --- a/src/pass.js +++ b/src/pass.js @@ -671,7 +671,7 @@ class Pass { let modelPath = path.resolve(options.model) + (!!options.model && !path.extname(options.model) ? ".pass" : ""); const filteredOpts = schema.getValidated(options.overrides, "supportedOptions"); - if (!Object.keys(filteredOpts).length) { + if (!filteredOpts) { throw new Error(formatMessage("OVV_KEYS_BADFORMAT")) } @@ -714,10 +714,16 @@ function readCertificates(certificates) { const optCertsNames = Object.keys(raw); const certPaths = optCertsNames.map((val) => { const cert = raw[val]; - const filePath = !(cert instanceof Object) ? cert : cert["keyFile"]; - const resolvedPath = path.resolve(filePath); + // realRawValue exists as signerKey might be an object + const realRawValue = !(cert instanceof Object) ? cert : cert["keyFile"]; - return readFile(resolvedPath); + // 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); + } else { + return Promise.resolve(realRawValue); + } }); return Promise.all(certPaths) diff --git a/src/schema.js b/src/schema.js index 422ae70..50df36c 100644 --- a/src/schema.js +++ b/src/schema.js @@ -146,7 +146,7 @@ function getValidated(opts, schemaName) { if (validation.error) { debug(`Validation failed in getValidated due to error: ${validation.error.message}`); - return {}; + return null; } return validation.value;