@eluvio/elv-client-js 4.0.104 → 4.0.107

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 +9 -12
  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 +47 -28
  12. package/dist/src/ElvWallet.js +7 -5
  13. package/dist/src/EthClient.js +8 -9
  14. package/dist/src/FrameClient.js +8 -9
  15. package/dist/src/HttpClient.js +1 -2
  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 +194 -150
  20. package/dist/src/Utils.js +2 -3
  21. package/dist/src/abr_profiles/abr_profile_live_drm.js +22 -0
  22. package/dist/src/client/ABRPublishing.js +2 -2
  23. package/dist/src/client/AccessGroups.js +2 -2
  24. package/dist/src/client/ContentAccess.js +9 -6
  25. package/dist/src/client/ContentManagement.js +3 -3
  26. package/dist/src/client/Contracts.js +433 -108
  27. package/dist/src/client/Files.js +2 -2
  28. package/dist/src/client/LiveConf.js +60 -78
  29. package/dist/src/client/LiveStream.js +270 -158
  30. package/dist/src/client/NFT.js +2 -2
  31. package/dist/src/walletClient/ClientMethods.js +2 -2
  32. package/dist/src/walletClient/Profile.js +2 -2
  33. package/dist/src/walletClient/Utils.js +2 -2
  34. package/dist/src/walletClient/index.js +19 -16
  35. package/package.json +1 -1
  36. package/src/UserProfileClient.js +19 -20
  37. package/src/abr_profiles/abr_profile_live_drm.js +22 -0
  38. package/src/client/Contracts.js +244 -42
  39. package/src/client/LiveConf.js +86 -111
  40. package/src/client/LiveStream.js +141 -44
  41. package/testScripts/TestAddTenantContractId.js +45 -4
@@ -1,8 +1,8 @@
1
1
  var _regeneratorRuntime = require("@babel/runtime/regenerator");
2
2
  var _defineProperty = require("@babel/runtime/helpers/defineProperty");
3
3
  var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
4
- 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; }
5
- 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; }
4
+ 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; }
5
+ 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; }
6
6
  /**
7
7
  * Methods for creating and managing NFTs
8
8
  *
@@ -1,8 +1,8 @@
1
1
  var _defineProperty = require("@babel/runtime/helpers/defineProperty");
2
2
  var _regeneratorRuntime = require("@babel/runtime/regenerator");
3
3
  var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
4
- 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; }
5
- 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; }
4
+ 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; }
5
+ 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; }
6
6
  var Utils = require("../Utils");
7
7
  var UrlJoin = require("url-join");
8
8
  var _require = require("./Utils"),
@@ -2,8 +2,8 @@ var _defineProperty = require("@babel/runtime/helpers/defineProperty");
2
2
  var _typeof = require("@babel/runtime/helpers/typeof");
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
  var Utils = require("../Utils");
8
8
  var UrlJoin = require("url-join");
9
9
  var StateStorePath = function StateStorePath(_ref) {
@@ -2,8 +2,8 @@ var _regeneratorRuntime = require("@babel/runtime/regenerator");
2
2
  var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
3
3
  var _defineProperty = require("@babel/runtime/helpers/defineProperty");
4
4
  var _slicedToArray = require("@babel/runtime/helpers/slicedToArray");
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
  var Utils = require("../Utils");
8
8
  var RarityToPercentage = function RarityToPercentage(rarity) {
9
9
  if (!rarity) {
@@ -7,8 +7,8 @@ var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
7
7
  var _classCallCheck = require("@babel/runtime/helpers/classCallCheck");
8
8
  var _createClass = require("@babel/runtime/helpers/createClass");
9
9
  var _excluded = ["code", "address", "type", "authToken", "expiresAt"];
10
- 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; }
11
- 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; }
10
+ 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; }
11
+ 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; }
12
12
  var _require = require("../ElvClient"),
13
13
  ElvClient = _require.ElvClient;
14
14
  var Configuration = require("./Configuration");
@@ -79,7 +79,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
79
79
  this.utils = client.utils;
80
80
  this.ForbiddenMethods = ElvWalletClient.ForbiddenMethods;
81
81
  }
82
- _createClass(ElvWalletClient, [{
82
+ return _createClass(ElvWalletClient, [{
83
83
  key: "Log",
84
84
  value: function Log(message) {
85
85
  var error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
@@ -136,7 +136,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
136
136
  */
