mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 21:25:26 +00:00
Reverted parsePEM from utils to pass.js
This commit is contained in:
21
src/pass.js
21
src/pass.js
@@ -17,7 +17,7 @@ const FieldsArray = require("./fieldsArray");
|
||||
const {
|
||||
assignLength, generateStringFile,
|
||||
removeHidden, dateToW3CString,
|
||||
isValidRGB, parsePEM
|
||||
isValidRGB
|
||||
} = require("./utils");
|
||||
|
||||
const readdir = promisify(fs.readdir);
|
||||
@@ -218,6 +218,8 @@ class Pass {
|
||||
// No model available at this path - renaming the error
|
||||
throw new Error(formatMessage("MODEL_NOT_FOUND", this.model));
|
||||
}
|
||||
|
||||
throw new Error(err);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -769,6 +771,23 @@ function readCertificates(certificates) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the PEM-formatted passed text (certificates)
|
||||
*
|
||||
* @function parsePEM
|
||||
* @params {String} element - Text content of .pem files
|
||||
* @params {String=} passphrase - passphrase for the key
|
||||
* @returns {Object} The parsed certificate or key in node forge format
|
||||
*/
|
||||
|
||||
function parsePEM(pemName, element, passphrase) {
|
||||
if (pemName === "signerKey" && passphrase) {
|
||||
return forge.pki.decryptRsaPrivateKey(element, String(passphrase));
|
||||
} else {
|
||||
return forge.pki.certificateFromPem(element);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatically generates barcodes for all the types given common info
|
||||
*
|
||||
|
||||
20
src/utils.js
20
src/utils.js
@@ -1,23 +1,6 @@
|
||||
const moment = require("moment");
|
||||
const { EOL } = require("os");
|
||||
|
||||
/**
|
||||
* Parses the PEM-formatted passed text (certificates)
|
||||
*
|
||||
* @function parsePEM
|
||||
* @params {String} element - Text content of .pem files
|
||||
* @params {String=} passphrase - passphrase for the key
|
||||
* @returns {Object} The parsed certificate or key in node forge format
|
||||
*/
|
||||
|
||||
function parsePEM(pemName, element, passphrase) {
|
||||
if (pemName === "signerKey" && passphrase) {
|
||||
return forge.pki.decryptRsaPrivateKey(element, String(passphrase));
|
||||
} else {
|
||||
return forge.pki.certificateFromPem(element);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if an rgb value is compliant with CSS-like syntax
|
||||
*
|
||||
@@ -114,6 +97,5 @@ module.exports = {
|
||||
generateStringFile,
|
||||
removeHidden,
|
||||
dateToW3CString,
|
||||
isValidRGB,
|
||||
parsePEM
|
||||
isValidRGB
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user