mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 16:25:21 +00:00
Moved types from factory to schema
This commit is contained in:
@@ -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<Pass> {
|
||||
if (!(options && Object.keys(options).length)) {
|
||||
throw new Error("Unable to create Pass: no options were passed");
|
||||
}
|
||||
|
||||
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user