carbon-js-sdk 0.11.48 → 0.11.50
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/lib/clients/TokenClient.js +0 -4
- package/lib/util/auth.d.ts +2 -1
- package/lib/util/auth.js +13 -1
- package/lib/wallet/CarbonWallet.js +2 -1
- package/package.json +1 -1
|
@@ -411,10 +411,6 @@ class TokenClient {
|
|
|
411
411
|
this.symbols[token.denom] = token.symbol;
|
|
412
412
|
}
|
|
413
413
|
else {
|
|
414
|
-
if (this.isNativeToken(token.denom)) {
|
|
415
|
-
// Change token name to Carbon
|
|
416
|
-
token.name = "Carbon";
|
|
417
|
-
}
|
|
418
414
|
this.tokens[token.denom] = token;
|
|
419
415
|
this.symbols[token.denom] = token.symbol;
|
|
420
416
|
}
|
package/lib/util/auth.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Network } from '../constant';
|
|
1
2
|
export declare const expirybufferSeconds = 30;
|
|
2
3
|
export type AccessTokenResponse = {
|
|
3
4
|
access_token: string;
|
|
@@ -27,4 +28,4 @@ export type GrantRequest = {
|
|
|
27
28
|
export declare const getAuthMessage: () => string;
|
|
28
29
|
export declare const hasExpired: (exp?: number) => boolean;
|
|
29
30
|
export declare const hasRefreshTokenExpired: (refreshToken: string) => boolean;
|
|
30
|
-
export declare const isValidIssuer: (iss
|
|
31
|
+
export declare const isValidIssuer: (iss: string | undefined, network: Network) => boolean;
|
package/lib/util/auth.js
CHANGED
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.isValidIssuer = exports.hasRefreshTokenExpired = exports.hasExpired = exports.getAuthMessage = exports.GrantType = exports.expirybufferSeconds = void 0;
|
|
7
|
+
const constant_1 = require("../constant");
|
|
7
8
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
8
9
|
const evm_1 = require("./evm");
|
|
9
10
|
exports.expirybufferSeconds = 30;
|
|
@@ -31,5 +32,16 @@ const hasRefreshTokenExpired = (refreshToken) => {
|
|
|
31
32
|
return (0, exports.hasExpired)(payload.exp);
|
|
32
33
|
};
|
|
33
34
|
exports.hasRefreshTokenExpired = hasRefreshTokenExpired;
|
|
34
|
-
const isValidIssuer = (iss) =>
|
|
35
|
+
const isValidIssuer = (iss = '', network) => {
|
|
36
|
+
switch (network) {
|
|
37
|
+
case constant_1.Network.MainNet:
|
|
38
|
+
return iss === 'demex-auth';
|
|
39
|
+
case constant_1.Network.DevNet:
|
|
40
|
+
return iss === 'demex-auth-dev';
|
|
41
|
+
case constant_1.Network.TestNet:
|
|
42
|
+
return iss === 'demex-auth-test';
|
|
43
|
+
default:
|
|
44
|
+
return iss === 'demex-auth-local';
|
|
45
|
+
}
|
|
46
|
+
};
|
|
35
47
|
exports.isValidIssuer = isValidIssuer;
|
|
@@ -189,9 +189,10 @@ class CarbonWallet {
|
|
|
189
189
|
}
|
|
190
190
|
reloadJwtToken(request) {
|
|
191
191
|
return __awaiter(this, void 0, void 0, function* () {
|
|
192
|
+
const network = this.network;
|
|
192
193
|
if (this.jwt) {
|
|
193
194
|
const { iss, exp } = (0, jwt_decode_1.jwtDecode)(this.jwt.access_token);
|
|
194
|
-
if (!(0, auth_2.isValidIssuer)(iss))
|
|
195
|
+
if (!(0, auth_2.isValidIssuer)(iss, network))
|
|
195
196
|
return this.getNewJwtToken(request);
|
|
196
197
|
const accessTokenExpired = (0, auth_2.hasExpired)(exp);
|
|
197
198
|
if (accessTokenExpired) {
|