ggez-banking-sdk 0.1.105 → 0.1.107

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.
Files changed (89) hide show
  1. package/dist/api/clients/account.d.ts +8 -8
  2. package/dist/api/clients/account.js +26 -19
  3. package/dist/api/clients/auth.d.ts +22 -17
  4. package/dist/api/clients/auth.js +57 -42
  5. package/dist/api/clients/blockchain.d.ts +16 -16
  6. package/dist/api/clients/blockchain.js +52 -42
  7. package/dist/api/clients/ipAddressAndLocation.js +15 -13
  8. package/dist/api/clients/limited.d.ts +42 -32
  9. package/dist/api/clients/limited.js +100 -82
  10. package/dist/api/clients/order.d.ts +4 -4
  11. package/dist/api/clients/order.js +16 -12
  12. package/dist/api/clients/organization.d.ts +23 -18
  13. package/dist/api/clients/organization.js +57 -45
  14. package/dist/api/clients/promotion.d.ts +28 -13
  15. package/dist/api/clients/promotion.js +32 -30
  16. package/dist/api/clients/transaction.d.ts +9 -9
  17. package/dist/api/clients/transaction.js +30 -24
  18. package/dist/api/clients/user.d.ts +387 -301
  19. package/dist/api/clients/user.js +886 -735
  20. package/dist/api/data/account.d.ts +3 -0
  21. package/dist/api/data/account.js +8 -0
  22. package/dist/api/data/blockchain.d.ts +2 -1
  23. package/dist/api/data/blockchain.js +11 -1
  24. package/dist/api/data/index.d.ts +2 -0
  25. package/dist/api/data/index.js +2 -0
  26. package/dist/api/data/order.d.ts +2 -1
  27. package/dist/api/data/order.js +15 -1
  28. package/dist/api/data/organization.d.ts +2 -1
  29. package/dist/api/data/organization.js +26 -1
  30. package/dist/api/data/result.d.ts +9 -0
  31. package/dist/api/data/result.js +48 -0
  32. package/dist/api/data/transaction.d.ts +4 -2
  33. package/dist/api/data/transaction.js +24 -1
  34. package/dist/api/data/user/confirmUserSecurity.d.ts +3 -0
  35. package/dist/api/data/user/confirmUserSecurity.js +12 -0
  36. package/dist/api/data/user/forgetSecurityData.d.ts +3 -0
  37. package/dist/api/data/user/forgetSecurityData.js +10 -0
  38. package/dist/api/data/user/index.d.ts +8 -8
  39. package/dist/api/data/user/index.js +8 -161
  40. package/dist/api/data/user/user.d.ts +6 -0
  41. package/dist/api/data/user/user.js +159 -0
  42. package/dist/api/data/user/validateLimitedSecurity.d.ts +3 -0
  43. package/dist/api/data/user/validateLimitedSecurity.js +10 -0
  44. package/dist/api/data/user/validateSecurityData.d.ts +3 -0
  45. package/dist/api/data/user/validateSecurityData.js +11 -0
  46. package/dist/api/data/user/verifyUserSecurity.d.ts +3 -0
  47. package/dist/api/data/user/verifyUserSecurity.js +11 -0
  48. package/dist/api/services/account.js +1 -1
  49. package/dist/api/services/auth.js +4 -5
  50. package/dist/api/services/base.d.ts +1 -1
  51. package/dist/api/services/base.js +1 -0
  52. package/dist/api/services/blockchain.js +5 -9
  53. package/dist/api/services/ipAddressAndLocation.js +10 -10
  54. package/dist/api/services/limited.js +2 -1
  55. package/dist/api/services/order.js +2 -3
  56. package/dist/api/services/organization.d.ts +2 -2
  57. package/dist/api/services/organization.js +7 -10
  58. package/dist/api/services/promotion.js +1 -1
  59. package/dist/api/services/transaction.d.ts +2 -2
  60. package/dist/api/services/transaction.js +3 -5
  61. package/dist/api/services/user.js +65 -127
  62. package/dist/constants/structure.d.ts +1 -0
  63. package/dist/constants/structure.js +1 -0
  64. package/dist/helper/api/axiosHelper.js +71 -71
  65. package/dist/helper/api/responseHelper.d.ts +12 -11
  66. package/dist/helper/api/responseHelper.js +24 -25
  67. package/dist/helper/cipherHelper.js +95 -97
  68. package/dist/helper/clientHelper.js +1 -0
  69. package/dist/helper/cookiesHelper.d.ts +5 -0
  70. package/dist/helper/cookiesHelper.js +169 -126
  71. package/dist/helper/deviceHelper.js +31 -31
  72. package/dist/helper/userHelper.d.ts +12 -2
  73. package/dist/helper/userHelper.js +69 -2
  74. package/dist/index.d.ts +1 -1
  75. package/dist/index.js +1 -1
  76. package/dist/tsconfig.tsbuildinfo +1 -1
  77. package/dist/types/banking/common/ResultSet.d.ts +10 -0
  78. package/dist/types/banking/common/ResultSet.js +1 -0
  79. package/dist/types/banking/common/index.d.ts +1 -0
  80. package/dist/types/banking/entities/address.d.ts +1 -0
  81. package/dist/types/banking/oauth/tokenData.d.ts +3 -1
  82. package/dist/types/banking/transaction/index.d.ts +1 -0
  83. package/dist/types/banking/transaction/transactionResultInquiry.d.ts +9 -0
  84. package/dist/types/banking/transaction/transactionResultInquiry.js +1 -0
  85. package/dist/types/helper/index.d.ts +4 -3
  86. package/dist/types/helper/index.js +1 -3
  87. package/dist/types/helper/userHelper.d.ts +17 -0
  88. package/dist/types/helper/userHelper.js +2 -0
  89. package/package.json +2 -2
