squarefi-bff-api-module 1.8.2 → 1.10.0
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/api/types.d.ts +9 -0
- package/dist/utils/tokensFactory.js +2 -13
- package/package.json +1 -1
- package/src/api/types.ts +9 -0
- package/src/utils/tokensFactory.ts +2 -13
package/dist/api/types.d.ts
CHANGED
|
@@ -1169,6 +1169,15 @@ export declare namespace API {
|
|
|
1169
1169
|
wallet_uuid: string;
|
|
1170
1170
|
limit?: number;
|
|
1171
1171
|
offset?: number;
|
|
1172
|
+
filter: {
|
|
1173
|
+
created_at?: string;
|
|
1174
|
+
from?: string;
|
|
1175
|
+
status?: string;
|
|
1176
|
+
to?: string;
|
|
1177
|
+
type?: string;
|
|
1178
|
+
method?: WalletTransactionMeta;
|
|
1179
|
+
record_type?: WalletTransactionRecordType;
|
|
1180
|
+
};
|
|
1172
1181
|
};
|
|
1173
1182
|
type Response = {
|
|
1174
1183
|
total: number;
|
|
@@ -13,7 +13,6 @@ exports.setTokens = setTokens;
|
|
|
13
13
|
exports.deleteTokens = deleteTokens;
|
|
14
14
|
exports.refreshTokens = refreshTokens;
|
|
15
15
|
exports.getTokens = getTokens;
|
|
16
|
-
const sdk_react_1 = require("@telegram-apps/sdk-react");
|
|
17
16
|
const storage_1 = require("./storage");
|
|
18
17
|
const auth_1 = require("../api/auth");
|
|
19
18
|
function setTokens({ access_token, refresh_token }) {
|
|
@@ -27,20 +26,10 @@ function deleteTokens() {
|
|
|
27
26
|
function refreshTokens() {
|
|
28
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
28
|
const refreshToken = (0, storage_1.getFromLocalStorage)('refresh_token');
|
|
30
|
-
if (!refreshToken
|
|
29
|
+
if (!refreshToken) {
|
|
31
30
|
return null;
|
|
32
31
|
}
|
|
33
|
-
const
|
|
34
|
-
var _a;
|
|
35
|
-
return (0, sdk_react_1.isTMA)()
|
|
36
|
-
? auth_1.auth.signin.telegram({
|
|
37
|
-
tg_id: (_a = sdk_react_1.initData.user()) === null || _a === void 0 ? void 0 : _a.id,
|
|
38
|
-
hash: sdk_react_1.initData.hash(),
|
|
39
|
-
init_data_raw: sdk_react_1.initData.raw(),
|
|
40
|
-
})
|
|
41
|
-
: auth_1.auth.refresh.refresh_token(refreshToken);
|
|
42
|
-
};
|
|
43
|
-
const tokens = yield refreshHandler();
|
|
32
|
+
const tokens = yield auth_1.auth.refresh.refresh_token(refreshToken);
|
|
44
33
|
setTokens(tokens);
|
|
45
34
|
return tokens;
|
|
46
35
|
});
|
package/package.json
CHANGED
package/src/api/types.ts
CHANGED
|
@@ -1427,6 +1427,15 @@ export namespace API {
|
|
|
1427
1427
|
wallet_uuid: string;
|
|
1428
1428
|
limit?: number;
|
|
1429
1429
|
offset?: number;
|
|
1430
|
+
filter: {
|
|
1431
|
+
created_at?: string;
|
|
1432
|
+
from?: string;
|
|
1433
|
+
status?: string;
|
|
1434
|
+
to?: string;
|
|
1435
|
+
type?: string;
|
|
1436
|
+
method?: WalletTransactionMeta;
|
|
1437
|
+
record_type?: WalletTransactionRecordType;
|
|
1438
|
+
};
|
|
1430
1439
|
};
|
|
1431
1440
|
export type Response = {
|
|
1432
1441
|
total: number;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { initData, isTMA } from '@telegram-apps/sdk-react';
|
|
2
|
-
|
|
3
1
|
import { deleteFromLocalStorage, getFromLocalStorage, setToLocalStorage } from './storage';
|
|
4
2
|
|
|
5
3
|
import { auth } from '../api/auth';
|
|
@@ -22,20 +20,11 @@ export function deleteTokens() {
|
|
|
22
20
|
export async function refreshTokens() {
|
|
23
21
|
const refreshToken = getFromLocalStorage('refresh_token');
|
|
24
22
|
|
|
25
|
-
if (!refreshToken
|
|
23
|
+
if (!refreshToken) {
|
|
26
24
|
return null;
|
|
27
25
|
}
|
|
28
26
|
|
|
29
|
-
const
|
|
30
|
-
isTMA()
|
|
31
|
-
? auth.signin.telegram({
|
|
32
|
-
tg_id: initData.user()?.id as number,
|
|
33
|
-
hash: initData.hash() as string,
|
|
34
|
-
init_data_raw: initData.raw() as string,
|
|
35
|
-
})
|
|
36
|
-
: auth.refresh.refresh_token(refreshToken as string);
|
|
37
|
-
|
|
38
|
-
const tokens = await refreshHandler();
|
|
27
|
+
const tokens = await auth.refresh.refresh_token(refreshToken);
|
|
39
28
|
|
|
40
29
|
setTokens(tokens);
|
|
41
30
|
|