tek-wallet 0.0.40 → 0.0.47
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/components/ui/RequireConnect/index.js +2 -2
- package/dist/components/views/CreateWalletView/index.js +3 -5
- package/dist/handlers/auth/functions/getLoginInfoFromCookies.d.ts +1 -1
- package/dist/handlers/auth/functions/refreshTokenKeycloak.d.ts +1 -1
- package/dist/handlers/auth/functions/refreshTokenKeycloak.js +4 -4
- package/dist/handlers/auth/functions/setLoginInfoToCookies.d.ts +1 -1
- package/dist/handlers/auth/import/index.d.ts +1 -1
- package/dist/handlers/auth/login/index.d.ts +1 -1
- package/dist/handlers/auth/login/index.js +8 -8
- package/dist/handlers/auth/signout/index.d.ts +1 -5
- package/dist/handlers/index.d.ts +1 -1
- package/dist/hooks/useWalletData.d.ts +3 -0
- package/dist/hooks/useWalletData.js +15 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/providers/TekWalletProvider/index.d.ts +0 -2
- package/dist/providers/TekWalletProvider/index.js +2 -3
- package/dist/providers/WalletDataProvider/index.d.ts +8 -0
- package/dist/providers/WalletDataProvider/index.js +222 -0
- package/dist/services/axios/create-wallet-service/createWalletService.d.ts +1 -5
- package/dist/services/axios/get-balance-service/getBalanceService.d.ts +1 -1
- package/dist/services/axios/import-wallet-service/importWalletExternalService.d.ts +1 -1
- package/dist/services/axios/import-wallet-service/importWalletIntenalService.d.ts +1 -1
- package/dist/services/axios/sign-out-internal/loginIntenalService.d.ts +1 -1
- package/dist/types/expose-type.d.ts +137 -0
- package/dist/{handlers/type.js → types/expose-type.js} +1 -0
- package/package.json +1 -1
- package/dist/app/api/auth/[...nextauth]/route.d.ts +0 -2
- package/dist/app/api/auth/[...nextauth]/route.js +0 -162
- package/dist/configs/app/index.d.ts +0 -3
- package/dist/configs/app/index.js +0 -11
- package/dist/configs/app/type.d.ts +0 -5
- package/dist/configs/app/type.js +0 -7
- package/dist/handlers/type.d.ts +0 -23
- package/dist/hooks/type.d.ts +0 -4
- package/dist/hooks/type.js +0 -8
- package/dist/hooks/useTekWallet.d.ts +0 -7
- package/dist/hooks/useTekWallet.js +0 -25
- package/dist/providers/AuthProvider/index.d.ts +0 -5
- package/dist/providers/AuthProvider/index.js +0 -41
- package/dist/providers/AuthProvider/type.d.ts +0 -0
- package/dist/providers/AuthProvider/type.js +0 -1
- package/dist/services/axios/create-wallet-service/type.d.ts +0 -43
- package/dist/services/axios/create-wallet-service/type.js +0 -2
- package/dist/services/axios/get-balance-service/type.d.ts +0 -37
- package/dist/services/axios/get-balance-service/type.js +0 -2
- package/dist/services/axios/import-wallet-service/type.d.ts +0 -32
- package/dist/services/axios/import-wallet-service/type.js +0 -2
- package/dist/services/axios/login-internal/type.d.ts +0 -0
- package/dist/services/axios/login-internal/type.js +0 -1
- package/dist/services/axios/login-internal copy/loginIntenalService.d.ts +0 -3
- package/dist/services/axios/login-internal copy/loginIntenalService.js +0 -55
- package/dist/services/axios/sign-out-internal/type.d.ts +0 -0
- package/dist/services/axios/sign-out-internal/type.js +0 -1
- package/dist/store/Provider.d.ts +0 -4
- package/dist/store/Provider.js +0 -11
- package/dist/store/auth/authSlice.d.ts +0 -5
- package/dist/store/auth/authSlice.js +0 -65
- package/dist/store/auth/authThunk.d.ts +0 -20
- package/dist/store/auth/authThunk.js +0 -75
- package/dist/store/auth/type.d.ts +0 -6
- package/dist/store/auth/type.js +0 -2
- package/dist/store/hooks.d.ts +0 -7
- package/dist/store/hooks.js +0 -7
- package/dist/store/store.d.ts +0 -11
- package/dist/store/store.js +0 -16
- package/dist/store/tokens/tokenThunk.d.ts +0 -10
- package/dist/store/tokens/tokenThunk.js +0 -55
- package/dist/store/tokens/tokensSlice.d.ts +0 -4
- package/dist/store/tokens/tokensSlice.js +0 -26
- package/dist/store/tokens/type.d.ts +0 -8
- package/dist/store/tokens/type.js +0 -2
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
export declare enum LoginMessage {
|
|
2
|
+
SUCCESS = "Login is successfully",
|
|
3
|
+
ERROR = "Login is failed",
|
|
4
|
+
EXPIRED = "Login info is expired",
|
|
5
|
+
NOT_FOUND = "Login info is not found",
|
|
6
|
+
REFRESH_TOKEN_FAILED = "Refresh token is failed"
|
|
7
|
+
}
|
|
8
|
+
export declare enum REFRESH_TOKEN_STATUS {
|
|
9
|
+
FAILED = "Refresh token is failed",
|
|
10
|
+
SUCCESS = "Refresh token is successfully"
|
|
11
|
+
}
|
|
12
|
+
export interface ResponseError<T = string> {
|
|
13
|
+
status: number;
|
|
14
|
+
message: T;
|
|
15
|
+
}
|
|
16
|
+
export interface SignOutResponse {
|
|
17
|
+
success: boolean;
|
|
18
|
+
message?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface CreateWalletServiceBody {
|
|
21
|
+
passcode: string;
|
|
22
|
+
appSlug: string;
|
|
23
|
+
}
|
|
24
|
+
export interface CreateWalletServiceResponse {
|
|
25
|
+
success: boolean;
|
|
26
|
+
message: string;
|
|
27
|
+
data: WalletData;
|
|
28
|
+
timestamp: string;
|
|
29
|
+
}
|
|
30
|
+
export interface ImportWalletServiceResponse {
|
|
31
|
+
success: boolean;
|
|
32
|
+
message: string;
|
|
33
|
+
data: ImportWalletData;
|
|
34
|
+
timestamp: string;
|
|
35
|
+
}
|
|
36
|
+
export interface GetBalanceServiceResponse {
|
|
37
|
+
id: string;
|
|
38
|
+
user_updated: string;
|
|
39
|
+
date_created: string;
|
|
40
|
+
date_updated: null;
|
|
41
|
+
user_created: string;
|
|
42
|
+
address: string;
|
|
43
|
+
app_slug: string[];
|
|
44
|
+
balances: Balance[];
|
|
45
|
+
blockchain_wallets: Blockchainwallet[];
|
|
46
|
+
}
|
|
47
|
+
export interface WalletProviderDataType {
|
|
48
|
+
isAuthenticated: boolean | undefined;
|
|
49
|
+
session: LoginInfoResponse | undefined;
|
|
50
|
+
isAuthLoading: boolean | undefined;
|
|
51
|
+
tokens: Balance[] | undefined;
|
|
52
|
+
isTokensLoading: boolean | undefined;
|
|
53
|
+
updateLogin: () => void;
|
|
54
|
+
updateBalance: () => void;
|
|
55
|
+
disconnect: () => void;
|
|
56
|
+
}
|
|
57
|
+
export interface LoginInfo {
|
|
58
|
+
accessToken: string;
|
|
59
|
+
refreshToken: string;
|
|
60
|
+
expiresAt: number;
|
|
61
|
+
refreshExpiresAt: number;
|
|
62
|
+
}
|
|
63
|
+
export interface LoginInfoResponse extends Omit<LoginInfo, "refreshToken" | "refreshExpiresAt"> {
|
|
64
|
+
}
|
|
65
|
+
export interface WalletData {
|
|
66
|
+
id: string;
|
|
67
|
+
user_updated: string;
|
|
68
|
+
date_created: string;
|
|
69
|
+
date_updated: null;
|
|
70
|
+
user_created: string;
|
|
71
|
+
address: string;
|
|
72
|
+
app_slug: string[];
|
|
73
|
+
balances: Balance[];
|
|
74
|
+
blockchain_wallets: Blockchainwallet[];
|
|
75
|
+
seed_pharse: string;
|
|
76
|
+
user: User;
|
|
77
|
+
}
|
|
78
|
+
export interface User {
|
|
79
|
+
action_token_url: string;
|
|
80
|
+
user_id: string;
|
|
81
|
+
access_token: string;
|
|
82
|
+
refresh_token: string;
|
|
83
|
+
}
|
|
84
|
+
export interface Blockchainwallet {
|
|
85
|
+
master_address: string;
|
|
86
|
+
blockchain_address: string;
|
|
87
|
+
network_slug: string;
|
|
88
|
+
}
|
|
89
|
+
export interface Balance {
|
|
90
|
+
id: string;
|
|
91
|
+
master_wallet_id: string;
|
|
92
|
+
currency_slug: string;
|
|
93
|
+
current_value: string;
|
|
94
|
+
total_value: string;
|
|
95
|
+
user_created: string;
|
|
96
|
+
user_updated: string;
|
|
97
|
+
date_created: string;
|
|
98
|
+
date_updated: null;
|
|
99
|
+
currency: Currency;
|
|
100
|
+
}
|
|
101
|
+
export interface Currency {
|
|
102
|
+
id: number;
|
|
103
|
+
name: string;
|
|
104
|
+
slug: string;
|
|
105
|
+
full_name: string;
|
|
106
|
+
icon: string;
|
|
107
|
+
link: string;
|
|
108
|
+
}
|
|
109
|
+
export interface Tokens {
|
|
110
|
+
access_token: string;
|
|
111
|
+
expires_in: number;
|
|
112
|
+
refresh_expires_in: number;
|
|
113
|
+
refresh_token: string;
|
|
114
|
+
token_type: string;
|
|
115
|
+
session_state: string;
|
|
116
|
+
}
|
|
117
|
+
export interface ImportWalletData {
|
|
118
|
+
id: string;
|
|
119
|
+
user_updated: string;
|
|
120
|
+
date_created: string;
|
|
121
|
+
date_updated: null;
|
|
122
|
+
user_created: string;
|
|
123
|
+
address: string;
|
|
124
|
+
app_slug: string[];
|
|
125
|
+
balances: null[][];
|
|
126
|
+
assets: number;
|
|
127
|
+
blockchain_wallets: null[][];
|
|
128
|
+
tokens: Tokens;
|
|
129
|
+
}
|
|
130
|
+
export interface importWalletServiceBody {
|
|
131
|
+
seed_pharse: string;
|
|
132
|
+
app_slugs: string[];
|
|
133
|
+
}
|
|
134
|
+
export interface ResponseError<T = string> {
|
|
135
|
+
status: number;
|
|
136
|
+
message: T;
|
|
137
|
+
}
|
package/package.json
CHANGED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
var next_auth_1 = __importDefault(require("next-auth"));
|
|
43
|
-
var credentials_1 = __importDefault(require("next-auth/providers/credentials"));
|
|
44
|
-
var importWalletExternalService_1 = __importDefault(require("../../../../services/axios/import-wallet-service/importWalletExternalService"));
|
|
45
|
-
var refreshTokenKeycloak_1 = __importDefault(require("../../../../handlers/auth/functions/refreshTokenKeycloak"));
|
|
46
|
-
var type_1 = require("../../../../handlers/type");
|
|
47
|
-
var handler = (0, next_auth_1.default)({
|
|
48
|
-
providers: [
|
|
49
|
-
(0, credentials_1.default)({
|
|
50
|
-
name: "Credentials",
|
|
51
|
-
credentials: {},
|
|
52
|
-
authorize: function (credentials) {
|
|
53
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
54
|
-
var _a, seed_pharse, app_slugs, response, tokens, error_1;
|
|
55
|
-
var _b;
|
|
56
|
-
return __generator(this, function (_c) {
|
|
57
|
-
switch (_c.label) {
|
|
58
|
-
case 0:
|
|
59
|
-
_c.trys.push([0, 2, , 3]);
|
|
60
|
-
_a = credentials, seed_pharse = _a.seed_pharse, app_slugs = _a.app_slugs;
|
|
61
|
-
return [4 /*yield*/, (0, importWalletExternalService_1.default)({
|
|
62
|
-
seed_pharse: seed_pharse,
|
|
63
|
-
app_slugs: [app_slugs || ""],
|
|
64
|
-
})];
|
|
65
|
-
case 1:
|
|
66
|
-
response = _c.sent();
|
|
67
|
-
if (response === null || response === void 0 ? void 0 : response.success) {
|
|
68
|
-
tokens = (_b = response === null || response === void 0 ? void 0 : response.data) === null || _b === void 0 ? void 0 : _b.tokens;
|
|
69
|
-
console.warn("🚀 ~ authorize ~ tokens:", tokens);
|
|
70
|
-
return [2 /*return*/, {
|
|
71
|
-
access_token: tokens.access_token,
|
|
72
|
-
refresh_token: tokens.refresh_token,
|
|
73
|
-
expires_at: tokens.expires_in,
|
|
74
|
-
refresh_expires_at: tokens.refresh_expires_in || 240,
|
|
75
|
-
client: "tek_wallet",
|
|
76
|
-
}];
|
|
77
|
-
}
|
|
78
|
-
return [2 /*return*/, null];
|
|
79
|
-
case 2:
|
|
80
|
-
error_1 = _c.sent();
|
|
81
|
-
console.error("🚀 ~ authorize ~ error:", error_1);
|
|
82
|
-
return [2 /*return*/, null];
|
|
83
|
-
case 3: return [2 /*return*/];
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
},
|
|
88
|
-
}),
|
|
89
|
-
],
|
|
90
|
-
session: {
|
|
91
|
-
strategy: "jwt",
|
|
92
|
-
},
|
|
93
|
-
secret: process.env.TEK_WALLET_AUTH_SECRET,
|
|
94
|
-
cookies: {
|
|
95
|
-
sessionToken: {
|
|
96
|
-
name: "tek_wallet_session_token",
|
|
97
|
-
options: {
|
|
98
|
-
httpOnly: true,
|
|
99
|
-
secure: process.env.NODE_ENV === "production",
|
|
100
|
-
sameSite: "lax",
|
|
101
|
-
path: "/",
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
callbacks: {
|
|
106
|
-
jwt: function (_a) {
|
|
107
|
-
return __awaiter(this, arguments, void 0, function (_b) {
|
|
108
|
-
var preExpiredTime, expiresAt, refreshedTokens, data, expiresAt;
|
|
109
|
-
var _c, _d;
|
|
110
|
-
var user = _b.user, token = _b.token;
|
|
111
|
-
return __generator(this, function (_e) {
|
|
112
|
-
switch (_e.label) {
|
|
113
|
-
case 0:
|
|
114
|
-
preExpiredTime = 40000;
|
|
115
|
-
//The first time login
|
|
116
|
-
console.warn("🚀 ~ jwt ~ user:", user, token);
|
|
117
|
-
if (user) {
|
|
118
|
-
expiresAt = ((_c = user.expires_at) !== null && _c !== void 0 ? _c : 0) * 1000;
|
|
119
|
-
token.accessToken = user.access_token;
|
|
120
|
-
token.refreshToken = user.refresh_token;
|
|
121
|
-
token.expiresAt = Math.max(expiresAt - preExpiredTime, 0);
|
|
122
|
-
token.refreshExpiresAt = user.refresh_expires_at;
|
|
123
|
-
}
|
|
124
|
-
if (!(Date.now() > +((_d = token.expiresAt) !== null && _d !== void 0 ? _d : 0))) return [3 /*break*/, 2];
|
|
125
|
-
return [4 /*yield*/, (0, refreshTokenKeycloak_1.default)(token.refreshToken)];
|
|
126
|
-
case 1:
|
|
127
|
-
refreshedTokens = _e.sent();
|
|
128
|
-
console.warn("🚀 ~ jwt ~ refreshedTokens:", token.refreshToken, refreshedTokens);
|
|
129
|
-
if (refreshedTokens.status === type_1.REFRESH_TOKEN_STATUS.SUCCESS) {
|
|
130
|
-
data = refreshedTokens.data;
|
|
131
|
-
expiresAt = (data === null || data === void 0 ? void 0 : data.expires_in) * 1000 + Date.now();
|
|
132
|
-
token.accessToken = data === null || data === void 0 ? void 0 : data.access_token;
|
|
133
|
-
token.refreshToken = data === null || data === void 0 ? void 0 : data.refresh_token;
|
|
134
|
-
token.expiresAt = Math.max(expiresAt - preExpiredTime, 0);
|
|
135
|
-
token.error = "";
|
|
136
|
-
}
|
|
137
|
-
if (refreshedTokens.status === type_1.REFRESH_TOKEN_STATUS.FAILED) {
|
|
138
|
-
token.error = type_1.REFRESH_TOKEN_STATUS.FAILED;
|
|
139
|
-
}
|
|
140
|
-
_e.label = 2;
|
|
141
|
-
case 2: return [2 /*return*/, token];
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
},
|
|
146
|
-
session: function (_a) {
|
|
147
|
-
return __awaiter(this, arguments, void 0, function (_b) {
|
|
148
|
-
var session = _b.session, token = _b.token;
|
|
149
|
-
return __generator(this, function (_c) {
|
|
150
|
-
if (token) {
|
|
151
|
-
session.accessToken = token.accessToken;
|
|
152
|
-
session.refreshToken = token.refreshToken;
|
|
153
|
-
session.expiresAt = token.expiresAt;
|
|
154
|
-
session.refreshExpiresAt = token.refreshExpiresAt;
|
|
155
|
-
}
|
|
156
|
-
return [2 /*return*/, session];
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
});
|
|
162
|
-
exports.default = handler;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setConfigs = exports.configs = void 0;
|
|
4
|
-
exports.configs = {
|
|
5
|
-
serverUrl: "",
|
|
6
|
-
appSlug: "",
|
|
7
|
-
};
|
|
8
|
-
var setConfigs = function (newConfigs) {
|
|
9
|
-
Object.assign(exports.configs, newConfigs);
|
|
10
|
-
};
|
|
11
|
-
exports.setConfigs = setConfigs;
|
package/dist/configs/app/type.js
DELETED
package/dist/handlers/type.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export interface ResponseError<T = string> {
|
|
2
|
-
status: number;
|
|
3
|
-
message: T;
|
|
4
|
-
}
|
|
5
|
-
export interface LoginInfo {
|
|
6
|
-
accessToken: string;
|
|
7
|
-
refreshToken: string;
|
|
8
|
-
expiresAt: number;
|
|
9
|
-
refreshExpiresAt: number;
|
|
10
|
-
}
|
|
11
|
-
export interface LoginInfoResponse extends Omit<LoginInfo, "refreshToken" | "refreshExpiresAt"> {
|
|
12
|
-
}
|
|
13
|
-
export declare enum LoginMessage {
|
|
14
|
-
SUCCESS = "Login is successfully",
|
|
15
|
-
ERROR = "Login is failed",
|
|
16
|
-
EXPIRED = "Login info is expired",
|
|
17
|
-
NOT_FOUND = "Login info is not found",
|
|
18
|
-
REFRESH_TOKEN_FAILED = "Refresh token is failed"
|
|
19
|
-
}
|
|
20
|
-
export declare enum REFRESH_TOKEN_STATUS {
|
|
21
|
-
FAILED = "Refresh token is failed",
|
|
22
|
-
SUCCESS = "Refresh token is successfully"
|
|
23
|
-
}
|
package/dist/hooks/type.d.ts
DELETED
package/dist/hooks/type.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LoginStatus = void 0;
|
|
4
|
-
var LoginStatus;
|
|
5
|
-
(function (LoginStatus) {
|
|
6
|
-
LoginStatus["AUTHENTICATED"] = "authenticated";
|
|
7
|
-
LoginStatus["UNAUTHENTICATED"] = "unauthenticated";
|
|
8
|
-
})(LoginStatus || (exports.LoginStatus = LoginStatus = {}));
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var authThunk_1 = require("./../store/auth/authThunk");
|
|
4
|
-
var react_redux_1 = require("react-redux");
|
|
5
|
-
var react_redux_2 = require("react-redux");
|
|
6
|
-
var tokenThunk_1 = require("../store/tokens/tokenThunk");
|
|
7
|
-
var hooks_1 = require("../store/hooks");
|
|
8
|
-
function useTekWallet() {
|
|
9
|
-
var dispatch = (0, react_redux_2.useDispatch)();
|
|
10
|
-
var tokens = (0, react_redux_1.useSelector)(function (state) { return state.tokens; }).tokens;
|
|
11
|
-
var isAuthenticated = (0, hooks_1.useAppSelector)(function (state) { return state.auth; }).isAuthenticated;
|
|
12
|
-
var disconnect = function () {
|
|
13
|
-
dispatch((0, authThunk_1.disconnectWallet)());
|
|
14
|
-
};
|
|
15
|
-
var updateTokens = function () {
|
|
16
|
-
dispatch((0, tokenThunk_1.getBalanceThunk)());
|
|
17
|
-
};
|
|
18
|
-
return {
|
|
19
|
-
tokens: tokens,
|
|
20
|
-
updateTokens: updateTokens,
|
|
21
|
-
disconnect: disconnect,
|
|
22
|
-
isAuthenticated: isAuthenticated,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
exports.default = useTekWallet;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
"use client";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
-
var hooks_1 = require("../../store/hooks");
|
|
9
|
-
var react_1 = __importDefault(require("react"));
|
|
10
|
-
var tokenThunk_1 = require("../../store/tokens/tokenThunk");
|
|
11
|
-
var authThunk_1 = require("../../store/auth/authThunk");
|
|
12
|
-
var AuthContext = react_1.default.createContext(null);
|
|
13
|
-
function AuthProvider(_a) {
|
|
14
|
-
var children = _a.children;
|
|
15
|
-
var timeout = react_1.default.useRef(undefined);
|
|
16
|
-
var dispatch = (0, hooks_1.useAppDispatch)();
|
|
17
|
-
var _b = (0, hooks_1.useAppSelector)(function (state) { return state.auth; }), isAuthenticated = _b.isAuthenticated, session = _b.session;
|
|
18
|
-
react_1.default.useEffect(function () {
|
|
19
|
-
dispatch((0, authThunk_1.update)());
|
|
20
|
-
}, []);
|
|
21
|
-
react_1.default.useEffect(function () {
|
|
22
|
-
if (isAuthenticated) {
|
|
23
|
-
dispatch((0, tokenThunk_1.getBalanceThunk)());
|
|
24
|
-
}
|
|
25
|
-
}, [isAuthenticated]);
|
|
26
|
-
react_1.default.useEffect(function () {
|
|
27
|
-
var _a;
|
|
28
|
-
!!timeout.current && clearTimeout(timeout.current);
|
|
29
|
-
var expiredTime = +((_a = session === null || session === void 0 ? void 0 : session.expiresAt) !== null && _a !== void 0 ? _a : 0);
|
|
30
|
-
console.warn("🚀 ~ React.useEffect ~ expiredTime:", expiredTime, session);
|
|
31
|
-
var currentTime = Date.now();
|
|
32
|
-
var timeDiff = Math.max(expiredTime - currentTime, 0);
|
|
33
|
-
console.warn("🚀 ~ React.useEffect ~ timeDiff:", timeDiff);
|
|
34
|
-
timeout.current = setTimeout(function () {
|
|
35
|
-
dispatch((0, authThunk_1.update)());
|
|
36
|
-
}, timeDiff);
|
|
37
|
-
return function () { return clearTimeout(timeout.current); };
|
|
38
|
-
}, [session === null || session === void 0 ? void 0 : session.expiresAt]);
|
|
39
|
-
return (0, jsx_runtime_1.jsx)(AuthContext.Provider, { value: null, children: children });
|
|
40
|
-
}
|
|
41
|
-
exports.default = AuthProvider;
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
export interface CreateWalletServiceResponse {
|
|
2
|
-
success: boolean;
|
|
3
|
-
message: string;
|
|
4
|
-
data: Data;
|
|
5
|
-
timestamp: string;
|
|
6
|
-
}
|
|
7
|
-
interface Data {
|
|
8
|
-
id: string;
|
|
9
|
-
user_updated: string;
|
|
10
|
-
date_created: string;
|
|
11
|
-
date_updated: null;
|
|
12
|
-
user_created: string;
|
|
13
|
-
address: string;
|
|
14
|
-
app_slug: string[];
|
|
15
|
-
balances: Balance[];
|
|
16
|
-
blockchain_wallets: Blockchainwallet[];
|
|
17
|
-
seed_pharse: string;
|
|
18
|
-
user: User;
|
|
19
|
-
}
|
|
20
|
-
interface User {
|
|
21
|
-
action_token_url: string;
|
|
22
|
-
user_id: string;
|
|
23
|
-
access_token: string;
|
|
24
|
-
refresh_token: string;
|
|
25
|
-
}
|
|
26
|
-
interface Blockchainwallet {
|
|
27
|
-
master_address: string;
|
|
28
|
-
blockchain_address: string;
|
|
29
|
-
network_slug: string;
|
|
30
|
-
}
|
|
31
|
-
interface Balance {
|
|
32
|
-
id: string;
|
|
33
|
-
master_wallet_id: string;
|
|
34
|
-
currency_slug: string;
|
|
35
|
-
current_value: string;
|
|
36
|
-
total_value: string;
|
|
37
|
-
user_created: string;
|
|
38
|
-
user_updated: string;
|
|
39
|
-
date_created: string;
|
|
40
|
-
date_updated: null;
|
|
41
|
-
currency_name: string;
|
|
42
|
-
}
|
|
43
|
-
export {};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export interface GetBalanceServiceResponse {
|
|
2
|
-
id: string;
|
|
3
|
-
user_updated: string;
|
|
4
|
-
date_created: string;
|
|
5
|
-
date_updated: null;
|
|
6
|
-
user_created: string;
|
|
7
|
-
address: string;
|
|
8
|
-
app_slug: string[];
|
|
9
|
-
balances: Balance[];
|
|
10
|
-
blockchain_wallets: Blockchainwallet[];
|
|
11
|
-
}
|
|
12
|
-
interface Blockchainwallet {
|
|
13
|
-
master_address: string;
|
|
14
|
-
blockchain_address: string;
|
|
15
|
-
network_slug: string;
|
|
16
|
-
}
|
|
17
|
-
export interface Balance {
|
|
18
|
-
id: string;
|
|
19
|
-
master_wallet_id: string;
|
|
20
|
-
currency_slug: string;
|
|
21
|
-
current_value: string;
|
|
22
|
-
total_value: string;
|
|
23
|
-
user_created: string;
|
|
24
|
-
user_updated: string;
|
|
25
|
-
date_created: string;
|
|
26
|
-
date_updated: null;
|
|
27
|
-
currency: Currency;
|
|
28
|
-
}
|
|
29
|
-
interface Currency {
|
|
30
|
-
id: number;
|
|
31
|
-
name: string;
|
|
32
|
-
slug: string;
|
|
33
|
-
full_name: string;
|
|
34
|
-
icon: string;
|
|
35
|
-
link: string;
|
|
36
|
-
}
|
|
37
|
-
export {};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export interface importWalletServiceBody {
|
|
2
|
-
seed_pharse: string;
|
|
3
|
-
app_slugs: string[];
|
|
4
|
-
}
|
|
5
|
-
export interface ImportWalletServiceResponse {
|
|
6
|
-
success: boolean;
|
|
7
|
-
message: string;
|
|
8
|
-
data: Data;
|
|
9
|
-
timestamp: string;
|
|
10
|
-
}
|
|
11
|
-
interface Data {
|
|
12
|
-
id: string;
|
|
13
|
-
user_updated: string;
|
|
14
|
-
date_created: string;
|
|
15
|
-
date_updated: null;
|
|
16
|
-
user_created: string;
|
|
17
|
-
address: string;
|
|
18
|
-
app_slug: string[];
|
|
19
|
-
balances: null[][];
|
|
20
|
-
assets: number;
|
|
21
|
-
blockchain_wallets: null[][];
|
|
22
|
-
tokens: Tokens;
|
|
23
|
-
}
|
|
24
|
-
interface Tokens {
|
|
25
|
-
access_token: string;
|
|
26
|
-
expires_in: number;
|
|
27
|
-
refresh_expires_in: number;
|
|
28
|
-
refresh_token: string;
|
|
29
|
-
token_type: string;
|
|
30
|
-
session_state: string;
|
|
31
|
-
}
|
|
32
|
-
export {};
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|