@futdevpro/fsm-dynamo 1.10.51 → 1.10.53

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 (30) hide show
  1. package/build/_collections/utils/shared.util.d.ts +4 -0
  2. package/build/_collections/utils/shared.util.d.ts.map +1 -1
  3. package/build/_collections/utils/shared.util.js +13 -0
  4. package/build/_collections/utils/shared.util.js.map +1 -1
  5. package/build/_collections/utils/stack.util.js +1 -1
  6. package/build/_models/control-models/data-property-params.control-model.js +6 -6
  7. package/build/_modules/crypto/_collections/crypto-2-non-stable.util.d.ts +48 -0
  8. package/build/_modules/crypto/_collections/crypto-2-non-stable.util.d.ts.map +1 -0
  9. package/build/_modules/crypto/_collections/crypto-2-non-stable.util.js +204 -0
  10. package/build/_modules/crypto/_collections/crypto-2-non-stable.util.js.map +1 -0
  11. package/build/_modules/crypto/_collections/crypto.util.d.ts +45 -13
  12. package/build/_modules/crypto/_collections/crypto.util.d.ts.map +1 -1
  13. package/build/_modules/crypto/_collections/crypto.util.js +96 -71
  14. package/build/_modules/crypto/_collections/crypto.util.js.map +1 -1
  15. package/build/_modules/crypto/_collections/crypto.util.spec.js +77 -77
  16. package/build/_modules/crypto/_collections/crypto.util.spec.js.map +1 -1
  17. package/futdevpro-fsm-dynamo-01.10.53.tgz +0 -0
  18. package/package.json +1 -1
  19. package/src/_collections/utils/shared.util.ts +13 -0
  20. package/src/_collections/utils/stack.util.ts +1 -1
  21. package/src/_models/control-models/data-property-params.control-model.ts +6 -6
  22. package/src/_modules/crypto/_collections/crypto-2-non-stable.util.ts +224 -0
  23. package/src/_modules/crypto/_collections/crypto.util.spec.ts +1 -1
  24. package/src/_modules/crypto/_collections/crypto.util.ts +143 -82
  25. package/build/_modules/crypto/_collections/crypto-non-stable.util.d.ts +0 -80
  26. package/build/_modules/crypto/_collections/crypto-non-stable.util.d.ts.map +0 -1
  27. package/build/_modules/crypto/_collections/crypto-non-stable.util.js +0 -229
  28. package/build/_modules/crypto/_collections/crypto-non-stable.util.js.map +0 -1
  29. package/futdevpro-fsm-dynamo-01.10.51.tgz +0 -0
  30. package/src/_modules/crypto/_collections/crypto-non-stable.util.ts +0 -285
@@ -6,30 +6,63 @@ const CryptoJS = tslib_1.__importStar(require("crypto-js"));
6
6
  const error_control_model_1 = require("../../../_models/control-models/error.control-model");
7
7
  /**
8
8
  * A utility class for secure encryption and decryption of data
9
- * Uses AES-256-CBC with deterministic IV and salt for consistent results
9
+ * Uses AES-256-CBC with PBKDF2 key derivation
10
10
  */
