ggez-banking-sdk 0.1.146 → 0.1.148

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,12 +1,18 @@
1
1
  import { createCipheriv, createDecipheriv } from "crypto";
2
2
  class CipherHelper {
3
3
  static Encrypt = (plainText, key, iv) => {
4
- const keyBuffer = Buffer.from(key, "utf8");
5
- const ivBuffer = Buffer.from(iv, "utf8");
6
- const cipher = createCipheriv("aes-256-cbc", keyBuffer, ivBuffer);
7
- let encrypted = cipher.update(plainText, "utf8", "base64");
8
- encrypted += cipher.final("base64");
9
- return encrypted;
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 {
@@ -21,7 +27,8 @@ class CipherHelper {
21
27
  return decrypted;
22
28
  }
23
29
  catch (error) {
24
- return JSON.stringify(error);
30
+ console.error(error + " CipherHelper.Decrypt");
31
+ return "";
25
32
  }
26
33
  };
27
34
  static Generate = (code) => {
@@ -33,7 +40,7 @@ class CipherHelper {
33
40
  return { key: KEY, iv: IV };
34
41
  }
35
42
  catch (error) {
36
- console.error(error);
43
+ console.error(error + " CipherHelper.Generate");
37
44
  return { key: "", iv: "" };
38
45
  }
39
46
  };
@@ -55,7 +62,7 @@ class CipherHelper {
55
62
  return { key: KEY, iv: IV };
56
63
  }
57
64
  catch (error) {
58
- console.error(error);
65
+ console.error(error + " CipherHelper.GenerateByUSRAndIID");
59
66
  return { key: "", iv: "" };
60
67
  }
61
68
  };
@@ -75,14 +82,20 @@ class CipherHelper {
75
82
  return { key: KEY, iv: IV };
76
83
  }
77
84
  catch (error) {
78
- console.error(error);
85
+ console.error(error + " CipherHelper.GenerateByProgramID");
79
86
  return { key: "", iv: "" };
80
87
  }
81
88
  };
82
89
  static GenerateByUserID = (user_id) => {
83
- const UID_KEY = this.PaddingLeft(user_id.toString(), 32, "0");
84
- const UID_IV = this.PaddingLeft(user_id.toString(), 16, "0");
85
- return { key: UID_KEY, iv: UID_IV };
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
+ }
86
99
  };
87
100
  static GenerateByInstallationID = (IID) => {
88
101
  try {
@@ -94,14 +107,20 @@ class CipherHelper {
94
107
  return { key: IID_KEY, iv: IID_IV };
95
108
  }
96
109
  catch (error) {
97
- console.error(error);
110
+ console.error(error + " CipherHelper.GenerateByInstallationID");
98
111
  return { key: "", iv: "" };
99
112
  }
100
113
  };
101
114
  static PaddingLeft = (value, length, paddingChar) => {
102
- if (value.length >= length)
103
- return value;
104
- return paddingChar.repeat(length - value.length) + value;
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
+ }
105
124
  };
106
125
  }
107
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: (data: UserData) => void;
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
- return JSON.parse(decryptedUserData);
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 = (data) => {
245
+ static SetUserData = (userData) => {
243
246
  try {
244
247
  const IID = this.GetIID();
245
248
  const { key, iv } = CipherHelper.GenerateByInstallationID(IID);
246
- const encryptedUserData = CipherHelper.Encrypt(JSON.stringify(data), key, iv);
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.146",
3
+ "version": "0.1.148",
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",