ggez-banking-sdk 0.1.143 → 0.1.145
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/transaction.js +2 -2
- package/dist/constants/constants.d.ts +19 -12
- package/dist/constants/constants.js +26 -13
- package/dist/constants/structure.js +2 -0
- package/dist/helper/cipherHelper.js +3 -0
- package/dist/helper/cookiesHelper.d.ts +6 -1
- package/dist/helper/cookiesHelper.js +70 -7
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Endpoints } from "../../constants";
|
|
1
|
+
import { Endpoints, TransactionEndpoints } from "../../constants";
|
|
2
2
|
import { BaseService } from "./base";
|
|
3
3
|
import { IPAddressAndLocationService } from "..";
|
|
4
4
|
import { GeoHelper } from "../../helper";
|
|
@@ -16,7 +16,7 @@ class TransactionService extends BaseService {
|
|
|
16
16
|
}
|
|
17
17
|
// #region "GET"
|
|
18
18
|
async inquiry(payload) {
|
|
19
|
-
const url = this.resolveURL(
|
|
19
|
+
const url = this.resolveURL(TransactionEndpoints.Inquiry);
|
|
20
20
|
return this.GET(url, payload);
|
|
21
21
|
}
|
|
22
22
|
// #endregion
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
declare const HTTPMethod: {
|
|
2
|
-
readonly GET: "GET";
|
|
3
|
-
readonly POST: "POST";
|
|
4
|
-
readonly PUT: "PUT";
|
|
5
|
-
readonly DELETE: "DELETE";
|
|
6
|
-
};
|
|
7
1
|
declare const Endpoints: {
|
|
8
2
|
readonly Blockchain: "v1/blockchain";
|
|
9
3
|
readonly Account: "v1/account";
|
|
@@ -17,9 +11,6 @@ declare const Endpoints: {
|
|
|
17
11
|
readonly Auth: "oauth/token";
|
|
18
12
|
readonly IPAddress: "v1/myipaddress";
|
|
19
13
|
};
|
|
20
|
-
declare const TransactionEndpoints: {
|
|
21
|
-
readonly Inquiry: "/inquiry";
|
|
22
|
-
};
|
|
23
14
|
declare const AccountEndpoints: {
|
|
24
15
|
Limits: string;
|
|
25
16
|
};
|
|
@@ -31,6 +22,12 @@ declare const LimitedEndpoints: {
|
|
|
31
22
|
readonly SecurityForgetValidate: "/security/forget/validate";
|
|
32
23
|
readonly SecurityForgetConfirm: "/security/forget/confirm";
|
|
33
24
|
};
|
|
25
|
+
declare const TransactionEndpoints: {
|
|
26
|
+
readonly Inquiry: "/inquiry";
|
|
27
|
+
};
|
|
28
|
+
declare const OrganizationEndpoints: {
|
|
29
|
+
Document: string;
|
|
30
|
+
};
|
|
34
31
|
declare const UserEndpoints: {
|
|
35
32
|
readonly Preferences: "/preferences";
|
|
36
33
|
readonly TermsAndConditions: "/terms_and_conditions";
|
|
@@ -66,8 +63,11 @@ declare const UserEndpoints: {
|
|
|
66
63
|
readonly AuthDelete: "/auth/delete";
|
|
67
64
|
readonly HistoryLatest: "/history/latest";
|
|
68
65
|
};
|
|
69
|
-
declare const
|
|
70
|
-
|
|
66
|
+
declare const HTTPMethod: {
|
|
67
|
+
readonly GET: "GET";
|
|
68
|
+
readonly POST: "POST";
|
|
69
|
+
readonly PUT: "PUT";
|
|
70
|
+
readonly DELETE: "DELETE";
|
|
71
71
|
};
|
|
72
72
|
declare const HeaderKeys: {
|
|
73
73
|
readonly Authorization: "Authorization";
|
|
@@ -87,4 +87,11 @@ declare const GrantType: {
|
|
|
87
87
|
readonly DeviceCredential: "device_credential";
|
|
88
88
|
readonly LimitedCredential: "limited_credential";
|
|
89
89
|
};
|
|
90
|
-
|
|
90
|
+
declare const CookieKeys: {
|
|
91
|
+
readonly DEK: "DEK";
|
|
92
|
+
readonly USR: "USR";
|
|
93
|
+
readonly IID: "IID";
|
|
94
|
+
readonly access_token: "access_token";
|
|
95
|
+
readonly jwt_token: "jwt_token";
|
|
96
|
+
};
|
|
97
|
+
export { HTTPMethod, HeaderKeys, Endpoints, UserEndpoints, TransactionEndpoints, AccountEndpoints, OrganizationEndpoints, LimitedEndpoints, GrantType, CookieKeys, };
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
GET: "GET",
|
|
3
|
-
POST: "POST",
|
|
4
|
-
PUT: "PUT",
|
|
5
|
-
DELETE: "DELETE",
|
|
6
|
-
};
|
|
1
|
+
// #region "Endpoints"
|
|
7
2
|
const Endpoints = {
|
|
8
3
|
Blockchain: "v1/blockchain",
|
|
9
4
|
Account: "v1/account",
|
|
10
5
|
Transaction: "v1/transaction",
|
|
11
|
-
Promotion: "api/promotion",
|
|
6
|
+
Promotion: "api/promotion",
|
|
12
7
|
User: "v1/user",
|
|
13
8
|
Organization: "v1/organization",
|
|
14
9
|
Order: "v1/order",
|
|
@@ -17,9 +12,6 @@ const Endpoints = {
|
|
|
17
12
|
Auth: "oauth/token",
|
|
18
13
|
IPAddress: "v1/myipaddress",
|
|
19
14
|
};
|
|
20
|
-
const TransactionEndpoints = {
|
|
21
|
-
Inquiry: "/inquiry",
|
|
22
|
-
};
|
|
23
15
|
const AccountEndpoints = {
|
|
24
16
|
Limits: "/limits",
|
|
25
17
|
};
|
|
@@ -31,6 +23,12 @@ const LimitedEndpoints = {
|
|
|
31
23
|
SecurityForgetValidate: "/security/forget/validate",
|
|
32
24
|
SecurityForgetConfirm: "/security/forget/confirm",
|
|
33
25
|
};
|
|
26
|
+
const TransactionEndpoints = {
|
|
27
|
+
Inquiry: "/inquiry",
|
|
28
|
+
};
|
|
29
|
+
const OrganizationEndpoints = {
|
|
30
|
+
Document: "/document",
|
|
31
|
+
};
|
|
34
32
|
const UserEndpoints = {
|
|
35
33
|
Preferences: "/preferences",
|
|
36
34
|
TermsAndConditions: "/terms_and_conditions",
|
|
@@ -66,8 +64,13 @@ const UserEndpoints = {
|
|
|
66
64
|
AuthDelete: "/auth/delete",
|
|
67
65
|
HistoryLatest: "/history/latest",
|
|
68
66
|
};
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
// #endregion
|
|
68
|
+
// #region "API"
|
|
69
|
+
const HTTPMethod = {
|
|
70
|
+
GET: "GET",
|
|
71
|
+
POST: "POST",
|
|
72
|
+
PUT: "PUT",
|
|
73
|
+
DELETE: "DELETE",
|
|
71
74
|
};
|
|
72
75
|
const HeaderKeys = {
|
|
73
76
|
Authorization: "Authorization",
|
|
@@ -87,4 +90,14 @@ const GrantType = {
|
|
|
87
90
|
DeviceCredential: "device_credential",
|
|
88
91
|
LimitedCredential: "limited_credential",
|
|
89
92
|
};
|
|
90
|
-
|
|
93
|
+
// #endregion
|
|
94
|
+
// #region "Cookies"
|
|
95
|
+
const CookieKeys = {
|
|
96
|
+
DEK: "DEK",
|
|
97
|
+
USR: "USR",
|
|
98
|
+
IID: "IID",
|
|
99
|
+
access_token: "access_token",
|
|
100
|
+
jwt_token: "jwt_token",
|
|
101
|
+
};
|
|
102
|
+
// #endregion
|
|
103
|
+
export { HTTPMethod, HeaderKeys, Endpoints, UserEndpoints, TransactionEndpoints, AccountEndpoints, OrganizationEndpoints, LimitedEndpoints, GrantType, CookieKeys, };
|
|
@@ -4,6 +4,7 @@ const BlockchainActions = {
|
|
|
4
4
|
Delegate: "delegate",
|
|
5
5
|
Undelegate: "undelegate",
|
|
6
6
|
};
|
|
7
|
+
// #region "Codes"
|
|
7
8
|
const StructTicketMessageDescriptionCodes = {
|
|
8
9
|
Custom: "M000",
|
|
9
10
|
Identification_Is_Being_Verified: "M100",
|
|
@@ -77,4 +78,5 @@ const SystemResponses = {
|
|
|
77
78
|
Invalid_Authentication_Code: "6049",
|
|
78
79
|
Internal_Server_Error: "7001",
|
|
79
80
|
};
|
|
81
|
+
// #endregion
|
|
80
82
|
export { BlockchainActions, StructTicketMessageDescriptionCodes, SystemResponses, };
|
|
@@ -15,6 +15,9 @@ class CipherHelper {
|
|
|
15
15
|
const decipher = createDecipheriv("aes-256-cbc", keyBuffer, ivBuffer);
|
|
16
16
|
let decrypted = decipher.update(cipherText, "base64", "utf8");
|
|
17
17
|
decrypted += decipher.final("utf8");
|
|
18
|
+
if (decrypted == "{}") {
|
|
19
|
+
return "";
|
|
20
|
+
}
|
|
18
21
|
return decrypted;
|
|
19
22
|
}
|
|
20
23
|
catch (error) {
|
|
@@ -2,15 +2,20 @@ import { USR } from "../types";
|
|
|
2
2
|
declare class CookiesHelper {
|
|
3
3
|
static GetIID: () => any;
|
|
4
4
|
static SetIID: () => void;
|
|
5
|
+
static ValidateIID: (IID: string) => string;
|
|
5
6
|
static GetDEK: () => string;
|
|
6
7
|
static SetDEK: (deviceEncryptionKey: string, USR: USR) => void;
|
|
8
|
+
static ValidateDEK: (DEK: string) => string;
|
|
7
9
|
static GetUSR: () => USR;
|
|
8
10
|
static SetUSR: (deviceId: string, userId: string) => void;
|
|
11
|
+
static ValidateUSR: (USR: string) => string;
|
|
9
12
|
static GetDeviceSecurityCode: () => string;
|
|
10
13
|
static GetAccessToken: () => string;
|
|
11
|
-
static SetAccessToken: (accessToken: string) => void;
|
|
14
|
+
static SetAccessToken: (accessToken: string, expires: Date) => void;
|
|
15
|
+
static ValidateAccessToken: (accessToken: string) => string;
|
|
12
16
|
static GetJWTToken: () => string;
|
|
13
17
|
static SetJWTToken: (jwtToken: string) => void;
|
|
18
|
+
static ValidateJWTToken: (jwtToken: string) => string;
|
|
14
19
|
static GET: (key: string) => string | undefined;
|
|
15
20
|
static SET: (key: string, value: string, expires?: Date) => void;
|
|
16
21
|
static REMOVE: (key: string) => void;
|
|
@@ -29,6 +29,16 @@ class CookiesHelper {
|
|
|
29
29
|
console.error(error);
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
|
+
static ValidateIID = (IID) => {
|
|
33
|
+
try {
|
|
34
|
+
const { key, iv } = CipherHelper.GenerateByProgramID();
|
|
35
|
+
const decryptedIID = CipherHelper.Decrypt(IID, key, iv);
|
|
36
|
+
return decryptedIID;
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
console.error(error);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
32
42
|
// #endregion
|
|
33
43
|
// #region "DEK"
|
|
34
44
|
static GetDEK = () => {
|
|
@@ -64,6 +74,20 @@ class CookiesHelper {
|
|
|
64
74
|
console.error(error);
|
|
65
75
|
}
|
|
66
76
|
};
|
|
77
|
+
static ValidateDEK = (DEK) => {
|
|
78
|
+
try {
|
|
79
|
+
const IID = this.GetIID();
|
|
80
|
+
const USR = this.GetUSR();
|
|
81
|
+
if (!DEK || !USR)
|
|
82
|
+
return null;
|
|
83
|
+
const { key, iv } = CipherHelper.GenerateByUSRAndIID(USR, IID);
|
|
84
|
+
const decryptedDEK = CipherHelper.Decrypt(DEK, key, iv);
|
|
85
|
+
return decryptedDEK;
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
console.error(error);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
67
91
|
// #endregion
|
|
68
92
|
// #region "USR"
|
|
69
93
|
static GetUSR = () => {
|
|
@@ -93,6 +117,19 @@ class CookiesHelper {
|
|
|
93
117
|
console.error(error);
|
|
94
118
|
}
|
|
95
119
|
};
|
|
120
|
+
static ValidateUSR = (USR) => {
|
|
121
|
+
try {
|
|
122
|
+
const IID = this.GetIID();
|
|
123
|
+
if (!IID)
|
|
124
|
+
return null;
|
|
125
|
+
const { key, iv } = CipherHelper.GenerateByInstallationID(IID);
|
|
126
|
+
const decryptedDEK = CipherHelper.Decrypt(USR, key, iv);
|
|
127
|
+
return decryptedDEK;
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
console.error(error);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
96
133
|
// #endregion
|
|
97
134
|
// #region "Device Security Code"
|
|
98
135
|
static GetDeviceSecurityCode = () => {
|
|
@@ -126,12 +163,25 @@ class CookiesHelper {
|
|
|
126
163
|
console.error(error);
|
|
127
164
|
}
|
|
128
165
|
};
|
|
129
|
-
static SetAccessToken = (accessToken) => {
|
|
166
|
+
static SetAccessToken = (accessToken, expires) => {
|
|
130
167
|
try {
|
|
131
168
|
const IID = this.GetIID();
|
|
132
169
|
const { key, iv } = CipherHelper.GenerateByInstallationID(IID);
|
|
133
170
|
const encryptedAccessToken = CipherHelper.Encrypt(accessToken, key, iv);
|
|
134
|
-
this.SET("access_token", encryptedAccessToken);
|
|
171
|
+
this.SET("access_token", encryptedAccessToken, expires);
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
console.error(error);
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
static ValidateAccessToken = (accessToken) => {
|
|
178
|
+
try {
|
|
179
|
+
const IID = this.GetIID();
|
|
180
|
+
if (!IID)
|
|
181
|
+
return null;
|
|
182
|
+
const { key, iv } = CipherHelper.GenerateByInstallationID(IID);
|
|
183
|
+
const decryptedAccessToken = CipherHelper.Decrypt(accessToken, key, iv);
|
|
184
|
+
return decryptedAccessToken;
|
|
135
185
|
}
|
|
136
186
|
catch (error) {
|
|
137
187
|
console.error(error);
|
|
@@ -162,6 +212,19 @@ class CookiesHelper {
|
|
|
162
212
|
console.error(error);
|
|
163
213
|
}
|
|
164
214
|
};
|
|
215
|
+
static ValidateJWTToken = (jwtToken) => {
|
|
216
|
+
try {
|
|
217
|
+
const IID = this.GetIID();
|
|
218
|
+
if (!IID)
|
|
219
|
+
return null;
|
|
220
|
+
const { key, iv } = CipherHelper.GenerateByInstallationID(IID);
|
|
221
|
+
const decryptedAccessToken = CipherHelper.Decrypt(jwtToken, key, iv);
|
|
222
|
+
return decryptedAccessToken;
|
|
223
|
+
}
|
|
224
|
+
catch (error) {
|
|
225
|
+
console.error(error);
|
|
226
|
+
}
|
|
227
|
+
};
|
|
165
228
|
// #endregion
|
|
166
229
|
// #region "Getters & Setters"
|
|
167
230
|
static GET = (key) => {
|
|
@@ -194,31 +257,31 @@ class CookiesHelper {
|
|
|
194
257
|
switch (changedCookie.name) {
|
|
195
258
|
case "IID":
|
|
196
259
|
const IID = this.GetIID();
|
|
197
|
-
if (IID != changedCookie.value) {
|
|
260
|
+
if (IID != this.ValidateIID(changedCookie.value)) {
|
|
198
261
|
callback();
|
|
199
262
|
}
|
|
200
263
|
break;
|
|
201
264
|
case "USR":
|
|
202
265
|
const USR = this.GetUSR();
|
|
203
|
-
if (USR.toString() != changedCookie.value) {
|
|
266
|
+
if (USR.toString() != this.ValidateUSR(changedCookie.value)) {
|
|
204
267
|
callback();
|
|
205
268
|
}
|
|
206
269
|
break;
|
|
207
270
|
case "DEK":
|
|
208
271
|
const DEK = this.GetDEK();
|
|
209
|
-
if (DEK != changedCookie.value) {
|
|
272
|
+
if (DEK != this.ValidateDEK(changedCookie.value)) {
|
|
210
273
|
callback();
|
|
211
274
|
}
|
|
212
275
|
break;
|
|
213
276
|
case "access_token":
|
|
214
277
|
const accessToken = this.GetAccessToken();
|
|
215
|
-
if (accessToken != changedCookie.value) {
|
|
278
|
+
if (accessToken != this.ValidateAccessToken(changedCookie.value)) {
|
|
216
279
|
callback();
|
|
217
280
|
}
|
|
218
281
|
break;
|
|
219
282
|
case "jwt_token":
|
|
220
283
|
const jwtToken = this.GetJWTToken();
|
|
221
|
-
if (jwtToken != changedCookie.value) {
|
|
284
|
+
if (jwtToken != this.ValidateJWTToken(changedCookie.value)) {
|
|
222
285
|
callback();
|
|
223
286
|
}
|
|
224
287
|
break;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ggez-banking-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.145",
|
|
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",
|