Socket
Socket
Sign inDemoInstall

@probot/get-private-key

Package Overview
Dependencies
2
Maintainers
7
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.0 to 1.1.1

25

dist-node/index.js

@@ -13,2 +13,4 @@ 'use strict';

const begin = "-----BEGIN RSA PRIVATE KEY-----";
const end = "-----END RSA PRIVATE KEY-----";
function getPrivateKey(options = {}) {

@@ -30,8 +32,14 @@ const env = options.env || process.env;

const begin = "-----BEGIN RSA PRIVATE KEY-----";
const end = "-----END RSA PRIVATE KEY-----";
if (privateKey.includes(begin) && privateKey.includes(end)) {
// newlines are escaped
if (privateKey.indexOf("\\n") !== -1) {
privateKey = privateKey.replace(/\\n/g, "\n");
} // newlines are missing
if (privateKey.includes(begin) && privateKey.includes(end)) {
// Full key with new lines
return privateKey.replace(/\\n/g, "\n");
if (privateKey.indexOf("\n") === -1) {
privateKey = addNewlines(privateKey);
}
return privateKey;
}

@@ -66,2 +74,9 @@

}
function addNewlines(privateKey) {
const middleLength = privateKey.length - begin.length - end.length - 2;
const middle = privateKey.substr(begin.length + 1, middleLength);
return `${begin}\n${middle.trim().replace(/\s+/g, "\n")}\n${end}`;
}
getPrivateKey.VERSION = VERSION;

@@ -68,0 +83,0 @@

@@ -5,2 +5,4 @@ import { resolve } from "path";

import { VERSION } from "./version";
const begin = "-----BEGIN RSA PRIVATE KEY-----";
const end = "-----END RSA PRIVATE KEY-----";
export function getPrivateKey(options = {}) {

@@ -18,7 +20,12 @@ const env = options.env || process.env;

}
const begin = "-----BEGIN RSA PRIVATE KEY-----";
const end = "-----END RSA PRIVATE KEY-----";
if (privateKey.includes(begin) && privateKey.includes(end)) {
// Full key with new lines
return privateKey.replace(/\\n/g, "\n");
// newlines are escaped
if (privateKey.indexOf("\\n") !== -1) {
privateKey = privateKey.replace(/\\n/g, "\n");
}
// newlines are missing
if (privateKey.indexOf("\n") === -1) {
privateKey = addNewlines(privateKey);
}
return privateKey;
}

@@ -46,2 +53,7 @@ throw new Error(`[@probot/get-private-key] The contents of "env.PRIVATE_KEY" could not be validated. Please check to ensure you have copied the contents of the .pem file correctly.`);

}
function addNewlines(privateKey) {
const middleLength = privateKey.length - begin.length - end.length - 2;
const middle = privateKey.substr(begin.length + 1, middleLength);
return `${begin}\n${middle.trim().replace(/\s+/g, "\n")}\n${end}`;
}
getPrivateKey.VERSION = VERSION;

4

package.json
{
"name": "@probot/get-private-key",
"description": "Get private key from a path, environment variables, or a `*.pem` file in the current working directory",
"version": "1.1.0",
"version": "1.1.1",
"license": "ISC",

@@ -16,3 +16,3 @@ "files": [

],
"repository": "https://github.com/probot/get-private-key",
"repository": "github:probot/get-private-key",
"dependencies": {

@@ -19,0 +19,0 @@ "@types/is-base64": "^1.1.0",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc