@futdevpro/fsm-dynamo 1.14.20 → 1.14.21

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 (27) hide show
  1. package/build/_modules/crypto/_collections/crypto.util.d.ts.map +1 -1
  2. package/build/_modules/crypto/_collections/crypto.util.edge.spec.d.ts +2 -0
  3. package/build/_modules/crypto/_collections/crypto.util.edge.spec.d.ts.map +1 -0
  4. package/build/_modules/crypto/_collections/crypto.util.edge.spec.js +551 -0
  5. package/build/_modules/crypto/_collections/crypto.util.edge.spec.js.map +1 -0
  6. package/build/_modules/crypto/_collections/crypto.util.extra.spec.d.ts +2 -0
  7. package/build/_modules/crypto/_collections/crypto.util.extra.spec.d.ts.map +1 -0
  8. package/build/_modules/crypto/_collections/crypto.util.extra.spec.js +555 -0
  9. package/build/_modules/crypto/_collections/crypto.util.extra.spec.js.map +1 -0
  10. package/build/_modules/crypto/_collections/crypto.util.js +33 -3
  11. package/build/_modules/crypto/_collections/crypto.util.js.map +1 -1
  12. package/build/_modules/crypto/_collections/crypto.util.simple.spec.d.ts +2 -0
  13. package/build/_modules/crypto/_collections/crypto.util.simple.spec.d.ts.map +1 -0
  14. package/build/_modules/crypto/_collections/crypto.util.simple.spec.js +429 -0
  15. package/build/_modules/crypto/_collections/crypto.util.simple.spec.js.map +1 -0
  16. package/futdevpro-fsm-dynamo-01.14.21.tgz +0 -0
  17. package/package.json +2 -2
  18. package/src/_modules/crypto/_collections/crypto.util.edge.spec.ts +606 -0
  19. package/src/_modules/crypto/_collections/crypto.util.extra.spec.ts +643 -0
  20. package/src/_modules/crypto/_collections/crypto.util.simple.spec.ts +513 -0
  21. package/src/_modules/crypto/_collections/crypto.util.ts +81 -48
  22. package/build/_modules/crypto/_collections/crypto.util.spec.d.ts +0 -2
  23. package/build/_modules/crypto/_collections/crypto.util.spec.d.ts.map +0 -1
  24. package/build/_modules/crypto/_collections/crypto.util.spec.js +0 -1180
  25. package/build/_modules/crypto/_collections/crypto.util.spec.js.map +0 -1
  26. package/futdevpro-fsm-dynamo-01.14.20.tgz +0 -0
  27. package/src/_modules/crypto/_collections/crypto.util.spec.ts +0 -1370
@@ -0,0 +1,555 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const crypto_util_1 = require("./crypto.util");
4
+ describe('| DyFM_Crypto extra tests', () => {
5
+ describe('| TIME MANIPULATION TESTS - Cross-temporal consistency', () => {
6
+ const testKey = 'time-test-key-456';
7
+ const testData = {
8
+ id: 123,
9
+ name: 'time-test',
10
+ timestamp: new Date().toISOString(),
11
+ nested: { value: 'time-dependent-test' }
12
+ };
13
+ let originalDateNow;
14
+ let originalDateConstructor;
15
+ beforeEach(() => {
16
+ // Store original Date functions
17
+ originalDateNow = Date.now;
18
+ originalDateConstructor = Date;
19
+ });
20
+ afterEach(() => {
21
+ // Restore original Date functions
22
+ Date.now = originalDateNow;
23
+ global.Date = originalDateConstructor;
24
+ });
25
+ it('| should produce identical encrypted output regardless of system time', () => {
26
+ const baseTime = 1609459200000; // 2021-01-01 00:00:00 UTC
27
+ // Mock Date.now to return fixed time
28
+ Date.now = jasmine.createSpy('Date.now').and.returnValue(baseTime);
29
+ // Mock Date constructor to return fixed date
30
+ global.Date = jasmine.createSpy('Date').and.callFake((args) => {
31
+ if (!args) {
32
+ return new originalDateConstructor(baseTime);
33
+ }
34
+ return new originalDateConstructor(args);
35
+ });
36
+ const encrypted1 = crypto_util_1.DyFM_Crypto.encrypt(testData, testKey);
37
+ const encrypted2 = crypto_util_1.DyFM_Crypto.encrypt(testData, testKey);
38
+ expect(encrypted1).toEqual(encrypted2);
39
+ expect(encrypted1).toBeDefined();
40
+ });
41
+ it('| should maintain consistency across different time zones', () => {
42
+ const timeZones = [
43
+ 0, // UTC
44
+ -5, // EST
45
+ 1, // CET
46
+ 9, // JST
47
+ -8, // PST
48
+ 5.5 // IST
49
+ ];
50
+ const results = [];
51
+ timeZones.forEach(offset => {
52
+ const baseTime = 1609459200000 + (offset * 3600000); // Adjust for timezone
53
+ Date.now = jasmine.createSpy('Date.now').and.returnValue(baseTime);
54
+ const encrypted = crypto_util_1.DyFM_Crypto.encrypt(testData, testKey);
55
+ results.push(encrypted);
56
+ });
57
+ // All results should be identical regardless of timezone
58
+ const firstResult = results[0];
59
+ results.forEach(result => {
60
+ expect(result).toEqual(firstResult);
61
+ });
62
+ });
63
+ it('| should handle time-based data consistently', () => {
64
+ const timeBasedData = {
65
+ createdAt: new Date('2023-01-01T00:00:00Z'),
66
+ updatedAt: new Date('2023-12-31T23:59:59Z'),
67
+ timestamp: Date.now(),
68
+ timeString: new Date().toISOString()
69
+ };
70
+ // Test with different system times
71
+ const times = [
72
+ 1609459200000, // 2021-01-01
73
+ 1640995200000, // 2022-01-01
74
+ 1672531200000, // 2023-01-01
75
+ 1704067200000 // 2024-01-01
76
+ ];
77
+ const results = [];
78
+ times.forEach(time => {
79
+ Date.now = jasmine.createSpy('Date.now').and.returnValue(time);
80
+ const encrypted = crypto_util_1.DyFM_Crypto.encrypt(timeBasedData, testKey);
81
+ results.push(encrypted);
82
+ });
83
+ // All results should be identical
84
+ const firstResult = results[0];
85
+ results.forEach(result => {
86
+ expect(result).toEqual(firstResult);
87
+ });
88
+ });
89
+ it('| should maintain consistency across date boundaries', () => {
90
+ const boundaryTimes = [
91
+ 1609459200000, // 2021-01-01 00:00:00
92
+ 1609459259999, // 2021-01-01 00:00:59
93
+ 1609459260000, // 2021-01-01 00:01:00
94
+ 1609545600000, // 2021-01-02 00:00:00
95
+ 1609632000000, // 2021-01-03 00:00:00
96
+ 1640995200000, // 2022-01-01 00:00:00
97
+ 1672531200000 // 2023-01-01 00:00:00
98
+ ];
99
+ const results = [];
100
+ boundaryTimes.forEach(time => {
101
+ Date.now = jasmine.createSpy('Date.now').and.returnValue(time);
102
+ const encrypted = crypto_util_1.DyFM_Crypto.encrypt(testData, testKey);
103
+ results.push(encrypted);
104
+ });
105
+ // All results should be identical
106
+ const firstResult = results[0];
107
+ results.forEach(result => {
108
+ expect(result).toEqual(firstResult);
109
+ });
110
+ });
111
+ it('| should handle leap year transitions consistently', () => {
112
+ const leapYearTimes = [
113
+ 1609459200000, // 2021-01-01 (not leap year)
114
+ 1640995200000, // 2022-01-01 (not leap year)
115
+ 1672531200000, // 2023-01-01 (not leap year)
116
+ 1704067200000, // 2024-01-01 (leap year)
117
+ 1735689600000, // 2025-01-01 (not leap year)
118
+ 1735689600000 + (365 * 24 * 60 * 60 * 1000), // 2025-12-31
119
+ 1735689600000 + (366 * 24 * 60 * 60 * 1000) // 2026-01-01
120
+ ];
121
+ const results = [];
122
+ leapYearTimes.forEach(time => {
123
+ Date.now = jasmine.createSpy('Date.now').and.returnValue(time);
124
+ const encrypted = crypto_util_1.DyFM_Crypto.encrypt(testData, testKey);
125
+ results.push(encrypted);
126
+ });
127
+ // All results should be identical
128
+ const firstResult = results[0];
129
+ results.forEach(result => {
130
+ expect(result).toEqual(firstResult);
131
+ });
132
+ });
133
+ it('| should maintain consistency across daylight saving time transitions', () => {
134
+ // DST transition times (approximate)
135
+ const dstTimes = [
136
+ 1615708800000, // 2021-03-14 (DST start)
137
+ 1615712400000, // 2021-03-14 01:00 (DST start + 1 hour)
138
+ 1636243200000, // 2021-11-07 (DST end)
139
+ 1636246800000, // 2021-11-07 01:00 (DST end + 1 hour)
140
+ 1648339200000, // 2022-03-13 (DST start)
141
+ 1648342800000, // 2022-03-13 01:00 (DST start + 1 hour)
142
+ 1668816000000, // 2022-11-06 (DST end)
143
+ 1668819600000 // 2022-11-06 01:00 (DST end + 1 hour)
144
+ ];
145
+ const results = [];
146
+ dstTimes.forEach(time => {
147
+ Date.now = jasmine.createSpy('Date.now').and.returnValue(time);
148
+ const encrypted = crypto_util_1.DyFM_Crypto.encrypt(testData, testKey);
149
+ results.push(encrypted);
150
+ });
151
+ // All results should be identical
152
+ const firstResult = results[0];
153
+ results.forEach(result => {
154
+ expect(result).toEqual(firstResult);
155
+ });
156
+ });
157
+ it('| should handle microsecond precision consistently', () => {
158
+ const baseTime = 1609459200000;
159
+ const microsecondOffsets = [
160
+ 0,
161
+ 1,
162
+ 10,
163
+ 100,
164
+ 1000,
165
+ 10000,
166
+ 100000,
167
+ 999999
168
+ ];
169
+ const results = [];
170
+ microsecondOffsets.forEach(offset => {
171
+ const time = baseTime + offset;
172
+ Date.now = jasmine.createSpy('Date.now').and.returnValue(time);
173
+ const encrypted = crypto_util_1.DyFM_Crypto.encrypt(testData, testKey);
174
+ results.push(encrypted);
175
+ });
176
+ // All results should be identical
177
+ const firstResult = results[0];
178
+ results.forEach(result => {
179
+ expect(result).toEqual(firstResult);
180
+ });
181
+ });
182
+ it('| should maintain consistency across different Date object states', () => {
183
+ const testDataWithDates = {
184
+ date1: new Date('2023-01-01'),
185
+ date2: new Date('2023-12-31'),
186
+ date3: new Date(),
187
+ date4: new Date(0), // Unix epoch
188
+ date5: new Date(8640000000000000), // Max safe date
189
+ date6: new Date(-8640000000000000) // Min safe date
190
+ };
191
+ const results = [];
192
+ // Test with different system times
193
+ const systemTimes = [1609459200000, 1640995200000, 1672531200000];
194
+ systemTimes.forEach(systemTime => {
195
+ Date.now = jasmine.createSpy('Date.now').and.returnValue(systemTime);
196
+ const encrypted = crypto_util_1.DyFM_Crypto.encrypt(testDataWithDates, testKey);
197
+ results.push(encrypted);
198
+ });
199
+ // All results should be identical
200
+ const firstResult = results[0];
201
+ results.forEach(result => {
202
+ expect(result).toEqual(firstResult);
203
+ });
204
+ });
205
+ it('| should handle time-based encryption/decryption cycles consistently', () => {
206
+ const cycles = 10;
207
+ const results = [];
208
+ for (let i = 0; i < cycles; i++) {
209
+ // Simulate different system times
210
+ const time = 1609459200000 + (i * 86400000); // Add 1 day each cycle
211
+ Date.now = jasmine.createSpy('Date.now').and.returnValue(time);
212
+ const encrypted = crypto_util_1.DyFM_Crypto.encrypt(testData, testKey);
213
+ results.push(encrypted);
214
+ }
215
+ // All results should be identical
216
+ const firstResult = results[0];
217
+ results.forEach(result => {
218
+ expect(result).toEqual(firstResult);
219
+ });
220
+ });
221
+ it('| should maintain consistency with real-world time scenarios', () => {
222
+ const realWorldScenarios = [
223
+ { name: 'New Year 2021', time: 1609459200000 },
224
+ { name: 'Leap Day 2020', time: 1583020800000 },
225
+ { name: 'DST Start 2021', time: 1615708800000 },
226
+ { name: 'DST End 2021', time: 1636243200000 },
227
+ { name: 'Midnight UTC', time: 1609459200000 },
228
+ { name: 'Noon UTC', time: 1609459200000 + (12 * 3600000) },
229
+ { name: 'End of Day', time: 1609459200000 + (23 * 3600000) + (59 * 60000) + (59 * 1000) }
230
+ ];
231
+ const results = [];
232
+ realWorldScenarios.forEach(scenario => {
233
+ Date.now = jasmine.createSpy('Date.now').and.returnValue(scenario.time);
234
+ const encrypted = crypto_util_1.DyFM_Crypto.encrypt(testData, testKey);
235
+ results.push(encrypted);
236
+ });
237
+ // All results should be identical
238
+ const firstResult = results[0];
239
+ results.forEach((result, index) => {
240
+ expect(result).toEqual(firstResult);
241
+ });
242
+ });
243
+ });
244
+ describe('| ERROR HANDLING TESTS - Comprehensive validation', () => {
245
+ const validKey = 'valid-test-key-123';
246
+ const validData = { id: 1, name: 'test' };
247
+ describe('| Encryption Error Cases', () => {
248
+ it('| should throw descriptive error when encrypting undefined data', () => {
249
+ expect(() => crypto_util_1.DyFM_Crypto.encrypt(undefined, validKey)).toThrow();
250
+ });
251
+ it('| should throw descriptive error when encrypting null data', () => {
252
+ expect(() => crypto_util_1.DyFM_Crypto.encrypt(null, validKey)).toThrow();
253
+ });
254
+ it('| should throw descriptive error when encrypting empty string', () => {
255
+ expect(() => crypto_util_1.DyFM_Crypto.encrypt('', validKey)).toThrow();
256
+ });
257
+ it('| should allow empty object for backward compatibility', () => {
258
+ expect(() => crypto_util_1.DyFM_Crypto.encrypt({}, validKey)).not.toThrow();
259
+ });
260
+ it('| should allow empty array for backward compatibility', () => {
261
+ expect(() => crypto_util_1.DyFM_Crypto.encrypt([], validKey)).not.toThrow();
262
+ });
263
+ it('| should throw descriptive error when key is missing', () => {
264
+ expect(() => crypto_util_1.DyFM_Crypto.encrypt(validData, undefined)).toThrow();
265
+ });
266
+ it('| should throw descriptive error when key is null', () => {
267
+ expect(() => crypto_util_1.DyFM_Crypto.encrypt(validData, null)).toThrow();
268
+ });
269
+ it('| should throw descriptive error when key is not a string', () => {
270
+ expect(() => crypto_util_1.DyFM_Crypto.encrypt(validData, 123)).toThrow();
271
+ });
272
+ it('| should throw descriptive error when key is empty string', () => {
273
+ expect(() => crypto_util_1.DyFM_Crypto.encrypt(validData, '')).toThrow();
274
+ });
275
+ it('| should throw descriptive error when key is only whitespace', () => {
276
+ expect(() => crypto_util_1.DyFM_Crypto.encrypt(validData, ' ')).toThrow();
277
+ });
278
+ it('| should warn about short keys but still work', () => {
279
+ // This test just ensures encryption works with short keys
280
+ // Note: Warning is shown in console but spy might not catch it in test environment
281
+ expect(() => crypto_util_1.DyFM_Crypto.encrypt(validData, 'short')).not.toThrow();
282
+ });
283
+ });
284
+ describe('| Decryption Error Cases', () => {
285
+ it('| should throw descriptive error when decrypting undefined data', () => {
286
+ expect(() => crypto_util_1.DyFM_Crypto.decrypt(undefined, validKey)).toThrow();
287
+ });
288
+ it('| should throw descriptive error when decrypting null data', () => {
289
+ expect(() => crypto_util_1.DyFM_Crypto.decrypt(null, validKey)).toThrow();
290
+ });
291
+ it('| should throw descriptive error when decrypting non-string data', () => {
292
+ expect(() => crypto_util_1.DyFM_Crypto.decrypt(123, validKey)).toThrow();
293
+ });
294
+ it('| should throw descriptive error when decrypting empty string', () => {
295
+ expect(() => crypto_util_1.DyFM_Crypto.decrypt('', validKey)).toThrow();
296
+ });
297
+ it('| should throw descriptive error when decrypting too short data', () => {
298
+ expect(() => crypto_util_1.DyFM_Crypto.decrypt('short', validKey)).toThrow();
299
+ });
300
+ it('| should throw descriptive error when decrypting invalid format', () => {
301
+ expect(() => crypto_util_1.DyFM_Crypto.decrypt('invalid!@#format', validKey)).toThrow();
302
+ });
303
+ it('| should throw descriptive error when key is missing for decryption', () => {
304
+ const encrypted = crypto_util_1.DyFM_Crypto.encrypt(validData, validKey);
305
+ expect(() => crypto_util_1.DyFM_Crypto.decrypt(encrypted, undefined)).toThrow();
306
+ });
307
+ it('| should throw descriptive error when key is wrong type for decryption', () => {
308
+ const encrypted = crypto_util_1.DyFM_Crypto.encrypt(validData, validKey);
309
+ expect(() => crypto_util_1.DyFM_Crypto.decrypt(encrypted, 123)).toThrow();
310
+ });
311
+ it('| should throw descriptive error when key is empty for decryption', () => {
312
+ const encrypted = crypto_util_1.DyFM_Crypto.encrypt(validData, validKey);
313
+ expect(() => crypto_util_1.DyFM_Crypto.decrypt(encrypted, '')).toThrow();
314
+ });
315
+ it('| should handle decryption with proper key validation', () => {
316
+ // Test that decryption works with valid key
317
+ const encrypted = crypto_util_1.DyFM_Crypto.encrypt(validData, validKey);
318
+ expect(() => crypto_util_1.DyFM_Crypto.decrypt(encrypted, validKey)).not.toThrow();
319
+ });
320
+ });
321
+ describe('| Decryption Failure Scenarios', () => {
322
+ it('| should throw descriptive error when decrypting with wrong key', () => {
323
+ const encrypted = crypto_util_1.DyFM_Crypto.encrypt(validData, validKey);
324
+ expect(() => crypto_util_1.DyFM_Crypto.decrypt(encrypted, 'wrong-key-123')).toThrow();
325
+ });
326
+ it('| should throw descriptive error when decrypting corrupted data', () => {
327
+ const encrypted = crypto_util_1.DyFM_Crypto.encrypt(validData, validKey);
328
+ const corrupted = encrypted.substring(0, encrypted.length - 10); // Remove last 10 characters
329
+ expect(() => crypto_util_1.DyFM_Crypto.decrypt(corrupted, validKey)).toThrow();
330
+ });
331
+ it('| should throw descriptive error when decrypting invalid base64', () => {
332
+ expect(() => crypto_util_1.DyFM_Crypto.decrypt('invalid-base64!@#', validKey)).toThrow();
333
+ });
334
+ it('| should throw descriptive error when decrypting completely wrong data', () => {
335
+ expect(() => crypto_util_1.DyFM_Crypto.decrypt('this-is-not-encrypted-data', validKey)).toThrow();
336
+ });
337
+ });
338
+ describe('| Edge Case Validations', () => {
339
+ it('| should allow valid data with minimum key length', () => {
340
+ const shortKey = '12345678'; // 8 characters minimum
341
+ const encrypted = crypto_util_1.DyFM_Crypto.encrypt(validData, shortKey);
342
+ const decrypted = crypto_util_1.DyFM_Crypto.decrypt(encrypted, shortKey);
343
+ expect(decrypted).toEqual(validData);
344
+ });
345
+ it('| should allow valid data with whitespace in key', () => {
346
+ const keyWithSpaces = ' valid-key-123 ';
347
+ const encrypted = crypto_util_1.DyFM_Crypto.encrypt(validData, keyWithSpaces);
348
+ const decrypted = crypto_util_1.DyFM_Crypto.decrypt(encrypted, keyWithSpaces);
349
+ expect(decrypted).toEqual(validData);
350
+ });
351
+ it('| should handle special characters in data', () => {
352
+ const specialData = {
353
+ special: '!@#$%^&*()_+-=[]{}|;:,.<>?',
354
+ unicode: '世界你好',
355
+ emoji: '🚀💻🔐'
356
+ };
357
+ const encrypted = crypto_util_1.DyFM_Crypto.encrypt(specialData, validKey);
358
+ const decrypted = crypto_util_1.DyFM_Crypto.decrypt(encrypted, validKey);
359
+ expect(decrypted).toEqual(specialData);
360
+ });
361
+ it('| should handle very long data', () => {
362
+ const longData = {
363
+ text: 'A'.repeat(10000),
364
+ array: Array(1000).fill(0).map((_, i) => i),
365
+ nested: {
366
+ level1: { level2: { level3: { data: 'deep nested data' } } }
367
+ }
368
+ };
369
+ const encrypted = crypto_util_1.DyFM_Crypto.encrypt(longData, validKey);
370
+ const decrypted = crypto_util_1.DyFM_Crypto.decrypt(encrypted, validKey);
371
+ expect(decrypted).toEqual(longData);
372
+ });
373
+ });
374
+ describe('| Error Code Validation', () => {
375
+ it('| should have specific error codes for different failure types', () => {
376
+ try {
377
+ crypto_util_1.DyFM_Crypto.encrypt(undefined, validKey);
378
+ fail('Should have thrown an error');
379
+ }
380
+ catch (error) {
381
+ expect(error._errorCode).toBe('DyFM-CRY-DATA-UNDEFINED');
382
+ }
383
+ try {
384
+ crypto_util_1.DyFM_Crypto.encrypt(validData, '');
385
+ fail('Should have thrown an error');
386
+ }
387
+ catch (error) {
388
+ expect(error._errorCode).toBe('DyFM-CRY-KEY-MISSING');
389
+ }
390
+ try {
391
+ crypto_util_1.DyFM_Crypto.decrypt('', validKey);
392
+ fail('Should have thrown an error');
393
+ }
394
+ catch (error) {
395
+ expect(error._errorCode).toBe('DyFM-CRY-ENCRYPTED-EMPTY');
396
+ }
397
+ });
398
+ });
399
+ });
400
+ describe('| specific byte count and corruption scenarios', () => {
401
+ const validKey = 'valid-test-key-123';
402
+ const validData = { id: 1, name: 'test' };
403
+ it('| should throw DyFM-CRY-DATA-CORRUPTED error with correct message for 18 bytes', () => {
404
+ // Create a base64 string that parses to exactly 18 bytes
405
+ // 18 bytes = 24 base64 characters (18 * 4/3 = 24)
406
+ const exactly18Bytes = 'ABCDEFGHIJKLMNOPQRSTUVWX'; // 24 chars = 18 bytes
407
+ try {
408
+ crypto_util_1.DyFM_Crypto.decrypt(exactly18Bytes, validKey);
409
+ fail('Should have thrown an error');
410
+ }
411
+ catch (error) {
412
+ expect(error._errorCode).toBe('DyFM-CRY-DATA-CORRUPTED');
413
+ // Pre-parse validation catches this, so check for base64 character count message
414
+ expect(error._message || error.message || '').toContain('too short');
415
+ expect(error._message || error.message || '').toContain('characters');
416
+ }
417
+ });
418
+ it('| should throw error for 16 bytes (too short)', () => {
419
+ // 16 bytes = ~22 base64 characters (but we need exact 16 bytes = 21.33 chars, round to 22)
420
+ const exactly16Bytes = 'ABCDEFGHIJKLMNOPQRSTUV'; // 22 chars ≈ 16 bytes
421
+ try {
422
+ crypto_util_1.DyFM_Crypto.decrypt(exactly16Bytes, validKey);
423
+ fail('Should have thrown an error');
424
+ }
425
+ catch (error) {
426
+ expect(error._errorCode).toBe('DyFM-CRY-DATA-CORRUPTED');
427
+ }
428
+ });
429
+ it('| should throw error for 24 bytes (too short)', () => {
430
+ // 24 bytes = 32 base64 characters
431
+ const exactly24Bytes = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCD'; // 32 chars = 24 bytes
432
+ try {
433
+ crypto_util_1.DyFM_Crypto.decrypt(exactly24Bytes, validKey);
434
+ fail('Should have thrown an error');
435
+ }
436
+ catch (error) {
437
+ expect(error._errorCode).toBe('DyFM-CRY-DATA-CORRUPTED');
438
+ // Pre-parse validation catches this, so check for base64 character count message
439
+ expect(error._message || error.message || '').toContain('too short');
440
+ expect(error._message || error.message || '').toContain('characters');
441
+ }
442
+ });
443
+ it('| should throw error for 32 bytes (too short)', () => {
444
+ // 32 bytes = 43 base64 characters (32 * 4/3 = 42.67, round to 43)
445
+ const exactly32Bytes = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOP'; // 43 chars ≈ 32 bytes
446
+ try {
447
+ crypto_util_1.DyFM_Crypto.decrypt(exactly32Bytes, validKey);
448
+ fail('Should have thrown an error');
449
+ }
450
+ catch (error) {
451
+ expect(error._errorCode).toBe('DyFM-CRY-DATA-CORRUPTED');
452
+ // Pre-parse validation catches this, so check for base64 character count message
453
+ expect(error._message || error.message || '').toContain('too short');
454
+ }
455
+ });
456
+ it('| should throw error for 40 bytes (too short)', () => {
457
+ // 40 bytes = 54 base64 characters (40 * 4/3 = 53.33, round to 54)
458
+ const exactly40Bytes = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZAB'; // 54 chars ≈ 40 bytes
459
+ try {
460
+ crypto_util_1.DyFM_Crypto.decrypt(exactly40Bytes, validKey);
461
+ fail('Should have thrown an error');
462
+ }
463
+ catch (error) {
464
+ expect(error._errorCode).toBe('DyFM-CRY-DATA-CORRUPTED');
465
+ // Pre-parse validation catches this, so check for base64 character count message
466
+ expect(error._message || error.message || '').toContain('too short');
467
+ }
468
+ });
469
+ it('| should validate error message includes correct expected byte count (48)', () => {
470
+ const encrypted = crypto_util_1.DyFM_Crypto.encrypt(validData, validKey);
471
+ // Truncate to make it less than 48 bytes
472
+ const truncated = encrypted.substring(0, 20); // Very short
473
+ try {
474
+ crypto_util_1.DyFM_Crypto.decrypt(truncated, validKey);
475
+ fail('Should have thrown an error');
476
+ }
477
+ catch (error) {
478
+ expect(error._errorCode).toBe('DyFM-CRY-DATA-CORRUPTED');
479
+ // Pre-parse validation catches this, so check for base64 character count or byte count message
480
+ const errorMsg = error._message || error.message || '';
481
+ expect(errorMsg).toMatch(/Expected at least|too short|48|bytes|characters/);
482
+ }
483
+ });
484
+ it('| should validate error message includes correct received byte count', () => {
485
+ // Create a base64 string that parses to exactly 18 bytes
486
+ const exactly18Bytes = 'ABCDEFGHIJKLMNOPQRSTUVWX'; // 24 chars = 18 bytes
487
+ try {
488
+ crypto_util_1.DyFM_Crypto.decrypt(exactly18Bytes, validKey);
489
+ fail('Should have thrown an error');
490
+ }
491
+ catch (error) {
492
+ expect(error._errorCode).toBe('DyFM-CRY-DATA-CORRUPTED');
493
+ // Pre-parse validation catches this, so check for character count or byte count in message
494
+ const errorMsg = error._message || error.message || '';
495
+ expect(errorMsg).toMatch(/received|characters|bytes|original/);
496
+ }
497
+ });
498
+ it('| should handle scenarios where base64 string length does not match parsed byte count', () => {
499
+ // Create a base64 string with padding that affects byte count
500
+ const encrypted = crypto_util_1.DyFM_Crypto.encrypt(validData, validKey);
501
+ // Add padding characters that shouldn't be there
502
+ const withExtraPadding = encrypted + '==';
503
+ try {
504
+ crypto_util_1.DyFM_Crypto.decrypt(withExtraPadding, validKey);
505
+ fail('Should have thrown an error');
506
+ }
507
+ catch (error) {
508
+ // Should throw some kind of error (either corrupted or wrong key)
509
+ expect(() => {
510
+ throw error;
511
+ }).toThrow();
512
+ }
513
+ });
514
+ it('| should throw error for 64 bytes when truncated from valid encrypted data', () => {
515
+ const encrypted = crypto_util_1.DyFM_Crypto.encrypt(validData, validKey);
516
+ // Truncate encrypted data to simulate corruption
517
+ // Use a shorter truncation that will definitely fail validation
518
+ // 50 characters is less than 64 (minimum expected), so it will fail pre-parse validation
519
+ const truncated = encrypted.substring(0, 50);
520
+ try {
521
+ crypto_util_1.DyFM_Crypto.decrypt(truncated, validKey);
522
+ fail('Should have thrown an error');
523
+ }
524
+ catch (error) {
525
+ // Should throw an error - DATA-CORRUPTED from pre-parse validation
526
+ expect(error._errorCode).toBe('DyFM-CRY-DATA-CORRUPTED');
527
+ expect(() => {
528
+ throw error;
529
+ }).toThrow();
530
+ }
531
+ });
532
+ it('| should validate error code for various byte count scenarios', () => {
533
+ const byteCounts = [
534
+ { bytes: 16, base64Length: 22 },
535
+ { bytes: 18, base64Length: 24 },
536
+ { bytes: 24, base64Length: 32 },
537
+ { bytes: 32, base64Length: 43 },
538
+ { bytes: 40, base64Length: 54 }
539
+ ];
540
+ byteCounts.forEach(({ base64Length }) => {
541
+ // Create a base64 string of the specified length
542
+ const shortBase64 = 'A'.repeat(base64Length);
543
+ try {
544
+ crypto_util_1.DyFM_Crypto.decrypt(shortBase64, validKey);
545
+ fail(`Should have thrown an error for ${base64Length} character base64 string`);
546
+ }
547
+ catch (error) {
548
+ // All should throw DATA-CORRUPTED or similar error
549
+ expect(error._errorCode).toBeDefined();
550
+ }
551
+ });
552
+ });
553
+ });
554
+ });
555
+ //# sourceMappingURL=crypto.util.extra.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.util.extra.spec.js","sourceRoot":"","sources":["../../../../src/_modules/crypto/_collections/crypto.util.extra.spec.ts"],"names":[],"mappings":";;AAAA,+CAA4C;AAE5C,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IAEzC,QAAQ,CAAC,wDAAwD,EAAE,GAAG,EAAE;QACtE,MAAM,OAAO,GAAG,mBAAmB,CAAC;QACpC,MAAM,QAAQ,GAAG;YACf,EAAE,EAAE,GAAG;YACP,IAAI,EAAE,WAAW;YACjB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,MAAM,EAAE,EAAE,KAAK,EAAE,qBAAqB,EAAE;SACzC,CAAC;QAEF,IAAI,eAA6B,CAAC;QAClC,IAAI,uBAAwC,CAAC;QAE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AAC,KAAK,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,CAAC;gBACzC,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -381,8 +381,26 @@ class DyFM_Crypto {
381
381
  const base64 = encryptedData
382
382
  .replace(/-/g, '+')
383
383
  .replace(/_/g, '/');
384
+ // Add padding if needed (base64 must be multiple of 4 characters)
385
+ // This ensures CryptoJS.parse works correctly even when padding was stripped during URL transmission
386
+ const paddingNeeded = (4 - (base64.length % 4)) % 4;
387
+ const paddedBase64 = base64 + '='.repeat(paddingNeeded);
388
+ // Validate base64 format before parsing
389
+ // Check if the string length makes sense for expected minimum byte count
390
+ // Minimum expected: 48 bytes = ~64 base64 characters (48 * 4/3 = 64)
391
+ const minExpectedBase64Length = Math.ceil((finalConfig.ivLength + finalConfig.saltLength + 16) * 4 / 3);
392
+ if (paddedBase64.length < minExpectedBase64Length) {
393
+ throw new error_control_model_1.DyFM_Error({
394
+ ...this.getDefaultErrorSettings('decrypt'),
395
+ errorCode: 'DyFM-CRY-DATA-CORRUPTED',
396
+ message: `Encrypted data is too short. Expected at least ${minExpectedBase64Length} base64 characters ` +
397
+ `(for ${(finalConfig.ivLength + finalConfig.saltLength + 16)} bytes), ` +
398
+ `but received ${paddedBase64.length} characters (${encryptedData.length} original). ` +
399
+ `This may indicate the data was truncated during transmission or storage.`
400
+ });
401
+ }
384
402
  // Parse the combined data
