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

@neoskop/ethereal-secrets-client

Package Overview
Dependencies
Maintainers
2
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@neoskop/ethereal-secrets-client - npm Package Compare versions

Comparing version 1.3.1 to 1.4.0

71

dist/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var sjcl = require("sjcl");
var sjcl_1 = require("sjcl");
var request = require("superagent");
var crypto = require("crypto");
var superagent_1 = require("superagent");
var EtherealSecretsClient = /** @class */ (function () {
function EtherealSecretsClient(config) {
this._storage = typeof config.storage === 'undefined' || config.storage === null ? sessionStorage : config.storage;
this._cacheKey = typeof config.cacheKey === 'undefined' || config.cacheKey === null ? false : config.cacheKey;
this._endpoint = config.endpoint.endsWith('/') ? config.endpoint : config.endpoint + '/';
this._storage = (config === null || config === void 0 ? void 0 : config.storage) || sessionStorage;
this._cacheKey = (config === null || config === void 0 ? void 0 : config.cacheKey) || false;
this._endpoint = config.endpoint.endsWith('/')
? config.endpoint
: config.endpoint + '/';
if (typeof window !== 'undefined') {
this._agent = request;
}
else if (this._agent == null) {
this._agent = request.agent();
else if (this._agent === null) {
this._agent = superagent_1.agent();
}

@@ -42,13 +44,13 @@ }

.get(this._endpoint + keys_1.remoteKey)
.accept("application/json")
.accept('application/json')
.then(function (res) {
if (!res.body.hasOwnProperty('data')) {
if (!res.body.data) {
return Promise.reject('The server did not answer with any data');
}
try {
var clearText = sjcl.decrypt(keys_1.localKey, res.body.data);
var clearText = sjcl_1.decrypt(keys_1.localKey, res.body.data);
var result = {
clearText: clearText
clearText: clearText,
};
if (res.body.hasOwnProperty('expiryDate')) {
if (res.body.expiryDate) {
result.expiryDate = new Date(res.body.expiryDate);

@@ -72,3 +74,3 @@ }

.del(this._endpoint + keys.remoteKey)
.accept("application/json")
.accept('application/json')
.then(function () {

@@ -84,7 +86,7 @@ return Promise.resolve();

var secret = this.generateLocalSecret();
var cipherText = sjcl.encrypt(secret, clearText);
var cipherText = sjcl_1.encrypt(secret, clearText);
return this._agent
.post(this._endpoint)
.send({ data: cipherText.toString() })
.accept("application/json")
.accept('application/json')
.then(function (res) {

@@ -95,3 +97,3 @@ if (!res.body.hasOwnProperty('key')) {

var result = {
fragmentIdentifier: res.body.key + ';' + secret
fragmentIdentifier: res.body.key + ';' + secret,
};

@@ -102,3 +104,4 @@ if (res.body.hasOwnProperty('expiryDate')) {

return Promise.resolve(result);
}).catch(function (err) {
})
.catch(function (err) {
return Promise.reject(err.message);

@@ -114,3 +117,3 @@ });

remoteKey: fragmentParts[0],
localKey: fragmentParts[1]
localKey: fragmentParts[1],
};

@@ -120,17 +123,14 @@ };

var randomValues = new Uint8Array(32);
if (typeof window !== 'undefined') {
if ('crypto' in window) {
window.crypto.getRandomValues(randomValues);
}
else if ('msCrypto' in window) {
window.msCrypto.getRandomValues(randomValues);
}
else {
throw new Error('No secure source of randomness');
}
if (window === null || window === void 0 ? void 0 : window.crypto) {
window.crypto.getRandomValues(randomValues);
}
else if (window && window['msCrypto']) {
window['msCrypto'].getRandomValues(randomValues);
}
else {
crypto.randomFillSync(randomValues);
throw new Error('No secure source of randomness');
}
return Buffer.from(randomValues.buffer).toString('hex');
// Workaround, since Buffer is no global JS element
return randomValues.reduce(function (prev, i) { return prev + ((i < 16 ? '0' : '') + i.toString(16)); }, '');
// return Buffer.from(randomValues.buffer).toString('hex');
};

@@ -140,3 +140,3 @@ EtherealSecretsClient.prototype.decryptCipherText = function (cipherText) {

try {
var clearText = sjcl.decrypt(secret, cipherText);
var clearText = sjcl_1.decrypt(secret, cipherText);
return Promise.resolve(clearText);

@@ -151,3 +151,3 @@ }

return this.retrieveRemoteSecret().then(function (secret) {
var cipherText = sjcl.encrypt(secret, value);
var cipherText = sjcl_1.encrypt(secret, value);
return Promise.resolve(cipherText.toString());

@@ -164,5 +164,5 @@ });

.withCredentials()
.accept("application/json")
.accept('application/json')
.then(function (res) {
if (!res.body.hasOwnProperty('key')) {
if (!res.body.key) {
return Promise.reject('The server did not answer with a key');

@@ -174,3 +174,4 @@ }

return Promise.resolve(res.body.key);
}).catch(function (err) {
})
.catch(function (err) {
return Promise.reject(err.message);

@@ -177,0 +178,0 @@ });

{
"name": "@neoskop/ethereal-secrets-client",
"version": "1.3.1",
"version": "1.4.0",
"main": "dist/index.js",

@@ -19,5 +19,8 @@ "typings": "dist/index.d.ts",

"devDependencies": {
"@types/bluebird": "3.5.30",
"@types/chai": "4.2.11",
"@types/chai-as-promised": "7.1.2",
"@types/mocha": "7.0.2",
"@types/sjcl": "1.0.30",
"@types/superagent": "4.1.7",
"chai": "4.2.0",

@@ -29,2 +32,3 @@ "chai-as-promised": "7.1.1",

"nyc": "15.0.1",
"prettier": "2.4.1",
"rimraf": "3.0.2",

@@ -35,5 +39,2 @@ "ts-node": "8.8.2",

"dependencies": {
"@types/bluebird": "3.5.30",
"@types/sjcl": "1.0.29",
"@types/superagent": "4.1.7",
"bluebird": "3.7.2",

@@ -40,0 +41,0 @@ "sjcl": "1.0.8",

Sorry, the diff of this file is not supported yet

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