Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@expo/pkcs12

Package Overview
Dependencies
Maintainers
24
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@expo/pkcs12 - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

4

build/index.d.ts

@@ -19,5 +19,9 @@ /// <reference types="node" />

export declare function getX509CertificateByFriendlyName(p12: forge.pkcs12.Pkcs12Pfx, friendlyName: string): forge.pki.Certificate | null;
export declare function getX509Asn1ByFriendlyName(p12: forge.pkcs12.Pkcs12Pfx, friendlyName: string): forge.asn1.Asn1 | null;
export declare function parsePKCS12(p12BufferOrBase64String: Buffer | string, maybePassword: string | null): forge.pkcs12.Pkcs12Pfx;
export declare function getAsn1Hash(asn1: forge.asn1.Asn1, { hashAlgorithm, }: {
hashAlgorithm?: string;
}): string;
export declare function getCertificateFingerprint(certificate: forge.pki.Certificate, { hashAlgorithm, }: {
hashAlgorithm?: string;
}): string;

51

build/index.js

@@ -26,7 +26,3 @@ "use strict";

}
const certificate = bags[0].cert;
if (!certificate) {
throw new Error('PKCS12: bag is not a certificate');
}
return certificate;
return getX509CertificateFromBag(bags[0]);
}

@@ -48,9 +44,34 @@ exports.getX509Certificate = getX509Certificate;

}
const certificate = bags[0].cert;
if (!certificate) {
return getX509CertificateFromBag(bags[0]);
}
exports.getX509CertificateByFriendlyName = getX509CertificateByFriendlyName;
function getX509CertificateFromBag(bag) {
const { cert, asn1 } = bag;
if (!cert && asn1) {
// if asn1 is present but certificate isnt, the certificate type was unknown
// github.com/digitalbazaar/forge/blob/1887cfce43a8f5ca9cb5c256168cf12ce1715ecf/lib/pkcs12.js#L703
throw new Error('PKCS12: unknown X.509 certificate type');
}
if (!cert) {
throw new Error('PKCS12: bag is not a certificate');
}
return certificate;
return cert;
}
exports.getX509CertificateByFriendlyName = getX509CertificateByFriendlyName;
function getX509Asn1ByFriendlyName(p12, friendlyName) {
const certBagType = node_forge_1.default.pki.oids.certBag;
// node-forge converts friendly names to lowercase, so we search by lowercase
const bags = p12.getBags({ friendlyName: friendlyName.toLowerCase(), bagType: certBagType })
.friendlyName;
if (!bags || bags.length === 0) {
return null;
}
const { cert, asn1 } = bags[0];
if (cert) {
return node_forge_1.default.pki.certificateToAsn1(cert);
}
// if asn1 is present but certificate isnt, the certificate type was unknown
// github.com/digitalbazaar/forge/blob/1887cfce43a8f5ca9cb5c256168cf12ce1715ecf/lib/pkcs12.js#L703
return asn1 !== null && asn1 !== void 0 ? asn1 : null;
}
exports.getX509Asn1ByFriendlyName = getX509Asn1ByFriendlyName;
function parsePKCS12(p12BufferOrBase64String, maybePassword) {

@@ -76,5 +97,4 @@ const base64EncodedP12 = Buffer.isBuffer(p12BufferOrBase64String)

}
function getCertificateFingerprint(certificate, { hashAlgorithm, }) {
const certAsn1 = node_forge_1.default.pki.certificateToAsn1(certificate);
const certDer = node_forge_1.default.asn1.toDer(certAsn1).getBytes(); // binary encoded string
function getAsn1Hash(asn1, { hashAlgorithm, }) {
const certDer = node_forge_1.default.asn1.toDer(asn1).getBytes(); // binary encoded string
return getHash(certDer, {

@@ -86,3 +106,10 @@ hashAlgorithm,

}
exports.getAsn1Hash = getAsn1Hash;
function getCertificateFingerprint(certificate, { hashAlgorithm, }) {
const certAsn1 = node_forge_1.default.pki.certificateToAsn1(certificate);
return getAsn1Hash(certAsn1, {
hashAlgorithm,
});
}
exports.getCertificateFingerprint = getCertificateFingerprint;
//# sourceMappingURL=index.js.map
{
"name": "@expo/pkcs12",
"version": "0.0.3",
"version": "0.0.4",
"description": "PKCS#12 Utilities for Node.js",

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

Sorry, the diff of this file is not supported yet

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