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

freedom-pgp-e2e

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

freedom-pgp-e2e - npm Package Compare versions

Comparing version 0.4.3 to 0.5.0

80

dist/e2e.js

@@ -9,2 +9,43 @@ /*globals freedom, console, e2e, exports, ArrayBuffer, Uint8Array, Uint16Array, DataView*/

if (typeof crypto === 'undefined') {
console.log("POLYFILLING CRYPTO RANDOM");
var rand = freedom['core.crypto'](),
buf,
offset = 0;
var refreshBuffer = function (size, callback) {
console.log('in rb');
rand.getRandomBytes(size).then(function (bytes) {
console.log('done refresh');
buf = new Uint8Array(bytes);
offset = 0;
return callback(0);
}, function (err) {
console.log('err!');
console.log(err);
return callback(-1, err);
});
}.bind(this);
crypto = {};
crypto.getRandomValues = function (buffer) {
console.log('trying to get randomness');
console.log(buffer);
console.log(buf);
console.log(offset);
if (buffer.buffer) {
buffer = buffer.buffer;
}
var size = buffer.byteLength,
view = new Uint8Array(buffer),
i;
if (offset + size > buf.length) {
throw new Error("Insufficient Randomness Allocated.");
}
for (i = 0; i < size; i += 1) {
view[i] = buf[offset + i];
}
offset += size;
};
}
/**

@@ -25,16 +66,26 @@ * Implementation of a crypto-pgp provider for freedom.js

mye2e.prototype.setup = function(passphrase, userid) {
// userid needs to be in format "name <email>"
if (!userid.match(/^[^<]*\s?<[^>]*>$/)) {
return Promise.reject(Error('Invalid userid, expected: "name <email>"'));
}
this.pgpUser = userid;
this.pgpContext.setKeyRingPassphrase(passphrase);
var init = function () {
console.log('in init');
// userid needs to be in format "name <email>"
if (!userid.match(/^[^<]*\s?<[^>]*>$/)) {
return Promise.reject(Error('Invalid userid, expected: "name <email>"'));
}
this.pgpUser = userid;
this.pgpContext.setKeyRingPassphrase(passphrase);
if (e2e.async.Result.getValue(
this.pgpContext.searchPrivateKey(this.pgpUser)).length === 0) {
var username = this.pgpUser.slice(0, userid.lastIndexOf('<')).trim();
var email = this.pgpUser.slice(userid.lastIndexOf('<') + 1, -1);
this.generateKey(username, email);
if (e2e.async.Result.getValue(
this.pgpContext.searchPrivateKey(this.pgpUser)).length === 0) {
var username = this.pgpUser.slice(0, userid.lastIndexOf('<')).trim();
var email = this.pgpUser.slice(userid.lastIndexOf('<') + 1, -1);
return this.generateKey(username, email);
} else {
return Promise.resolve();
}
}.bind(this);
if (refreshBuffer) {
console.log('refresh?');
Promise.resolve(refreshBuffer(50000)).then(init);
} else {
return init();
}
return Promise.resolve();
};

@@ -47,5 +98,4 @@

// See googstorage.js for details on how storage works
if (this.storage.get('UserKeyRing')) {
this.storage.remove('UserKeyRing');
}
this.storage.remove('UserKeyRing');
this.storage.remove('Salt');
};

@@ -52,0 +102,0 @@

@@ -98,2 +98,3 @@ {

"permissions": [
"core.crypto",
"core.storage"

@@ -100,0 +101,0 @@ ]

2

package.json
{
"name": "freedom-pgp-e2e",
"description": "Library to provide freedom API wrapper of end-to-end library",
"version": "0.4.3",
"version": "0.5.0",
"contributors": [

@@ -6,0 +6,0 @@ "Aaron Gallant <ag@cs.washington.edu>"

@@ -18,3 +18,2 @@ /*globals freedom, console, e2e, exports, ArrayBuffer, Uint8Array, Uint16Array, DataView*/

this.pgpUser = null;
this.storage = new store();
};

@@ -30,11 +29,12 @@

this.pgpUser = userid;
this.pgpContext.setKeyRingPassphrase(passphrase);
if (e2e.async.Result.getValue(
this.pgpContext.searchPrivateKey(this.pgpUser)).length === 0) {
var username = this.pgpUser.slice(0, userid.lastIndexOf('<')).trim();
var email = this.pgpUser.slice(userid.lastIndexOf('<') + 1, -1);
this.generateKey(username, email);
}
return Promise.resolve();
return store.prepareFreedom().then(function() {
this.pgpContext.setKeyRingPassphrase(passphrase);
if (e2e.async.Result.getValue(
this.pgpContext.searchPrivateKey(this.pgpUser)).length === 0) {
var username = this.pgpUser.slice(0, userid.lastIndexOf('<')).trim();
var email = this.pgpUser.slice(userid.lastIndexOf('<') + 1, -1);
this.generateKey(username, email);
}
}.bind(this));
};

@@ -47,4 +47,6 @@

// See googstorage.js for details on how storage works
this.storage.remove('UserKeyRing');
this.storage.remove('Salt');
return store.prepareFreedom().then(function() {
var storage = new store();
storage.clear();
});
};

@@ -51,0 +53,0 @@

@@ -5,12 +5,3 @@

this.memStorage = {};
this.freedomStorage.get('UserKeyRing').then(function(value) {
if (value) {
this.memStorage.UserKeyRing = value;
}
}.bind(this));
this.freedomStorage.get('Salt').then(function(value) {
if (value) {
this.memStorage.Salt = value;
}
}.bind(this));
this.initialize();
}

@@ -79,2 +70,18 @@

store.prototype.initialize = function() {
this.memStorage = store.preparedMem;
};
store.preparedMem = {};
// IMPORTANT - this function must be called and resolved before instantiating
// a store object, otherwise async nastiness w/freedom localstorage occurs
store.prepareFreedom = function() {
return freedom['core.storage']().get('UserKeyRing').then(function(value) {
if (value) {
store.preparedMem.UserKeyRing = value;
}
});
}
goog.storage.mechanism.HTML5LocalStorage = store;
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