137
137
  }, {
138
138
  key: "PersonalSign",
139
- value: function () {
139
+ value: (function () {
140
140
  var _PersonalSign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref2) {
141
141
  var message, parameters, url;
142
142
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
@@ -265,7 +265,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
265
265
  return _PersonalSign.apply(this, arguments);
266
266
  }
267
267
  return PersonalSign;
268
- }()
268
+ }())
269
269
  }, {
270
270
  key: "LogInURL",
271
271
  value: function () {
@@ -344,7 +344,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
344
344
  */
345
345
  }, {
346
346
  key: "LogIn",
347
- value: function () {
347
+ value: (function () {
348
348
  var _LogIn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref5) {
349
349
  var _this = this;
350
350
  var _ref5$method, method, provider, _ref5$mode, mode, callbackUrl, marketplaceParams, _ref5$clearLogin, clearLogin, callback, loginUrl;
@@ -463,9 +463,10 @@ var ElvWalletClient = /*#__PURE__*/function () {
463
463
  *
464
464
  * @methodGroup Login
465
465
  */
466
+ )
466
467
  }, {
467
468
  key: "LogOut",
468
- value: function () {
469
+ value: (function () {
469
470
  var _LogOut = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
470
471
  return _regeneratorRuntime.wrap(function _callee8$(_context8) {
471
472
  while (1) switch (_context8.prev = _context8.next) {
@@ -508,7 +509,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
508
509
  return _LogOut.apply(this, arguments);
509
510
  }
510
511
  return LogOut;
511
- }()
512
+ }())
512
513
  }, {
513
514
  key: "TokenStatus",
514
515
  value: function () {
@@ -548,7 +549,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
548
549
  */
549
550
  }, {
550
551
  key: "Authenticate",
551
- value: function () {
552
+ value: (function () {
552
553
  var _Authenticate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref7) {
553
554
  var token, decodedToken;
554
555
  return _regeneratorRuntime.wrap(function _callee10$(_context10) {
@@ -614,9 +615,10 @@ var ElvWalletClient = /*#__PURE__*/function () {
614
615
  * - signingToken - Identical to `authToken`, but also includes the ability to perform arbitrary signatures with the custodial wallet. This token should be protected and should not be
615
616
  * shared with third parties.
616
617
  */
618
+ )
617
619
  }, {
618
620
  key: "AuthenticateOAuth",
619
- value: function () {
621
+ value: (function () {
620
622
  var _AuthenticateOAuth = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref8) {
621
623
  var idToken, tenantId, email, signerURIs, _ref8$shareEmail, shareEmail, _ref8$extraData, extraData, nonce, _ref8$createRemoteTok, createRemoteToken, _ref8$force, force, tokenDuration, fabricToken, expiresAt, tokenResponse, address, decodedToken;
622
624
  return _regeneratorRuntime.wrap(function _callee11$(_context11) {
@@ -653,6 +655,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
653
655
  return this.client.signer.RetrieveCSAT({
654
656
  email: email,
655
657
  nonce: nonce,
658
+ tenantId: tenantId,
656
659
  force: force
657
660
  });
658
661
  case 12:
@@ -743,9 +746,10 @@ var ElvWalletClient = /*#__PURE__*/function () {
743
746
  * @returns {Promise<string>} - Returns an authorization token that can be used to initialize the client using <a href="#Authenticate">Authenticate</a>.
744
747
  * Save this token to avoid having to reauthenticate. This token expires after 24 hours.
745
748
  */
749
+ )
746
750
  }, {
747
751
  key: "AuthenticateExternalWallet",
748
- value: function () {
752
+ value: (function () {
749
753
  var _AuthenticateExternalWallet = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref9) {
750
754
  var _this2 = this;
751
755
  var address, _ref9$tokenDuration, tokenDuration, _ref9$walletName, walletName, Sign, expiresAt, fabricToken;
@@ -814,6 +818,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
814
818
  *
815
819
  * @returns {string} - The client auth token
816
820
  */
821
+ )
817
822
  }, {
818
823
  key: "ClientAuthToken",
819
824
  value: function ClientAuthToken() {
@@ -1114,8 +1119,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
1114
1119
  produceLinkUrls: true,
1115
1120
  authorizationToken: this.publicStaticToken,
1116
1121
  noAuth: true,
1117
- select: ["info/marketplace_order", "tenants/*/.", "tenants/*/info/branding", "tenants/*/marketplaces/*/.", "tenants/*/marketplaces/*/info/tenant_id", "tenants/*/marketplaces/*/info/tenant_name", "tenants/*/marketplaces/*/info/branding", "tenants/*/marketplaces/*/info/storefront/background", "tenants/*/marketplaces/*/info/storefront/background_mobile"],
1118
- remove: ["tenants/*/info/branding/wallet_css", "tenants/*/marketplaces/*/info/branding/custom_css"]
1122
+ select: ["info/marketplace_order", "tenants/*/.", "tenants/*/info/branding/show", "tenants/*/info/branding/name", "tenants/*/marketplaces/*/.", "tenants/*/marketplaces/*/info/tenant_id", "tenants/*/marketplaces/*/info/tenant_name", "tenants/*/marketplaces/*/info/branding/show", "tenants/*/marketplaces/*/info/branding/name"]
1119
1123
  });
1120
1124
  case 5:
1121
1125
  metadata = _context18.sent;
@@ -1978,7 +1982,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
1978
1982
  */
1979
1983
  }, {
1980
1984
  key: "Initialize",
1981
- value: function () {
1985
+ value: (function () {
1982
1986
  var _Initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25(_ref24) {
1983
1987
  var client, _ref24$appId, appId, _ref24$network, network, _ref24$mode, mode, localization, marketplaceParams, previewMarketplaceId, _ref24$storeAuthToken, storeAuthToken, _ref24$skipMarketplac, skipMarketplaceLoad, _ref25, tenantSlug, marketplaceSlug, marketplaceId, marketplaceHash, previewMarketplaceHash, walletClient, url, savedToken;
1984
1988
  return _regeneratorRuntime.wrap(function _callee25$(_context25) {
@@ -2096,9 +2100,8 @@ var ElvWalletClient = /*#__PURE__*/function () {
2096
2100
  return _Initialize.apply(this, arguments);
2097
2101
  }
2098
2102
  return Initialize;
2099
- }()
2103
+ }())
2100
2104
  }]);
2101
- return ElvWalletClient;
2102
2105
  }();
2103
2106
  Object.assign(ElvWalletClient.prototype, require("./ClientMethods"));
2104
2107
  Object.assign(ElvWalletClient.prototype, require("./Profile"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eluvio/elv-client-js",
3
- "version": "4.0.104",
3
+ "version": "4.0.107",
4
4
  "description": "Javascript client for the Eluvio Content Fabric",
5
5
  "main": "src/index.js",
6
6
  "author": "Kevin Talmadge",
@@ -420,20 +420,20 @@ await client.userProfileClient.UserMetadata()
420
420
  }
421
421
 
422
422
  /**
423
- * Return the ID of the tenant this user belongs to, if set.
423
+ * Return the ID of the tenant admin group set for current user
424
424
  *
425
425
  * @return {Promise<string>} - Tenant ID
426
426
  */
427
427
  async TenantId() {
428
428
  if(!this.tenantId) {
429
- this.tenantId = await this.UserMetadata({metadataSubtree: "tenantId"});
429
+ const {objectId} = await this.UserWalletObjectInfo();
430
+ this.tenantId = await this.client.TenantId({ objectId });
430
431
  }
431
-
432
432
  return this.tenantId;
433
433
  }
434
434
 
435
435
  /**
436
- * Set the current user's tenant
436
+ * Set the current user's tenant admin group ID
437
437
  *
438
438
  * Note: This method is not accessible to applications. Eluvio core will drop the request.
439
439
  *
@@ -441,7 +441,8 @@ await client.userProfileClient.UserMetadata()
441
441
  * @param {string} id - The tenant ID in hash format
442
442
  * @param {string} address - The group address to use in the hash if id is not provided
443
443
  */
444
- async SetTenantId({id, address}) {
444
+ async SetTenantId({ id, address }) {
445
+
445
446
  if(id && (!id.startsWith("iten") || !Utils.ValidHash(id))) {
446
447
  throw Error(`Invalid tenant ID: ${id}`);
447
448
  }
@@ -454,19 +455,11 @@ await client.userProfileClient.UserMetadata()
454
455
  id = `iten${Utils.AddressToHash(address)}`;
455
456
  }
456
457
 
457
- try {
458
- const version = await this.client.AccessType({id});
459
-
460
- if(version !== this.client.authClient.ACCESS_TYPES.GROUP) {
461
- throw Error("Invalid tenant ID: " + id);
462
- }
463
- } catch(error) {
464
- throw Error("Invalid tenant ID: " + id);
465
- }
466
-
467
- await this.ReplaceUserMetadata({metadataSubtree: "tenantId", metadata: id});
458
+ const {objectId} = await this.UserWalletObjectInfo();
468
459
 
469
- this.tenantId = id;
460
+ const tenantInfo = await this.client.SetTenantId({ objectId, tenantId: id });
461
+ this.tenantContractId = tenantInfo.tenantContractId;
462
+ this.tenantId = tenantInfo.tenantId;
470
463
  }
471
464
 
472
465
  /**
@@ -477,9 +470,7 @@ await client.userProfileClient.UserMetadata()
477
470
  async TenantContractId() {
478
471
  if(!this.tenantContractId) {
479
472
  const {objectId} = await this.UserWalletObjectInfo();
480
- this.tenantContractId = await this.client.TenantContractId({
481
- contractAddress: this.client.utils.HashToAddress(objectId)
482
- });
473
+ this.tenantContractId = await this.client.TenantContractId({ objectId });
483
474
  }
484
475
  return this.tenantContractId;
485
476
  }
@@ -498,6 +489,14 @@ await client.userProfileClient.UserMetadata()
498
489
 
499
490
  const tenantInfo = await this.client.SetTenantContractId({ objectId,tenantContractId });
500
491
  this.tenantContractId = tenantInfo.tenantContractId;
492
+ this.tenantId = tenantInfo.tenantId;
493
+ }
494
+
495
+ async ResetTenantId(){
496
+ const {objectId} = await this.UserWalletObjectInfo();
497
+ await this.client.ResetTenantId({objectId});
498
+ this.tenantId = this.client.TenantId({objectId});
499
+ this.tenantContractId = this.client.TenantContractId({objectId});
501
500
  }
502
501
 
503
502
  /**
@@ -1863,6 +1863,28 @@ const AbrProfileLiveDrm = {
1863
1863
  }
1864
1864
  },
1865
1865
  "playout_formats": {
1866
+ "dash-playready-cenc": {
1867
+ "drm": {
1868
+ "enc_scheme_name": "cenc",
1869
+ "type": "DrmPlayReady"
1870
+ },
1871
+ "protocol": {
1872
+ "min_buffer_length": 2,
1873
+ "type": "ProtoDash"
1874
+ }
1875
+ },
1876
+ "dash-widevine": {
1877
+ "drm": {
1878
+ "content_id": "",
1879
+ "enc_scheme_name": "cenc",
1880
+ "license_servers": [],
1881
+ "type": "DrmWidevine"
1882
+ },
1883
+ "protocol": {
1884
+ "min_buffer_length": 2,
1885
+ "type": "ProtoDash"
1886
+ }
1887
+ },
1866
1888
  "hls-fairplay": {
1867
1889
  "drm": {
1868
1890
  "enc_scheme_name": "cbcs",
@@ -11,7 +11,8 @@ const {
11
11
  ValidateAddress,
12
12
  ValidateParameters,
13
13
  ValidatePresence,
14
- ValidateObject, ValidateVersion
14
+ ValidateObject,
15
+ ValidateVersion
15
16
  } = require("../Validation");
16
17
  const Utils=require("../Utils");
17
18
 
@@ -579,19 +580,7 @@ exports.SendFunds = async function({recipient, ether}) {
579
580
  return await transaction.wait();
580
581
  };
581
582
 
582
- /**
583
- * Retrieve the ID of the tenant contract for the specified object
584
- *
585
- * @methodGroup Tenant
586
- * @namedParams
587
- * @param {string=} contractAddress - The address of the object
588
- * @param {string=} objectId - The ID of the object
589
- * @param {string=} versionHash - A version hash of the object
590
- *
591
- * @returns {Promise<string|undefined>}
592
- */
593
- exports.TenantContractId = async function({contractAddress, objectId, versionHash}) {
594
-
583
+ const GetObjectIDAndContractAddress = async function({contractAddress, objectId, versionHash}){
595
584
  if(contractAddress){
596
585
  ValidateAddress(contractAddress);
597
586
  objectId = Utils.AddressToObjectId(contractAddress);
@@ -606,32 +595,165 @@ exports.TenantContractId = async function({contractAddress, objectId, versionHas
606
595
  throw Error("contractAddress or objectId or versionHash not specified");
607
596
  }
608
597
 
609
- const hasGetMetaMethod = await this.authClient.ContractHasMethod({
610
- contractAddress: contractAddress,
611
- methodName: "getMeta"
612
- });
598
+ return {
599
+ contractAddress,
600
+ objectId
601
+ };
602
+ };
603
+
604
+ /**
605
+ * Retrieve the ID of the tenant admin group set for the specified object
606
+ *
607
+ * @methodGroup Tenant
608
+ * @namedParams
609
+ * @param {string=} contractAddress - The address of the object
610
+ * @param {string=} objectId - The ID of the object
611
+ * @param {string=} versionHash - A version hash of the object
612
+ *
613
+ * @returns {Promise<string|undefined>}
614
+ */
615
+ exports.TenantId = async function({contractAddress, objectId, versionHash}) {
613
616
 
614
- if(hasGetMetaMethod) {
615
- const tenantContractId = await this.ContractMetadata({
616
- contractAddress:contractAddress,
617
- metadataKey:"_ELV_TENANT_ID"
617
+ objectInfo = await GetObjectIDAndContractAddress({contractAddress, objectId, versionHash});
618
+ contractAddress = objectInfo.contractAddress;
619
+ objectId = objectInfo.objectId;
620
+
621
+ let tenantId;
622
+ try {
623
+ const hasGetMetaMethod = await this.authClient.ContractHasMethod({
624
+ contractAddress: contractAddress,
625
+ methodName: "getMeta"
618
626
  });
619
- if(tenantContractId !== "") {
620
- return tenantContractId;
627
+
628
+ if(hasGetMetaMethod) {
629
+ tenantId = await this.ContractMetadata({
630
+ contractAddress:contractAddress,
631
+ metadataKey:"_tenantId"
632
+ });
621
633
  }
634
+
635
+ // If the getMeta method does not exist or is not set in the contract, check the fabric metadata.
636
+ if(tenantId === undefined) {
637
+ const libraryId = await this.ContentObjectLibraryId({ objectId });
638
+
639
+ tenantId = await this.ContentObjectMetadata({
640
+ libraryId,
641
+ objectId,
642
+ metadataSubtree: "tenantId",
643
+ });
644
+ }
645
+ return tenantId;
646
+ } catch(e) {
647
+ return "";
622
648
  }
649
+ };
623
650
 
624
- const libraryId = await this.ContentObjectLibraryId({ objectId });
651
+ /**
652
+ * Retrieve the ID of the tenant contract for the specified object
653
+ *
654
+ * @methodGroup Tenant
655
+ * @namedParams
656
+ * @param {string=} contractAddress - The address of the object
657
+ * @param {string=} objectId - The ID of the object
658
+ * @param {string=} versionHash - A version hash of the object
659
+ *
660
+ * @returns {Promise<string|undefined>}
661
+ */
662
+ exports.TenantContractId = async function({contractAddress, objectId, versionHash}) {
625
663
 
626
- return await this.ContentObjectMetadata({
627
- libraryId,
628
- objectId,
629
- metadataSubtree: "tenantContractId",
664
+ objectInfo = await GetObjectIDAndContractAddress({contractAddress, objectId, versionHash});
665
+ contractAddress = objectInfo.contractAddress;
666
+ objectId = objectInfo.objectId;
667
+
668
+ try {
669
+ const hasGetMetaMethod = await this.authClient.ContractHasMethod({
670
+ contractAddress: contractAddress,
671
+ methodName: "getMeta"
672
+ });
673
+ let tenantContractId;
674
+ if(hasGetMetaMethod) {
675
+ tenantContractId = await this.ContractMetadata({
676
+ contractAddress:contractAddress,
677
+ metadataKey:"_ELV_TENANT_ID"
678
+ });
679
+ }
680
+
681
+ // If the getMeta method does not exist or is not set in the contract, check the fabric metadata.
682
+ if(tenantContractId === undefined) {
683
+ const libraryId = await this.ContentObjectLibraryId({ objectId });
684
+
685
+ tenantContractId = await this.ContentObjectMetadata({
686
+ libraryId,
687
+ objectId,
688
+ metadataSubtree: "tenantContractId",
689
+ });
690
+ }
691
+ return tenantContractId;
692
+ } catch(e) {
693
+ return "";
694
+ }
695
+ };
696
+
697
+ /**
698
+ * Set the tenant contract ID and tenant admin group ID for the specified object
699
+ * when tenant admin group ID is provided
700
+ *
701
+ * @methodGroup Tenant
702
+ * @namedParams
703
+ * @param {string=} contractAddress - The address of the object
704
+ * @param {string=} objectId - The ID of the object
705
+ * @param {string=} versionHash - A version hash of the object
706
+ * @param {string} tenantContractId - The tenant contract ID to set
707
+ * @param {string} tenantId - The tenant ID to set
708
+ *
709
+ * @returns {Promise<{tenantId: (undefined|string), tenantContractId}>}
710
+ */
711
+ exports.SetTenantId = async function({contractAddress, objectId, versionHash, tenantId}) {
712
+ objectInfo = await GetObjectIDAndContractAddress({contractAddress, objectId, versionHash});
713
+ contractAddress = objectInfo.contractAddress;
714
+ objectId = objectInfo.objectId;
715
+
716
+ const objectVersion = await this.authClient.AccessType(objectId);
717
+ if(objectVersion !== this.authClient.ACCESS_TYPES.GROUP &&
718
+ objectVersion !== this.authClient.ACCESS_TYPES.WALLET &&
719
+ objectVersion !== this.authClient.ACCESS_TYPES.LIBRARY &&
720
+ objectVersion !== this.authClient.ACCESS_TYPES.TYPE &&
721
+ objectVersion !== this.authClient.ACCESS_TYPES.TENANT) {
722
+ throw Error(`Invalid object ID: ${objectId},
723
+ applicable only for wallet,group, library or content_type object.`);
724
+ }
725
+
726
+ ValidateObject(tenantId);
727
+
728
+ if(!tenantId.startsWith("iten") || !Utils.ValidHash(tenantId)) {
729
+ throw Error(`Invalid tenant ID: ${tenantId}`);
730
+ }
731
+
732
+ const version = await this.authClient.AccessType(tenantId);
733
+ if(version !== this.authClient.ACCESS_TYPES.GROUP) {
734
+ throw Error("Invalid tenant ID: " + tenantId);
735
+ }
736
+
737
+ // get tenantContractId set for the tenant admin group
738
+ tenantContractId = await this.TenantContractId({
739
+ objectId: tenantId
630
740
  });
741
+ if(tenantContractId){
742
+ return await this.SetTenantContractId({
743
+ contractAddress,
744
+ objectId,
745
+ versionHash,
746
+ tenantContractId
747
+ });
748
+ } else {
749
+ throw Error("Invalid tenantId: tenant contract id not found");
750
+ }
631
751
  };
632
752
 
753
+
633
754
  /**
634
- * Set the tenant contract ID for the specified object
755
+ * Set the tenant contract ID and tenant admin group ID for the specified object
756
+ * when tenant contract ID is provided
635
757
  *
636
758
  * @methodGroup Tenant
637
759
  * @namedParams
@@ -644,19 +766,20 @@ exports.TenantContractId = async function({contractAddress, objectId, versionHas
644
766
  */
645
767
  exports.SetTenantContractId = async function({contractAddress, objectId, versionHash, tenantContractId}) {
646
768
 
647
- if(contractAddress){
648
- ValidateAddress(contractAddress);
649
- objectId = Utils.AddressToObjectId(contractAddress);
650
- } else if(versionHash){
651
- ValidateVersion(versionHash);
652
- objectId = this.utils.DecodeVersionHash(versionHash).objectId;
653
- contractAddress = Utils.HashToAddress(objectId);
654
- } else if(objectId){
655
- ValidateObject(objectId);
656
- contractAddress=Utils.HashToAddress(objectId);
657
- } else {
658
- throw Error("contractAddress or objectId or versionHash not specified");
769
+ objectInfo = await GetObjectIDAndContractAddress({contractAddress, objectId, versionHash});
770
+ contractAddress = objectInfo.contractAddress;
771
+ objectId = objectInfo.objectId;
772
+
773
+ const objectVersion = await this.authClient.AccessType(objectId);
774
+ if(objectVersion !== this.authClient.ACCESS_TYPES.GROUP &&
775
+ objectVersion !== this.authClient.ACCESS_TYPES.WALLET &&
776
+ objectVersion !== this.authClient.ACCESS_TYPES.LIBRARY &&
777
+ objectVersion !== this.authClient.ACCESS_TYPES.TYPE &&
778
+ objectVersion !== this.authClient.ACCESS_TYPES.TENANT) {
779
+ throw Error(`Invalid object ID: ${objectId},
780
+ applicable only for wallet,group, library or content_type object.`);
659
781
  }
782
+
660
783
  ValidateObject(tenantContractId);
661
784
 
662
785
  if(tenantContractId && (!tenantContractId.startsWith("iten") || !Utils.ValidHash(tenantContractId))) {
@@ -727,3 +850,82 @@ exports.SetTenantContractId = async function({contractAddress, objectId, version
727
850
  tenantId: !tenantAdminGroupAddress ? undefined : `iten${Utils.AddressToHash(tenantAdminGroupAddress)}`
728
851
  };
729
852
  };
853
+
854
+ /**
855
+ * Remove the tenant contract ID and tenant admin group ID for the specified object
856
+ *
857
+ * @methodGroup Tenant
858
+ * @namedParams
859
+ * @param {string=} contractAddress - The address of the object
860
+ * @param {string=} objectId - The ID of the object
861
+ * @param {string=} versionHash - A version hash of the object
862
+ *
863
+ * @returns {Promise<void>}
864
+ */
865
+ exports.ResetTenantId = async function({contractAddress, objectId, versionHash}) {
866
+
867
+ objectInfo = await GetObjectIDAndContractAddress({contractAddress, objectId, versionHash});
868
+ contractAddress = objectInfo.contractAddress;
869
+ objectId = objectInfo.objectId;
870
+
871
+ const objectVersion = await this.authClient.AccessType(objectId);
872
+ if(objectVersion !== this.authClient.ACCESS_TYPES.GROUP &&
873
+ objectVersion !== this.authClient.ACCESS_TYPES.WALLET &&
874
+ objectVersion !== this.authClient.ACCESS_TYPES.LIBRARY &&
875
+ objectVersion !== this.authClient.ACCESS_TYPES.TYPE &&
876
+ objectVersion !== this.authClient.ACCESS_TYPES.TENANT) {
877
+ throw Error(`Invalid object ID: ${objectId},
878
+ applicable only for wallet,group, library or content_type object.`);
879
+ }
880
+
881
+ let tenantContractId = this.TenantContractId({objectId});
882
+ let tenantId = this.TenantId({objectId});
883
+
884
+ if(tenantContractId || tenantId){
885
+ const hasPutMetaMethod = await this.authClient.ContractHasMethod({
886
+ contractAddress: contractAddress,
887
+ methodName: "putMeta"
888
+ });
889
+
890
+ if(hasPutMetaMethod) {
891
+
892
+ await this.ReplaceContractMetadata({
893
+ contractAddress: contractAddress,
894
+ metadataKey: "_ELV_TENANT_ID",
895
+ metadata: ""
896
+ });
897
+
898
+ await this.ReplaceContractMetadata({
899
+ contractAddress: contractAddress,
900
+ metadataKey: "_tenantId",
901
+ metadata: ""
902
+ });
903
+
904
+ } else {
905
+ const libraryId = await this.ContentObjectLibraryId({ objectId });
906
+ const editRequest = await this.EditContentObject({libraryId, objectId});
907
+
908
+ await this.MergeMetadata({
909
+ libraryId,
910
+ objectId,
911
+ writeToken: editRequest.write_token,
912
+ metadata: {
913
+ tenantContractId: undefined,
914
+ tenantId: undefined
915
+ },
916
+ });
917
+
918
+ await this.FinalizeContentObject({
919
+ libraryId,
920
+ objectId,
921
+ writeToken: editRequest.write_token,
922
+ commitMessage: "remove tenant_contract_id"
923
+ });
924
+ }
925
+ } else {
926
+ // eslint-disable-next-line no-console
927
+ console.warn("No tenant ID associated with current tenant.");
928
+ }
929
+ };
930
+
931
+