@eluvio/elv-client-js 4.0.36 → 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/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) {
|
package/typeSpecs/Default.js
CHANGED
|
@@ -77,7 +77,7 @@ const defaultSpec = {
|
|
|
77
77
|
],
|
|
78
78
|
searchable_links: [
|
|
79
79
|
{target: "/public/asset_metadata", link_key: "asset_metadata"},
|
|
80
|
-
{target: "/
|
|
80
|
+
{target: "/assets", link_key: "assets"},
|
|
81
81
|
{target: "/offerings", link_key: "offerings"},
|
|
82
82
|
{target: "/video_tags", link_key: "video_tags"}
|
|
83
83
|
]
|
|
@@ -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();
|