@eluvio/elv-client-js 4.0.147 → 4.1.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.
Files changed (47) hide show
  1. package/dist/ElvClient-min.js +2 -67
  2. package/dist/ElvClient-min.js.LICENSE.txt +72 -0
  3. package/dist/ElvClient-node-min.js +2 -66
  4. package/dist/ElvClient-node-min.js.LICENSE.txt +72 -0
  5. package/dist/ElvFrameClient-min.js +2 -60
  6. package/dist/ElvFrameClient-min.js.LICENSE.txt +72 -0
  7. package/dist/ElvPermissionsClient-min.js +2 -60
  8. package/dist/ElvPermissionsClient-min.js.LICENSE.txt +72 -0
  9. package/dist/ElvWalletClient-min.js +2 -67
  10. package/dist/ElvWalletClient-min.js.LICENSE.txt +72 -0
  11. package/dist/ElvWalletClient-node-min.js +2 -66
  12. package/dist/ElvWalletClient-node-min.js.LICENSE.txt +72 -0
  13. package/dist/src/AuthorizationClient.js +713 -715
  14. package/dist/src/ContentObjectAudit.js +59 -59
  15. package/dist/src/Crypto.js +85 -86
  16. package/dist/src/ElvClient.js +532 -501
  17. package/dist/src/ElvWallet.js +30 -28
  18. package/dist/src/EthClient.js +316 -316
  19. package/dist/src/FrameClient.js +70 -71
  20. package/dist/src/HttpClient.js +60 -60
  21. package/dist/src/Id.js +1 -2
  22. package/dist/src/PermissionsClient.js +501 -489
  23. package/dist/src/RemoteSigner.js +83 -84
  24. package/dist/src/UserProfileClient.js +392 -374
  25. package/dist/src/Utils.js +67 -67
  26. package/dist/src/Validation.js +20 -12
  27. package/dist/src/client/ABRPublishing.js +412 -356
  28. package/dist/src/client/AccessGroups.js +479 -476
  29. package/dist/src/client/ContentAccess.js +1750 -1804
  30. package/dist/src/client/ContentManagement.js +874 -874
  31. package/dist/src/client/Contracts.js +586 -590
  32. package/dist/src/client/Files.js +702 -686
  33. package/dist/src/client/LiveConf.js +3 -5
  34. package/dist/src/client/LiveStream.js +659 -652
  35. package/dist/src/client/NFT.js +16 -16
  36. package/dist/src/client/NTP.js +84 -84
  37. package/dist/src/client/Shares.js +51 -51
  38. package/dist/src/walletClient/ClientMethods.js +979 -953
  39. package/dist/src/walletClient/Notifications.js +14 -14
  40. package/dist/src/walletClient/Profile.js +68 -68
  41. package/dist/src/walletClient/Utils.js +17 -17
  42. package/dist/src/walletClient/index.js +574 -564
  43. package/package.json +17 -16
  44. package/src/client/AccessGroups.js +1 -1
  45. package/testScripts/Test.js +5 -1
  46. package/webpack.config.js +10 -13
  47. package/dist/src/ContentObjectVerification.js +0 -281
@@ -1,9 +1,9 @@
1
1
  var _regeneratorRuntime = require("@babel/runtime/regenerator");
2
2
  var _toConsumableArray = require("@babel/runtime/helpers/toConsumableArray");
3
3
  var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
4
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
5
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
4
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
5
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
6
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
7
7
  var UrlJoin = require("url-join");
8
8
  var HttpClient = require("./HttpClient");
9
9
  var UUID = require("uuid").v4;
@@ -11,9 +11,9 @@ var _require = require("./Validation"),
11
11
  ValidateParameters = _require.ValidateParameters;