11
11
  class DyFM_Crypto {
12
+ static DEFAULT_CONFIG = {
13
+ ivLength: 16, // 128 bits
14
+ saltLength: 16, // 128 bits
15
+ keyIterations: 10000,
16
+ keySize: 8 // 256 bits (8 * 32)
17
+ };
12
18
  static defaultErrorUserMsg = `We encountered an unhandled Authentication Error, ` +
13
19
  `\nplease contact the responsible development team.`;
20
+ // Tömör: kb. 60–80 karakteres token, nem 200+
21
+ // Nem szabványos: nehéz visszafejteni
22
+ // Használható cookie, header, URL-ben
14
23
  /**
15
- * Validates the encryption key
24
+ * Validates the input data and key
25
+ * @throws {DyFM_Error} if validation fails
16
26
  */
17
- static validateKey(key) {
18
- if (!key || typeof key !== 'string') {
27
+ static validateInput(data, key) {
28
+ if (!key || typeof key !== 'string' || key.trim().length === 0) {
19
29
  throw new error_control_model_1.DyFM_Error({
20
- status: 401,
21
- message: 'Encryption key is required and must be a string',
22
- errorCode: 'DyFM-CRY-KEY-REQ'
30
+ ...this.getDefaultErrorSettings('validateInput'),
31
+ errorCode: 'DyFM-CRY-IKY',
32
+ message: 'Invalid encryption key'
23
33
  });
24
34
  }
25
- if (key.trim().length === 0) {
35
+ if (data === undefined || data === null) {
26
36
  throw new error_control_model_1.DyFM_Error({
27
- status: 401,
28
- message: 'Encryption key cannot be empty or whitespace-only',
29
- errorCode: 'DyFM-CRY-KEY-EMPTY'
37
+ ...this.getDefaultErrorSettings('validateInput'),
38
+ errorCode: 'DyFM-CRY-IDT',
39
+ message: 'Invalid data to encrypt/decrypt'
30
40
  });
31
41
  }
32
42
  }
43
+ /**
44
+ * Generates a deterministic IV based on the input data and key
45
+ */
46
+ static generateIV(data, key, config) {
47
+ const hash = CryptoJS.SHA256(data + key);
48
+ return CryptoJS.lib.WordArray.create(hash.words.slice(0, config.ivLength / 4));
49
+ }
50
+ /**
51
+ * Generates a deterministic salt based on the input data and key
52
+ */
53
+ static generateSalt(data, key, config) {
54
+ const hash = CryptoJS.SHA256(key + data);
55
+ return CryptoJS.lib.WordArray.create(hash.words.slice(0, config.saltLength / 4));
56
+ }
57
+ /**
58
+ * Derives a key using PBKDF2
59
+ */
60
+ static deriveKey(key, salt, config) {
61
+ return CryptoJS.PBKDF2(key, salt, {
62
+ keySize: config.keySize,
63
+ iterations: config.keyIterations
64
+ });
65
+ }
33
66
  /**
34
67
  * Safely serializes data to JSON
35
68
  */
@@ -76,51 +109,34 @@ class DyFM_Crypto {
76
109
  }
77
110
  }
78
111
  /**
79
- * Derives a 256-bit key from the passphrase using SHA256
80
- */
81
- static deriveKey(key) {
82
- return CryptoJS.SHA256(key);
83
- }
84
- /**
85
- * Creates a deterministic IV from the key only
86
- */
87
- static createDeterministicIV(key) {
88
- const hash = CryptoJS.SHA256(key + ':iv');
89
- return CryptoJS.lib.WordArray.create(hash.words.slice(0, 4)); // Use first 16 bytes (128 bits)
90
- }
91
- /**
92
- * Encrypts data using AES-256-CBC with deterministic key and IV
112
+ * Encrypts data using AES-256-CBC
93
113
  * @param data The data to encrypt
94
114
  * @param key The encryption key
115
+ * @param config Optional configuration
95
116
  * @returns URL-safe encrypted string
96
117
  * @throws {DyFM_Error} if encryption fails
97
118
  */
98
- static encrypt(data, key) {
119
+ static encrypt(data, key, config) {
99
120
  try {
100
- // Validate key
101
- this.validateKey(key);
102
- // Validate data
103
- if (data === undefined || data === null) {
104
- throw new error_control_model_1.DyFM_Error({
105
- status: 401,
106
- message: 'Data cannot be undefined or null',
107
- errorCode: 'DyFM-CRY-DATA-NULL'
108
- });
109
- }
121
+ this.validateInput(data, key);
122
+ const finalConfig = { ...this.DEFAULT_CONFIG, ...config };
110
123
  // Convert data to string
111
124
  const dataStr = this.safeSerialize(data);
112
- // Derive key and IV
113
- const aesKey = this.deriveKey(key);
114
- const iv = this.createDeterministicIV(key);
115
- // Encrypt the data with deterministic key and IV
116
- const encrypted = CryptoJS.AES.encrypt(dataStr, aesKey, {
125
+ // Generate deterministic IV and salt based on data and key
126
+ const iv = this.generateIV(dataStr, key, finalConfig);
127
+ const salt = this.generateSalt(dataStr, key, finalConfig);
128
+ // Derive key using PBKDF2
129
+ const derivedKey = this.deriveKey(key, salt, finalConfig);
130
+ // Encrypt the data
131
+ const encrypted = CryptoJS.AES.encrypt(dataStr, derivedKey, {
117
132
  iv: iv,
118
133
  mode: CryptoJS.mode.CBC,
119
134
  padding: CryptoJS.pad.Pkcs7
120
135
  });
136
+ // Combine IV + Salt + Ciphertext
137
+ const combined = iv.concat(salt).concat(encrypted.ciphertext);
121
138
  // Convert to URL-safe base64
122
- const base64 = encrypted.ciphertext.toString(CryptoJS.enc.Base64);
123
- return base64
139
+ return CryptoJS.enc.Base64.stringify(combined)
124
140
  .replace(/\+/g, '-')
125
141
  .replace(/\//g, '_')
126
142
  .replace(/=+$/, '');
@@ -136,49 +152,39 @@ class DyFM_Crypto {
136
152
  * Decrypts data that was encrypted using encrypt()
137
153
  * @param encryptedData The encrypted data
138
154
  * @param key The decryption key
155
+ * @param config Optional configuration
139
156
  * @returns The decrypted data
140
157
  * @throws {DyFM_Error} if decryption fails
141
158
  */
142
- static decrypt(encryptedData, key) {
159
+ static decrypt(encryptedData, key, config) {
143
160
  try {
144
- // Validate key
145
- this.validateKey(key);
146
- // Validate encrypted data
147
- if (!encryptedData || typeof encryptedData !== 'string') {
148
- throw new error_control_model_1.DyFM_Error({
149
- status: 401,
150
- message: 'Encrypted data is required and must be a string',
151
- errorCode: 'DyFM-CRY-DATA-REQ'
152
- });
153
- }
161
+ this.validateInput(encryptedData, key);
162
+ const finalConfig = { ...this.DEFAULT_CONFIG, ...config };
154
163
  // Convert from URL-safe base64
155
- let base64 = encryptedData
164
+ const base64 = encryptedData
156
165
  .replace(/-/g, '+')
157
166
  .replace(/_/g, '/');
158
- // Add padding if needed
159
- const padLength = 4 - (base64.length % 4);
160
- if (padLength < 4) {
161
- base64 += '='.repeat(padLength);
167
+ // Parse the combined data
168
+ const combined = CryptoJS.enc.Base64.parse(base64);
169
+ // Validate minimum length (IV + Salt + minimum ciphertext)
170
+ const minLength = (finalConfig.ivLength + finalConfig.saltLength + 16) / 4; // 16 bytes minimum for ciphertext
171
+ if (combined.words.length < minLength) {
172
+ throw new Error('Invalid encrypted data length');
162
173
  }
163
- // Derive key and IV
164
- const aesKey = this.deriveKey(key);
165
- const iv = this.createDeterministicIV(key);
174
+ // Extract IV, salt, and ciphertext
175
+ const iv = CryptoJS.lib.WordArray.create(combined.words.slice(0, finalConfig.ivLength / 4));
176
+ const salt = CryptoJS.lib.WordArray.create(combined.words.slice(finalConfig.ivLength / 4, (finalConfig.ivLength + finalConfig.saltLength) / 4));
177
+ const ciphertext = CryptoJS.lib.WordArray.create(combined.words.slice((finalConfig.ivLength + finalConfig.saltLength) / 4));
178
+ // Derive key using PBKDF2
179
+ const derivedKey = this.deriveKey(key, salt, finalConfig);
166
180
  // Decrypt the data
167
- const encryptedWA = CryptoJS.enc.Base64.parse(base64);
168
- const decrypted = CryptoJS.AES.decrypt({ ciphertext: encryptedWA }, aesKey, {
181
+ const decrypted = CryptoJS.AES.decrypt({ ciphertext: ciphertext }, derivedKey, {
169
182
  iv: iv,
170
183
  mode: CryptoJS.mode.CBC,
171
184
  padding: CryptoJS.pad.Pkcs7
172
185
  });
173
186
  // Parse JSON
174
187
  const decryptedStr = decrypted.toString(CryptoJS.enc.Utf8);
175
- if (!decryptedStr) {
176
- throw new error_control_model_1.DyFM_Error({
177
- status: 401,
178
- message: 'Failed to decrypt data - invalid key or corrupted data',
179
- errorCode: 'DyFM-CRY-DEC-FAIL'
180
- });
181
- }
182
188
  return this.safeDeserialize(decryptedStr);
183
189
  }
184
190
  catch (error) {
@@ -188,6 +194,25 @@ class DyFM_Crypto {
188
194
  });
189
195
  }
190
196
  }
197
+ /**
198
+ * Generates a secure random key
199
+ * @param length Length of the key in bytes (default: 32)
200
+ * @returns A secure random key
201
+ */
202
+ static generateKey(length = 32) {
203
+ return CryptoJS.lib.WordArray.random(length).toString();
204
+ }
205
+ /**
206
+ * Validates if a string is a valid encrypted data
207
+ * @param encryptedData The data to validate
208
+ * @returns true if the data appears to be valid encrypted data
209
+ */
210
+ static isValidEncryptedData(encryptedData) {
211
+ if (!encryptedData || typeof encryptedData !== 'string') {
212
+ return false;
213
+ }
214
+ return /^[A-Za-z0-9\-_]+$/.test(encryptedData);
215
+ }
191
216
  /**
192
217
  * Gets default error settings
193
218
  */
@@ -1 +1 @@
1
- {"version":3,"file":"crypto.util.js","sourceRoot":"","sources":["../../../../src/_modules/crypto/_collections/crypto.util.ts"],"names":[],"mappings":";;;;AAAA,4DAAsC;AACtC,6FAG6D;AAG7D;;;GAGG;AACH,MAAa,WAAW;IACd,MAAM,CAAU,mBAAmB,GACzC,oDAAoD;QACpD,oDAAoD,CAAC;IAEvD;;OAEG;IACK,MAAM,CAAC,WAAW,CAAC,GAAW;QACpC,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YACpC,MAAM,IAAI,gCAAU,CAAC;gBACnB,MAAM,EAAE,GAAG;gBACX,OAAO,EAAE,iDAAiD;gBAC1D,SAAS,EAAE,kBAAkB;aAC9B,CAAC,CAAC;QACL,CAAC;QAED,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,gCAAU,CAAC;gBACnB,MAAM,EAAE,GAAG;gBACX,OAAO,EAAE,mDAAmD;gBAC5D,SAAS,EAAE,oBAAoB;aAChC,CAAC,CAAC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oNC"}
1
+ {"version":3,"file":"crypto.util.js","sourceRoot":"","sources":["../../../../src/_modules/crypto/_collections/crypto.util.ts"],"names":[],"mappings":";;;;AAAA,4DAAsC;AACtC,6FAG6D;AAwB7D;;;GAGG;AACH,MAAa,WAAW;IACd,MAAM,CAAU,cAAc,GAA2B;QAC/D,QAAQ,EAAE,EAAE,EAAE,WAAW;QACzB,UAAU,EAAE,EAAE,EAAE,WAAW;QAC3B,aAAa,EAAE,KAAK;QACpB,OAAO,EAAE,CAAC,CAAC,oBAAoB;KAChC,CAAC;IACM,MAAM,CAAU,mBAAmB,GACzC,oDAAoD;QACpD,oDAAoD,CAAC;IAEvD,8CAA8C;IAC9C,sCAAsC;IACtC,sCAAsC;IAEtC;;;OAGG;IACK,MAAM,CAAC,aAAa,CAAC,IAAS,EAAE,GAAW;QACjD,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC/D,MAAM,IAAI,gCAAU,CAAC;gBACnB,GAAG,IAAI,CAAC,uBAAuB,CAAC,eAAe,CAAC;gBAChD,SAAS,EAAE,cAAc;gBACzB,OAAO,EAAE,wBAAwB;aAClC,CAAC,CAAC;QACL,CAAC;QAED,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;YACxC,MAAM,IAAI,gCAAU,CAAC;gBACnB,GAAG,IAAI,CAAC,uBAAuB,CAAC,eAAe,CAAC;gBAChD,SAAS,EAAE,cAAc;gBACzB,OAAO,EAAE,iCAAiC;aAC3C,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED;;OAEG;IACK,MAAM,CAAC,UAAU,CAAC,IAAY,EAAE,GAAW,EAAE,MAA8B;QACjF,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC;QACzC,OAAO,QAAQ,CAAC,GAAG,CAAC,SA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CAAC,GAAG;gBACvB,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,KAAK;aAC5B,CACF,CAAC;YAEF,aAAa;YACb,MAAM,YAAY,GAAG,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC3D,OAAO,IAAI,CAAC,eAAe,CAAI,YAAY,CAAC,CAAC;QAC/C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,gCAAU,CAAC;gBACnB,GAAG,IAAI,CAAC,uBAAuB,CAAC,SAAS,EAAE,KAAK,CAAC;gBACjD,SAAS,EAAE,cAAc;aAC1B,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,WAAW,CAAC,SAAiB,EAAE;QACpC,OAAO,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC1D,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,oBAAoB,CAAC,aAAqB;QAC/C,IAAI,CAAC,aAAa,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE,CAAC;YACxD,OAAO,KAAK,CAAC;QACf,CAAC;QACD,OAAO,mBAAmB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACjD,CAAC;IAED;;OAEG;IACK,MAAM,CAAC,uBAAuB,CAAC,SAAiB,EAAE,KAAW;QACnE,OAAO;YACL,MAAM,EAAG,KAAoB,EAAE,SAAS,IAAK,KAAa,EAAE,MAAM,IAAI,GAAG;YACzE,OAAO,EAAE,qBAAqB,SAAS,UAAU;YACjD,KAAK,EAAE,KAAK;YACZ,SAAS,EAAE,cAAc;SAC1B,CAAC;IACJ,CAAC;;AA3PH,kCA4PC"}
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const crypto_util_1 = require("./crypto.util");
3
+ const crypto_2_non_stable_util_1 = require("./crypto-2-non-stable.util");
4
4
  describe('| DyFM_Crypto', () => {
5
5
  const testKey = 'test-secret-key-123';
6
6
  const testData = { id: 1, name: 'test' };
7
7
  describe('| encrypt', () => {
8
8
  it('| should successfully encrypt data', () => {
9
- const encrypted = crypto_util_1.DyFM_Crypto.encrypt(testData, testKey);
9
+ const encrypted = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(testData, testKey);
10
10
  expect(encrypted).toBeDefined();
11
11
  expect(typeof encrypted).toBe('string');
12
12
  expect(encrypted).toMatch(/^[A-Za-z0-9\-_]+$/);
@@ -14,13 +14,13 @@ describe('| DyFM_Crypto', () => {
14
14
  it('| should encrypt different data with different results', () => {
15
15
  const data1 = { id: 1 };
16
16
  const data2 = { id: 2 };
17
- const encrypted1 = crypto_util_1.DyFM_Crypto.encrypt(data1, testKey);
18
- const encrypted2 = crypto_util_1.DyFM_Crypto.encrypt(data2, testKey);
17
+ const encrypted1 = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(data1, testKey);
18
+ const encrypted2 = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(data2, testKey);
19
19
  expect(encrypted1).not.toEqual(encrypted2);
20
20
  });
21
21
  it('| should throw DyFM_Error when encryption fails', () => {
22
22
  // @ts-ignore - Testing invalid input
23
- expect(() => crypto_util_1.DyFM_Crypto.encrypt(undefined, testKey)).toThrow();
23
+ expect(() => crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(undefined, testKey)).toThrow();
24
24
  });
25
25
  it('| should handle complex objects', () => {
26
26
  const complexData = {
@@ -31,8 +31,8 @@ describe('| DyFM_Crypto', () => {
31
31
  array: [1, 2, 3]
32
32
  }
33
33
  };
34
- const encrypted = crypto_util_1.DyFM_Crypto.encrypt(complexData, testKey);
35
- const decrypted = crypto_util_1.DyFM_Crypto.decrypt(encrypted, testKey);
34
+ const encrypted = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(complexData, testKey);
35
+ const decrypted = crypto_2_non_stable_util_1.DyFM_Crypto.decrypt(encrypted, testKey);
36
36
  expect(decrypted).toEqual(complexData);
37
37
  });
38
38
  it('| should get the same result with the same input', () => {
@@ -45,8 +45,8 @@ describe('| DyFM_Crypto', () => {
45
45
  }
46
46
  };
47
47
  const expectedResult = JSON.stringify(complexData);
48
- const encrypted = crypto_util_1.DyFM_Crypto.encrypt(complexData, testKey);
49
- const decrypted = crypto_util_1.DyFM_Crypto.decrypt(encrypted, testKey);
48
+ const encrypted = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(complexData, testKey);
49
+ const decrypted = crypto_2_non_stable_util_1.DyFM_Crypto.decrypt(encrypted, testKey);
50
50
  const result = JSON.stringify(decrypted);
51
51
  expect(result).toBe(expectedResult);
52
52
  });
@@ -57,66 +57,66 @@ describe('| DyFM_Crypto', () => {
57
57
  nested: { value: 'nested-value', array: [1, 2, 3] }
58
58
  };
59
59
  const originalData = JSON.stringify(complexData);
60
- const encrypted = crypto_util_1.DyFM_Crypto.encrypt(complexData, testKey);
61
- const decrypted = crypto_util_1.DyFM_Crypto.decrypt(encrypted, testKey);
60
+ const encrypted = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(complexData, testKey);
61
+ const decrypted = crypto_2_non_stable_util_1.DyFM_Crypto.decrypt(encrypted, testKey);
62
62
  const result = JSON.stringify(decrypted);
63
63
  expect(result).toBe(originalData);
64
64
  });
65
65
  it('| should handle arrays', () => {
66
66
  const arrayData = [1, 'test', { nested: true }];
67
- const encrypted = crypto_util_1.DyFM_Crypto.encrypt(arrayData, testKey);
68
- const decrypted = crypto_util_1.DyFM_Crypto.decrypt(encrypted, testKey);
67
+ const encrypted = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(arrayData, testKey);
68
+ const decrypted = crypto_2_non_stable_util_1.DyFM_Crypto.decrypt(encrypted, testKey);
69
69
  expect(decrypted).toEqual(arrayData);
70
70
  });
71
71
  it('| should handle primitive values', () => {
72
72
  const stringData = 'test string';
73
73
  const numberData = 42;
74
74
  const booleanData = true;
75
- const encryptedString = crypto_util_1.DyFM_Crypto.encrypt(stringData, testKey);
76
- const encryptedNumber = crypto_util_1.DyFM_Crypto.encrypt(numberData, testKey);
77
- const encryptedBoolean = crypto_util_1.DyFM_Crypto.encrypt(booleanData, testKey);
78
- expect(crypto_util_1.DyFM_Crypto.decrypt(encryptedString, testKey)).toBe(stringData);
79
- expect(crypto_util_1.DyFM_Crypto.decrypt(encryptedNumber, testKey)).toBe(numberData);
80
- expect(crypto_util_1.DyFM_Crypto.decrypt(encryptedBoolean, testKey)).toBe(booleanData);
75
+ const encryptedString = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(stringData, testKey);
76
+ const encryptedNumber = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(numberData, testKey);
77
+ const encryptedBoolean = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(booleanData, testKey);
78
+ expect(crypto_2_non_stable_util_1.DyFM_Crypto.decrypt(encryptedString, testKey)).toBe(stringData);
79
+ expect(crypto_2_non_stable_util_1.DyFM_Crypto.decrypt(encryptedNumber, testKey)).toBe(numberData);
80
+ expect(crypto_2_non_stable_util_1.DyFM_Crypto.decrypt(encryptedBoolean, testKey)).toBe(booleanData);
81
81
  });
82
82
  });
83
83
  describe('| decrypt', () => {
84
84
  it('| should successfully decrypt encrypted data', () => {
85
- const encrypted = crypto_util_1.DyFM_Crypto.encrypt(testData, testKey);
86
- const decrypted = crypto_util_1.DyFM_Crypto.decrypt(encrypted, testKey);
85
+ const encrypted = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(testData, testKey);
86
+ const decrypted = crypto_2_non_stable_util_1.DyFM_Crypto.decrypt(encrypted, testKey);
87
87
  expect(decrypted).toEqual(testData);
88
88
  });
89
89
  it('| should throw DyFM_Error when decryption fails', () => {
90
- expect(() => crypto_util_1.DyFM_Crypto.decrypt('invalid-encrypted-data', testKey)).toThrow();
90
+ expect(() => crypto_2_non_stable_util_1.DyFM_Crypto.decrypt('invalid-encrypted-data', testKey)).toThrow();
91
91
  });
92
92
  it('| should throw DyFM_Error when using wrong key', () => {
93
- const encrypted = crypto_util_1.DyFM_Crypto.encrypt(testData, testKey);
94
- expect(() => crypto_util_1.DyFM_Crypto.decrypt(encrypted, 'wrong-key')).toThrow();
93
+ const encrypted = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(testData, testKey);
94
+ expect(() => crypto_2_non_stable_util_1.DyFM_Crypto.decrypt(encrypted, 'wrong-key')).toThrow();
95
95
  });
96
96
  it('| should throw DyFM_Error when encrypted data is modified', () => {
97
- const encrypted = crypto_util_1.DyFM_Crypto.encrypt(testData, testKey);
97
+ const encrypted = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(testData, testKey);
98
98
  const modified = encrypted.slice(0, -1) + 'A';
99
- expect(() => crypto_util_1.DyFM_Crypto.decrypt(modified, testKey)).toThrow();
99
+ expect(() => crypto_2_non_stable_util_1.DyFM_Crypto.decrypt(modified, testKey)).toThrow();
100
100
  });
101
101
  });
102
102
  describe('| URL-safe encryption', () => {
103
103
  it('| should produce URL-safe strings', () => {
104
- const encrypted = crypto_util_1.DyFM_Crypto.encrypt(testData, testKey);
104
+ const encrypted = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(testData, testKey);
105
105
  expect(encrypted).toMatch(/^[A-Za-z0-9\-_]+$/);
106
106
  });
107
107
  it('| should work in HTTP headers', () => {
108
- const encrypted = crypto_util_1.DyFM_Crypto.encrypt(testData, testKey);
108
+ const encrypted = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(testData, testKey);
109
109
  const header = `Bearer ${encrypted}`;
110
110
  const extracted = header.split(' ')[1];
111
- const decrypted = crypto_util_1.DyFM_Crypto.decrypt(extracted, testKey);
111
+ const decrypted = crypto_2_non_stable_util_1.DyFM_Crypto.decrypt(extracted, testKey);
112
112
  expect(decrypted).toEqual(testData);
113
113
  });
114
114
  it('| should work in URLs', () => {
115
- const encrypted = crypto_util_1.DyFM_Crypto.encrypt(testData, testKey);
115
+ const encrypted = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(testData, testKey);
116
116
  const url = `https://example.com/api?token=${encrypted}`;
117
117
  const params = new URLSearchParams(url.split('?')[1]);
118
118
  const extracted = params.get('token');
119
- const decrypted = crypto_util_1.DyFM_Crypto.decrypt(extracted, testKey);
119
+ const decrypted = crypto_2_non_stable_util_1.DyFM_Crypto.decrypt(extracted, testKey);
120
120
  expect(decrypted).toEqual(testData);
121
121
  });
122
122
  });
@@ -124,14 +124,14 @@ describe('| DyFM_Crypto', () => {
124
124
  describe('| empty and null values', () => {
125
125
  it('| should handle empty objects', () => {
126
126
  const emptyObj = {};
127
- const encrypted = crypto_util_1.DyFM_Crypto.encrypt(emptyObj, testKey);
128
- const decrypted = crypto_util_1.DyFM_Crypto.decrypt(encrypted, testKey);
127
+ const encrypted = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(emptyObj, testKey);
128
+ const decrypted = crypto_2_non_stable_util_1.DyFM_Crypto.decrypt(encrypted, testKey);
129
129
  expect(decrypted).toEqual(emptyObj);
130
130
  });
131
131
  it('| should handle empty arrays', () => {
132
132
  const emptyArr = [];
133
- const encrypted = crypto_util_1.DyFM_Crypto.encrypt(emptyArr, testKey);
134
- const decrypted = crypto_util_1.DyFM_Crypto.decrypt(encrypted, testKey);
133
+ const encrypted = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(emptyArr, testKey);
134
+ const decrypted = crypto_2_non_stable_util_1.DyFM_Crypto.decrypt(encrypted, testKey);
135
135
  expect(decrypted).toEqual(emptyArr);
136
136
  });
137
137
  it('| should handle null values in objects', () => {
@@ -140,8 +140,8 @@ describe('| DyFM_Crypto', () => {
140
140
  name: null,
141
141
  nested: { value: null }
142
142
  };
143
- const encrypted = crypto_util_1.DyFM_Crypto.encrypt(dataWithNull, testKey);
144
- const decrypted = crypto_util_1.DyFM_Crypto.decrypt(encrypted, testKey);
143
+ const encrypted = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(dataWithNull, testKey);
144
+ const decrypted = crypto_2_non_stable_util_1.DyFM_Crypto.decrypt(encrypted, testKey);
145
145
  expect(decrypted).toEqual(dataWithNull);
146
146
  });
147
147
  it('| should handle undefined values in objects', () => {
@@ -150,41 +150,41 @@ describe('| DyFM_Crypto', () => {
150
150
  name: undefined,
151
151
  nested: { value: undefined }
152
152
  };
153
- const encrypted = crypto_util_1.DyFM_Crypto.encrypt(dataWithUndefined, testKey);
154
- const decrypted = crypto_util_1.DyFM_Crypto.decrypt(encrypted, testKey);
153
+ const encrypted = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(dataWithUndefined, testKey);
154
+ const decrypted = crypto_2_non_stable_util_1.DyFM_Crypto.decrypt(encrypted, testKey);
155
155
  expect(decrypted).toEqual({ id: 1, nested: {} });
156
156
  });
157
157
  });
158
158
  describe('| key edge cases', () => {
159
159
  it('| should handle very long keys', () => {
160
160
  const longKey = 'a'.repeat(1000);
161
- const encrypted = crypto_util_1.DyFM_Crypto.encrypt(testData, longKey);
162
- const decrypted = crypto_util_1.DyFM_Crypto.decrypt(encrypted, longKey);
161
+ const encrypted = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(testData, longKey);
162
+ const decrypted = crypto_2_non_stable_util_1.DyFM_Crypto.decrypt(encrypted, longKey);
163
163
  expect(decrypted).toEqual(testData);
164
164
  });
165
165
  it('| should handle empty key', () => {
166
- expect(() => crypto_util_1.DyFM_Crypto.encrypt(testData, '')).toThrow();
166
+ expect(() => crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(testData, '')).toThrow();
167
167
  });
168
168
  it('| should handle whitespace-only keys', () => {
169
- expect(() => crypto_util_1.DyFM_Crypto.encrypt(testData, ' ')).toThrow();
169
+ expect(() => crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(testData, ' ')).toThrow();
170
170
  });
171
171
  });
172
172
  describe('| encrypted data manipulation', () => {
173
173
  it('| should detect when encrypted data is truncated', () => {
174
- const encrypted = crypto_util_1.DyFM_Crypto.encrypt(testData, testKey);
174
+ const encrypted = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(testData, testKey);
175
175
  const truncated = encrypted.slice(0, -10);
176
- expect(() => crypto_util_1.DyFM_Crypto.decrypt(truncated, testKey)).toThrow();
176
+ expect(() => crypto_2_non_stable_util_1.DyFM_Crypto.decrypt(truncated, testKey)).toThrow();
177
177
  });
178
178
  it('| should detect when encrypted data is extended', () => {
179
- const encrypted = crypto_util_1.DyFM_Crypto.encrypt(testData, testKey);
179
+ const encrypted = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(testData, testKey);
180
180
  const extended = encrypted + 'A'.repeat(10);
181
- expect(() => crypto_util_1.DyFM_Crypto.decrypt(extended, testKey)).toThrow();
181
+ expect(() => crypto_2_non_stable_util_1.DyFM_Crypto.decrypt(extended, testKey)).toThrow();
182
182
  });
183
183
  it('| should detect when encrypted data is modified in the middle', () => {
184
- const encrypted = crypto_util_1.DyFM_Crypto.encrypt(testData, testKey);
184
+ const encrypted = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(testData, testKey);
185
185
  const midPoint = Math.floor(encrypted.length / 2);
186
186
  const modified = encrypted.slice(0, midPoint) + 'X' + encrypted.slice(midPoint + 1);
187
- expect(() => crypto_util_1.DyFM_Crypto.decrypt(modified, testKey)).toThrow();
187
+ expect(() => crypto_2_non_stable_util_1.DyFM_Crypto.decrypt(modified, testKey)).toThrow();
188
188
  });
189
189
  });
190
190
  describe('| JSON handling edge cases', () => {
@@ -200,8 +200,8 @@ describe('| DyFM_Crypto', () => {
200
200
  };
201
201
  // Simulate double stringification
202
202
  const doubleStringified = JSON.stringify(JSON.stringify(testData));
203
- const encrypted = crypto_util_1.DyFM_Crypto.encrypt(doubleStringified, testKey);
204
- const decrypted = crypto_util_1.DyFM_Crypto.decrypt(encrypted, testKey);
203
+ const encrypted = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(doubleStringified, testKey);
204
+ const decrypted = crypto_2_non_stable_util_1.DyFM_Crypto.decrypt(encrypted, testKey);
205
205
  // Should be able to parse the decrypted data back to the original object
206
206
  const parsed = JSON.parse(decrypted);
207
207
  expect(parsed).toEqual(testData);
@@ -451,8 +451,8 @@ describe('| DyFM_Crypto', () => {
451
451
  '239': '}',
452
452
  '240': '}'
453
453
  };
454
- const encrypted = crypto_util_1.DyFM_Crypto.encrypt(charByCharData, testKey);
455
- const decrypted = crypto_util_1.DyFM_Crypto.decrypt(encrypted, testKey);
454
+ const encrypted = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(charByCharData, testKey);
455
+ const decrypted = crypto_2_non_stable_util_1.DyFM_Crypto.decrypt(encrypted, testKey);
456
456
  // Should be able to parse the decrypted data back to the original object
457
457
  expect(decrypted).toEqual(charByCharData);
458
458
  });
@@ -466,11 +466,11 @@ describe('| DyFM_Crypto', () => {
466
466
  };
467
467
  const key = 'test-secret-key-123';
468
468
  // Simulate different environments by creating new instances
469
- const encrypted1 = crypto_util_1.DyFM_Crypto.encrypt(testData, key);
470
- const encrypted2 = crypto_util_1.DyFM_Crypto.encrypt(testData, key);
469
+ const encrypted1 = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(testData, key);
470
+ const encrypted2 = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(testData, key);
471
471
  expect(encrypted1).toBe(encrypted2);
472
- expect(crypto_util_1.DyFM_Crypto.decrypt(encrypted1, key)).toEqual(testData);
473
- expect(crypto_util_1.DyFM_Crypto.decrypt(encrypted2, key)).toEqual(testData);
472
+ expect(crypto_2_non_stable_util_1.DyFM_Crypto.decrypt(encrypted1, key)).toEqual(testData);
473
+ expect(crypto_2_non_stable_util_1.DyFM_Crypto.decrypt(encrypted2, key)).toEqual(testData);
474
474
  });
475
475
  it('| should maintain encryption consistency with different data types', () => {
476
476
  const testCases = [
@@ -480,8 +480,8 @@ describe('| DyFM_Crypto', () => {
480
480
  { data: { nested: { value: true } }, key: 'key4' }
481
481
  ];
482
482
  testCases.forEach(({ data, key }) => {
483
- const encrypted1 = crypto_util_1.DyFM_Crypto.encrypt(data, key);
484
- const encrypted2 = crypto_util_1.DyFM_Crypto.encrypt(data, key);
483
+ const encrypted1 = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(data, key);
484
+ const encrypted2 = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(data, key);
485
485
  expect(encrypted1).toBe(encrypted2);
486
486
  });
487
487
  });
@@ -499,10 +499,10 @@ describe('| DyFM_Crypto', () => {
499
499
  };
500
500
  const key = 'db-storage-key';
501
501
  // Simulate database storage and retrieval
502
- const encrypted = crypto_util_1.DyFM_Crypto.encrypt(originalData, key);
502
+ const encrypted = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(originalData, key);
503
503
  const storedData = encrypted; // Simulating database storage
504
504
  const retrievedData = storedData; // Simulating database retrieval
505
- const decrypted = crypto_util_1.DyFM_Crypto.decrypt(retrievedData, key);
505
+ const decrypted = crypto_2_non_stable_util_1.DyFM_Crypto.decrypt(retrievedData, key);
506
506
  expect(decrypted).toEqual(originalData);
507
507
  });
508
508
  it('| should handle multiple encryption/decryption cycles for database operations', () => {
@@ -517,15 +517,15 @@ describe('| DyFM_Crypto', () => {
517
517
  };
518
518
  const key = 'persistent-key';
519
519
  // Simulate multiple database operations
520
- const encrypted1 = crypto_util_1.DyFM_Crypto.encrypt(userData, key);
521
- const decrypted1 = crypto_util_1.DyFM_Crypto.decrypt(encrypted1, key);
520
+ const encrypted1 = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(userData, key);
521
+ const decrypted1 = crypto_2_non_stable_util_1.DyFM_Crypto.decrypt(encrypted1, key);
522
522
  // Simulate data update with a different timestamp
523
523
  const updatedData = {
524
524
  ...decrypted1,
525
525
  lastLogin: '2024-01-02T15:30:00.000Z'
526
526
  };
527
- const encrypted2 = crypto_util_1.DyFM_Crypto.encrypt(updatedData, key);
528
- const decrypted2 = crypto_util_1.DyFM_Crypto.decrypt(encrypted2, key);
527
+ const encrypted2 = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(updatedData, key);
528
+ const decrypted2 = crypto_2_non_stable_util_1.DyFM_Crypto.decrypt(encrypted2, key);
529
529
  expect(decrypted1).toEqual(userData);
530
530
  expect(decrypted2).toEqual(updatedData);
531
531
  expect(decrypted2.lastLogin).not.toBe(userData.lastLogin);
@@ -541,10 +541,10 @@ describe('| DyFM_Crypto', () => {
541
541
  };
542
542
  const key = 'sensitive-data-key';
543
543
  // Simulate multiple database operations with the same data
544
- const encrypted1 = crypto_util_1.DyFM_Crypto.encrypt(sensitiveData, key);
545
- const decrypted1 = crypto_util_1.DyFM_Crypto.decrypt(encrypted1, key);
546
- const encrypted2 = crypto_util_1.DyFM_Crypto.encrypt(decrypted1, key);
547
- const decrypted2 = crypto_util_1.DyFM_Crypto.decrypt(encrypted2, key);
544
+ const encrypted1 = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(sensitiveData, key);
545
+ const decrypted1 = crypto_2_non_stable_util_1.DyFM_Crypto.decrypt(encrypted1, key);
546
+ const encrypted2 = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(decrypted1, key);
547
+ const decrypted2 = crypto_2_non_stable_util_1.DyFM_Crypto.decrypt(encrypted2, key);
548
548
  expect(decrypted1).toEqual(sensitiveData);
549
549
  expect(decrypted2).toEqual(sensitiveData);
550
550
  expect(encrypted1).toBe(encrypted2); // Different encryption instances
@@ -559,8 +559,8 @@ describe('| DyFM_Crypto', () => {
559
559
  'ĐĐĐđđđßßߤ¤¤×××÷÷÷¨¨¨¨~~~ˇˇˇ^^^˘˘˘°°°˛˛˛```˙˙˙´´´˝˝˝˝¸¸¸§§§' +
560
560
  '???ééééáááűűűúúúőőőóóóüüüöööíííÉÉÉÁÁÁŰŰŰÚÚÚŐŐŐÓÓÓÜÖÖÖÍÍÍ'
561
561
  };
562
- const encrypted = crypto_util_1.DyFM_Crypto.encrypt(unicodeData, testKey);
563
- const decrypted = crypto_util_1.DyFM_Crypto.decrypt(encrypted, testKey);
562
+ const encrypted = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(unicodeData, testKey);
563
+ const decrypted = crypto_2_non_stable_util_1.DyFM_Crypto.decrypt(encrypted, testKey);
564
564
  expect(decrypted).toEqual(unicodeData);
565
565
  });
566
566
  it('| should handle special characters in object keys', () => {
@@ -570,8 +570,8 @@ describe('| DyFM_Crypto', () => {
570
570
  'key-with-special-chars!@#': 'value',
571
571
  'key-with-unicode-世界': 'value'
572
572
  };
573
- const encrypted = crypto_util_1.DyFM_Crypto.encrypt(specialKeyData, testKey);
574
- const decrypted = crypto_util_1.DyFM_Crypto.decrypt(encrypted, testKey);
573
+ const encrypted = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(specialKeyData, testKey);
574
+ const decrypted = crypto_2_non_stable_util_1.DyFM_Crypto.decrypt(encrypted, testKey);
575
575
  expect(decrypted).toEqual(specialKeyData);
576
576
  });
577
577
  it('| should handle special characters in nested objects', () => {
@@ -582,8 +582,8 @@ describe('| DyFM_Crypto', () => {
582
582
  }
583
583
  }
584
584
  };
585
- const encrypted = crypto_util_1.DyFM_Crypto.encrypt(nestedData, testKey);
586
- const decrypted = crypto_util_1.DyFM_Crypto.decrypt(encrypted, testKey);
585
+ const encrypted = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(nestedData, testKey);
586
+ const decrypted = crypto_2_non_stable_util_1.DyFM_Crypto.decrypt(encrypted, testKey);
587
587
  expect(decrypted).toEqual(nestedData);
588
588
  });
589
589
  it('| should handle special characters in arrays', () => {
@@ -592,8 +592,8 @@ describe('| DyFM_Crypto', () => {
592
592
  { 'special-key': 'value with !@#' },
593
593
  ['nested', 'array', 'with', 'special', 'chars!@#']
594
594
  ];
595
- const encrypted = crypto_util_1.DyFM_Crypto.encrypt(arrayData, testKey);
596
- const decrypted = crypto_util_1.DyFM_Crypto.decrypt(encrypted, testKey);
595
+ const encrypted = crypto_2_non_stable_util_1.DyFM_Crypto.encrypt(arrayData, testKey);
596
+ const decrypted = crypto_2_non_stable_util_1.DyFM_Crypto.decrypt(encrypted, testKey);
597
597
  expect(decrypted).toEqual(arrayData);
598
598
  });
599
599
  });