@eluvio/elv-client-js 4.0.143 → 4.0.145

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 (41) hide show
  1. package/dist/ElvClient-min.js +15 -14
  2. package/dist/ElvClient-node-min.js +14 -13
  3. package/dist/ElvFrameClient-min.js +10 -10
  4. package/dist/ElvPermissionsClient-min.js +9 -9
  5. package/dist/ElvWalletClient-min.js +15 -14
  6. package/dist/ElvWalletClient-node-min.js +14 -13
  7. package/dist/src/AuthorizationClient.js +11 -14
  8. package/dist/src/ContentObjectAudit.js +3 -3
  9. package/dist/src/ContentObjectVerification.js +3 -3
  10. package/dist/src/Crypto.js +2 -2
  11. package/dist/src/ElvClient.js +532 -401
  12. package/dist/src/ElvWallet.js +7 -5
  13. package/dist/src/EthClient.js +9 -10
  14. package/dist/src/FrameClient.js +10 -11
  15. package/dist/src/HttpClient.js +5 -5
  16. package/dist/src/Id.js +1 -2
  17. package/dist/src/PermissionsClient.js +31 -19
  18. package/dist/src/RemoteSigner.js +10 -11
  19. package/dist/src/UserProfileClient.js +35 -20
  20. package/dist/src/Utils.js +2 -3
  21. package/dist/src/Validation.js +10 -2
  22. package/dist/src/client/ABRPublishing.js +438 -238
  23. package/dist/src/client/AccessGroups.js +2 -2
  24. package/dist/src/client/ContentAccess.js +281 -344
  25. package/dist/src/client/ContentManagement.js +100 -84
  26. package/dist/src/client/Contracts.js +430 -2
  27. package/dist/src/client/Files.js +2 -2
  28. package/dist/src/client/LiveConf.js +43 -26
  29. package/dist/src/client/LiveStream.js +65 -63
  30. package/dist/src/client/NFT.js +2 -2
  31. package/dist/src/client/Shares.js +47 -24
  32. package/dist/src/walletClient/ClientMethods.js +2 -2
  33. package/dist/src/walletClient/Profile.js +2 -2
  34. package/dist/src/walletClient/Utils.js +2 -2
  35. package/dist/src/walletClient/index.js +359 -280
  36. package/package.json +2 -2
  37. package/src/FrameClient.js +1 -0
  38. package/src/Validation.js +9 -3
  39. package/src/client/ABRPublishing.js +176 -160
  40. package/src/client/Contracts.js +258 -0
  41. package/src/walletClient/index.js +13 -0
@@ -2,8 +2,8 @@ var _typeof = require("@babel/runtime/helpers/typeof");
2
2
  var _defineProperty = require("@babel/runtime/helpers/defineProperty");
3
3
  var _regeneratorRuntime = require("@babel/runtime/regenerator");
4
4
  var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
5
- 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; }
6
- 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; }
5
+ 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; }
6
+ 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; }
7
7
  /**
8
8
  * Methods for managing content types, libraries and objects
9
9
  *
@@ -421,11 +421,11 @@ exports.CreateContentType = /*#__PURE__*/function () {
421
421
  * @param {string} name - Library name
422
422
  * @param {string=} description - Library description
423
423
  * @param {blob=} image - Image associated with the library
424
- * @param {string=} - imageName - Name of the image associated with the library (required if image specified)
424
+ * @param {string=} imageName - Name of the image associated with the library (required if image specified)
425
425
  * @param {Object=} metadata - Metadata of library object
426
426
  * @param {string=} kmsId - ID of the KMS to use for content in this library. If not specified,
427
427
  * the default KMS will be used.
428
- * @param {string=} tenantId - ID of the tenant to use for this library
428
+ * @param {string=} tenantContractId - ID of the tenant to use for this library
429
429
  *
430
430
  * @returns {Promise<string>} - Library ID of created library
431
431
  */
@@ -657,32 +657,17 @@ exports.SetContentObjectImage = /*#__PURE__*/function () {
657
657
  */
658
658
  exports.DeleteContentLibrary = /*#__PURE__*/function () {
659
659
  var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref14) {
660
- var libraryId, path, authorizationHeader;
660
+ var libraryId;
661
661
  return _regeneratorRuntime.wrap(function _callee8$(_context8) {
662
662
  while (1) switch (_context8.prev = _context8.next) {
663
663
  case 0:
664
664
  libraryId = _ref14.libraryId;
665
- throw Error("Not supported");
666
- case 6:
667
- authorizationHeader = _context8.sent;
668
- _context8.next = 9;
669
- return this.CallContractMethodAndWait({
670
- contractAddress: this.utils.HashToAddress(libraryId),
671
- methodName: "kill",
672
- methodArgs: []
673
- });
674
- case 9:
675
- _context8.next = 11;
676
- return this.HttpClient.Request({
677
- headers: authorizationHeader,
678
- method: "DELETE",
679
- path: path
680
- });
681
- case 11:
665
+ throw Error("Delete library not supported. (".concat(libraryId, ")"));
666
+ case 2:
682
667
  case "end":
683
668
  return _context8.stop();
684
669
  }
685
- }, _callee8, this);
670
+ }, _callee8);
686
671
  }));
