squarefi-bff-api-module 1.0.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.
Files changed (58) hide show
  1. package/README.md +36 -0
  2. package/dist/api/auth.d.ts +27 -0
  3. package/dist/api/auth.js +38 -0
  4. package/dist/api/config.d.ts +37 -0
  5. package/dist/api/config.js +40 -0
  6. package/dist/api/developer.d.ts +12 -0
  7. package/dist/api/developer.js +15 -0
  8. package/dist/api/exchange.d.ts +35 -0
  9. package/dist/api/exchange.js +27 -0
  10. package/dist/api/fetch_api.d.ts +1 -0
  11. package/dist/api/fetch_api.js +122 -0
  12. package/dist/api/fiat_accounts.d.ts +32 -0
  13. package/dist/api/fiat_accounts.js +51 -0
  14. package/dist/api/index.d.ts +12 -0
  15. package/dist/api/index.js +17 -0
  16. package/dist/api/issuing.d.ts +31 -0
  17. package/dist/api/issuing.js +68 -0
  18. package/dist/api/kyc.d.ts +6 -0
  19. package/dist/api/kyc.js +9 -0
  20. package/dist/api/list.d.ts +10 -0
  21. package/dist/api/list.js +13 -0
  22. package/dist/api/orders.d.ts +12 -0
  23. package/dist/api/orders.js +34 -0
  24. package/dist/api/types.d.ts +945 -0
  25. package/dist/api/types.js +2 -0
  26. package/dist/api/user.d.ts +18 -0
  27. package/dist/api/user.js +21 -0
  28. package/dist/api/wallets.d.ts +18 -0
  29. package/dist/api/wallets.js +42 -0
  30. package/dist/constants.d.ts +149 -0
  31. package/dist/constants.js +172 -0
  32. package/dist/index.d.ts +5 -0
  33. package/dist/index.js +22 -0
  34. package/dist/utils/apiClientFactory.d.ts +13 -0
  35. package/dist/utils/apiClientFactory.js +132 -0
  36. package/dist/utils/storage.d.ts +3 -0
  37. package/dist/utils/storage.js +30 -0
  38. package/dist/utils/tokensFactory.d.ts +12 -0
  39. package/dist/utils/tokensFactory.js +53 -0
  40. package/package.json +35 -0
  41. package/src/api/auth.ts +50 -0
  42. package/src/api/developer.ts +18 -0
  43. package/src/api/exchange.ts +32 -0
  44. package/src/api/fiat_accounts.ts +69 -0
  45. package/src/api/index.ts +16 -0
  46. package/src/api/issuing.ts +66 -0
  47. package/src/api/kyc.ts +10 -0
  48. package/src/api/list.ts +18 -0
  49. package/src/api/orders.ts +32 -0
  50. package/src/api/types.ts +1141 -0
  51. package/src/api/user.ts +24 -0
  52. package/src/api/wallets.ts +39 -0
  53. package/src/constants.ts +180 -0
  54. package/src/index.ts +7 -0
  55. package/src/utils/apiClientFactory.ts +154 -0
  56. package/src/utils/storage.ts +29 -0
  57. package/src/utils/tokensFactory.ts +50 -0
  58. package/tsconfig.json +15 -0
