ggez-banking-sdk 0.1.147 → 0.1.149
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/services/blockchain.js +5 -5
- package/dist/api/services/limited.js +5 -5
- package/dist/constants/constants.d.ts +23 -18
- package/dist/constants/constants.js +30 -18
- package/dist/helper/cipherHelper.js +34 -17
- package/dist/helper/cookiesHelper.d.ts +1 -1
- package/dist/helper/cookiesHelper.js +7 -3
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Endpoints } from "../../constants";
|
|
1
|
+
import { BlockchainEndpoints, Endpoints } from "../../constants";
|
|
2
2
|
import { BaseService } from "./base";
|
|
3
3
|
class BlockchainService extends BaseService {
|
|
4
4
|
endpoint = Endpoints.Blockchain;
|
|
@@ -7,19 +7,19 @@ class BlockchainService extends BaseService {
|
|
|
7
7
|
}
|
|
8
8
|
// #region "POST"
|
|
9
9
|
async send(payload) {
|
|
10
|
-
const url = this.resolveURL();
|
|
10
|
+
const url = this.resolveURL(BlockchainEndpoints.Send);
|
|
11
11
|
return this.POST(url, payload);
|
|
12
12
|
}
|
|
13
13
|
async multiSend(payload) {
|
|
14
|
-
const url = this.resolveURL();
|
|
14
|
+
const url = this.resolveURL(BlockchainEndpoints.MultiSend);
|
|
15
15
|
return this.POST(url, payload);
|
|
16
16
|
}
|
|
17
17
|
async delegate(payload) {
|
|
18
|
-
const url = this.resolveURL();
|
|
18
|
+
const url = this.resolveURL(BlockchainEndpoints.Delegate);
|
|
19
19
|
return this.POST(url, payload);
|
|
20
20
|
}
|
|
21
21
|
async undelegate(payload) {
|
|
22
|
-
const url = this.resolveURL();
|
|
22
|
+
const url = this.resolveURL(BlockchainEndpoints.Undelegate);
|
|
23
23
|
return this.POST(url, payload);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -23,23 +23,23 @@ class LimitedService extends BaseService {
|
|
|
23
23
|
}
|
|
24
24
|
// #region "POST"
|
|
25
25
|
async validateForgetSecurityData(data) {
|
|
26
|
-
const url = this.resolveURL(
|
|
26
|
+
const url = this.resolveURL(LimitedEndpoints.SecurityForgetValidate);
|
|
27
27
|
return await this.POST(url, data);
|
|
28
28
|
}
|
|
29
29
|
async confirmForgetSecurityData(data) {
|
|
30
|
-
const url = this.resolveURL(
|
|
30
|
+
const url = this.resolveURL(LimitedEndpoints.SecurityForgetConfirm);
|
|
31
31
|
return await this.POST(url, data);
|
|
32
32
|
}
|
|
33
33
|
async validateSecurityData(data) {
|
|
34
|
-
const url = this.resolveURL(
|
|
34
|
+
const url = this.resolveURL(LimitedEndpoints.SecurityValidate);
|
|
35
35
|
return await this.POST(url, data);
|
|
36
36
|
}
|
|
37
37
|
async verifySecurityData(data) {
|
|
38
|
-
const url = this.resolveURL(
|
|
38
|
+
const url = this.resolveURL(LimitedEndpoints.SecurityVerify);
|
|
39
39
|
return await this.POST(url, data);
|
|
40
40
|
}
|
|
41
41
|
async confirmSecurityData(data) {
|
|
42
|
-
const url = this.resolveURL(
|
|
42
|
+
const url = this.resolveURL(LimitedEndpoints.SecurityConfirm);
|
|
43
43
|
return await this.POST(url, data);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
declare const Endpoints: {
|
|
2
|
-
readonly Blockchain: "v1/blockchain";
|
|
3
2
|
readonly Account: "v1/account";
|
|
4
|
-
readonly Transaction: "v1/transaction";
|
|
5
|
-
readonly Promotion: "api/promotion";
|
|
6
|
-
readonly User: "v1/user";
|
|
7
|
-
readonly Organization: "v1/organization";
|
|
8
|
-
readonly Order: "v1/order";
|
|
9
|
-
readonly LimitedSecurity: "v1/limited/security";
|
|
10
|
-
readonly Limited: "v1/limited";
|
|
11
3
|
readonly Auth: "oauth/token";
|
|
4
|
+
readonly Blockchain: "v1/blockchain";
|
|
12
5
|
readonly IPAddress: "v1/myipaddress";
|
|
6
|
+
readonly Limited: "v1/limited";
|
|
7
|
+
readonly Order: "v1/order";
|
|
8
|
+
readonly Organization: "v1/organization";
|
|
9
|
+
readonly Promotion: "api/promotion";
|
|
10
|
+
readonly Transaction: "v1/transaction";
|
|
11
|
+
readonly User: "v1/user";
|
|
13
12
|
};
|
|
14
13
|
declare const AccountEndpoints: {
|
|
15
14
|
Limits: string;
|
|
16
15
|
};
|
|
16
|
+
declare const BlockchainEndpoints: {
|
|
17
|
+
readonly Send: "/send";
|
|
18
|
+
readonly MultiSend: "/multisend";
|
|
19
|
+
readonly Delegate: "/delegate";
|
|
20
|
+
readonly Undelegate: "/undelegate";
|
|
21
|
+
};
|
|
17
22
|
declare const LimitedEndpoints: {
|
|
18
23
|
readonly Security: "/security";
|
|
19
24
|
readonly SecurityValidate: "/security/validate";
|
|
@@ -63,11 +68,10 @@ declare const UserEndpoints: {
|
|
|
63
68
|
readonly AuthDelete: "/auth/delete";
|
|
64
69
|
readonly HistoryLatest: "/history/latest";
|
|
65
70
|
};
|
|
66
|
-
declare const
|
|
67
|
-
readonly
|
|
68
|
-
readonly
|
|
69
|
-
readonly
|
|
70
|
-
readonly DELETE: "DELETE";
|
|
71
|
+
declare const GrantType: {
|
|
72
|
+
readonly UserCredential: "user_credential";
|
|
73
|
+
readonly DeviceCredential: "device_credential";
|
|
74
|
+
readonly LimitedCredential: "limited_credential";
|
|
71
75
|
};
|
|
72
76
|
declare const HeaderKeys: {
|
|
73
77
|
readonly Authorization: "Authorization";
|
|
@@ -82,10 +86,11 @@ declare const HeaderKeys: {
|
|
|
82
86
|
readonly GenerateJwt: "generate_jwt";
|
|
83
87
|
readonly AllowControlAllowCredentials: "Allow-Control-Allow-Credentials";
|
|
84
88
|
};
|
|
85
|
-
declare const
|
|
86
|
-
readonly
|
|
87
|
-
readonly
|
|
88
|
-
readonly
|
|
89
|
+
declare const HTTPMethod: {
|
|
90
|
+
readonly GET: "GET";
|
|
91
|
+
readonly POST: "POST";
|
|
92
|
+
readonly PUT: "PUT";
|
|
93
|
+
readonly DELETE: "DELETE";
|
|
89
94
|
};
|
|
90
95
|
declare const CookieKeys: {
|
|
91
96
|
readonly DEK: "DEK";
|
|
@@ -94,4 +99,4 @@ declare const CookieKeys: {
|
|
|
94
99
|
readonly access_token: "access_token";
|
|
95
100
|
readonly jwt_token: "jwt_token";
|
|
96
101
|
};
|
|
97
|
-
export {
|
|
102
|
+
export { Endpoints, AccountEndpoints, BlockchainEndpoints, LimitedEndpoints, OrganizationEndpoints, TransactionEndpoints, UserEndpoints, GrantType, HeaderKeys, HTTPMethod, CookieKeys, };
|
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
// #region "Endpoints"
|
|
2
2
|
const Endpoints = {
|
|
3
|
-
Blockchain: "v1/blockchain",
|
|
4
3
|
Account: "v1/account",
|
|
5
|
-
Transaction: "v1/transaction",
|
|
6
|
-
Promotion: "api/promotion",
|
|
7
|
-
User: "v1/user",
|
|
8
|
-
Organization: "v1/organization",
|
|
9
|
-
Order: "v1/order",
|
|
10
|
-
LimitedSecurity: "v1/limited/security",
|
|
11
|
-
Limited: "v1/limited",
|
|
12
4
|
Auth: "oauth/token",
|
|
5
|
+
Blockchain: "v1/blockchain",
|
|
13
6
|
IPAddress: "v1/myipaddress",
|
|
7
|
+
Limited: "v1/limited",
|
|
8
|
+
Order: "v1/order",
|
|
9
|
+
Organization: "v1/organization",
|
|
10
|
+
Promotion: "api/promotion",
|
|
11
|
+
Transaction: "v1/transaction",
|
|
12
|
+
User: "v1/user",
|
|
14
13
|
};
|
|
15
14
|
const AccountEndpoints = {
|
|
16
15
|
Limits: "/limits",
|
|
17
16
|
};
|
|
17
|
+
const BlockchainEndpoints = {
|
|
18
|
+
Send: "/send",
|
|
19
|
+
MultiSend: "/multisend",
|
|
20
|
+
Delegate: "/delegate",
|
|
21
|
+
Undelegate: "/undelegate",
|
|
22
|
+
};
|
|
18
23
|
const LimitedEndpoints = {
|
|
19
24
|
Security: "/security",
|
|
20
25
|
SecurityValidate: "/security/validate",
|
|
@@ -66,11 +71,10 @@ const UserEndpoints = {
|
|
|
66
71
|
};
|
|
67
72
|
// #endregion
|
|
68
73
|
// #region "API"
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
DELETE: "DELETE",
|
|
74
|
+
const GrantType = {
|
|
75
|
+
UserCredential: "user_credential",
|
|
76
|
+
DeviceCredential: "device_credential",
|
|
77
|
+
LimitedCredential: "limited_credential",
|
|
74
78
|
};
|
|
75
79
|
const HeaderKeys = {
|
|
76
80
|
Authorization: "Authorization",
|
|
@@ -85,10 +89,11 @@ const HeaderKeys = {
|
|
|
85
89
|
GenerateJwt: "generate_jwt",
|
|
86
90
|
AllowControlAllowCredentials: "Allow-Control-Allow-Credentials",
|
|
87
91
|
};
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
const HTTPMethod = {
|
|
93
|
+
GET: "GET",
|
|
94
|
+
POST: "POST",
|
|
95
|
+
PUT: "PUT",
|
|
96
|
+
DELETE: "DELETE",
|
|
92
97
|
};
|
|
93
98
|
// #endregion
|
|
94
99
|
// #region "Cookies"
|
|
@@ -100,4 +105,11 @@ const CookieKeys = {
|
|
|
100
105
|
jwt_token: "jwt_token",
|
|
101
106
|
};
|
|
102
107
|
// #endregion
|
|
103
|
-
export {
|
|
108
|
+
export {
|
|
109
|
+
// #region "Endpoints"
|
|
110
|
+
Endpoints, AccountEndpoints, BlockchainEndpoints, LimitedEndpoints, OrganizationEndpoints, TransactionEndpoints, UserEndpoints,
|
|
111
|
+
// #endregion
|
|
112
|
+
// #region "API"
|
|
113
|
+
GrantType, HeaderKeys, HTTPMethod,
|
|
114
|
+
// #endregion
|
|
115
|
+
CookieKeys, };
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { createCipheriv, createDecipheriv } from "crypto";
|
|
2
2
|
class CipherHelper {
|
|
3
3
|
static Encrypt = (plainText, key, iv) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
try {
|
|
5
|
+
const keyBuffer = Buffer.from(key, "utf8");
|
|
6
|
+
const ivBuffer = Buffer.from(iv, "utf8");
|
|
7
|
+
const cipher = createCipheriv("aes-256-cbc", keyBuffer, ivBuffer);
|
|
8
|
+
let encrypted = cipher.update(plainText, "utf8", "base64");
|
|
9
|
+
encrypted += cipher.final("base64");
|
|
10
|
+
return encrypted;
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
console.error(error + " CipherHelper.Encrypt");
|
|
14
|
+
return "";
|
|
15
|
+
}
|
|
10
16
|
};
|
|
11
17
|
static Decrypt = (cipherText, key, iv) => {
|
|
12
18
|
try {
|
|
@@ -23,7 +29,6 @@ class CipherHelper {
|
|
|
23
29
|
catch (error) {
|
|
24
30
|
console.error(error + " CipherHelper.Decrypt");
|
|
25
31
|
return "";
|
|
26
|
-
// return JSON.stringify(error);
|
|
27
32
|
}
|
|
28
33
|
};
|
|
29
34
|
static Generate = (code) => {
|
|
@@ -35,7 +40,7 @@ class CipherHelper {
|
|
|
35
40
|
return { key: KEY, iv: IV };
|
|
36
41
|
}
|
|
37
42
|
catch (error) {
|
|
38
|
-
console.error(error);
|
|
43
|
+
console.error(error + " CipherHelper.Generate");
|
|
39
44
|
return { key: "", iv: "" };
|
|
40
45
|
}
|
|
41
46
|
};
|
|
@@ -57,7 +62,7 @@ class CipherHelper {
|
|
|
57
62
|
return { key: KEY, iv: IV };
|
|
58
63
|
}
|
|
59
64
|
catch (error) {
|
|
60
|
-
console.error(error);
|
|
65
|
+
console.error(error + " CipherHelper.GenerateByUSRAndIID");
|
|
61
66
|
return { key: "", iv: "" };
|
|
62
67
|
}
|
|
63
68
|
};
|
|
@@ -77,14 +82,20 @@ class CipherHelper {
|
|
|
77
82
|
return { key: KEY, iv: IV };
|
|
78
83
|
}
|
|
79
84
|
catch (error) {
|
|
80
|
-
console.error(error);
|
|
85
|
+
console.error(error + " CipherHelper.GenerateByProgramID");
|
|
81
86
|
return { key: "", iv: "" };
|
|
82
87
|
}
|
|
83
88
|
};
|
|
84
89
|
static GenerateByUserID = (user_id) => {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
90
|
+
try {
|
|
91
|
+
const UID_KEY = this.PaddingLeft(user_id.toString(), 32, "0");
|
|
92
|
+
const UID_IV = this.PaddingLeft(user_id.toString(), 16, "0");
|
|
93
|
+
return { key: UID_KEY, iv: UID_IV };
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
console.error(error + " CipherHelper.GenerateByUserID");
|
|
97
|
+
return { key: "", iv: "" };
|
|
98
|
+
}
|
|
88
99
|
};
|
|
89
100
|
static GenerateByInstallationID = (IID) => {
|
|
90
101
|
try {
|
|
@@ -96,14 +107,20 @@ class CipherHelper {
|
|
|
96
107
|
return { key: IID_KEY, iv: IID_IV };
|
|
97
108
|
}
|
|
98
109
|
catch (error) {
|
|
99
|
-
console.error(error);
|
|
110
|
+
console.error(error + " CipherHelper.GenerateByInstallationID");
|
|
100
111
|
return { key: "", iv: "" };
|
|
101
112
|
}
|
|
102
113
|
};
|
|
103
114
|
static PaddingLeft = (value, length, paddingChar) => {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
115
|
+
try {
|
|
116
|
+
if (value.length >= length)
|
|
117
|
+
return value;
|
|
118
|
+
return paddingChar.repeat(length - value.length) + value;
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
console.error(error + " CipherHelper.PaddingLeft");
|
|
122
|
+
return "";
|
|
123
|
+
}
|
|
107
124
|
};
|
|
108
125
|
}
|
|
109
126
|
export { CipherHelper };
|
|
@@ -17,7 +17,7 @@ declare class CookiesHelper {
|
|
|
17
17
|
static SetJWTToken: (jwtToken: string) => void;
|
|
18
18
|
static ValidateJWTToken: (jwtToken: string) => string;
|
|
19
19
|
static GetUserData: () => UserData;
|
|
20
|
-
static SetUserData: (
|
|
20
|
+
static SetUserData: (userData: UserData) => void;
|
|
21
21
|
static GET: (key: string) => string | undefined;
|
|
22
22
|
static SET: (key: string, value: string, expires?: Date) => void;
|
|
23
23
|
static REMOVE: (key: string) => void;
|
|
@@ -233,17 +233,21 @@ class CookiesHelper {
|
|
|
233
233
|
const { key, iv } = CipherHelper.GenerateByInstallationID(IID);
|
|
234
234
|
const userData = this.GET("CUD");
|
|
235
235
|
const decryptedUserData = CipherHelper.Decrypt(userData, key, iv);
|
|
236
|
-
|
|
236
|
+
if (decryptedUserData) {
|
|
237
|
+
return JSON.parse(decryptedUserData);
|
|
238
|
+
}
|
|
239
|
+
return null;
|
|
237
240
|
}
|
|
238
241
|
catch (error) {
|
|
239
242
|
console.error(error);
|
|
240
243
|
}
|
|
241
244
|
};
|
|
242
|
-
static SetUserData = (
|
|
245
|
+
static SetUserData = (userData) => {
|
|
243
246
|
try {
|
|
244
247
|
const IID = this.GetIID();
|
|
245
248
|
const { key, iv } = CipherHelper.GenerateByInstallationID(IID);
|
|
246
|
-
const
|
|
249
|
+
const data = JSON.stringify(userData);
|
|
250
|
+
const encryptedUserData = CipherHelper.Encrypt(data, key, iv);
|
|
247
251
|
this.SET("CUD", encryptedUserData);
|
|
248
252
|
}
|
|
249
253
|
catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ggez-banking-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.149",
|
|
4
4
|
"description": "A Node.js package to handle GGEZ Banking API endpoints, Simplify the process of managing CRUD operations with this efficient and easy-to-use package.",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|