diff --git a/src/PKPass.ts b/src/PKPass.ts index f3bd977..9f801d4 100644 --- a/src/PKPass.ts +++ b/src/PKPass.ts @@ -32,9 +32,9 @@ type TransitTypes = `PKTransitType${ const LOCALIZED_FILE_REGEX_BASE = "(?[a-zA-Z-]{2,}).lproj/"; export default class PKPass extends Bundle { - private certificates: Schemas.Certificates; + private certificates: Schemas.CertificatesSchema; private [fieldKeysPoolSymbol] = new Set(); - private [propsSymbol]: Schemas.ValidPass = {}; + private [propsSymbol]: Schemas.PassProps = {}; private [localizationSymbol]: { [lang: string]: { [placeholder: string]: string; @@ -129,7 +129,11 @@ export default class PKPass extends Bundle { // *** INSTANCE *** // // **************** // - constructor(buffers: NamedBuffers, certificates: Certificates) { + constructor( + buffers: NamedBuffers, + certificates: Schemas.CertificatesSchema, + overrides: Schemas.OverridablePassProps, + ) { super("application/vnd.apple.pkpass"); /** @@ -153,7 +157,7 @@ export default class PKPass extends Bundle { * that are composing your pass instance. */ - public get props(): Readonly { + public get props(): Readonly { return freezeRecusive(this[propsSymbol]); } @@ -322,7 +326,7 @@ export default class PKPass extends Bundle { return super.addBuffer(pathName, buffer); } - private [importMetadataSymbol](data: Schemas.ValidPass) { + private [importMetadataSymbol](data: Schemas.PassProps) { const possibleTypes = [ "boardingPass", "coupon", @@ -768,11 +772,11 @@ function readPassMetadata(buffer: Buffer) { try { const contentAsJSON = JSON.parse( buffer.toString("utf8"), - ) as Schemas.ValidPass; + ) as Schemas.PassProps; const validation = Schemas.getValidated( contentAsJSON, - Schemas.ValidPass, + Schemas.PassProps, ); /** diff --git a/src/schemas/index.ts b/src/schemas/index.ts index ec480c9..93d2953 100644 --- a/src/schemas/index.ts +++ b/src/schemas/index.ts @@ -25,7 +25,7 @@ export interface Manifest { [key: string]: string; } -export interface Certificates { +/* export interface Certificates { wwdr?: string; signerCert?: string; signerKey?: @@ -34,54 +34,28 @@ export interface Certificates { passphrase?: string; } | string; -} - -export interface FactoryOptions { - model: BundleUnit | string; - certificates: Certificates; - overrides?: OverridesSupportedOptions; -} - -export interface BundleUnit { - [key: string]: Buffer; -} - -export interface PartitionedBundle { - bundle: BundleUnit; - l10nBundle: { - [key: string]: BundleUnit; - }; -} +}*/ export interface CertificatesSchema { - wwdr: string; - signerCert: string; - signerKey: string; + wwdr: string | Buffer; + signerCert: string | Buffer; + signerKey: string | Buffer; + signerKeyPassphrase?: string; } export const CertificatesSchema = Joi.object() .keys({ wwdr: Joi.alternatives(Joi.binary(), Joi.string()).required(), signerCert: Joi.alternatives(Joi.binary(), Joi.string()).required(), - signerKey: Joi.alternatives() - .try( - Joi.object().keys({ - keyFile: Joi.alternatives( - Joi.binary(), - Joi.string(), - ).required(), - passphrase: Joi.string().required(), - }), - Joi.alternatives(Joi.binary(), Joi.string()), - ) - .required(), + signerKey: Joi.alternatives(Joi.binary(), Joi.string()).required(), + signerKeyPassphrase: Joi.string(), }) .required(); export interface Template { model: string; certificates: CertificatesSchema; - overrides?: OverridesSupportedOptions; + overrides?: OverridablePassProps; } export const Template = Joi.object