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

macos-export-certificate-and-key

Package Overview
Dependencies
Maintainers
34
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

macos-export-certificate-and-key - npm Package Compare versions

Comparing version 1.1.2 to 1.2.0

src/binding.cc

2

index.d.ts

@@ -18,6 +18,8 @@ declare type LookupOptions = {

function exportCertificateAndPrivateKey(input: LookupOptions): PfxResult;
function exportCertificateAndPrivateKeyAsync(input: LookupOptions): Promise<PfxResult>;
function exportSystemCertificates(input: StoreOptions): string[];
function exportSystemCertificatesAsync(input: StoreOptions): Promise<string[]>;
}
export = exportCertificateAndPrivateKey;

40

index.js

@@ -1,9 +0,12 @@

const { exportCertificateAndKey, exportAllCertificates } = require('bindings')('macos_export_certificate_and_key');
const {
exportCertificateAndKey,
exportCertificateAndKeyAsync,
exportAllCertificates,
exportAllCertificatesAsync
} = require('bindings')('macos_export_certificate_and_key');
const { randomBytes } = require('crypto');
const util = require('util');
const { promisify } = util;
function exportCertificateAndPrivateKey({
subject,
thumbprint
}) {
function validateSubjectAndThumbprint(subject, thumbprint) {
if (!subject && !thumbprint) {

@@ -21,5 +24,24 @@ throw new Error('Need to specify either `subject` or `thumbprint`');

}
}
const passphrase = randomBytes(12).toString('hex');
const pfx = exportCertificateAndKey(
function exportCertificateAndPrivateKey({
subject,
thumbprint
}) {
validateSubjectAndThumbprint(subject, thumbprint);
const passphrase = randomBytes(12).toString('hex');
const pfx = exportCertificateAndKey(
subject ? { subject } : { thumbprint },
passphrase
);
return { passphrase, pfx };
};
async function exportCertificateAndPrivateKeyAsync({
subject,
thumbprint
}) {
validateSubjectAndThumbprint(subject, thumbprint);
const passphrase = (await promisify(randomBytes)(12)).toString('hex');
const pfx = await promisify(exportCertificateAndKeyAsync)(
subject ? { subject } : { thumbprint },

@@ -33,2 +55,4 @@ passphrase

module.exports.exportCertificateAndPrivateKey = exportCertificateAndPrivateKey;
module.exports.exportSystemCertificates = exportAllCertificates;
module.exports.exportCertificateAndPrivateKeyAsync = exportCertificateAndPrivateKeyAsync;
module.exports.exportSystemCertificates = exportAllCertificates;
module.exports.exportSystemCertificatesAsync = promisify(exportAllCertificatesAsync);

@@ -13,3 +13,3 @@ {

"name": "macos-export-certificate-and-key",
"version": "1.1.2",
"version": "1.2.0",
"description": "Export a certificate and its corresponding private key from the MacOS default keychain",

@@ -30,3 +30,3 @@ "repository": {

"files": [
"binding.cc",
"src",
"binding.gyp",

@@ -33,0 +33,0 @@ "index.d.ts",

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