macos-export-certificate-and-key
Advanced tools
Comparing version 1.1.2 to 1.2.0
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18009
8
71