squarefi-bff-api-module 1.18.13 → 1.19.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/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.19.0] - 2025-05-25
9
+
10
+ ### Added
11
+
12
+ - Integrated Time-based One-Time Password (TOTP) functionality with new types and API client methods
13
+
8
14
  ## [1.18.9] - 2025-05-24
9
15
 
10
16
  ### Added
package/README.md CHANGED
@@ -1,187 +1,140 @@
1
- # Squarefi BFF API Module
1
+ # Squarefi BFF API SDK
2
2
 
3
- A professional TypeScript/JavaScript SDK for seamless integration with Squarefi BFF API.
3
+ A fully-typed TypeScript / JavaScript SDK for effortless interaction with the Squarefi **Back-For-Front** (BFF) API.
4
+
5
+ ---
6
+
7
+ ## ✨ Why use this SDK?
8
+
9
+ • Built-in token lifecycle management (refresh, revoke, storage helpers).
10
+ • Strict TypeScript types generated from the OpenAPI contract.
11
+ • Axios-powered HTTP client with automatic tenant & environment headers.
12
+ • First-class support for **Telegram Mini-Apps** as well as Web.
13
+ • Batteries included: constants, helpers & cryptography utilities.
14
+ • Zero-config – just provide your API URLs and tenant id.
15
+
16
+ ---
4
17
 
5
18
  ## 📦 Installation
6
19
 
7
20
  ```bash
21
+ # npm
22
+ yarn add squarefi-bff-api-module
23
+ # or
8
24
  npm install squarefi-bff-api-module
9
25
  ```
10
26
 
11
- ## 🔧 Usage
27
+ The package ships with `.d.ts` files so no additional typings are required.
12
28
 
13
- ```typescript
14
- import { squarefi_bff_api_client } from 'squarefi-bff-api-module';
29
+ ---
15
30
 
16
- // Authentication
17
- await squarefi_bff_api_client.auth.signin.omni.email({
18
- email: 'user@example.com',
19
- invite_code: 'optional_invite_code',
20
- referrer: 'optional_referrer',
21
- redirect_url: 'optional_redirect_url',
22
- });
31
+ ## ⚡️ Quick start
32
+
33
+ ```ts
34
+ import { squarefi_bff_api_client as api, OrderType } from 'squarefi-bff-api-module';
23
35
 
