From a441297aa2275be67d1b59b0ba2c7d575f2cba4b Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Sat, 5 Sep 2020 22:32:33 +0200 Subject: [PATCH] Fixed issue with TS types update and signerKey extraction --- src/parser.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/parser.ts b/src/parser.ts index cc9821a..f425e6e 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -231,24 +231,26 @@ export function getModelBufferContents(model: BundleUnit): PartitionedBundle { * @param options */ -type flatCertificates = Omit & { signerKey: string; [key: string]: string }; +type flatCertificates = Omit & { + signerKey: string; +}; export async function readCertificatesFromOptions(options: Certificates): Promise { if (!(options && Object.keys(options).length && isValid(options, "certificatesSchema"))) { throw new Error(formatMessage("CP_NO_CERTS")); } + let signerKey: string; + + if (typeof options.signerKey === "object") { + signerKey = options.signerKey?.keyFile; + } else { + signerKey = options.signerKey; + } + // if the signerKey is an object, we want to get // all the real contents and don't care of passphrase - const flattenedDocs = Object.assign({}, options, { - signerKey: ( - options.signerKey && typeof options.signerKey === "string" && - options.signerKey || ( - options.signerKey && - options.signerKey.keyFile - ) - ) - }) as flatCertificates; + const flattenedDocs = Object.assign({}, options, { signerKey }) as flatCertificates; // We read the contents const rawContentsPromises = Object.keys(flattenedDocs)