libves 1.9.9 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,15 +1,34 @@
1
1
  ## libVES
2
- A JavaScript interface to VESvault REST API (beta).
3
- libVES user WebCrypto end-to-end encryption.
2
+
3
+
4
+ Simple, safe and secure e2e encryption for data at-rest.
5
+
4
6
 
5
7
  https://VESvault.com
6
8
  https://VES.host
7
9
 
8
- - Deposit and retrieve encrypted items into VESvault repository using end-to-end encryption
9
- - Manage asymmetric encryption keys in the VESvault repository using end-to-end encryption
10
- - [VESrecovery](https://www.vesvault.com/#vault)™ operations: set VESrecovery friends, assist in VESrecovery
11
10
 
12
- Run Makefile.pl to generate a consolidated js file, and a minified version of it.
11
+ ; Instantiate libVES
12
+ var VES = new libVES({domain: 'x-myapp'});
13
+
14
+ ; Authorize with VES in the same browser window
15
+ VES.flow(true).then(....)
16
+
17
+ ; Or, authorize in a popup window
18
+ VES.delegate().then(....)
19
+
20
+ ; Store an e2e encrypted value
21
+ VES.putValue('item-id', 'value')
22
+
23
+ ; Store a value and e2e share with other VES accounts
24
+ VES.putValue('item-id', 'value', [{externalId: 'me@acme.com'}, {externalId: 'user1@acme.com'}, {externalId: 'user2@acme.com'}])
25
+
26
+ ; Retrieve a previously stored value
27
+ VES.getValue('item-id').then(function(value) { .... })
28
+
29
+
30
+ See https://demo.ves.world
31
+
13
32
 
14
- API Documentation:
33
+ Full API Docs:
15
34
  https://ves.host/docs/libVES
package/libVES.node.js CHANGED
@@ -14,7 +14,7 @@
14
14
  * \___/ - VESrecovery (TM)
15
15
  *
16
16
  *
17
- * (c) 2017 - 2020 VESvault Corp
17
+ * (c) 2017 - 2022 VESvault Corp
18
18
  * Jim Zubov <jz@vesvault.com>
19
19
  *
20
20
  * GNU General Public License v3
@@ -27,7 +27,7 @@
27
27
  *
28
28
  * @title libVES
29
29
  * @dev A JavaScript end-to-end encryption interface to VESvault REST API
30
- * @version 1.99
30
+ * @version 2.00
31
31
  *
32
32
  * @dev Official source code: https://github.com/vesvault/libVES
33
33
  *
@@ -349,7 +349,9 @@ libVES.prototype = {
349
349
  });
350
350
  },
351
351
  vaultRefToUser: function(ext) {
352
- return new libVES.User({email: ext.externalId}, self);
352
+ var email = ext.externalId ? ext.externalId.replace(/\!.*/, '') : '';
353
+ if (!email.match(/\@/)) throw {code: 'NotFound', message: 'externalId is not an email for non-existing vault'};
354
+ return new libVES.User({email: email}, self);
353
355
  }
354
356
  };
355
357
  });
@@ -361,7 +363,7 @@ libVES.prototype = {
361
363
  return self.prepareExternals([ex]);
362
364
  });
