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

@evervault/sdk

Package Overview
Dependencies
Maintainers
5
Versions
105
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@evervault/sdk - npm Package Compare versions

Comparing version 3.5.0 to 3.6.0

73

lib/core/crypto.js

@@ -36,3 +36,2 @@ const crypto = require('crypto');

};
const _traverseObject = async (

@@ -148,2 +147,12 @@ curve,

const _evEncryptedFileVersion = () => {
if (config.ecdhCurve == 'secp256k1') {
return Buffer.from([0x00]);
} else if (config.ecdhCurve === 'prime256v1') {
return Buffer.from([0x01]);
} else {
throw new Error('Invalid curve specified');
}
};
const _format = (

@@ -158,6 +167,56 @@ datatype = 'string',

}:${base64RemovePadding(keyIv)}:${base64RemovePadding(
ecdhPublicKey
ecdhPublicKey.toString('base64')
)}:${base64RemovePadding(encryptedData)}:$`;
};
const _encryptFile = async (
curve,
ecdhTeamKey,
ecdhPublicKey,
derivedSecret,
data
) => {
const keyIv = await generateBytes(config.ivLength);
const cipher = crypto.createCipheriv(
config.cipherAlgorithm,
derivedSecret,
keyIv,
{
authTagLength: config.authTagLength,
}
);
if (curve === PRIME256V1) {
cipher.setAAD(Buffer.from(ecdhTeamKey, 'base64'));
}
const encryptedBuffer = Buffer.concat([
cipher.update(data),
cipher.final(),
cipher.getAuthTag(),
]);
return _formatFile(keyIv, ecdhPublicKey, encryptedBuffer);
};
const _formatFile = async (keyIv, ecdhPublicKey, encryptedData) => {
const evEncryptedFileIdentifier = Buffer.from([
0x25, 0x45, 0x56, 0x45, 0x4e, 0x43,
]);
const versionNumber = _evEncryptedFileVersion();
const offsetToData = Buffer.from([0x37, 0x00]);
const flags = Buffer.from([0x00]);
return Buffer.concat([
evEncryptedFileIdentifier,
versionNumber,
offsetToData,
Buffer.from(ecdhPublicKey),
Buffer.from(keyIv),
flags,
Buffer.from(encryptedData),
]);
};
const encrypt = async (

@@ -175,3 +234,11 @@ curve,

if (Datatypes.isObjectStrict(data)) {
if (Datatypes.isBuffer(data)) {
return await _encryptFile(
curve,
ecdhTeamKey,
ecdhPublicKey,
derivedSecret,
data
);
} else if (Datatypes.isObjectStrict(data)) {
return await _encryptObject(

@@ -178,0 +245,0 @@ curve,

2

lib/index.js

@@ -204,3 +204,3 @@ const crypto = require('crypto');

'_ecdhPublicKey',
this._ecdh.getPublicKey(null, 'compressed').toString('base64')
this._ecdh.getPublicKey(null, 'compressed')
);

@@ -207,0 +207,0 @@ if (this.curve === EvervaultClient.CURVES.PRIME256V1) {

{
"name": "@evervault/sdk",
"version": "3.5.0",
"version": "3.6.0",
"description": "Node.js SDK for Evervault",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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