385
- const combined = CryptoJS.enc.Base64.parse(base64);
403
+ const combined = CryptoJS.enc.Base64.parse(paddedBase64);
386
404
  // For now, skip version checking to maintain backward compatibility
387
405
  // TODO: Implement proper version checking in future versions
388
406
  // Validate minimum length (IV + Salt + minimum ciphertext)
@@ -391,7 +409,10 @@ class DyFM_Crypto {
391
409
  throw new error_control_model_1.DyFM_Error({
392
410
  ...this.getDefaultErrorSettings('decrypt'),
393
411
  errorCode: 'DyFM-CRY-DATA-CORRUPTED',
394
- message: `Encrypted data is corrupted or incomplete. Expected at least ${minLength * 4} bytes, but received ${combined.sigBytes} bytes.`
412
+ message: `Encrypted data is corrupted or incomplete. Expected at least ${minLength * 4} bytes, but received ${combined.sigBytes} bytes. ` +
413
+ `Original string length: ${encryptedData.length} characters. ` +
414
+ `Base64 length: ${base64.length} characters (${paddedBase64.length} with padding). ` +
415
+ `This may indicate the data was truncated during transmission or storage.`
395
416
  });
396
417
  }
397
418
  // Extract IV, salt, and ciphertext (skip version for now)