363
365
  }).catch(function(e) {
364
- throw new libVES.Error('NotFound','Cannot match externalId for domain:' + ext.domain + ', user:' + user + '. Define libVES.Domain.' + ext.domain + '.userToVaultRef(user) to return a valid reference.',{error: e});
366
+ throw new libVES.Error('NotFound', 'Cannot match externalId for domain:' + ext.domain + ', user:' + user + '. Define libVES.Domain.' + ext.domain + '.userToVaultRef(user) to return a valid reference.',{error: e});
365
367
  })).then(function(exts) {
366
368
  var vkey = new libVES.VaultKey({externals: exts, creator: self.me()},self);
367
369
  return vkey.getId().then(function() {
@@ -371,7 +373,7 @@ libVES.prototype = {
371
373
  return Promise.resolve(user || m().then(function(dom) {
372
374
  return dom.vaultRefToUser(exts[0]);
373
375
  })).catch(function(e) {
374
- throw new libVES.Error('NotFound','No matching secondary key (domain:' + ext.domain + ', externalId:' + ext.externalId + '). Supply "user" to create the temp key, or define libVES.Domain.' + ext.domain + '.vaultRefToUser(vaultRef) to return matching libVES.User',{error: e});
376
+ throw new libVES.Error('NotFound', 'No matching secondary vault key',{error: e});
375
377
  }).then(function(u) {
376
378
  return self.me().then(function(me) {
377
379
  return Promise.all([me.getId(),u.getId()]).then(function(ids) {
@@ -551,6 +553,23 @@ libVES.prototype = {
551
553
  });
552
554
  });
553
555
  },
556
+ setAnonymousKey: function(veskey, optns) {
557
+ var self = this;
558
+ return this.prepareExternals({externalId: self.externalId}).then(function(ext) {
559
+ if (!veskey) throw new libVES.Error('InvalidValue','VESkey cannot be empty');
560
+ return (new libVES.VaultKey({type: 'secondary', algo: (optns && optns.algo ? optns.algo : self.keyAlgo), externals: ext},self)).generate(veskey, optns).then(function(k) {
561
+ return k.post(undefined, ['encSessionToken'], optns).then(function(post) {
562
+ return k.setField('id', post.id, false).then(function() {
563
+ k.fieldUpdate = {id: true};
564
+ });
565
+ }).catch(function(e) {
566
+ if (!e || e.code != 'Unauthorized') throw e;
567
+ }).then(function() {
568
+ return self.unlock(veskey);
569
+ });
570
+ });
571
+ });
572
+ },
554
573
  setShadow: function(usrs,optns) {
555
574
  var self = this;
556
575
  if (!(usrs instanceof Array)) return Promise.reject(new libVES.Error('InvalidValue', 'usrs must be an array'));
@@ -2084,7 +2103,7 @@ libVES.VaultItem.prototype = new libVES.Object({
2084
2103
  apiUri: 'vaultItems',
2085
2104
  fieldList: {id: true},
2086
2105
  fieldClass: {vaultKey: libVES.VaultKey, file: libVES.File},
2087
- fieldSets: [{type: true, meta: true},{vaultEntries: {id: true, encData: true, vaultKey: {id: true, type: true, user: {id: true}, algo: true}}},{vaultKey: true, file: true}],
2106
+ fieldSets: [{type: true, meta: true},{vaultEntries: {id: true, encData: true, vaultKey: {id: true, type: true, user: {id: true}, algo: true, externals: {id: true}}}},{vaultKey: true, file: true}],
2088
2107
  defaultCipher: 'AES256GCM',
2089
2108
  getRaw: function() {
2090
2109
  var self = this;
@@ -3222,13 +3241,13 @@ libVES.Delegate = {
3222
3241
  return this.popupWindow = window.open(url,this.name,"width=600,height=600,top=100,left=100");
3223
3242
  },
3224
3243
  retryPopup: function(url,href) {
3225
- var f = this.retryPopupCalled;
3226
3244
  this.retryPopupCalled++;
3227
- if (href && f > 1) href.target = '_blank';
3228
- else if (this.popupWindow) try {
3245
+ if (this.popupWindow) try {
3229
3246
  this.popupWindow.focus();
3247
+ return true;
3230
3248
  } catch(e) {}
3231
- return !f && this.openPopup(url);
3249
+ this.openPopup(url);
3250
+ return true;
3232
3251
  },
3233
3252
  listener: function(evnt) {
3234
3253
  if (this.popup && evnt.origin == this.matchOrigin) try {
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libves",
3
- "version": "1.9.9",
3
+ "version": "2.0.0",
4
4
  "description": "VESvault end-to-end encryption API",
5
5
  "main": "libVES.node.js",
6
6
  "scripts": {
@@ -13,7 +13,10 @@
13
13
  "keywords": [
14
14
  "encryption",
15
15
  "VESvault",
16
- "VES"
16
+ "VES",
17
+ "e2e",
18
+ "at-rest",
19
+ "end-to-end"
17
20
  ],
18
21
  "author": "jz@vesvault.com",
19
22
  "license": "GPL-3.0",
package/libves-1.9.9.tgz DELETED
Binary file