12
12
  var ContentObjectAudit = {
13
13
  AuditContentObject: function AuditContentObject(_ref) {
14
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
15
- var client, libraryId, objectId, versionHash, salt, samples, _ref$live, live, authorizationToken, queryParams, uris, httpClient, path, responses, auditHash, verified, audits, _iterator, _step, response, url, audit, res;
16
- return _regeneratorRuntime.wrap(function _callee$(_context) {
14
+ return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
15
+ var client, libraryId, objectId, versionHash, salt, samples, _ref$live, live, authorizationToken, queryParams, uris, httpClient, path, responses, auditHash, verified, audits, _iterator, _step, response, url, audit, res, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t0, _t1;
16
+ return _regeneratorRuntime.wrap(function (_context) {
17
17
  while (1) switch (_context.prev = _context.next) {
18
18
  case 0:
19
19
  client = _ref.client, libraryId = _ref.libraryId, objectId = _ref.objectId, versionHash = _ref.versionHash, salt = _ref.salt, samples = _ref.samples, _ref$live = _ref.live, live = _ref$live === void 0 ? false : _ref$live, authorizationToken = _ref.authorizationToken;
@@ -30,16 +30,16 @@ var ContentObjectAudit = {
30
30
  objectId = client.utils.DecodeVersionHash(versionHash).objectId;
31
31
  }
32
32
  if (libraryId) {
33
- _context.next = 9;
33
+ _context.next = 2;
34
34
  break;
35
35
  }
36
- _context.next = 8;
36
+ _context.next = 1;
37
37
  return client.ContentObjectLibraryId({
38
38
  objectId: objectId
39
39
  });
40
- case 8:
40
+ case 1:
41
41
  libraryId = _context.sent;
42
- case 9:
42
+ case 2:
43
43
  ValidateParameters({
44
44
  libraryId: libraryId,
45
45
  objectId: objectId,
@@ -54,64 +54,64 @@ var ContentObjectAudit = {
54
54
  }
55
55
 
56
56
  // Test against the node the client is currently using, plus a batch of fresh nodes
57
- _context.t0 = [client.HttpClient.uris[client.HttpClient.uriIndex]];
58
- _context.t1 = _toConsumableArray;
59
- _context.next = 16;
57
+ _t = [client.HttpClient.uris[client.HttpClient.uriIndex]];
58
+ _t2 = _toConsumableArray;
59
+ _context.next = 3;
60
60
  return client.Configuration({
61
61
  configUrl: client.configUrl,
62
62
  clientIP: client.clientIP,
63
63
  region: client.region
64
64
  });
65
- case 16:
66
- _context.t2 = _context.sent.fabricURIs;
67
- _context.t3 = (0, _context.t1)(_context.t2);
68
- uris = _context.t0.concat.call(_context.t0, _context.t3).filter(function (v, i, s) {
65
+ case 3:
66
+ _t3 = _context.sent.fabricURIs;
67
+ _t4 = _t2(_t3);
68
+ uris = _t.concat.call(_t, _t4).filter(function (v, i, s) {
69
69
  return s.indexOf(v) === i;
70
70
  });
71
71
  httpClient = new HttpClient({
72
72
  uris: uris
73
73
  });
74
74
  path = UrlJoin("qlibs", libraryId, "q", versionHash || objectId, live ? "call/live/audit" : "audit");
75
- _context.t4 = httpClient;
75
+ _t5 = httpClient;
76
76
  if (!authorizationToken) {
77
- _context.next = 26;
77
+ _context.next = 4;
78
78
  break;
79
79
  }
80
- _context.t5 = {
80
+ _t6 = {
81
81
  Authorization: "Bearer ".concat(authorizationToken)
82
82
  };
83
- _context.next = 29;
83
+ _context.next = 6;
84
84
  break;
85
- case 26:
86
- _context.next = 28;
85
+ case 4:
86
+ _context.next = 5;
87
87
  return client.authClient.AuthorizationHeader({
88
88
  libraryId: libraryId,
89
89
  objectId: objectId,
90
90
  versionHash: versionHash
91
91
  });
92
- case 28:
93
- _context.t5 = _context.sent;
94
- case 29:
95
- _context.t6 = _context.t5;
96
- _context.t7 = queryParams;
97
- _context.t8 = path;
98
- _context.t9 = {
99
- headers: _context.t6,
100
- queryParams: _context.t7,
92
+ case 5:
93
+ _t6 = _context.sent;
94
+ case 6:
95
+ _t7 = _t6;
96
+ _t8 = queryParams;
97
+ _t9 = path;
98
+ _t0 = {
99
+ headers: _t7,
100
+ queryParams: _t8,
101
101
  method: "GET",
102
- path: _context.t8
102
+ path: _t9
103
103
  };
104
- _context.next = 35;
105
- return _context.t4.RequestAll.call(_context.t4, _context.t9);
106
- case 35:
104
+ _context.next = 7;
105
+ return _t5.RequestAll.call(_t5, _t0);
106
+ case 7:
107
107
  responses = _context.sent;
108
108
  audits = [];
109
109
  _iterator = _createForOfIteratorHelper(responses);
110
- _context.prev = 38;
110
+ _context.prev = 8;
111
111
  _iterator.s();
112
- case 40:
112
+ case 9:
113
113
  if ((_step = _iterator.n()).done) {
114
- _context.next = 57;
114
+ _context.next = 14;
115
115
  break;
116
116
  }
117
117
  response = _step.value;
@@ -120,17 +120,17 @@ var ContentObjectAudit = {
120
120
  host: url.hostname
121
121
  };
122
122
  if (response.ok) {
123
- _context.next = 49;
123
+ _context.next = 10;
124
124
  break;
125
125
  }
126
126
  audit.error = response;
127
127
  audit.errorMessage = response.message || JSON.stringify(response);
128
- _context.next = 54;
128
+ _context.next = 12;
129
129
  break;
130
- case 49:
131
- _context.next = 51;
130
+ case 10:
131
+ _context.next = 11;
132
132
  return client.utils.ResponseToJson(response);
133
- case 51:
133
+ case 11:
134
134
  res = _context.sent;
135
135
  if (auditHash === undefined) {
136
136
  auditHash = res.audit_hash;
@@ -140,23 +140,23 @@ var ContentObjectAudit = {
140
140
  verified = true;
141
141
  }
142
142
  audit.audit_hash = res.audit_hash;
143
- case 54:
143
+ case 12:
144
144
  audits.push(audit);
145
- case 55:
146
- _context.next = 40;
145
+ case 13:
146
+ _context.next = 9;
147
147
  break;
148
- case 57:
149
- _context.next = 62;
148
+ case 14:
149
+ _context.next = 16;
150
150
  break;
151
- case 59:
152
- _context.prev = 59;
153
- _context.t10 = _context["catch"](38);
154
- _iterator.e(_context.t10);
155
- case 62:
156
- _context.prev = 62;
151
+ case 15:
152
+ _context.prev = 15;
153
+ _t1 = _context["catch"](8);
154
+ _iterator.e(_t1);
155
+ case 16:
156
+ _context.prev = 16;
157
157
  _iterator.f();
158
- return _context.finish(62);
159
- case 65:
158
+ return _context.finish(16);
159
+ case 17:
160
160
  verified = verified || false;
161
161
  return _context.abrupt("return", {
162
162
  verified: verified,
@@ -164,11 +164,11 @@ var ContentObjectAudit = {
164
164
  samples: samples,
165
165
  audits: audits
166
166
  });
167
- case 67:
167
+ case 18:
168
168
  case "end":
169
169
  return _context.stop();
170
170
  }
171
- }, _callee, null, [[38, 59, 62, 65]]);
171
+ }, _callee, null, [[8, 15, 16, 17]]);
172
172
  }))();
173
173
  }
174
174
  };
@@ -1,8 +1,7 @@
1
1
  var _typeof = require("@babel/runtime/helpers/typeof");
2
2
  var _regeneratorRuntime = require("@babel/runtime/regenerator");
3
3
  var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
4
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
5
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
4
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t4 in e) "default" !== _t4 && {}.hasOwnProperty.call(e, _t4) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t4)) && (i.get || i.set) ? o(f, _t4, i) : f[_t4] = e[_t4]); return f; })(e, t); }
6
5
  if (typeof globalThis.Buffer === "undefined") {
7
6
  globalThis.Buffer = require("buffer/").Buffer;
8
7
  }
