squarefi-bff-api-module 1.36.31 → 1.36.33
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/bank-data.d.ts +4 -1
- package/dist/api/bank-data.js +4 -6
- package/dist/api/frontend.d.ts +10 -0
- package/dist/api/frontend.js +17 -1
- package/dist/api/orders.d.ts +0 -1
- package/dist/api/orders.js +0 -1
- package/dist/api/types/autogen/apiV1External.types.d.ts +288 -244
- package/dist/api/types/autogen/apiV1Frontend.types.d.ts +1132 -847
- package/dist/api/types/autogen/apiV1Legacy.types.d.ts +104 -1062
- package/dist/api/types/autogen/apiV1Tenant.types.d.ts +88 -225
- package/dist/api/types/autogen/apiV2.types.d.ts +382 -86
- package/dist/api/types/types.d.ts +61 -5
- package/dist/api/user.d.ts +4 -0
- package/dist/api/user.js +10 -0
- package/dist/constants.d.ts +7 -0
- package/dist/constants.js +8 -0
- package/dist/utils/apiClientFactory.js +11 -1
- package/dist/utils/tokensFactory.d.ts +10 -0
- package/dist/utils/tokensFactory.js +25 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { APIKeyRole, CardFormFactor, CardTransactionType, CardType, CurrencyType, IssuingProgramStatus, OrderType, SortingDirection, SubAccountType } from '../../constants';
|
|
1
|
+
import { APIKeyRole, CardFormFactor, CardTransactionType, CardType, CurrencyType, IssuingProgramStatus, OrderStatuses, OrderType, SortingDirection, SubAccountType } from '../../constants';
|
|
2
2
|
import { components, operations, paths } from './autogen/apiV2.types';
|
|
3
3
|
import { components as componentsV1Frontend, paths as pathsV1Frontend } from './autogen/apiV1Frontend.types';
|
|
4
4
|
import { paths as pathsV1Legacy } from './autogen/apiV1Legacy.types';
|
|
@@ -81,6 +81,12 @@ export declare namespace API {
|
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
+
namespace BankData {
|
|
85
|
+
namespace GetByCode {
|
|
86
|
+
type Request = pathsV1Frontend['/frontend/bank-data']['get']['parameters']['query'];
|
|
87
|
+
type Response = pathsV1Frontend['/frontend/bank-data']['get']['responses'][200]['content']['application/json'];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
84
90
|
namespace Cards {
|
|
85
91
|
namespace Config {
|
|
86
92
|
type IssuingProgramOrderType = {
|
|
@@ -664,6 +670,50 @@ export declare namespace API {
|
|
|
664
670
|
}
|
|
665
671
|
}
|
|
666
672
|
}
|
|
673
|
+
namespace Issuing {
|
|
674
|
+
type CardDepositRoot = pathsV1Frontend['/frontend/issuing/cards/{card_id}/deposit'];
|
|
675
|
+
type CardWithdrawRoot = pathsV1Frontend['/frontend/issuing/cards/{card_id}/withdraw'];
|
|
676
|
+
type SubAccountDepositRoot = pathsV1Frontend['/frontend/issuing/sub-accounts/{sub_account_id}/deposit'];
|
|
677
|
+
type SubAccountWithdrawRoot = pathsV1Frontend['/frontend/issuing/sub-accounts/{sub_account_id}/withdraw'];
|
|
678
|
+
type WithOrderStatus<T extends {
|
|
679
|
+
data?: {
|
|
680
|
+
status?: string;
|
|
681
|
+
};
|
|
682
|
+
}> = Omit<T, 'data'> & {
|
|
683
|
+
data?: Omit<NonNullable<T['data']>, 'status'> & {
|
|
684
|
+
status?: `${OrderStatuses}`;
|
|
685
|
+
};
|
|
686
|
+
};
|
|
687
|
+
export namespace SubAccounts {
|
|
688
|
+
namespace Deposit {
|
|
689
|
+
type Request = {
|
|
690
|
+
sub_account_id: string;
|
|
691
|
+
} & SubAccountDepositRoot['post']['requestBody']['content']['application/json'];
|
|
692
|
+
type Response = WithOrderStatus<SubAccountDepositRoot['post']['responses']['200']['content']['application/json']>;
|
|
693
|
+
}
|
|
694
|
+
namespace Withdraw {
|
|
695
|
+
type Request = {
|
|
696
|
+
sub_account_id: string;
|
|
697
|
+
} & SubAccountWithdrawRoot['post']['requestBody']['content']['application/json'];
|
|
698
|
+
type Response = WithOrderStatus<SubAccountWithdrawRoot['post']['responses']['200']['content']['application/json']>;
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
export namespace Cards {
|
|
702
|
+
namespace Deposit {
|
|
703
|
+
type Request = {
|
|
704
|
+
card_id: string;
|
|
705
|
+
} & CardDepositRoot['post']['requestBody']['content']['application/json'];
|
|
706
|
+
type Response = SubAccounts.Deposit.Response;
|
|
707
|
+
}
|
|
708
|
+
namespace Withdraw {
|
|
709
|
+
type Request = {
|
|
710
|
+
card_id: string;
|
|
711
|
+
} & CardWithdrawRoot['post']['requestBody']['content']['application/json'];
|
|
712
|
+
type Response = SubAccounts.Withdraw.Response;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
export {};
|
|
716
|
+
}
|
|
667
717
|
}
|
|
668
718
|
namespace Issuing {
|
|
669
719
|
namespace Programs {
|
|
@@ -1799,10 +1849,6 @@ export declare namespace API {
|
|
|
1799
1849
|
type Request = componentsV1Frontend['schemas']['FrontendL2FOrderRequest'];
|
|
1800
1850
|
type Response = OrderEnvelope;
|
|
1801
1851
|
}
|
|
1802
|
-
namespace Card {
|
|
1803
|
-
type Request = pathsV1Frontend['/frontend/orders/withdrawal/card']['post']['requestBody']['content']['application/json'];
|
|
1804
|
-
type Response = OrderEnvelope;
|
|
1805
|
-
}
|
|
1806
1852
|
}
|
|
1807
1853
|
namespace Exchange {
|
|
1808
1854
|
type Request = componentsV1Frontend['schemas']['FrontendExchangeOrderRequest'];
|
|
@@ -2270,6 +2316,16 @@ export declare namespace API {
|
|
|
2270
2316
|
type Response = operations['UserController_updateMyUserData']['responses']['200']['content']['application/json'];
|
|
2271
2317
|
}
|
|
2272
2318
|
}
|
|
2319
|
+
namespace Verification {
|
|
2320
|
+
type Flow = components['schemas']['UserVerificationFlow'];
|
|
2321
|
+
namespace Init {
|
|
2322
|
+
type Request = operations['UserVerificationController_init']['requestBody']['content']['application/json'];
|
|
2323
|
+
type Response = operations['UserVerificationController_init']['responses']['200']['content']['application/json'];
|
|
2324
|
+
}
|
|
2325
|
+
namespace Resume {
|
|
2326
|
+
type Response = operations['UserVerificationController_resume']['responses']['200']['content']['application/json'];
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2273
2329
|
}
|
|
2274
2330
|
namespace Wallets {
|
|
2275
2331
|
export interface SimplifiedWallet {
|
package/dist/api/user.d.ts
CHANGED
|
@@ -7,6 +7,10 @@ export declare const user: {
|
|
|
7
7
|
get: (options?: GetUserDataOptions) => Promise<API.User.UserData.Get.Response>;
|
|
8
8
|
update: (data: API.User.UserData.Update.Request) => Promise<API.User.UserData.Update.Response>;
|
|
9
9
|
};
|
|
10
|
+
verification: {
|
|
11
|
+
init: (data: API.User.Verification.Init.Request) => Promise<API.User.Verification.Init.Response>;
|
|
12
|
+
resume: () => Promise<API.User.Verification.Resume.Response>;
|
|
13
|
+
};
|
|
10
14
|
update: {
|
|
11
15
|
phone: {
|
|
12
16
|
request: (data: API.User.UpdateUser.Phone.RequestOTP.Request) => Promise<void>;
|
package/dist/api/user.js
CHANGED
|
@@ -4,6 +4,16 @@ export const user = {
|
|
|
4
4
|
get: (options) => apiClientV2.getRequest('/user/user-data', options?.bypassUnauthorizedHandler ? { context: { bypassUnauthorizedHandler: true } } : undefined),
|
|
5
5
|
update: (data) => apiClientV2.patchRequest('/user/user-data', { data }),
|
|
6
6
|
},
|
|
7
|
+
verification: {
|
|
8
|
+
// Starts (or moves up) the per-user Sumsub level for the requested step and returns the WebSDK
|
|
9
|
+
// credentials. Resolves 404 when the tenant has no level configured for the step. Step results
|
|
10
|
+
// land on user-data (`identity_verification_status` / `face_verification_status`), so poll
|
|
11
|
+
// `user.userData.get()` after the WebSDK reports completion.
|
|
12
|
+
init: (data) => apiClientV2.postRequest('/user/verification/init', { data }),
|
|
13
|
+
// Re-issues the WebSDK access token for the level the user is already on; 404 when the user has
|
|
14
|
+
// never been initialized.
|
|
15
|
+
resume: () => apiClientV2.postRequest('/user/verification/resume'),
|
|
16
|
+
},
|
|
7
17
|
update: {
|
|
8
18
|
phone: {
|
|
9
19
|
request: (data) => apiClientV2.patchRequest('/user/phone', { data }),
|
package/dist/constants.d.ts
CHANGED
|
@@ -294,6 +294,13 @@ export declare enum KYCStatuses {
|
|
|
294
294
|
}
|
|
295
295
|
export declare const KYCStatusCheck: IsEnumEqualToUnion<KYCStatuses, API.KYC.KYCStatus>;
|
|
296
296
|
export type KYCStatusMismatch = EnumUnionMismatch<KYCStatuses, API.KYC.KYCStatus>;
|
|
297
|
+
export declare enum UserVerificationFlows {
|
|
298
|
+
DATA = "data",
|
|
299
|
+
DOCUMENTS = "documents",
|
|
300
|
+
FACE = "face"
|
|
301
|
+
}
|
|
302
|
+
export declare const UserVerificationFlowCheck: IsEnumEqualToUnion<UserVerificationFlows, API.User.Verification.Flow>;
|
|
303
|
+
export type UserVerificationFlowMismatch = EnumUnionMismatch<UserVerificationFlows, API.User.Verification.Flow>;
|
|
297
304
|
export declare enum OrderStatuses {
|
|
298
305
|
NEW = "NEW",
|
|
299
306
|
PENDING = "PENDING",
|
package/dist/constants.js
CHANGED
|
@@ -308,6 +308,14 @@ export var KYCStatuses;
|
|
|
308
308
|
KYCStatuses["WAITING_ON_REVIEW"] = "WAITING_ON_REVIEW";
|
|
309
309
|
})(KYCStatuses || (KYCStatuses = {}));
|
|
310
310
|
export const KYCStatusCheck = true;
|
|
311
|
+
// Steps of the per-user verification ladder passed to `user.verification.init`.
|
|
312
|
+
export var UserVerificationFlows;
|
|
313
|
+
(function (UserVerificationFlows) {
|
|
314
|
+
UserVerificationFlows["DATA"] = "data";
|
|
315
|
+
UserVerificationFlows["DOCUMENTS"] = "documents";
|
|
316
|
+
UserVerificationFlows["FACE"] = "face";
|
|
317
|
+
})(UserVerificationFlows || (UserVerificationFlows = {}));
|
|
318
|
+
export const UserVerificationFlowCheck = true;
|
|
311
319
|
export var OrderStatuses;
|
|
312
320
|
(function (OrderStatuses) {
|
|
313
321
|
OrderStatuses["NEW"] = "NEW";
|
|
@@ -4,7 +4,7 @@ import axios from 'axios';
|
|
|
4
4
|
import { telegramSignUpPath, telegramSignInPath, refreshTokenPath } from '../api/auth';
|
|
5
5
|
import { AppEnviroment, ResponseStatus } from '../constants';
|
|
6
6
|
import { isExternalAuthMode, resolveAccessToken, triggerReverification, triggerUnauthorized, } from './accessTokenProvider';
|
|
7
|
-
import { deleteTokens, getTokens, refreshTokens } from './tokensFactory';
|
|
7
|
+
import { ExternalAuthRequiredError, deleteTokens, getTokens, refreshTokens } from './tokensFactory';
|
|
8
8
|
// eslint-disable-next-line no-constant-condition
|
|
9
9
|
// Backend signals that a sensitive request needs a fresh second-factor verification with this code.
|
|
10
10
|
// Backend error codes are UPPER_SNAKE_CASE, and the code can sit at either `data.code` or
|
|
@@ -119,6 +119,15 @@ export const createApiClient = ({ baseURL, isBearerToken, tenantId }) => {
|
|
|
119
119
|
}
|
|
120
120
|
})
|
|
121
121
|
.catch((tokenRefreshError) => {
|
|
122
|
+
// A Clerk tenant answered the sign-in with a one-time ticket: the SDK cannot complete
|
|
123
|
+
// it here, but the stored session is still valid and the app recovers by registering
|
|
124
|
+
// `setAccessTokenProvider`. Settle the queued requests with the error instead of
|
|
125
|
+
// wiping the tokens and redirecting to logout.
|
|
126
|
+
if (tokenRefreshError instanceof ExternalAuthRequiredError) {
|
|
127
|
+
requestQueue.forEach((request) => request.fail(tokenRefreshError));
|
|
128
|
+
requestQueue = [];
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
122
131
|
if (typeof window !== 'undefined') {
|
|
123
132
|
window.location.href = envLogoutURL;
|
|
124
133
|
deleteTokens();
|
|
@@ -140,6 +149,7 @@ export const createApiClient = ({ baseURL, isBearerToken, tenantId }) => {
|
|
|
140
149
|
return res(instance(failedRequestConfig));
|
|
141
150
|
},
|
|
142
151
|
reject: () => rej(instance(failedRequestConfig)),
|
|
152
|
+
fail: (queuedError) => rej(queuedError),
|
|
143
153
|
});
|
|
144
154
|
});
|
|
145
155
|
}
|
|
@@ -2,6 +2,16 @@ type ITokens = {
|
|
|
2
2
|
access_token: string;
|
|
3
3
|
refresh_token?: string | null;
|
|
4
4
|
};
|
|
5
|
+
/**
|
|
6
|
+
* Raised when the tenant's auth provider answers a sign-in with a one-time Clerk ticket
|
|
7
|
+
* (`{ ticket, expires_at }`) instead of a session. This localStorage flow cannot complete such a
|
|
8
|
+
* sign-in, but the session is **not** dead: the app is expected to exchange the ticket via Clerk JS
|
|
9
|
+
* (`signIn.create({ strategy: 'ticket', ticket })`) and register `setAccessTokenProvider`. Callers
|
|
10
|
+
* must treat it as "retry once the provider is ready", never as a reason to sign the user out.
|
|
11
|
+
*/
|
|
12
|
+
export declare class ExternalAuthRequiredError extends Error {
|
|
13
|
+
constructor(message?: string);
|
|
14
|
+
}
|
|
5
15
|
export declare function setTokens({ access_token, refresh_token }: ITokens): void;
|
|
6
16
|
export declare function deleteTokens(): void;
|
|
7
17
|
export declare function refreshTokens(): Promise<ITokens>;
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import { initData, isTMA } from '@telegram-apps/sdk-react';
|
|
2
2
|
import { deleteFromLocalStorage, getFromLocalStorage, setToLocalStorage } from './storage';
|
|
3
3
|
import { auth } from '../api/auth';
|
|
4
|
+
/**
|
|
5
|
+
* Raised when the tenant's auth provider answers a sign-in with a one-time Clerk ticket
|
|
6
|
+
* (`{ ticket, expires_at }`) instead of a session. This localStorage flow cannot complete such a
|
|
7
|
+
* sign-in, but the session is **not** dead: the app is expected to exchange the ticket via Clerk JS
|
|
8
|
+
* (`signIn.create({ strategy: 'ticket', ticket })`) and register `setAccessTokenProvider`. Callers
|
|
9
|
+
* must treat it as "retry once the provider is ready", never as a reason to sign the user out.
|
|
10
|
+
*/
|
|
11
|
+
export class ExternalAuthRequiredError extends Error {
|
|
12
|
+
constructor(message = 'Sign-in returned a Clerk ticket instead of a session; exchange it via Clerk and register setAccessTokenProvider') {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = 'ExternalAuthRequiredError';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
4
17
|
export function setTokens({ access_token, refresh_token }) {
|
|
5
18
|
access_token && setToLocalStorage('access_token', access_token);
|
|
6
19
|
refresh_token && setToLocalStorage('refresh_token', refresh_token);
|
|
@@ -27,6 +40,18 @@ export async function refreshTokens() {
|
|
|
27
40
|
hash,
|
|
28
41
|
init_data_raw,
|
|
29
42
|
});
|
|
43
|
+
// A malformed body (empty response, HTML error page) leaves the session unusable, so it stays a
|
|
44
|
+
// plain error and drives the caller's sign-out path.
|
|
45
|
+
if (typeof telegramSignInResponse !== 'object' || telegramSignInResponse === null) {
|
|
46
|
+
return Promise.reject(new Error('Telegram sign-in returned an unexpected response body'));
|
|
47
|
+
}
|
|
48
|
+
// Clerk tenants answer with a one-time sign-in ticket instead of a session: there is no bearer
|
|
49
|
+
// token to store here. Those apps exchange the ticket via Clerk JS and register
|
|
50
|
+
// `setAccessTokenProvider`, which bypasses this localStorage flow entirely — so this is a
|
|
51
|
+
// recoverable state, not a dead session.
|
|
52
|
+
if (!('access_token' in telegramSignInResponse)) {
|
|
53
|
+
return Promise.reject(new ExternalAuthRequiredError());
|
|
54
|
+
}
|
|
30
55
|
setTokens(telegramSignInResponse);
|
|
31
56
|
return telegramSignInResponse;
|
|
32
57
|
}
|