@riocrypto/common-server 1.0.1082 → 1.0.1084
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AxiosRequestConfig } from "axios";
|
|
2
|
+
import { BankAccount, User } from "@riocrypto/common";
|
|
2
3
|
declare class BitsoClient {
|
|
3
4
|
private apiKey;
|
|
4
5
|
private apiSecret;
|
|
@@ -6,7 +7,7 @@ declare class BitsoClient {
|
|
|
6
7
|
private baseUrl;
|
|
7
8
|
constructor(apiKey: string, apiSecret: string, env: "production" | "sandbox");
|
|
8
9
|
createClabe(): Promise<string>;
|
|
9
|
-
createReceivingAccount(): Promise<string>;
|
|
10
|
+
createReceivingAccount(user: User, bankAccount: BankAccount, bitsoBankCode: string): Promise<string>;
|
|
10
11
|
signRequest(requestConfig: AxiosRequestConfig): AxiosRequestConfig;
|
|
11
12
|
}
|
|
12
13
|
export declare const buildBistoClient: () => Promise<BitsoClient>;
|
|
@@ -41,7 +41,7 @@ class BitsoClient {
|
|
|
41
41
|
return data.payload.clabe;
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
|
-
createReceivingAccount() {
|
|
44
|
+
createReceivingAccount(user, bankAccount, bitsoBankCode) {
|
|
45
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46
46
|
const requestConfig = {
|
|
47
47
|
method: "POST",
|
|
@@ -50,7 +50,9 @@ class BitsoClient {
|
|
|
50
50
|
"Content-Type": "application/json",
|
|
51
51
|
},
|
|
52
52
|
data: {
|
|
53
|
-
alias:
|
|
53
|
+
alias: `CLABE for ${user.type === common_1.UserType.Business
|
|
54
|
+
? user.companyName
|
|
55
|
+
: user.firstName + " " + user.lastName} - ${user.id}`,
|
|
54
56
|
currency: "mxn",
|
|
55
57
|
taxonomy: {
|
|
56
58
|
network: "spei",
|
|
@@ -59,9 +61,9 @@ class BitsoClient {
|
|
|
59
61
|
integration: "stp",
|
|
60
62
|
},
|
|
61
63
|
details: {
|
|
62
|
-
beneficiary:
|
|
63
|
-
institution_code:
|
|
64
|
-
clabe:
|
|
64
|
+
beneficiary: bankAccount.accountHolderName,
|
|
65
|
+
institution_code: bitsoBankCode,
|
|
66
|
+
clabe: bankAccount.accountNumber,
|
|
65
67
|
},
|
|
66
68
|
},
|
|
67
69
|
};
|
|
@@ -73,22 +75,15 @@ class BitsoClient {
|
|
|
73
75
|
signRequest(requestConfig) {
|
|
74
76
|
var _a;
|
|
75
77
|
const url = new URL(requestConfig.url || "");
|
|
76
|
-
console.log("url", url);
|
|
77
78
|
const requestPath = url.pathname + (url.search || "");
|
|
78
|
-
|
|
79
|
-
const payload = requestConfig.data || "";
|
|
80
|
-
console.log("payload", payload);
|
|
79
|
+
const payload = JSON.stringify(requestConfig.data) || "";
|
|
81
80
|
const nonce = new Date().getTime().toString();
|
|
82
|
-
console.log("nonce", nonce);
|
|
83
81
|
const data = nonce +
|
|
84
82
|
(((_a = requestConfig.method) === null || _a === void 0 ? void 0 : _a.toUpperCase()) || "") +
|
|
85
83
|
requestPath +
|
|
86
84
|
payload;
|
|
87
|
-
console.log("data", data);
|
|
88
85
|
const signature = crypto_js_1.default.HmacSHA256(data, this.apiSecret).toString(crypto_js_1.default.enc.Hex);
|
|
89
|
-
console.log("signature", signature);
|
|
90
86
|
const authHeader = `Bitso ${this.apiKey}:${nonce}:${signature}`;
|
|
91
|
-
console.log("authHeader", authHeader);
|
|
92
87
|
if (!requestConfig.headers) {
|
|
93
88
|
requestConfig.headers = {};
|
|
94
89
|
}
|
|
@@ -11,6 +11,7 @@ interface BankAccountAttrs {
|
|
|
11
11
|
approved: boolean;
|
|
12
12
|
swiftCode?: string;
|
|
13
13
|
notes?: string;
|
|
14
|
+
bitsoBankCode?: string;
|
|
14
15
|
}
|
|
15
16
|
interface BankAccountDoc extends Document {
|
|
16
17
|
createdAt: Date;
|
|
@@ -23,6 +24,7 @@ interface BankAccountDoc extends Document {
|
|
|
23
24
|
approved: boolean;
|
|
24
25
|
swiftCode?: string;
|
|
25
26
|
notes?: string;
|
|
27
|
+
bitsoBankCode?: string;
|
|
26
28
|
}
|
|
27
29
|
interface BankAccountModel extends Model<BankAccountDoc> {
|
|
28
30
|
build(attrs: BankAccountAttrs): BankAccountDoc;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riocrypto/common-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1084",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@aws-sdk/client-s3": "^3.297.0",
|
|
26
26
|
"@everapi/currencyapi-js": "^1.0.6",
|
|
27
27
|
"@google-cloud/storage": "^6.9.5",
|
|
28
|
-
"@riocrypto/common": "^1.0.
|
|
28
|
+
"@riocrypto/common": "^1.0.922",
|
|
29
29
|
"@types/express": "^4.17.13",
|
|
30
30
|
"axios": "^0.27.2",
|
|
31
31
|
"ccxt": "^3.0.30",
|