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.5.3 to 1.5.4

CHANGELOG.md

2

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

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

@@ -22,2 +22,4 @@ const fs = require("fs");

const noop = () => { };
class Pass {

@@ -291,5 +293,3 @@ constructor(options) {

if (!type || !data || !types.includes(type)) {
return Object.assign({
length: 0
}, this);
return assignLength(0, this);
}

@@ -306,5 +306,3 @@

return Object.assign({
length: valid.length
}, this);
return assignLength(valid.length, this);
}

@@ -321,5 +319,3 @@

return Object.assign({
length: Number(!cond)
}, this);
return assignLength(Number(!cond), this);
} else if (type === "relevantDate") {

@@ -334,5 +330,3 @@ let dateParse = dateToW3CString(data, relevanceDateFormat);

return Object.assign({
length: Number(!!dateParse)
}, this);
return assignLength(Number(!!dateParse), this);
}

@@ -352,7 +346,6 @@ }

if (!data) {
return Object.assign({
length: 0,
autocomplete: () => { },
backward: () => { }
}, this);
return assignLength(0, this, {
autocomplete: noop,
backward: noop,
});
}

@@ -366,7 +359,9 @@

return Object.assign({
length: 4,
autocomplete: () => { },
// I bind "this" to get a clean context (without these two methods)
// when returning from the methods
return assignLength(4, this, {
autocomplete: noop,
backward: this.__barcodeChooseBackward.bind(this)
}, this);
});
}

@@ -392,9 +387,9 @@

// I bind "this" to get a clean context (without these two methods) when returning from the methods
// I bind "this" to get a clean context (without these two methods)
// when returning from the methods
return Object.assign({
length: valid.length,
return assignLength(valid.length, this, {
autocomplete: this.__barcodeAutocomplete.bind(this),
backward: this.__barcodeChooseBackward.bind(this)
}, this);
});
}

@@ -441,6 +436,8 @@

if (props.length === 4 || !props.length) {
return Object.assign({
length: 0,
// I bind "this" to get a clean context (without these two methods)
// when returning from the methods
return assignLength(0, this, {
backward: this.__barcodeChooseBackward.bind(this)
}, this);
});
}

@@ -450,6 +447,8 @@

return Object.assign({
length: 4 - props.length,
// I bind "this" to get a clean context (without these two methods)
// when returning from the methods
return assignLength(4 - props.length, this, {
backward: this.__barcodeChooseBackward.bind(this)
}, this);
});
}

@@ -542,12 +541,9 @@

let passFile = JSON.parse(passBuffer.toString("utf8"));
let index = passTypes.findIndex(passType => passFile.hasOwnProperty(passType));
this.type = passTypes.find(type => passFile.hasOwnProperty(type));
if (index == -1) {
if (!this.type) {
return false;
}
let type = passTypes[index];
this.type = type;
return schema.isValid(passFile[type], "passDict");
return schema.isValid(passFile[this.type], "passDict");
}

@@ -750,3 +746,3 @@

return { [certName]: pem };
}, [])
})
);

@@ -861,2 +857,12 @@ }).catch(err => {

/**
* Creates a new object with custom length property
* @param {number} value - the length
* @param {Array<Object<string, any>>} source - the main sources of properties
*/
function assignLength(value, ...sources) {
return Object.assign({ length: value }, ...sources);
}
module.exports = { Pass };

@@ -109,7 +109,14 @@ const Joi = require("joi");

let resolveSchemaName = (name) => {
function resolveSchemaName(name) {
return schemas[name] || "";
};
}
let isValid = (opts, schemaName) => {
/**
* Checks if the passed options are compliant with the indicated schema
* @param {any} opts - options to be checks
* @param {string} schemaName - the indicated schema (will be converted)
* @returns {boolean} - result of the check
*/
function isValid(opts, schemaName) {
let resolvedSchema = resolveSchemaName(schemaName);

@@ -129,21 +136,32 @@

return !validation.error;
};
}
let filter = (opts, schemaName) => {
let isObject = opts instanceof Object;
let list = isObject ? Object.keys(opts) : opts;
/**
* Keeps only the opts elements that are compliant with the selected schema.
* @param {object} opts
* @param {string} schemaName - the selected schema.
*/
return list.reduce((acc, current, index) => {
let ref = isObject ? current : index;
let check = isObject ? { [current]: opts[current] } : [opts[index]];
function filter(opts, schemaName) {
let list = Object.keys(opts);
return list.reduce((acc, current) => {
let check = { [current]: opts[current] };
if (isValid(check, schemaName)) {
acc[ref] = opts[ref];
acc[current] = opts[current];
}
return acc;
}, isObject ? {} : []);
}, {});
};
let getValidated = (opts, schemaName) => {
/**
* Executes the validation in verbose mode, exposing the value or
* @param {object} opts - to be validated
* @param {*} schemaName - selected schema
* @returns {any} false or the returned value
*/
function getValidated(opts, schemaName) {
let resolvedSchema = resolveSchemaName(schemaName);

@@ -150,0 +168,0 @@ let validation = Joi.validate(opts, resolvedSchema);

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