@eluvio/elv-client-js 3.1.81 → 3.1.85
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 +3 -3
- package/dist/ElvClient-node-min.js +5 -5
- package/dist/ElvFrameClient-min.js +6 -6
- package/dist/ElvPermissionsClient-min.js +6 -6
- package/dist/src/ElvClient.js +2 -3
- package/dist/src/RemoteSigner.js +28 -5
- package/dist/src/Utils.js +23 -3
- package/dist/src/client/ContentAccess.js +10 -7
- package/dist/src/client/ContentManagement.js +35 -29
- package/package-lock.json +1 -1
- package/package.json +1 -1
- package/src/ElvClient.js +1 -2
- package/src/RemoteSigner.js +21 -3
- package/src/Utils.js +26 -5
- package/src/client/ContentAccess.js +10 -4
- package/src/client/ContentManagement.js +9 -5
- package/testScripts/InitializeTenant.js +0 -1
package/dist/src/ElvClient.js
CHANGED
|
@@ -619,18 +619,17 @@ function () {
|
|
|
619
619
|
}, {
|
|
620
620
|
key: "SetRemoteSigner",
|
|
621
621
|
value: function SetRemoteSigner(_ref9) {
|
|
622
|
-
var idToken, authToken, tenantId,
|
|
622
|
+
var idToken, authToken, tenantId, extraData, signer;
|
|
623
623
|
return _regeneratorRuntime.async(function SetRemoteSigner$(_context6) {
|
|
624
624
|
while (1) {
|
|
625
625
|
switch (_context6.prev = _context6.next) {
|
|
626
626
|
case 0:
|
|
627
|
-
idToken = _ref9.idToken, authToken = _ref9.authToken, tenantId = _ref9.tenantId,
|
|
627
|
+
idToken = _ref9.idToken, authToken = _ref9.authToken, tenantId = _ref9.tenantId, extraData = _ref9.extraData;
|
|
628
628
|
signer = new RemoteSigner({
|
|
629
629
|
rpcUris: this.authServiceURIs,
|
|
630
630
|
idToken: idToken,
|
|
631
631
|
authToken: authToken,
|
|
632
632
|
tenantId: tenantId,
|
|
633
|
-
address: address,
|
|
634
633
|
provider: this.ethClient.provider,
|
|
635
634
|
extraData: extraData
|
|
636
635
|
});
|
package/dist/src/RemoteSigner.js
CHANGED
|
@@ -31,7 +31,6 @@ function (_Ethers$Signer) {
|
|
|
31
31
|
var rpcUris = _ref.rpcUris,
|
|
32
32
|
idToken = _ref.idToken,
|
|
33
33
|
authToken = _ref.authToken,
|
|
34
|
-
address = _ref.address,
|
|
35
34
|
tenantId = _ref.tenantId,
|
|
36
35
|
provider = _ref.provider,
|
|
37
36
|
_ref$extraData = _ref.extraData,
|
|
@@ -47,8 +46,6 @@ function (_Ethers$Signer) {
|
|
|
47
46
|
_this.idToken = idToken;
|
|
48
47
|
_this.tenantId = tenantId;
|
|
49
48
|
_this.authToken = authToken;
|
|
50
|
-
_this.address = address ? Utils.FormatAddress(address) : undefined;
|
|
51
|
-
_this.id = _this.address ? "ikms".concat(Utils.AddressToHash(_this.address)) : undefined;
|
|
52
49
|
_this.extraLoginData = extraData || {};
|
|
53
50
|
_this.provider = provider;
|
|
54
51
|
return _this;
|
|
@@ -57,7 +54,7 @@ function (_Ethers$Signer) {
|
|
|
57
54
|
_createClass(RemoteSigner, [{
|
|
58
55
|
key: "Initialize",
|
|
59
56
|
value: function Initialize() {
|
|
60
|
-
var _ref2, addr, eth, token;
|
|
57
|
+
var _ref2, addr, eth, token, keys, address;
|
|
61
58
|
|
|
62
59
|
return _regeneratorRuntime.async(function Initialize$(_context) {
|
|
63
60
|
while (1) {
|
|
@@ -93,9 +90,35 @@ function (_Ethers$Signer) {
|
|
|
93
90
|
this.id = eth;
|
|
94
91
|
|
|
95
92
|
case 10:
|
|
93
|
+
if (this.address) {
|
|
94
|
+
_context.next = 16;
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
_context.next = 13;
|
|
99
|
+
return _regeneratorRuntime.awrap(Utils.ResponseToJson(this.HttpClient.Request({
|
|
100
|
+
method: "GET",
|
|
101
|
+
path: UrlJoin("as", "wlt", "keys"),
|
|
102
|
+
headers: {
|
|
103
|
+
Authorization: "Bearer ".concat(this.authToken)
|
|
104
|
+
}
|
|
105
|
+
})));
|
|
106
|
+
|
|
107
|
+
case 13:
|
|
108
|
+
keys = _context.sent;
|
|
109
|
+
address = keys.eth[0];
|
|
110
|
+
|
|
111
|
+
if (address && address.startsWith("0x")) {
|
|
112
|
+
this.address = address;
|
|
113
|
+
} else {
|
|
114
|
+
this.address = Utils.HashToAddress(keys.eth[0]);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
case 16:
|
|
118
|
+
this.id = this.address ? "ikms".concat(Utils.AddressToHash(this.address)) : undefined;
|
|
96
119
|
this.signer = this.provider.getSigner(this.address);
|
|
97
120
|
|
|
98
|
-
case
|
|
121
|
+
case 18:
|
|
99
122
|
case "end":
|
|
100
123
|
return _context.stop();
|
|
101
124
|
}
|
package/dist/src/Utils.js
CHANGED
|
@@ -21,6 +21,8 @@ var BigNumber = require("bignumber.js")["default"];
|
|
|
21
21
|
var VarInt = require("varint");
|
|
22
22
|
|
|
23
23
|
var URI = require("urijs");
|
|
24
|
+
|
|
25
|
+
var keccak256 = require("ethers").utils.keccak256;
|
|
24
26
|
/**
|
|
25
27
|
* @namespace
|
|
26
28
|
* @description This is a utility namespace mostly containing functions for managing
|
|
@@ -163,11 +165,13 @@ var Utils = {
|
|
|
163
165
|
* Convert contract address to multiformat hash
|
|
164
166
|
*
|
|
165
167
|
* @param {string} address - Address of contract
|
|
168
|
+
* @param {boolean} key - Whether or not the first param is a public key. Defaults to address type
|
|
166
169
|
*
|
|
167
170
|
* @returns {string} - Hash of contract address
|
|
168
171
|
*/
|
|
169
172
|
AddressToHash: function AddressToHash(address) {
|
|
170
|
-
|
|
173
|
+
var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
174
|
+
address = address.replace(key ? "0x04" : "0x", "");
|
|
171
175
|
return bs58.encode(Buffer.from(address, "hex"));
|
|
172
176
|
},
|
|
173
177
|
|
|
@@ -208,12 +212,14 @@ var Utils = {
|
|
|
208
212
|
* Convert any content fabric ID to the corresponding contract address
|
|
209
213
|
*
|
|
210
214
|
* @param {string} hash - Hash to convert to address
|
|
215
|
+
* @param {boolean} key - Whether or not the first param is a key. Defaults to address type
|
|
211
216
|
*
|
|
212
217
|
* @returns {string} - Contract address of item
|
|
213
218
|
*/
|
|
214
219
|
HashToAddress: function HashToAddress(hash) {
|
|
215
|
-
|
|
216
|
-
|
|
220
|
+
var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
221
|
+
hash = key ? hash : hash.substr(4);
|
|
222
|
+
return Utils.FormatAddress((key ? "0x04" : "0x") + bs58.decode(hash).toString("hex"));
|
|
217
223
|
},
|
|
218
224
|
|
|
219
225
|
/**
|
|
@@ -667,6 +673,20 @@ var Utils = {
|
|
|
667
673
|
return JSON.parse(JSON.stringify(value));
|
|
668
674
|
}
|
|
669
675
|
},
|
|
676
|
+
|
|
677
|
+
/**
|
|
678
|
+
* Converts the given string to a public address
|
|
679
|
+
*
|
|
680
|
+
* @param key - Public key to convert to a public address
|
|
681
|
+
*
|
|
682
|
+
* @returns {string} - the public address
|
|
683
|
+
*/
|
|
684
|
+
PublicKeyToAddress: function PublicKeyToAddress(key) {
|
|
685
|
+
var keyData = new Uint8Array(Buffer.from(key.replace("0x04", ""), "hex"));
|
|
686
|
+
var keccakHash = keccak256(keyData);
|
|
687
|
+
var address = "0x" + keccakHash.slice(26);
|
|
688
|
+
return Utils.FormatAddress(address);
|
|
689
|
+
},
|
|
670
690
|
PLATFORM_NODE: "node",
|
|
671
691
|
PLATFORM_WEB: "web",
|
|
672
692
|
PLATFORM_REACT_NATIVE: "react-native",
|
|
@@ -2389,19 +2389,20 @@ exports.AvailableOfferings = function _callee30(_ref22) {
|
|
|
2389
2389
|
* @param {Object=} context - Additional audience data to include in the authorization request.
|
|
2390
2390
|
* - Note: Context must be a map of string->string
|
|
2391
2391
|
* @param {Object=} authorizationToken - Additional authorization token for authorizing this request
|
|
2392
|
+
* @param {Object=} options - Additional query parameters to pass when requesting available playout options, such as clipping parameters.
|
|
2392
2393
|
*/
|
|
2393
2394
|
|
|
2394
2395
|
|
|
2395
2396
|
exports.PlayoutOptions = function _callee33(_ref24) {
|
|
2396
2397
|
var _this9 = this;
|
|
2397
2398
|
|
|
2398
|
-
var offeringURI, objectId, versionHash, writeToken, linkPath, _ref24$signedLink, signedLink, _ref24$protocols, protocols, _ref24$handler, handler, _ref24$offering, offering, playoutType, _ref24$drms, drms, context, _ref24$hlsjsProfile, hlsjsProfile, authorizationToken, uriInfo, libraryId, offeringPath, link, _ref25, path, linkTarget, audienceData, authorization, queryParams, playoutOptions, playoutMap, sessionId, multiview, i, option, protocol, drm, playoutPath, licenseServers, cert, method, certUrl, protocolMatch, drmMatch;
|
|
2399
|
+
var offeringURI, objectId, versionHash, writeToken, linkPath, _ref24$signedLink, signedLink, _ref24$protocols, protocols, _ref24$handler, handler, _ref24$offering, offering, playoutType, _ref24$drms, drms, context, _ref24$hlsjsProfile, hlsjsProfile, authorizationToken, _ref24$options, options, uriInfo, libraryId, offeringPath, link, _ref25, path, linkTarget, audienceData, authorization, queryParams, playoutOptions, playoutMap, sessionId, multiview, i, option, protocol, drm, playoutPath, licenseServers, cert, method, certUrl, protocolMatch, drmMatch;
|
|
2399
2400
|
|
|
2400
2401
|
return _regeneratorRuntime.async(function _callee33$(_context33) {
|
|
2401
2402
|
while (1) {
|
|
2402
2403
|
switch (_context33.prev = _context33.next) {
|
|
2403
2404
|
case 0:
|
|
2404
|
-
offeringURI = _ref24.offeringURI, objectId = _ref24.objectId, versionHash = _ref24.versionHash, writeToken = _ref24.writeToken, linkPath = _ref24.linkPath, _ref24$signedLink = _ref24.signedLink, signedLink = _ref24$signedLink === void 0 ? false : _ref24$signedLink, _ref24$protocols = _ref24.protocols, protocols = _ref24$protocols === void 0 ? ["dash", "hls"] : _ref24$protocols, _ref24$handler = _ref24.handler, handler = _ref24$handler === void 0 ? "playout" : _ref24$handler, _ref24$offering = _ref24.offering, offering = _ref24$offering === void 0 ? "default" : _ref24$offering, playoutType = _ref24.playoutType, _ref24$drms = _ref24.drms, drms = _ref24$drms === void 0 ? [] : _ref24$drms, context = _ref24.context, _ref24$hlsjsProfile = _ref24.hlsjsProfile, hlsjsProfile = _ref24$hlsjsProfile === void 0 ? true : _ref24$hlsjsProfile, authorizationToken = _ref24.authorizationToken;
|
|
2405
|
+
offeringURI = _ref24.offeringURI, objectId = _ref24.objectId, versionHash = _ref24.versionHash, writeToken = _ref24.writeToken, linkPath = _ref24.linkPath, _ref24$signedLink = _ref24.signedLink, signedLink = _ref24$signedLink === void 0 ? false : _ref24$signedLink, _ref24$protocols = _ref24.protocols, protocols = _ref24$protocols === void 0 ? ["dash", "hls"] : _ref24$protocols, _ref24$handler = _ref24.handler, handler = _ref24$handler === void 0 ? "playout" : _ref24$handler, _ref24$offering = _ref24.offering, offering = _ref24$offering === void 0 ? "default" : _ref24$offering, playoutType = _ref24.playoutType, _ref24$drms = _ref24.drms, drms = _ref24$drms === void 0 ? [] : _ref24$drms, context = _ref24.context, _ref24$hlsjsProfile = _ref24.hlsjsProfile, hlsjsProfile = _ref24$hlsjsProfile === void 0 ? true : _ref24$hlsjsProfile, authorizationToken = _ref24.authorizationToken, _ref24$options = _ref24.options, options = _ref24$options === void 0 ? {} : _ref24$options;
|
|
2405
2406
|
|
|
2406
2407
|
if (!offeringURI) {
|
|
2407
2408
|
_context33.next = 8;
|
|
@@ -2558,10 +2559,10 @@ exports.PlayoutOptions = function _callee33(_ref24) {
|
|
|
2558
2559
|
};
|
|
2559
2560
|
|
|
2560
2561
|
authorization = [_context33.t9, _context33.t10].flat().filter(_context33.t11);
|
|
2561
|
-
queryParams = {
|
|
2562
|
+
queryParams = _objectSpread({
|
|
2562
2563
|
authorization: authorization,
|
|
2563
2564
|
resolve: !!linkPath
|
|
2564
|
-
};
|
|
2565
|
+
}, options);
|
|
2565
2566
|
_context33.t12 = Object;
|
|
2566
2567
|
_context33.next = 61;
|
|
2567
2568
|
return _regeneratorRuntime.awrap(this.utils.ResponseToJson(this.HttpClient.Request({
|
|
@@ -2825,17 +2826,18 @@ exports.PlayoutOptions = function _callee33(_ref24) {
|
|
|
2825
2826
|
* @param {Object=} context - Additional audience data to include in the authorization request
|
|
2826
2827
|
* - Note: Context must be a map of string->string
|
|
2827
2828
|
* @param {Object=} authorizationToken - Additional authorization token for authorizing this request
|
|
2829
|
+
* @param {Object=} options - Additional query parameters to pass when requesting available playout options, such as clipping parameters.
|
|
2828
2830
|
*/
|
|
2829
2831
|
|
|
2830
2832
|
|
|
2831
2833
|
exports.BitmovinPlayoutOptions = function _callee34(_ref27) {
|
|
2832
|
-
var objectId, versionHash, writeToken, linkPath, _ref27$signedLink, signedLink, _ref27$protocols, protocols, _ref27$drms, drms, _ref27$handler, handler, _ref27$offering, offering, playoutType, context, authorizationToken, playoutOptions, _ref28, linkTarget, authorization, config;
|
|
2834
|
+
var objectId, versionHash, writeToken, linkPath, _ref27$signedLink, signedLink, _ref27$protocols, protocols, _ref27$drms, drms, _ref27$handler, handler, _ref27$offering, offering, playoutType, context, authorizationToken, _ref27$options, options, playoutOptions, _ref28, linkTarget, authorization, config;
|
|
2833
2835
|
|
|
2834
2836
|
return _regeneratorRuntime.async(function _callee34$(_context34) {
|
|
2835
2837
|
while (1) {
|
|
2836
2838
|
switch (_context34.prev = _context34.next) {
|
|
2837
2839
|
case 0:
|
|
2838
|
-
objectId = _ref27.objectId, versionHash = _ref27.versionHash, writeToken = _ref27.writeToken, linkPath = _ref27.linkPath, _ref27$signedLink = _ref27.signedLink, signedLink = _ref27$signedLink === void 0 ? false : _ref27$signedLink, _ref27$protocols = _ref27.protocols, protocols = _ref27$protocols === void 0 ? ["dash", "hls"] : _ref27$protocols, _ref27$drms = _ref27.drms, drms = _ref27$drms === void 0 ? [] : _ref27$drms, _ref27$handler = _ref27.handler, handler = _ref27$handler === void 0 ? "playout" : _ref27$handler, _ref27$offering = _ref27.offering, offering = _ref27$offering === void 0 ? "default" : _ref27$offering, playoutType = _ref27.playoutType, context = _ref27.context, authorizationToken = _ref27.authorizationToken;
|
|
2840
|
+
objectId = _ref27.objectId, versionHash = _ref27.versionHash, writeToken = _ref27.writeToken, linkPath = _ref27.linkPath, _ref27$signedLink = _ref27.signedLink, signedLink = _ref27$signedLink === void 0 ? false : _ref27$signedLink, _ref27$protocols = _ref27.protocols, protocols = _ref27$protocols === void 0 ? ["dash", "hls"] : _ref27$protocols, _ref27$drms = _ref27.drms, drms = _ref27$drms === void 0 ? [] : _ref27$drms, _ref27$handler = _ref27.handler, handler = _ref27$handler === void 0 ? "playout" : _ref27$handler, _ref27$offering = _ref27.offering, offering = _ref27$offering === void 0 ? "default" : _ref27$offering, playoutType = _ref27.playoutType, context = _ref27.context, authorizationToken = _ref27.authorizationToken, _ref27$options = _ref27.options, options = _ref27$options === void 0 ? {} : _ref27$options;
|
|
2839
2841
|
versionHash ? ValidateVersion(versionHash) : ValidateObject(objectId);
|
|
2840
2842
|
|
|
2841
2843
|
if (!objectId) {
|
|
@@ -2856,7 +2858,8 @@ exports.BitmovinPlayoutOptions = function _callee34(_ref27) {
|
|
|
2856
2858
|
playoutType: playoutType,
|
|
2857
2859
|
hlsjsProfile: false,
|
|
2858
2860
|
context: context,
|
|
2859
|
-
authorizationToken: authorizationToken
|
|
2861
|
+
authorizationToken: authorizationToken,
|
|
2862
|
+
options: options
|
|
2860
2863
|
}));
|
|
2861
2864
|
|
|
2862
2865
|
case 5:
|
|
@@ -32,8 +32,7 @@ var _require = require("../Validation"),
|
|
|
32
32
|
ValidateVersion = _require.ValidateVersion,
|
|
33
33
|
ValidateWriteToken = _require.ValidateWriteToken,
|
|
34
34
|
ValidateParameters = _require.ValidateParameters,
|
|
35
|
-
ValidatePresence = _require.ValidatePresence
|
|
36
|
-
ValidateAddress = _require.ValidateAddress;
|
|
35
|
+
ValidatePresence = _require.ValidatePresence;
|
|
37
36
|
|
|
38
37
|
exports.SetVisibility = function _callee(_ref) {
|
|
39
38
|
var id, visibility, hasSetVisibility, event;
|
|
@@ -448,19 +447,20 @@ exports.CreateContentType = function _callee3(_ref4) {
|
|
|
448
447
|
* @param {Object=} metadata - Metadata of library object
|
|
449
448
|
* @param {string=} kmsId - ID of the KMS to use for content in this library. If not specified,
|
|
450
449
|
* the default KMS will be used.
|
|
450
|
+
* @param {string=} tenantId - ID of the tenant to use for this library
|
|
451
451
|
*
|
|
452
452
|
* @returns {Promise<string>} - Library ID of created library
|
|
453
453
|
*/
|
|
454
454
|
|
|
455
455
|
|
|
456
456
|
exports.CreateContentLibrary = function _callee4(_ref6) {
|
|
457
|
-
var name, description, image, imageName, _ref6$metadata, metadata, kmsId, _ref7, contractAddress,
|
|
457
|
+
var name, description, image, imageName, _ref6$metadata, metadata, kmsId, tenantId, _ref7, contractAddress, libraryId, objectId, editResponse;
|
|
458
458
|
|
|
459
459
|
return _regeneratorRuntime.async(function _callee4$(_context5) {
|
|
460
460
|
while (1) {
|
|
461
461
|
switch (_context5.prev = _context5.next) {
|
|
462
462
|
case 0:
|
|
463
|
-
name = _ref6.name, description = _ref6.description, image = _ref6.image, imageName = _ref6.imageName, _ref6$metadata = _ref6.metadata, metadata = _ref6$metadata === void 0 ? {} : _ref6$metadata, kmsId = _ref6.kmsId;
|
|
463
|
+
name = _ref6.name, description = _ref6.description, image = _ref6.image, imageName = _ref6.imageName, _ref6$metadata = _ref6.metadata, metadata = _ref6$metadata === void 0 ? {} : _ref6$metadata, kmsId = _ref6.kmsId, tenantId = _ref6.tenantId;
|
|
464
464
|
|
|
465
465
|
if (kmsId) {
|
|
466
466
|
_context5.next = 9;
|
|
@@ -488,25 +488,32 @@ exports.CreateContentLibrary = function _callee4(_ref6) {
|
|
|
488
488
|
case 13:
|
|
489
489
|
_ref7 = _context5.sent;
|
|
490
490
|
contractAddress = _ref7.contractAddress;
|
|
491
|
-
|
|
491
|
+
|
|
492
|
+
if (tenantId) {
|
|
493
|
+
_context5.next = 19;
|
|
494
|
+
break;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
_context5.next = 18;
|
|
492
498
|
return _regeneratorRuntime.awrap(this.userProfileClient.TenantId());
|
|
493
499
|
|
|
494
|
-
case
|
|
500
|
+
case 18:
|
|
495
501
|
tenantId = _context5.sent;
|
|
496
502
|
|
|
503
|
+
case 19:
|
|
497
504
|
if (!tenantId) {
|
|
498
|
-
_context5.next =
|
|
505
|
+
_context5.next = 22;
|
|
499
506
|
break;
|
|
500
507
|
}
|
|
501
508
|
|
|
502
|
-
_context5.next =
|
|
509
|
+
_context5.next = 22;
|
|
503
510
|
return _regeneratorRuntime.awrap(this.CallContractMethod({
|
|
504
511
|
contractAddress: contractAddress,
|
|
505
512
|
methodName: "putMeta",
|
|
506
513
|
methodArgs: ["_tenantId", tenantId]
|
|
507
514
|
}));
|
|
508
515
|
|
|
509
|
-
case
|
|
516
|
+
case 22:
|
|
510
517
|
metadata = _objectSpread({}, metadata, {
|
|
511
518
|
name: name,
|
|
512
519
|
description: description,
|
|
@@ -520,15 +527,15 @@ exports.CreateContentLibrary = function _callee4(_ref6) {
|
|
|
520
527
|
this.Log("Contract address: ".concat(contractAddress)); // Set library content object type and metadata on automatically created library object
|
|
521
528
|
|
|
522
529
|
objectId = libraryId.replace("ilib", "iq__");
|
|
523
|
-
_context5.next =
|
|
530
|
+
_context5.next = 29;
|
|
524
531
|
return _regeneratorRuntime.awrap(this.EditContentObject({
|
|
525
532
|
libraryId: libraryId,
|
|
526
533
|
objectId: objectId
|
|
527
534
|
}));
|
|
528
535
|
|
|
529
|
-
case
|
|
536
|
+
case 29:
|
|
530
537
|
editResponse = _context5.sent;
|
|
531
|
-
_context5.next =
|
|
538
|
+
_context5.next = 32;
|
|
532
539
|
return _regeneratorRuntime.awrap(this.ReplaceMetadata({
|
|
533
540
|
libraryId: libraryId,
|
|
534
541
|
objectId: objectId,
|
|
@@ -536,8 +543,8 @@ exports.CreateContentLibrary = function _callee4(_ref6) {
|
|
|
536
543
|
writeToken: editResponse.write_token
|
|
537
544
|
}));
|
|
538
545
|
|
|
539
|
-
case
|
|
540
|
-
_context5.next =
|
|
546
|
+
case 32:
|
|
547
|
+
_context5.next = 34;
|
|
541
548
|
return _regeneratorRuntime.awrap(this.FinalizeContentObject({
|
|
542
549
|
libraryId: libraryId,
|
|
543
550
|
objectId: objectId,
|
|
@@ -545,24 +552,24 @@ exports.CreateContentLibrary = function _callee4(_ref6) {
|
|
|
545
552
|
commitMessage: "Create library"
|
|
546
553
|
}));
|
|
547
554
|
|
|
548
|
-
case
|
|
555
|
+
case 34:
|
|
549
556
|
if (!image) {
|
|
550
|
-
_context5.next =
|
|
557
|
+
_context5.next = 37;
|
|
551
558
|
break;
|
|
552
559
|
}
|
|
553
560
|
|
|
554
|
-
_context5.next =
|
|
561
|
+
_context5.next = 37;
|
|
555
562
|
return _regeneratorRuntime.awrap(this.SetContentLibraryImage({
|
|
556
563
|
libraryId: libraryId,
|
|
557
564
|
image: image,
|
|
558
565
|
imageName: imageName
|
|
559
566
|
}));
|
|
560
567
|
|
|
561
|
-
case
|
|
568
|
+
case 37:
|
|
562
569
|
this.Log("Library ".concat(libraryId, " created"));
|
|
563
570
|
return _context5.abrupt("return", libraryId);
|
|
564
571
|
|
|
565
|
-
case
|
|
572
|
+
case 39:
|
|
566
573
|
case "end":
|
|
567
574
|
return _context5.stop();
|
|
568
575
|
}
|
|
@@ -1246,7 +1253,6 @@ exports.CopyContentObject = function _callee12(_ref15) {
|
|
|
1246
1253
|
* @param {string} libraryId - ID of the library
|
|
1247
1254
|
* @param {string} objectId - ID of the object
|
|
1248
1255
|
* @param {string} publicKey - Public key for the target cap
|
|
1249
|
-
* @param {string} publicAddress - Public address for the target cap key
|
|
1250
1256
|
* @param {string} writeToken - Write token for the content object - If specified, info will be retrieved from the write draft instead of creating a new draft and finalizing
|
|
1251
1257
|
*
|
|
1252
1258
|
* @returns {Promise<Object>}
|
|
@@ -1254,37 +1260,37 @@ exports.CopyContentObject = function _callee12(_ref15) {
|
|
|
1254
1260
|
|
|
1255
1261
|
|
|
1256
1262
|
exports.CreateNonOwnerCap = function _callee13(_ref17) {
|
|
1257
|
-
var objectId, libraryId, publicKey,
|
|
1263
|
+
var objectId, libraryId, publicKey, writeToken, userCapKey, userCapValue, userConk, publicAddress, targetUserCapKey, targetUserCapValue, finalize;
|
|
1258
1264
|
return _regeneratorRuntime.async(function _callee13$(_context14) {
|
|
1259
1265
|
while (1) {
|
|
1260
1266
|
switch (_context14.prev = _context14.next) {
|
|
1261
1267
|
case 0:
|
|
1262
|
-
objectId = _ref17.objectId, libraryId = _ref17.libraryId, publicKey = _ref17.publicKey,
|
|
1263
|
-
publicAddress = ValidateAddress(publicAddress);
|
|
1268
|
+
objectId = _ref17.objectId, libraryId = _ref17.libraryId, publicKey = _ref17.publicKey, writeToken = _ref17.writeToken;
|
|
1264
1269
|
userCapKey = "eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address));
|
|
1265
|
-
_context14.next =
|
|
1270
|
+
_context14.next = 4;
|
|
1266
1271
|
return _regeneratorRuntime.awrap(this.ContentObjectMetadata({
|
|
1267
1272
|
objectId: objectId,
|
|
1268
1273
|
libraryId: libraryId,
|
|
1269
1274
|
metadataSubtree: userCapKey
|
|
1270
1275
|
}));
|
|
1271
1276
|
|
|
1272
|
-
case
|
|
1277
|
+
case 4:
|
|
1273
1278
|
userCapValue = _context14.sent;
|
|
1274
1279
|
|
|
1275
1280
|
if (userCapValue) {
|
|
1276
|
-
_context14.next =
|
|
1281
|
+
_context14.next = 7;
|
|
1277
1282
|
break;
|
|
1278
1283
|
}
|
|
1279
1284
|
|
|
1280
1285
|
throw Error("No user cap found for current user");
|
|
1281
1286
|
|
|
1282
|
-
case
|
|
1283
|
-
_context14.next =
|
|
1287
|
+
case 7:
|
|
1288
|
+
_context14.next = 9;
|
|
1284
1289
|
return _regeneratorRuntime.awrap(this.Crypto.DecryptCap(userCapValue, this.signer.signingKey.privateKey));
|
|
1285
1290
|
|
|
1286
|
-
case
|
|
1291
|
+
case 9:
|
|
1287
1292
|
userConk = _context14.sent;
|
|
1293
|
+
publicAddress = this.utils.PublicKeyToAddress(publicKey);
|
|
1288
1294
|
targetUserCapKey = "eluv.caps.iusr".concat(this.utils.AddressToHash(publicAddress));
|
|
1289
1295
|
_context14.next = 14;
|
|
1290
1296
|
return _regeneratorRuntime.awrap(this.Crypto.EncryptConk(userConk, publicKey));
|
package/package-lock.json
CHANGED
package/package.json
CHANGED
package/src/ElvClient.js
CHANGED
|
@@ -599,13 +599,12 @@ class ElvClient {
|
|
|
599
599
|
* @param {string=} tenantId - If specified, user will be associated with the tenant
|
|
600
600
|
* @param {Object=} extraData - Additional data to pass to the login API
|
|
601
601
|
*/
|
|
602
|
-
async SetRemoteSigner({idToken, authToken, tenantId,
|
|
602
|
+
async SetRemoteSigner({idToken, authToken, tenantId, extraData}) {
|
|
603
603
|
const signer = new RemoteSigner({
|
|
604
604
|
rpcUris: this.authServiceURIs,
|
|
605
605
|
idToken,
|
|
606
606
|
authToken,
|
|
607
607
|
tenantId,
|
|
608
|
-
address,
|
|
609
608
|
provider: this.ethClient.provider,
|
|
610
609
|
extraData
|
|
611
610
|
});
|
package/src/RemoteSigner.js
CHANGED
|
@@ -8,7 +8,6 @@ class RemoteSigner extends Ethers.Signer {
|
|
|
8
8
|
rpcUris,
|
|
9
9
|
idToken,
|
|
10
10
|
authToken,
|
|
11
|
-
address,
|
|
12
11
|
tenantId,
|
|
13
12
|
provider,
|
|
14
13
|
extraData={}
|
|
@@ -22,8 +21,6 @@ class RemoteSigner extends Ethers.Signer {
|
|
|
22
21
|
this.tenantId = tenantId;
|
|
23
22
|
|
|
24
23
|
this.authToken = authToken;
|
|
25
|
-
this.address = address ? Utils.FormatAddress(address) : undefined;
|
|
26
|
-
this.id = this.address ? `ikms${Utils.AddressToHash(this.address)}` : undefined;
|
|
27
24
|
this.extraLoginData = extraData || {};
|
|
28
25
|
|
|
29
26
|
this.provider = provider;
|
|
@@ -47,6 +44,27 @@ class RemoteSigner extends Ethers.Signer {
|
|
|
47
44
|
this.id = eth;
|
|
48
45
|
}
|
|
49
46
|
|
|
47
|
+
if(!this.address) {
|
|
48
|
+
const keys = await Utils.ResponseToJson(
|
|
49
|
+
this.HttpClient.Request({
|
|
50
|
+
method: "GET",
|
|
51
|
+
path: UrlJoin("as", "wlt", "keys"),
|
|
52
|
+
headers: {
|
|
53
|
+
Authorization: `Bearer ${this.authToken}`
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const address = keys.eth[0];
|
|
59
|
+
|
|
60
|
+
if(address && address.startsWith("0x")) {
|
|
61
|
+
this.address = address;
|
|
62
|
+
} else {
|
|
63
|
+
this.address = Utils.HashToAddress(keys.eth[0]);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
this.id = this.address ? `ikms${Utils.AddressToHash(this.address)}` : undefined;
|
|
50
68
|
this.signer = this.provider.getSigner(this.address);
|
|
51
69
|
}
|
|
52
70
|
|
package/src/Utils.js
CHANGED
|
@@ -5,6 +5,10 @@ const BigNumber = require("bignumber.js").default;
|
|
|
5
5
|
const VarInt = require("varint");
|
|
6
6
|
const URI = require("urijs");
|
|
7
7
|
|
|
8
|
+
const {
|
|
9
|
+
keccak256
|
|
10
|
+
} = require("ethers").utils;
|
|
11
|
+
|
|
8
12
|
/**
|
|
9
13
|
* @namespace
|
|
10
14
|
* @description This is a utility namespace mostly containing functions for managing
|
|
@@ -149,11 +153,12 @@ const Utils = {
|
|
|
149
153
|
* Convert contract address to multiformat hash
|
|
150
154
|
*
|
|
151
155
|
* @param {string} address - Address of contract
|
|
156
|
+
* @param {boolean} key - Whether or not the first param is a public key. Defaults to address type
|
|
152
157
|
*
|
|
153
158
|
* @returns {string} - Hash of contract address
|
|
154
159
|
*/
|
|
155
|
-
AddressToHash: (address) => {
|
|
156
|
-
address = address.replace("0x", "");
|
|
160
|
+
AddressToHash: (address, key=false) => {
|
|
161
|
+
address = address.replace(key ? "0x04" : "0x", "");
|
|
157
162
|
return bs58.encode(Buffer.from(address, "hex"));
|
|
158
163
|
},
|
|
159
164
|
|
|
@@ -194,12 +199,13 @@ const Utils = {
|
|
|
194
199
|
* Convert any content fabric ID to the corresponding contract address
|
|
195
200
|
*
|
|
196
201
|
* @param {string} hash - Hash to convert to address
|
|
202
|
+
* @param {boolean} key - Whether or not the first param is a key. Defaults to address type
|
|
197
203
|
*
|
|
198
204
|
* @returns {string} - Contract address of item
|
|
199
205
|
*/
|
|
200
|
-
HashToAddress: (hash) => {
|
|
201
|
-
hash = hash.substr(4);
|
|
202
|
-
return Utils.FormatAddress("0x" + bs58.decode(hash).toString("hex"));
|
|
206
|
+
HashToAddress: (hash, key=false) => {
|
|
207
|
+
hash = key ? hash : hash.substr(4);
|
|
208
|
+
return Utils.FormatAddress((key ? "0x04" : "0x") + bs58.decode(hash).toString("hex"));
|
|
203
209
|
},
|
|
204
210
|
|
|
205
211
|
/**
|
|
@@ -505,6 +511,21 @@ const Utils = {
|
|
|
505
511
|
}
|
|
506
512
|
},
|
|
507
513
|
|
|
514
|
+
/**
|
|
515
|
+
* Converts the given string to a public address
|
|
516
|
+
*
|
|
517
|
+
* @param key - Public key to convert to a public address
|
|
518
|
+
*
|
|
519
|
+
* @returns {string} - the public address
|
|
520
|
+
*/
|
|
521
|
+
PublicKeyToAddress: (key) => {
|
|
522
|
+
const keyData = new Uint8Array(Buffer.from(key.replace("0x04", ""), "hex"));
|
|
523
|
+
const keccakHash = keccak256(keyData);
|
|
524
|
+
const address = "0x" + keccakHash.slice(26);
|
|
525
|
+
|
|
526
|
+
return Utils.FormatAddress(address);
|
|
527
|
+
},
|
|
528
|
+
|
|
508
529
|
PLATFORM_NODE: "node",
|
|
509
530
|
PLATFORM_WEB: "web",
|
|
510
531
|
PLATFORM_REACT_NATIVE: "react-native",
|
|
@@ -1325,6 +1325,7 @@ exports.AvailableOfferings = async function({
|
|
|
1325
1325
|
* @param {Object=} context - Additional audience data to include in the authorization request.
|
|
1326
1326
|
* - Note: Context must be a map of string->string
|
|
1327
1327
|
* @param {Object=} authorizationToken - Additional authorization token for authorizing this request
|
|
1328
|
+
* @param {Object=} options - Additional query parameters to pass when requesting available playout options, such as clipping parameters.
|
|
1328
1329
|
*/
|
|
1329
1330
|
exports.PlayoutOptions = async function({
|
|
1330
1331
|
offeringURI,
|
|
@@ -1340,7 +1341,8 @@ exports.PlayoutOptions = async function({
|
|
|
1340
1341
|
drms=[],
|
|
1341
1342
|
context,
|
|
1342
1343
|
hlsjsProfile=true,
|
|
1343
|
-
authorizationToken
|
|
1344
|
+
authorizationToken,
|
|
1345
|
+
options={}
|
|
1344
1346
|
}) {
|
|
1345
1347
|
if(offeringURI) {
|
|
1346
1348
|
const uriInfo = offeringURI.match(/(hq__[^/]+)\/rep\/([^/]+)\/([^/]+)\/options.json/);
|
|
@@ -1421,7 +1423,8 @@ exports.PlayoutOptions = async function({
|
|
|
1421
1423
|
|
|
1422
1424
|
let queryParams = {
|
|
1423
1425
|
authorization,
|
|
1424
|
-
resolve: !!linkPath
|
|
1426
|
+
resolve: !!linkPath,
|
|
1427
|
+
...options
|
|
1425
1428
|
};
|
|
1426
1429
|
|
|
1427
1430
|
const playoutOptions = Object.values(
|
|
@@ -1590,6 +1593,7 @@ exports.PlayoutOptions = async function({
|
|
|
1590
1593
|
* @param {Object=} context - Additional audience data to include in the authorization request
|
|
1591
1594
|
* - Note: Context must be a map of string->string
|
|
1592
1595
|
* @param {Object=} authorizationToken - Additional authorization token for authorizing this request
|
|
1596
|
+
* @param {Object=} options - Additional query parameters to pass when requesting available playout options, such as clipping parameters.
|
|
1593
1597
|
*/
|
|
1594
1598
|
exports.BitmovinPlayoutOptions = async function({
|
|
1595
1599
|
objectId,
|
|
@@ -1603,7 +1607,8 @@ exports.BitmovinPlayoutOptions = async function({
|
|
|
1603
1607
|
offering="default",
|
|
1604
1608
|
playoutType,
|
|
1605
1609
|
context,
|
|
1606
|
-
authorizationToken
|
|
1610
|
+
authorizationToken,
|
|
1611
|
+
options={}
|
|
1607
1612
|
}) {
|
|
1608
1613
|
versionHash ? ValidateVersion(versionHash) : ValidateObject(objectId);
|
|
1609
1614
|
|
|
@@ -1624,7 +1629,8 @@ exports.BitmovinPlayoutOptions = async function({
|
|
|
1624
1629
|
playoutType,
|
|
1625
1630
|
hlsjsProfile: false,
|
|
1626
1631
|
context,
|
|
1627
|
-
authorizationToken
|
|
1632
|
+
authorizationToken,
|
|
1633
|
+
options
|
|
1628
1634
|
});
|
|
1629
1635
|
|
|
1630
1636
|
delete playoutOptions.playoutMethods;
|
|
@@ -22,7 +22,6 @@ const {
|
|
|
22
22
|
ValidateWriteToken,
|
|
23
23
|
ValidateParameters,
|
|
24
24
|
ValidatePresence,
|
|
25
|
-
ValidateAddress
|
|
26
25
|
} = require("../Validation");
|
|
27
26
|
|
|
28
27
|
exports.SetVisibility = async function({id, visibility}) {
|
|
@@ -243,6 +242,7 @@ exports.CreateContentType = async function({name, metadata={}, bitcode}) {
|
|
|
243
242
|
* @param {Object=} metadata - Metadata of library object
|
|
244
243
|
* @param {string=} kmsId - ID of the KMS to use for content in this library. If not specified,
|
|
245
244
|
* the default KMS will be used.
|
|
245
|
+
* @param {string=} tenantId - ID of the tenant to use for this library
|
|
246
246
|
*
|
|
247
247
|
* @returns {Promise<string>} - Library ID of created library
|
|
248
248
|
*/
|
|
@@ -253,6 +253,7 @@ exports.CreateContentLibrary = async function({
|
|
|
253
253
|
imageName,
|
|
254
254
|
metadata={},
|
|
255
255
|
kmsId,
|
|
256
|
+
tenantId
|
|
256
257
|
}) {
|
|
257
258
|
if(!kmsId) {
|
|
258
259
|
kmsId = `ikms${this.utils.AddressToHash(await this.DefaultKMSAddress())}`;
|
|
@@ -265,7 +266,10 @@ exports.CreateContentLibrary = async function({
|
|
|
265
266
|
|
|
266
267
|
|
|
267
268
|
// Set tenant ID on the library if the user is associated with a tenant
|
|
268
|
-
|
|
269
|
+
if(!tenantId) {
|
|
270
|
+
tenantId = await this.userProfileClient.TenantId();
|
|
271
|
+
}
|
|
272
|
+
|
|
269
273
|
if(tenantId) {
|
|
270
274
|
await this.CallContractMethod({
|
|
271
275
|
contractAddress,
|
|
@@ -691,13 +695,11 @@ exports.CopyContentObject = async function({libraryId, originalVersionHash, opti
|
|
|
691
695
|
* @param {string} libraryId - ID of the library
|
|
692
696
|
* @param {string} objectId - ID of the object
|
|
693
697
|
* @param {string} publicKey - Public key for the target cap
|
|
694
|
-
* @param {string} publicAddress - Public address for the target cap key
|
|
695
698
|
* @param {string} writeToken - Write token for the content object - If specified, info will be retrieved from the write draft instead of creating a new draft and finalizing
|
|
696
699
|
*
|
|
697
700
|
* @returns {Promise<Object>}
|
|
698
701
|
*/
|
|
699
|
-
exports.CreateNonOwnerCap = async function({objectId, libraryId, publicKey,
|
|
700
|
-
publicAddress = ValidateAddress(publicAddress);
|
|
702
|
+
exports.CreateNonOwnerCap = async function({objectId, libraryId, publicKey, writeToken}) {
|
|
701
703
|
const userCapKey = `eluv.caps.iusr${this.utils.AddressToHash(this.signer.address)}`;
|
|
702
704
|
const userCapValue = await this.ContentObjectMetadata({objectId, libraryId, metadataSubtree: userCapKey});
|
|
703
705
|
|
|
@@ -707,6 +709,8 @@ exports.CreateNonOwnerCap = async function({objectId, libraryId, publicKey, publ
|
|
|
707
709
|
|
|
708
710
|
const userConk = await this.Crypto.DecryptCap(userCapValue, this.signer.signingKey.privateKey);
|
|
709
711
|
|
|
712
|
+
const publicAddress = this.utils.PublicKeyToAddress(publicKey);
|
|
713
|
+
|
|
710
714
|
const targetUserCapKey = `eluv.caps.iusr${this.utils.AddressToHash(publicAddress)}`;
|
|
711
715
|
const targetUserCapValue = await this.Crypto.EncryptConk(userConk, publicKey);
|
|
712
716
|
|
|
@@ -16,7 +16,6 @@ const reportTypes = [
|
|
|
16
16
|
|
|
17
17
|
const liveTypes = [
|
|
18
18
|
{ name: "Eluvio LIVE Drop Event Site", spec: require("../typeSpecs/DropEventSite") },
|
|
19
|
-
{ name: "Eluvio LIVE Event Site", spec: require("../typeSpecs/EventSite") },
|
|
20
19
|
{ name: "Eluvio LIVE Marketplace", spec: require("../typeSpecs/Marketplace") },
|
|
21
20
|
{ name: "Eluvio LIVE Tenant", spec: require("../typeSpecs/EventTenant") },
|
|
22
21
|
{ name: "NFT Collection", spec: require("../typeSpecs/NFTCollection") },
|