@eluvio/elv-client-js 3.1.80 → 3.1.84
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 +14 -9
- package/dist/src/client/ContentManagement.js +10 -12
- 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 +13 -7
- package/src/client/ContentManagement.js +3 -4
- package/testScripts/InitializeTenant.js +0 -1
- package/typeSpecs/DropEventSite.js +51 -56
- package/typeSpecs/Marketplace.js +88 -80
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",
|
|
@@ -1326,13 +1326,13 @@ exports.ContentObjectLibraryId = function _callee19(_ref14) {
|
|
|
1326
1326
|
exports.ProduceMetadataLinks = function _callee22(_ref15) {
|
|
1327
1327
|
var _this7 = this;
|
|
1328
1328
|
|
|
1329
|
-
var libraryId, objectId, versionHash, _ref15$path, path, metadata, authorizationToken, result;
|
|
1329
|
+
var libraryId, objectId, versionHash, _ref15$path, path, metadata, authorizationToken, noAuth, result;
|
|
1330
1330
|
|
|
1331
1331
|
return _regeneratorRuntime.async(function _callee22$(_context22) {
|
|
1332
1332
|
while (1) {
|
|
1333
1333
|
switch (_context22.prev = _context22.next) {
|
|
1334
1334
|
case 0:
|
|
1335
|
-
libraryId = _ref15.libraryId, objectId = _ref15.objectId, versionHash = _ref15.versionHash, _ref15$path = _ref15.path, path = _ref15$path === void 0 ? "/" : _ref15$path, metadata = _ref15.metadata, authorizationToken = _ref15.authorizationToken;
|
|
1335
|
+
libraryId = _ref15.libraryId, objectId = _ref15.objectId, versionHash = _ref15.versionHash, _ref15$path = _ref15.path, path = _ref15$path === void 0 ? "/" : _ref15$path, metadata = _ref15.metadata, authorizationToken = _ref15.authorizationToken, noAuth = _ref15.noAuth;
|
|
1336
1336
|
|
|
1337
1337
|
if (!(!metadata || _typeof(metadata) !== "object")) {
|
|
1338
1338
|
_context22.next = 3;
|
|
@@ -1360,7 +1360,8 @@ exports.ProduceMetadataLinks = function _callee22(_ref15) {
|
|
|
1360
1360
|
versionHash: versionHash,
|
|
1361
1361
|
path: UrlJoin(path, i.toString()),
|
|
1362
1362
|
metadata: entry,
|
|
1363
|
-
authorizationToken: authorizationToken
|
|
1363
|
+
authorizationToken: authorizationToken,
|
|
1364
|
+
noAuth: noAuth
|
|
1364
1365
|
}));
|
|
1365
1366
|
|
|
1366
1367
|
case 2:
|
|
@@ -1417,7 +1418,8 @@ exports.ProduceMetadataLinks = function _callee22(_ref15) {
|
|
|
1417
1418
|
versionHash: versionHash,
|
|
1418
1419
|
path: UrlJoin(path, key),
|
|
1419
1420
|
metadata: metadata[key],
|
|
1420
|
-
authorizationToken: authorizationToken
|
|
1421
|
+
authorizationToken: authorizationToken,
|
|
1422
|
+
noAuth: noAuth
|
|
1421
1423
|
}));
|
|
1422
1424
|
|
|
1423
1425
|
case 2:
|
|
@@ -1740,7 +1742,8 @@ exports.ContentObjectMetadata = function _callee24(_ref17) {
|
|
|
1740
1742
|
versionHash: versionHash,
|
|
1741
1743
|
path: metadataSubtree,
|
|
1742
1744
|
metadata: metadata,
|
|
1743
|
-
authorizationToken: authorizationToken
|
|
1745
|
+
authorizationToken: authorizationToken,
|
|
1746
|
+
noAuth: noAuth
|
|
1744
1747
|
}));
|
|
1745
1748
|
|
|
1746
1749
|
case 26:
|
|
@@ -1780,13 +1783,13 @@ exports.ContentObjectMetadata = function _callee24(_ref17) {
|
|
|
1780
1783
|
exports.AssetMetadata = function _callee25(_ref18) {
|
|
1781
1784
|
var _this8 = this;
|
|
1782
1785
|
|
|
1783
|
-
var libraryId, objectId, versionHash, metadata, localization, _ref18$produceLinkUrl, produceLinkUrls, mergedMetadata;
|
|
1786
|
+
var libraryId, objectId, versionHash, metadata, localization, noAuth, _ref18$produceLinkUrl, produceLinkUrls, mergedMetadata;
|
|
1784
1787
|
|
|
1785
1788
|
return _regeneratorRuntime.async(function _callee25$(_context25) {
|
|
1786
1789
|
while (1) {
|
|
1787
1790
|
switch (_context25.prev = _context25.next) {
|
|
1788
1791
|
case 0:
|
|
1789
|
-
libraryId = _ref18.libraryId, objectId = _ref18.objectId, versionHash = _ref18.versionHash, metadata = _ref18.metadata, localization = _ref18.localization, _ref18$produceLinkUrl = _ref18.produceLinkUrls, produceLinkUrls = _ref18$produceLinkUrl === void 0 ? false : _ref18$produceLinkUrl;
|
|
1792
|
+
libraryId = _ref18.libraryId, objectId = _ref18.objectId, versionHash = _ref18.versionHash, metadata = _ref18.metadata, localization = _ref18.localization, noAuth = _ref18.noAuth, _ref18$produceLinkUrl = _ref18.produceLinkUrls, produceLinkUrls = _ref18$produceLinkUrl === void 0 ? false : _ref18$produceLinkUrl;
|
|
1790
1793
|
ValidateParameters({
|
|
1791
1794
|
libraryId: libraryId,
|
|
1792
1795
|
objectId: objectId,
|
|
@@ -1811,7 +1814,8 @@ exports.AssetMetadata = function _callee25(_ref18) {
|
|
|
1811
1814
|
resolveLinks: true,
|
|
1812
1815
|
linkDepthLimit: 2,
|
|
1813
1816
|
resolveIgnoreErrors: true,
|
|
1814
|
-
produceLinkUrls: produceLinkUrls
|
|
1817
|
+
produceLinkUrls: produceLinkUrls,
|
|
1818
|
+
noAuth: noAuth
|
|
1815
1819
|
}));
|
|
1816
1820
|
|
|
1817
1821
|
case 6:
|
|
@@ -1841,7 +1845,8 @@ exports.AssetMetadata = function _callee25(_ref18) {
|
|
|
1841
1845
|
objectId: objectId,
|
|
1842
1846
|
versionHash: versionHash,
|
|
1843
1847
|
path: UrlJoin("public", "asset_metadata"),
|
|
1844
|
-
metadata: metadata
|
|
1848
|
+
metadata: metadata,
|
|
1849
|
+
noAuth: noAuth
|
|
1845
1850
|
}));
|
|
1846
1851
|
|
|
1847
1852
|
case 15:
|
|
@@ -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;
|
|
@@ -1246,7 +1245,6 @@ exports.CopyContentObject = function _callee12(_ref15) {
|
|
|
1246
1245
|
* @param {string} libraryId - ID of the library
|
|
1247
1246
|
* @param {string} objectId - ID of the object
|
|
1248
1247
|
* @param {string} publicKey - Public key for the target cap
|
|
1249
|
-
* @param {string} publicAddress - Public address for the target cap key
|
|
1250
1248
|
* @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
1249
|
*
|
|
1252
1250
|
* @returns {Promise<Object>}
|
|
@@ -1254,37 +1252,37 @@ exports.CopyContentObject = function _callee12(_ref15) {
|
|
|
1254
1252
|
|
|
1255
1253
|
|
|
1256
1254
|
exports.CreateNonOwnerCap = function _callee13(_ref17) {
|
|
1257
|
-
var objectId, libraryId, publicKey,
|
|
1255
|
+
var objectId, libraryId, publicKey, writeToken, userCapKey, userCapValue, userConk, publicAddress, targetUserCapKey, targetUserCapValue, finalize;
|
|
1258
1256
|
return _regeneratorRuntime.async(function _callee13$(_context14) {
|
|
1259
1257
|
while (1) {
|
|
1260
1258
|
switch (_context14.prev = _context14.next) {
|
|
1261
1259
|
case 0:
|
|
1262
|
-
objectId = _ref17.objectId, libraryId = _ref17.libraryId, publicKey = _ref17.publicKey,
|
|
1263
|
-
publicAddress = ValidateAddress(publicAddress);
|
|
1260
|
+
objectId = _ref17.objectId, libraryId = _ref17.libraryId, publicKey = _ref17.publicKey, writeToken = _ref17.writeToken;
|
|
1264
1261
|
userCapKey = "eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address));
|
|
1265
|
-
_context14.next =
|
|
1262
|
+
_context14.next = 4;
|
|
1266
1263
|
return _regeneratorRuntime.awrap(this.ContentObjectMetadata({
|
|
1267
1264
|
objectId: objectId,
|
|
1268
1265
|
libraryId: libraryId,
|
|
1269
1266
|
metadataSubtree: userCapKey
|
|
1270
1267
|
}));
|
|
1271
1268
|
|
|
1272
|
-
case
|
|
1269
|
+
case 4:
|
|
1273
1270
|
userCapValue = _context14.sent;
|
|
1274
1271
|
|
|
1275
1272
|
if (userCapValue) {
|
|
1276
|
-
_context14.next =
|
|
1273
|
+
_context14.next = 7;
|
|
1277
1274
|
break;
|
|
1278
1275
|
}
|
|
1279
1276
|
|
|
1280
1277
|
throw Error("No user cap found for current user");
|
|
1281
1278
|
|
|
1282
|
-
case
|
|
1283
|
-
_context14.next =
|
|
1279
|
+
case 7:
|
|
1280
|
+
_context14.next = 9;
|
|
1284
1281
|
return _regeneratorRuntime.awrap(this.Crypto.DecryptCap(userCapValue, this.signer.signingKey.privateKey));
|
|
1285
1282
|
|
|
1286
|
-
case
|
|
1283
|
+
case 9:
|
|
1287
1284
|
userConk = _context14.sent;
|
|
1285
|
+
publicAddress = this.utils.PublicKeyToAddress(publicKey);
|
|
1288
1286
|
targetUserCapKey = "eluv.caps.iusr".concat(this.utils.AddressToHash(publicAddress));
|
|
1289
1287
|
_context14.next = 14;
|
|
1290
1288
|
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",
|
|
@@ -703,7 +703,8 @@ exports.ProduceMetadataLinks = async function({
|
|
|
703
703
|
versionHash,
|
|
704
704
|
path="/",
|
|
705
705
|
metadata,
|
|
706
|
-
authorizationToken
|
|
706
|
+
authorizationToken,
|
|
707
|
+
noAuth
|
|
707
708
|
}) {
|
|
708
709
|
// Primitive
|
|
709
710
|
if(!metadata || typeof metadata !== "object") { return metadata; }
|
|
@@ -719,7 +720,8 @@ exports.ProduceMetadataLinks = async function({
|
|
|
719
720
|
versionHash,
|
|
720
721
|
path: UrlJoin(path, i.toString()),
|
|
721
722
|
metadata: entry,
|
|
722
|
-
authorizationToken
|
|
723
|
+
authorizationToken,
|
|
724
|
+
noAuth
|
|
723
725
|
})
|
|
724
726
|
);
|
|
725
727
|
}
|
|
@@ -747,7 +749,8 @@ exports.ProduceMetadataLinks = async function({
|
|
|
747
749
|
versionHash,
|
|
748
750
|
path: UrlJoin(path, key),
|
|
749
751
|
metadata: metadata[key],
|
|
750
|
-
authorizationToken
|
|
752
|
+
authorizationToken,
|
|
753
|
+
noAuth
|
|
751
754
|
});
|
|
752
755
|
}
|
|
753
756
|
);
|
|
@@ -924,7 +927,8 @@ exports.ContentObjectMetadata = async function({
|
|
|
924
927
|
versionHash,
|
|
925
928
|
path: metadataSubtree,
|
|
926
929
|
metadata,
|
|
927
|
-
authorizationToken
|
|
930
|
+
authorizationToken,
|
|
931
|
+
noAuth
|
|
928
932
|
});
|
|
929
933
|
};
|
|
930
934
|
|
|
@@ -951,7 +955,7 @@ exports.ContentObjectMetadata = async function({
|
|
|
951
955
|
* @param {boolean=} produceLinkUrls=false - If specified, file and rep links will automatically be populated with a
|
|
952
956
|
* full URL
|
|
953
957
|
*/
|
|
954
|
-
exports.AssetMetadata = async function({libraryId, objectId, versionHash, metadata, localization, produceLinkUrls=false}) {
|
|
958
|
+
exports.AssetMetadata = async function({libraryId, objectId, versionHash, metadata, localization, noAuth, produceLinkUrls=false}) {
|
|
955
959
|
ValidateParameters({libraryId, objectId, versionHash});
|
|
956
960
|
|
|
957
961
|
if(!objectId) {
|
|
@@ -967,7 +971,8 @@ exports.AssetMetadata = async function({libraryId, objectId, versionHash, metada
|
|
|
967
971
|
resolveLinks: true,
|
|
968
972
|
linkDepthLimit: 2,
|
|
969
973
|
resolveIgnoreErrors: true,
|
|
970
|
-
produceLinkUrls
|
|
974
|
+
produceLinkUrls,
|
|
975
|
+
noAuth
|
|
971
976
|
})) || {};
|
|
972
977
|
} else if(produceLinkUrls) {
|
|
973
978
|
metadata = await this.ProduceMetadataLinks({
|
|
@@ -975,7 +980,8 @@ exports.AssetMetadata = async function({libraryId, objectId, versionHash, metada
|
|
|
975
980
|
objectId,
|
|
976
981
|
versionHash,
|
|
977
982
|
path: UrlJoin("public", "asset_metadata"),
|
|
978
|
-
metadata
|
|
983
|
+
metadata,
|
|
984
|
+
noAuth
|
|
979
985
|
});
|
|
980
986
|
}
|
|
981
987
|
|
|
@@ -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}) {
|
|
@@ -691,13 +690,11 @@ exports.CopyContentObject = async function({libraryId, originalVersionHash, opti
|
|
|
691
690
|
* @param {string} libraryId - ID of the library
|
|
692
691
|
* @param {string} objectId - ID of the object
|
|
693
692
|
* @param {string} publicKey - Public key for the target cap
|
|
694
|
-
* @param {string} publicAddress - Public address for the target cap key
|
|
695
693
|
* @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
694
|
*
|
|
697
695
|
* @returns {Promise<Object>}
|
|
698
696
|
*/
|
|
699
|
-
exports.CreateNonOwnerCap = async function({objectId, libraryId, publicKey,
|
|
700
|
-
publicAddress = ValidateAddress(publicAddress);
|
|
697
|
+
exports.CreateNonOwnerCap = async function({objectId, libraryId, publicKey, writeToken}) {
|
|
701
698
|
const userCapKey = `eluv.caps.iusr${this.utils.AddressToHash(this.signer.address)}`;
|
|
702
699
|
const userCapValue = await this.ContentObjectMetadata({objectId, libraryId, metadataSubtree: userCapKey});
|
|
703
700
|
|
|
@@ -707,6 +704,8 @@ exports.CreateNonOwnerCap = async function({objectId, libraryId, publicKey, publ
|
|
|
707
704
|
|
|
708
705
|
const userConk = await this.Crypto.DecryptCap(userCapValue, this.signer.signingKey.privateKey);
|
|
709
706
|
|
|
707
|
+
const publicAddress = this.utils.PublicKeyToAddress(publicKey);
|
|
708
|
+
|
|
710
709
|
const targetUserCapKey = `eluv.caps.iusr${this.utils.AddressToHash(publicAddress)}`;
|
|
711
710
|
const targetUserCapValue = await this.Crypto.EncryptConk(userConk, publicKey);
|
|
712
711
|
|
|
@@ -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") },
|
|
@@ -51,8 +51,7 @@ const eventSiteSpec = {
|
|
|
51
51
|
},
|
|
52
52
|
{
|
|
53
53
|
"name": "tenant_slug",
|
|
54
|
-
"type": "text"
|
|
55
|
-
"required": true,
|
|
54
|
+
"type": "text"
|
|
56
55
|
},
|
|
57
56
|
{
|
|
58
57
|
"name": "marketplace_info",
|
|
@@ -299,6 +298,12 @@ const eventSiteSpec = {
|
|
|
299
298
|
"type": "fabric_link",
|
|
300
299
|
"video_preview": true
|
|
301
300
|
},
|
|
301
|
+
{
|
|
302
|
+
"name": "hero_video_mobile",
|
|
303
|
+
"label": "Hero Video (Mobile)",
|
|
304
|
+
"type": "fabric_link",
|
|
305
|
+
"video_preview": true
|
|
306
|
+
},
|
|
302
307
|
{
|
|
303
308
|
"extensions": imageTypes,
|
|
304
309
|
"label": "Header Image (Dark)",
|
|
@@ -323,64 +328,54 @@ const eventSiteSpec = {
|
|
|
323
328
|
"type": "file",
|
|
324
329
|
"label": "Main Logo (TV)"
|
|
325
330
|
},
|
|
326
|
-
{
|
|
327
|
-
"name": "main_page_banner",
|
|
328
|
-
"type": "subsection",
|
|
329
|
-
"fields": [
|
|
330
|
-
{
|
|
331
|
-
"name": "show",
|
|
332
|
-
"type": "checkbox"
|
|
333
|
-
},
|
|
334
|
-
{
|
|
335
|
-
"extensions": imageTypes,
|
|
336
|
-
"name": "image",
|
|
337
|
-
"type": "file",
|
|
338
|
-
"depends_on": "./show"
|
|
339
|
-
},
|
|
340
|
-
{
|
|
341
|
-
"extensions": imageTypes,
|
|
342
|
-
"name": "image_mobile",
|
|
343
|
-
"label": "Image (Mobile)",
|
|
344
|
-
"type": "file",
|
|
345
|
-
"depends_on": "./show"
|
|
346
|
-
},
|
|
347
|
-
{
|
|
348
|
-
"name": "type",
|
|
349
|
-
"type": "select",
|
|
350
|
-
"options": [
|
|
351
|
-
"drop",
|
|
352
|
-
"marketplace",
|
|
353
|
-
"link"
|
|
354
|
-
],
|
|
355
|
-
"default_value": "marketplace",
|
|
356
|
-
"hint": "Specify what happens when clicking on the banner. The banner can link to a URL or a drop, or it can open the marketplace view.",
|
|
357
|
-
"depends_on": "./show"
|
|
358
|
-
},
|
|
359
|
-
{
|
|
360
|
-
"name": "marketplace_filters",
|
|
361
|
-
"type": "list",
|
|
362
|
-
"hint": "If the banner links to the marketplace, you can specify filters to apply when the marketplace is opened via the banner.",
|
|
363
|
-
"depends_on": "./show"
|
|
364
|
-
},
|
|
365
|
-
{
|
|
366
|
-
"name": "link",
|
|
367
|
-
"type": "text",
|
|
368
|
-
"hint": "If the banner is a link, specify the URL to link to.",
|
|
369
|
-
"depends_on": "./show"
|
|
370
|
-
},
|
|
371
|
-
{
|
|
372
|
-
"label": "Drop UUID",
|
|
373
|
-
"name": "drop_uuid",
|
|
374
|
-
"type": "text",
|
|
375
|
-
"hint": "If the banner links to a drop, you can specify a specific drop to link to. If not specified, the banner will link to the next upcoming drop.",
|
|
376
|
-
"depends_on": "./show"
|
|
377
|
-
}
|
|
378
|
-
]
|
|
379
|
-
}
|
|
380
331
|
],
|
|
381
332
|
"name": "event_images",
|
|
382
333
|
"type": "subsection"
|
|
383
334
|
},
|
|
335
|
+
{
|
|
336
|
+
"name": "main_page_banners",
|
|
337
|
+
"type": "list",
|
|
338
|
+
"fields": [
|
|
339
|
+
{
|
|
340
|
+
"extensions": imageTypes,
|
|
341
|
+
"name": "image",
|
|
342
|
+
"type": "file",
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
"extensions": imageTypes,
|
|
346
|
+
"name": "image_mobile",
|
|
347
|
+
"label": "Image (Mobile)",
|
|
348
|
+
"type": "file",
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
"name": "type",
|
|
352
|
+
"type": "select",
|
|
353
|
+
"options": [
|
|
354
|
+
"drop",
|
|
355
|
+
"marketplace",
|
|
356
|
+
"link"
|
|
357
|
+
],
|
|
358
|
+
"default_value": "marketplace",
|
|
359
|
+
"hint": "Specify what happens when clicking on the banner. The banner can link to a URL or a drop, or it can open the marketplace view.",
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
"name": "marketplace_filters",
|
|
363
|
+
"type": "list",
|
|
364
|
+
"hint": "If the banner links to the marketplace, you can specify filters to apply when the marketplace is opened via the banner.",
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
"name": "link",
|
|
368
|
+
"type": "text",
|
|
369
|
+
"hint": "If the banner is a link, specify the URL to link to.",
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
"label": "Drop UUID",
|
|
373
|
+
"name": "drop_uuid",
|
|
374
|
+
"type": "text",
|
|
375
|
+
"hint": "If the banner links to a drop, you can specify a specific drop to link to. If not specified, the banner will link to the next upcoming drop.",
|
|
376
|
+
}
|
|
377
|
+
]
|
|
378
|
+
},
|
|
384
379
|
{
|
|
385
380
|
"name": "promo_videos",
|
|
386
381
|
"type": "list",
|