24
- // Telegram authentication
25
- await squarefi_bff_api_client.auth.signin.telegram({
26
- tg_id: 123456789,
27
- hash: 'telegram_hash',
28
- init_data_raw: 'telegram_init_data',
36
+ // 1) Authenticate (choose the strategy that suits your flow)
37
+ await api.auth.signin.omni.email({
38
+ email: 'alice@example.com',
39
+ invite_code: 'optional',
29
40
  });
30
41
 
31
- // Password authentication
32
- await squarefi_bff_api_client.auth.signin.password('user@example.com', 'password');
42
+ // 2) Make authorised calls – tokens are forwarded automatically.
43
+ const wallets = await api.wallets.getAll();
44
+ const firstWalletUuid = wallets[0].uuid;
45
+
46
+ const cards = await api.issuing.cards.byWalletUuid.getAll({
47
+ wallet_uuid: firstWalletUuid,
48
+ });
33
49
 
34
- // OTP verification
35
- await squarefi_bff_api_client.auth.otp.verify.email('user@example.com', 'otp_token');
36
- await squarefi_bff_api_client.auth.otp.verify.phone('+1234567890', 'otp_token');
50
+ // 3) Exchange rates helper
51
+ await api.exchange.byOrderType[OrderType.DEPOSIT_FIAT_SEPA].getByFromCurrency(firstWalletUuid);
52
+ ```
37
53
 
38
- // User operations
39
- const userData = await squarefi_bff_api_client.user.get();
40
- const userProfile = await squarefi_bff_api_client.user.userData.get();
54
+ See the [Examples](#examples) section below for more real-life snippets.
41
55
 
42
- // Wallet operations
43
- const wallets = await squarefi_bff_api_client.wallets.getAll();
44
- const walletDetails = await squarefi_bff_api_client.wallets.getByUuid('wallet_uuid');
56
+ ---
45
57
 
46
- // Card operations
47
- const cards = await squarefi_bff_api_client.issuing.cards.byWalletUuid.getAll({
48
- wallet_uuid: 'wallet_uuid',
49
- limit: 10,
50
- offset: 0,
51
- });
58
+ ## 🌐 Environment variables
52
59
 
53
- // Exchange operations
54
- const exchangeRates = await squarefi_bff_api_client.exchange.byOrderType[OrderType.DEPOSIT_FIAT_SEPA].getByFromCurrency(
55
- 'from_uuid'
56
- );
60
+ The SDK reads connection details from process-level variables. When bundling for the browser, tools like **Vite**, **Webpack DefinePlugin**, or **Next.js** can safely inline those values at build time.
57
61
 
58
- // System operations (currencies, chains, countries)
59
- const currencies = await squarefi_bff_api_client.list.currencies.getAll();
60
- const chains = await squarefi_bff_api_client.list.chains.getAll();
61
- const countries = await squarefi_bff_api_client.list.countries.getAll();
62
- ```
62
+ | Name | Description | Required | Example |
63
+ | -------------------------- | -------------------------------------------------------------------- | ----------------------------- | ----------------------------- |
64
+ | `API_URL` | Base URL of the BFF **v1** service | ✅ | `https://api-v1.squarefi.com` |
65
+ | `API_V2_URL` | Base URL of the BFF **v2** service | ✅ | `https://api-v2.squarefi.com` |
66
+ | `API_TOTP_URL` | Base URL of the **TOTP / OTP** micro-service | ⚠️ _If you use TOTP features_ | `https://totp.squarefi.com` |
67
+ | `TENANT_ID` | Your tenant / organisation identifier | ✅ | `tenant_12345` |
68
+ | `LOGOUT_URL` | Frontend route where the user is redirected when refresh token fails | ❌ | `/auth/logout` |
69
+ | `SERVER_PUBLIC_KEY_BASE64` | PEM encoded key (base64) used for request signing | ✅ | `MIIBIjANBgkqh…` |
63
70
 
64
- ## 📚 Available API Modules
65
-
66
- Access different API functionalities through the client:
67
-
68
- - `squarefi_bff_api_client.auth` - Authentication and authorization
69
- - OTP verification (email/phone)
70
- - Sign in (email/phone/telegram/password)
71
- - Sign up (email/telegram)
72
- - Token refresh
73
- - `squarefi_bff_api_client.counterparties` - Counterparty management
74
- - List, create, update counterparties
75
- - Manage counterparty destinations
76
- - `squarefi_bff_api_client.developer` - Developer tools
77
- - API key management
78
- - Vendor management
79
- - `squarefi_bff_api_client.exchange` - Currency exchange operations
80
- - Get exchange rates by order type
81
- - Get rates by currency
82
- - `squarefi_bff_api_client.issuing` - Card issuing operations
83
- - Create and manage cards
84
- - Card limits and controls
85
- - Transaction history
86
- - Card status management
87
- - `squarefi_bff_api_client.kyc` - Know Your Customer procedures
88
- - Sumsub integration
89
- - Persona inquiries initialization
90
- - `squarefi_bff_api_client.list` - System data operations
91
- - Currencies list (`/system/currencies`)
92
- - Chains list (`/system/chains`)
93
- - Countries list (`/system/countries`)
94
- - `squarefi_bff_api_client.orders` - Order management
95
- - Create orders by type
96
- - Calculate exchange rates
97
- - Support for INTERNAL_TRANSFER order type
98
- - `squarefi_bff_api_client.rails` - KYC onboarding rails
99
- - Manage onboarding rails and flows
100
- - `squarefi_bff_api_client.forms` - KYC forms
101
- - Manage and submit KYC forms
102
- - `squarefi_bff_api_client.tenants` - Tenant management operations
103
- - Tenant configuration
104
- - `squarefi_bff_api_client.user` - User profile operations
105
- - Get/update user data
106
- - Update contact information
107
- - OTP verification
108
- - `squarefi_bff_api_client.wallets` - Crypto wallet operations
109
- - Create and manage wallets
110
- - Address management
111
- - Transaction history
112
- - Balance tracking
113
-
114
- ## ⚙️ Environment Variables
115
-
116
- | Variable | Description | Required | Example |
117
- | ------------------------ | --------------------------------------------- | -------- | -------------------- |
118
- | API_URL | Base URL for the Squarefi BFF API | Yes | `https://api-v1.url` |
119
- | API_V2_URL | Base URL for the Squarefi BFF API | Yes | `https://api-v2.url` |
120
- | TENANT_ID | Your tenant identifier | Yes | `tenant_12345` |
121
- | LOGOUT_URL | Your frontend-app logout route | No | '/auth/logout' |
122
- | SERVER_PUBLIC_KEY_BASE64 | Server provides base64-encoded PEM format key | Yes | 'example' |
123
-
124
- ## 🚀 Features
125
-
126
- - 🔒 Built-in token management and authentication
127
- - 📱 Telegram integration support
128
- - 💪 Full TypeScript support with strict typing
129
- - 🔄 Axios-based HTTP client
130
- - 📦 Comprehensive constants and types
131
- - 🛡️ Secure request handling
132
- - 🔑 Multi-tenant support
133
- - 🧩 Persona KYC integration
134
- - 📝 Rails and Forms modules for flexible onboarding/compliance
135
-
136
- ## 🛠️ Development
137
-
138
- ### Prerequisites
139
-
140
- - Node.js (Latest LTS version)
141
- - npm or yarn
142
-
143
- ### Setup
71
+ > ℹ️ When running in Node.js you can place these variables in a `.env` file and load them with [dotenv](https://npmjs.com/package/dotenv).
144
72
 
145
- ```bash
146
- # Install dependencies
147
- npm install
73
+ ---
148
74
 
149
- # Build the package
150
- npm run build
75
+ ## 🗺️ API surface
151
76
 
152
- # Run tests
153
- npm test
154
- ```
77
+ `squarefi_bff_api_client` is a plain object where every property is a namespaced group of operations. The list below reflects the current SDK version (v1.18.13).
155
78
 
156
- ## 🔐 Security
79
+ | Namespace | Highlights |
80
+ | ------------------- | ------------------------------------------------------------------- |
81
+ | **auth** | Omni/Telegram/Password sign-in & sign-up, token refresh, OTP verify |
82
+ | **counterparties** | CRUD for counterparties & their destinations |
83
+ | **developer** | Vendor & API key management |
84
+ | **exchange** | Exchange rates per order type / currency |
85
+ | **issuing** | Virtual & physical cards, limits, controls, transactions |
86
+ | **kyc** | Sumsub flows, rails & form submission |
87
+ | **list** | Static system lists – currencies, chains, countries |
88
+ | **orders** | Create / calculate orders (including internal transfer) |
89
+ | **persona** | Persona in-app KYC inquiries |
90
+ | **tenants** | Tenant configuration |
91
+ | **totp** | TOTP generation / verification / revoke helpers |
92
+ | **user** | User profile, contacts, OTP verification |
93
+ | **virtualAccounts** | Create & manage virtual IBAN accounts |
94
+ | **wallets** | Wallet creation, addresses, balances, history |
157
95
 
158
- The module implements industry-standard security practices:
96
+ > 📝 Every method returns a typed `Promise<Response>` so you get IDE autocompletion & compile-time safety.
159
97
 
160
- - Secure token management
161
- - Request signing
162
- - Rate limiting protection
163
- - HTTPS enforcement
164
- - Multi-tenant isolation
98
+ ---
165
99
 
166
- ## Dependencies
100
+ ## 🛠️ Development & contributing
167
101
 
168
- ### Main Dependencies
102
+ 1. Fork the repo and install dependencies:
103
+ ```bash
104
+ git clone https://github.com/squarefi-tech/bff-api-module-npm.git
105
+ cd bff-api-module-npm
106
+ npm ci
107
+ ```
108
+ 2. Generate/update OpenAPI types (if the backend spec changed):
109
+ ```bash
110
+ npm run generate:openapi-types
111
+ ```
112
+ 3. Run the linter & the test suite:
113
+ ```bash
114
+ npm test
115
+ ```
116
+ 4. Build the package:
117
+ ```bash
118
+ npm run build
119
+ ```
169
120
 
170
- - axios: 1.6.7
171
- - @telegram-apps/sdk-react: 3.1.2
121
+ Please open a PR once the checks are green. All contributions are welcome! 🤝
172
122
 
173
- ### Peer Dependencies
123
+ ---
174
124
 
175
- - react: >=18.x.x
125
+ ## 🔐 Security policy
176
126
 
177
- ## 📝 Changelog
127
+ If you discover a vulnerability, **do NOT** open a public issue. Instead please email *security@squarefi.com* with the details and we will respond promptly.
178
128
 
179
- See [CHANGELOG.md](https://github.com/squarefi-tech/bff-api-module-npm/blob/main/CHANGELOG.md) for a list of changes and updates.
129
+ ---
180
130
 
181
131
  ## 📄 License
182
132
 
183
- MIT
133
+ [MIT](./LICENSE)
134
+
135
+ ---
184
136
 
185
- ## 🔗 Repository
137
+ ## 🔗 Links
186
138
 
187
- This package is available on [GitHub](https://github.com/squarefi-tech/bff-api-module-npm) and [npm](https://www.npmjs.com/package/squarefi-bff-api-module).
139
+ NPM https://www.npmjs.com/package/squarefi-bff-api-module
140
+ • GitHub – https://github.com/squarefi-tech/bff-api-module-npm
@@ -8,6 +8,7 @@ import { list } from './list';
8
8
  import { orders } from './orders';
9
9
  import { persona } from './persona';
10
10
  import { tenants } from './tenants';
11
+ import { totp } from './totp';
11
12
  import { user } from './user';
12
13
  import { virtualAccounts } from './virtual-accounts';
13
14
  import { wallets } from './wallets';
@@ -22,6 +23,7 @@ type Api = {
22
23
  orders: typeof orders;
23
24
  persona: typeof persona;
24
25
  tenants: typeof tenants;
26
+ totp: typeof totp;
25
27
  user: typeof user;
26
28
  virtualAccounts: typeof virtualAccounts;
27
29
  wallets: typeof wallets;
package/dist/api/index.js CHANGED
@@ -11,6 +11,7 @@ const list_1 = require("./list");
11
11
  const orders_1 = require("./orders");
12
12
  const persona_1 = require("./persona");
13
13
  const tenants_1 = require("./tenants");
14
+ const totp_1 = require("./totp");
14
15
  const user_1 = require("./user");
15
16
  const virtual_accounts_1 = require("./virtual-accounts");
16
17
  const wallets_1 = require("./wallets");
@@ -25,6 +26,7 @@ exports.squarefi_bff_api_client = {
25
26
  orders: orders_1.orders,
26
27
  persona: persona_1.persona,
27
28
  tenants: tenants_1.tenants,
29
+ totp: totp_1.totp,
28
30
  user: user_1.user,
29
31
  virtualAccounts: virtual_accounts_1.virtualAccounts,
30
32
  wallets: wallets_1.wallets,
@@ -0,0 +1,15 @@
1
+ import { API } from './types/types';
2
+ export declare const totp: {
3
+ otp_verification: {
4
+ create: (data: API.TOTP.OTPVerification.Create.Request) => Promise<API.TOTP.OTPVerification.Create.Response>;
5
+ verify: (data: API.TOTP.OTPVerification.Verify.Request) => Promise<API.TOTP.OTPVerification.Verify.Response>;
6
+ get: (id: string) => Promise<API.TOTP.OTPVerification.OTPVerificationInfo>;
7
+ };
8
+ totp: {
9
+ generate: (data: API.TOTP.TOTP.Generate.Request) => Promise<API.TOTP.TOTP.Generate.Response>;
10
+ verify: (data: API.TOTP.TOTP.Verify.Request) => Promise<API.TOTP.TOTP.Verify.Response>;
11
+ revoke: (data: API.TOTP.TOTP.Revoke.Request) => Promise<API.TOTP.TOTP.Revoke.Response>;
12
+ activate: (data: API.TOTP.TOTP.Activate.Request) => Promise<API.TOTP.TOTP.Activate.Response>;
13
+ generateEncrypted: (data: API.TOTP.TOTP.GenerateEncrypted.Request) => Promise<API.TOTP.TOTP.GenerateEncrypted.Response>;
14
+ };
15
+ };
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.totp = void 0;
4
+ const apiClientFactory_1 = require("../utils/apiClientFactory");
5
+ exports.totp = {
6
+ otp_verification: {
7
+ create: (data) => {
8
+ return apiClientFactory_1.apiClientTOTP.postRequest('/api/otp-verification', { data });
9
+ },
10
+ verify: (data) => {
11
+ return apiClientFactory_1.apiClientTOTP.postRequest('/api/otp-verification/verify', {
12
+ data,
13
+ });
14
+ },
15
+ get: (id) => {
16
+ return apiClientFactory_1.apiClientTOTP.getRequest(`/api/otp-verification/${id}`);
17
+ },
18
+ },
19
+ totp: {
20
+ generate: (data) => {
21
+ return apiClientFactory_1.apiClientTOTP.postRequest('/api/totp/generate', { data });
22
+ },
23
+ verify: (data) => {
24
+ return apiClientFactory_1.apiClientTOTP.postRequest('/api/totp/verify', { data });
25
+ },
26
+ revoke: (data) => {
27
+ return apiClientFactory_1.apiClientTOTP.postRequest('/api/totp/revoke', { data });
28
+ },
29
+ activate: (data) => {
30
+ return apiClientFactory_1.apiClientTOTP.postRequest('/api/totp/activate', { data });
31
+ },
32
+ generateEncrypted: (data) => {
33
+ return apiClientFactory_1.apiClientTOTP.postRequest('/api/totp/generate-encrypted', {
34
+ data,
35
+ });
36
+ },
37
+ },
38
+ };
@@ -683,7 +683,7 @@ export interface paths {
683
683
  patch?: never;
684
684
  trace?: never;
685
685
  };
686
- "/webhook/kyc/hifi-bridge": {
686
+ "/webhook/kyc/hifibridge": {
687
687
  parameters: {
688
688
  query?: never;
689
689
  header?: never;
@@ -806,6 +806,23 @@ export interface paths {
806
806
  patch?: never;
807
807
  trace?: never;
808
808
  };
809
+ "/storage/kyc/{folderId}/{fileId}": {
810
+ parameters: {
811
+ query?: never;
812
+ header?: never;
813
+ path?: never;
814
+ cookie?: never;
815
+ };
816
+ /** Get KYC file by ID */
817
+ get: operations["StorageController_getKycFile"];
818
+ put?: never;
819
+ post?: never;
820
+ delete?: never;
821
+ options?: never;
822
+ head?: never;
823
+ patch?: never;
824
+ trace?: never;
825
+ };
809
826
  "/counterparties/{wallet_id}": {
810
827
  parameters: {
811
828
  query?: never;
@@ -1703,7 +1720,8 @@ export interface components {
1703
1720
  proof_of_address_url?: string | null;
1704
1721
  proof_of_ownership_url?: string | null;
1705
1722
  /** @enum {string|null} */
1706
- purpose?: "PAY_SUPPLIERS" | "PAY_SERVICE_PROVIDERS" | "GOODS_MERCHANDISE_COMMODITIES" | "FREELANCERS_CONTRACTORS_PAYROLL" | "FINANCIAL_SERVICES_LOANS_INVESTMENTS" | "TAX_REGULATORY_FEES" | "LEGAL_SERVICES" | "OPERATIONAL_EXPENSES" | "SUBSCRIPTIONS" | "TRAVEL_RELATED_EXPENSES" | "INSURANCE" | "ADVERTISING_MARKETING_EXPENSES" | "EQUIPMENT_MACHINERY" | "TECHNOLOGY_SERVICES" | "EDUCATION_RELATED_EXPENSES" | "TREASURY_PAYMENTS" | "FX_SERVICES" | "OTHER" | "ONLINE_MARKETPLACE_TRADING" | "OFFLINE_TRADING" | null;
1723
+ purpose?: "charitable_donations" | "ecommerce_retail_payments" | "investment_purposes" | "other" | "payments_to_friends_or_family_abroad" | "payroll" | "personal_or_living_expenses" | "protect_wealth" | "purchase_goods_and_services" | "receive_payments_for_goods_and_services" | "tax_optimization" | "third_party_money_transmission" | "treasury_management" | "operating_a_company" | "receive_payment_for_freelancing" | "receive_salary" | null;
1724
+ purpose_other?: string | null;
1707
1725
  registration_number?: string | null;
1708
1726
  share_structure_url?: string | null;
1709
1727
  sof_eu_questionnaire?: components["schemas"]["KycEntitySofEuQuestionnaireEntity"] | null;
@@ -1793,7 +1811,8 @@ export interface components {
1793
1811
  proof_of_address_url?: string | null;
1794
1812
  proof_of_ownership_url?: string | null;
1795
1813
  /** @enum {string|null} */
1796
- purpose?: "PAY_SUPPLIERS" | "PAY_SERVICE_PROVIDERS" | "GOODS_MERCHANDISE_COMMODITIES" | "FREELANCERS_CONTRACTORS_PAYROLL" | "FINANCIAL_SERVICES_LOANS_INVESTMENTS" | "TAX_REGULATORY_FEES" | "LEGAL_SERVICES" | "OPERATIONAL_EXPENSES" | "SUBSCRIPTIONS" | "TRAVEL_RELATED_EXPENSES" | "INSURANCE" | "ADVERTISING_MARKETING_EXPENSES" | "EQUIPMENT_MACHINERY" | "TECHNOLOGY_SERVICES" | "EDUCATION_RELATED_EXPENSES" | "TREASURY_PAYMENTS" | "FX_SERVICES" | "OTHER" | "ONLINE_MARKETPLACE_TRADING" | "OFFLINE_TRADING" | null;
1814
+ purpose?: "charitable_donations" | "ecommerce_retail_payments" | "investment_purposes" | "other" | "payments_to_friends_or_family_abroad" | "payroll" | "personal_or_living_expenses" | "protect_wealth" | "purchase_goods_and_services" | "receive_payments_for_goods_and_services" | "tax_optimization" | "third_party_money_transmission" | "treasury_management" | "operating_a_company" | "receive_payment_for_freelancing" | "receive_salary" | null;
1815
+ purpose_other?: string | null;
1797
1816
  registration_number?: string | null;
1798
1817
  share_structure_url?: string | null;
1799
1818
  sof_eu_questionnaire?: components["schemas"]["KycEntitySofEuQuestionnaireEntity"] | null;
@@ -3834,6 +3853,28 @@ export interface operations {
3834
3853
  };
3835
3854
  };
3836
3855
  };
3856
+ StorageController_getKycFile: {
3857
+ parameters: {
3858
+ query?: never;
3859
+ header?: never;
3860
+ path: {
3861
+ folderId: string;
3862
+ fileId: string;
3863
+ };
3864
+ cookie?: never;
3865
+ };
3866
+ requestBody?: never;
3867
+ responses: {
3868
+ 200: {
3869
+ headers: {
3870
+ [name: string]: unknown;
3871
+ };
3872
+ content: {
3873
+ "application/octet-stream": string;
3874
+ };
3875
+ };
3876
+ };
3877
+ };
3837
3878
  CounterpartyAccountsController_findAll: {
3838
3879
  parameters: {
3839
3880
  query?: {
@@ -1396,6 +1396,120 @@ export declare namespace API {
1396
1396
  }
1397
1397
  }
1398
1398
  }
1399
+ namespace TOTP {
1400
+ namespace OTPVerification {
1401
+ type OTPVerificationChannelType = 'EMAIL' | 'SMS' | 'TOTP' | 'APP';
1402
+ type OTPVerificationStatus = 'PENDING' | 'APPROVED' | 'DENIED';
1403
+ type OTPVerificationChannelInfo = {
1404
+ channel: OTPVerificationChannelType;
1405
+ validity: number;
1406
+ };
1407
+ type OTPVerificationInfo = {
1408
+ id: string;
1409
+ status: OTPVerificationStatus;
1410
+ created_at: string;
1411
+ updated_at: string;
1412
+ };
1413
+ namespace Create {
1414
+ type Request = {
1415
+ id: string;
1416
+ amount: number;
1417
+ order_type: string;
1418
+ wallet_id: string;
1419
+ meta: {
1420
+ description: string;
1421
+ };
1422
+ };
1423
+ type Response = {
1424
+ id: string;
1425
+ status: OTPVerificationStatus;
1426
+ channels: OTPVerificationChannelInfo[];
1427
+ };
1428
+ }
1429
+ namespace Verify {
1430
+ type Request = {
1431
+ id: string;
1432
+ channel: OTPVerificationChannelType;
1433
+ otp: string;
1434
+ };
1435
+ type Response = {
1436
+ success?: boolean;
1437
+ error?: boolean;
1438
+ message?: string;
1439
+ details?: string;
1440
+ };
1441
+ }
1442
+ }
1443
+ namespace TOTP {
1444
+ namespace Generate {
1445
+ type Request = {
1446
+ user_name: string;
1447
+ service_name: string;
1448
+ };
1449
+ type Response = {
1450
+ success?: boolean;
1451
+ error?: boolean;
1452
+ message?: string;
1453
+ data?: {
1454
+ id: string;
1455
+ qrCode: string;
1456
+ secret: string;
1457
+ };
1458
+ };
1459
+ }
1460
+ namespace Verify {
1461
+ type Request = {
1462
+ token: string;
1463
+ otp: string;
1464
+ };
1465
+ type Response = {
1466
+ success?: boolean;
1467
+ error?: boolean;
1468
+ message?: string;
1469
+ details?: string;
1470
+ };
1471
+ }
1472
+ namespace Revoke {
1473
+ type Request = {
1474
+ token: string;
1475
+ };
1476
+ type Response = {
1477
+ success?: boolean;
1478
+ error?: boolean;
1479
+ message?: string;
1480
+ details?: string;
1481
+ };
1482
+ }
1483
+ namespace Activate {
1484
+ type Request = {
1485
+ token: string;
1486
+ };
1487
+ type Response = {
1488
+ success?: boolean;
1489
+ error?: boolean;
1490
+ message?: string;
1491
+ details?: string;
1492
+ data?: {
1493
+ activated: boolean;
1494
+ };
1495
+ };
1496
+ }
1497
+ namespace GenerateEncrypted {
1498
+ type Request = {
1499
+ user_name: string;
1500
+ service_name: string;
1501
+ public_key: string;
1502
+ };
1503
+ type Response = {
1504
+ success?: boolean;
1505
+ error?: boolean;
1506
+ message?: string;
1507
+ details?: string;
1508
+ data?: string;
1509
+ };
1510
+ }
1511
+ }
1512
+ }
1399
1513
  namespace VirtualAccounts {
1400
1514
  namespace Create {
1401
1515
  interface Request {
@@ -22,4 +22,10 @@ export declare const apiClientV2: {
22
22
  deleteRequest: (url: string, config?: AxiosRequestConfig) => Promise<any>;
23
23
  getRequest: <T>(url: string, config?: AxiosRequestConfig) => Promise<T>;
24
24
  };
25
+ export declare const apiClientTOTP: {
26
+ patchRequest: <T>(url: string, config?: AxiosRequestConfig) => Promise<T>;
27
+ postRequest: <T>(url: string, config?: AxiosRequestConfig) => Promise<T>;
28
+ deleteRequest: (url: string, config?: AxiosRequestConfig) => Promise<any>;
29
+ getRequest: <T>(url: string, config?: AxiosRequestConfig) => Promise<T>;
30
+ };
25
31
  export {};
@@ -22,9 +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, _d;
25
+ var _a, _b, _c, _d, _e;
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.apiClientV2 = exports.apiClientV1 = exports.createApiClient = void 0;
27
+ exports.apiClientTOTP = exports.apiClientV2 = exports.apiClientV1 = exports.createApiClient = void 0;
28
28
  /* eslint-disable no-console */
29
29
  const sdk_react_1 = require("@telegram-apps/sdk-react");
30
30
  const axios_1 = __importDefault(require("axios"));
@@ -35,8 +35,9 @@ const tokensFactory_1 = require("../utils/tokensFactory");
35
35
  // eslint-disable-next-line no-constant-condition
36
36
  const apiV1BaseURL = (_a = process.env.API_URL) !== null && _a !== void 0 ? _a : 'ENV variable API_URL is not defined';
37
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';
39
- const envLogoutURL = (_d = process.env.LOGOUT_URL) !== null && _d !== void 0 ? _d : '/auth/logout';
38
+ const apiTOTPBaseURL = (_c = process.env.API_TOTP_URL) !== null && _c !== void 0 ? _c : 'ENV variable API_TOTP_URL is not defined';
39
+ const envTenantId = (_d = process.env.TENANT_ID) !== null && _d !== void 0 ? _d : 'ENV variable TENANT_ID is not defined';
40
+ const envLogoutURL = (_e = process.env.LOGOUT_URL) !== null && _e !== void 0 ? _e : '/auth/logout';
40
41
  const createApiClient = ({ baseURL, isBearerToken, tenantId }) => {
41
42
  const instance = axios_1.default.create({
42
43
  baseURL,
@@ -139,3 +140,8 @@ exports.apiClientV2 = (0, exports.createApiClient)({
139
140
  isBearerToken: true,
140
141
  tenantId: envTenantId,
141
142
  });
143
+ exports.apiClientTOTP = (0, exports.createApiClient)({
144
+ baseURL: apiTOTPBaseURL,
145
+ isBearerToken: true,
146
+ tenantId: envTenantId,
147
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squarefi-bff-api-module",
3
- "version": "1.18.13",
3
+ "version": "1.19.0",
4
4
  "description": "Squarefi BFF API client module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -10,7 +10,7 @@ type ApiDocsData = {
10
10
 
11
11
  const apiDocsData: ApiDocsData[] = [
12
12
  {
13
- url: process.env.API_V2_URL,
13
+ url: process.env.API_DOCS_V2_URL,
14
14
  name: 'apiV2',
15
15
  },
16
16
  ];
package/src/api/index.ts CHANGED
@@ -9,6 +9,7 @@ import { list } from './list';
9
9
  import { orders } from './orders';
10
10
  import { persona } from './persona';
11
11
  import { tenants } from './tenants';
12
+ import { totp } from './totp';
12
13
  import { user } from './user';
13
14
  import { virtualAccounts } from './virtual-accounts';
14
15
  import { wallets } from './wallets';
@@ -24,6 +25,7 @@ type Api = {
24
25
  orders: typeof orders;
25
26
  persona: typeof persona;
26
27
  tenants: typeof tenants;
28
+ totp: typeof totp;
27
29
  user: typeof user;
28
30
  virtualAccounts: typeof virtualAccounts;
29
31
  wallets: typeof wallets;
@@ -40,6 +42,7 @@ export const squarefi_bff_api_client: Api = {
40
42
  orders,
41
43
  persona,
42
44
  tenants,
45
+ totp,
43
46
  user,
44
47
  virtualAccounts,
45
48
  wallets,
@@ -0,0 +1,39 @@
1
+ import { apiClientTOTP } from '../utils/apiClientFactory';
2
+ import { API } from './types/types';
3
+
4
+ export const totp = {
5
+ otp_verification: {
6
+ create: (data: API.TOTP.OTPVerification.Create.Request): Promise<API.TOTP.OTPVerification.Create.Response> => {
7
+ return apiClientTOTP.postRequest<API.TOTP.OTPVerification.Create.Response>('/api/otp-verification', { data });
8
+ },
9
+ verify: (data: API.TOTP.OTPVerification.Verify.Request): Promise<API.TOTP.OTPVerification.Verify.Response> => {
10
+ return apiClientTOTP.postRequest<API.TOTP.OTPVerification.Verify.Response>('/api/otp-verification/verify', {
11
+ data,
12
+ });
13
+ },
14
+ get: (id: string): Promise<API.TOTP.OTPVerification.OTPVerificationInfo> => {
15
+ return apiClientTOTP.getRequest<API.TOTP.OTPVerification.OTPVerificationInfo>(`/api/otp-verification/${id}`);
16
+ },
17
+ },
18
+ totp: {
19
+ generate: (data: API.TOTP.TOTP.Generate.Request): Promise<API.TOTP.TOTP.Generate.Response> => {
20
+ return apiClientTOTP.postRequest<API.TOTP.TOTP.Generate.Response>('/api/totp/generate', { data });
21
+ },
22
+ verify: (data: API.TOTP.TOTP.Verify.Request): Promise<API.TOTP.TOTP.Verify.Response> => {
23
+ return apiClientTOTP.postRequest<API.TOTP.TOTP.Verify.Response>('/api/totp/verify', { data });
24
+ },
25
+ revoke: (data: API.TOTP.TOTP.Revoke.Request): Promise<API.TOTP.TOTP.Revoke.Response> => {
26
+ return apiClientTOTP.postRequest<API.TOTP.TOTP.Revoke.Response>('/api/totp/revoke', { data });
27
+ },
28
+ activate: (data: API.TOTP.TOTP.Activate.Request): Promise<API.TOTP.TOTP.Activate.Response> => {
29
+ return apiClientTOTP.postRequest<API.TOTP.TOTP.Activate.Response>('/api/totp/activate', { data });
30
+ },
31
+ generateEncrypted: (
32
+ data: API.TOTP.TOTP.GenerateEncrypted.Request
33
+ ): Promise<API.TOTP.TOTP.GenerateEncrypted.Response> => {
34
+ return apiClientTOTP.postRequest<API.TOTP.TOTP.GenerateEncrypted.Response>('/api/totp/generate-encrypted', {
35
+ data,
36
+ });
37
+ },
38
+ },
39
+ };
@@ -684,7 +684,7 @@ export interface paths {
684
684
  patch?: never;
685
685
  trace?: never;
686
686
  };
687
- "/webhook/kyc/hifi-bridge": {
687
+ "/webhook/kyc/hifibridge": {
688
688
  parameters: {
689
689
  query?: never;
690
690
  header?: never;
@@ -807,6 +807,23 @@ export interface paths {
807
807
  patch?: never;
808
808
  trace?: never;
809
809
  };
810
+ "/storage/kyc/{folderId}/{fileId}": {
811
+ parameters: {
812
+ query?: never;
813
+ header?: never;
814
+ path?: never;
815
+ cookie?: never;
816
+ };
817
+ /** Get KYC file by ID */
818
+ get: operations["StorageController_getKycFile"];
819
+ put?: never;
820
+ post?: never;
821
+ delete?: never;
822
+ options?: never;
823
+ head?: never;
824
+ patch?: never;
825
+ trace?: never;
826
+ };
810
827
  "/counterparties/{wallet_id}": {
811
828
  parameters: {
812
829
  query?: never;
@@ -1704,7 +1721,8 @@ export interface components {
1704
1721
  proof_of_address_url?: string | null;
1705
1722
  proof_of_ownership_url?: string | null;
1706
1723
  /** @enum {string|null} */
1707
- purpose?: "PAY_SUPPLIERS" | "PAY_SERVICE_PROVIDERS" | "GOODS_MERCHANDISE_COMMODITIES" | "FREELANCERS_CONTRACTORS_PAYROLL" | "FINANCIAL_SERVICES_LOANS_INVESTMENTS" | "TAX_REGULATORY_FEES" | "LEGAL_SERVICES" | "OPERATIONAL_EXPENSES" | "SUBSCRIPTIONS" | "TRAVEL_RELATED_EXPENSES" | "INSURANCE" | "ADVERTISING_MARKETING_EXPENSES" | "EQUIPMENT_MACHINERY" | "TECHNOLOGY_SERVICES" | "EDUCATION_RELATED_EXPENSES" | "TREASURY_PAYMENTS" | "FX_SERVICES" | "OTHER" | "ONLINE_MARKETPLACE_TRADING" | "OFFLINE_TRADING" | null;
1724
+ purpose?: "charitable_donations" | "ecommerce_retail_payments" | "investment_purposes" | "other" | "payments_to_friends_or_family_abroad" | "payroll" | "personal_or_living_expenses" | "protect_wealth" | "purchase_goods_and_services" | "receive_payments_for_goods_and_services" | "tax_optimization" | "third_party_money_transmission" | "treasury_management" | "operating_a_company" | "receive_payment_for_freelancing" | "receive_salary" | null;
1725
+ purpose_other?: string | null;
1708
1726
  registration_number?: string | null;
1709
1727
  share_structure_url?: string | null;
1710
1728
  sof_eu_questionnaire?: components["schemas"]["KycEntitySofEuQuestionnaireEntity"] | null;
@@ -1794,7 +1812,8 @@ export interface components {
1794
1812
  proof_of_address_url?: string | null;
1795
1813
  proof_of_ownership_url?: string | null;
1796
1814
  /** @enum {string|null} */
1797
- purpose?: "PAY_SUPPLIERS" | "PAY_SERVICE_PROVIDERS" | "GOODS_MERCHANDISE_COMMODITIES" | "FREELANCERS_CONTRACTORS_PAYROLL" | "FINANCIAL_SERVICES_LOANS_INVESTMENTS" | "TAX_REGULATORY_FEES" | "LEGAL_SERVICES" | "OPERATIONAL_EXPENSES" | "SUBSCRIPTIONS" | "TRAVEL_RELATED_EXPENSES" | "INSURANCE" | "ADVERTISING_MARKETING_EXPENSES" | "EQUIPMENT_MACHINERY" | "TECHNOLOGY_SERVICES" | "EDUCATION_RELATED_EXPENSES" | "TREASURY_PAYMENTS" | "FX_SERVICES" | "OTHER" | "ONLINE_MARKETPLACE_TRADING" | "OFFLINE_TRADING" | null;
1815
+ purpose?: "charitable_donations" | "ecommerce_retail_payments" | "investment_purposes" | "other" | "payments_to_friends_or_family_abroad" | "payroll" | "personal_or_living_expenses" | "protect_wealth" | "purchase_goods_and_services" | "receive_payments_for_goods_and_services" | "tax_optimization" | "third_party_money_transmission" | "treasury_management" | "operating_a_company" | "receive_payment_for_freelancing" | "receive_salary" | null;
1816
+ purpose_other?: string | null;
1798
1817
  registration_number?: string | null;
1799
1818
  share_structure_url?: string | null;
1800
1819
  sof_eu_questionnaire?: components["schemas"]["KycEntitySofEuQuestionnaireEntity"] | null;
@@ -3835,6 +3854,28 @@ export interface operations {
3835
3854
  };
3836
3855
  };
3837
3856
  };
3857
+ StorageController_getKycFile: {
3858
+ parameters: {
3859
+ query?: never;
3860
+ header?: never;
3861
+ path: {
3862
+ folderId: string;
3863
+ fileId: string;
3864
+ };
3865
+ cookie?: never;
3866
+ };
3867
+ requestBody?: never;
3868
+ responses: {
3869
+ 200: {
3870
+ headers: {
3871
+ [name: string]: unknown;
3872
+ };
3873
+ content: {
3874
+ "application/octet-stream": string;
3875
+ };
3876
+ };
3877
+ };
3878
+ };
3838
3879
  CounterpartyAccountsController_findAll: {
3839
3880
  parameters: {
3840
3881
  query?: {
@@ -1695,6 +1695,134 @@ export namespace API {
1695
1695
  }
1696
1696
  }
1697
1697
 
1698
+ export namespace TOTP {
1699
+ export namespace OTPVerification {
1700
+ export type OTPVerificationChannelType = 'EMAIL' | 'SMS' | 'TOTP' | 'APP';
1701
+ export type OTPVerificationStatus = 'PENDING' | 'APPROVED' | 'DENIED';
1702
+ export type OTPVerificationChannelInfo = {
1703
+ channel: OTPVerificationChannelType;
1704
+ validity: number;
1705
+ };
1706
+ export type OTPVerificationInfo = {
1707
+ id: string;
1708
+ status: OTPVerificationStatus;
1709
+ created_at: string;
1710
+ updated_at: string;
1711
+ };
1712
+
1713
+ export namespace Create {
1714
+ export type Request = {
1715
+ id: string;
1716
+ amount: number;
1717
+ order_type: string;
1718
+ wallet_id: string;
1719
+ meta: {
1720
+ description: string;
1721
+ };
1722
+ };
1723
+
1724
+ export type Response = {
1725
+ id: string;
1726
+ status: OTPVerificationStatus;
1727
+ channels: OTPVerificationChannelInfo[];
1728
+ };
1729
+ }
1730
+
1731
+ export namespace Verify {
1732
+ export type Request = {
1733
+ id: string;
1734
+ channel: OTPVerificationChannelType;
1735
+ otp: string;
1736
+ };
1737
+
1738
+ export type Response = {
1739
+ success?: boolean;
1740
+ error?: boolean;
1741
+ message?: string;
1742
+ details?: string;
1743
+ };
1744
+ }
1745
+ }
1746
+ export namespace TOTP {
1747
+ export namespace Generate {
1748
+ export type Request = {
1749
+ user_name: string;
1750
+ service_name: string;
1751
+ };
1752
+
1753
+ export type Response = {
1754
+ success?: boolean;
1755
+ error?: boolean;
1756
+ message?: string;
1757
+ data?: {
1758
+ id: string;
1759
+ qrCode: string;
1760
+ secret: string;
1761
+ };
1762
+ };
1763
+ }
1764
+
1765
+ export namespace Verify {
1766
+ export type Request = {
1767
+ token: string;
1768
+ otp: string;
1769
+ };
1770
+
1771
+ export type Response = {
1772
+ success?: boolean;
1773
+ error?: boolean;
1774
+ message?: string;
1775
+ details?: string;
1776
+ };
1777
+ }
1778
+
1779
+ export namespace Revoke {
1780
+ export type Request = {
1781
+ token: string;
1782
+ };
1783
+
1784
+ export type Response = {
1785
+ success?: boolean;
1786
+ error?: boolean;
1787
+ message?: string;
1788
+ details?: string;
1789
+ };
1790
+ }
1791
+
1792
+ export namespace Activate {
1793
+ export type Request = {
1794
+ token: string;
1795
+ };
1796
+
1797
+ export type Response = {
1798
+ success?: boolean;
1799
+ error?: boolean;
1800
+ message?: string;
1801
+ details?: string;
1802
+ data?: {
1803
+ activated: boolean;
1804
+ };
1805
+ };
1806
+ }
1807
+
1808
+ export namespace GenerateEncrypted {
1809
+ export type Request = {
1810
+ user_name: string;
1811
+ service_name: string;
1812
+ public_key: string;
1813
+ };
1814
+
1815
+ export type Response = {
1816
+ success?: boolean;
1817
+ error?: boolean;
1818
+ message?: string;
1819
+ details?: string;
1820
+ data?: string;
1821
+ };
1822
+ }
1823
+ }
1824
+ }
1825
+
1698
1826
  export namespace VirtualAccounts {
1699
1827
  export namespace Create {
1700
1828
  export interface Request {
@@ -12,6 +12,7 @@ import { deleteTokens, refreshTokens } from '../utils/tokensFactory';
12
12
 
13
13
  const apiV1BaseURL = process.env.API_URL ?? 'ENV variable API_URL is not defined';
14
14
  const apiV2BaseURL = process.env.API_V2_URL ?? 'ENV variable API_V2_URL is not defined';
15
+ const apiTOTPBaseURL = process.env.API_TOTP_URL ?? 'ENV variable API_TOTP_URL is not defined';
15
16
  const envTenantId = process.env.TENANT_ID ?? 'ENV variable TENANT_ID is not defined';
16
17
  const envLogoutURL = process.env.LOGOUT_URL ?? '/auth/logout';
17
18
 
@@ -161,3 +162,9 @@ export const apiClientV2 = createApiClient({
161
162
  isBearerToken: true,
162
163
  tenantId: envTenantId,
163
164
  });
165
+
166
+ export const apiClientTOTP = createApiClient({
167
+ baseURL: apiTOTPBaseURL,
168
+ isBearerToken: true,
169
+ tenantId: envTenantId,
170
+ });