squarefi-bff-api-module 1.24.33 → 1.24.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/types/autogen/apiV2.types.d.ts +4 -3
- package/dist/api/types/types.d.ts +25 -131
- package/dist/api/wallets.d.ts +1 -1
- package/dist/api/wallets.js +4 -1
- package/dist/utils/encrypt.js +48 -2
- package/package.json +1 -1
- package/src/api/types/autogen/apiV2.types.ts +4 -3
- package/src/api/types/types.ts +165 -141
- package/src/api/wallets.ts +9 -3
- package/src/utils/encrypt.ts +52 -2
|
@@ -1237,8 +1237,6 @@ export interface components {
|
|
|
1237
1237
|
TransactionsFilter: {
|
|
1238
1238
|
created_at?: string;
|
|
1239
1239
|
/** @enum {string} */
|
|
1240
|
-
status?: "complete" | "pending" | "canceled" | "failed" | "processing" | "new";
|
|
1241
|
-
/** @enum {string} */
|
|
1242
1240
|
type?: "deposit_crypto" | "withdrawal_crypto" | "deposit_fiat" | "withdrawal_fiat" | "deposit_vcard" | "withdrawal_vcard" | "deposit" | "withdrawal";
|
|
1243
1241
|
/** @enum {string|null} */
|
|
1244
1242
|
method?: "p2p" | "crypto" | "bank_transfer" | "exchange" | "sbp" | "internal_fiat" | null;
|
|
@@ -1255,6 +1253,7 @@ export interface components {
|
|
|
1255
1253
|
to_created_at?: string;
|
|
1256
1254
|
/** @default false */
|
|
1257
1255
|
show_low_balance: boolean;
|
|
1256
|
+
status?: ("complete" | "pending" | "canceled" | "failed" | "processing" | "new")[];
|
|
1258
1257
|
};
|
|
1259
1258
|
ChainDto: {
|
|
1260
1259
|
id: number;
|
|
@@ -2984,7 +2983,9 @@ export interface operations {
|
|
|
2984
2983
|
};
|
|
2985
2984
|
WalletsTransactionsController_export: {
|
|
2986
2985
|
parameters: {
|
|
2987
|
-
query?:
|
|
2986
|
+
query?: {
|
|
2987
|
+
status?: ("complete" | "pending" | "canceled" | "failed" | "processing" | "new")[];
|
|
2988
|
+
};
|
|
2988
2989
|
header?: never;
|
|
2989
2990
|
path: {
|
|
2990
2991
|
wallet_id: string;
|
|
@@ -668,136 +668,6 @@ export declare namespace API {
|
|
|
668
668
|
}
|
|
669
669
|
}
|
|
670
670
|
}
|
|
671
|
-
namespace SubAccountsV2 {
|
|
672
|
-
type SubAccountDetails = {
|
|
673
|
-
iban: string;
|
|
674
|
-
bank_name: string;
|
|
675
|
-
swift_code: string;
|
|
676
|
-
bank_address: string;
|
|
677
|
-
receiver_name: string;
|
|
678
|
-
payment_details: string;
|
|
679
|
-
reference_number: string;
|
|
680
|
-
registration_number: string;
|
|
681
|
-
};
|
|
682
|
-
interface SubAccount {
|
|
683
|
-
balance: number;
|
|
684
|
-
cards_count: number;
|
|
685
|
-
created_at: string;
|
|
686
|
-
currency: API.Currencies.FiatCurrency;
|
|
687
|
-
fiat_balance: number;
|
|
688
|
-
id: string;
|
|
689
|
-
issuing_program: API.Cards.Config.Program;
|
|
690
|
-
nick_name: string;
|
|
691
|
-
program_id: string;
|
|
692
|
-
realtimeauth_balance: number;
|
|
693
|
-
status: string;
|
|
694
|
-
total_balance: number;
|
|
695
|
-
wallet_id: string;
|
|
696
|
-
}
|
|
697
|
-
namespace ExtendedSubAccount {
|
|
698
|
-
interface ExtendedSubAccount extends SubAccount {
|
|
699
|
-
account_details?: SubAccountDetails;
|
|
700
|
-
payment_types: Array<{
|
|
701
|
-
order_type: OrderType;
|
|
702
|
-
}>;
|
|
703
|
-
realtime_auth: [
|
|
704
|
-
{
|
|
705
|
-
crypto_token: string;
|
|
706
|
-
fiat_account: string;
|
|
707
|
-
id: string;
|
|
708
|
-
priority: number;
|
|
709
|
-
}
|
|
710
|
-
];
|
|
711
|
-
}
|
|
712
|
-
interface Request {
|
|
713
|
-
wallet_uuid: string;
|
|
714
|
-
fiat_account_id: string;
|
|
715
|
-
}
|
|
716
|
-
type Response = ExtendedSubAccount;
|
|
717
|
-
}
|
|
718
|
-
interface SubAccountWithCards extends SubAccount {
|
|
719
|
-
cards: API.Cards.IssuingCardListItem[];
|
|
720
|
-
}
|
|
721
|
-
interface SubAccountsList<T extends SubAccount | SubAccountWithCards> {
|
|
722
|
-
count: number;
|
|
723
|
-
data: T[];
|
|
724
|
-
}
|
|
725
|
-
type SubAccountsListWithCards = SubAccountsList<SubAccountWithCards>;
|
|
726
|
-
type SubAccountsListWithoutCards = SubAccountsList<SubAccount>;
|
|
727
|
-
namespace CreateSubAccount {
|
|
728
|
-
interface Request {
|
|
729
|
-
wallet_id: string;
|
|
730
|
-
program_id: string;
|
|
731
|
-
}
|
|
732
|
-
type Response = {
|
|
733
|
-
id: string;
|
|
734
|
-
balance: number;
|
|
735
|
-
nick_name: string;
|
|
736
|
-
wallet_id: string;
|
|
737
|
-
created_at: string;
|
|
738
|
-
account_currency: string;
|
|
739
|
-
type: SubAccountType | string;
|
|
740
|
-
program_id: string;
|
|
741
|
-
status: 'ACTIVE';
|
|
742
|
-
fiat: {
|
|
743
|
-
code: string;
|
|
744
|
-
uuid: string;
|
|
745
|
-
symbol: string;
|
|
746
|
-
enabled: boolean;
|
|
747
|
-
coingecko: string;
|
|
748
|
-
};
|
|
749
|
-
issuing_program: {
|
|
750
|
-
id: string;
|
|
751
|
-
form_factor: CardFormFactor | string;
|
|
752
|
-
brand: string;
|
|
753
|
-
tokenizable: boolean;
|
|
754
|
-
type: CardType | string;
|
|
755
|
-
};
|
|
756
|
-
};
|
|
757
|
-
}
|
|
758
|
-
namespace Transactions {
|
|
759
|
-
type Transaction = {
|
|
760
|
-
vendor_transaction_id: string;
|
|
761
|
-
created_at: string;
|
|
762
|
-
cleared_at: string;
|
|
763
|
-
merchant: {
|
|
764
|
-
name: string;
|
|
765
|
-
category_code: string;
|
|
766
|
-
city: string;
|
|
767
|
-
country: string;
|
|
768
|
-
};
|
|
769
|
-
last4: string;
|
|
770
|
-
title: string;
|
|
771
|
-
billing_amount: number;
|
|
772
|
-
billing_currency: string;
|
|
773
|
-
transaction_amount: number;
|
|
774
|
-
transaction_currency: string;
|
|
775
|
-
vendor_sub_account_id: string;
|
|
776
|
-
failure_reason: string;
|
|
777
|
-
status: string;
|
|
778
|
-
transaction_type: string;
|
|
779
|
-
is_credit: boolean;
|
|
780
|
-
has_receipt: boolean;
|
|
781
|
-
adjustment_type: string;
|
|
782
|
-
review_status: string;
|
|
783
|
-
group: string;
|
|
784
|
-
total_amount: number;
|
|
785
|
-
};
|
|
786
|
-
namespace TransactionList {
|
|
787
|
-
interface Request {
|
|
788
|
-
fiat_account_id: string;
|
|
789
|
-
wallet_uuid: string;
|
|
790
|
-
limit?: number;
|
|
791
|
-
offset?: number;
|
|
792
|
-
}
|
|
793
|
-
interface Response {
|
|
794
|
-
count: number;
|
|
795
|
-
data: Transaction[];
|
|
796
|
-
has_more: boolean;
|
|
797
|
-
}
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
671
|
namespace Issuing {
|
|
802
672
|
namespace Programs {
|
|
803
673
|
type Request = {
|
|
@@ -2413,13 +2283,37 @@ export declare namespace API {
|
|
|
2413
2283
|
};
|
|
2414
2284
|
}
|
|
2415
2285
|
namespace TransactionList {
|
|
2416
|
-
type Request =
|
|
2286
|
+
type Request = {
|
|
2417
2287
|
wallet_uuid: string;
|
|
2288
|
+
limit: number;
|
|
2289
|
+
offset: number;
|
|
2290
|
+
filter?: {
|
|
2291
|
+
created_at?: string;
|
|
2292
|
+
status?: WalletTransactionStatus[];
|
|
2293
|
+
type?: WalletTransactionType;
|
|
2294
|
+
method?: WalletTransactionMethod;
|
|
2295
|
+
record_type?: WalletTransactionRecordType;
|
|
2296
|
+
'currency.uuid'?: string;
|
|
2297
|
+
'meta.billing_amount_currency'?: string;
|
|
2298
|
+
'meta.transaction_amount_currency'?: string;
|
|
2299
|
+
address?: string;
|
|
2300
|
+
from_created_at?: string;
|
|
2301
|
+
to_created_at?: string;
|
|
2302
|
+
};
|
|
2418
2303
|
};
|
|
2419
2304
|
type Response = {
|
|
2420
2305
|
total: number;
|
|
2421
2306
|
data: Transaction[];
|
|
2422
2307
|
};
|
|
2308
|
+
namespace ExportCsv {
|
|
2309
|
+
type Request = {
|
|
2310
|
+
wallet_uuid: string;
|
|
2311
|
+
status?: WalletTransactionStatus[];
|
|
2312
|
+
from_created_at?: string;
|
|
2313
|
+
to_created_at?: string;
|
|
2314
|
+
};
|
|
2315
|
+
type Response = string;
|
|
2316
|
+
}
|
|
2423
2317
|
}
|
|
2424
2318
|
}
|
|
2425
2319
|
}
|
package/dist/api/wallets.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare const wallets: {
|
|
|
18
18
|
getByUuid: ({ wallet_uuid, uuid, }: API.Wallets.WalletTransactions.GetByUuid.Request) => Promise<API.Wallets.WalletTransactions.DetailedTransaction>;
|
|
19
19
|
};
|
|
20
20
|
csv: {
|
|
21
|
-
getByWalletUuid: (wallet_uuid:
|
|
21
|
+
getByWalletUuid: ({ wallet_uuid, ...params }: API.Wallets.WalletTransactions.TransactionList.ExportCsv.Request) => Promise<API.Wallets.WalletTransactions.TransactionList.ExportCsv.Response>;
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
24
|
};
|
package/dist/api/wallets.js
CHANGED
|
@@ -47,7 +47,10 @@ exports.wallets = {
|
|
|
47
47
|
getByUuid: ({ wallet_uuid, uuid, }) => apiClientFactory_1.apiClientV2.getRequest(`/wallets/${wallet_uuid}/transactions/${uuid}`),
|
|
48
48
|
},
|
|
49
49
|
csv: {
|
|
50
|
-
getByWalletUuid: (
|
|
50
|
+
getByWalletUuid: (_a) => {
|
|
51
|
+
var { wallet_uuid } = _a, params = __rest(_a, ["wallet_uuid"]);
|
|
52
|
+
return apiClientFactory_1.apiClientV2.getRequest(`/wallets/${wallet_uuid}/transactions/export/csv`, { params });
|
|
53
|
+
},
|
|
51
54
|
},
|
|
52
55
|
},
|
|
53
56
|
};
|
package/dist/utils/encrypt.js
CHANGED
|
@@ -27,10 +27,56 @@ const decryptAESData = (encryptedData, iv, secretKey) => __awaiter(void 0, void
|
|
|
27
27
|
return JSON.parse(decrypted);
|
|
28
28
|
});
|
|
29
29
|
exports.decryptAESData = decryptAESData;
|
|
30
|
+
/**
|
|
31
|
+
* Очищает и валидирует публичный RSA ключ
|
|
32
|
+
* Исправляет ошибку InvalidAsn1Error: encoding too long
|
|
33
|
+
* путем удаления лишних символов и нормализации переносов строк
|
|
34
|
+
*/
|
|
35
|
+
const cleanAndValidatePublicKey = (publicKey) => {
|
|
36
|
+
try {
|
|
37
|
+
// Декодируем base64 ключ
|
|
38
|
+
const publicKeyBase64 = Buffer.from(publicKey, 'base64').toString('utf8');
|
|
39
|
+
// Удаляем лишние символы (переносы строк, пробелы в начале и конце)
|
|
40
|
+
// Нормализуем переносы строк для корректной обработки ASN.1
|
|
41
|
+
const cleanedKey = publicKeyBase64.trim().replace(/\r?\n|\r/g, '\n');
|
|
42
|
+
// Проверяем, что ключ содержит необходимые маркеры
|
|
43
|
+
if (!cleanedKey.includes('BEGIN') || !cleanedKey.includes('END')) {
|
|
44
|
+
throw new Error('Invalid public key format: missing BEGIN/END markers');
|
|
45
|
+
}
|
|
46
|
+
return cleanedKey;
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
throw new Error(`Invalid public key format: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Автоматически определяет формат RSA ключа по заголовку
|
|
54
|
+
* Помогает избежать ошибок импорта при неправильном указании формата
|
|
55
|
+
*/
|
|
56
|
+
const detectKeyFormat = (key) => {
|
|
57
|
+
if (key.includes('BEGIN RSA PUBLIC KEY')) {
|
|
58
|
+
return 'pkcs1';
|
|
59
|
+
}
|
|
60
|
+
else if (key.includes('BEGIN PUBLIC KEY')) {
|
|
61
|
+
return 'pkcs8';
|
|
62
|
+
}
|
|
63
|
+
// По умолчанию возвращаем pkcs8, как было ранее
|
|
64
|
+
return 'pkcs8';
|
|
65
|
+
};
|
|
30
66
|
const makeSecureRequest = (_a) => __awaiter(void 0, [_a], void 0, function* ({ callback, publicKey }) {
|
|
31
67
|
const clientRsa = new node_rsa_1.default();
|
|
32
|
-
|
|
33
|
-
|
|
68
|
+
try {
|
|
69
|
+
// Очищаем и валидируем публичный ключ
|
|
70
|
+
const cleanedPublicKey = cleanAndValidatePublicKey(publicKey);
|
|
71
|
+
// Определяем формат ключа автоматически
|
|
72
|
+
const keyFormat = detectKeyFormat(cleanedPublicKey);
|
|
73
|
+
// Импортируем ключ с правильным форматом
|
|
74
|
+
clientRsa.importKey(cleanedPublicKey, `${keyFormat}-public-pem`);
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
78
|
+
throw new Error(`Failed to import RSA public key: ${errorMessage}`);
|
|
79
|
+
}
|
|
34
80
|
const clientSecretKey = (0, exports.generateSecretKey)();
|
|
35
81
|
const clientPayload = {
|
|
36
82
|
key: clientSecretKey.toString('base64'),
|
package/package.json
CHANGED
|
@@ -1238,8 +1238,6 @@ export interface components {
|
|
|
1238
1238
|
TransactionsFilter: {
|
|
1239
1239
|
created_at?: string;
|
|
1240
1240
|
/** @enum {string} */
|
|
1241
|
-
status?: "complete" | "pending" | "canceled" | "failed" | "processing" | "new";
|
|
1242
|
-
/** @enum {string} */
|
|
1243
1241
|
type?: "deposit_crypto" | "withdrawal_crypto" | "deposit_fiat" | "withdrawal_fiat" | "deposit_vcard" | "withdrawal_vcard" | "deposit" | "withdrawal";
|
|
1244
1242
|
/** @enum {string|null} */
|
|
1245
1243
|
method?: "p2p" | "crypto" | "bank_transfer" | "exchange" | "sbp" | "internal_fiat" | null;
|
|
@@ -1256,6 +1254,7 @@ export interface components {
|
|
|
1256
1254
|
to_created_at?: string;
|
|
1257
1255
|
/** @default false */
|
|
1258
1256
|
show_low_balance: boolean;
|
|
1257
|
+
status?: ("complete" | "pending" | "canceled" | "failed" | "processing" | "new")[];
|
|
1259
1258
|
};
|
|
1260
1259
|
ChainDto: {
|
|
1261
1260
|
id: number;
|
|
@@ -2985,7 +2984,9 @@ export interface operations {
|
|
|
2985
2984
|
};
|
|
2986
2985
|
WalletsTransactionsController_export: {
|
|
2987
2986
|
parameters: {
|
|
2988
|
-
query?:
|
|
2987
|
+
query?: {
|
|
2988
|
+
status?: ("complete" | "pending" | "canceled" | "failed" | "processing" | "new")[];
|
|
2989
|
+
};
|
|
2989
2990
|
header?: never;
|
|
2990
2991
|
path: {
|
|
2991
2992
|
wallet_id: string;
|
package/src/api/types/types.ts
CHANGED
|
@@ -819,144 +819,144 @@ export namespace API {
|
|
|
819
819
|
}
|
|
820
820
|
}
|
|
821
821
|
|
|
822
|
-
export namespace SubAccountsV2 {
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
}
|
|
822
|
+
// export namespace SubAccountsV2 {
|
|
823
|
+
// export type SubAccountDetails = {
|
|
824
|
+
// iban: string;
|
|
825
|
+
// bank_name: string;
|
|
826
|
+
// swift_code: string;
|
|
827
|
+
// bank_address: string;
|
|
828
|
+
// receiver_name: string;
|
|
829
|
+
// payment_details: string;
|
|
830
|
+
// reference_number: string;
|
|
831
|
+
// registration_number: string;
|
|
832
|
+
// };
|
|
833
|
+
|
|
834
|
+
// export interface SubAccount {
|
|
835
|
+
// balance: number;
|
|
836
|
+
// cards_count: number;
|
|
837
|
+
// created_at: string;
|
|
838
|
+
// currency: API.Currencies.FiatCurrency;
|
|
839
|
+
// fiat_balance: number;
|
|
840
|
+
// id: string;
|
|
841
|
+
// issuing_program: API.Cards.Config.Program;
|
|
842
|
+
// nick_name: string;
|
|
843
|
+
// program_id: string;
|
|
844
|
+
// realtimeauth_balance: number;
|
|
845
|
+
// status: string;
|
|
846
|
+
// total_balance: number;
|
|
847
|
+
// wallet_id: string;
|
|
848
|
+
// }
|
|
849
|
+
|
|
850
|
+
// export namespace ExtendedSubAccount {
|
|
851
|
+
// export interface ExtendedSubAccount extends SubAccount {
|
|
852
|
+
// account_details?: SubAccountDetails;
|
|
853
|
+
// payment_types: Array<{ order_type: OrderType }>;
|
|
854
|
+
// realtime_auth: [
|
|
855
|
+
// {
|
|
856
|
+
// crypto_token: string;
|
|
857
|
+
// fiat_account: string;
|
|
858
|
+
// id: string;
|
|
859
|
+
// priority: number;
|
|
860
|
+
// }
|
|
861
|
+
// ];
|
|
862
|
+
// }
|
|
863
|
+
// export interface Request {
|
|
864
|
+
// wallet_uuid: string;
|
|
865
|
+
// fiat_account_id: string;
|
|
866
|
+
// }
|
|
867
|
+
|
|
868
|
+
// export type Response = ExtendedSubAccount;
|
|
869
|
+
// }
|
|
870
|
+
|
|
871
|
+
// export interface SubAccountWithCards extends SubAccount {
|
|
872
|
+
// cards: API.Cards.IssuingCardListItem[];
|
|
873
|
+
// }
|
|
874
|
+
|
|
875
|
+
// export interface SubAccountsList<T extends SubAccount | SubAccountWithCards> {
|
|
876
|
+
// count: number;
|
|
877
|
+
// data: T[];
|
|
878
|
+
// }
|
|
879
|
+
|
|
880
|
+
// export type SubAccountsListWithCards = SubAccountsList<SubAccountWithCards>;
|
|
881
|
+
// export type SubAccountsListWithoutCards = SubAccountsList<SubAccount>;
|
|
882
|
+
|
|
883
|
+
// export namespace CreateSubAccount {
|
|
884
|
+
// export interface Request {
|
|
885
|
+
// wallet_id: string;
|
|
886
|
+
// program_id: string;
|
|
887
|
+
// }
|
|
888
|
+
// export type Response = {
|
|
889
|
+
// id: string;
|
|
890
|
+
// balance: number;
|
|
891
|
+
// nick_name: string;
|
|
892
|
+
// wallet_id: string;
|
|
893
|
+
// created_at: string;
|
|
894
|
+
// account_currency: string;
|
|
895
|
+
// type: SubAccountType | string;
|
|
896
|
+
// program_id: string;
|
|
897
|
+
// status: 'ACTIVE';
|
|
898
|
+
// fiat: {
|
|
899
|
+
// code: string;
|
|
900
|
+
// uuid: string;
|
|
901
|
+
// symbol: string;
|
|
902
|
+
// enabled: boolean;
|
|
903
|
+
// coingecko: string;
|
|
904
|
+
// };
|
|
905
|
+
// issuing_program: {
|
|
906
|
+
// id: string;
|
|
907
|
+
// form_factor: CardFormFactor | string;
|
|
908
|
+
// brand: string;
|
|
909
|
+
// tokenizable: boolean;
|
|
910
|
+
// type: CardType | string;
|
|
911
|
+
// };
|
|
912
|
+
// };
|
|
913
|
+
// }
|
|
914
|
+
|
|
915
|
+
// export namespace Transactions {
|
|
916
|
+
// // export type Transaction = API.Cards.TransactionItem;
|
|
917
|
+
// export type Transaction = {
|
|
918
|
+
// vendor_transaction_id: string;
|
|
919
|
+
// created_at: string;
|
|
920
|
+
// cleared_at: string;
|
|
921
|
+
// merchant: {
|
|
922
|
+
// name: string;
|
|
923
|
+
// category_code: string;
|
|
924
|
+
// city: string;
|
|
925
|
+
// country: string;
|
|
926
|
+
// };
|
|
927
|
+
// last4: string;
|
|
928
|
+
// title: string;
|
|
929
|
+
// billing_amount: number;
|
|
930
|
+
// billing_currency: string;
|
|
931
|
+
// transaction_amount: number;
|
|
932
|
+
// transaction_currency: string;
|
|
933
|
+
// vendor_sub_account_id: string;
|
|
934
|
+
// failure_reason: string;
|
|
935
|
+
// status: string;
|
|
936
|
+
// transaction_type: string;
|
|
937
|
+
// is_credit: boolean;
|
|
938
|
+
// has_receipt: boolean;
|
|
939
|
+
// adjustment_type: string;
|
|
940
|
+
// review_status: string;
|
|
941
|
+
// group: string;
|
|
942
|
+
// total_amount: number;
|
|
943
|
+
// };
|
|
944
|
+
|
|
945
|
+
// export namespace TransactionList {
|
|
946
|
+
// export interface Request {
|
|
947
|
+
// fiat_account_id: string;
|
|
948
|
+
// wallet_uuid: string;
|
|
949
|
+
// limit?: number;
|
|
950
|
+
// offset?: number;
|
|
951
|
+
// }
|
|
952
|
+
// export interface Response {
|
|
953
|
+
// count: number;
|
|
954
|
+
// data: Transaction[];
|
|
955
|
+
// has_more: boolean;
|
|
956
|
+
// }
|
|
957
|
+
// }
|
|
958
|
+
// }
|
|
959
|
+
// }
|
|
960
960
|
|
|
961
961
|
export namespace Issuing {
|
|
962
962
|
export namespace Programs {
|
|
@@ -2818,14 +2818,38 @@ export namespace API {
|
|
|
2818
2818
|
}
|
|
2819
2819
|
|
|
2820
2820
|
export namespace TransactionList {
|
|
2821
|
-
export type Request =
|
|
2822
|
-
|
|
2823
|
-
|
|
2821
|
+
export type Request = {
|
|
2822
|
+
wallet_uuid: string;
|
|
2823
|
+
limit: number;
|
|
2824
|
+
offset: number;
|
|
2825
|
+
filter?: {
|
|
2826
|
+
created_at?: string;
|
|
2827
|
+
status?: WalletTransactionStatus[];
|
|
2828
|
+
type?: WalletTransactionType;
|
|
2829
|
+
method?: WalletTransactionMethod;
|
|
2830
|
+
record_type?: WalletTransactionRecordType;
|
|
2831
|
+
'currency.uuid'?: string;
|
|
2832
|
+
'meta.billing_amount_currency'?: string;
|
|
2833
|
+
'meta.transaction_amount_currency'?: string;
|
|
2834
|
+
address?: string;
|
|
2835
|
+
from_created_at?: string;
|
|
2836
|
+
to_created_at?: string;
|
|
2824
2837
|
};
|
|
2838
|
+
};
|
|
2825
2839
|
export type Response = {
|
|
2826
2840
|
total: number;
|
|
2827
2841
|
data: Transaction[];
|
|
2828
2842
|
};
|
|
2843
|
+
|
|
2844
|
+
export namespace ExportCsv {
|
|
2845
|
+
export type Request = {
|
|
2846
|
+
wallet_uuid: string;
|
|
2847
|
+
status?: WalletTransactionStatus[];
|
|
2848
|
+
from_created_at?: string;
|
|
2849
|
+
to_created_at?: string;
|
|
2850
|
+
};
|
|
2851
|
+
export type Response = string;
|
|
2852
|
+
}
|
|
2829
2853
|
}
|
|
2830
2854
|
}
|
|
2831
2855
|
}
|
package/src/api/wallets.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { API } from './types/types';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { apiClientV2 } from '../utils/apiClientFactory';
|
|
4
4
|
|
|
5
5
|
import { defaultPaginationParams, WalletTypeValues } from '../constants';
|
|
6
6
|
|
|
@@ -52,8 +52,14 @@ export const wallets = {
|
|
|
52
52
|
),
|
|
53
53
|
},
|
|
54
54
|
csv: {
|
|
55
|
-
getByWalletUuid: (
|
|
56
|
-
|
|
55
|
+
getByWalletUuid: ({
|
|
56
|
+
wallet_uuid,
|
|
57
|
+
...params
|
|
58
|
+
}: API.Wallets.WalletTransactions.TransactionList.ExportCsv.Request): Promise<API.Wallets.WalletTransactions.TransactionList.ExportCsv.Response> =>
|
|
59
|
+
apiClientV2.getRequest<API.Wallets.WalletTransactions.TransactionList.ExportCsv.Response>(
|
|
60
|
+
`/wallets/${wallet_uuid}/transactions/export/csv`,
|
|
61
|
+
{ params }
|
|
62
|
+
),
|
|
57
63
|
},
|
|
58
64
|
},
|
|
59
65
|
};
|
package/src/utils/encrypt.ts
CHANGED
|
@@ -20,11 +20,61 @@ export const decryptAESData = async (encryptedData: string, iv: string, secretKe
|
|
|
20
20
|
return JSON.parse(decrypted);
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Очищает и валидирует публичный RSA ключ
|
|
25
|
+
* Исправляет ошибку InvalidAsn1Error: encoding too long
|
|
26
|
+
* путем удаления лишних символов и нормализации переносов строк
|
|
27
|
+
*/
|
|
28
|
+
const cleanAndValidatePublicKey = (publicKey: string): string => {
|
|
29
|
+
try {
|
|
30
|
+
// Декодируем base64 ключ
|
|
31
|
+
const publicKeyBase64 = Buffer.from(publicKey, 'base64').toString('utf8');
|
|
32
|
+
|
|
33
|
+
// Удаляем лишние символы (переносы строк, пробелы в начале и конце)
|
|
34
|
+
// Нормализуем переносы строк для корректной обработки ASN.1
|
|
35
|
+
const cleanedKey = publicKeyBase64.trim().replace(/\r?\n|\r/g, '\n');
|
|
36
|
+
|
|
37
|
+
// Проверяем, что ключ содержит необходимые маркеры
|
|
38
|
+
if (!cleanedKey.includes('BEGIN') || !cleanedKey.includes('END')) {
|
|
39
|
+
throw new Error('Invalid public key format: missing BEGIN/END markers');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return cleanedKey;
|
|
43
|
+
} catch (error) {
|
|
44
|
+
throw new Error(`Invalid public key format: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Автоматически определяет формат RSA ключа по заголовку
|
|
50
|
+
* Помогает избежать ошибок импорта при неправильном указании формата
|
|
51
|
+
*/
|
|
52
|
+
const detectKeyFormat = (key: string): 'pkcs1' | 'pkcs8' => {
|
|
53
|
+
if (key.includes('BEGIN RSA PUBLIC KEY')) {
|
|
54
|
+
return 'pkcs1';
|
|
55
|
+
} else if (key.includes('BEGIN PUBLIC KEY')) {
|
|
56
|
+
return 'pkcs8';
|
|
57
|
+
}
|
|
58
|
+
// По умолчанию возвращаем pkcs8, как было ранее
|
|
59
|
+
return 'pkcs8';
|
|
60
|
+
};
|
|
61
|
+
|
|
23
62
|
export const makeSecureRequest = async <T>({ callback, publicKey }: MakeSecureRequestParams): Promise<T> => {
|
|
24
63
|
const clientRsa = new NodeRSA();
|
|
25
64
|
|
|
26
|
-
|
|
27
|
-
|
|
65
|
+
try {
|
|
66
|
+
// Очищаем и валидируем публичный ключ
|
|
67
|
+
const cleanedPublicKey = cleanAndValidatePublicKey(publicKey);
|
|
68
|
+
|
|
69
|
+
// Определяем формат ключа автоматически
|
|
70
|
+
const keyFormat = detectKeyFormat(cleanedPublicKey);
|
|
71
|
+
|
|
72
|
+
// Импортируем ключ с правильным форматом
|
|
73
|
+
clientRsa.importKey(cleanedPublicKey, `${keyFormat}-public-pem`);
|
|
74
|
+
} catch (error) {
|
|
75
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
76
|
+
throw new Error(`Failed to import RSA public key: ${errorMessage}`);
|
|
77
|
+
}
|
|
28
78
|
|
|
29
79
|
const clientSecretKey = generateSecretKey();
|
|
30
80
|
const clientPayload = {
|