New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

@codefresh-io/service-base

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codefresh-io/service-base - npm Package Compare versions

Comparing version

to
4.0.6

@@ -6,3 +6,3 @@

const uuid = require('node-uuid');
const cryptoAsync = require('@ronomon/crypto-async');
const crypto = require('crypto');

@@ -16,2 +16,15 @@ const config = require('../config');

async function cipher(algorithm, encrypt, key, iv, data) {
if (encrypt) {
const cipherObject = crypto.createCipheriv(algorithm, key, iv);
let ciphertext = cipherObject.update(data, 'utf8', 'hex');
ciphertext += cipherObject.final('hex');
return ciphertext;
}
const decipher = crypto.createDecipheriv(algorithm, key, iv);
let plaintext = decipher.update(data, 'hex', 'utf8');
plaintext += decipher.final('utf8');
return plaintext;
}
const Safe = function (safeModel) { // eslint-disable-line

@@ -66,13 +79,10 @@ this.safeModel = safeModel;

const encrypt = 0; // 0 = Decrypt
cryptoAsync.cipher(
ALGORITHM, encrypt, key, iv, Buffer.from(ciphertext.slice(prefix.length), 'hex'),
(error, plaintext) => {
if (error) {
deferred.reject(error);
return;
}
const ret = plaintext.toString();
deferred.resolve(shouldParse ? JSON.parse(ret) : ret);
},
);
cipher(ALGORITHM, encrypt, key, iv, Buffer.from(ciphertext.slice(prefix.length), 'hex')).then((plaintext) => {
const ret = plaintext.toString();
deferred.resolve(shouldParse ? JSON.parse(ret) : ret);
}).catch((error) => {
if (error) {
deferred.reject(error);
}
});
return deferred.promise;

@@ -99,12 +109,9 @@ };

const encrypt = 1; // 1 = Encrypt
cryptoAsync.cipher(
ALGORITHM, encrypt, key, iv, Buffer.from(textToEncrypt),
(error, ciphertext) => {
if (error) {
deferred.reject(error);
return;
}
deferred.resolve(`${prefix}${ciphertext.toString('hex')}`);
},
);
cipher(ALGORITHM, encrypt, key, iv, Buffer.from(textToEncrypt)).then((ciphertext) => {
deferred.resolve(`${prefix}${ciphertext.toString('hex')}`);
}).catch((error) => {
if (error) {
deferred.reject(error);
}
});
return deferred.promise;

@@ -111,0 +118,0 @@ };

{
"name": "@codefresh-io/service-base",
"version": "4.0.5",
"version": "4.0.6",
"main": "index.js",

@@ -33,3 +33,3 @@ "description": "",

"@codefresh-io/authenticated-entity": "^2.17.1",
"@codefresh-io/cf-monitor": "^0.0.27",
"@codefresh-io/cf-monitor": "^0.0.29",
"@codefresh-io/cf-openapi": "^0.7.20",

@@ -39,3 +39,2 @@ "@codefresh-io/eventbus": "^2.0.0",

"@codefresh-io/internal-service-config": "^1.0.3",
"@ronomon/crypto-async": "^5.0.1",
"@wegolook/joi-objectid": "^2.4.0",

@@ -42,0 +41,0 @@ "ajv": "^6.10.0",

Sorry, the diff of this file is not supported yet