@@ -545,7 +566,16 @@ class DyFM_Crypto {
545
566
  '\n 1) Wrong encryption key, ' +
546
567
  '\n 2) Corrupted encrypted data, ' +
547
568
  '\n 3) Version incompatibility, ' +
548
- '\n 4) Data was encrypted with different parameters.';
569
+ '\n 4) Data was encrypted with different parameters, ' +
570
+ '\n 5) Data truncation during transmission (check HTTP header size limits, URL length limits), ' +
571
+ '\n 6) Missing base64 padding (should be automatically handled, but may indicate transmission issues).';
572
+ // Add specific guidance for truncation issues (like the "18 bytes" error)
573
+ baseSettings.message += '\n\nFor truncation issues (e.g., "received 18 bytes"): ' +
574
+ '\n - Check if data is being truncated in HTTP headers (Nginx default: 4-8KB, configurable), ' +
575
+ '\n - Verify URL parameter length limits if passed via query string, ' +
576
+ '\n - Check database field size limits if stored, ' +
577
+ '\n - Ensure proxy/load balancer header size limits are sufficient, ' +
578
+ '\n - Verify the encrypted data string length matches expected size before decryption.';
549
579
  }
550
580
  else if (operation === 'encrypt') {
551
581
  baseSettings.message += '\nThis usually indicates: ' +