@@ -1,106 +1,104 @@
1
- var _a;
2
1
  import { createCipheriv, createDecipheriv } from "crypto";
3
2
  class CipherHelper {
4
- }
5
- _a = CipherHelper;
6
- CipherHelper.Encrypt = (plainText, key, iv) => {
7
- const keyBuffer = Buffer.from(key, "utf8");
8
- const ivBuffer = Buffer.from(iv, "utf8");
9
- const cipher = createCipheriv("aes-256-cbc", keyBuffer, ivBuffer);
10
- let encrypted = cipher.update(plainText, "utf8", "base64");
11
- encrypted += cipher.final("base64");
12
- return encrypted;
13
- };
14
- CipherHelper.Decrypt = (cipherText, key, iv) => {
15
- try {
3
+ static Encrypt = (plainText, key, iv) => {
16
4
  const keyBuffer = Buffer.from(key, "utf8");
17
5
  const ivBuffer = Buffer.from(iv, "utf8");
18
- const decipher = createDecipheriv("aes-256-cbc", keyBuffer, ivBuffer);
19
- let decrypted = decipher.update(cipherText, "base64", "utf8");
20
- decrypted += decipher.final("utf8");
21
- return decrypted;
22
- }
23
- catch (error) {
24
- return JSON.stringify(error);
25
- }
26
- };
27
- CipherHelper.Generate = (code) => {
28
- try {
29
- if (!code)
30
- throw new Error("code is not defined");
31
- const KEY = _a.PaddingLeft(code.toString(), 32, "0");
32
- const IV = _a.PaddingLeft(code.toString(), 16, "0");
33
- return { key: KEY, iv: IV };
34
- }
35
- catch (error) {
36
- console.error(error);
37
- return { key: "", iv: "" };
38
- }
39
- };
40
- CipherHelper.GenerateByUSRAndIID = (USR, IID) => {
41
- try {
42
- if (!USR || !USR.device_id || !USR.user_id) {
43
- throw new Error("USR is not defined");
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;
10
+ };
11
+ static Decrypt = (cipherText, key, iv) => {
12
+ try {
13
+ const keyBuffer = Buffer.from(key, "utf8");
14
+ const ivBuffer = Buffer.from(iv, "utf8");
15
+ const decipher = createDecipheriv("aes-256-cbc", keyBuffer, ivBuffer);
16
+ let decrypted = decipher.update(cipherText, "base64", "utf8");
17
+ decrypted += decipher.final("utf8");
18
+ return decrypted;
19
+ }
20
+ catch (error) {
21
+ return JSON.stringify(error);
22
+ }
23
+ };
24
+ static Generate = (code) => {
25
+ try {
26
+ if (!code)
27
+ throw new Error("code is not defined");
28
+ const KEY = this.PaddingLeft(code.toString(), 32, "0");
29
+ const IV = this.PaddingLeft(code.toString(), 16, "0");
30
+ return { key: KEY, iv: IV };
31
+ }
32
+ catch (error) {
33
+ console.error(error);
34
+ return { key: "", iv: "" };
44
35
  }
45
- if (!IID) {
46
- throw new Error("IID is not defined");
36
+ };
37
+ static GenerateByUSRAndIID = (USR, IID) => {
38
+ try {
39
+ if (!USR || !USR.device_id || !USR.user_id) {
40
+ throw new Error("USR is not defined");
41
+ }
42
+ if (!IID) {
43
+ throw new Error("IID is not defined");
44
+ }
45
+ const DID_KEY = this.PaddingLeft(USR.device_id.toString(), 10, "0");
46
+ const UID_KEY = this.PaddingLeft(USR.user_id.toString(), 10, "0");
47
+ const IID_KEY = IID.slice(0, 10);
48
+ const KEY = `${DID_KEY}.${UID_KEY}.${IID_KEY}`.toString();
49
+ const DID_IV = this.PaddingLeft(USR.device_id.toString(), 8, "0");
50
+ const UID_IV = this.PaddingLeft(USR.user_id.toString(), 8, "0");
51
+ const IV = `${DID_IV}${UID_IV}`;
52
+ return { key: KEY, iv: IV };
47
53
  }
48
- const DID_KEY = _a.PaddingLeft(USR.device_id.toString(), 10, "0");
49
- const UID_KEY = _a.PaddingLeft(USR.user_id.toString(), 10, "0");
50
- const IID_KEY = IID.slice(0, 10);
51
- const KEY = `${DID_KEY}.${UID_KEY}.${IID_KEY}`.toString();
52
- const DID_IV = _a.PaddingLeft(USR.device_id.toString(), 8, "0");
53
- const UID_IV = _a.PaddingLeft(USR.user_id.toString(), 8, "0");
54
- const IV = `${DID_IV}${UID_IV}`.toString();
55
- return { key: KEY, iv: IV };
56
- }
57
- catch (error) {
58
- console.error(error);
59
- return { key: "", iv: "" };
60
- }
61
- };
62
- CipherHelper.GenerateByProgramID = () => {
63
- try {
64
- const programId = process.env.NEXT_PUBLIC_PROGRAM_ID || process.env.VITE_PROGRAM_ID;
65
- if (!programId) {
66
- throw new Error("Program ID is not defined");
54
+ catch (error) {
55
+ console.error(error);
56
+ return { key: "", iv: "" };
67
57
  }
68
- const PID_KEY = _a.PaddingLeft(programId.toString(), 10, "0");
69
- const F_KEY = _a.PaddingLeft("0".toString(), 10, "0");
70
- const FingerPrint_KEY = _a.PaddingLeft("", 10, "0");
71
- const KEY = `${PID_KEY}.${F_KEY}.${FingerPrint_KEY}`;
72
- const PID_IV = _a.PaddingLeft(programId.toString(), 8, "0");
73
- const F_IV = _a.PaddingLeft("0".toString(), 8, "0");
74
- const IV = `${PID_IV}${F_IV}`;
75
- return { key: KEY, iv: IV };
76
- }
77
- catch (error) {
78
- console.error(error);
79
- return { key: "", iv: "" };
80
- }
81
- };
82
- CipherHelper.GenerateByUserID = (user_id) => {
83
- const UID_KEY = _a.PaddingLeft(user_id.toString(), 32, "0");
84
- const UID_IV = _a.PaddingLeft(user_id.toString(), 16, "0");
85
- return { key: UID_KEY, iv: UID_IV };
86
- };
87
- CipherHelper.GenerateByInstallationID = (IID) => {
88
- try {
89
- if (!IID) {
90
- throw new Error("Installation ID is not defined");
58
+ };
59
+ static GenerateByProgramID = () => {
60
+ try {
61
+ const programId = process.env.NEXT_PUBLIC_PROGRAM_ID || process.env.VITE_PROGRAM_ID;
62
+ if (!programId) {
63
+ throw new Error("Program ID is not defined");
64
+ }
65
+ const PID_KEY = this.PaddingLeft(programId.toString(), 10, "0");
66
+ const F_KEY = this.PaddingLeft("0".toString(), 10, "0");
67
+ const FingerPrint_KEY = this.PaddingLeft("", 10, "0");
68
+ const KEY = `${PID_KEY}.${F_KEY}.${FingerPrint_KEY}`;
69
+ const PID_IV = this.PaddingLeft(programId.toString(), 8, "0");
70
+ const F_IV = this.PaddingLeft("0".toString(), 8, "0");
71
+ const IV = `${PID_IV}${F_IV}`;
72
+ return { key: KEY, iv: IV };
91
73
  }
92
- const IID_KEY = IID.slice(0, 32);
93
- const IID_IV = IID.slice(0, 16);
94
- return { key: IID_KEY, iv: IID_IV };
95
- }
96
- catch (error) {
97
- console.error(error);
98
- return { key: "", iv: "" };
99
- }
100
- };
101
- CipherHelper.PaddingLeft = (value, length, paddingChar) => {
102
- if (value.length >= length)
103
- return value;
104
- return paddingChar.repeat(length - value.length) + value;
105
- };
74
+ catch (error) {
75
+ console.error(error);
76
+ return { key: "", iv: "" };
77
+ }
78
+ };
79
+ static GenerateByUserID = (user_id) => {
80
+ const UID_KEY = this.PaddingLeft(user_id.toString(), 32, "0");
81
+ const UID_IV = this.PaddingLeft(user_id.toString(), 16, "0");
82
+ return { key: UID_KEY, iv: UID_IV };
83
+ };
84
+ static GenerateByInstallationID = (IID) => {
85
+ try {
86
+ if (!IID) {
87
+ throw new Error("Installation ID is not defined");
88
+ }
89
+ const IID_KEY = IID.slice(0, 32);
90
+ const IID_IV = IID.slice(0, 16);
91
+ return { key: IID_KEY, iv: IID_IV };
92
+ }
93
+ catch (error) {
94
+ console.error(error);
95
+ return { key: "", iv: "" };
96
+ }
97
+ };
98
+ static PaddingLeft = (value, length, paddingChar) => {
99
+ if (value.length >= length)
100
+ return value;
101
+ return paddingChar.repeat(length - value.length) + value;
102
+ };
103
+ }
106
104
  export { CipherHelper };
@@ -1,5 +1,6 @@
1
1
  import { UAParser } from "ua-parser-js";
2
2
  class ClientHelper {
3
+ clientBrowserData;
3
4
  constructor() {
4
5
  const uaParser = new UAParser();
5
6
  this.clientBrowserData = uaParser.getResult();
@@ -10,5 +10,10 @@ declare class CookiesHelper {
10
10
  static GET: (key: string) => string | undefined;
11
11
  static SET: (key: string, value: string, expires?: Date) => void;
12
12
  static REMOVE: (key: string) => void;
13
+ static cookieEventHandler: (e: CookieChangeEvent, callback: () => void) => void;
14
+ static onChangeHandler: (changed: CookieInit[], callback: () => void) => void;
15
+ static onDeleteHandler: (deleted: CookieInit[], callback: () => void) => void;
16
+ static addOnChangeEventListener: (callback: () => void) => void;
17
+ static removeOnChangeEventListener: (callback: () => void) => void;
13
18
  }
14
19
  export { CookiesHelper };
@@ -1,132 +1,175 @@
1
- var _a;
2
1
  import { v4 } from "uuid";
3
2
  import Cookies from "js-cookie";
4
3
  import { CipherHelper } from ".";
5
4
  class CookiesHelper {
6
- }
7
- _a = CookiesHelper;
8
- // #region "IID"
9
- CookiesHelper.GetIID = () => {
10
- try {
11
- const { key, iv } = CipherHelper.GenerateByProgramID();
12
- const IID = _a.GET("IID");
13
- if (!IID) {
14
- _a.SetIID();
15
- return _a.GetIID();
16
- }
17
- const decryptedIID = CipherHelper.Decrypt(IID, key, iv);
18
- return decryptedIID;
19
- }
20
- catch (error) {
21
- console.error(error);
22
- }
23
- };
24
- CookiesHelper.SetIID = () => {
25
- try {
26
- const IID = v4();
27
- const { key, iv } = CipherHelper.GenerateByProgramID();
28
- const encryptedIID = CipherHelper.Encrypt(IID, key, iv);
29
- _a.SET("IID", encryptedIID);
30
- }
31
- catch (error) {
32
- console.error(error);
33
- }
34
- };
35
- // #endregion
36
- // #region "DEK"
37
- CookiesHelper.GetDEK = () => {
38
- try {
39
- const IID = _a.GetIID();
40
- const DEK = _a.GET("DEK");
41
- const USR = _a.GetUSR();
42
- if (!DEK || !USR) {
43
- return null;
44
- }
45
- const { key, iv } = CipherHelper.GenerateByUSRAndIID(USR, IID);
46
- const encryptionKey = CipherHelper.Decrypt(DEK, key, iv);
47
- if (encryptionKey.length == 16)
48
- return encryptionKey;
49
- }
50
- catch (error) {
51
- console.error(error);
52
- }
53
- };
54
- CookiesHelper.SetDEK = (deviceEncryptionKey, USR) => {
55
- try {
56
- const IID = _a.GetIID();
57
- const { user_id } = USR;
58
- const { key, iv } = CipherHelper.GenerateByUSRAndIID(USR, IID);
59
- if (deviceEncryptionKey) {
60
- const cipherKeys = CipherHelper.GenerateByUserID(user_id);
61
- const encryptionKey = CipherHelper.Decrypt(deviceEncryptionKey, cipherKeys.key, cipherKeys.iv);
62
- const DEK = CipherHelper.Encrypt(encryptionKey, key, iv);
63
- _a.SET("DEK", DEK);
64
- }
65
- }
66
- catch (error) {
67
- console.error(error);
68
- }
69
- };
70
- // #endregion
71
- // #region "USR"
72
- CookiesHelper.GetUSR = () => {
73
- try {
74
- const IID = _a.GetIID();
75
- const { key, iv } = CipherHelper.GenerateByInstallationID(IID);
76
- const USR = _a.GET("USR");
77
- const decryptedUSR = CipherHelper.Decrypt(USR, key, iv);
78
- return JSON.parse(decryptedUSR);
79
- }
80
- catch (error) {
81
- console.error(error);
82
- }
83
- };
84
- CookiesHelper.SetUSR = (deviceId, userId) => {
85
- try {
86
- const IID = _a.GetIID();
87
- const { key, iv } = CipherHelper.GenerateByInstallationID(IID);
88
- const USR = JSON.stringify({
89
- device_id: deviceId,
90
- user_id: userId,
5
+ // #region "IID"
6
+ static GetIID = () => {
7
+ try {
8
+ const IID = this.GET("IID");
9
+ if (!IID) {
10
+ this.SetIID();
11
+ return this.GetIID();
12
+ }
13
+ const { key, iv } = CipherHelper.GenerateByProgramID();
14
+ const decryptedIID = CipherHelper.Decrypt(IID, key, iv);
15
+ return decryptedIID;
16
+ }
17
+ catch (error) {
18
+ console.error(error);
19
+ }
20
+ };
21
+ static SetIID = () => {
22
+ try {
23
+ const IID = v4();
24
+ const { key, iv } = CipherHelper.GenerateByProgramID();
25
+ const encryptedIID = CipherHelper.Encrypt(IID, key, iv);
26
+ this.SET("IID", encryptedIID);
27
+ }
28
+ catch (error) {
29
+ console.error(error);
30
+ }
31
+ };
32
+ // #endregion
33
+ // #region "DEK"
34
+ static GetDEK = () => {
35
+ try {
36
+ const IID = this.GetIID();
37
+ const DEK = this.GET("DEK");
38
+ const USR = this.GetUSR();
39
+ if (!DEK || !USR) {
40
+ return null;
41
+ }
42
+ const { key, iv } = CipherHelper.GenerateByUSRAndIID(USR, IID);
43
+ const encryptionKey = CipherHelper.Decrypt(DEK, key, iv);
44
+ if (encryptionKey.length == 16)
45
+ return encryptionKey;
46
+ }
47
+ catch (error) {
48
+ console.error(error);
49
+ }
50
+ };
51
+ static SetDEK = (deviceEncryptionKey, USR) => {
52
+ try {
53
+ const IID = this.GetIID();
54
+ const { user_id } = USR;
55
+ const { key, iv } = CipherHelper.GenerateByUSRAndIID(USR, IID);
56
+ if (deviceEncryptionKey) {
57
+ const cipherKeys = CipherHelper.GenerateByUserID(user_id);
58
+ const encryptionKey = CipherHelper.Decrypt(deviceEncryptionKey, cipherKeys.key, cipherKeys.iv);
59
+ const DEK = CipherHelper.Encrypt(encryptionKey, key, iv);
60
+ this.SET("DEK", DEK);
61
+ }
62
+ }
63
+ catch (error) {
64
+ console.error(error);
65
+ }
66
+ };
67
+ // #endregion
68
+ // #region "USR"
69
+ static GetUSR = () => {
70
+ try {
71
+ const IID = this.GetIID();
72
+ const { key, iv } = CipherHelper.GenerateByInstallationID(IID);
73
+ const USR = this.GET("USR");
74
+ const decryptedUSR = CipherHelper.Decrypt(USR, key, iv);
75
+ return JSON.parse(decryptedUSR);
76
+ }
77
+ catch (error) {
78
+ console.error(error);
79
+ }
80
+ };
81
+ static SetUSR = (deviceId, userId) => {
82
+ try {
83
+ const IID = this.GetIID();
84
+ const { key, iv } = CipherHelper.GenerateByInstallationID(IID);
85
+ const USR = JSON.stringify({
86
+ device_id: deviceId,
87
+ user_id: userId,
88
+ });
89
+ const encryptedUSR = CipherHelper.Encrypt(USR, key, iv);
90
+ this.SET("USR", encryptedUSR);
91
+ }
92
+ catch (error) {
93
+ console.error(error);
94
+ }
95
+ };
96
+ // #endregion
97
+ // #region "Device Security Code"
98
+ static GetDeviceSecurityCode = () => {
99
+ try {
100
+ const IID = this.GetIID();
101
+ const DEK = this.GetDEK();
102
+ const USR = this.GetUSR();
103
+ const { key, iv } = CipherHelper.GenerateByUserID(USR.user_id.toString());
104
+ const DUID = IID + "." + DEK;
105
+ const deviceSecurityCode = CipherHelper.Encrypt(DUID, key, iv);
106
+ return deviceSecurityCode;
107
+ }
108
+ catch (error) {
109
+ console.error(error);
110
+ }
111
+ };
112
+ // #endregion
113
+ // #region "Getters & Setters"
114
+ static GET = (key) => {
115
+ return Cookies.get(key);
116
+ };
117
+ static SET = (key, value, expires) => {
118
+ const defaultExpireDate = new Date(Date.now() + 1000 * 60 * 60 * 24 * 365);
119
+ Cookies.set(key, value, {
120
+ path: "/",
121
+ sameSite: "lax",
122
+ domain: process.env.NEXT_PUBLIC_DOMAIN || process.env.VITE_DOMAIN || "ggez.one",
123
+ expires: expires || defaultExpireDate,
91
124
  });
92
- const encryptedUSR = CipherHelper.Encrypt(USR, key, iv);
93
- _a.SET("USR", encryptedUSR);
94
- }
95
- catch (error) {
96
- console.error(error);
97
- }
98
- };
99
- // #endregion
100
- // #region "Device Security Code"
101
- CookiesHelper.GetDeviceSecurityCode = () => {
102
- try {
103
- const IID = _a.GetIID();
104
- const DEK = _a.GetDEK();
105
- const USR = _a.GetUSR();
106
- const { key, iv } = CipherHelper.GenerateByUserID(USR.user_id.toString());
107
- const DUID = IID + "." + DEK;
108
- const deviceSecurityCode = CipherHelper.Encrypt(DUID, key, iv);
109
- return deviceSecurityCode;
110
- }
111
- catch (error) {
112
- console.error(error);
113
- }
114
- };
115
- // #endregion
116
- // #region "Getters & Setters"
117
- CookiesHelper.GET = (key) => {
118
- return Cookies.get(key);
119
- };
120
- CookiesHelper.SET = (key, value, expires) => {
121
- const defaultExpireDate = new Date(Date.now() + 1000 * 60 * 60 * 24 * 365);
122
- Cookies.set(key, value, {
123
- path: "/",
124
- sameSite: "lax",
125
- domain: process.env.NEXT_PUBLIC_DOMAIN || process.env.VITE_DOMAIN || "ggez.one",
126
- expires: expires || defaultExpireDate,
127
- });
128
- };
129
- CookiesHelper.REMOVE = (key) => {
130
- Cookies.remove(key);
131
- };
125
+ };
126
+ static REMOVE = (key) => {
127
+ Cookies.remove(key);
128
+ };
129
+ // #endregion
130
+ // #region "Cookie Change Event Listener"
131
+ static cookieEventHandler = (e, callback) => {
132
+ if (e.changed.length > 0) {
133
+ this.onChangeHandler(e.changed, callback);
134
+ }
135
+ if (e.deleted.length > 0) {
136
+ this.onDeleteHandler(e.deleted, callback);
137
+ }
138
+ };
139
+ static onChangeHandler = (changed, callback) => {
140
+ const changedCookie = changed[0];
141
+ switch (changedCookie.name) {
142
+ case "IID":
143
+ const IID = this.GetIID();
144
+ if (IID != changedCookie.value) {
145
+ callback();
146
+ }
147
+ break;
148
+ case "USR":
149
+ const USR = this.GetUSR();
150
+ if (USR.toString() != changedCookie.value) {
151
+ callback();
152
+ }
153
+ break;
154
+ case "DEK":
155
+ const DEK = this.GetDEK();
156
+ if (DEK != changedCookie.value) {
157
+ callback();
158
+ }
159
+ break;
160
+ }
161
+ };
162
+ static onDeleteHandler = (deleted, callback) => {
163
+ const deletedCookie = deleted[0];
164
+ if (["DEK", "USR", "IID"].includes(deletedCookie.name)) {
165
+ callback();
166
+ }
167
+ };
168
+ static addOnChangeEventListener = (callback) => {
169
+ window.cookieStore.addEventListener("change", (e) => this.cookieEventHandler(e, callback));
170
+ };
171
+ static removeOnChangeEventListener = (callback) => {
172
+ window.cookieStore.removeEventListener("change", (e) => this.cookieEventHandler(e, callback));
173
+ };
174
+ }
132
175
  export { CookiesHelper };
@@ -2,36 +2,36 @@ import { DeviceType, SecurityOperationMethod } from "../constants";
2
2
  import { ClientHelper } from "./clientHelper";
3
3
  import { DateTimeHelper } from "./dateTimeHelper";
4
4
  class DeviceHelper {
5
- }
6
- DeviceHelper.GetDeviceDetails = (asJson = false) => {
7
- const clientHelper = new ClientHelper();
8
- const device = {
9
- type: DeviceType.Browser,
10
- brand: `${clientHelper.getBrowser()}-${clientHelper.getBrowserVersion()}`,
11
- os: clientHelper.getOS(),
12
- extended_info: {
13
- sim_info: null,
14
- culture_info: null,
15
- user_agent: clientHelper.getUserAgent(),
16
- cpu: clientHelper.getCPU(),
17
- system_language: clientHelper.getSystemLanguage(),
18
- },
19
- activity_type: SecurityOperationMethod.Login,
20
- application_version: "",
21
- serial_number: "",
22
- source_ip_address: "",
23
- geo_coordinates: "",
24
- installation_id: "",
25
- client_time_zone: DateTimeHelper.GetClientTimeZone(),
26
- server_date: "",
27
- date_utc: DateTimeHelper.GetDateUTC(),
28
- client_date: DateTimeHelper.GetClientDate(),
29
- update_date_utc: DateTimeHelper.GetDateUTC(),
30
- original_source_id: "",
5
+ static GetDeviceDetails = (asJson = false) => {
6
+ const clientHelper = new ClientHelper();
7
+ const device = {
8
+ type: DeviceType.Browser,
9
+ brand: `${clientHelper.getBrowser()}-${clientHelper.getBrowserVersion()}`,
10
+ os: clientHelper.getOS(),
11
+ extended_info: {
12
+ sim_info: null,
13
+ culture_info: null,
14
+ user_agent: clientHelper.getUserAgent(),
15
+ cpu: clientHelper.getCPU(),
16
+ system_language: clientHelper.getSystemLanguage(),
17
+ },
18
+ activity_type: SecurityOperationMethod.Login,
19
+ application_version: "",
20
+ serial_number: "",
21
+ source_ip_address: "",
22
+ geo_coordinates: "",
23
+ installation_id: "",
24
+ client_time_zone: DateTimeHelper.GetClientTimeZone(),
25
+ server_date: "",
26
+ date_utc: DateTimeHelper.GetDateUTC(),
27
+ client_date: DateTimeHelper.GetClientDate(),
28
+ update_date_utc: DateTimeHelper.GetDateUTC(),
29
+ original_source_id: "",
30
+ };
31
+ if (asJson)
32
+ return JSON.stringify(device);
33
+ return device;
31
34
  };
32
- if (asJson)
33
- return JSON.stringify(device);
34
- return device;
35
- };
36
- DeviceHelper.GetDeviceExtendedInfo = () => { };
35
+ static GetDeviceExtendedInfo = () => { };
36
+ }
37
37
  export { DeviceHelper };
@@ -1,4 +1,5 @@
1
- declare const UserHelper: (userInfo: any) => {
1
+ import { TModifyByEntity, TModifyByDocumentData, TSortByID, TSortByIsPrimary, TSortByVerificationStatus, TSortEntity } from "..";
2
+ declare const OldUserHelper: (userInfo: any) => {
2
3
  checkResponse: () => {
3
4
  checkUserResponseAuth: (response: any, showMessageSuccess: boolean, funcName: string) => any;
4
5
  checkGlobalResponse: (key: string, response: any, funcName: string, keyAction?: string) => {
@@ -8,4 +9,13 @@ declare const UserHelper: (userInfo: any) => {
8
9
  };
9
10
  };
10
11
  export declare function sortUserInfo(list?: any[] | null): any;
11
- export default UserHelper;
12
+ export default OldUserHelper;
13
+ declare class UserHelper {
14
+ static ModifyByEntity: TModifyByEntity;
15
+ static ModifyByDocumentData: TModifyByDocumentData;
16
+ static SortEntity: TSortEntity;
17
+ static SortByIsPrimary: TSortByIsPrimary;
18
+ static SortByVerificationStatus: TSortByVerificationStatus;
19
+ static SortById: TSortByID;
20
+ }
21
+ export { UserHelper };