mirror of
https://github.com/musix-org/musix-oss
synced 2025-06-17 20:15:59 +00:00
Modules
This commit is contained in:
8
node_modules/google-p12-pem/build/src/bin/gp12-pem.d.ts
generated
vendored
Normal file
8
node_modules/google-p12-pem/build/src/bin/gp12-pem.d.ts
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Copyright 2018 Google LLC
|
||||
*
|
||||
* Distributed under MIT license.
|
||||
* See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
||||
*/
|
||||
export {};
|
26
node_modules/google-p12-pem/build/src/bin/gp12-pem.js
generated
vendored
Normal file
26
node_modules/google-p12-pem/build/src/bin/gp12-pem.js
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env node
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2018 Google LLC
|
||||
*
|
||||
* Distributed under MIT license.
|
||||
* See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const gp12 = require("../index");
|
||||
const argv = process.argv;
|
||||
const p12Path = argv[2];
|
||||
if (!p12Path) {
|
||||
console.error('Please specify a *.p12 file to convert.');
|
||||
process.exit(1);
|
||||
}
|
||||
gp12.getPem(p12Path, (err, pem) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
process.exit(1);
|
||||
}
|
||||
else {
|
||||
console.log(pem);
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=gp12-pem.js.map
|
15
node_modules/google-p12-pem/build/src/index.d.ts
generated
vendored
Normal file
15
node_modules/google-p12-pem/build/src/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Copyright 2018 Google LLC
|
||||
*
|
||||
* Distributed under MIT license.
|
||||
* See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
||||
*/
|
||||
/**
|
||||
* Convert a .p12 file to .pem string
|
||||
* @param filename The .p12 key filename.
|
||||
* @param callback The callback function.
|
||||
* @return A promise that resolves with the .pem private key
|
||||
* if no callback provided.
|
||||
*/
|
||||
export declare function getPem(filename: string): Promise<string>;
|
||||
export declare function getPem(filename: string, callback: (err: Error | null, pem: string | null) => void): void;
|
48
node_modules/google-p12-pem/build/src/index.js
generated
vendored
Normal file
48
node_modules/google-p12-pem/build/src/index.js
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2018 Google LLC
|
||||
*
|
||||
* Distributed under MIT license.
|
||||
* See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const fs = require("fs");
|
||||
const forge = require("node-forge");
|
||||
const util_1 = require("util");
|
||||
const readFile = util_1.promisify(fs.readFile);
|
||||
function getPem(filename, callback) {
|
||||
if (callback) {
|
||||
getPemAsync(filename)
|
||||
.then(pem => callback(null, pem))
|
||||
.catch(err => callback(err, null));
|
||||
}
|
||||
else {
|
||||
return getPemAsync(filename);
|
||||
}
|
||||
}
|
||||
exports.getPem = getPem;
|
||||
function getPemAsync(filename) {
|
||||
return readFile(filename, { encoding: 'base64' }).then(keyp12 => {
|
||||
return convertToPem(keyp12);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Converts a P12 in base64 encoding to a pem.
|
||||
* @param p12base64 String containing base64 encoded p12.
|
||||
* @returns a string containing the pem.
|
||||
*/
|
||||
function convertToPem(p12base64) {
|
||||
const p12Der = forge.util.decode64(p12base64);
|
||||
const p12Asn1 = forge.asn1.fromDer(p12Der);
|
||||
const p12 = forge.pkcs12.pkcs12FromAsn1(p12Asn1, 'notasecret');
|
||||
const bags = p12.getBags({ friendlyName: 'privatekey' });
|
||||
if (bags.friendlyName) {
|
||||
const privateKey = bags.friendlyName[0].key;
|
||||
const pem = forge.pki.privateKeyToPem(privateKey);
|
||||
return pem.replace(/\r\n/g, '\n');
|
||||
}
|
||||
else {
|
||||
throw new Error('Unable to get friendly name.');
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=index.js.map
|
Reference in New Issue
Block a user