@eluvio/elv-client-js 3.2.8 → 3.2.11
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 +8 -8
- package/dist/ElvClient-node-min.js +2 -2
- package/dist/ElvWalletClient-min.js +1 -1
- package/dist/ElvWalletClient-node-min.js +2 -2
- package/dist/src/ElvClient.js +5 -4
- package/dist/src/RemoteSigner.js +2 -2
- package/dist/src/walletClient/Configuration.js +1 -1
- package/dist/src/walletClient/index.js +81 -56
- package/package.json +1 -1
- package/src/ElvClient.js +3 -2
- package/src/RemoteSigner.js +2 -2
- package/src/walletClient/Configuration.js +1 -1
- package/src/walletClient/index.js +21 -8
package/dist/src/ElvClient.js
CHANGED
|
@@ -652,6 +652,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
652
652
|
* @param {string=} authToken - Eluvio authorization token previously issued from OAuth ID token
|
|
653
653
|
* @param {string=} tenantId - If specified, user will be associated with the tenant
|
|
654
654
|
* @param {Object=} extraData - Additional data to pass to the login API
|
|
655
|
+
* @param {Array<string>=} signerURIs - (Only if using custom OAuth) - URIs corresponding to the key server(s) to use
|
|
655
656
|
* @param {boolean=} unsignedPublicAuth=false - If specified, the client will use an unsigned static token for calls that don't require authorization (reduces remote signature calls)
|
|
656
657
|
*/
|
|
657
658
|
|
|
@@ -659,14 +660,14 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
659
660
|
key: "SetRemoteSigner",
|
|
660
661
|
value: function () {
|
|
661
662
|
var _SetRemoteSigner = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref8) {
|
|
662
|
-
var idToken, authToken, tenantId, extraData, unsignedPublicAuth, signer;
|
|
663
|
+
var idToken, authToken, tenantId, extraData, signerURIs, unsignedPublicAuth, signer;
|
|
663
664
|
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
664
665
|
while (1) {
|
|
665
666
|
switch (_context6.prev = _context6.next) {
|
|
666
667
|
case 0:
|
|
667
|
-
idToken = _ref8.idToken, authToken = _ref8.authToken, tenantId = _ref8.tenantId, extraData = _ref8.extraData, unsignedPublicAuth = _ref8.unsignedPublicAuth;
|
|
668
|
+
idToken = _ref8.idToken, authToken = _ref8.authToken, tenantId = _ref8.tenantId, extraData = _ref8.extraData, signerURIs = _ref8.signerURIs, unsignedPublicAuth = _ref8.unsignedPublicAuth;
|
|
668
669
|
_context6.t0 = RemoteSigner;
|
|
669
|
-
_context6.t1 = this.authServiceURIs;
|
|
670
|
+
_context6.t1 = signerURIs || this.authServiceURIs;
|
|
670
671
|
_context6.t2 = idToken;
|
|
671
672
|
_context6.t3 = authToken;
|
|
672
673
|
_context6.t4 = tenantId;
|
|
@@ -678,7 +679,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
678
679
|
_context6.t6 = extraData;
|
|
679
680
|
_context6.t7 = unsignedPublicAuth;
|
|
680
681
|
_context6.t8 = {
|
|
681
|
-
|
|
682
|
+
signerURIs: _context6.t1,
|
|
682
683
|
idToken: _context6.t2,
|
|
683
684
|
authToken: _context6.t3,
|
|
684
685
|
tenantId: _context6.t4,
|
package/dist/src/RemoteSigner.js
CHANGED
|
@@ -34,7 +34,7 @@ var RemoteSigner = /*#__PURE__*/function (_Ethers$Signer) {
|
|
|
34
34
|
function RemoteSigner(_ref) {
|
|
35
35
|
var _this;
|
|
36
36
|
|
|
37
|
-
var
|
|
37
|
+
var signerURIs = _ref.signerURIs,
|
|
38
38
|
idToken = _ref.idToken,
|
|
39
39
|
authToken = _ref.authToken,
|
|
40
40
|
tenantId = _ref.tenantId,
|
|
@@ -50,7 +50,7 @@ var RemoteSigner = /*#__PURE__*/function (_Ethers$Signer) {
|
|
|
50
50
|
_this.remoteSigner = true;
|
|
51
51
|
_this.unsignedPublicAuth = unsignedPublicAuth;
|
|
52
52
|
_this.HttpClient = new HttpClient({
|
|
53
|
-
uris:
|
|
53
|
+
uris: signerURIs
|
|
54
54
|
});
|
|
55
55
|
_this.idToken = idToken;
|
|
56
56
|
_this.tenantId = tenantId;
|
|
@@ -12,7 +12,7 @@ var WalletConfiguration = {
|
|
|
12
12
|
staging: {
|
|
13
13
|
siteId: "iq__inauxD1KLyKWPHargCWjdCh2ayr",
|
|
14
14
|
purchaseMode: "production",
|
|
15
|
-
appUrl: "https://
|
|
15
|
+
appUrl: "https://wallet.preview.contentfabric.io"
|
|
16
16
|
},
|
|
17
17
|
production: {
|
|
18
18
|
siteId: "iq__suqRJUt2vmXsyiWS5ZaSGwtFU9R",
|
|
@@ -31,6 +31,8 @@ var UrlJoin = require("url-join");
|
|
|
31
31
|
var Utils = require("../Utils");
|
|
32
32
|
|
|
33
33
|
var Ethers = require("ethers");
|
|
34
|
+
|
|
35
|
+
var inBrowser = typeof window !== "undefined";
|
|
34
36
|
/**
|
|
35
37
|
* Use the <a href="#.Initialize">Initialize</a> method to initialize a new client.
|
|
36
38
|
*
|
|
@@ -38,7 +40,6 @@ var Ethers = require("ethers");
|
|
|
38
40
|
* See the Modules section on the sidebar for all client methods unrelated to login and authorization
|
|
39
41
|
*/
|
|
40
42
|
|
|
41
|
-
|
|
42
43
|
var ElvWalletClient = /*#__PURE__*/function () {
|
|
43
44
|
"use strict";
|
|
44
45
|
|
|
@@ -116,7 +117,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
116
117
|
return false;
|
|
117
118
|
}
|
|
118
119
|
|
|
119
|
-
return !!this.__authorization.clusterToken || !!(this.UserInfo().walletName.toLowerCase() === "metamask" && window.ethereum && window.ethereum.isMetaMask && window.ethereum.chainId);
|
|
120
|
+
return !!this.__authorization.clusterToken || inBrowser && !!(this.UserInfo().walletName.toLowerCase() === "metamask" && window.ethereum && window.ethereum.isMetaMask && window.ethereum.chainId);
|
|
120
121
|
}
|
|
121
122
|
/**
|
|
122
123
|
* <b><i>Requires login</i></b>
|
|
@@ -156,7 +157,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
156
157
|
|
|
157
158
|
case 3:
|
|
158
159
|
if (!this.CanSign()) {
|
|
159
|
-
_context3.next =
|
|
160
|
+
_context3.next = 19;
|
|
160
161
|
break;
|
|
161
162
|
}
|
|
162
163
|
|
|
@@ -189,6 +190,18 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
189
190
|
throw Error("ElvWalletClient: Unable to sign");
|
|
190
191
|
|
|
191
192
|
case 17:
|
|
193
|
+
_context3.next = 21;
|
|
194
|
+
break;
|
|
195
|
+
|
|
196
|
+
case 19:
|
|
197
|
+
if (inBrowser) {
|
|
198
|
+
_context3.next = 21;
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
throw Error("ElvWalletClient: Unable to sign");
|
|
203
|
+
|
|
204
|
+
case 21:
|
|
192
205
|
parameters = {
|
|
193
206
|
action: "personal-sign",
|
|
194
207
|
message: message,
|
|
@@ -197,7 +210,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
197
210
|
url = new URL(this.appUrl);
|
|
198
211
|
url.hash = UrlJoin("/action", "sign", Utils.B58(JSON.stringify(parameters)));
|
|
199
212
|
url.searchParams.set("origin", window.location.origin);
|
|
200
|
-
_context3.next =
|
|
213
|
+
_context3.next = 27;
|
|
201
214
|
return new Promise( /*#__PURE__*/function () {
|
|
202
215
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resolve, reject) {
|
|
203
216
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
@@ -262,10 +275,10 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
262
275
|
};
|
|
263
276
|
}());
|
|
264
277
|
|
|
265
|
-
case
|
|
278
|
+
case 27:
|
|
266
279
|
return _context3.abrupt("return", _context3.sent);
|
|
267
280
|
|
|
268
|
-
case
|
|
281
|
+
case 28:
|
|
269
282
|
case "end":
|
|
270
283
|
return _context3.stop();
|
|
271
284
|
}
|
|
@@ -537,7 +550,8 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
537
550
|
|
|
538
551
|
_context7.next = 13;
|
|
539
552
|
return this.client.SetRemoteSigner({
|
|
540
|
-
authToken: decodedToken.clusterToken
|
|
553
|
+
authToken: decodedToken.clusterToken,
|
|
554
|
+
signerURIs: decodedToken.signerURIs
|
|
541
555
|
});
|
|
542
556
|
|
|
543
557
|
case 13:
|
|
@@ -568,8 +582,8 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
568
582
|
* @param {string} idToken - An OAuth ID token
|
|
569
583
|
* @param {string=} tenantId - ID of tenant with which to associate the user. If marketplace info was set upon initialization, this will be determined automatically.
|
|
570
584
|
* @param {string=} email - Email address of the user. If not specified, this method will attempt to extract the email from the ID token.
|
|
585
|
+
* @param {Array<string>=} signerURIs - (Only if using custom OAuth) - URIs corresponding to the key server(s) to use
|
|
571
586
|
* @param {boolean=} shareEmail=false - Whether or not the user consents to sharing their email
|
|
572
|
-
* @param {number=} tokenDuration=24 - Number of hours the generated authorization token will last before expiring
|
|
573
587
|
*
|
|
574
588
|
* @returns {Promise<Object>} - Returns an authorization tokens that can be used to initialize the client using <a href="#Authenticate">Authenticate</a>.
|
|
575
589
|
* Save this token to avoid having to reauthenticate with OAuth. This token expires after 24 hours.
|
|
@@ -584,64 +598,66 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
584
598
|
key: "AuthenticateOAuth",
|
|
585
599
|
value: function () {
|
|
586
600
|
var _AuthenticateOAuth = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref7) {
|
|
587
|
-
var idToken, tenantId, email, _ref7$shareEmail, shareEmail,
|
|
601
|
+
var idToken, tenantId, email, signerURIs, _ref7$shareEmail, shareEmail, tokenDuration, expiresAt, fabricToken, address, decodedToken;
|
|
588
602
|
|
|
589
603
|
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
590
604
|
while (1) {
|
|
591
605
|
switch (_context8.prev = _context8.next) {
|
|
592
606
|
case 0:
|
|
593
|
-
idToken = _ref7.idToken, tenantId = _ref7.tenantId, email = _ref7.email,
|
|
607
|
+
idToken = _ref7.idToken, tenantId = _ref7.tenantId, email = _ref7.email, signerURIs = _ref7.signerURIs, _ref7$shareEmail = _ref7.shareEmail, shareEmail = _ref7$shareEmail === void 0 ? false : _ref7$shareEmail;
|
|
608
|
+
tokenDuration = 24;
|
|
594
609
|
|
|
595
610
|
if (!(!tenantId && this.selectedMarketplaceInfo)) {
|
|
596
|
-
_context8.next =
|
|
611
|
+
_context8.next = 6;
|
|
597
612
|
break;
|
|
598
613
|
}
|
|
599
614
|
|
|
600
|
-
_context8.next =
|
|
615
|
+
_context8.next = 5;
|
|
601
616
|
return this.AvailableMarketplaces();
|
|
602
617
|
|
|
603
|
-
case
|
|
618
|
+
case 5:
|
|
604
619
|
tenantId = this.selectedMarketplaceInfo.tenantId;
|
|
605
620
|
|
|
606
|
-
case
|
|
607
|
-
_context8.next =
|
|
621
|
+
case 6:
|
|
622
|
+
_context8.next = 8;
|
|
608
623
|
return this.client.SetRemoteSigner({
|
|
609
624
|
idToken: idToken,
|
|
610
625
|
tenantId: tenantId,
|
|
626
|
+
signerURIs: signerURIs,
|
|
611
627
|
extraData: {
|
|
612
628
|
share_email: shareEmail
|
|
613
629
|
},
|
|
614
630
|
unsignedPublicAuth: true
|
|
615
631
|
});
|
|
616
632
|
|
|
617
|
-
case
|
|
633
|
+
case 8:
|
|
618
634
|
expiresAt = Date.now() + tokenDuration * 60 * 60 * 1000;
|
|
619
|
-
_context8.next =
|
|
635
|
+
_context8.next = 11;
|
|
620
636
|
return this.client.CreateFabricToken({
|
|
621
637
|
duration: tokenDuration * 60 * 60 * 1000
|
|
622
638
|
});
|
|
623
639
|
|
|
624
|
-
case
|
|
640
|
+
case 11:
|
|
625
641
|
fabricToken = _context8.sent;
|
|
626
642
|
address = this.client.utils.FormatAddress(this.client.CurrentAccountAddress());
|
|
627
643
|
|
|
628
644
|
if (email) {
|
|
629
|
-
_context8.next =
|
|
645
|
+
_context8.next = 22;
|
|
630
646
|
break;
|
|
631
647
|
}
|
|
632
648
|
|
|
633
|
-
_context8.prev =
|
|
649
|
+
_context8.prev = 14;
|
|
634
650
|
decodedToken = JSON.parse(this.utils.FromB64URL(idToken.split(".")[1]));
|
|
635
651
|
email = decodedToken.email;
|
|
636
|
-
_context8.next =
|
|
652
|
+
_context8.next = 22;
|
|
637
653
|
break;
|
|
638
654
|
|
|
639
|
-
case
|
|
640
|
-
_context8.prev =
|
|
641
|
-
_context8.t0 = _context8["catch"](
|
|
655
|
+
case 19:
|
|
656
|
+
_context8.prev = 19;
|
|
657
|
+
_context8.t0 = _context8["catch"](14);
|
|
642
658
|
throw Error("Failed to decode ID token");
|
|
643
659
|
|
|
644
|
-
case
|
|
660
|
+
case 22:
|
|
645
661
|
this.client.SetStaticToken({
|
|
646
662
|
token: fabricToken
|
|
647
663
|
});
|
|
@@ -652,6 +668,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
652
668
|
address: address,
|
|
653
669
|
email: email,
|
|
654
670
|
expiresAt: expiresAt,
|
|
671
|
+
signerURIs: signerURIs,
|
|
655
672
|
walletType: "Custodial",
|
|
656
673
|
walletName: "Eluvio"
|
|
657
674
|
}),
|
|
@@ -662,17 +679,18 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
662
679
|
address: address,
|
|
663
680
|
email: email,
|
|
664
681
|
expiresAt: expiresAt,
|
|
682
|
+
signerURIs: signerURIs,
|
|
665
683
|
walletType: "Custodial",
|
|
666
684
|
walletName: "Eluvio"
|
|
667
685
|
})
|
|
668
686
|
});
|
|
669
687
|
|
|
670
|
-
case
|
|
688
|
+
case 24:
|
|
671
689
|
case "end":
|
|
672
690
|
return _context8.stop();
|
|
673
691
|
}
|
|
674
692
|
}
|
|
675
|
-
}, _callee8, this, [[
|
|
693
|
+
}, _callee8, this, [[14, 19]]);
|
|
676
694
|
}));
|
|
677
695
|
|
|
678
696
|
function AuthenticateOAuth(_x12) {
|
|
@@ -809,6 +827,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
809
827
|
address = _ref10.address,
|
|
810
828
|
email = _ref10.email,
|
|
811
829
|
expiresAt = _ref10.expiresAt,
|
|
830
|
+
signerURIs = _ref10.signerURIs,
|
|
812
831
|
walletType = _ref10.walletType,
|
|
813
832
|
walletName = _ref10.walletName;
|
|
814
833
|
address = this.client.utils.FormatAddress(address);
|
|
@@ -824,6 +843,10 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
824
843
|
|
|
825
844
|
if (clusterToken) {
|
|
826
845
|
this.__authorization.clusterToken = clusterToken;
|
|
846
|
+
|
|
847
|
+
if (signerURIs) {
|
|
848
|
+
this.__authorization.signerURIs = signerURIs;
|
|
849
|
+
}
|
|
827
850
|
}
|
|
828
851
|
|
|
829
852
|
this.loggedIn = true;
|
|
@@ -849,7 +872,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
849
872
|
case 0:
|
|
850
873
|
message = _ref11.message, address = _ref11.address;
|
|
851
874
|
|
|
852
|
-
if (window.ethereum) {
|
|
875
|
+
if (!(!inBrowser || !window.ethereum)) {
|
|
853
876
|
_context11.next = 3;
|
|
854
877
|
break;
|
|
855
878
|
}
|
|
@@ -1405,7 +1428,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1405
1428
|
}
|
|
1406
1429
|
|
|
1407
1430
|
_context16.t0 = mode;
|
|
1408
|
-
_context16.next = _context16.t0 === "owned" ? 34 : _context16.t0 === "listings" ? 37 : _context16.t0 === "transfers" ? 39 : _context16.t0 === "sales" ?
|
|
1431
|
+
_context16.next = _context16.t0 === "owned" ? 34 : _context16.t0 === "listings" ? 37 : _context16.t0 === "transfers" ? 39 : _context16.t0 === "sales" ? 43 : _context16.t0 === "listing-stats" ? 46 : _context16.t0 === "sales-stats" ? 48 : 50;
|
|
1409
1432
|
break;
|
|
1410
1433
|
|
|
1411
1434
|
case 34:
|
|
@@ -1415,52 +1438,54 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1415
1438
|
path = UrlJoin("as", "wlt", "nfts", marketplaceInfo.tenantId);
|
|
1416
1439
|
}
|
|
1417
1440
|
|
|
1418
|
-
return _context16.abrupt("break",
|
|
1441
|
+
return _context16.abrupt("break", 50);
|
|
1419
1442
|
|
|
1420
1443
|
case 37:
|
|
1421
1444
|
path = UrlJoin("as", "mkt", "f");
|
|
1422
|
-
return _context16.abrupt("break",
|
|
1445
|
+
return _context16.abrupt("break", 50);
|
|
1423
1446
|
|
|
1424
1447
|
case 39:
|
|
1425
1448
|
path = UrlJoin("as", "mkt", "hst", "f");
|
|
1426
|
-
|
|
1449
|
+
filters.push("action:eq:TRANSFERRED");
|
|
1450
|
+
filters.push("action:eq:SOLD");
|
|
1451
|
+
return _context16.abrupt("break", 50);
|
|
1427
1452
|
|
|
1428
|
-
case
|
|
1453
|
+
case 43:
|
|
1429
1454
|
path = UrlJoin("as", "mkt", "hst", "f");
|
|
1430
1455
|
filters.push("action:eq:SOLD");
|
|
1431
|
-
return _context16.abrupt("break",
|
|
1456
|
+
return _context16.abrupt("break", 50);
|
|
1432
1457
|
|
|
1433
|
-
case
|
|
1458
|
+
case 46:
|
|
1434
1459
|
path = UrlJoin("as", "mkt", "stats", "listed");
|
|
1435
|
-
return _context16.abrupt("break",
|
|
1460
|
+
return _context16.abrupt("break", 50);
|
|
1436
1461
|
|
|
1437
|
-
case
|
|
1462
|
+
case 48:
|
|
1438
1463
|
path = UrlJoin("as", "mkt", "stats", "sold");
|
|
1439
|
-
return _context16.abrupt("break",
|
|
1464
|
+
return _context16.abrupt("break", 50);
|
|
1440
1465
|
|
|
1441
|
-
case
|
|
1466
|
+
case 50:
|
|
1442
1467
|
if (filters.length > 0) {
|
|
1443
1468
|
params.filter = filters;
|
|
1444
1469
|
}
|
|
1445
1470
|
|
|
1446
1471
|
if (!mode.includes("stats")) {
|
|
1447
|
-
_context16.next =
|
|
1472
|
+
_context16.next = 55;
|
|
1448
1473
|
break;
|
|
1449
1474
|
}
|
|
1450
1475
|
|
|
1451
|
-
_context16.next =
|
|
1476
|
+
_context16.next = 54;
|
|
1452
1477
|
return Utils.ResponseToJson(this.client.authClient.MakeAuthServiceRequest({
|
|
1453
1478
|
path: path,
|
|
1454
1479
|
method: "GET",
|
|
1455
1480
|
queryParams: params
|
|
1456
1481
|
}));
|
|
1457
1482
|
|
|
1458
|
-
case
|
|
1483
|
+
case 54:
|
|
1459
1484
|
return _context16.abrupt("return", _context16.sent);
|
|
1460
1485
|
|
|
1461
|
-
case
|
|
1486
|
+
case 55:
|
|
1462
1487
|
_context16.t2 = Utils;
|
|
1463
|
-
_context16.next =
|
|
1488
|
+
_context16.next = 58;
|
|
1464
1489
|
return this.client.authClient.MakeAuthServiceRequest({
|
|
1465
1490
|
path: path,
|
|
1466
1491
|
method: "GET",
|
|
@@ -1470,22 +1495,22 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1470
1495
|
} : {}
|
|
1471
1496
|
});
|
|
1472
1497
|
|
|
1473
|
-
case
|
|
1498
|
+
case 58:
|
|
1474
1499
|
_context16.t3 = _context16.sent;
|
|
1475
|
-
_context16.next =
|
|
1500
|
+
_context16.next = 61;
|
|
1476
1501
|
return _context16.t2.ResponseToJson.call(_context16.t2, _context16.t3);
|
|
1477
1502
|
|
|
1478
|
-
case
|
|
1503
|
+
case 61:
|
|
1479
1504
|
_context16.t1 = _context16.sent;
|
|
1480
1505
|
|
|
1481
1506
|
if (_context16.t1) {
|
|
1482
|
-
_context16.next =
|
|
1507
|
+
_context16.next = 64;
|
|
1483
1508
|
break;
|
|
1484
1509
|
}
|
|
1485
1510
|
|
|
1486
1511
|
_context16.t1 = [];
|
|
1487
1512
|
|
|
1488
|
-
case
|
|
1513
|
+
case 64:
|
|
1489
1514
|
_ref16 = _context16.t1;
|
|
1490
1515
|
contents = _ref16.contents;
|
|
1491
1516
|
paging = _ref16.paging;
|
|
@@ -1501,12 +1526,12 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1501
1526
|
})
|
|
1502
1527
|
});
|
|
1503
1528
|
|
|
1504
|
-
case
|
|
1505
|
-
_context16.prev =
|
|
1529
|
+
case 70:
|
|
1530
|
+
_context16.prev = 70;
|
|
1506
1531
|
_context16.t4 = _context16["catch"](11);
|
|
1507
1532
|
|
|
1508
1533
|
if (!(_context16.t4.status && _context16.t4.status.toString() === "404")) {
|
|
1509
|
-
_context16.next =
|
|
1534
|
+
_context16.next = 74;
|
|
1510
1535
|
break;
|
|
1511
1536
|
}
|
|
1512
1537
|
|
|
@@ -1520,15 +1545,15 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1520
1545
|
results: []
|
|
1521
1546
|
});
|
|
1522
1547
|
|
|
1523
|
-
case
|
|
1548
|
+
case 74:
|
|
1524
1549
|
throw _context16.t4;
|
|
1525
1550
|
|
|
1526
|
-
case
|
|
1551
|
+
case 75:
|
|
1527
1552
|
case "end":
|
|
1528
1553
|
return _context16.stop();
|
|
1529
1554
|
}
|
|
1530
1555
|
}
|
|
1531
|
-
}, _callee16, this, [[11,
|
|
1556
|
+
}, _callee16, this, [[11, 70]]);
|
|
1532
1557
|
}));
|
|
1533
1558
|
|
|
1534
1559
|
function FilteredQuery() {
|
|
@@ -1689,7 +1714,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1689
1714
|
storeAuthToken: storeAuthToken
|
|
1690
1715
|
});
|
|
1691
1716
|
|
|
1692
|
-
if (!(
|
|
1717
|
+
if (!(inBrowser && window.location && window.location.href)) {
|
|
1693
1718
|
_context18.next = 31;
|
|
1694
1719
|
break;
|
|
1695
1720
|
}
|
package/package.json
CHANGED
package/src/ElvClient.js
CHANGED
|
@@ -601,11 +601,12 @@ class ElvClient {
|
|
|
601
601
|
* @param {string=} authToken - Eluvio authorization token previously issued from OAuth ID token
|
|
602
602
|
* @param {string=} tenantId - If specified, user will be associated with the tenant
|
|
603
603
|
* @param {Object=} extraData - Additional data to pass to the login API
|
|
604
|
+
* @param {Array<string>=} signerURIs - (Only if using custom OAuth) - URIs corresponding to the key server(s) to use
|
|
604
605
|
* @param {boolean=} unsignedPublicAuth=false - If specified, the client will use an unsigned static token for calls that don't require authorization (reduces remote signature calls)
|
|
605
606
|
*/
|
|
606
|
-
async SetRemoteSigner({idToken, authToken, tenantId, extraData, unsignedPublicAuth}) {
|
|
607
|
+
async SetRemoteSigner({idToken, authToken, tenantId, extraData, signerURIs, unsignedPublicAuth}) {
|
|
607
608
|
const signer = new RemoteSigner({
|
|
608
|
-
|
|
609
|
+
signerURIs: signerURIs || this.authServiceURIs,
|
|
609
610
|
idToken,
|
|
610
611
|
authToken,
|
|
611
612
|
tenantId,
|
package/src/RemoteSigner.js
CHANGED
|
@@ -5,7 +5,7 @@ const UrlJoin = require("url-join");
|
|
|
5
5
|
|
|
6
6
|
class RemoteSigner extends Ethers.Signer {
|
|
7
7
|
constructor({
|
|
8
|
-
|
|
8
|
+
signerURIs,
|
|
9
9
|
idToken,
|
|
10
10
|
authToken,
|
|
11
11
|
tenantId,
|
|
@@ -18,7 +18,7 @@ class RemoteSigner extends Ethers.Signer {
|
|
|
18
18
|
this.remoteSigner = true;
|
|
19
19
|
this.unsignedPublicAuth = unsignedPublicAuth;
|
|
20
20
|
|
|
21
|
-
this.HttpClient = new HttpClient({uris:
|
|
21
|
+
this.HttpClient = new HttpClient({uris: signerURIs});
|
|
22
22
|
this.idToken = idToken;
|
|
23
23
|
this.tenantId = tenantId;
|
|
24
24
|
|
|
@@ -12,7 +12,7 @@ let WalletConfiguration = {
|
|
|
12
12
|
staging: {
|
|
13
13
|
siteId: "iq__inauxD1KLyKWPHargCWjdCh2ayr",
|
|
14
14
|
purchaseMode: "production",
|
|
15
|
-
appUrl: "https://
|
|
15
|
+
appUrl: "https://wallet.preview.contentfabric.io",
|
|
16
16
|
},
|
|
17
17
|
production: {
|
|
18
18
|
siteId: "iq__suqRJUt2vmXsyiWS5ZaSGwtFU9R",
|
|
@@ -5,6 +5,7 @@ const UrlJoin = require("url-join");
|
|
|
5
5
|
const Utils = require("../Utils");
|
|
6
6
|
const Ethers = require("ethers");
|
|
7
7
|
|
|
8
|
+
const inBrowser = typeof window !== "undefined";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Use the <a href="#.Initialize">Initialize</a> method to initialize a new client.
|
|
@@ -91,7 +92,7 @@ class ElvWalletClient {
|
|
|
91
92
|
storeAuthToken
|
|
92
93
|
});
|
|
93
94
|
|
|
94
|
-
if(
|
|
95
|
+
if(inBrowser && window.location && window.location.href) {
|
|
95
96
|
let url = new URL(window.location.href);
|
|
96
97
|
if(url.searchParams.get("elvToken")) {
|
|
97
98
|
await walletClient.Authenticate({token: url.searchParams.get("elvToken")});
|
|
@@ -130,7 +131,7 @@ class ElvWalletClient {
|
|
|
130
131
|
if(!this.loggedIn) { return false; }
|
|
131
132
|
|
|
132
133
|
return !!this.__authorization.clusterToken ||
|
|
133
|
-
!!(this.UserInfo().walletName.toLowerCase() === "metamask" && window.ethereum && window.ethereum.isMetaMask && window.ethereum.chainId);
|
|
134
|
+
(inBrowser && !!(this.UserInfo().walletName.toLowerCase() === "metamask" && window.ethereum && window.ethereum.isMetaMask && window.ethereum.chainId));
|
|
134
135
|
}
|
|
135
136
|
|
|
136
137
|
/**
|
|
@@ -167,6 +168,8 @@ class ElvWalletClient {
|
|
|
167
168
|
} else {
|
|
168
169
|
throw Error("ElvWalletClient: Unable to sign");
|
|
169
170
|
}
|
|
171
|
+
} else if(!inBrowser) {
|
|
172
|
+
throw Error("ElvWalletClient: Unable to sign");
|
|
170
173
|
}
|
|
171
174
|
|
|
172
175
|
const parameters = {
|
|
@@ -331,7 +334,7 @@ class ElvWalletClient {
|
|
|
331
334
|
}
|
|
332
335
|
|
|
333
336
|
if(decodedToken.clusterToken) {
|
|
334
|
-
await this.client.SetRemoteSigner({authToken: decodedToken.clusterToken});
|
|
337
|
+
await this.client.SetRemoteSigner({authToken: decodedToken.clusterToken, signerURIs: decodedToken.signerURIs});
|
|
335
338
|
}
|
|
336
339
|
|
|
337
340
|
this.client.SetStaticToken({token: decodedToken.fabricToken});
|
|
@@ -347,8 +350,8 @@ class ElvWalletClient {
|
|
|
347
350
|
* @param {string} idToken - An OAuth ID token
|
|
348
351
|
* @param {string=} tenantId - ID of tenant with which to associate the user. If marketplace info was set upon initialization, this will be determined automatically.
|
|
349
352
|
* @param {string=} email - Email address of the user. If not specified, this method will attempt to extract the email from the ID token.
|
|
353
|
+
* @param {Array<string>=} signerURIs - (Only if using custom OAuth) - URIs corresponding to the key server(s) to use
|
|
350
354
|
* @param {boolean=} shareEmail=false - Whether or not the user consents to sharing their email
|
|
351
|
-
* @param {number=} tokenDuration=24 - Number of hours the generated authorization token will last before expiring
|
|
352
355
|
*
|
|
353
356
|
* @returns {Promise<Object>} - Returns an authorization tokens that can be used to initialize the client using <a href="#Authenticate">Authenticate</a>.
|
|
354
357
|
* Save this token to avoid having to reauthenticate with OAuth. This token expires after 24 hours.
|
|
@@ -358,14 +361,16 @@ class ElvWalletClient {
|
|
|
358
361
|
* - 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
|
|
359
362
|
* shared with third parties.
|
|
360
363
|
*/
|
|
361
|
-
async AuthenticateOAuth({idToken, tenantId, email, shareEmail=false
|
|
364
|
+
async AuthenticateOAuth({idToken, tenantId, email, signerURIs, shareEmail=false}) {
|
|
365
|
+
let tokenDuration = 24;
|
|
366
|
+
|
|
362
367
|
if(!tenantId && this.selectedMarketplaceInfo) {
|
|
363
368
|
// Load tenant ID automatically from selected marketplace
|
|
364
369
|
await this.AvailableMarketplaces();
|
|
365
370
|
tenantId = this.selectedMarketplaceInfo.tenantId;
|
|
366
371
|
}
|
|
367
372
|
|
|
368
|
-
await this.client.SetRemoteSigner({idToken, tenantId, extraData: { share_email: shareEmail }, unsignedPublicAuth: true});
|
|
373
|
+
await this.client.SetRemoteSigner({idToken, tenantId, signerURIs, extraData: { share_email: shareEmail }, unsignedPublicAuth: true});
|
|
369
374
|
|
|
370
375
|
const expiresAt = Date.now() + tokenDuration * 60 * 60 * 1000;
|
|
371
376
|
const fabricToken = await this.client.CreateFabricToken({duration: tokenDuration * 60 * 60 * 1000});
|
|
@@ -389,6 +394,7 @@ class ElvWalletClient {
|
|
|
389
394
|
address,
|
|
390
395
|
email,
|
|
391
396
|
expiresAt,
|
|
397
|
+
signerURIs,
|
|
392
398
|
walletType: "Custodial",
|
|
393
399
|
walletName: "Eluvio"
|
|
394
400
|
}),
|
|
@@ -399,6 +405,7 @@ class ElvWalletClient {
|
|
|
399
405
|
address,
|
|
400
406
|
email,
|
|
401
407
|
expiresAt,
|
|
408
|
+
signerURIs,
|
|
402
409
|
walletType: "Custodial",
|
|
403
410
|
walletName: "Eluvio"
|
|
404
411
|
})
|
|
@@ -461,7 +468,7 @@ class ElvWalletClient {
|
|
|
461
468
|
return this.__authorization.fabricToken;
|
|
462
469
|
}
|
|
463
470
|
|
|
464
|
-
SetAuthorization({clusterToken, fabricToken, tenantId, address, email, expiresAt, walletType, walletName}) {
|
|
471
|
+
SetAuthorization({clusterToken, fabricToken, tenantId, address, email, expiresAt, signerURIs, walletType, walletName}) {
|
|
465
472
|
address = this.client.utils.FormatAddress(address);
|
|
466
473
|
|
|
467
474
|
this.__authorization = {
|
|
@@ -476,6 +483,10 @@ class ElvWalletClient {
|
|
|
476
483
|
|
|
477
484
|
if(clusterToken) {
|
|
478
485
|
this.__authorization.clusterToken = clusterToken;
|
|
486
|
+
|
|
487
|
+
if(signerURIs) {
|
|
488
|
+
this.__authorization.signerURIs = signerURIs;
|
|
489
|
+
}
|
|
479
490
|
}
|
|
480
491
|
|
|
481
492
|
this.loggedIn = true;
|
|
@@ -495,7 +506,7 @@ class ElvWalletClient {
|
|
|
495
506
|
}
|
|
496
507
|
|
|
497
508
|
async SignMetamask({message, address}) {
|
|
498
|
-
if(!window.ethereum) {
|
|
509
|
+
if(!inBrowser || !window.ethereum) {
|
|
499
510
|
throw Error("ElvWalletClient: Unable to initialize - Metamask not available");
|
|
500
511
|
}
|
|
501
512
|
|
|
@@ -841,6 +852,8 @@ class ElvWalletClient {
|
|
|
841
852
|
|
|
842
853
|
case "transfers":
|
|
843
854
|
path = UrlJoin("as", "mkt", "hst", "f");
|
|
855
|
+
filters.push("action:eq:TRANSFERRED");
|
|
856
|
+
filters.push("action:eq:SOLD");
|
|
844
857
|
break;
|
|
845
858
|
|
|
846
859
|
case "sales":
|