@eluvio/elv-client-js 4.0.147 → 4.2.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
package/dist/src/Utils.js CHANGED
@@ -3,8 +3,8 @@ var _regeneratorRuntime = require("@babel/runtime/regenerator");
3
3
  var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
4
4
  var _defineProperty = require("@babel/runtime/helpers/defineProperty");
5
5
  var _slicedToArray = require("@babel/runtime/helpers/slicedToArray");
6
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
7
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
8
8
  if (typeof globalThis.Buffer === "undefined") {
9
9
  globalThis.Buffer = require("buffer/").Buffer;
10
10
  }
@@ -281,7 +281,6 @@ var Utils = {
281
281
  flags: flags // flags for part write token (tqp_)
282
282
  };
283
283
  },
284
-
285
284
  /**
286
285
  * Convert contract address to multiformat hash
287
286
  *
@@ -470,37 +469,37 @@ var Utils = {
470
469
  });
471
470
  },
472
471
  LimitedMap: function () {
473
- var _LimitedMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(limit, array, f) {
472
+ var _LimitedMap = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(limit, array, f) {
474
473
  var index, locked, nextIndex, results, active;
475
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
474
+ return _regeneratorRuntime.wrap(function (_context3) {
476
475
  while (1) switch (_context3.prev = _context3.next) {
477
476
  case 0:
478
477
  index = 0;
479
478
  locked = false;
480
479
  nextIndex = /*#__PURE__*/function () {
481
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
480
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
482
481
  var thisIndex;
483
- return _regeneratorRuntime.wrap(function _callee$(_context) {
482
+ return _regeneratorRuntime.wrap(function (_context) {
484
483
  while (1) switch (_context.prev = _context.next) {
485
484
  case 0:
486
485
  if (!locked) {
487
- _context.next = 5;
486
+ _context.next = 2;
488
487
  break;
489
488
  }
490
- _context.next = 3;
489
+ _context.next = 1;
491
490
  return new Promise(function (resolve) {
492
491
  return setTimeout(resolve, 10);
493
492
  });
494
- case 3:
493
+ case 1:
495
494
  _context.next = 0;
496
495
  break;
497
- case 5:
496
+ case 2:
498
497
  locked = true;
499
498
  thisIndex = index;
500
499
  index += 1;
501
500
  locked = false;
502
501
  return _context.abrupt("return", thisIndex);
503
- case 10:
502
+ case 3:
504
503
  case "end":
505
504
  return _context.stop();
506
505
  }
@@ -513,53 +512,53 @@ var Utils = {
513
512
  results = [];
514
513
  active = 0;
515
514
  return _context3.abrupt("return", new Promise(function (resolve, reject) {
516
- _toConsumableArray(Array(limit || 1)).forEach( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
517
- var index;
518
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
515
+ _toConsumableArray(Array(limit || 1)).forEach(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
516
+ var index, _t;
517
+ return _regeneratorRuntime.wrap(function (_context2) {
519
518
  while (1) switch (_context2.prev = _context2.next) {
520
519
  case 0:
521
520
  active += 1;
522
- _context2.next = 3;
521
+ _context2.next = 1;
523
522
  return nextIndex();
524
- case 3:
523
+ case 1:
525
524
  index = _context2.sent;
526
- case 4:
525
+ case 2:
527
526
  if (!(index < array.length)) {
528
- _context2.next = 19;
527
+ _context2.next = 8;
529
528
  break;
530
529
  }
531
- _context2.prev = 5;
532
- _context2.next = 8;
530
+ _context2.prev = 3;
531
+ _context2.next = 4;
533
532
  return f(array[index], index);
534
- case 8:
533
+ case 4:
535
534
  results[index] = _context2.sent;
536
- _context2.next = 14;
535
+ _context2.next = 6;
537
536
  break;
538
- case 11:
539
- _context2.prev = 11;
540
- _context2.t0 = _context2["catch"](5);
541
- reject(_context2.t0);
542
- case 14:
543
- _context2.next = 16;
537
+ case 5:
538
+ _context2.prev = 5;
539
+ _t = _context2["catch"](3);
540
+ reject(_t);
541
+ case 6:
542
+ _context2.next = 7;
544
543
  return nextIndex();
545
- case 16:
544
+ case 7:
546
545
  index = _context2.sent;
547
- _context2.next = 4;
546
+ _context2.next = 2;
548
547
  break;
549
- case 19:
548
+ case 8:
550
549
  // When finished and no more workers are active, resolve
551
550
  active -= 1;
552
551
  if (active === 0) {
553
552
  resolve(results);
554
553
  }
555
- case 21:
554
+ case 9:
556
555
  case "end":
557
556
  return _context2.stop();
558
557
  }
559
- }, _callee2, null, [[5, 11]]);
558
+ }, _callee2, null, [[3, 5]]);
560
559
  })));
561
560
  }));
562
- case 6:
561
+ case 1:
563
562
  case "end":
564
563
  return _context3.stop();
565
564
  }
@@ -579,20 +578,20 @@ var Utils = {
579
578
  * @return {*} - Result of parsing response body as JSON
580
579
  */
581
580
  ResponseToJson: function () {
582
- var _ResponseToJson = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(response) {
581
+ var _ResponseToJson = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(response) {
583
582
  var debug,
584
583
  logFn,
585
584
  _args4 = arguments;
586
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
585
+ return _regeneratorRuntime.wrap(function (_context4) {
587
586
  while (1) switch (_context4.prev = _context4.next) {
588
587
  case 0:
589
588
  debug = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : false;
590
589
  logFn = _args4.length > 2 ? _args4[2] : undefined;
591
- _context4.next = 4;
590
+ _context4.next = 1;
592
591
  return Utils.ResponseToFormat("json", response, debug, logFn);
593
- case 4:
592
+ case 1:
594
593
  return _context4.abrupt("return", _context4.sent);
595
- case 5:
594
+ case 2:
596
595
  case "end":
597
596
  return _context4.stop();
598
597
  }
@@ -613,60 +612,61 @@ var Utils = {
613
612
  * @return {*} - Result of converting response body into the requested format
614
613
  */
615
614
  ResponseToFormat: function () {
616
- var _ResponseToFormat = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(format, response) {
615
+ var _ResponseToFormat = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(format, response) {
617
616
  var debug,
618
617
  logFn,
619
618
  formattedBody,
620
- _args5 = arguments;
621
- return _regeneratorRuntime.wrap(function _callee5$(_context5) {
619
+ _args5 = arguments,
620
+ _t2;
621
+ return _regeneratorRuntime.wrap(function (_context5) {
622
622
  while (1) switch (_context5.prev = _context5.next) {
623
623
  case 0:
624
624
  debug = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : false;
625
625
  logFn = _args5.length > 3 ? _args5[3] : undefined;
626
- _context5.next = 4;
626
+ _context5.next = 1;
627
627
  return response;
628
- case 4:
628
+ case 1:
629
629
  response = _context5.sent;
630
- _context5.t0 = format.toLowerCase();
631
- _context5.next = _context5.t0 === "json" ? 8 : _context5.t0 === "text" ? 13 : _context5.t0 === "blob" ? 18 : _context5.t0 === "arraybuffer" ? 21 : _context5.t0 === "formdata" ? 24 : _context5.t0 === "buffer" ? 27 : 30;
630
+ _t2 = format.toLowerCase();
631
+ _context5.next = _t2 === "json" ? 2 : _t2 === "text" ? 4 : _t2 === "blob" ? 6 : _t2 === "arraybuffer" ? 8 : _t2 === "formdata" ? 10 : _t2 === "buffer" ? 12 : 14;
632
632
  break;
633
- case 8:
634
- _context5.next = 10;
633
+ case 2:
634
+ _context5.next = 3;
635
635
  return response.json();
636
- case 10:
636
+ case 3:
637
637
  formattedBody = _context5.sent;
638
638
  if (debug) logFn("response body: ".concat(JSON.stringify(formattedBody, null, 2)));
639
639
  return _context5.abrupt("return", formattedBody);
640
- case 13:
641
- _context5.next = 15;
640
+ case 4:
641
+ _context5.next = 5;
642
642
  return response.text();
643
- case 15:
643
+ case 5:
644
644
  formattedBody = _context5.sent;
645
645
  if (debug) logFn("response body: ".concat(formattedBody));
646
646
  return _context5.abrupt("return", formattedBody);
647
- case 18:
648
- _context5.next = 20;
647
+ case 6:
648
+ _context5.next = 7;
649
649
  return response.blob();
650
- case 20:
650
+ case 7:
651
651
  return _context5.abrupt("return", _context5.sent);
652
- case 21:
653
- _context5.next = 23;
652
+ case 8:
653
+ _context5.next = 9;
654
654
  return response.arrayBuffer();
655
- case 23:
655
+ case 9:
656
656
  return _context5.abrupt("return", _context5.sent);
657
- case 24:
658
- _context5.next = 26;
657
+ case 10:
658
+ _context5.next = 11;
659
659
  return response.formData();
660
- case 26:
660
+ case 11:
661
661
  return _context5.abrupt("return", _context5.sent);
662
- case 27:
663
- _context5.next = 29;
662
+ case 12:
663
+ _context5.next = 13;
664
664
  return response.buffer();
665
- case 29:
665
+ case 13:
666
666
  return _context5.abrupt("return", _context5.sent);
667
- case 30:
667
+ case 14:
668
668
  return _context5.abrupt("return", response);
669
- case 31:
669
+ case 15:
670
670
  case "end":
671
671
  return _context5.stop();
672
672
  }
@@ -27,11 +27,19 @@ exports.ValidateVersion = function (versionHash) {
27
27
  throw Error("Invalid version hash: ".concat(versionHash));
28
28
  }
29
29
  };
30
+
31
+ // Validates that write token is in valid format and is properly encoded.
32
+ // If objectId is also supplied, then write token's encoded object id is checked to make sure it matches
33
+ // the supplied object id.
30
34
  exports.ValidateWriteToken = function (writeToken) {
35
+ var objectId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
31
36
  if (!writeToken) {
32
37
  throw Error("Write token not specified");
33
- } else if (!writeToken.toString().startsWith("t")) {
34
- throw Error("Invalid write token: ".concat(writeToken));
38
+ } else {
39
+ var decoded = Utils.DecodeWriteToken(writeToken);
40
+ if (objectId && objectId !== decoded.objectId) {
41
+ throw Error("Object id (".concat(objectId, ") does not match the the id (").concat(decoded.objectId, ") decoded from write token (").concat(writeToken, ")"));
42
+ }
35
43
  }
36
44
  };
37
45
  exports.ValidatePartHash = function (partHash) {
@@ -80,36 +88,36 @@ exports.ValidateDate = function (date) {
80
88
  return new Date(date).getTime();
81
89
  };
82
90
  exports.ValidateUserWallet = /*#__PURE__*/function () {
83
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref2) {
91
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref2) {
84
92
  var address, client, walletAddress;
85
- return _regeneratorRuntime.wrap(function _callee$(_context) {
93
+ return _regeneratorRuntime.wrap(function (_context) {
86
94
  while (1) switch (_context.prev = _context.next) {
87
95
  case 0:
88
96
  address = _ref2.address, client = _ref2.client;
89
97
  if (address) {
90
- _context.next = 5;
98
+ _context.next = 1;
91
99
  break;
92
100
  }
93
101
  throw Error("Address not specified");
94
- case 5:
102
+ case 1:
95
103
  if (client) {
96
- _context.next = 7;
104
+ _context.next = 2;
97
105
  break;
98
106
  }
99
107
  throw Error("Client not specified");
100
- case 7:
101
- _context.next = 9;
108
+ case 2:
109
+ _context.next = 3;
102
110
  return client.userProfileClient.UserWalletAddress({
103
111
  address: address
104
112
  });
105
- case 9:
113
+ case 3:
106
114
  walletAddress = _context.sent;
107
115
  if (walletAddress) {
108
- _context.next = 12;
116
+ _context.next = 4;
109
117
  break;
110
118
  }
111
119
  throw Error("User address has no wallet: ".concat(address));
112
- case 12:
120
+ case 4:
113
121
  case "end":
114
122
  return _context.stop();
115
123
  }