squarefi-bff-api-module 1.0.0 → 1.0.2
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/auth.js +11 -10
- package/dist/api/developer.js +6 -6
- package/dist/api/exchange.js +4 -4
- package/dist/api/fiat_accounts.js +12 -12
- package/dist/api/index.d.ts +23 -11
- package/dist/api/index.js +23 -15
- package/dist/api/issuing.js +14 -14
- package/dist/api/kyc.js +2 -2
- package/dist/api/list.js +3 -3
- package/dist/api/orders.js +6 -6
- package/dist/api/user.js +8 -8
- package/dist/api/wallets.js +7 -7
- package/dist/utils/apiClientFactory.d.ts +12 -0
- package/dist/utils/apiClientFactory.js +15 -1
- package/package.json +1 -1
- package/src/api/auth.ts +2 -2
- package/src/api/developer.ts +1 -1
- package/src/api/exchange.ts +1 -1
- package/src/api/fiat_accounts.ts +3 -3
- package/src/api/index.ts +34 -14
- package/src/api/issuing.ts +1 -1
- package/src/api/kyc.ts +1 -1
- package/src/api/list.ts +1 -1
- package/src/api/orders.ts +1 -1
- package/src/api/user.ts +1 -1
- package/src/api/wallets.ts +1 -1
- package/src/utils/apiClientFactory.ts +15 -0
package/dist/api/auth.js
CHANGED
|
@@ -1,38 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.auth = exports.refreshTokenPath = exports.telegramSignUpPath = exports.telegramSignInPath = void 0;
|
|
4
|
-
const
|
|
4
|
+
const apiClientFactory_1 = require("../utils/apiClientFactory");
|
|
5
5
|
exports.telegramSignInPath = '/auth/sign-in/telegram';
|
|
6
6
|
exports.telegramSignUpPath = '/auth/sign-up/telegram';
|
|
7
7
|
exports.refreshTokenPath = '/auth/refresh/refresh-token';
|
|
8
8
|
exports.auth = {
|
|
9
9
|
otp: {
|
|
10
10
|
verify: {
|
|
11
|
-
email: (email, token) =>
|
|
11
|
+
email: (email, token) => apiClientFactory_1.apiClientV2.postRequest('/auth/verify/email/otp', {
|
|
12
12
|
data: { email, token, type: 'email' },
|
|
13
13
|
}),
|
|
14
|
-
phone: (phone, token) =>
|
|
14
|
+
phone: (phone, token) => apiClientFactory_1.apiClientV2.postRequest('/auth/verify/phone/otp', {
|
|
15
15
|
data: { phone, token, type: 'sms' },
|
|
16
16
|
}),
|
|
17
17
|
},
|
|
18
18
|
},
|
|
19
19
|
signin: {
|
|
20
20
|
omni: {
|
|
21
|
-
email: (data) =>
|
|
22
|
-
phone: (data) =>
|
|
21
|
+
email: (data) => apiClientFactory_1.apiClientV2.postRequest('/auth/sign-in/omni/email/otp', { data }),
|
|
22
|
+
phone: (data) => apiClientFactory_1.apiClientV2.postRequest('/auth/sign-in/omni/phone/otp', { data }),
|
|
23
23
|
},
|
|
24
|
-
telegram: (data) =>
|
|
25
|
-
password: (email, password
|
|
24
|
+
telegram: (data) => apiClientFactory_1.apiClientV2.postRequest(exports.telegramSignInPath, { data }),
|
|
25
|
+
password: (email, password // check on backend V2
|
|
26
|
+
) => apiClientFactory_1.apiClientV2.postRequest('/auth/sign-in/password', {
|
|
26
27
|
data: { email, password },
|
|
27
28
|
}),
|
|
28
29
|
},
|
|
29
30
|
signup: {
|
|
30
|
-
password: (email, password) =>
|
|
31
|
+
password: (email, password) => apiClientFactory_1.apiClientV2.postRequest('/auth/sign-up/password', {
|
|
31
32
|
data: { email, password },
|
|
32
33
|
}),
|
|
33
|
-
telegram: (data) =>
|
|
34
|
+
telegram: (data) => apiClientFactory_1.apiClientV2.postRequest(exports.telegramSignUpPath, { data }),
|
|
34
35
|
},
|
|
35
36
|
refresh: {
|
|
36
|
-
refresh_token: (refresh_token) =>
|
|
37
|
+
refresh_token: (refresh_token) => apiClientFactory_1.apiClientV2.postRequest(exports.refreshTokenPath, { data: { refresh_token } }),
|
|
37
38
|
},
|
|
38
39
|
};
|
package/dist/api/developer.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.developer = void 0;
|
|
4
|
-
const
|
|
4
|
+
const apiClientFactory_1 = require("../utils/apiClientFactory");
|
|
5
5
|
exports.developer = {
|
|
6
6
|
apiKeys: {
|
|
7
|
-
getAll: () =>
|
|
8
|
-
create: (data) =>
|
|
9
|
-
rotate: (data) =>
|
|
10
|
-
update: (data) =>
|
|
7
|
+
getAll: () => apiClientFactory_1.apiClientV1.getRequest('/developer/access/list'),
|
|
8
|
+
create: (data) => apiClientFactory_1.apiClientV1.postRequest('/developer/access/create', { data }),
|
|
9
|
+
rotate: (data) => apiClientFactory_1.apiClientV1.postRequest(`/developer/access/rotate`, { data }),
|
|
10
|
+
update: (data) => apiClientFactory_1.apiClientV1.postRequest(`/developer/access/update`, { data }),
|
|
11
11
|
},
|
|
12
12
|
vendors: {
|
|
13
|
-
list: () =>
|
|
13
|
+
list: () => apiClientFactory_1.apiClientV1.getRequest('/developer/vendors/list'),
|
|
14
14
|
},
|
|
15
15
|
};
|
package/dist/api/exchange.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.exchange = void 0;
|
|
4
|
-
const
|
|
4
|
+
const apiClientFactory_1 = require("../utils/apiClientFactory");
|
|
5
5
|
const constants_1 = require("../constants");
|
|
6
6
|
const createOrderTypeMethods = (orderType) => ({
|
|
7
|
-
getByFromCurrency: (from_uuid) =>
|
|
7
|
+
getByFromCurrency: (from_uuid) => apiClientFactory_1.apiClientV1
|
|
8
8
|
.getRequest('/exchange/', { params: { from_uuid, order_type: orderType } })
|
|
9
9
|
.then(({ data }) => data),
|
|
10
|
-
getByToCurrency: (to_uuid) =>
|
|
10
|
+
getByToCurrency: (to_uuid) => apiClientFactory_1.apiClientV1
|
|
11
11
|
.getRequest('/exchange/', { params: { to_uuid, order_type: orderType } })
|
|
12
12
|
.then(({ data }) => data),
|
|
13
|
-
getByOrderType: () =>
|
|
13
|
+
getByOrderType: () => apiClientFactory_1.apiClientV1
|
|
14
14
|
.getRequest('/exchange/', { params: { order_type: orderType } })
|
|
15
15
|
.then(({ data }) => data),
|
|
16
16
|
});
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fiat_accounts = exports.fiat_accounts_v2 = void 0;
|
|
4
|
-
const
|
|
4
|
+
const apiClientFactory_1 = require("../utils/apiClientFactory");
|
|
5
5
|
exports.fiat_accounts_v2 = {
|
|
6
6
|
list: {
|
|
7
7
|
withCards: {
|
|
8
|
-
getAll: (wallet_uuid, limit, offset) =>
|
|
8
|
+
getAll: (wallet_uuid, limit, offset) => apiClientFactory_1.apiClientV2.getRequest(`/fiat-accounts/${wallet_uuid}`, {
|
|
9
9
|
params: { limit, offset, show_cards: true },
|
|
10
10
|
}),
|
|
11
11
|
},
|
|
12
12
|
withoutCards: {
|
|
13
|
-
getAll: (wallet_uuid, limit, offset) =>
|
|
13
|
+
getAll: (wallet_uuid, limit, offset) => apiClientFactory_1.apiClientV2.getRequest(`/fiat-accounts/${wallet_uuid}`, {
|
|
14
14
|
params: { limit, offset },
|
|
15
15
|
}),
|
|
16
16
|
},
|
|
17
17
|
},
|
|
18
|
-
getByUuid: ({ wallet_uuid, fiat_account_id }) =>
|
|
19
|
-
create: ({ wallet_id, program_id }) =>
|
|
18
|
+
getByUuid: ({ wallet_uuid, fiat_account_id }) => apiClientFactory_1.apiClientV2.getRequest(`/fiat-accounts/${wallet_uuid}/${fiat_account_id}`),
|
|
19
|
+
create: ({ wallet_id, program_id }) => apiClientFactory_1.apiClientV2.postRequest(`/fiat-accounts/${wallet_id}`, {
|
|
20
20
|
data: { program_id },
|
|
21
21
|
}),
|
|
22
22
|
transactions: {
|
|
23
|
-
get: ({ fiat_account_id, wallet_uuid, limit, offset }) =>
|
|
23
|
+
get: ({ fiat_account_id, wallet_uuid, limit, offset }) => apiClientFactory_1.apiClientV2.getRequest(`/fiat-accounts/${wallet_uuid}/${fiat_account_id}/transactions`, {
|
|
24
24
|
params: { limit, offset },
|
|
25
25
|
}),
|
|
26
26
|
},
|
|
@@ -28,23 +28,23 @@ exports.fiat_accounts_v2 = {
|
|
|
28
28
|
exports.fiat_accounts = {
|
|
29
29
|
list: {
|
|
30
30
|
withCards: {
|
|
31
|
-
getSinglecards: (wallet_uuid, limit, offset) =>
|
|
31
|
+
getSinglecards: (wallet_uuid, limit, offset) => apiClientFactory_1.apiClientV1.getRequest(`/fiat_accounts/list/${wallet_uuid}`, {
|
|
32
32
|
params: { limit, offset, lt_cards_limit: 2, gt_cards_limit: 0, show_cards: true },
|
|
33
33
|
}),
|
|
34
|
-
getAll: (wallet_uuid, limit, offset) =>
|
|
34
|
+
getAll: (wallet_uuid, limit, offset) => apiClientFactory_1.apiClientV1.getRequest(`/fiat_accounts/list/${wallet_uuid}`, {
|
|
35
35
|
params: { limit, offset, show_cards: true },
|
|
36
36
|
}),
|
|
37
37
|
},
|
|
38
38
|
withoutCards: {
|
|
39
|
-
getAll: (wallet_uuid, limit, offset) =>
|
|
39
|
+
getAll: (wallet_uuid, limit, offset) => apiClientFactory_1.apiClientV1.getRequest(`/fiat_accounts/list/${wallet_uuid}`, {
|
|
40
40
|
params: { limit, offset },
|
|
41
41
|
}),
|
|
42
42
|
},
|
|
43
43
|
},
|
|
44
|
-
getByUuid: (uuid) =>
|
|
45
|
-
create: (wallet_id, program_id) =>
|
|
44
|
+
getByUuid: (uuid) => apiClientFactory_1.apiClientV1.getRequest(`/fiat_accounts/${uuid}`),
|
|
45
|
+
create: (wallet_id, program_id) => apiClientFactory_1.apiClientV1.postRequest(`/fiat_accounts`, { data: { wallet_id, program_id } }),
|
|
46
46
|
transactions: {
|
|
47
|
-
get: (fiat_account_id, limit, offset) =>
|
|
47
|
+
get: (fiat_account_id, limit, offset) => apiClientFactory_1.apiClientV1.getRequest(`/fiat_accounts/${fiat_account_id}/transactions`, {
|
|
48
48
|
params: { limit, offset },
|
|
49
49
|
}),
|
|
50
50
|
},
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { auth } from './auth';
|
|
2
|
+
import { developer } from './developer';
|
|
3
|
+
import { exchange } from './exchange';
|
|
4
|
+
import { fiat_accounts } from './fiat_accounts';
|
|
5
|
+
import { issuing } from './issuing';
|
|
6
|
+
import { kyc } from './kyc';
|
|
7
|
+
import { list } from './list';
|
|
8
|
+
import { orders } from './orders';
|
|
9
|
+
import { user } from './user';
|
|
10
|
+
import { wallets } from './wallets';
|
|
11
|
+
type Api = {
|
|
12
|
+
auth: typeof auth;
|
|
13
|
+
developer: typeof developer;
|
|
14
|
+
exchange: typeof exchange;
|
|
15
|
+
fiat_accounts: typeof fiat_accounts;
|
|
16
|
+
issuing: typeof issuing;
|
|
17
|
+
kyc: typeof kyc;
|
|
18
|
+
list: typeof list;
|
|
19
|
+
orders: typeof orders;
|
|
20
|
+
user: typeof user;
|
|
21
|
+
wallets: typeof wallets;
|
|
12
22
|
};
|
|
23
|
+
export declare const squarefiBffApiClient: Api;
|
|
24
|
+
export {};
|
package/dist/api/index.js
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a, _b, _c;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
3
|
+
exports.squarefiBffApiClient = void 0;
|
|
4
|
+
const auth_1 = require("./auth");
|
|
5
|
+
const developer_1 = require("./developer");
|
|
6
|
+
const exchange_1 = require("./exchange");
|
|
7
|
+
const fiat_accounts_1 = require("./fiat_accounts");
|
|
8
|
+
const issuing_1 = require("./issuing");
|
|
9
|
+
const kyc_1 = require("./kyc");
|
|
10
|
+
const list_1 = require("./list");
|
|
11
|
+
const orders_1 = require("./orders");
|
|
12
|
+
const user_1 = require("./user");
|
|
13
|
+
const wallets_1 = require("./wallets");
|
|
14
|
+
exports.squarefiBffApiClient = {
|
|
15
|
+
auth: auth_1.auth,
|
|
16
|
+
developer: developer_1.developer,
|
|
17
|
+
exchange: exchange_1.exchange,
|
|
18
|
+
fiat_accounts: fiat_accounts_1.fiat_accounts,
|
|
19
|
+
issuing: issuing_1.issuing,
|
|
20
|
+
kyc: kyc_1.kyc,
|
|
21
|
+
list: list_1.list,
|
|
22
|
+
orders: orders_1.orders,
|
|
23
|
+
user: user_1.user,
|
|
24
|
+
wallets: wallets_1.wallets,
|
|
25
|
+
};
|
package/dist/api/issuing.js
CHANGED
|
@@ -22,18 +22,18 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
23
|
exports.issuing = void 0;
|
|
24
24
|
const fiat_accounts_1 = require("./fiat_accounts");
|
|
25
|
-
const
|
|
25
|
+
const apiClientFactory_1 = require("../utils/apiClientFactory");
|
|
26
26
|
const constants_1 = require("../constants");
|
|
27
27
|
exports.issuing = {
|
|
28
28
|
cards: {
|
|
29
29
|
create: {
|
|
30
|
-
standAloneCard: (data) =>
|
|
31
|
-
fiatAccountCard: (data) =>
|
|
30
|
+
standAloneCard: (data) => apiClientFactory_1.apiClientV1.postRequest('/issuing/cards/create', { data }),
|
|
31
|
+
fiatAccountCard: (data) => apiClientFactory_1.apiClientV1.postRequest('/issuing/cards/balance', { data }),
|
|
32
32
|
},
|
|
33
|
-
getByWalletUuid: (params) =>
|
|
34
|
-
getByFiatAccountAndWalletId: (params) =>
|
|
33
|
+
getByWalletUuid: (params) => apiClientFactory_1.apiClientV1.getRequest('/issuing/cards', { params }),
|
|
34
|
+
getByFiatAccountAndWalletId: (params) => apiClientFactory_1.apiClientV1.getRequest('/issuing/cards', { params }),
|
|
35
35
|
getById: (card_id) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
-
const _a = yield
|
|
36
|
+
const _a = yield apiClientFactory_1.apiClientV1.getRequest(`/issuing/cards/${card_id}`), { data: card } = _a, rest = __rest(_a, ["data"]);
|
|
37
37
|
const { data: fiatAccountData } = yield fiat_accounts_1.fiat_accounts.getByUuid(card.fiat_account.id);
|
|
38
38
|
// const { data: fiatAccountData } = await fiat_accounts.getByUuid({ V2 API FIAT ACCOUNTS
|
|
39
39
|
// wallet_uuid: card.fiat_account.wallet_id,
|
|
@@ -42,27 +42,27 @@ exports.issuing = {
|
|
|
42
42
|
return Object.assign(Object.assign({}, rest), { data: Object.assign(Object.assign({}, card), { fiat_account: Object.assign(Object.assign({}, fiatAccountData), { type: card.fiat_account.type }) }) });
|
|
43
43
|
}),
|
|
44
44
|
sensitiveData: {
|
|
45
|
-
get: (card_id) =>
|
|
45
|
+
get: (card_id) => apiClientFactory_1.apiClientV1.getRequest(`/issuing/cards/${card_id}/sensitive`),
|
|
46
46
|
otp: {
|
|
47
47
|
// have to update
|
|
48
|
-
get: (card_id) =>
|
|
48
|
+
get: (card_id) => apiClientFactory_1.apiClientV1.getRequest(`/vcards/cards/${card_id}/sensitive/otp`),
|
|
49
49
|
},
|
|
50
50
|
},
|
|
51
|
-
close: (card_id) =>
|
|
52
|
-
freeze: (card_id) =>
|
|
53
|
-
unfreeze: (card_id) =>
|
|
51
|
+
close: (card_id) => apiClientFactory_1.apiClientV1.deleteRequest(`/issuing/cards/${card_id}`),
|
|
52
|
+
freeze: (card_id) => apiClientFactory_1.apiClientV1.patchRequest(`/issuing/cards/${card_id}/freeze`),
|
|
53
|
+
unfreeze: (card_id) => apiClientFactory_1.apiClientV1.patchRequest(`/issuing/cards/${card_id}/unfreeze`),
|
|
54
54
|
},
|
|
55
55
|
transactions: {
|
|
56
|
-
getByCardId: (card_id, limit = constants_1.defaultPaginationParams.limit, offset = constants_1.defaultPaginationParams.offset) =>
|
|
56
|
+
getByCardId: (card_id, limit = constants_1.defaultPaginationParams.limit, offset = constants_1.defaultPaginationParams.offset) => apiClientFactory_1.apiClientV1.getRequest(`/issuing/transactions/`, {
|
|
57
57
|
params: { limit, offset, card_id, new_scheme: true },
|
|
58
58
|
}),
|
|
59
|
-
getByFiatAccountId: (fiat_account_id, limit = constants_1.defaultPaginationParams.limit, offset = constants_1.defaultPaginationParams.offset) =>
|
|
59
|
+
getByFiatAccountId: (fiat_account_id, limit = constants_1.defaultPaginationParams.limit, offset = constants_1.defaultPaginationParams.offset) => apiClientFactory_1.apiClientV1.getRequest(`/issuing/transactions/`, {
|
|
60
60
|
params: { limit, offset, fiat_account_id, new_scheme: true },
|
|
61
61
|
}),
|
|
62
62
|
},
|
|
63
63
|
config: {
|
|
64
64
|
programs: {
|
|
65
|
-
getAll: () =>
|
|
65
|
+
getAll: () => apiClientFactory_1.apiClientV1.getRequest('/issuing/config/programs').then(({ data }) => data),
|
|
66
66
|
},
|
|
67
67
|
},
|
|
68
68
|
};
|
package/dist/api/kyc.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.kyc = void 0;
|
|
4
|
-
const
|
|
4
|
+
const apiClientFactory_1 = require("../utils/apiClientFactory");
|
|
5
5
|
exports.kyc = {
|
|
6
6
|
sumsub: {
|
|
7
|
-
generate_token: (data) =>
|
|
7
|
+
generate_token: (data) => apiClientFactory_1.apiClientV1.postRequest('/kyc/sumsub/generate_token', { data }),
|
|
8
8
|
},
|
|
9
9
|
};
|
package/dist/api/list.js
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
/* eslint-disable import/prefer-default-export */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.list = void 0;
|
|
5
|
-
const
|
|
5
|
+
const apiClientFactory_1 = require("../utils/apiClientFactory");
|
|
6
6
|
exports.list = {
|
|
7
7
|
currencies: {
|
|
8
|
-
getAll: (params) =>
|
|
8
|
+
getAll: (params) => apiClientFactory_1.apiClientV2.getRequest('/currencies', params).then(({ data }) => data),
|
|
9
9
|
},
|
|
10
10
|
chains: {
|
|
11
|
-
getAll: (params) =>
|
|
11
|
+
getAll: (params) => apiClientFactory_1.apiClientV2.getRequest('/chains', params).then(({ data }) => data),
|
|
12
12
|
},
|
|
13
13
|
};
|
package/dist/api/orders.js
CHANGED
|
@@ -12,23 +12,23 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.orders = void 0;
|
|
15
|
-
const
|
|
15
|
+
const apiClientFactory_1 = require("../utils/apiClientFactory");
|
|
16
16
|
const constants_1 = require("../constants");
|
|
17
17
|
exports.orders = {
|
|
18
18
|
calc: (_a) => {
|
|
19
19
|
var { signal } = _a, params = __rest(_a, ["signal"]);
|
|
20
|
-
return
|
|
20
|
+
return apiClientFactory_1.apiClientV1.getRequest('/orders/calc', { params, signal }).then((res) => res.data);
|
|
21
21
|
},
|
|
22
22
|
create: {
|
|
23
23
|
byOrderType: {
|
|
24
|
-
[constants_1.OrderType.TRANSFER_CARD_SUBACCOUNT]: (data) =>
|
|
24
|
+
[constants_1.OrderType.TRANSFER_CARD_SUBACCOUNT]: (data) => apiClientFactory_1.apiClientV1.postRequest('/orders/TRANSFER_CARD_SUBACCOUNT', {
|
|
25
25
|
data,
|
|
26
26
|
}),
|
|
27
|
-
[constants_1.OrderType.WITHDRAWAL_CRYPTO]: (data) =>
|
|
27
|
+
[constants_1.OrderType.WITHDRAWAL_CRYPTO]: (data) => apiClientFactory_1.apiClientV1.postRequest('/orders/WITHDRAWAL_CRYPTO', {
|
|
28
28
|
data,
|
|
29
29
|
}),
|
|
30
|
-
[constants_1.OrderType.EXCHANGE_CRYPTO_INTERNAL]: (data) =>
|
|
31
|
-
[constants_1.OrderType.TRANSFER_CARD_WHOLESALE]: (data) =>
|
|
30
|
+
[constants_1.OrderType.EXCHANGE_CRYPTO_INTERNAL]: (data) => apiClientFactory_1.apiClientV1.postRequest('/orders/EXCHANGE_CRYPTO_INTERNAL', { data }),
|
|
31
|
+
[constants_1.OrderType.TRANSFER_CARD_WHOLESALE]: (data) => apiClientFactory_1.apiClientV1.postRequest('/orders/TRANSFER_CARD_WHOLESALE', { data }),
|
|
32
32
|
},
|
|
33
33
|
},
|
|
34
34
|
};
|
package/dist/api/user.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.user = void 0;
|
|
4
|
-
const
|
|
4
|
+
const apiClientFactory_1 = require("../utils/apiClientFactory");
|
|
5
5
|
exports.user = {
|
|
6
|
-
get: () =>
|
|
6
|
+
get: () => apiClientFactory_1.apiClientV2.getRequest('/user'),
|
|
7
7
|
userData: {
|
|
8
|
-
get: () =>
|
|
9
|
-
update: (data) =>
|
|
8
|
+
get: () => apiClientFactory_1.apiClientV2.getRequest('/user/user-data'),
|
|
9
|
+
update: (data) => apiClientFactory_1.apiClientV2.patchRequest('/user/user-data', { data }),
|
|
10
10
|
},
|
|
11
11
|
update: {
|
|
12
12
|
phone: {
|
|
13
|
-
request: (data) =>
|
|
14
|
-
confirm: (data) =>
|
|
13
|
+
request: (data) => apiClientFactory_1.apiClientV2.patchRequest('/user/phone', { data }),
|
|
14
|
+
confirm: (data) => apiClientFactory_1.apiClientV2.postRequest('/user/phone', { data }),
|
|
15
15
|
},
|
|
16
16
|
email: {
|
|
17
|
-
request: (data) =>
|
|
18
|
-
confirm: (data) =>
|
|
17
|
+
request: (data) => apiClientFactory_1.apiClientV2.patchRequest('/user/email', { data }),
|
|
18
|
+
confirm: (data) => apiClientFactory_1.apiClientV2.postRequest('/user/email', { data }),
|
|
19
19
|
},
|
|
20
20
|
},
|
|
21
21
|
};
|
package/dist/api/wallets.js
CHANGED
|
@@ -10,21 +10,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.wallets = void 0;
|
|
13
|
-
const
|
|
13
|
+
const apiClientFactory_1 = require("../utils/apiClientFactory");
|
|
14
14
|
const constants_1 = require("../constants");
|
|
15
15
|
exports.wallets = {
|
|
16
|
-
create: (type) =>
|
|
17
|
-
getAll: () =>
|
|
18
|
-
getByUuid: (uuid) =>
|
|
16
|
+
create: (type) => apiClientFactory_1.apiClientV2.postRequest('/wallets', { data: { type } }).then(({ data }) => data),
|
|
17
|
+
getAll: () => apiClientFactory_1.apiClientV2.getRequest('/wallets').then(({ data }) => data),
|
|
18
|
+
getByUuid: (uuid) => apiClientFactory_1.apiClientV2.getRequest(`/wallets/${uuid}`).then(({ data }) => data),
|
|
19
19
|
addresses: {
|
|
20
|
-
create: ({ wallet_uuid, chain, label }) =>
|
|
20
|
+
create: ({ wallet_uuid, chain, label }) => apiClientFactory_1.apiClientV2
|
|
21
21
|
.postRequest(`/wallets/${wallet_uuid}/addresses/${chain}`, {
|
|
22
22
|
data: { label },
|
|
23
23
|
})
|
|
24
24
|
.then(({ data }) => data),
|
|
25
25
|
get: {
|
|
26
26
|
byWalletUuid: {
|
|
27
|
-
byChainId: (wallet_uuid, chain_id) =>
|
|
27
|
+
byChainId: (wallet_uuid, chain_id) => apiClientFactory_1.apiClientV2
|
|
28
28
|
.getRequest(`/wallets/${wallet_uuid}/addresses/${chain_id}`)
|
|
29
29
|
.then(({ data }) => data),
|
|
30
30
|
},
|
|
@@ -32,7 +32,7 @@ exports.wallets = {
|
|
|
32
32
|
},
|
|
33
33
|
transactions: {
|
|
34
34
|
getByWalletUuid: (wallet_uuid_1, ...args_1) => __awaiter(void 0, [wallet_uuid_1, ...args_1], void 0, function* (wallet_uuid, limit = constants_1.defaultPaginationParams.limit, offset = constants_1.defaultPaginationParams.offset) {
|
|
35
|
-
return
|
|
35
|
+
return apiClientFactory_1.apiClientV2
|
|
36
36
|
.getRequest(`/wallets/${wallet_uuid}/transactions`, {
|
|
37
37
|
params: { limit, offset },
|
|
38
38
|
})
|
|
@@ -10,4 +10,16 @@ export declare const createApiClient: ({ baseURL, isBearerToken, tenantId }: Cre
|
|
|
10
10
|
deleteRequest: (url: string, config?: AxiosRequestConfig) => Promise<AxiosResponse<any, any>>;
|
|
11
11
|
getRequest: <T>(url: string, config?: AxiosRequestConfig) => Promise<AxiosResponse<T>>;
|
|
12
12
|
};
|
|
13
|
+
export declare const apiClientV1: {
|
|
14
|
+
patchRequest: <T>(url: string, config?: AxiosRequestConfig) => Promise<AxiosResponse<T>>;
|
|
15
|
+
postRequest: <T>(url: string, config?: AxiosRequestConfig) => Promise<AxiosResponse<T>>;
|
|
16
|
+
deleteRequest: (url: string, config?: AxiosRequestConfig) => Promise<AxiosResponse<any, any>>;
|
|
17
|
+
getRequest: <T>(url: string, config?: AxiosRequestConfig) => Promise<AxiosResponse<T>>;
|
|
18
|
+
};
|
|
19
|
+
export declare const apiClientV2: {
|
|
20
|
+
patchRequest: <T>(url: string, config?: AxiosRequestConfig) => Promise<AxiosResponse<T>>;
|
|
21
|
+
postRequest: <T>(url: string, config?: AxiosRequestConfig) => Promise<AxiosResponse<T>>;
|
|
22
|
+
deleteRequest: (url: string, config?: AxiosRequestConfig) => Promise<AxiosResponse<any, any>>;
|
|
23
|
+
getRequest: <T>(url: string, config?: AxiosRequestConfig) => Promise<AxiosResponse<T>>;
|
|
24
|
+
};
|
|
13
25
|
export {};
|
|
@@ -22,8 +22,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
22
22
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
24
|
};
|
|
25
|
+
var _a, _b, _c;
|
|
25
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.createApiClient = void 0;
|
|
27
|
+
exports.apiClientV2 = exports.apiClientV1 = exports.createApiClient = void 0;
|
|
27
28
|
/* eslint-disable no-console */
|
|
28
29
|
const sdk_react_1 = require("@telegram-apps/sdk-react");
|
|
29
30
|
const axios_1 = __importDefault(require("axios"));
|
|
@@ -31,6 +32,10 @@ const auth_1 = require("../api/auth");
|
|
|
31
32
|
const constants_1 = require("../constants");
|
|
32
33
|
const storage_1 = require("../utils/storage");
|
|
33
34
|
const tokensFactory_1 = require("../utils/tokensFactory");
|
|
35
|
+
// eslint-disable-next-line no-constant-condition
|
|
36
|
+
const apiV1BaseURL = (_a = process.env.API_URL) !== null && _a !== void 0 ? _a : 'ENV variable API_URL is not defined';
|
|
37
|
+
const apiV2BaseURL = (_b = process.env.API_V2_URL) !== null && _b !== void 0 ? _b : 'ENV variable API_V2_URL is not defined';
|
|
38
|
+
const envTenantId = (_c = process.env.TENANT_ID) !== null && _c !== void 0 ? _c : 'ENV variable TENANT_ID is not defined';
|
|
34
39
|
const createApiClient = ({ baseURL, isBearerToken, tenantId }) => {
|
|
35
40
|
const instance = axios_1.default.create({
|
|
36
41
|
baseURL,
|
|
@@ -130,3 +135,12 @@ const createApiClient = ({ baseURL, isBearerToken, tenantId }) => {
|
|
|
130
135
|
return { patchRequest, postRequest, deleteRequest, getRequest };
|
|
131
136
|
};
|
|
132
137
|
exports.createApiClient = createApiClient;
|
|
138
|
+
exports.apiClientV1 = (0, exports.createApiClient)({
|
|
139
|
+
baseURL: apiV1BaseURL,
|
|
140
|
+
tenantId: envTenantId,
|
|
141
|
+
});
|
|
142
|
+
exports.apiClientV2 = (0, exports.createApiClient)({
|
|
143
|
+
baseURL: apiV2BaseURL,
|
|
144
|
+
isBearerToken: true,
|
|
145
|
+
tenantId: envTenantId,
|
|
146
|
+
});
|
package/package.json
CHANGED
package/src/api/auth.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { API } from './types';
|
|
2
2
|
|
|
3
|
-
import { apiClientV2 } from '
|
|
3
|
+
import { apiClientV2 } from '../utils/apiClientFactory';
|
|
4
4
|
|
|
5
5
|
export const telegramSignInPath = '/auth/sign-in/telegram';
|
|
6
6
|
export const telegramSignUpPath = '/auth/sign-up/telegram';
|
|
@@ -30,7 +30,7 @@ export const auth = {
|
|
|
30
30
|
apiClientV2.postRequest<API.Auth.Tokens>(telegramSignInPath, { data }),
|
|
31
31
|
password: (
|
|
32
32
|
email: string,
|
|
33
|
-
password: string
|
|
33
|
+
password: string // check on backend V2
|
|
34
34
|
) =>
|
|
35
35
|
apiClientV2.postRequest<API.Auth.SupabaseGetSessionResponse>('/auth/sign-in/password', {
|
|
36
36
|
data: { email, password },
|
package/src/api/developer.ts
CHANGED
package/src/api/exchange.ts
CHANGED
package/src/api/fiat_accounts.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { API } from './types';
|
|
2
2
|
|
|
3
|
-
import { apiClientV2, apiClientV1 } from '
|
|
3
|
+
import { apiClientV2, apiClientV1 } from '../utils/apiClientFactory';
|
|
4
4
|
|
|
5
5
|
export const fiat_accounts_v2 = {
|
|
6
6
|
list: {
|
|
@@ -20,7 +20,7 @@ export const fiat_accounts_v2 = {
|
|
|
20
20
|
|
|
21
21
|
getByUuid: ({ wallet_uuid, fiat_account_id }: API.FiatAccountsV2.ExtendedFiatAccount.Request) =>
|
|
22
22
|
apiClientV2.getRequest<API.FiatAccountsV2.ExtendedFiatAccount.Response>(
|
|
23
|
-
`/fiat-accounts/${wallet_uuid}/${fiat_account_id}
|
|
23
|
+
`/fiat-accounts/${wallet_uuid}/${fiat_account_id}`
|
|
24
24
|
),
|
|
25
25
|
create: ({ wallet_id, program_id }: API.FiatAccountsV2.CreateFiatAccount.Request) =>
|
|
26
26
|
apiClientV2.postRequest<API.FiatAccountsV2.CreateFiatAccount.Response>(`/fiat-accounts/${wallet_id}`, {
|
|
@@ -32,7 +32,7 @@ export const fiat_accounts_v2 = {
|
|
|
32
32
|
`/fiat-accounts/${wallet_uuid}/${fiat_account_id}/transactions`,
|
|
33
33
|
{
|
|
34
34
|
params: { limit, offset },
|
|
35
|
-
}
|
|
35
|
+
}
|
|
36
36
|
),
|
|
37
37
|
},
|
|
38
38
|
};
|
package/src/api/index.ts
CHANGED
|
@@ -1,16 +1,36 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { auth } from './auth';
|
|
2
|
+
import { developer } from './developer';
|
|
3
|
+
import { exchange } from './exchange';
|
|
4
|
+
import { fiat_accounts } from './fiat_accounts';
|
|
5
|
+
import { issuing } from './issuing';
|
|
6
|
+
import { kyc } from './kyc';
|
|
7
|
+
import { list } from './list';
|
|
8
|
+
import { orders } from './orders';
|
|
9
|
+
import { user } from './user';
|
|
10
|
+
import { wallets } from './wallets';
|
|
2
11
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
12
|
+
type Api = {
|
|
13
|
+
auth: typeof auth;
|
|
14
|
+
developer: typeof developer;
|
|
15
|
+
exchange: typeof exchange;
|
|
16
|
+
fiat_accounts: typeof fiat_accounts;
|
|
17
|
+
issuing: typeof issuing;
|
|
18
|
+
kyc: typeof kyc;
|
|
19
|
+
list: typeof list;
|
|
20
|
+
orders: typeof orders;
|
|
21
|
+
user: typeof user;
|
|
22
|
+
wallets: typeof wallets;
|
|
23
|
+
};
|
|
6
24
|
|
|
7
|
-
export const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
25
|
+
export const squarefiBffApiClient: Api = {
|
|
26
|
+
auth,
|
|
27
|
+
developer,
|
|
28
|
+
exchange,
|
|
29
|
+
fiat_accounts,
|
|
30
|
+
issuing,
|
|
31
|
+
kyc,
|
|
32
|
+
list,
|
|
33
|
+
orders,
|
|
34
|
+
user,
|
|
35
|
+
wallets,
|
|
36
|
+
};
|
package/src/api/issuing.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { AxiosResponse } from 'axios';
|
|
|
3
3
|
import { fiat_accounts } from './fiat_accounts';
|
|
4
4
|
import { API } from './types';
|
|
5
5
|
|
|
6
|
-
import { apiClientV1 } from '
|
|
6
|
+
import { apiClientV1 } from '../utils/apiClientFactory';
|
|
7
7
|
|
|
8
8
|
import { defaultPaginationParams } from '../constants';
|
|
9
9
|
|
package/src/api/kyc.ts
CHANGED
package/src/api/list.ts
CHANGED
package/src/api/orders.ts
CHANGED
package/src/api/user.ts
CHANGED
package/src/api/wallets.ts
CHANGED
|
@@ -10,6 +10,10 @@ import { deleteTokens, refreshTokens } from '../utils/tokensFactory';
|
|
|
10
10
|
|
|
11
11
|
// eslint-disable-next-line no-constant-condition
|
|
12
12
|
|
|
13
|
+
const apiV1BaseURL = process.env.API_URL ?? 'ENV variable API_URL is not defined';
|
|
14
|
+
const apiV2BaseURL = process.env.API_V2_URL ?? 'ENV variable API_V2_URL is not defined';
|
|
15
|
+
const envTenantId = process.env.TENANT_ID ?? 'ENV variable TENANT_ID is not defined';
|
|
16
|
+
|
|
13
17
|
type CreateApiClientOptions = {
|
|
14
18
|
baseURL: string;
|
|
15
19
|
tenantId: string;
|
|
@@ -152,3 +156,14 @@ export const createApiClient = ({ baseURL, isBearerToken, tenantId }: CreateApiC
|
|
|
152
156
|
|
|
153
157
|
return { patchRequest, postRequest, deleteRequest, getRequest };
|
|
154
158
|
};
|
|
159
|
+
|
|
160
|
+
export const apiClientV1 = createApiClient({
|
|
161
|
+
baseURL: apiV1BaseURL,
|
|
162
|
+
tenantId: envTenantId,
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
export const apiClientV2 = createApiClient({
|
|
166
|
+
baseURL: apiV2BaseURL,
|
|
167
|
+
isBearerToken: true,
|
|
168
|
+
tenantId: envTenantId,
|
|
169
|
+
});
|