@@ -27,40 +26,40 @@ if (typeof crypto === "undefined") {
27
26
  */
28
27
  var Crypto = {
29
28
  ElvCrypto: function () {
30
- var _ElvCrypto = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
31
- var _ElvCrypto2;
32
- return _regeneratorRuntime.wrap(function _callee$(_context) {
29
+ var _ElvCrypto = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
30
+ var _ElvCrypto2, _t;
31
+ return _regeneratorRuntime.wrap(function (_context) {
33
32
  while (1) switch (_context.prev = _context.next) {
34
33
  case 0:
35
34
  _context.prev = 0;
36
35
  if (Crypto.elvCrypto) {
37
- _context.next = 8;
36
+ _context.next = 3;
38
37
  break;
39
38
  }
40
- _context.next = 4;
39
+ _context.next = 1;
41
40
  return Promise.resolve().then(function () {
42
41
  return _interopRequireWildcard(require("@eluvio/crypto"));
43
42
  });
44
- case 4:
43
+ case 1:
45
44
  _ElvCrypto2 = _context.sent["default"];
46
- _context.next = 7;
45
+ _context.next = 2;
47
46
  return new _ElvCrypto2().init();
48
- case 7:
47
+ case 2:
49
48
  Crypto.elvCrypto = _context.sent;
50
- case 8:
49
+ case 3:
51
50
  return _context.abrupt("return", Crypto.elvCrypto);
52
- case 11:
53
- _context.prev = 11;
54
- _context.t0 = _context["catch"](0);
51
+ case 4:
52
+ _context.prev = 4;
53
+ _t = _context["catch"](0);
55
54
  // eslint-disable-next-line no-console
56
55
  console.error("Error initializing ElvCrypto:");
57
56
  // eslint-disable-next-line no-console
58
- console.error(_context.t0);
59
- case 15:
57
+ console.error(_t);
58
+ case 5:
60
59
  case "end":
61
60
  return _context.stop();
62
61
  }
63
- }, _callee, null, [[0, 11]]);
62
+ }, _callee, null, [[0, 4]]);
64
63
  }));