687
672
  return function (_x8) {
688
673
  return _ref15.apply(this, arguments);
@@ -828,7 +813,11 @@ exports.RemoveLibraryContentType = /*#__PURE__*/function () {
828
813
  *
829
814
  * meta: Metadata to use for the new object
830
815
  *
831
- * @returns {Promise<Object>} - Response containing the object ID and write token of the draft
816
+ * noEncryptionConk: Set to true to prevent creation of an encryption conk for the object
817
+ *
818
+ * createKMSConk: Set to true to create a KMS conk for object (usually for sharing a playable object) (incompatible with noEncryptionConk: true)
819
+ *
820
+ * @returns {Promise<Object>} - Response containing the object ID and write token of the draft, as well as the url of the node that created the write token.
832
821
  */
833
822
  exports.CreateContentObject = /*#__PURE__*/function () {
834
823
  var _ref21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref20) {
@@ -842,143 +831,165 @@ exports.CreateContentObject = /*#__PURE__*/function () {
842
831
  ValidateObject(objectId);
843
832
  }
844
833
  this.Log("Creating content object: ".concat(libraryId, " ").concat(objectId || ""));
845
-
846
- // Look up content type, if specified
834
+ if (!(options.noEncryptionConk && options.createKMSConk)) {
835
+ _context11.next = 6;
836
+ break;
837
+ }
838
+ throw new Error("Incompatible options: noEncryptionConk and createKMSConk both set to true");
839
+ case 6:
847
840
  if (!options.type) {
848
- _context11.next = 26;
841
+ _context11.next = 28;
849
842
  break;
850
843
  }
851
844
  this.Log("Type specified: ".concat(options.type));
852
845
  type = options.type;
853
846
  if (!type.startsWith("hq__")) {
854
- _context11.next = 13;
847
+ _context11.next = 15;
855
848
  break;
856
849
  }
857
- _context11.next = 10;
850
+ _context11.next = 12;
858
851
  return this.ContentType({
859
852
  versionHash: type
860
853
  });
861
- case 10:
854
+ case 12:
862
855
  type = _context11.sent;
863
- _context11.next = 22;
856
+ _context11.next = 24;
864
857
  break;
865
- case 13:
858
+ case 15:
866
859
  if (!type.startsWith("iq__")) {
867
- _context11.next = 19;
860
+ _context11.next = 21;
868
861
  break;
869
862
  }
870
- _context11.next = 16;
863
+ _context11.next = 18;
871
864
  return this.ContentType({
872
865
  typeId: type
873
866
  });
874
- case 16:
867
+ case 18:
875
868
  type = _context11.sent;
876
- _context11.next = 22;
869
+ _context11.next = 24;
877
870
  break;
878
- case 19:
879
- _context11.next = 21;
871
+ case 21:
872
+ _context11.next = 23;
880
873
  return this.ContentType({
881
874
  name: type
882
875
  });
883
- case 21:
876
+ case 23:
884
877
  type = _context11.sent;
885
- case 22:
878
+ case 24:
886
879
  if (type) {
887
- _context11.next = 24;
880
+ _context11.next = 26;
888
881
  break;
889
882
  }
890
883
  throw Error("Unable to find content type '".concat(options.type, "'"));
891
- case 24:
884
+ case 26:
892
885
  typeId = type.id;
893
886
  options.type = type.hash;
894
- case 26:
887
+ case 28:
895
888
  if (objectId) {
896
- _context11.next = 44;
889
+ _context11.next = 46;
897
890
  break;
898
891
  }
899
- _context11.next = 29;
892
+ _context11.next = 31;
900
893
  return this.CurrentAccountAddress();
901
- case 29:
894
+ case 31:
902
895
  currentAccountAddress = _context11.sent;
903
- _context11.next = 32;
896
+ _context11.next = 34;
904
897
  return this.CallContractMethod({
905
898
  contractAddress: this.utils.HashToAddress(libraryId),
906
899
  methodName: "canContribute",
907
900
  methodArgs: [currentAccountAddress]
908
901
  });
909
- case 32:
902
+ case 34:
910
903
  canContribute = _context11.sent;
911
904
  if (canContribute) {
912
- _context11.next = 35;
905
+ _context11.next = 37;
913
906
  break;
914
907
  }
915
908
  throw Error("Current user does not have permission to create content in library ".concat(libraryId));
916
- case 35:
909
+ case 37:
917
910
  this.Log("Deploying contract...");
918
- _context11.next = 38;
911
+ _context11.next = 40;
919
912
  return this.authClient.CreateContentObject({
920
913
  libraryId: libraryId,
921
914
  typeId: typeId
922
915
  });
923
- case 38:
916
+ case 40:
924
917
  _yield$this$authClien3 = _context11.sent;
925
918
  contractAddress = _yield$this$authClien3.contractAddress;
926
919
  objectId = this.utils.AddressToObjectId(contractAddress);
927
920
  this.Log("Contract deployed: ".concat(contractAddress, " ").concat(objectId));
928
- _context11.next = 51;
921
+ _context11.next = 53;
929
922
  break;
930
- case 44:
923
+ case 46:
931
924
  _context11.t0 = this;
932
925
  _context11.t1 = "Contract already deployed for contract type: ";
933
- _context11.next = 48;
926
+ _context11.next = 50;
934
927
  return this.AccessType({
935
928
  id: objectId
936
929
  });
937
- case 48:
930
+ case 50:
938
931
  _context11.t2 = _context11.sent;
939
932
  _context11.t3 = _context11.t1.concat.call(_context11.t1, _context11.t2);
940
933
  _context11.t0.Log.call(_context11.t0, _context11.t3);
941
- case 51:
934
+ case 53:
942
935
  if (!options.visibility) {
943
- _context11.next = 55;
936
+ _context11.next = 57;
944
937
  break;
945
938
  }
946
939
  this.Log("Setting visibility to ".concat(options.visibility));
947
- _context11.next = 55;
940
+ _context11.next = 57;
948
941
  return this.SetVisibility({
949
942
  id: objectId,
950
943
  visibility: options.visibility
951
944
  });
952
- case 55:
945
+ case 57:
953
946
  path = UrlJoin("qid", objectId);
954
947
  _context11.t4 = this.HttpClient;
955
- _context11.next = 59;
948
+ _context11.next = 61;
956
949
  return this.authClient.AuthorizationHeader({
957
950
  libraryId: libraryId,
958
951
  objectId: objectId,
959
952
  update: true
960
953
  });
961
- case 59:
954
+ case 61:
962
955
  _context11.t5 = _context11.sent;
963
956
  _context11.t6 = path;
964
- _context11.t7 = options;
957
+ _context11.t7 = {
958
+ // filter out options not recognized by server (noEncryptionConk, createKMSConk)
959
+ type: options.type,
960
+ meta: options.meta,
961
+ copy_from: options.copy_from
962
+ };
965
963
  _context11.t8 = {
966
964
  headers: _context11.t5,
967
965
  method: "POST",
968
966
  path: _context11.t6,
969
967
  body: _context11.t7
970
968
  };
971
- _context11.next = 65;
969
+ _context11.next = 67;
972
970
  return _context11.t4.Request.call(_context11.t4, _context11.t8);
973
- case 65:
971
+ case 67:
974
972
  rawCreateResponse = _context11.sent;
975
973
  // extract the url for the node that handled the request
976
- // TODO: remove/simplify after we start using /nodes API call to get node URLs for write tokens
974
+ // (not strictly needed now that we can quickly look up node URL for a write token,
975
+ // but still convenient)
977
976
  nodeUrl = new URL(rawCreateResponse.url).origin;
978
- _context11.next = 69;
977
+ _context11.next = 71;
979
978
  return this.utils.ResponseToJson(rawCreateResponse, this.HttpClient.debug, this.HttpClient.Log.bind(this.HttpClient));
980
- case 69:
979
+ case 71:
981
980
  createResponse = _context11.sent;
981
+ if (options.noEncryptionConk) {
982
+ _context11.next = 75;
983
+ break;
984
+ }
985
+ _context11.next = 75;
986
+ return this.CreateEncryptionConk({
987
+ libraryId: libraryId,
988
+ objectId: objectId,
989
+ writeToken: createResponse.write_token,
990
+ createKMSConk: !!options.createKMSConk // make sure `undefined` gets converted to `false`
991
+ });
992
+ case 75:
982
993
  // Record the node used in creating this write token
983
994
  this.RecordWriteToken({
984
995
  writeToken: createResponse.write_token,
@@ -988,7 +999,7 @@ exports.CreateContentObject = /*#__PURE__*/function () {
988
999
  createResponse.objectId = createResponse.id;
989
1000
  createResponse.nodeUrl = nodeUrl;
990
1001
  return _context11.abrupt("return", createResponse);
991
- case 75:
1002
+ case 80:
992
1003
  case "end":
993
1004
  return _context11.stop();
994
1005
  }
@@ -1838,7 +1849,7 @@ exports.PublishContentVersion = /*#__PURE__*/function () {
1838
1849
  h = void 0;
1839
1850
  _context21.prev = 53;
1840
1851
  _context21.next = 56;
1841
- return this.LatestVersionHashV2({
1852
+ return this.LatestVersionHash({
1842
1853
  objectId: objectId
1843
1854
  });
1844
1855
  case 56:
@@ -2303,7 +2314,7 @@ exports.UpdateContentObjectGraph = /*#__PURE__*/function () {
2303
2314
  return _context30.delegateYield(_loop(), "t0", 8);
2304
2315
  case 8:
2305
2316
  _ret = _context30.t0;
2306
- if (!(_typeof(_ret) === "object")) {
2317
+ if (!_ret) {
2307
2318
  _context30.next = 11;
2308
2319
  break;
2309
2320
  }
@@ -2451,12 +2462,12 @@ exports.CreateLinks = /*#__PURE__*/function () {
2451
2462
  return _regeneratorRuntime.wrap(function _callee31$(_context32) {
2452
2463
  while (1) switch (_context32.prev = _context32.next) {
2453
2464
  case 0:
2454
- path = info.path.replace(/^(\/|\.)+/, "");
2465
+ path = info.path.replace(/^([/.])+/, "");
2455
2466
  type = (info.type || "file") === "file" ? "files" : info.type;
2456
2467
  if (type === "metadata") {
2457
2468
  type = "meta";
2458
2469
  }
2459
- target = authTarget = info.target.replace(/^(\/|\.)+/, "");
2470
+ target = authTarget = info.target.replace(/^([/.])+/, "");
2460
2471
  if (info.targetHash) {
2461
2472
  target = "/qfab/".concat(info.targetHash, "/").concat(type, "/").concat(target);
2462
2473
  } else {
@@ -2637,38 +2648,43 @@ exports.SetAuthPolicy = /*#__PURE__*/function () {
2637
2648
  *
2638
2649
  * @namedParams
2639
2650
  * @param {string} writeToken - Write token to delete
2640
- * @param {string} libraryId - ID of the library
2641
2651
  */
2642
2652
  exports.DeleteWriteToken = /*#__PURE__*/function () {
2643
2653
  var _ref65 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee35(_ref64) {
2644
- var writeToken, libraryId, path, authorizationHeader;
2654
+ var writeToken, objectId, libraryId, path, authorizationHeader;
2645
2655
  return _regeneratorRuntime.wrap(function _callee35$(_context36) {
2646
2656
  while (1) switch (_context36.prev = _context36.next) {
2647
2657
  case 0:
2648
- writeToken = _ref64.writeToken, libraryId = _ref64.libraryId;
2658
+ writeToken = _ref64.writeToken;
2649
2659
  ValidateWriteToken(writeToken);
2650
- ValidateLibrary(libraryId);
2660
+ objectId = this.utils.DecodeWriteToken(writeToken).objectId;
2661
+ _context36.next = 5;
2662
+ return this.ContentObjectLibraryId({
2663
+ objectId: objectId
2664
+ });
2665
+ case 5:
2666
+ libraryId = _context36.sent;
2651
2667
  path = UrlJoin("qlibs", libraryId, "q", writeToken);
2652
- _context36.next = 6;
2668
+ _context36.next = 9;
2653
2669
  return this.authClient.AuthorizationHeader({
2654
- libraryId: libraryId,
2670
+ objectId: objectId,
2655
2671
  update: true
2656
2672
  });
2657
- case 6:
2673
+ case 9:
2658
2674
  authorizationHeader = _context36.sent;
2659
- _context36.next = 9;
2675
+ _context36.next = 12;
2660
2676
  return this.HttpClient.Request({
2661
2677
  headers: authorizationHeader,
2662
2678
  method: "DELETE",
2663
2679
  path: path,
2664
2680
  allowFailover: false
2665
2681
  });
2666
- case 9:
2667
- _context36.next = 11;
2682
+ case 12:
2683
+ _context36.next = 14;
2668
2684
  return this.HttpClient.ClearWriteToken({
2669
2685
  writeToken: writeToken
2670
2686
  });
2671
- case 11:
2687
+ case 14:
2672
2688
  case "end":
2673
2689
  return _context36.stop();
2674
2690
  }