package/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # Squarefi BFF API Module
2
+
3
+ A TypeScript/JavaScript client for interacting with the Squarefi BFF API.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install squarefi-bff-api-module
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import { createApiClient } from 'squarefi-bff-api-module';
15
+
16
+ const api = createApiClient({
17
+ baseURL: 'YOUR_API_BASE_URL',
18
+ tenantId: 'YOUR_TENANT_ID',
19
+ isBearerToken: true,
20
+ });
21
+
22
+ // Make API calls
23
+ const response = await api.getRequest('/some-endpoint');
24
+ ```
25
+
26
+ ## Features
27
+
28
+ - Full TypeScript support
29
+ - Axios-based HTTP client
30
+ - Token management
31
+ - Telegram integration support
32
+ - Comprehensive constants and types
33
+
34
+ ## License
35
+
36
+ MIT
@@ -0,0 +1,27 @@
1
+ import { API } from './types';
2
+ export declare const telegramSignInPath = "/auth/sign-in/telegram";
3
+ export declare const telegramSignUpPath = "/auth/sign-up/telegram";
4
+ export declare const refreshTokenPath = "/auth/refresh/refresh-token";
5
+ export declare const auth: {
6
+ otp: {
7
+ verify: {
8
+ email: (email: string, token: string) => Promise<import("axios").AxiosResponse<API.Auth.VerifyOtp.Response, any>>;
9
+ phone: (phone: string, token: string) => Promise<import("axios").AxiosResponse<API.Auth.VerifyOtp.Response, any>>;
10
+ };
11
+ };
12
+ signin: {
13
+ omni: {
14
+ email: (data: API.Auth.SignIn.Email.OTP.Request) => Promise<import("axios").AxiosResponse<unknown, any>>;
15
+ phone: (data: API.Auth.SignIn.Phone.OTP.Request) => Promise<import("axios").AxiosResponse<unknown, any>>;
16
+ };
17
+ telegram: (data: API.Auth.Telegram.Signin) => Promise<import("axios").AxiosResponse<API.Auth.Tokens, any>>;
18
+ password: (email: string, password: string) => Promise<import("axios").AxiosResponse<API.Auth.SupabaseGetSessionResponse, any>>;
19
+ };
20
+ signup: {
21
+ password: (email: string, password: string) => Promise<import("axios").AxiosResponse<API.Auth.SupabaseGetSessionResponse, any>>;
22
+ telegram: (data: API.Auth.Telegram.Signup) => Promise<import("axios").AxiosResponse<unknown, any>>;
23
+ };
24
+ refresh: {
25
+ refresh_token: (refresh_token: string) => Promise<import("axios").AxiosResponse<API.Auth.Tokens, any>>;
26
+ };
27
+ };
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.auth = exports.refreshTokenPath = exports.telegramSignUpPath = exports.telegramSignInPath = void 0;
4
+ const _1 = require(".");
5
+ exports.telegramSignInPath = '/auth/sign-in/telegram';
6
+ exports.telegramSignUpPath = '/auth/sign-up/telegram';
7
+ exports.refreshTokenPath = '/auth/refresh/refresh-token';
8
+ exports.auth = {
9
+ otp: {
10
+ verify: {
11
+ email: (email, token) => _1.apiClientV2.postRequest('/auth/verify/email/otp', {
12
+ data: { email, token, type: 'email' },
13
+ }),
14
+ phone: (phone, token) => _1.apiClientV2.postRequest('/auth/verify/phone/otp', {
15
+ data: { phone, token, type: 'sms' },
16
+ }),
17
+ },
18
+ },
19
+ signin: {
20
+ omni: {
21
+ email: (data) => _1.apiClientV2.postRequest('/auth/sign-in/omni/email/otp', { data }),
22
+ phone: (data) => _1.apiClientV2.postRequest('/auth/sign-in/omni/phone/otp', { data }),
23
+ },
24
+ telegram: (data) => _1.apiClientV2.postRequest(exports.telegramSignInPath, { data }),
25
+ password: (email, password) => _1.apiClientV2.postRequest('/auth/sign-in/password', {
26
+ data: { email, password },
27
+ }),
28
+ },
29
+ signup: {
30
+ password: (email, password) => _1.apiClientV2.postRequest('/auth/sign-up/password', {
31
+ data: { email, password },
32
+ }),
33
+ telegram: (data) => _1.apiClientV2.postRequest(exports.telegramSignUpPath, { data }),
34
+ },
35
+ refresh: {
36
+ refresh_token: (refresh_token) => _1.apiClientV2.postRequest(exports.refreshTokenPath, { data: { refresh_token } }),
37
+ },
38
+ };
@@ -0,0 +1,37 @@
1
+ export declare const baseURL: string;
2
+ export declare const tenantId: string | undefined;
3
+ export declare const pathnames: {
4
+ readonly auth: {
5
+ readonly me: "/auth/me";
6
+ readonly otp: {
7
+ readonly request: {
8
+ readonly email: "/auth/signin/email/otp";
9
+ readonly phone: "/auth/signin/phone/otp";
10
+ };
11
+ readonly verify: {
12
+ readonly email: "/auth/verify/email/otp";
13
+ readonly phone: "/auth/verify/phone/otp";
14
+ };
15
+ };
16
+ readonly signin: {
17
+ readonly password: {
18
+ readonly email: "/auth/signin/password/email";
19
+ readonly phone: "/auth/signin/password/phone";
20
+ };
21
+ };
22
+ readonly signup: {
23
+ readonly email: "/auth/signup/email";
24
+ readonly password: {
25
+ readonly email: "/auth/signup/password/email";
26
+ readonly phone: "/auth/signup/password/phone";
27
+ };
28
+ };
29
+ readonly refresh: {
30
+ readonly refresh_token: "/auth/refresh/refresh_token";
31
+ };
32
+ readonly user_data: {
33
+ readonly get: "/auth/user_data";
34
+ readonly update: "/auth/user_data";
35
+ };
36
+ };
37
+ };
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pathnames = exports.tenantId = exports.baseURL = void 0;
4
+ exports.baseURL = process.env.API_URL || '/api/';
5
+ exports.tenantId = process.env.TENANT_ID;
6
+ exports.pathnames = {
7
+ auth: {
8
+ me: '/auth/me',
9
+ otp: {
10
+ request: {
11
+ email: '/auth/signin/email/otp',
12
+ phone: '/auth/signin/phone/otp',
13
+ },
14
+ verify: {
15
+ email: '/auth/verify/email/otp',
16
+ phone: '/auth/verify/phone/otp',
17
+ },
18
+ },
19
+ signin: {
20
+ password: {
21
+ email: '/auth/signin/password/email',
22
+ phone: '/auth/signin/password/phone',
23
+ },
24
+ },
25
+ signup: {
26
+ email: '/auth/signup/email',
27
+ password: {
28
+ email: '/auth/signup/password/email',
29
+ phone: '/auth/signup/password/phone',
30
+ },
31
+ },
32
+ refresh: {
33
+ refresh_token: '/auth/refresh/refresh_token',
34
+ },
35
+ user_data: {
36
+ get: '/auth/user_data',
37
+ update: '/auth/user_data',
38
+ },
39
+ },
40
+ };
@@ -0,0 +1,12 @@
1
+ import { API } from './types';
2
+ export declare const developer: {
3
+ apiKeys: {
4
+ getAll: () => Promise<import("axios").AxiosResponse<API.Developer.ApiCode.ApiCode[], any>>;
5
+ create: (data: API.Developer.ApiCode.Create.Request) => Promise<import("axios").AxiosResponse<API.Developer.ApiCode.Create.Response, any>>;
6
+ rotate: (data: API.Developer.ApiCode.Rotate.Request) => Promise<import("axios").AxiosResponse<API.Developer.ApiCode.Rotate.Response, any>>;
7
+ update: (data: API.Developer.ApiCode.Update.Request) => Promise<import("axios").AxiosResponse<unknown, any>>;
8
+ };
9
+ vendors: {
10
+ list: () => Promise<import("axios").AxiosResponse<API.Developer.Vendors.Vendor[], any>>;
11
+ };
12
+ };
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.developer = void 0;
4
+ const _1 = require(".");
5
+ exports.developer = {
6
+ apiKeys: {
7
+ getAll: () => _1.apiClientV1.getRequest('/developer/access/list'),
8
+ create: (data) => _1.apiClientV1.postRequest('/developer/access/create', { data }),
9
+ rotate: (data) => _1.apiClientV1.postRequest(`/developer/access/rotate`, { data }),
10
+ update: (data) => _1.apiClientV1.postRequest(`/developer/access/update`, { data }),
11
+ },
12
+ vendors: {
13
+ list: () => _1.apiClientV1.getRequest('/developer/vendors/list'),
14
+ },
15
+ };
@@ -0,0 +1,35 @@
1
+ import { API } from './types';
2
+ export declare const exchange: {
3
+ byOrderType: {
4
+ DEPOSIT_FIAT_SEPA: {
5
+ getByFromCurrency: (from_uuid: string) => Promise<API.Exchange.Exchange[]>;
6
+ getByToCurrency: (to_uuid: string) => Promise<API.Exchange.Exchange[]>;
7
+ getByOrderType: () => Promise<API.Exchange.Exchange[]>;
8
+ };
9
+ DEPOSIT_FIAT_SWIFT: {
10
+ getByFromCurrency: (from_uuid: string) => Promise<API.Exchange.Exchange[]>;
11
+ getByToCurrency: (to_uuid: string) => Promise<API.Exchange.Exchange[]>;
12
+ getByOrderType: () => Promise<API.Exchange.Exchange[]>;
13
+ };
14
+ WITHDRAWAL_FIAT_SEPA: {
15
+ getByFromCurrency: (from_uuid: string) => Promise<API.Exchange.Exchange[]>;
16
+ getByToCurrency: (to_uuid: string) => Promise<API.Exchange.Exchange[]>;
17
+ getByOrderType: () => Promise<API.Exchange.Exchange[]>;
18
+ };
19
+ TRANSFER_CARD_SUBACCOUNT: {
20
+ getByFromCurrency: (from_uuid: string) => Promise<API.Exchange.Exchange[]>;
21
+ getByToCurrency: (to_uuid: string) => Promise<API.Exchange.Exchange[]>;
22
+ getByOrderType: () => Promise<API.Exchange.Exchange[]>;
23
+ };
24
+ WITHDRAWAL_CRYPTO: {
25
+ getByFromCurrency: (from_uuid: string) => Promise<API.Exchange.Exchange[]>;
26
+ getByToCurrency: (to_uuid: string) => Promise<API.Exchange.Exchange[]>;
27
+ getByOrderType: () => Promise<API.Exchange.Exchange[]>;
28
+ };
29
+ EXCHANGE_CRYPTO_INTERNAL: {
30
+ getByFromCurrency: (from_uuid: string) => Promise<API.Exchange.Exchange[]>;
31
+ getByToCurrency: (to_uuid: string) => Promise<API.Exchange.Exchange[]>;
32
+ getByOrderType: () => Promise<API.Exchange.Exchange[]>;
33
+ };
34
+ };
35
+ };
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.exchange = void 0;
4
+ const _1 = require(".");
5
+ const constants_1 = require("../constants");
6
+ const createOrderTypeMethods = (orderType) => ({
7
+ getByFromCurrency: (from_uuid) => _1.apiClientV1
8
+ .getRequest('/exchange/', { params: { from_uuid, order_type: orderType } })
9
+ .then(({ data }) => data),
10
+ getByToCurrency: (to_uuid) => _1.apiClientV1
11
+ .getRequest('/exchange/', { params: { to_uuid, order_type: orderType } })
12
+ .then(({ data }) => data),
13
+ getByOrderType: () => _1.apiClientV1
14
+ .getRequest('/exchange/', { params: { order_type: orderType } })
15
+ .then(({ data }) => data),
16
+ });
17
+ exports.exchange = {
18
+ byOrderType: {
19
+ [constants_1.OrderType.DEPOSIT_FIAT_SEPA]: createOrderTypeMethods(constants_1.OrderType.DEPOSIT_FIAT_SEPA),
20
+ [constants_1.OrderType.DEPOSIT_FIAT_SWIFT]: createOrderTypeMethods(constants_1.OrderType.DEPOSIT_FIAT_SWIFT),
21
+ [constants_1.OrderType.WITHDRAWAL_FIAT_SEPA]: createOrderTypeMethods(constants_1.OrderType.WITHDRAWAL_FIAT_SEPA),
22
+ // [OrderType.TRANSFER_CARD_PREPAID]: createOrderTypeMethods(OrderType.TRANSFER_CARD_PREPAID), // DO not used
23
+ [constants_1.OrderType.TRANSFER_CARD_SUBACCOUNT]: createOrderTypeMethods(constants_1.OrderType.TRANSFER_CARD_SUBACCOUNT),
24
+ [constants_1.OrderType.WITHDRAWAL_CRYPTO]: createOrderTypeMethods(constants_1.OrderType.WITHDRAWAL_CRYPTO),
25
+ [constants_1.OrderType.EXCHANGE_CRYPTO_INTERNAL]: createOrderTypeMethods(constants_1.OrderType.EXCHANGE_CRYPTO_INTERNAL),
26
+ },
27
+ };
@@ -0,0 +1 @@
1
+ export declare const test = 123;
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ // // import { toast } from 'react-toastify';
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.test = void 0;
5
+ // import { auth } from './auth';
6
+ // import { baseURL, pathnames, tenantId } from './config';
7
+ // import { RequestConfig, RequestMethods, RequestOptions, RequestQueueItem } from './types';
8
+ // import { getAuthCookie } from '@/actions/auth.action';
9
+ // import { handleLogout } from '@/actions/redirect.action';
10
+ // import { ResponseStatus } from '@/constants';
11
+ // import { deleteTokens, refreshTokens, setTokens } from '@/helpers/serverTokensFactory';
12
+ // const logLevel = 'debug';
13
+ // let isTokenRefreshing = false;
14
+ // let requestQueue: RequestQueueItem[] = [];
15
+ // const createRequestHandler = (method: RequestMethods) => {
16
+ // const requestHandler = async <T>(url: string, requestConfig?: RequestConfig): Promise<T> => {
17
+ // const { headers, data } = requestConfig || {};
18
+ // const { access_token, refresh_token } = await getAuthCookie();
19
+ // const options: RequestOptions = {
20
+ // method,
21
+ // headers: {
22
+ // 'Content-Type': 'application/json',
23
+ // 'X-Tenant-Id': tenantId,
24
+ // ...headers,
25
+ // },
26
+ // body: data ? JSON.stringify(data) : undefined,
27
+ // };
28
+ // if (access_token) {
29
+ // options.headers = {
30
+ // ...options.headers,
31
+ // Authorization: access_token,
32
+ // };
33
+ // }
34
+ // const urlSearchParams = new URLSearchParams(requestConfig?.params);
35
+ // const requestUrl = new URL(`${baseURL}${url}?${urlSearchParams}`);
36
+ // if (logLevel === 'debug') {
37
+ // const requestLog = `[fetch][request] ${requestUrl}`;
38
+ // // eslint-disable-next-line no-console
39
+ // console.debug(requestLog);
40
+ // }
41
+ // const response = await fetch(requestUrl, options);
42
+ // const isError = !response.ok;
43
+ // const { status: responseStatus } = response;
44
+ // const currentTime = new Date().getMilliseconds();
45
+ // const requestSendTime = new Date(response.headers.get('date') || currentTime).getMilliseconds();
46
+ // const requestTime = (currentTime - requestSendTime) / 1000;
47
+ // const responseLog = `[fetch][${
48
+ // isError ? 'error' : 'response'
49
+ // }] ${method} ${responseStatus} ${requestUrl} +${requestTime}s`;
50
+ // if (logLevel === 'debug') {
51
+ // // eslint-disable-next-line no-console
52
+ // console.debug(responseLog);
53
+ // }
54
+ // if (isError) {
55
+ // if (response?.status === ResponseStatus.UNAUTHORIZED && access_token && typeof window !== 'undefined') {
56
+ // const isRefreshTokenRequest = url === pathnames.auth.refresh.refresh_token;
57
+ // const isRefreshAvailable = !isTokenRefreshing && refresh_token;
58
+ // const isLogoutNeccesary = !isRefreshAvailable || isRefreshTokenRequest;
59
+ // if (isLogoutNeccesary) {
60
+ // await deleteTokens();
61
+ // requestQueue.forEach((request) => request.reject());
62
+ // requestQueue = [];
63
+ // handleLogout();
64
+ // return Promise.reject(response);
65
+ // }
66
+ // if (isRefreshAvailable) {
67
+ // refreshTokens(refresh_token).then((tokens) => {
68
+ // setTokens(tokens); // todo set clients/server cookies
69
+ // requestQueue.forEach((request) => request.resolve());
70
+ // requestQueue = [];
71
+ // isTokenRefreshing = false;
72
+ // });
73
+ // }
74
+ // return new Promise((res, rej) => {
75
+ // requestQueue.push({
76
+ // resolve: () => res(requestHandler(url, requestConfig)),
77
+ // reject: () => rej(requestHandler(url, requestConfig)),
78
+ // });
79
+ // });
80
+ // }
81
+ // try {
82
+ // const errorData = await response.text();
83
+ // let parsedError;
84
+ // try {
85
+ // parsedError = JSON.parse(errorData);
86
+ // } catch {
87
+ // // Extract error message from HTML if it contains <!DOCTYPE html>
88
+ // if (errorData.includes('<!DOCTYPE html>')) {
89
+ // const messageMatch = errorData.match(/<pre>([^<]+)<\/pre>/);
90
+ // const extractedMessage = messageMatch ? messageMatch[1] : null;
91
+ // parsedError = {
92
+ // status: response.status,
93
+ // message: extractedMessage || response.statusText || 'Unknown error occurred',
94
+ // };
95
+ // } else {
96
+ // // If not HTML, use raw text as message
97
+ // parsedError = {
98
+ // status: response.status,
99
+ // message: errorData || response.statusText || 'Unknown error occurred',
100
+ // };
101
+ // }
102
+ // }
103
+ // return Promise.reject(parsedError);
104
+ // } catch (error) {
105
+ // // If we can't even read the response text, return a basic error
106
+ // const basicError = new Error('Failed to read error response');
107
+ // basicError.cause = response.status;
108
+ // basicError.message = response.statusText || 'Failed to read error response';
109
+ // return Promise.reject(basicError);
110
+ // }
111
+ // }
112
+ // const responseData = await response.json();
113
+ // return responseData;
114
+ // };
115
+ // return requestHandler;
116
+ // };
117
+ // export const getRequest = createRequestHandler('GET');
118
+ // export const deleteRequest = createRequestHandler('DELETE');
119
+ // export const patchRequest = createRequestHandler('PATCH');
120
+ // export const postRequest = createRequestHandler('POST');
121
+ // export { auth };
122
+ exports.test = 123;
@@ -0,0 +1,32 @@
1
+ import { API } from './types';
2
+ export declare const fiat_accounts_v2: {
3
+ list: {
4
+ withCards: {
5
+ getAll: (wallet_uuid: string, limit: number, offset: number) => Promise<import("axios").AxiosResponse<API.FiatAccountsV2.FiatAccountsListWithCards, any>>;
6
+ };
7
+ withoutCards: {
8
+ getAll: (wallet_uuid: string, limit: number, offset: number) => Promise<import("axios").AxiosResponse<API.FiatAccountsV2.FiatAccountsListWithoutCards, any>>;
9
+ };
10
+ };
11
+ getByUuid: ({ wallet_uuid, fiat_account_id }: API.FiatAccountsV2.ExtendedFiatAccount.Request) => Promise<import("axios").AxiosResponse<API.FiatAccountsV2.ExtendedFiatAccount.ExtendedFiatAccount, any>>;
12
+ create: ({ wallet_id, program_id }: API.FiatAccountsV2.CreateFiatAccount.Request) => Promise<import("axios").AxiosResponse<API.FiatAccountsV2.CreateFiatAccount.Response, any>>;
13
+ transactions: {
14
+ get: ({ fiat_account_id, wallet_uuid, limit, offset }: API.FiatAccountsV2.Transactions.TransactionList.Request) => Promise<import("axios").AxiosResponse<API.FiatAccountsV2.Transactions.TransactionList.Response, any>>;
15
+ };
16
+ };
17
+ export declare const fiat_accounts: {
18
+ list: {
19
+ withCards: {
20
+ getSinglecards: (wallet_uuid: string, limit: number, offset: number) => Promise<import("axios").AxiosResponse<API.FiatAccounts.FiatAccountWithCards[], any>>;
21
+ getAll: (wallet_uuid: string, limit: number, offset: number) => Promise<import("axios").AxiosResponse<API.FiatAccounts.FiatAccountWithCards[], any>>;
22
+ };
23
+ withoutCards: {
24
+ getAll: (wallet_uuid: string, limit: number, offset: number) => Promise<import("axios").AxiosResponse<API.FiatAccounts.FiatAccount[], any>>;
25
+ };
26
+ };
27
+ getByUuid: (uuid: string) => Promise<import("axios").AxiosResponse<API.FiatAccounts.FiatAccount, any>>;
28
+ create: (wallet_id: string, program_id: string) => Promise<import("axios").AxiosResponse<API.FiatAccounts.FiatAccount, any>>;
29
+ transactions: {
30
+ get: (fiat_account_id: string, limit?: number, offset?: number) => Promise<import("axios").AxiosResponse<API.FiatAccounts.TransactionList, any>>;
31
+ };
32
+ };
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fiat_accounts = exports.fiat_accounts_v2 = void 0;
4
+ const _1 = require(".");
5
+ exports.fiat_accounts_v2 = {
6
+ list: {
7
+ withCards: {
8
+ getAll: (wallet_uuid, limit, offset) => _1.apiClientV2.getRequest(`/fiat-accounts/${wallet_uuid}`, {
9
+ params: { limit, offset, show_cards: true },
10
+ }),
11
+ },
12
+ withoutCards: {
13
+ getAll: (wallet_uuid, limit, offset) => _1.apiClientV2.getRequest(`/fiat-accounts/${wallet_uuid}`, {
14
+ params: { limit, offset },
15
+ }),
16
+ },
17
+ },
18
+ getByUuid: ({ wallet_uuid, fiat_account_id }) => _1.apiClientV2.getRequest(`/fiat-accounts/${wallet_uuid}/${fiat_account_id}`),
19
+ create: ({ wallet_id, program_id }) => _1.apiClientV2.postRequest(`/fiat-accounts/${wallet_id}`, {
20
+ data: { program_id },
21
+ }),
22
+ transactions: {
23
+ get: ({ fiat_account_id, wallet_uuid, limit, offset }) => _1.apiClientV2.getRequest(`/fiat-accounts/${wallet_uuid}/${fiat_account_id}/transactions`, {
24
+ params: { limit, offset },
25
+ }),
26
+ },
27
+ };
28
+ exports.fiat_accounts = {
29
+ list: {
30
+ withCards: {
31
+ getSinglecards: (wallet_uuid, limit, offset) => _1.apiClientV1.getRequest(`/fiat_accounts/list/${wallet_uuid}`, {
32
+ params: { limit, offset, lt_cards_limit: 2, gt_cards_limit: 0, show_cards: true },
33
+ }),
34
+ getAll: (wallet_uuid, limit, offset) => _1.apiClientV1.getRequest(`/fiat_accounts/list/${wallet_uuid}`, {
35
+ params: { limit, offset, show_cards: true },
36
+ }),
37
+ },
38
+ withoutCards: {
39
+ getAll: (wallet_uuid, limit, offset) => _1.apiClientV1.getRequest(`/fiat_accounts/list/${wallet_uuid}`, {
40
+ params: { limit, offset },
41
+ }),
42
+ },
43
+ },
44
+ getByUuid: (uuid) => _1.apiClientV1.getRequest(`/fiat_accounts/${uuid}`),
45
+ create: (wallet_id, program_id) => _1.apiClientV1.postRequest(`/fiat_accounts`, { data: { wallet_id, program_id } }),
46
+ transactions: {
47
+ get: (fiat_account_id, limit, offset) => _1.apiClientV1.getRequest(`/fiat_accounts/${fiat_account_id}/transactions`, {
48
+ params: { limit, offset },
49
+ }),
50
+ },
51
+ };
@@ -0,0 +1,12 @@
1
+ export declare const apiClientV1: {
2
+ patchRequest: <T>(url: string, config?: import("axios").AxiosRequestConfig) => Promise<import("axios").AxiosResponse<T>>;
3
+ postRequest: <T>(url: string, config?: import("axios").AxiosRequestConfig) => Promise<import("axios").AxiosResponse<T>>;
4
+ deleteRequest: (url: string, config?: import("axios").AxiosRequestConfig) => Promise<import("axios").AxiosResponse<any, any>>;
5
+ getRequest: <T>(url: string, config?: import("axios").AxiosRequestConfig) => Promise<import("axios").AxiosResponse<T>>;
6
+ };
7
+ export declare const apiClientV2: {
8
+ patchRequest: <T>(url: string, config?: import("axios").AxiosRequestConfig) => Promise<import("axios").AxiosResponse<T>>;
9
+ postRequest: <T>(url: string, config?: import("axios").AxiosRequestConfig) => Promise<import("axios").AxiosResponse<T>>;
10
+ deleteRequest: (url: string, config?: import("axios").AxiosRequestConfig) => Promise<import("axios").AxiosResponse<any, any>>;
11
+ getRequest: <T>(url: string, config?: import("axios").AxiosRequestConfig) => Promise<import("axios").AxiosResponse<T>>;
12
+ };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var _a, _b, _c;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.apiClientV2 = exports.apiClientV1 = void 0;
5
+ const apiClientFactory_1 = require("../utils/apiClientFactory");
6
+ const apiV1BaseURL = (_a = process.env.API_URL) !== null && _a !== void 0 ? _a : 'ENV variable API_URL is not defined';
7
+ const apiV2BaseURL = (_b = process.env.API_V2_URL) !== null && _b !== void 0 ? _b : 'ENV variable API_V2_URL is not defined';
8
+ const envTenantId = (_c = process.env.TENANT_ID) !== null && _c !== void 0 ? _c : 'ENV variable TENANT_ID is not defined';
9
+ exports.apiClientV1 = (0, apiClientFactory_1.createApiClient)({
10
+ baseURL: apiV1BaseURL,
11
+ tenantId: envTenantId,
12
+ });
13
+ exports.apiClientV2 = (0, apiClientFactory_1.createApiClient)({
14
+ baseURL: apiV2BaseURL,
15
+ isBearerToken: true,
16
+ tenantId: envTenantId,
17
+ });
@@ -0,0 +1,31 @@
1
+ import { AxiosResponse } from 'axios';
2
+ import { API } from './types';
3
+ export declare const issuing: {
4
+ cards: {
5
+ create: {
6
+ standAloneCard: (data: API.Cards.Create.StandAloneRequest) => Promise<AxiosResponse<API.Cards.CardDetailItem, any>>;
7
+ fiatAccountCard: (data: API.Cards.Create.FiatAccountRequest) => Promise<AxiosResponse<API.Cards.CardDetailItem, any>>;
8
+ };
9
+ getByWalletUuid: (params: API.Cards.CardsList.Request.ByWalletUuid) => Promise<AxiosResponse<API.Cards.CardsList.Response, any>>;
10
+ getByFiatAccountAndWalletId: (params: API.Cards.CardsList.Request.ByFiatAccountAndWalletId) => Promise<AxiosResponse<API.Cards.CardsList.Response, any>>;
11
+ getById: (card_id: string) => Promise<AxiosResponse<API.Cards.CardDetailItem, any>>;
12
+ sensitiveData: {
13
+ get: (card_id: string) => Promise<AxiosResponse<API.Cards.SensitiveData, any>>;
14
+ otp: {
15
+ get: (card_id: string) => Promise<AxiosResponse<API.Cards.OTP, any>>;
16
+ };
17
+ };
18
+ close: (card_id: string) => Promise<AxiosResponse<any, any>>;
19
+ freeze: (card_id: string) => Promise<AxiosResponse<API.Cards.CardDetailItem, any>>;
20
+ unfreeze: (card_id: string) => Promise<AxiosResponse<API.Cards.CardDetailItem, any>>;
21
+ };
22
+ transactions: {
23
+ getByCardId: (card_id: string, limit?: number, offset?: number) => Promise<AxiosResponse<API.Cards.TransactionsList, any>>;
24
+ getByFiatAccountId: (fiat_account_id: string, limit?: number, offset?: number) => Promise<AxiosResponse<API.Cards.TransactionsList, any>>;
25
+ };
26
+ config: {
27
+ programs: {
28
+ getAll: () => Promise<API.Issuing.Programs.Response>;
29
+ };
30
+ };
31
+ };
@@ -0,0 +1,68 @@
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 __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.issuing = void 0;
24
+ const fiat_accounts_1 = require("./fiat_accounts");
25
+ const _1 = require(".");
26
+ const constants_1 = require("../constants");
27
+ exports.issuing = {
28
+ cards: {
29
+ create: {
30
+ standAloneCard: (data) => _1.apiClientV1.postRequest('/issuing/cards/create', { data }),
31
+ fiatAccountCard: (data) => _1.apiClientV1.postRequest('/issuing/cards/balance', { data }),
32
+ },
33
+ getByWalletUuid: (params) => _1.apiClientV1.getRequest('/issuing/cards', { params }),
34
+ getByFiatAccountAndWalletId: (params) => _1.apiClientV1.getRequest('/issuing/cards', { params }),
35
+ getById: (card_id) => __awaiter(void 0, void 0, void 0, function* () {
36
+ const _a = yield _1.apiClientV1.getRequest(`/issuing/cards/${card_id}`), { data: card } = _a, rest = __rest(_a, ["data"]);
37
+ const { data: fiatAccountData } = yield fiat_accounts_1.fiat_accounts.getByUuid(card.fiat_account.id);
38
+ // const { data: fiatAccountData } = await fiat_accounts.getByUuid({ V2 API FIAT ACCOUNTS
39
+ // wallet_uuid: card.fiat_account.wallet_id,
40
+ // fiat_account_id: card.fiat_account.id,
41
+ // });
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
+ }),
44
+ sensitiveData: {
45
+ get: (card_id) => _1.apiClientV1.getRequest(`/issuing/cards/${card_id}/sensitive`),
46
+ otp: {
47
+ // have to update
48
+ get: (card_id) => _1.apiClientV1.getRequest(`/vcards/cards/${card_id}/sensitive/otp`),
49
+ },
50
+ },
51
+ close: (card_id) => _1.apiClientV1.deleteRequest(`/issuing/cards/${card_id}`),
52
+ freeze: (card_id) => _1.apiClientV1.patchRequest(`/issuing/cards/${card_id}/freeze`),
53
+ unfreeze: (card_id) => _1.apiClientV1.patchRequest(`/issuing/cards/${card_id}/unfreeze`),
54
+ },
55
+ transactions: {
56
+ getByCardId: (card_id, limit = constants_1.defaultPaginationParams.limit, offset = constants_1.defaultPaginationParams.offset) => _1.apiClientV1.getRequest(`/issuing/transactions/`, {
57
+ params: { limit, offset, card_id, new_scheme: true },
58
+ }),
59
+ getByFiatAccountId: (fiat_account_id, limit = constants_1.defaultPaginationParams.limit, offset = constants_1.defaultPaginationParams.offset) => _1.apiClientV1.getRequest(`/issuing/transactions/`, {
60
+ params: { limit, offset, fiat_account_id, new_scheme: true },
61
+ }),
62
+ },
63
+ config: {
64
+ programs: {
65
+ getAll: () => _1.apiClientV1.getRequest('/issuing/config/programs').then(({ data }) => data),
66
+ },
67
+ },
68
+ };
@@ -0,0 +1,6 @@
1
+ import { API } from './types';
2
+ export declare const kyc: {
3
+ sumsub: {
4
+ generate_token: (data: API.KYC.Sumsub.GenerateToken.Request) => Promise<import("axios").AxiosResponse<API.KYC.Sumsub.GenerateToken.Response, any>>;
5
+ };
6
+ };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.kyc = void 0;
4
+ const _1 = require(".");
5
+ exports.kyc = {
6
+ sumsub: {
7
+ generate_token: (data) => _1.apiClientV1.postRequest('/kyc/sumsub/generate_token', { data }),
8
+ },
9
+ };
@@ -0,0 +1,10 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import { API } from './types';
3
+ export declare const list: {
4
+ currencies: {
5
+ getAll: (params?: AxiosRequestConfig) => Promise<API.Currencies.CurrencyList>;
6
+ };
7
+ chains: {
8
+ getAll: (params?: AxiosRequestConfig) => Promise<API.Chains.ChainList>;
9
+ };
10
+ };