@eluvio/elv-client-js 4.0.105 → 4.0.108
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ElvClient-min.js +14 -15
- package/dist/ElvClient-node-min.js +13 -14
- package/dist/ElvFrameClient-min.js +10 -10
- package/dist/ElvPermissionsClient-min.js +9 -9
- package/dist/ElvWalletClient-min.js +14 -15
- package/dist/ElvWalletClient-node-min.js +13 -14
- package/dist/src/AuthorizationClient.js +12 -9
- package/dist/src/ContentObjectAudit.js +3 -3
- package/dist/src/ContentObjectVerification.js +3 -3
- package/dist/src/Crypto.js +2 -2
- package/dist/src/ElvClient.js +28 -47
- package/dist/src/ElvWallet.js +5 -7
- package/dist/src/EthClient.js +9 -8
- package/dist/src/FrameClient.js +9 -8
- package/dist/src/HttpClient.js +2 -1
- package/dist/src/Id.js +2 -1
- package/dist/src/PermissionsClient.js +19 -31
- package/dist/src/RemoteSigner.js +8 -6
- package/dist/src/UserProfileClient.js +180 -167
- package/dist/src/Utils.js +3 -2
- package/dist/src/Validation.js +1 -13
- package/dist/src/client/ABRPublishing.js +2 -2
- package/dist/src/client/AccessGroups.js +2 -2
- package/dist/src/client/ContentAccess.js +3 -2
- package/dist/src/client/ContentManagement.js +3 -3
- package/dist/src/client/Contracts.js +433 -108
- package/dist/src/client/Files.js +2 -2
- package/dist/src/client/LiveConf.js +6 -4
- package/dist/src/client/LiveStream.js +231 -136
- package/dist/src/client/NFT.js +2 -2
- package/dist/src/walletClient/ClientMethods.js +2 -2
- package/dist/src/walletClient/Profile.js +2 -2
- package/dist/src/walletClient/Utils.js +2 -2
- package/dist/src/walletClient/index.js +14 -17
- package/package.json +1 -1
- package/src/UserProfileClient.js +20 -21
- package/src/Validation.js +0 -6
- package/src/client/Contracts.js +244 -42
- package/src/client/LiveConf.js +1 -1
- package/src/client/LiveStream.js +122 -44
- package/testScripts/TestAddTenantContractId.js +45 -4
package/dist/src/client/NFT.js
CHANGED
|
@@ -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(
|
|
5
|
-
function _objectSpread(
|
|
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; }
|
|
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(
|
|
5
|
-
function _objectSpread(
|
|
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; }
|
|
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(
|
|
6
|
-
function _objectSpread(
|
|
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; }
|
|
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(
|
|
6
|
-
function _objectSpread(
|
|
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; }
|
|
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(
|
|
11
|
-
function _objectSpread(
|
|
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; }
|
|
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
|
-
|
|
82
|
+
_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:
|
|
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:
|
|
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,10 +463,9 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
463
463
|
*
|
|
464
464
|
* @methodGroup Login
|
|
465
465
|
*/
|
|
466
|
-
)
|
|
467
466
|
}, {
|
|
468
467
|
key: "LogOut",
|
|
469
|
-
value:
|
|
468
|
+
value: function () {
|
|
470
469
|
var _LogOut = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
|
|
471
470
|
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
472
471
|
while (1) switch (_context8.prev = _context8.next) {
|
|
@@ -509,7 +508,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
509
508
|
return _LogOut.apply(this, arguments);
|
|
510
509
|
}
|
|
511
510
|
return LogOut;
|
|
512
|
-
}()
|
|
511
|
+
}()
|
|
513
512
|
}, {
|
|
514
513
|
key: "TokenStatus",
|
|
515
514
|
value: function () {
|
|
@@ -549,7 +548,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
549
548
|
*/
|
|
550
549
|
}, {
|
|
551
550
|
key: "Authenticate",
|
|
552
|
-
value:
|
|
551
|
+
value: function () {
|
|
553
552
|
var _Authenticate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref7) {
|
|
554
553
|
var token, decodedToken;
|
|
555
554
|
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
@@ -615,10 +614,9 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
615
614
|
* - 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
|
|
616
615
|
* shared with third parties.
|
|
617
616
|
*/
|
|
618
|
-
)
|
|
619
617
|
}, {
|
|
620
618
|
key: "AuthenticateOAuth",
|
|
621
|
-
value:
|
|
619
|
+
value: function () {
|
|
622
620
|
var _AuthenticateOAuth = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref8) {
|
|
623
621
|
var idToken, tenantId, email, signerURIs, _ref8$shareEmail, shareEmail, _ref8$extraData, extraData, nonce, _ref8$createRemoteTok, createRemoteToken, _ref8$force, force, tokenDuration, fabricToken, expiresAt, tokenResponse, address, decodedToken;
|
|
624
622
|
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
@@ -746,10 +744,9 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
746
744
|
* @returns {Promise<string>} - Returns an authorization token that can be used to initialize the client using <a href="#Authenticate">Authenticate</a>.
|
|
747
745
|
* Save this token to avoid having to reauthenticate. This token expires after 24 hours.
|
|
748
746
|
*/
|
|
749
|
-
)
|
|
750
747
|
}, {
|
|
751
748
|
key: "AuthenticateExternalWallet",
|
|
752
|
-
value:
|
|
749
|
+
value: function () {
|
|
753
750
|
var _AuthenticateExternalWallet = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref9) {
|
|
754
751
|
var _this2 = this;
|
|
755
752
|
var address, _ref9$tokenDuration, tokenDuration, _ref9$walletName, walletName, Sign, expiresAt, fabricToken;
|
|
@@ -818,7 +815,6 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
818
815
|
*
|
|
819
816
|
* @returns {string} - The client auth token
|
|
820
817
|
*/
|
|
821
|
-
)
|
|
822
818
|
}, {
|
|
823
819
|
key: "ClientAuthToken",
|
|
824
820
|
value: function ClientAuthToken() {
|
|
@@ -1982,7 +1978,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1982
1978
|
*/
|
|
1983
1979
|
}, {
|
|
1984
1980
|
key: "Initialize",
|
|
1985
|
-
value:
|
|
1981
|
+
value: function () {
|
|
1986
1982
|
var _Initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25(_ref24) {
|
|
1987
1983
|
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;
|
|
1988
1984
|
return _regeneratorRuntime.wrap(function _callee25$(_context25) {
|
|
@@ -2100,8 +2096,9 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
2100
2096
|
return _Initialize.apply(this, arguments);
|
|
2101
2097
|
}
|
|
2102
2098
|
return Initialize;
|
|
2103
|
-
}()
|
|
2099
|
+
}()
|
|
2104
2100
|
}]);
|
|
2101
|
+
return ElvWalletClient;
|
|
2105
2102
|
}();
|
|
2106
2103
|
Object.assign(ElvWalletClient.prototype, require("./ClientMethods"));
|
|
2107
2104
|
Object.assign(ElvWalletClient.prototype, require("./Profile"));
|
package/package.json
CHANGED
package/src/UserProfileClient.js
CHANGED
|
@@ -76,7 +76,7 @@ await client.userProfileClient.UserMetadata()
|
|
|
76
76
|
|
|
77
77
|
// Don't attempt to create a user wallet if user has no funds
|
|
78
78
|
const balance = await this.client.GetBalance({address: this.client.signer.address});
|
|
79
|
-
if(balance < 0.
|
|
79
|
+
if(balance < 0.05) {
|
|
80
80
|
return undefined;
|
|
81
81
|
}
|
|
82
82
|
|
|
@@ -420,20 +420,20 @@ await client.userProfileClient.UserMetadata()
|
|
|
420
420
|
}
|
|
421
421
|
|
|
422
422
|
/**
|
|
423
|
-
* Return the ID of the tenant
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
/**
|
package/src/Validation.js
CHANGED
|
@@ -104,10 +104,4 @@ exports.ValidateUserWallet = async ({address, client}) => {
|
|
|
104
104
|
if(!walletAddress) {
|
|
105
105
|
throw Error(`User address has no wallet: ${address}`);
|
|
106
106
|
}
|
|
107
|
-
|
|
108
|
-
const balance = await client.GetBalance({address});
|
|
109
|
-
|
|
110
|
-
if(balance < 0.1) {
|
|
111
|
-
throw Error(`User has no funds: ${address}`);
|
|
112
|
-
}
|
|
113
107
|
};
|
package/src/client/Contracts.js
CHANGED
|
@@ -11,7 +11,8 @@ const {
|
|
|
11
11
|
ValidateAddress,
|
|
12
12
|
ValidateParameters,
|
|
13
13
|
ValidatePresence,
|
|
14
|
-
ValidateObject,
|
|
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
|
-
|
|
610
|
-
contractAddress
|
|
611
|
-
|
|
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
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
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
|
-
|
|
620
|
-
|
|
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
|
-
|
|
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
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
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
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
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
|
+
|
package/src/client/LiveConf.js
CHANGED
|
@@ -508,7 +508,7 @@ class LiveConf {
|
|
|
508
508
|
elem.media_type = 1;
|
|
509
509
|
elem.stream_name = "video";
|
|
510
510
|
elem.stream_index = 0;
|
|
511
|
-
elem.representation = "videovideo_" +
|
|
511
|
+
elem.representation = "videovideo_" + elem.width + "x" + elem.height + "_h264@" + elem.bit_rate;
|
|
512
512
|
conf.live_recording.recording_config.recording_params.ladder_specs.push(elem);
|
|
513
513
|
}
|
|
514
514
|
// Currently the recording bitrate is the top bitrate of the ladder (it will be configurable separately in the future)
|