65
64
  function ElvCrypto() {
66
65
  return _ElvCrypto.apply(this, arguments);
@@ -91,27 +90,27 @@ var Crypto = {
91
90
  return reencrypt ? encryptedBlockSize + targetEncBlockOverhead : encryptedBlockSize + primaryEncBlockOverhead;
92
91
  },
93
92
  EncryptConk: function EncryptConk(conk, publicKey) {
94
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
93
+ return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
95
94
  var elvCrypto, _yield$elvCrypto$encr, data, ephemeralKey, tag, cap;
96
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
95
+ return _regeneratorRuntime.wrap(function (_context2) {
97
96
  while (1) switch (_context2.prev = _context2.next) {
98
97
  case 0:
99
- _context2.next = 2;
98
+ _context2.next = 1;
100
99
  return Crypto.ElvCrypto();
101
- case 2:
100
+ case 1:
102
101
  elvCrypto = _context2.sent;
103
102
  publicKey = new Uint8Array(Buffer.from(publicKey.replace("0x", ""), "hex"));
104
103
  conk = new Uint8Array(Buffer.from(JSON.stringify(conk)));
105
- _context2.next = 7;
104
+ _context2.next = 2;
106
105
  return elvCrypto.encryptECIES(conk, publicKey);
107
- case 7:
106
+ case 2:
108
107
  _yield$elvCrypto$encr = _context2.sent;
109
108
  data = _yield$elvCrypto$encr.data;
110
109
  ephemeralKey = _yield$elvCrypto$encr.ephemeralKey;
111
110
  tag = _yield$elvCrypto$encr.tag;
112
111
  cap = Buffer.concat([Buffer.from(ephemeralKey), Buffer.from(tag), Buffer.from(data)]);
113
112
  return _context2.abrupt("return", Utils.B64(cap));
114
- case 13:
113
+ case 3:
115
114
  case "end":
116
115
  return _context2.stop();
117
116
  }
@@ -119,14 +118,14 @@ var Crypto = {
119
118
  }))();
120
119
  },
121
120
  DecryptCap: function DecryptCap(encryptedCap, privateKey) {
122
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
121
+ return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
123
122
  var elvCrypto, ephemeralKey, tag, data, cap;
124
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
123
+ return _regeneratorRuntime.wrap(function (_context3) {
125
124
  while (1) switch (_context3.prev = _context3.next) {
126
125
  case 0:
127
- _context3.next = 2;
126
+ _context3.next = 1;
128
127
  return Crypto.ElvCrypto();
129
- case 2:
128
+ case 1:
130
129
  elvCrypto = _context3.sent;
131
130
  privateKey = new Uint8Array(Buffer.from(privateKey.replace("0x", ""), "hex"));
132
131
  encryptedCap = Buffer.from(encryptedCap, "base64");
@@ -135,7 +134,7 @@ var Crypto = {
135
134
  data = encryptedCap.slice(81);
136
135
  cap = elvCrypto.decryptECIES(new Uint8Array(data), privateKey, new Uint8Array(ephemeralKey), new Uint8Array(tag));
137
136
  return _context3.abrupt("return", JSON.parse(Buffer.from(cap).toString()));
138
- case 10:
137
+ case 2:
139
138
  case "end":
140
139
  return _context3.stop();
141
140
  }
@@ -143,15 +142,15 @@ var Crypto = {
143
142
  }))();
144
143
  },
145
144
  GeneratePrimaryConk: function GeneratePrimaryConk(_ref) {
146
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
145
+ return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
147
146
  var spaceId, objectId, elvCrypto, _elvCrypto$generatePr, secretKey, publicKey, symmetricKey;
148
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
147
+ return _regeneratorRuntime.wrap(function (_context4) {
149
148
  while (1) switch (_context4.prev = _context4.next) {
150
149
  case 0:
151
150
  spaceId = _ref.spaceId, objectId = _ref.objectId;
152
- _context4.next = 3;
151
+ _context4.next = 1;
153
152
  return Crypto.ElvCrypto();
154
- case 3:
153
+ case 1:
155
154
  elvCrypto = _context4.sent;
156
155
  _elvCrypto$generatePr = elvCrypto.generatePrimaryKeys(), secretKey = _elvCrypto$generatePr.secretKey, publicKey = _elvCrypto$generatePr.publicKey;
157
156
  symmetricKey = elvCrypto.generateSymmetricKey().key;
@@ -162,7 +161,7 @@ var Crypto = {
162
161
  sid: spaceId,
163
162
  qid: objectId
164
163
  });
165
- case 7:
164
+ case 2:
166
165
  case "end":
167
166
  return _context4.stop();
168
167
  }
@@ -170,21 +169,21 @@ var Crypto = {
170
169
  }))();
171
170
  },
172
171
  GenerateTargetConk: function GenerateTargetConk() {
173
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
172
+ return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
174
173
  var elvCrypto, _elvCrypto$generateTa, secretKey, publicKey;
175
- return _regeneratorRuntime.wrap(function _callee5$(_context5) {
174
+ return _regeneratorRuntime.wrap(function (_context5) {
176
175
  while (1) switch (_context5.prev = _context5.next) {
177
176
  case 0:
178
- _context5.next = 2;
177
+ _context5.next = 1;
179
178
  return Crypto.ElvCrypto();
180
- case 2:
179
+ case 1:
181
180
  elvCrypto = _context5.sent;
182
181
  _elvCrypto$generateTa = elvCrypto.generateTargetKeys(), secretKey = _elvCrypto$generateTa.secretKey, publicKey = _elvCrypto$generateTa.publicKey;
183
182
  return _context5.abrupt("return", {
184
183
  secret_key: "kpsk".concat(bs58.encode(Buffer.from(secretKey))),
185
184
  public_key: "ktpk".concat(bs58.encode(Buffer.from(publicKey)))
186
185
  });
187
- case 5:
186
+ case 2:
188
187
  case "end":
189
188
  return _context5.stop();
190
189
  }
@@ -202,14 +201,14 @@ var Crypto = {
202
201
  };
203
202
  },
204
203
  EncryptionContext: function EncryptionContext(cap) {
205
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
204
+ return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
206
205
  var elvCrypto, _Crypto$CapToConk, symmetricKey, secretKey, publicKey, context, type;
207
- return _regeneratorRuntime.wrap(function _callee6$(_context6) {
206
+ return _regeneratorRuntime.wrap(function (_context6) {
208
207
  while (1) switch (_context6.prev = _context6.next) {
209
208
  case 0:
210
- _context6.next = 2;
209
+ _context6.next = 1;
211
210
  return Crypto.ElvCrypto();
212
- case 2:
211
+ case 1:
213
212
  elvCrypto = _context6.sent;
214
213
  _Crypto$CapToConk = Crypto.CapToConk(cap), symmetricKey = _Crypto$CapToConk.symmetricKey, secretKey = _Crypto$CapToConk.secretKey, publicKey = _Crypto$CapToConk.publicKey;
215
214
  if (publicKey.length === elvCrypto.PRIMARY_PK_KEY_SIZE) {
@@ -225,7 +224,7 @@ var Crypto = {
225
224
  context: context,
226
225
  type: type
227
226
  });
228
- case 6:
227
+ case 2:
229
228
  case "end":
230
229
  return _context6.stop();
231
230
  }
@@ -242,26 +241,26 @@ var Crypto = {
242
241
  * @returns {Promise<Buffer>} - Decrypted data
243
242
  */
244
243
  Encrypt: function () {
245
- var _Encrypt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(cap, data) {
246
- var stream, dataArray, i, end, encryptedChunks;
247
- return _regeneratorRuntime.wrap(function _callee7$(_context7) {
244
+ var _Encrypt = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(cap, data) {
245
+ var stream, dataArray, i, end, encryptedChunks, _t2, _t3;
246
+ return _regeneratorRuntime.wrap(function (_context7) {
248
247
  while (1) switch (_context7.prev = _context7.next) {
249
248
  case 0:
250
- _context7.next = 2;
249
+ _context7.next = 1;
251
250
  return Crypto.OpenEncryptionStream(cap);
252
- case 2:
251
+ case 1:
253
252
  stream = _context7.sent;
254
253
  if (!(!Buffer.isBuffer(data) && !(data instanceof ArrayBuffer))) {
255
- _context7.next = 9;
254
+ _context7.next = 3;
256
255
  break;
257
256
  }
258
- _context7.t0 = Buffer;
259
- _context7.next = 7;
257
+ _t2 = Buffer;
258
+ _context7.next = 2;
260
259
  return new Response(data).arrayBuffer();
261
- case 7:
262
- _context7.t1 = _context7.sent;
263
- data = _context7.t0.from.call(_context7.t0, _context7.t1);
264
- case 9:
260
+ case 2:
261
+ _t3 = _context7.sent;
262
+ data = _t2.from.call(_t2, _t3);
263
+ case 3:
265
264
  dataArray = new Uint8Array(data);
266
265
  for (i = 0; i < dataArray.length; i += 1000000) {
267
266
  end = Math.min(dataArray.length, i + 1000000);
@@ -269,7 +268,7 @@ var Crypto = {
269
268
  }
270
269
  stream.end();
271
270
  encryptedChunks = [];
272
- _context7.next = 15;
271
+ _context7.next = 4;
273
272
  return new Promise(function (resolve, reject) {
274
273
  stream.on("data", function (chunk) {
275
274
  encryptedChunks.push(chunk);
@@ -279,9 +278,9 @@ var Crypto = {
279
278
  reject(e);
280
279
  });
281
280
  });
282
- case 15:
281
+ case 4:
283
282
  return _context7.abrupt("return", Buffer.concat(encryptedChunks));
284
- case 16:
283
+ case 5:
285
284
  case "end":
286
285
  return _context7.stop();
287
286
  }
@@ -293,18 +292,18 @@ var Crypto = {
293
292
  return Encrypt;
294
293
  }(),
295
294
  OpenEncryptionStream: function () {
296
- var _OpenEncryptionStream = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(cap) {
295
+ var _OpenEncryptionStream = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(cap) {
297
296
  var elvCrypto, _yield$Crypto$Encrypt, context, stream, cipher;
298
- return _regeneratorRuntime.wrap(function _callee8$(_context8) {
297
+ return _regeneratorRuntime.wrap(function (_context8) {
299
298
  while (1) switch (_context8.prev = _context8.next) {
300
299
  case 0:
301
- _context8.next = 2;
300
+ _context8.next = 1;
302
301
  return Crypto.ElvCrypto();
303
- case 2:
302
+ case 1:
304
303
  elvCrypto = _context8.sent;
305
- _context8.next = 5;
304
+ _context8.next = 2;
306
305
  return Crypto.EncryptionContext(cap);
307
- case 5:
306
+ case 2:
308
307
  _yield$Crypto$Encrypt = _context8.sent;
309
308
  context = _yield$Crypto$Encrypt.context;
310
309
  stream = new Stream.PassThrough();
@@ -314,7 +313,7 @@ var Crypto = {
314
313
  }).on("error", function (e) {
315
314
  throw Error(e);
316
315
  }));
317
- case 10:
316
+ case 3:
318
317
  case "end":
319
318
  return _context8.stop();
320
319
  }
@@ -335,14 +334,14 @@ var Crypto = {
335
334
  * @returns {Promise<Buffer>} - Decrypted data
336
335
  */
337
336
  Decrypt: function () {
338
- var _Decrypt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(cap, encryptedData) {
337
+ var _Decrypt = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(cap, encryptedData) {
339
338
  var stream, dataArray, i, end, decryptedChunks;
340
- return _regeneratorRuntime.wrap(function _callee9$(_context9) {
339
+ return _regeneratorRuntime.wrap(function (_context9) {
341
340
  while (1) switch (_context9.prev = _context9.next) {
342
341
  case 0:
343
- _context9.next = 2;
342
+ _context9.next = 1;
344
343
  return Crypto.OpenDecryptionStream(cap);
345
- case 2:
344
+ case 1:
346
345
  stream = _context9.sent;
347
346
  dataArray = new Uint8Array(encryptedData);
348
347
  for (i = 0; i < dataArray.length; i += 1000000) {
@@ -351,7 +350,7 @@ var Crypto = {
351
350
  }
352
351
  stream.end();
353
352
  decryptedChunks = [];
354
- _context9.next = 9;
353
+ _context9.next = 2;
355
354
  return new Promise(function (resolve, reject) {
356
355
  stream.on("data", function (chunk) {
357
356
  decryptedChunks.push(chunk);
@@ -361,9 +360,9 @@ var Crypto = {
361
360
  reject(e);
362
361
  });
363
362
  });
364
- case 9:
363
+ case 2:
365
364
  return _context9.abrupt("return", Buffer.concat(decryptedChunks));
366
- case 10:
365
+ case 3:
367
366
  case "end":
368
367
  return _context9.stop();
369
368
  }
@@ -375,33 +374,33 @@ var Crypto = {
375
374
  return Decrypt;
376
375
  }(),
377
376
  OpenDecryptionStream: function () {
378
- var _OpenDecryptionStream = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(cap) {
377
+ var _OpenDecryptionStream = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee0(cap) {
379
378
  var elvCrypto, _yield$Crypto$Encrypt2, context, type, stream, decipher;
380
- return _regeneratorRuntime.wrap(function _callee10$(_context10) {
381
- while (1) switch (_context10.prev = _context10.next) {
379
+ return _regeneratorRuntime.wrap(function (_context0) {
380
+ while (1) switch (_context0.prev = _context0.next) {
382
381
  case 0:
383
- _context10.next = 2;
382
+ _context0.next = 1;
384
383
  return Crypto.ElvCrypto();
385
- case 2:
386
- elvCrypto = _context10.sent;
387
- _context10.next = 5;
384
+ case 1:
385
+ elvCrypto = _context0.sent;
386
+ _context0.next = 2;
388
387
  return Crypto.EncryptionContext(cap);
389
- case 5:
390
- _yield$Crypto$Encrypt2 = _context10.sent;
388
+ case 2:
389
+ _yield$Crypto$Encrypt2 = _context0.sent;
391
390
  context = _yield$Crypto$Encrypt2.context;
392
391
  type = _yield$Crypto$Encrypt2.type;
393
392
  stream = new Stream.PassThrough();
394
393
  decipher = elvCrypto.createDecipher(type, context);
395
- return _context10.abrupt("return", stream.pipe(decipher).on("finish", function () {
394
+ return _context0.abrupt("return", stream.pipe(decipher).on("finish", function () {
396
395
  context.free();
397
396
  }).on("error", function (e) {
398
397
  throw Error(e);
399
398
  }));
400
- case 11:
399
+ case 3:
401
400
  case "end":
402
- return _context10.stop();
401
+ return _context0.stop();
403
402
  }
404
- }, _callee10);
403
+ }, _callee0);
405
404
  }));
406
405
  function OpenDecryptionStream(_x6) {
407
406
  return _OpenDecryptionStream.apply(this, arguments);