@eluvio/elv-client-js 4.0.37 → 4.0.38
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/ElvWalletClient-min.js +2 -2
- package/dist/ElvWalletClient-node-min.js +9 -9
- package/dist/src/walletClient/ClientMethods.js +569 -716
- package/dist/src/walletClient/Configuration.js +1 -1
- package/dist/src/walletClient/index.js +34 -77
- package/package.json +1 -1
- package/src/walletClient/Utils.js +3 -1
- package/src/walletClient/index.js +94 -24
- package/utilities/GenerateFabricToken.js +23 -0
|
@@ -27,7 +27,7 @@ var WalletConfiguration = {
|
|
|
27
27
|
appUrl: "https://wallet.contentfabric.io"
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
|
-
__MARKETPLACE_ORDER: ["PREVIEW", "
|
|
30
|
+
__MARKETPLACE_ORDER: ["PREVIEW", "masked-singer-brazil-marketplace", "eluvio-live-marketplace-globo-taf", "de228e92-ed45-4fe0-8e52-658cf366e962", "wwe-marketplace-main", "maskverse-marketplace", "dolly-marketplace", "eluvio-live-marketplace-sonark", "cirkay-marketplace", "eluvio-live-marketplace-fuudge", "oc-marketplace", "emp-marketplace", "microsoft", "indieflix-marketplace", "angels-airwaves-marketplace", "realcannonballrun-marketplace"]
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
// No production environment on demo
|
|
@@ -808,27 +808,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
808
808
|
return _SignMetamask.apply(this, arguments);
|
|
809
809
|
}
|
|
810
810
|
return SignMetamask;
|
|
811
|
-
}()
|
|
812
|
-
}, {
|
|
813
|
-
key: "FlowURL",
|
|
814
|
-
value: function FlowURL(_ref12) {
|
|
815
|
-
var _ref12$type = _ref12.type,
|
|
816
|
-
type = _ref12$type === void 0 ? "flow" : _ref12$type,
|
|
817
|
-
flow = _ref12.flow,
|
|
818
|
-
marketplaceId = _ref12.marketplaceId,
|
|
819
|
-
_ref12$parameters = _ref12.parameters,
|
|
820
|
-
parameters = _ref12$parameters === void 0 ? {} : _ref12$parameters;
|
|
821
|
-
var url = new URL(this.appUrl);
|
|
822
|
-
if (marketplaceId) {
|
|
823
|
-
url.hash = UrlJoin("/", type, flow, "marketplace", marketplaceId, Utils.B58(JSON.stringify(parameters)));
|
|
824
|
-
} else {
|
|
825
|
-
url.hash = UrlJoin("/", type, flow, Utils.B58(JSON.stringify(parameters)));
|
|
826
|
-
}
|
|
827
|
-
url.searchParams.set("origin", window.location.origin);
|
|
828
|
-
return url.toString();
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
// Internal loading methods
|
|
811
|
+
}() // Internal loading methods
|
|
832
812
|
}, {
|
|
833
813
|
key: "LoadAvailableMarketplaces",
|
|
834
814
|
value: function () {
|
|
@@ -864,8 +844,8 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
864
844
|
produceLinkUrls: true,
|
|
865
845
|
authorizationToken: this.publicStaticToken,
|
|
866
846
|
noAuth: true,
|
|
867
|
-
select: ["*/.", "*/
|
|
868
|
-
remove: ["*/
|
|
847
|
+
select: ["*/.", "*/marketplaces/*/.", "*/marketplaces/*/info/tenant_id", "*/marketplaces/*/info/tenant_name", "*/marketplaces/*/info/branding", "*/marketplaces/*/info/storefront/background", "*/marketplaces/*/info/storefront/background_mobile"],
|
|
848
|
+
remove: ["*/marketplaces/*/info/branding/custom_css"]
|
|
869
849
|
});
|
|
870
850
|
case 5:
|
|
871
851
|
metadata = _context12.sent;
|
|
@@ -942,7 +922,6 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
942
922
|
marketplaceSlug: marketplaceSlug,
|
|
943
923
|
marketplaceId: objectId,
|
|
944
924
|
marketplaceHash: versionHash,
|
|
945
|
-
tenantBranding: (metadata[tenantSlug].info || {}).branding || {},
|
|
946
925
|
order: Configuration.__MARKETPLACE_ORDER.findIndex(function (slug) {
|
|
947
926
|
return slug === marketplaceSlug;
|
|
948
927
|
})
|
|
@@ -980,12 +959,12 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
980
959
|
}, {
|
|
981
960
|
key: "LatestMarketplaceHash",
|
|
982
961
|
value: function () {
|
|
983
|
-
var _LatestMarketplaceHash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(
|
|
962
|
+
var _LatestMarketplaceHash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref12) {
|
|
984
963
|
var marketplaceParams, marketplaceInfo, marketplaceLink;
|
|
985
964
|
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
986
965
|
while (1) switch (_context13.prev = _context13.next) {
|
|
987
966
|
case 0:
|
|
988
|
-
marketplaceParams =
|
|
967
|
+
marketplaceParams = _ref12.marketplaceParams;
|
|
989
968
|
_context13.next = 3;
|
|
990
969
|
return this.MarketplaceInfo({
|
|
991
970
|
marketplaceParams: marketplaceParams
|
|
@@ -1043,7 +1022,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1043
1022
|
delete this.cachedMarketplaces[marketplaceId];
|
|
1044
1023
|
}
|
|
1045
1024
|
if (this.cachedMarketplaces[marketplaceId]) {
|
|
1046
|
-
_context15.next =
|
|
1025
|
+
_context15.next = 21;
|
|
1047
1026
|
break;
|
|
1048
1027
|
}
|
|
1049
1028
|
_context15.next = 9;
|
|
@@ -1061,31 +1040,9 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1061
1040
|
});
|
|
1062
1041
|
case 9:
|
|
1063
1042
|
marketplace = _context15.sent;
|
|
1064
|
-
|
|
1065
|
-
_context15.next = 17;
|
|
1066
|
-
break;
|
|
1067
|
-
}
|
|
1068
|
-
_context15.next = 13;
|
|
1069
|
-
return this.client.ContentObjectMetadata({
|
|
1070
|
-
libraryId: this.mainSiteLibraryId,
|
|
1071
|
-
objectId: this.mainSiteId,
|
|
1072
|
-
metadataSubtree: UrlJoin("/public", "asset_metadata", "tenants", marketplaceInfo.tenantSlug, "info", "branding"),
|
|
1073
|
-
authorizationToken: this.publicStaticToken,
|
|
1074
|
-
produceLinkUrls: true
|
|
1075
|
-
});
|
|
1076
|
-
case 13:
|
|
1077
|
-
_context15.t0 = _context15.sent;
|
|
1078
|
-
if (_context15.t0) {
|
|
1079
|
-
_context15.next = 16;
|
|
1080
|
-
break;
|
|
1081
|
-
}
|
|
1082
|
-
_context15.t0 = {};
|
|
1083
|
-
case 16:
|
|
1084
|
-
marketplace.tenantBranding = _context15.t0;
|
|
1085
|
-
case 17:
|
|
1086
|
-
_context15.next = 19;
|
|
1043
|
+
_context15.next = 12;
|
|
1087
1044
|
return Promise.all(marketplace.items.map( /*#__PURE__*/function () {
|
|
1088
|
-
var
|
|
1045
|
+
var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(item, index) {
|
|
1089
1046
|
var authorizationToken;
|
|
1090
1047
|
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
1091
1048
|
while (1) switch (_context14.prev = _context14.next) {
|
|
@@ -1130,10 +1087,10 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1130
1087
|
}, _callee14, null, [[5, 11]]);
|
|
1131
1088
|
}));
|
|
1132
1089
|
return function (_x18, _x19) {
|
|
1133
|
-
return
|
|
1090
|
+
return _ref13.apply(this, arguments);
|
|
1134
1091
|
};
|
|
1135
1092
|
}()));
|
|
1136
|
-
case
|
|
1093
|
+
case 12:
|
|
1137
1094
|
marketplace.items = _context15.sent;
|
|
1138
1095
|
marketplace.collections = (marketplace.collections || []).map(function (collection, collectionIndex) {
|
|
1139
1096
|
return _objectSpread(_objectSpread({}, collection), {}, {
|
|
@@ -1169,9 +1126,9 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1169
1126
|
} catch (error) {}
|
|
1170
1127
|
});
|
|
1171
1128
|
this.cachedMarketplaces[marketplaceId] = marketplace;
|
|
1172
|
-
case
|
|
1129
|
+
case 21:
|
|
1173
1130
|
return _context15.abrupt("return", this.cachedMarketplaces[marketplaceId]);
|
|
1174
|
-
case
|
|
1131
|
+
case 22:
|
|
1175
1132
|
case "end":
|
|
1176
1133
|
return _context15.stop();
|
|
1177
1134
|
}
|
|
@@ -1187,12 +1144,12 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1187
1144
|
value: function () {
|
|
1188
1145
|
var _FilteredQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16() {
|
|
1189
1146
|
var _this6 = this;
|
|
1190
|
-
var
|
|
1191
|
-
|
|
1147
|
+
var _ref14,
|
|
1148
|
+
_ref14$mode,
|
|
1192
1149
|
mode,
|
|
1193
|
-
|
|
1150
|
+
_ref14$sortBy,
|
|
1194
1151
|
sortBy,
|
|
1195
|
-
|
|
1152
|
+
_ref14$sortDesc,
|
|
1196
1153
|
sortDesc,
|
|
1197
1154
|
filter,
|
|
1198
1155
|
editionFilters,
|
|
@@ -1208,27 +1165,27 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1208
1165
|
capLimit,
|
|
1209
1166
|
userAddress,
|
|
1210
1167
|
sellerAddress,
|
|
1211
|
-
|
|
1168
|
+
_ref14$lastNDays,
|
|
1212
1169
|
lastNDays,
|
|
1213
|
-
|
|
1170
|
+
_ref14$includeCheckou,
|
|
1214
1171
|
includeCheckoutLocked,
|
|
1215
|
-
|
|
1172
|
+
_ref14$start,
|
|
1216
1173
|
start,
|
|
1217
|
-
|
|
1174
|
+
_ref14$limit,
|
|
1218
1175
|
limit,
|
|
1219
1176
|
params,
|
|
1220
1177
|
marketplaceInfo,
|
|
1221
1178
|
marketplace,
|
|
1222
1179
|
filters,
|
|
1223
1180
|
path,
|
|
1224
|
-
|
|
1181
|
+
_ref16,
|
|
1225
1182
|
contents,
|
|
1226
1183
|
paging,
|
|
1227
1184
|
_args16 = arguments;
|
|
1228
1185
|
return _regeneratorRuntime.wrap(function _callee16$(_context16) {
|
|
1229
1186
|
while (1) switch (_context16.prev = _context16.next) {
|
|
1230
1187
|
case 0:
|
|
1231
|
-
|
|
1188
|
+
_ref14 = _args16.length > 0 && _args16[0] !== undefined ? _args16[0] : {}, _ref14$mode = _ref14.mode, mode = _ref14$mode === void 0 ? "listings" : _ref14$mode, _ref14$sortBy = _ref14.sortBy, sortBy = _ref14$sortBy === void 0 ? "created" : _ref14$sortBy, _ref14$sortDesc = _ref14.sortDesc, sortDesc = _ref14$sortDesc === void 0 ? false : _ref14$sortDesc, filter = _ref14.filter, editionFilters = _ref14.editionFilters, attributeFilters = _ref14.attributeFilters, contractAddress = _ref14.contractAddress, tokenId = _ref14.tokenId, currency = _ref14.currency, marketplaceParams = _ref14.marketplaceParams, tenantId = _ref14.tenantId, collectionIndexes = _ref14.collectionIndexes, priceRange = _ref14.priceRange, tokenIdRange = _ref14.tokenIdRange, capLimit = _ref14.capLimit, userAddress = _ref14.userAddress, sellerAddress = _ref14.sellerAddress, _ref14$lastNDays = _ref14.lastNDays, lastNDays = _ref14$lastNDays === void 0 ? -1 : _ref14$lastNDays, _ref14$includeCheckou = _ref14.includeCheckoutLocked, includeCheckoutLocked = _ref14$includeCheckou === void 0 ? false : _ref14$includeCheckou, _ref14$start = _ref14.start, start = _ref14$start === void 0 ? 0 : _ref14$start, _ref14$limit = _ref14.limit, limit = _ref14$limit === void 0 ? 50 : _ref14$limit;
|
|
1232
1189
|
collectionIndexes = (collectionIndexes || []).map(function (i) {
|
|
1233
1190
|
return parseInt(i);
|
|
1234
1191
|
});
|
|
@@ -1327,9 +1284,9 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1327
1284
|
});
|
|
1328
1285
|
}
|
|
1329
1286
|
if (attributeFilters) {
|
|
1330
|
-
attributeFilters.map(function (
|
|
1331
|
-
var name =
|
|
1332
|
-
value =
|
|
1287
|
+
attributeFilters.map(function (_ref15) {
|
|
1288
|
+
var name = _ref15.name,
|
|
1289
|
+
value = _ref15.value;
|
|
1333
1290
|
if (!name || !value) {
|
|
1334
1291
|
return;
|
|
1335
1292
|
}
|
|
@@ -1426,9 +1383,9 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1426
1383
|
}
|
|
1427
1384
|
_context16.t1 = [];
|
|
1428
1385
|
case 62:
|
|
1429
|
-
|
|
1430
|
-
contents =
|
|
1431
|
-
paging =
|
|
1386
|
+
_ref16 = _context16.t1;
|
|
1387
|
+
contents = _ref16.contents;
|
|
1388
|
+
paging = _ref16.paging;
|
|
1432
1389
|
return _context16.abrupt("return", {
|
|
1433
1390
|
paging: {
|
|
1434
1391
|
start: params.start,
|
|
@@ -1472,12 +1429,12 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1472
1429
|
}, {
|
|
1473
1430
|
key: "MintingStatus",
|
|
1474
1431
|
value: function () {
|
|
1475
|
-
var _MintingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(
|
|
1432
|
+
var _MintingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(_ref17) {
|
|
1476
1433
|
var marketplaceParams, tenantId, marketplaceInfo, response;
|
|
1477
1434
|
return _regeneratorRuntime.wrap(function _callee17$(_context17) {
|
|
1478
1435
|
while (1) switch (_context17.prev = _context17.next) {
|
|
1479
1436
|
case 0:
|
|
1480
|
-
marketplaceParams =
|
|
1437
|
+
marketplaceParams = _ref17.marketplaceParams, tenantId = _ref17.tenantId;
|
|
1481
1438
|
if (tenantId) {
|
|
1482
1439
|
_context17.next = 6;
|
|
1483
1440
|
break;
|
|
@@ -1590,13 +1547,13 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1590
1547
|
}, {
|
|
1591
1548
|
key: "Initialize",
|
|
1592
1549
|
value: function () {
|
|
1593
|
-
var _Initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(
|
|
1594
|
-
var client,
|
|
1550
|
+
var _Initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(_ref18) {
|
|
1551
|
+
var client, _ref18$appId, appId, _ref18$network, network, _ref18$mode, mode, localization, marketplaceParams, previewMarketplaceId, _ref18$storeAuthToken, storeAuthToken, _ref18$skipMarketplac, skipMarketplaceLoad, _ref19, tenantSlug, marketplaceSlug, marketplaceId, marketplaceHash, previewMarketplaceHash, walletClient, url, savedToken;
|
|
1595
1552
|
return _regeneratorRuntime.wrap(function _callee18$(_context18) {
|
|
1596
1553
|
while (1) switch (_context18.prev = _context18.next) {
|
|
1597
1554
|
case 0:
|
|
1598
|
-
client =
|
|
1599
|
-
|
|
1555
|
+
client = _ref18.client, _ref18$appId = _ref18.appId, appId = _ref18$appId === void 0 ? "general" : _ref18$appId, _ref18$network = _ref18.network, network = _ref18$network === void 0 ? "main" : _ref18$network, _ref18$mode = _ref18.mode, mode = _ref18$mode === void 0 ? "production" : _ref18$mode, localization = _ref18.localization, marketplaceParams = _ref18.marketplaceParams, previewMarketplaceId = _ref18.previewMarketplaceId, _ref18$storeAuthToken = _ref18.storeAuthToken, storeAuthToken = _ref18$storeAuthToken === void 0 ? true : _ref18$storeAuthToken, _ref18$skipMarketplac = _ref18.skipMarketplaceLoad, skipMarketplaceLoad = _ref18$skipMarketplac === void 0 ? false : _ref18$skipMarketplac;
|
|
1556
|
+
_ref19 = marketplaceParams || {}, tenantSlug = _ref19.tenantSlug, marketplaceSlug = _ref19.marketplaceSlug, marketplaceId = _ref19.marketplaceId, marketplaceHash = _ref19.marketplaceHash;
|
|
1600
1557
|
if (Configuration[network]) {
|
|
1601
1558
|
_context18.next = 6;
|
|
1602
1559
|
break;
|
package/package.json
CHANGED
|
@@ -283,6 +283,42 @@ class ElvWalletClient {
|
|
|
283
283
|
});
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
+
async LogInURL({
|
|
287
|
+
mode="login",
|
|
288
|
+
provider,
|
|
289
|
+
marketplaceParams,
|
|
290
|
+
clearLogin
|
|
291
|
+
}) {
|
|
292
|
+
let loginUrl = new URL(this.appUrl);
|
|
293
|
+
loginUrl.hash = "/login";
|
|
294
|
+
|
|
295
|
+
loginUrl.searchParams.set("action", "login");
|
|
296
|
+
|
|
297
|
+
if(typeof window !== "undefined") {
|
|
298
|
+
loginUrl.searchParams.set("origin", window.location.origin);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
if(provider) {
|
|
302
|
+
loginUrl.searchParams.set("provider", provider);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
if(mode) {
|
|
306
|
+
loginUrl.searchParams.set("mode", mode);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
if(marketplaceParams) {
|
|
310
|
+
loginUrl.searchParams.set("mid", (await this.MarketplaceInfo({marketplaceParams})).marketplaceHash);
|
|
311
|
+
} else if((this.selectedMarketplaceInfo || {}).marketplaceHash) {
|
|
312
|
+
loginUrl.searchParams.set("mid", this.selectedMarketplaceInfo.marketplaceHash);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
if(clearLogin) {
|
|
316
|
+
loginUrl.searchParams.set("clear", "");
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
return loginUrl;
|
|
320
|
+
}
|
|
321
|
+
|
|
286
322
|
/**
|
|
287
323
|
* Direct the user to the Eluvio Media Wallet login page.
|
|
288
324
|
*
|
|
@@ -313,29 +349,7 @@ class ElvWalletClient {
|
|
|
313
349
|
clearLogin=false,
|
|
314
350
|
callback
|
|
315
351
|
}) {
|
|
316
|
-
let loginUrl =
|
|
317
|
-
loginUrl.hash = "/login";
|
|
318
|
-
|
|
319
|
-
loginUrl.searchParams.set("origin", window.location.origin);
|
|
320
|
-
loginUrl.searchParams.set("action", "login");
|
|
321
|
-
|
|
322
|
-
if(provider) {
|
|
323
|
-
loginUrl.searchParams.set("provider", provider);
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
if(mode) {
|
|
327
|
-
loginUrl.searchParams.set("mode", mode);
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
if(marketplaceParams) {
|
|
331
|
-
loginUrl.searchParams.set("mid", (await this.MarketplaceInfo({marketplaceParams})).marketplaceHash);
|
|
332
|
-
} else if((this.selectedMarketplaceInfo || {}).marketplaceHash) {
|
|
333
|
-
loginUrl.searchParams.set("mid", this.selectedMarketplaceInfo.marketplaceHash);
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
if(clearLogin) {
|
|
337
|
-
loginUrl.searchParams.set("clear", "");
|
|
338
|
-
}
|
|
352
|
+
let loginUrl = await this.LogInURL({mode, provider, marketplaceParams, clearLogin});
|
|
339
353
|
|
|
340
354
|
if(method === "redirect") {
|
|
341
355
|
loginUrl.searchParams.set("response", "redirect");
|
|
@@ -632,10 +646,66 @@ class ElvWalletClient {
|
|
|
632
646
|
return url.toString();
|
|
633
647
|
}
|
|
634
648
|
|
|
649
|
+
async GenerateCodeAuth({url}={}) {
|
|
650
|
+
if(!url) {
|
|
651
|
+
url = await this.LogInURL({mode: "login"});
|
|
635
652
|
|
|
636
|
-
|
|
653
|
+
url.searchParams.set("response", "code");
|
|
654
|
+
url.searchParams.set("source", "code");
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
const response = await Utils.ResponseToJson(
|
|
658
|
+
this.client.authClient.MakeAuthServiceRequest({
|
|
659
|
+
path: UrlJoin("as", "wlt", "login", "redirect", "metamask"),
|
|
660
|
+
method: "POST",
|
|
661
|
+
body: {
|
|
662
|
+
op: "create",
|
|
663
|
+
dest: url.toString()
|
|
664
|
+
}
|
|
665
|
+
})
|
|
666
|
+
);
|
|
637
667
|
|
|
668
|
+
response.code = response.id;
|
|
669
|
+
response.url = response.url.startsWith("https://") ? response.url : `https://${response.url}`;
|
|
670
|
+
response.metamask_url = response.metamask_url.startsWith("https://") ? response.metamask_url : `https://${response.metamask_url}`;
|
|
638
671
|
|
|
672
|
+
return response;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
async SetCodeAuth({code, authToken}) {
|
|
676
|
+
await Utils.ResponseToJson(
|
|
677
|
+
this.client.authClient.MakeAuthServiceRequest({
|
|
678
|
+
path: UrlJoin("as", "wlt", "login", "session", code),
|
|
679
|
+
method: "POST",
|
|
680
|
+
headers: {
|
|
681
|
+
Authorization: `Bearer ${this.AuthToken()}`
|
|
682
|
+
},
|
|
683
|
+
body: {
|
|
684
|
+
op: "set",
|
|
685
|
+
id: code,
|
|
686
|
+
format: "auth_token",
|
|
687
|
+
payload: authToken
|
|
688
|
+
}
|
|
689
|
+
})
|
|
690
|
+
);
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
async GetCodeAuth({code, passcode}) {
|
|
694
|
+
try {
|
|
695
|
+
return await Utils.ResponseToJson(
|
|
696
|
+
this.client.authClient.MakeAuthServiceRequest({
|
|
697
|
+
path: UrlJoin("as", "wlt", "login", "redirect", "metamask", code, passcode),
|
|
698
|
+
method: "GET",
|
|
699
|
+
})
|
|
700
|
+
);
|
|
701
|
+
} catch(error) {
|
|
702
|
+
if(error && error.status === 404) { return undefined; }
|
|
703
|
+
|
|
704
|
+
throw error;
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
// Internal loading methods
|
|
639
709
|
|
|
640
710
|
async LoadAvailableMarketplaces(forceReload=false) {
|
|
641
711
|
if(!forceReload && Object.keys(this.availableMarketplaces) > 0) {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const { ElvClient } = require("../src/ElvClient");
|
|
2
|
+
|
|
3
|
+
const GenerateFabricToken = async () => {
|
|
4
|
+
try {
|
|
5
|
+
const client = await ElvClient.FromNetworkName({networkName: "main"});
|
|
6
|
+
|
|
7
|
+
const wallet = client.GenerateWallet();
|
|
8
|
+
const signer = wallet.AddAccount({
|
|
9
|
+
privateKey: process.env.PRIVATE_KEY
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
client.SetSigner({signer});
|
|
13
|
+
|
|
14
|
+
console.log(await client.CreateFabricToken({duration: process.env.DURATION}));
|
|
15
|
+
} catch(error) {
|
|
16
|
+
console.error(error);
|
|
17
|
+
console.error(JSON.stringify(error, null, 2));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
process.exit(0);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
GenerateFabricToken();
|