ggez-banking-sdk 0.1.159 → 0.1.160

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.
@@ -2,10 +2,10 @@ import { createCipheriv, createDecipheriv } from "crypto";
2
2
  class CipherHelper {
3
3
  static Encrypt = (plainText, key, iv) => {
4
4
  try {
5
- const keyBuffer = Buffer.from(key, "utf8");
6
- const ivBuffer = Buffer.from(iv, "utf8");
5
+ const keyBuffer = Buffer.from(key, "utf16le");
6
+ const ivBuffer = Buffer.from(iv, "utf16le");
7
7
  const cipher = createCipheriv("aes-256-cbc", keyBuffer, ivBuffer);
8
- let encrypted = cipher.update(plainText, "utf8", "base64");
8
+ let encrypted = cipher.update(plainText, "utf16le", "base64");
9
9
  encrypted += cipher.final("base64");
10
10
  return encrypted;
11
11
  }
@@ -16,11 +16,11 @@ class CipherHelper {
16
16
  };
17
17
  static Decrypt = (cipherText, key, iv) => {
18
18
  try {
19
- const keyBuffer = Buffer.from(key, "utf8");
20
- const ivBuffer = Buffer.from(iv, "utf8");
19
+ const keyBuffer = Buffer.from(key, "utf16le");
20
+ const ivBuffer = Buffer.from(iv, "utf16le");
21
21
  const decipher = createDecipheriv("aes-256-cbc", keyBuffer, ivBuffer);
22
- let decrypted = decipher.update(cipherText, "base64", "utf8");
23
- decrypted += decipher.final("utf8");
22
+ let decrypted = decipher.update(cipherText, "base64", "utf16le");
23
+ decrypted += decipher.final("utf16le");
24
24
  if (decrypted == "{}") {
25
25
  return "";
26
26
  }
@@ -286,6 +286,7 @@ class CookiesHelper {
286
286
  const changedIID = this.ValidateIID(changedCookie.value);
287
287
  if (IID != changedIID) {
288
288
  callback();
289
+ this.SetIID();
289
290
  }
290
291
  break;
291
292
  case "USR":
@@ -31,7 +31,9 @@ class LocalStorageHelper {
31
31
  const { key, iv } = CipherHelper.GenerateByInstallationID(IID);
32
32
  const data = JSON.stringify(userData);
33
33
  const encryptedUserData = CipherHelper.Encrypt(data, key, iv);
34
- this.SET("CUD", encryptedUserData);
34
+ if (encryptedUserData) {
35
+ this.SET("CUD", encryptedUserData);
36
+ }
35
37
  }
36
38
  catch (error) {
37
39
  console.error(error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ggez-banking-sdk",
3
- "version": "0.1.159",
3
+ "version": "0.1.160",
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",