@eluvio/elv-client-js 4.2.8 → 4.2.10
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 +1 -1
- package/src/RemoteSigner.js +25 -3
- package/src/walletClient/index.js +14 -8
package/package.json
CHANGED
package/src/RemoteSigner.js
CHANGED
|
@@ -73,17 +73,21 @@ class RemoteSigner extends Ethers.Signer {
|
|
|
73
73
|
this.signer = this.provider.getSigner(this.address);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
async RetrieveCSAT({email, nonce, tenantId, force=false, duration=24}) {
|
|
77
|
-
nonce
|
|
76
|
+
async RetrieveCSAT({email, nonce, installId, tenantId, force=false, duration=24, appName}) {
|
|
77
|
+
if(nonce && !installId) {
|
|
78
|
+
const buf = await crypto.subtle.digest("SHA-512", new TextEncoder("utf-8").encode(nonce));
|
|
79
|
+
installId = Array.prototype.map.call(new Uint8Array(buf), x=>(("00"+x.toString(16)).slice(-2))).join("");
|
|
80
|
+
}
|
|
78
81
|
|
|
79
82
|
let response = await Utils.ResponseToJson(
|
|
80
83
|
this.HttpClient.Request({
|
|
81
84
|
method: "POST",
|
|
82
85
|
body: {
|
|
83
86
|
email,
|
|
84
|
-
|
|
87
|
+
install_id: installId,
|
|
85
88
|
force,
|
|
86
89
|
tid: tenantId,
|
|
90
|
+
app_name: appName,
|
|
87
91
|
exp: parseInt(duration * 60 * 60)
|
|
88
92
|
},
|
|
89
93
|
path: UrlJoin("as", "wlt", "sign", "csat"),
|
|
@@ -94,6 +98,7 @@ class RemoteSigner extends Ethers.Signer {
|
|
|
94
98
|
);
|
|
95
99
|
|
|
96
100
|
response.nonce = nonce;
|
|
101
|
+
response.installId = installId;
|
|
97
102
|
|
|
98
103
|
return response;
|
|
99
104
|
}
|
|
@@ -128,6 +133,23 @@ class RemoteSigner extends Ethers.Signer {
|
|
|
128
133
|
);
|
|
129
134
|
}
|
|
130
135
|
|
|
136
|
+
async RefreshCSAT({accessToken, refreshToken, nonce}) {
|
|
137
|
+
return await Utils.ResponseToJson(
|
|
138
|
+
this.HttpClient.Request({
|
|
139
|
+
method: "POST",
|
|
140
|
+
path: UrlJoin("as", "wlt", "refresh", "csat"),
|
|
141
|
+
body: {
|
|
142
|
+
last_csat: accessToken,
|
|
143
|
+
refresh_token: refreshToken,
|
|
144
|
+
nonce
|
|
145
|
+
},
|
|
146
|
+
headers: {
|
|
147
|
+
Authorization: `Bearer ${accessToken}`
|
|
148
|
+
},
|
|
149
|
+
})
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
131
153
|
// Overrides
|
|
132
154
|
|
|
133
155
|
getAddress() {
|
|
@@ -396,7 +396,7 @@ class ElvWalletClient {
|
|
|
396
396
|
* @methodGroup Login
|
|
397
397
|
*/
|
|
398
398
|
async LogOut() {
|
|
399
|
-
if(this.__authorization && this.__authorization.nonce) {
|
|
399
|
+
if(this.__authorization && (this.__authorization.nonce || this.__authorization.installId)) {
|
|
400
400
|
try {
|
|
401
401
|
await this.client.signer.ReleaseCSAT({accessToken: this.AuthToken()});
|
|
402
402
|
} catch(error) {
|
|
@@ -419,7 +419,7 @@ class ElvWalletClient {
|
|
|
419
419
|
}
|
|
420
420
|
|
|
421
421
|
async TokenStatus() {
|
|
422
|
-
if(!this.__authorization || !this.__authorization.nonce) {
|
|
422
|
+
if(!this.__authorization || !(this.__authorization.nonce || this.__authorization.installId)) {
|
|
423
423
|
return true;
|
|
424
424
|
}
|
|
425
425
|
|
|
@@ -482,6 +482,8 @@ class ElvWalletClient {
|
|
|
482
482
|
shareEmail=false,
|
|
483
483
|
extraData={},
|
|
484
484
|
nonce,
|
|
485
|
+
installId,
|
|
486
|
+
appName,
|
|
485
487
|
createRemoteToken=true,
|
|
486
488
|
force=false,
|
|
487
489
|
tokenDuration=24
|
|
@@ -497,9 +499,10 @@ class ElvWalletClient {
|
|
|
497
499
|
let fabricToken, refreshToken, expiresAt;
|
|
498
500
|
if(createRemoteToken && this.client.signer.remoteSigner) {
|
|
499
501
|
expiresAt = Date.now() + tokenDuration * 60 * 60 * 1000;
|
|
500
|
-
const tokenResponse = await this.client.signer.RetrieveCSAT({email, nonce, tenantId, force, duration: tokenDuration});
|
|
502
|
+
const tokenResponse = await this.client.signer.RetrieveCSAT({email, nonce, installId, appName, tenantId, force, duration: tokenDuration});
|
|
501
503
|
fabricToken = tokenResponse.token;
|
|
502
|
-
nonce = tokenResponse.nonce;
|
|
504
|
+
nonce = tokenResponse.nonce || nonce;
|
|
505
|
+
installId = tokenResponse.installId || installId;
|
|
503
506
|
refreshToken = tokenResponse.refresh_token;
|
|
504
507
|
} else {
|
|
505
508
|
expiresAt = Date.now() + tokenDuration * 60 * 60 * 1000;
|
|
@@ -533,7 +536,8 @@ class ElvWalletClient {
|
|
|
533
536
|
walletType: "Custodial",
|
|
534
537
|
walletName: "Eluvio",
|
|
535
538
|
register: true,
|
|
536
|
-
nonce
|
|
539
|
+
nonce,
|
|
540
|
+
installId
|
|
537
541
|
}),
|
|
538
542
|
signingToken: this.SetAuthorization({
|
|
539
543
|
clusterToken: this.client.signer.authToken,
|
|
@@ -546,7 +550,8 @@ class ElvWalletClient {
|
|
|
546
550
|
signerURIs,
|
|
547
551
|
walletType: "Custodial",
|
|
548
552
|
walletName: "Eluvio",
|
|
549
|
-
nonce
|
|
553
|
+
nonce,
|
|
554
|
+
installId
|
|
550
555
|
})
|
|
551
556
|
};
|
|
552
557
|
}
|
|
@@ -607,7 +612,7 @@ class ElvWalletClient {
|
|
|
607
612
|
return this.__authorization.fabricToken;
|
|
608
613
|
}
|
|
609
614
|
|
|
610
|
-
SetAuthorization({clusterToken, fabricToken, refreshToken, tenantId, address, email, expiresAt, signerURIs, walletType, walletName, nonce, register=false}) {
|
|
615
|
+
SetAuthorization({clusterToken, fabricToken, refreshToken, tenantId, address, email, expiresAt, signerURIs, walletType, walletName, nonce, installId, register=false}) {
|
|
611
616
|
address = this.client.utils.FormatAddress(address);
|
|
612
617
|
|
|
613
618
|
this.__authorization = {
|
|
@@ -619,7 +624,8 @@ class ElvWalletClient {
|
|
|
619
624
|
expiresAt,
|
|
620
625
|
walletType,
|
|
621
626
|
walletName,
|
|
622
|
-
nonce
|
|
627
|
+
nonce,
|
|
628
|
+
installId
|
|
623
629
|
};
|
|
624
630
|
|
|
625
631
|
if(clusterToken) {
|