mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 19:25:23 +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 readDir = promisify(_readdir);
|
||||||
const readFile = promisify(_readFile);
|
const readFile = promisify(_readFile);
|
||||||
|
|
||||||
interface BundleUnit {
|
export async function createPass(options: FactoryOptions): Promise<Pass> {
|
||||||
[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) {
|
|
||||||
if (!(options && Object.keys(options).length)) {
|
if (!(options && Object.keys(options).length)) {
|
||||||
throw new Error("Unable to create Pass: no options were passed");
|
throw new Error("Unable to create Pass: no options were passed");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,20 +20,33 @@ export interface FactoryOptions {
|
|||||||
shouldOverwrite?: boolean;
|
shouldOverwrite?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PassInstance {
|
export interface BundleUnit {
|
||||||
model: { [key: string]: Buffer };
|
[key: string]: Buffer;
|
||||||
certificates: {
|
}
|
||||||
|
|
||||||
|
export interface PartitionedBundle {
|
||||||
|
bundle: BundleUnit;
|
||||||
|
l10nBundle: {
|
||||||
|
[key: string]: BundleUnit
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FinalCertificates {
|
||||||
wwdr: string;
|
wwdr: string;
|
||||||
signerCert: string;
|
signerCert: string;
|
||||||
signerKey: {
|
signerKey: string;
|
||||||
keyFile: string;
|
|
||||||
passphrase?: string;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
overrides?: OverridesSupportedOptions;
|
|
||||||
shouldOverwrite?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface PassInstance {
|
||||||
|
model: PartitionedBundle;
|
||||||
|
certificates: FinalCertificates;
|
||||||
|
overrides?: OverridesSupportedOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ************************************ //
|
||||||
|
// * JOI Schemas + Related Interfaces * //
|
||||||
|
// ************************************ //
|
||||||
|
|
||||||
const certificatesSchema = Joi.object().keys({
|
const certificatesSchema = Joi.object().keys({
|
||||||
wwdr: Joi.string().required(),
|
wwdr: Joi.string().required(),
|
||||||
signerCert: Joi.string().required(),
|
signerCert: Joi.string().required(),
|
||||||
|
|||||||
Reference in New Issue
Block a user