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

@postalsys/vmc

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@postalsys/vmc - npm Package Compare versions

Comparing version

to
1.0.4

49

lib/cert-info.js
'use strict';
const { getDateString } = require('./tools');
const { getDateString, parseSubject } = require('./tools');
const oids = {
'1.3.6.1.4.1.53087.1.5': 'legalEntityIdentifier',
'1.3.6.1.4.1.53087.1.3': 'trademarkCountryOrRegionName',
'1.3.6.1.4.1.53087.1.2': 'trademarkOfficeName',
'1.3.6.1.4.1.53087.1.4': 'trademarkRegistration',
'1.3.6.1.4.1.53087.1.6': 'wordMark',
CN: 'commonName',
O: 'organizationName',
OU: 'organizationalUnitName',
L: 'localityName',
ST: 'stateOrProvinceName',
S: 'stateOrProvinceName',
C: 'countryName',
jurisdictionC: 'jurisdictionCountryName',
jurisdictionST: 'jurisdictionStateOrProvinceName',
jurisdictionL: 'jurisdictionLocalityName'
};
function parseSubject(subject) {
return Object.fromEntries(
(subject || '')
.split(/\r?\n/)
.map(line => {
let separatorPos = line.indexOf('=');
if (separatorPos < 0) {
return false;
}
let key = line.substring(0, separatorPos);
key = oids[key] || key;
let value = line.substring(separatorPos + 1);
value = value.replace(/\\,/g, ',');
if (value.charAt(0) === '"') {
try {
value = JSON.parse(value);
} catch (err) {
// ignore
}
}
return [key, value];
})
.filter(entry => entry)
);
}
function certInfo(cert) {

@@ -59,4 +14,4 @@ let subject = parseSubject(cert.subject);

return {
subject,
subjectAltName,
subject,
fingerprint: cert.fingerprint,

@@ -63,0 +18,0 @@ serialNumber: cert.serialNumber,

49

lib/tools.js

@@ -6,2 +6,20 @@ /* eslint no-control-regex: 0 */

const oids = {
'1.3.6.1.4.1.53087.1.5': 'legalEntityIdentifier',
'1.3.6.1.4.1.53087.1.3': 'trademarkCountryOrRegionName',
'1.3.6.1.4.1.53087.1.2': 'trademarkOfficeName',
'1.3.6.1.4.1.53087.1.4': 'trademarkRegistration',
'1.3.6.1.4.1.53087.1.6': 'wordMark',
CN: 'commonName',
O: 'organizationName',
OU: 'organizationalUnitName',
L: 'localityName',
ST: 'stateOrProvinceName',
S: 'stateOrProvinceName',
C: 'countryName',
jurisdictionC: 'jurisdictionCountryName',
jurisdictionST: 'jurisdictionStateOrProvinceName',
jurisdictionL: 'jurisdictionLocalityName'
};
function parsePemBundle(bundle) {

@@ -33,3 +51,3 @@ bundle = (bundle || '').toString().split(/\r?\n/).join('\x00');

if (typeof date === 'string') {
let dateObject = new Date();
let dateObject = new Date(date);
if (dateObject.toString() !== 'Invalid Date') {

@@ -49,2 +67,29 @@ return dateObject.toISOString();

module.exports = { parsePemBundle, getCerts, getDateString };
function parseSubject(subject) {
return Object.fromEntries(
(subject || '')
.split(/\r?\n/)
.map(line => {
let separatorPos = line.indexOf('=');
if (separatorPos < 0) {
return false;
}
let key = line.substring(0, separatorPos);
key = oids[key] || key;
let value = line.substring(separatorPos + 1);
value = value.replace(/\\,/g, ',');
if (value.charAt(0) === '"') {
try {
value = JSON.parse(value);
} catch (err) {
// ignore
}
}
return [key, value];
})
.filter(entry => entry)
);
}
module.exports = { parsePemBundle, getCerts, getDateString, parseSubject };
'use strict';
const { getDateString } = require('./tools');
const { getDateString, parseSubject } = require('./tools');
function formatCertError(cert, message, code, meta) {
let error = new Error(message);
let subjectAltName = (cert.subjectAltName || '')
.split(/^DNS:|,\s*DNS:/g)
.map(subject => subject.trim())
.filter(subject => subject);
error.details = Object.assign({}, meta || {}, {
subject: cert.subject,
fingerprint: cert.fingerprint,
fingerprint235: cert.fingerprint256,
validFrom: getDateString(cert.validFrom),
validTo: getDateString(cert.validTo)
certificate: {
subject: parseSubject(cert.subject),
subjectAltName,
fingerprint: cert.fingerprint,
serialNumber: cert.serialNumber,
validFrom: getDateString(cert.validFrom),
validTo: getDateString(cert.validTo),
issuer: parseSubject(cert.issuer)
}
});

@@ -14,0 +23,0 @@ error.code = code;

{
"name": "@postalsys/vmc",
"version": "1.0.3",
"version": "1.0.4",
"description": "Parse VMC logo files",

@@ -5,0 +5,0 @@ "main": "lib/vmc.js",