New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

passkit-generator

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

passkit-generator - npm Package Compare versions

Comparing version 1.4.2 to 1.5.0

2

package.json
{
"name": "passkit-generator",
"version": "1.4.2",
"version": "1.5.0",
"description": "The easiest way to generate custom Apple Wallet passes in Node.js",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -10,2 +10,3 @@ const fs = require("fs");

const got = require("got");
const barcodeDebug = debug("passkit:barcode");

@@ -54,3 +55,4 @@ const genericDebug = debug("passkit:generic");

return this._parseCertificates(this.Certificates._raw)
return readCertificates(this.Certificates)
.then((certs) => Object.assign(this.Certificates, certs))
.then(() => readdir(this.model))

@@ -690,47 +692,2 @@ .catch((err) => {

/**
* Validates the contents of the passed options and handle them
*
* @method _parseSettings
* @params {Object} options - the options passed to be parsed
* @returns {Object} - model path and filtered options
*/
_parseCertificates(certificates) {
if (this.Certificates.wwdr && this.Certificates.signerCert && typeof this.Certificates.signerKey === "object") {
return Promise.resolve();
}
let optCertsNames = Object.keys(this.Certificates._raw);
let certPaths = optCertsNames.map((val) => {
const cert = this.Certificates._raw[val];
const filePath = !(cert instanceof Object) ? cert : cert["keyFile"];
const resolvedPath = path.resolve(filePath);
return readFile(resolvedPath);
});
return Promise.all(certPaths)
.then(contents => {
contents.forEach((file, index) => {
let certName = optCertsNames[index];
let pem = parsePEM(certName, file, this.Certificates._raw[certName].passphrase);
if (!pem) {
throw new Error(formatError("INVALID_CERTS", optCertsNames[index]));
}
this.Certificates[certName] = pem;
});
}).catch(err => {
if (!err.path) {
// Catching error from '.then()';
console.log("Got an error");
throw err;
}
throw new Error(formatError("INVALID_CERT_PATH", path.parse(err.path).base));
});
}
set transitType(v) {

@@ -750,2 +707,51 @@ if (schema.isValid(v, "transitType")) {

/**
* Validates the contents of the passed options and handle them
*
* @function readCertificates
* @params {Object} certificates - certificates object with raw content and, optionally,
* the already parsed certificates
* @returns {Object} - parsed certificates to be pushed to Pass.Certificates.
*/
function readCertificates(certificates) {
if (certificates.wwdr && certificates.signerCert && typeof certificates.signerKey === "object") {
// Nothing must be added. Void object is returned.
return Promise.resolve({});
}
const raw = certificates._raw;
const optCertsNames = Object.keys(raw);
const certPaths = optCertsNames.map((val) => {
const cert = raw[val];
const filePath = !(cert instanceof Object) ? cert : cert["keyFile"];
const resolvedPath = path.resolve(filePath);
return readFile(resolvedPath);
});
return Promise.all(certPaths)
.then(contents => {
return Object.assign(
...contents.map((file, index) => {
const certName = optCertsNames[index];
const pem = parsePEM(certName, file, raw[certName].passphrase);
if (!pem) {
throw new Error(formatError("INVALID_CERTS", certName));
}
return { [certName]: pem };
}, [])
);
}).catch(err => {
if (!err.path) {
// Catching error from '.then()';
throw err;
}
throw new Error(formatError("INVALID_CERT_PATH", path.parse(err.path).base));
});
}
/**
* Parses the PEM-formatted passed text (certificates)

@@ -752,0 +758,0 @@ *

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc