From 46bd6d3b3c0e12484a5c40261530fe944b0bce42 Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Sun, 9 Jun 2019 11:46:28 +0200 Subject: [PATCH] Moved types from factory to schema --- src/factory.ts | 25 +------------------------ src/schema.ts | 33 +++++++++++++++++++++++---------- 2 files changed, 24 insertions(+), 34 deletions(-) diff --git a/src/factory.ts b/src/factory.ts index 41ed06a..6a18ba2 100644 --- a/src/factory.ts +++ b/src/factory.ts @@ -11,30 +11,7 @@ import { removeHidden } from "./utils"; const readDir = promisify(_readdir); const readFile = promisify(_readFile); -interface BundleUnit { - [key: string]: Buffer; -} - -interface PartitionedBundle { - bundle: BundleUnit; - l10nBundle: { - [key: string]: BundleUnit - }; -} - -interface FinalCertificates { - wwdr: forge.pki.Certificate; - signerCert: forge.pki.Certificate; - signerKey: forge.pki.PrivateKey; -} - -interface FactoryOptions { - model: string | BundleUnit, - certificates: Certificates; - overrides?: Object; -} - -export async function createPass(options: FactoryOptions) { +export async function createPass(options: FactoryOptions): Promise { if (!(options && Object.keys(options).length)) { throw new Error("Unable to create Pass: no options were passed"); } diff --git a/src/schema.ts b/src/schema.ts index b338ab3..e7549cd 100644 --- a/src/schema.ts +++ b/src/schema.ts @@ -20,20 +20,33 @@ export interface FactoryOptions { shouldOverwrite?: boolean; } -export interface PassInstance { - model: { [key: string]: Buffer }; - certificates: { +export interface BundleUnit { + [key: string]: Buffer; +} + +export interface PartitionedBundle { + bundle: BundleUnit; + l10nBundle: { + [key: string]: BundleUnit + }; +} + +export interface FinalCertificates { wwdr: string; signerCert: string; - signerKey: { - keyFile: string; - passphrase?: string; - }; - }; - overrides?: OverridesSupportedOptions; - shouldOverwrite?: boolean; + signerKey: string; } +export interface PassInstance { + model: PartitionedBundle; + certificates: FinalCertificates; + overrides?: OverridesSupportedOptions; +} + +// ************************************ // +// * JOI Schemas + Related Interfaces * // +// ************************************ // + const certificatesSchema = Joi.object().keys({ wwdr: Joi.string().required(), signerCert: Joi.string().required(),