Added certificates saving in constructor and parsing them when signature is being created; changed Manifest to be exported as a Buffer

This commit is contained in:
Alexander Cerutti
2021-10-03 18:14:10 +02:00
parent cd289ef164
commit e0d2db9fc4
4 changed files with 75 additions and 57 deletions

View File

@@ -6,6 +6,7 @@ export * from "./NFC";
export * from "./SemanticTags";
export * from "./PassFields";
export * from "./Personalize";
export * from "./Certificates";
import Joi from "joi";
import debug from "debug";
@@ -18,6 +19,7 @@ import { Field } from "./PassFieldContent";
import { PassFields, TransitType } from "./PassFields";
import { Personalization } from "./Personalize";
import { Semantics } from "./SemanticTags";
import { CertificatesSchema } from "./Certificates";
const schemaDebug = debug("Schema");
@@ -25,33 +27,6 @@ export interface FileBuffers {
[key: string]: Buffer;
}
/* export interface Certificates {
wwdr?: string;
signerCert?: string;
signerKey?:
| {
keyFile: string;
passphrase?: string;
}
| string;
}*/
export interface CertificatesSchema {
wwdr: string | Buffer;
signerCert: string | Buffer;
signerKey: string | Buffer;
signerKeyPassphrase?: string;
}
export const CertificatesSchema = Joi.object<CertificatesSchema>()
.keys({
wwdr: Joi.alternatives(Joi.binary(), Joi.string()).required(),
signerCert: Joi.alternatives(Joi.binary(), Joi.string()).required(),
signerKey: Joi.alternatives(Joi.binary(), Joi.string()).required(),
signerKeyPassphrase: Joi.string(),
})
.required();
export interface PassProps {
serialNumber?: string;
description?: string;
@@ -206,12 +181,6 @@ type AvailableSchemas =
| typeof CertificatesSchema
| typeof OverridablePassProps;
export type ArrayPassSchema = Beacon | Location | Barcode;
/* function resolveSchemaName(name: Schema) {
return schemas[name] || undefined;
}
*/
/**
* Checks if the passed options are compliant with the indicated schema
* @param {any} opts - options to be checks