@futdevpro/fsm-dynamo 1.12.9 → 1.12.11
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.
- package/build/_collections/utils/async.util.d.ts +4 -3
- package/build/_collections/utils/async.util.d.ts.map +1 -1
- package/build/_collections/utils/async.util.js +65 -3
- package/build/_collections/utils/async.util.js.map +1 -1
- package/build/_collections/utils/time.util.js +7 -7
- package/build/_collections/utils/time.util.js.map +1 -1
- package/build/_models/interfaces/search-query.interface.d.ts +11 -0
- package/build/_models/interfaces/search-query.interface.d.ts.map +1 -1
- package/build/_models/types/db-/304/221filter.type.d.ts +2 -1
- package/build/_models/types/db-/304/221filter.type.d.ts.map +1 -1
- package/build/_models/types/db-/304/221filter.type.js.map +1 -1
- package/build/_modules/crypto/_collections/crypto-old.util.d.ts +107 -0
- package/build/_modules/crypto/_collections/crypto-old.util.d.ts.map +1 -0
- package/build/_modules/crypto/_collections/crypto-old.util.js +279 -0
- package/build/_modules/crypto/_collections/crypto-old.util.js.map +1 -0
- package/build/_modules/crypto/_collections/crypto.util.d.ts +38 -6
- package/build/_modules/crypto/_collections/crypto.util.d.ts.map +1 -1
- package/build/_modules/crypto/_collections/crypto.util.js +298 -36
- package/build/_modules/crypto/_collections/crypto.util.js.map +1 -1
- package/build/_modules/crypto/_collections/crypto.util.spec.js +397 -2
- package/build/_modules/crypto/_collections/crypto.util.spec.js.map +1 -1
- package/build/_modules/crypto/index.d.ts +1 -1
- package/build/_modules/crypto/index.d.ts.map +1 -1
- package/build/_modules/crypto/index.js +1 -1
- package/build/_modules/crypto/index.js.map +1 -1
- package/futdevpro-fsm-dynamo-01.12.11.tgz +0 -0
- package/package.json +1 -1
- package/src/_collections/utils/async.util.ts +65 -4
- package/src/_collections/utils/time.util.ts +7 -7
- package/src/_models/interfaces/search-query.interface.ts +11 -0
- package/src/_models/types/db-/304/221filter.type.ts +6 -5
- package/src/_modules/crypto/_collections/crypto-old.util.ts +323 -0
- package/src/_modules/crypto/_collections/crypto.util.spec.ts +475 -2
- package/src/_modules/crypto/_collections/crypto.util.ts +337 -43
- package/src/_modules/crypto/index.ts +1 -1
- package/futdevpro-fsm-dynamo-01.12.09.tgz +0 -0
|
@@ -5,9 +5,9 @@ export declare class DyFM_Async {
|
|
|
5
5
|
* @param ms
|
|
6
6
|
* @returns
|
|
7
7
|
*/
|
|
8
|
-
static
|
|
9
|
-
static readonly sleep: typeof this.
|
|
10
|
-
static readonly
|
|
8
|
+
static wait(ms: number): Promise<void>;
|
|
9
|
+
static readonly sleep: typeof this.wait;
|
|
10
|
+
static readonly delay: typeof this.wait;
|
|
11
11
|
/**
|
|
12
12
|
* WARNING: This function is recommended to use ONLY for limited instances,
|
|
13
13
|
* because it can cause performance issues.
|
|
@@ -29,5 +29,6 @@ export declare class DyFM_Async {
|
|
|
29
29
|
* Creates a promise that resolves when the observable emits a value that passes the check function
|
|
30
30
|
*/
|
|
31
31
|
static takeUntil<T>(observable: Observable<T>, check: (value?: T) => boolean): Promise<T>;
|
|
32
|
+
static waitWithCountdownLogging(totalWaitTimeMs: number, context?: string): Promise<void>;
|
|
32
33
|
}
|
|
33
34
|
//# sourceMappingURL=async.util.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async.util.d.ts","sourceRoot":"","sources":["../../../src/_collections/utils/async.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"async.util.d.ts","sourceRoot":"","sources":["../../../src/_collections/utils/async.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAMlC,qBAAa,UAAU;IAErB;;;;OAIG;IACH,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAGtC,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,IAAI,CAAC,IAAI,CAAa;IACpD,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,IAAI,CAAC,IAAI,CAAa;IAEpD;;;OAGG;IACH,MAAM,CAAC,SAAS,CACd,KAAK,EAAE,MAAM,OAAO,EACpB,QAAQ,GAAE,MAAY,EACtB,OAAO,GAAE,MAAe,GACvB,OAAO,CAAC,IAAI,CAAC;IAmBhB;;;;;;;;;;OAUG;IACH,MAAM,CAAC,cAAc,CACnB,KAAK,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,EAC7B,QAAQ,GAAE,MAAY,EACtB,OAAO,GAAE,MAAc,GACtB,OAAO,CAAC,IAAI,CAAC;IAmBhB;;OAEG;IACH,MAAM,CAAC,SAAS,CAAC,CAAC,EAChB,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,EACzB,KAAK,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,OAAO,GAC5B,OAAO,CAAC,CAAC,CAAC;WAaA,wBAAwB,CACnC,eAAe,EAAE,MAAM,EACvB,OAAO,GAAE,MAAoB,GAC5B,OAAO,CAAC,IAAI,CAAC;CAuDjB"}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DyFM_Async = void 0;
|
|
4
|
+
const times_const_1 = require("../constants/times.const");
|
|
5
|
+
const time_util_1 = require("./time.util");
|
|
6
|
+
const log_util_1 = require("./log.util");
|
|
4
7
|
class DyFM_Async {
|
|
5
8
|
/**
|
|
6
9
|
* delays the execution of a function
|
|
7
10
|
* @param ms
|
|
8
11
|
* @returns
|
|
9
12
|
*/
|
|
10
|
-
static
|
|
13
|
+
static wait(ms) {
|
|
11
14
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
12
15
|
}
|
|
13
|
-
static sleep = this.
|
|
14
|
-
static
|
|
16
|
+
static sleep = this.wait;
|
|
17
|
+
static delay = this.wait;
|
|
15
18
|
/**
|
|
16
19
|
* WARNING: This function is recommended to use ONLY for limited instances,
|
|
17
20
|
* because it can cause performance issues.
|
|
@@ -72,6 +75,65 @@ class DyFM_Async {
|
|
|
72
75
|
});
|
|
73
76
|
});
|
|
74
77
|
}
|
|
78
|
+
static async waitWithCountdownLogging(totalWaitTimeMs, context = 'Countdown') {
|
|
79
|
+
const startTime = Date.now();
|
|
80
|
+
const endTime = startTime + totalWaitTimeMs;
|
|
81
|
+
// Define logging intervals based on total duration
|
|
82
|
+
const getLogInterval = (totalMs) => {
|
|
83
|
+
const totalSeconds = totalMs / times_const_1.second;
|
|
84
|
+
const totalMinutes = totalSeconds / 60;
|
|
85
|
+
const totalHours = totalMinutes / 60;
|
|
86
|
+
const totalDays = totalHours / 24;
|
|
87
|
+
const totalWeeks = totalDays / 7;
|
|
88
|
+
if (totalWeeks >= 4)
|
|
89
|
+
return times_const_1.week; // Every week
|
|
90
|
+
if (totalDays >= 7)
|
|
91
|
+
return times_const_1.day; // Every day
|
|
92
|
+
if (totalDays >= 3)
|
|
93
|
+
return 12 * times_const_1.hour; // Every 12 hours
|
|
94
|
+
if (totalDays >= 1)
|
|
95
|
+
return 6 * times_const_1.hour; // Every 6 hours
|
|
96
|
+
if (totalHours >= 12)
|
|
97
|
+
return 3 * times_const_1.hour; // Every 3 hours
|
|
98
|
+
if (totalHours >= 6)
|
|
99
|
+
return times_const_1.hour; // Every hour
|
|
100
|
+
if (totalHours >= 3)
|
|
101
|
+
return 30 * times_const_1.minute; // Every 30 minutes
|
|
102
|
+
if (totalHours >= 1)
|
|
103
|
+
return 10 * times_const_1.minute; // Every 10 minutes
|
|
104
|
+
if (totalMinutes >= 30)
|
|
105
|
+
return 5 * times_const_1.minute; // Every 5 minutes
|
|
106
|
+
if (totalMinutes >= 10)
|
|
107
|
+
return times_const_1.minute; // Every minute
|
|
108
|
+
if (totalMinutes >= 5)
|
|
109
|
+
return 30 * times_const_1.second; // Every 30 seconds
|
|
110
|
+
if (totalMinutes >= 1)
|
|
111
|
+
return 10 * times_const_1.second; // Every 10 seconds
|
|
112
|
+
if (totalSeconds >= 30)
|
|
113
|
+
return 5 * times_const_1.second; // Every 5 seconds
|
|
114
|
+
return times_const_1.second; // Every second
|
|
115
|
+
};
|
|
116
|
+
const logInterval = getLogInterval(totalWaitTimeMs);
|
|
117
|
+
let lastLogTime = startTime;
|
|
118
|
+
// Format remaining time for display using DyFM_Time utility
|
|
119
|
+
const formatRemainingTime = (remainingMs) => time_util_1.DyFM_Time.getTimeInShortestString(remainingMs);
|
|
120
|
+
// Log initial countdown start
|
|
121
|
+
log_util_1.DyFM_Log.info(`⏳ ${context} started - Total duration: ${formatRemainingTime(totalWaitTimeMs)}`);
|
|
122
|
+
while (Date.now() < endTime) {
|
|
123
|
+
const now = Date.now();
|
|
124
|
+
const remainingMs = endTime - now;
|
|
125
|
+
// Check if it's time to log
|
|
126
|
+
if (now - lastLogTime >= logInterval) {
|
|
127
|
+
const remainingTime = formatRemainingTime(remainingMs);
|
|
128
|
+
log_util_1.DyFM_Log.info(`⏳ ${context} - ${remainingTime} remaining`);
|
|
129
|
+
lastLogTime = now;
|
|
130
|
+
}
|
|
131
|
+
// Wait for a short interval before checking again
|
|
132
|
+
await DyFM_Async.wait(Math.min(time_util_1.DyFM_Time.second, remainingMs));
|
|
133
|
+
}
|
|
134
|
+
// Log completion
|
|
135
|
+
log_util_1.DyFM_Log.success(`✅ ${context} completed`);
|
|
136
|
+
}
|
|
75
137
|
}
|
|
76
138
|
exports.DyFM_Async = DyFM_Async;
|
|
77
139
|
//# sourceMappingURL=async.util.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async.util.js","sourceRoot":"","sources":["../../../src/_collections/utils/async.util.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"async.util.js","sourceRoot":"","sources":["../../../src/_collections/utils/async.util.ts"],"names":[],"mappings":";;;AACA,0DAA2E;AAC3E,2CAAwC;AACxC,yCAAsC;AAGtC,MAAa,UAAU;IAErB;;;;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D;QAC5D,MAAM,mBAAmB,GAAG,CAAC,WAAmB,EAAU,EAAE,CAAC,qBAAS,CAAC,uBAAuB,CAAC,WAAW,CAAW,CAAC;QAEtH,8BAA8B;QAC9B,mBAAQ,CAAC,IAAI,CAAC,KAAK,OAAO,8BAA8B,mBAAmB,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;QAEhG,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC;YAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACvB,MAAM,WAAW,GAAG,OAAO,GAAG,GAAG,CAAC;YAElC,4BAA4B;YAC5B,IAAI,GAAG,GAAG,WAAW,IAAI,WAAW,EAAE,CAAC;gBACrC,MAAM,aAAa,GAAG,mBAAmB,CAAC,WAAW,CAAC,CAAC;gBACvD,mBAAQ,CAAC,IAAI,CAAC,KAAK,OAAO,MAAM,aAAa,YAAY,CAAC,CAAC;gBAC3D,WAAW,GAAG,GAAG,CAAC;YACpB,CAAC;YAED,kDAAkD;YAClD,MAAM,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,qBAAS,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;QACjE,CAAC;QAED,iBAAiB;QACjB,mBAAQ,CAAC,OAAO,CAAC,KAAK,OAAO,YAAY,CAAC,CAAC;IAC7C,CAAC;;AAtJH,gCAuJC"}
|
|
@@ -217,25 +217,25 @@ class DyFM_Time {
|
|
|
217
217
|
return `${duration}ms`;
|
|
218
218
|
}
|
|
219
219
|
else if (duration < times_const_1.minute) {
|
|
220
|
-
return `${math_util_1.DyFM_Math.round(duration / times_const_1.second)}s ${duration % times_const_1.second}ms`;
|
|
220
|
+
return `${math_util_1.DyFM_Math.round(duration / times_const_1.second, 0)}s ${duration % times_const_1.second}ms`;
|
|
221
221
|
}
|
|
222
222
|
else if (duration < times_const_1.hour) {
|
|
223
|
-
return `${math_util_1.DyFM_Math.round(duration / times_const_1.minute)}m ${math_util_1.DyFM_Math.round(duration % times_const_1.minute)}s`;
|
|
223
|
+
return `${math_util_1.DyFM_Math.round(duration / times_const_1.minute, 0)}m ${math_util_1.DyFM_Math.round(duration % times_const_1.minute)}s`;
|
|
224
224
|
}
|
|
225
225
|
else if (duration < times_const_1.day) {
|
|
226
|
-
return `${math_util_1.DyFM_Math.round(duration / times_const_1.hour)}h ${math_util_1.DyFM_Math.round(duration % times_const_1.hour)}m`;
|
|
226
|
+
return `${math_util_1.DyFM_Math.round(duration / times_const_1.hour, 0)}h ${math_util_1.DyFM_Math.round(duration % times_const_1.hour)}m`;
|
|
227
227
|
}
|
|
228
228
|
else if (duration < times_const_1.week) {
|
|
229
|
-
return `${math_util_1.DyFM_Math.round(duration / times_const_1.day)}d ${math_util_1.DyFM_Math.round(duration % times_const_1.day)}h`;
|
|
229
|
+
return `${math_util_1.DyFM_Math.round(duration / times_const_1.day, 0)}d ${math_util_1.DyFM_Math.round(duration % times_const_1.day)}h`;
|
|
230
230
|
}
|
|
231
231
|
else if (duration < times_const_1.month) {
|
|
232
|
-
return `${math_util_1.DyFM_Math.round(duration / times_const_1.week)}w ${math_util_1.DyFM_Math.round(duration % times_const_1.week)}d`;
|
|
232
|
+
return `${math_util_1.DyFM_Math.round(duration / times_const_1.week, 0)}w ${math_util_1.DyFM_Math.round(duration % times_const_1.week)}d`;
|
|
233
233
|
}
|
|
234
234
|
else if (duration < times_const_1.year) {
|
|
235
|
-
return `${math_util_1.DyFM_Math.round(duration / times_const_1.month)}m ${math_util_1.DyFM_Math.round(duration % times_const_1.month)}w`;
|
|
235
|
+
return `${math_util_1.DyFM_Math.round(duration / times_const_1.month, 0)}m ${math_util_1.DyFM_Math.round(duration % times_const_1.month)}w`;
|
|
236
236
|
}
|
|
237
237
|
else {
|
|
238
|
-
return `${math_util_1.DyFM_Math.round(duration / times_const_1.year)}y ${math_util_1.DyFM_Math.round(duration % times_const_1.year)}m`;
|
|
238
|
+
return `${math_util_1.DyFM_Math.round(duration / times_const_1.year, 0)}y ${math_util_1.DyFM_Math.round(duration % times_const_1.year)}m`;
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
241
|
static getTimeInShortestString(time) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.util.js","sourceRoot":"","sources":["../../../src/_collections/utils/time.util.ts"],"names":[],"mappings":";;;AACA,0DAAwF;AACxF,6DAA0D;AAC1D,yEAAoE;AACpE,6EAAyE;AACzE,gDAA6C;AAE7C,qCAAqC;AACrC;;GAEG;AACH,MAAa,SAAS;IAEpB;;OAEG;IACH,MAAM,CAAU,MAAM,GAAG,oBAAM,CAAC;IAEhC;;OAEG;IACH,MAAM,CAAU,MAAM,GAAG,oBAAM,CAAC;IAEhC;;OAEG;IACH,MAAM,CAAU,IAAI,GAAG,kBAAI,CAAC;IAE5B;;OAEG;IACH,MAAM,CAAU,GAAG,GAAG,iBAAG,CAAC;IAE1B;;OAEG;IACH,MAAM,CAAU,IAAI,GAAG,kBAAI,CAAC;IAE5B;;OAEG;IACH,MAAM,CAAU,KAAK,GAAG,mBAAK,CAAC;IAE9B;;OAEG;IACH,MAAM,CAAU,IAAI,GAAG,kBAAI,CAAC;IAE5B;;;;OAIG;IACH,MAAM,CAAC,MAAM,CAAC,SAAiC;QAC7C,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,IAAI,EAAE,GAAG,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAC1D,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,OAAO,CAAC,IAA4B;QACzC,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7B,IAAI,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC;QAED,OAAO,CAAC,CAAC,IAAI,GAAI,kBAAI,CAAC,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,OAAO,CAAC,IAA4B;QACzC,IAAI,OAAO,IAAI,K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AAC,EAAE,CAAC;YACtB,OAAO,GAAG,IAAI,GAAG,kBAAI,GAAG,CAAC;QAC3B,CAAC;aAAM,IAAI,IAAI,GAAG,mBAAK,KAAK,CAAC,EAAE,CAAC;YAC9B,OAAO,GAAG,IAAI,GAAG,mBAAK,GAAG,CAAC;QAC5B,CAAC;aAAM,IAAI,IAAI,GAAG,kBAAI,KAAK,CAAC,EAAE,CAAC;YAC7B,OAAO,GAAG,IAAI,GAAG,kBAAI,GAAG,CAAC;QAC3B,CAAC;aAAM,IAAI,IAAI,GAAG,iBAAG,KAAK,CAAC,EAAE,CAAC;YAC5B,OAAO,GAAG,IAAI,GAAG,iBAAG,GAAG,CAAC;QAC1B,CAAC;aAAM,IAAI,IAAI,GAAG,kBAAI,KAAK,CAAC,EAAE,CAAC;YAC7B,OAAO,GAAG,IAAI,GAAG,kBAAI,GAAG,CAAC;QAC3B,CAAC;aAAM,IAAI,IAAI,GAAG,oBAAM,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,GAAG,IAAI,GAAG,oBAAM,GAAG,CAAC;QAC7B,CAAC;aAAM,IAAI,IAAI,GAAG,oBAAM,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,GAAG,IAAI,GAAG,oBAAM,GAAG,CAAC;QAC7B,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,IAAI,IAAI,CAAC;QACrB,CAAC;IACH,CAAC;;AA3RH,8BA4RC"}
|
|
@@ -2,8 +2,19 @@ import { DyFM_DBĐFilter } from '../types/db-đfilter.type';
|
|
|
2
2
|
import { DyFM_DBĐSort } from '../types/db-đsort.type';
|
|
3
3
|
export interface DyFM_SearchQuery<T> {
|
|
4
4
|
filterBy?: DyFM_DBĐFilter<T>;
|
|
5
|
+
/**
|
|
6
|
+
* The sort order to load.
|
|
7
|
+
* The last sort will apply last, so it will be the strongest sort.
|
|
8
|
+
*/
|
|
5
9
|
sortBy?: DyFM_DBĐSort[];
|
|
10
|
+
/**
|
|
11
|
+
* The page index number to load.
|
|
12
|
+
* 0-indexed.
|
|
13
|
+
*/
|
|
6
14
|
page?: number;
|
|
15
|
+
/**
|
|
16
|
+
* The page size to load.
|
|
17
|
+
*/
|
|
7
18
|
pageSize?: number;
|
|
8
19
|
}
|
|
9
20
|
//# sourceMappingURL=search-query.interface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-query.interface.d.ts","sourceRoot":"","sources":["../../../src/_models/interfaces/search-query.interface.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,MAAM,WAAW,gBAAgB,CAAC,CAAC;IACjC,QAAQ,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IAC7B,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
|
|
1
|
+
{"version":3,"file":"search-query.interface.d.ts","sourceRoot":"","sources":["../../../src/_models/interfaces/search-query.interface.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,MAAM,WAAW,gBAAgB,CAAC,CAAC;IACjC,QAAQ,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IAC7B;;;OAGG;IACH,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC;IACxB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -6,8 +6,9 @@ import { DyFM_RangeValue } from '../control-models/range-value.control-model';
|
|
|
6
6
|
* it should be the value, a range or an array of the searching values
|
|
7
7
|
*/
|
|
8
8
|
export type DyFM_DBĐFilter<T> = {
|
|
9
|
-
[K in keyof T]?:
|
|
9
|
+
[K in keyof T]?: DyFM_DBĐFilterProperty<T, K>;
|
|
10
10
|
};
|
|
11
|
+
export type DyFM_DBĐFilterProperty<T, K extends keyof T> = T[K] | T[K][] | DyFM_RangeValue<T[K]> | DyFM_SpecialSearch<T[K]> | DyFM_SpecialNestSearch;
|
|
11
12
|
export interface DyFM_SpecialSearch<T> {
|
|
12
13
|
isSpecialSearch: true;
|
|
13
14
|
searchValue: T | T[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db-đfilter.type.d.ts","sourceRoot":"","sources":["../../../src/_models/types/db-đfilter.type.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAE9E;;;;GAIG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI;KAC7B,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAG,CAAC,CAAC,CAAC,CAAC,GACJ,CAAC,CAAC,CAAC,CAAC,EAAE,GACN,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GACrB,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GACxB,sBAAsB
|
|
1
|
+
{"version":3,"file":"db-đfilter.type.d.ts","sourceRoot":"","sources":["../../../src/_models/types/db-đfilter.type.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAE9E;;;;GAIG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI;KAC7B,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAG,sBAAsB,CAAC,CAAC,EAAE,CAAC,CAAC;CAC/C,CAAC;AACF,MAAM,MAAM,sBAAsB,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAK,CAAC,CAAC,CAAC,CAAC,GACJ,CAAC,CAAC,CAAC,CAAC,EAAE,GACN,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GACrB,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GACxB,sBAAsB,CAAC;AAEnF,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC,eAAe,EAAE,IAAI,CAAC;IACtB,WAAW,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;IACrB,IAAI,EAAE,uBAAuB,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,mBAAmB,EAAE,IAAI,CAAC;IAC1B,sBAAsB,EAAE,uBAAuB,CAAC,GAAG,CAAC,EAAE,CAAC;CACxD;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB,CAAC,CAAC;IACxC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,EAAE,uBAAuB,CAAC;IACnC,MAAM,EAAE,CAAC,GACD,CAAC,EAAE,GACH,eAAe,CAAC,CAAC,CAAC,GAClB,kBAAkB,CAAC,CAAC,CAAC,CAAC;CAC/B;AAED,oBAAY,uBAAuB;IACjC;;SAEK;IACL,mBAAmB,wBAAwB;IAC3C;;SAEK;IACL,gBAAgB,qBAAqB;IACrC;;SAEK;IACL,uBAAuB,4BAA4B;CACpD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db-đfilter.type.js","sourceRoot":"","sources":["../../../src/_models/types/db-đfilter.type.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"db-đfilter.type.js","sourceRoot":"","sources":["../../../src/_models/types/db-đfilter.type.ts"],"names":[],"mappings":";;;AA8CA,IAAY,uBAaX;AAbD,WAAY,uBAAuB;IACjC;;SAEK;IACL,sEAA2C,CAAA;IAC3C;;SAEK;IACL,gEAAqC,CAAA;IACrC;;SAEK;IACL,8EAAmD,CAAA;AACrD,CAAC,EAbW,uBAAuB,uCAAvB,uBAAuB,QAalC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration options for encryption/decryption
|
|
3
|
+
*/
|
|
4
|
+
export interface CryptoConfig {
|
|
5
|
+
ivLength?: number;
|
|
6
|
+
saltLength?: number;
|
|
7
|
+
keyIterations?: number;
|
|
8
|
+
keySize?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A utility class for stable encryption and decryption of data
|
|
12
|
+
* Uses AES-256-CBC with deterministic IV and salt for consistent results across systems
|
|
13
|
+
* Prioritizes reliability and cross-platform compatibility over security
|
|
14
|
+
*
|
|
15
|
+
* @important DETERMINISTIC ENCRYPTION: This implementation produces identical encrypted
|
|
16
|
+
* output for identical input data and key across different systems and multiple calls.
|
|
17
|
+
* The same input will ALWAYS generate the same encrypted string on any platform.
|
|
18
|
+
*
|
|
19
|
+
* @warning SECURITY NOTICE: This deterministic behavior is intentional for cross-platform
|
|
20
|
+
* compatibility but reduces security. Identical inputs produce identical outputs, which
|
|
21
|
+
* can be exploited for pattern analysis attacks. Use only when consistency across
|
|
22
|
+
* systems is more important than cryptographic security.
|
|
23
|
+
*/
|
|
24
|
+
export declare class DyFM_Crypto {
|
|
25
|
+
private static readonly DEFAULT_CONFIG;
|
|
26
|
+
private static readonly defaultErrorUserMsg;
|
|
27
|
+
/**
|
|
28
|
+
* Validates the input data and key
|
|
29
|
+
* @throws {DyFM_Error} if validation fails
|
|
30
|
+
*/
|
|
31
|
+
private static validateInput;
|
|
32
|
+
/**
|
|
33
|
+
* Generates a deterministic IV based on the input data and key
|
|
34
|
+
* Uses MD5 for better stability across different CryptoJS versions
|
|
35
|
+
*
|
|
36
|
+
* @important DETERMINISTIC: Same data + key will ALWAYS produce the same IV
|
|
37
|
+
* across all systems and CryptoJS versions for consistent encryption results
|
|
38
|
+
*/
|
|
39
|
+
private static generateIV;
|
|
40
|
+
/**
|
|
41
|
+
* Generates a deterministic salt based on the input data and key
|
|
42
|
+
* Uses MD5 for better stability across different CryptoJS versions
|
|
43
|
+
*
|
|
44
|
+
* @important DETERMINISTIC: Same data + key will ALWAYS produce the same salt
|
|
45
|
+
* across all systems and CryptoJS versions for consistent encryption results
|
|
46
|
+
*/
|
|
47
|
+
private static generateSalt;
|
|
48
|
+
/**
|
|
49
|
+
* Derives a key using PBKDF2 with reduced iterations for stability
|
|
50
|
+
*/
|
|
51
|
+
private static deriveKey;
|
|
52
|
+
/**
|
|
53
|
+
* Safely serializes data to JSON
|
|
54
|
+
*/
|
|
55
|
+
private static safeSerialize;
|
|
56
|
+
/**
|
|
57
|
+
* Safely deserializes JSON data
|
|
58
|
+
*/
|
|
59
|
+
private static safeDeserialize;
|
|
60
|
+
/**
|
|
61
|
+
* Encrypts data using AES-256-CBC with deterministic IV and salt
|
|
62
|
+
*
|
|
63
|
+
* @important DETERMINISTIC BEHAVIOR: This method will produce identical encrypted
|
|
64
|
+
* output for identical input parameters across different systems, Node.js versions,
|
|
65
|
+
* and multiple function calls. The same data + key combination will ALWAYS generate
|
|
66
|
+
* the same encrypted string.
|
|
67
|
+
*
|
|
68
|
+
* @param data The data to encrypt
|
|
69
|
+
* @param key The encryption key
|
|
70
|
+
* @param config Optional configuration
|
|
71
|
+
* @returns URL-safe encrypted string that is identical across systems for same input
|
|
72
|
+
* @throws {DyFM_Error} if encryption fails
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* // These will produce identical results on any system:
|
|
76
|
+
* const result1 = DyFM_Crypto.encrypt({id: 1}, "mykey");
|
|
77
|
+
* const result2 = DyFM_Crypto.encrypt({id: 1}, "mykey");
|
|
78
|
+
* console.log(result1 === result2); // Always true
|
|
79
|
+
*/
|
|
80
|
+
static encrypt<T>(data: T, key: string, config?: CryptoConfig): string;
|
|
81
|
+
/**
|
|
82
|
+
* Decrypts data that was encrypted using encrypt()
|
|
83
|
+
* @param encryptedData The encrypted data
|
|
84
|
+
* @param key The decryption key
|
|
85
|
+
* @param config Optional configuration
|
|
86
|
+
* @returns The decrypted data
|
|
87
|
+
* @throws {DyFM_Error} if decryption fails
|
|
88
|
+
*/
|
|
89
|
+
static decrypt<T>(encryptedData: string, key: string, config?: CryptoConfig): T;
|
|
90
|
+
/**
|
|
91
|
+
* Generates a secure random key
|
|
92
|
+
* @param length Length of the key in bytes (default: 32)
|
|
93
|
+
* @returns A secure random key
|
|
94
|
+
*/
|
|
95
|
+
static generateKey(length?: number): string;
|
|
96
|
+
/**
|
|
97
|
+
* Validates if a string is a valid encrypted data
|
|
98
|
+
* @param encryptedData The data to validate
|
|
99
|
+
* @returns true if the data appears to be valid encrypted data
|
|
100
|
+
*/
|
|
101
|
+
static isValidEncryptedData(encryptedData: string): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Gets default error settings
|
|
104
|
+
*/
|
|
105
|
+
private static getDefaultErrorSettings;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=crypto-old.util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto-old.util.d.ts","sourceRoot":"","sources":["../../../../src/_modules/crypto/_collections/crypto-old.util.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAMD;;;;;;;;;;;;;GAaG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAKpC;IACF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAEY;IAEvD;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,aAAa;IAmB5B;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,UAAU;IAQzB;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,YAAY;IAQ3B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,SAAS;IAOxB;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,aAAa;IAa5B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,eAAe;IAuC9B;;;;;;;;;;;;;;;;;;;OAmBG;IACH,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM;IAsCtE;;;;;;;OAOG;IACH,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,CAAC;IAwD/E;;;;OAIG;IACH,MAAM,CAAC,WAAW,CAAC,MAAM,GAAE,MAAW,GAAG,MAAM;IAI/C;;;;OAIG;IACH,MAAM,CAAC,oBAAoB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO;IAO3D;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,uBAAuB;CAQvC"}
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DyFM_Crypto = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const CryptoJS = tslib_1.__importStar(require("crypto-js"));
|
|
6
|
+
const error_control_model_1 = require("../../../_models/control-models/error.control-model");
|
|
7
|
+
const object_util_1 = require("../../../_collections/utils/object.util");
|
|
8
|
+
// Compact: about 60–80 character tokens, not 200+
|
|
9
|
+
// Non-standard: hard to reverse-engineer
|
|
10
|
+
// Usable in cookies, headers, URLs
|
|
11
|
+
/**
|
|
12
|
+
* A utility class for stable encryption and decryption of data
|
|
13
|
+
* Uses AES-256-CBC with deterministic IV and salt for consistent results across systems
|
|
14
|
+
* Prioritizes reliability and cross-platform compatibility over security
|
|
15
|
+
*
|
|
16
|
+
* @important DETERMINISTIC ENCRYPTION: This implementation produces identical encrypted
|
|
17
|
+
* output for identical input data and key across different systems and multiple calls.
|
|
18
|
+
* The same input will ALWAYS generate the same encrypted string on any platform.
|
|
19
|
+
*
|
|
20
|
+
* @warning SECURITY NOTICE: This deterministic behavior is intentional for cross-platform
|
|
21
|
+
* compatibility but reduces security. Identical inputs produce identical outputs, which
|
|
22
|
+
* can be exploited for pattern analysis attacks. Use only when consistency across
|
|
23
|
+
* systems is more important than cryptographic security.
|
|
24
|
+
*/
|
|
25
|
+
class DyFM_Crypto {
|
|
26
|
+
static DEFAULT_CONFIG = {
|
|
27
|
+
ivLength: 16, // 128 bits
|
|
28
|
+
saltLength: 16, // 128 bits
|
|
29
|
+
keyIterations: 1000, // Reduced for better performance and stability
|
|
30
|
+
keySize: 8 // 256 bits (8 * 32)
|
|
31
|
+
};
|
|
32
|
+
static defaultErrorUserMsg = `We encountered an unhandled Authentication Error, ` +
|
|
33
|
+
`\nplease contact the responsible development team.`;
|
|
34
|
+
/**
|
|
35
|
+
* Validates the input data and key
|
|
36
|
+
* @throws {DyFM_Error} if validation fails
|
|
37
|
+
*/
|
|
38
|
+
static validateInput(data, key) {
|
|
39
|
+
if (!key || typeof key !== 'string' || key.trim().length === 0) {
|
|
40
|
+
throw new error_control_model_1.DyFM_Error({
|
|
41
|
+
...this.getDefaultErrorSettings('validateInput'),
|
|
42
|
+
errorCode: 'DyFM-CRY-IKY',
|
|
43
|
+
message: 'Invalid encryption key'
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
// Allow null values but not undefined
|
|
47
|
+
if (data === undefined) {
|
|
48
|
+
throw new error_control_model_1.DyFM_Error({
|
|
49
|
+
...this.getDefaultErrorSettings('validateInput'),
|
|
50
|
+
errorCode: 'DyFM-CRY-IDT',
|
|
51
|
+
message: `Invalid data to encrypt/decrypt (is "${data}")`
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Generates a deterministic IV based on the input data and key
|
|
57
|
+
* Uses MD5 for better stability across different CryptoJS versions
|
|
58
|
+
*
|
|
59
|
+
* @important DETERMINISTIC: Same data + key will ALWAYS produce the same IV
|
|
60
|
+
* across all systems and CryptoJS versions for consistent encryption results
|
|
61
|
+
*/
|
|
62
|
+
static generateIV(data, key, config) {
|
|
63
|
+
// Use MD5 for better stability - simpler hash algorithm, more consistent across versions
|
|
64
|
+
const combined = data + key;
|
|
65
|
+
const hash = CryptoJS.MD5(combined);
|
|
66
|
+
// Use slice(0, 4) for 16 bytes - more stable than division operations
|
|
67
|
+
return CryptoJS.lib.WordArray.create(hash.words.slice(0, 4));
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Generates a deterministic salt based on the input data and key
|
|
71
|
+
* Uses MD5 for better stability across different CryptoJS versions
|
|
72
|
+
*
|
|
73
|
+
* @important DETERMINISTIC: Same data + key will ALWAYS produce the same salt
|
|
74
|
+
* across all systems and CryptoJS versions for consistent encryption results
|
|
75
|
+
*/
|
|
76
|
+
static generateSalt(data, key, config) {
|
|
77
|
+
// Use MD5 for better stability - simpler hash algorithm, more consistent across versions
|
|
78
|
+
const combined = key + data;
|
|
79
|
+
const hash = CryptoJS.MD5(combined);
|
|
80
|
+
// Use slice(0, 4) for 16 bytes - more stable than division operations
|
|
81
|
+
return CryptoJS.lib.WordArray.create(hash.words.slice(0, 4));
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Derives a key using PBKDF2 with reduced iterations for stability
|
|
85
|
+
*/
|
|
86
|
+
static deriveKey(key, salt, config) {
|
|
87
|
+
return CryptoJS.PBKDF2(key, salt, {
|
|
88
|
+
keySize: config.keySize,
|
|
89
|
+
iterations: config.keyIterations
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Safely serializes data to JSON
|
|
94
|
+
*/
|
|
95
|
+
static safeSerialize(data) {
|
|
96
|
+
try {
|
|
97
|
+
// Always use JSON.stringify to ensure proper serialization/deserialization
|
|
98
|
+
return JSON.stringify(data);
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
throw new error_control_model_1.DyFM_Error({
|
|
102
|
+
...this.getDefaultErrorSettings('safeSerialize', error),
|
|
103
|
+
errorCode: 'DyFM-CRY-SER',
|
|
104
|
+
message: 'Failed to serialize data'
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Safely deserializes JSON data
|
|
110
|
+
*/
|
|
111
|
+
static safeDeserialize(data) {
|
|
112
|
+
try {
|
|
113
|
+
//let parsed = JSON.parse(data);
|
|
114
|
+
let parsed = object_util_1.DyFM_Object.failableSafeParseJSON(data);
|
|
115
|
+
// Handle double-stringified JSON (or more levels of stringification)
|
|
116
|
+
let maxAttempts = 3; // Prevent infinite loops
|
|
117
|
+
while (typeof parsed === 'string' && maxAttempts > 0) {
|
|
118
|
+
try {
|
|
119
|
+
//const nextParsed = JSON.parse(parsed);
|
|
120
|
+
const nextParsed = object_util_1.DyFM_Object.failableSafeParseJSON(parsed);
|
|
121
|
+
// Only continue if parsing actually changed the result
|
|
122
|
+
if (nextParsed !== parsed) {
|
|
123
|
+
parsed = nextParsed;
|
|
124
|
+
maxAttempts--;
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
// If parse fails, return current state
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// Handle primitive values
|
|
136
|
+
/* if (typeof parsed === 'string' || typeof parsed === 'number' || typeof parsed === 'boolean') {
|
|
137
|
+
return parsed as T;
|
|
138
|
+
} */
|
|
139
|
+
return parsed;
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
throw new error_control_model_1.DyFM_Error({
|
|
143
|
+
...this.getDefaultErrorSettings('safeDeserialize', error),
|
|
144
|
+
errorCode: 'DyFM-CRY-DES',
|
|
145
|
+
message: 'Failed to deserialize data'
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Encrypts data using AES-256-CBC with deterministic IV and salt
|
|
151
|
+
*
|
|
152
|
+
* @important DETERMINISTIC BEHAVIOR: This method will produce identical encrypted
|
|
153
|
+
* output for identical input parameters across different systems, Node.js versions,
|
|
154
|
+
* and multiple function calls. The same data + key combination will ALWAYS generate
|
|
155
|
+
* the same encrypted string.
|
|
156
|
+
*
|
|
157
|
+
* @param data The data to encrypt
|
|
158
|
+
* @param key The encryption key
|
|
159
|
+
* @param config Optional configuration
|
|
160
|
+
* @returns URL-safe encrypted string that is identical across systems for same input
|
|
161
|
+
* @throws {DyFM_Error} if encryption fails
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* // These will produce identical results on any system:
|
|
165
|
+
* const result1 = DyFM_Crypto.encrypt({id: 1}, "mykey");
|
|
166
|
+
* const result2 = DyFM_Crypto.encrypt({id: 1}, "mykey");
|
|
167
|
+
* console.log(result1 === result2); // Always true
|
|
168
|
+
*/
|
|
169
|
+
static encrypt(data, key, config) {
|
|
170
|
+
try {
|
|
171
|
+
this.validateInput(data, key);
|
|
172
|
+
const finalConfig = { ...this.DEFAULT_CONFIG, ...config };
|
|
173
|
+
// Convert data to string
|
|
174
|
+
const dataStr = this.safeSerialize(data);
|
|
175
|
+
// Generate deterministic IV and salt based on data and key
|
|
176
|
+
const iv = this.generateIV(dataStr, key, finalConfig);
|
|
177
|
+
const salt = this.generateSalt(dataStr, key, finalConfig);
|
|
178
|
+
// Derive key using PBKDF2
|
|
179
|
+
const derivedKey = this.deriveKey(key, salt, finalConfig);
|
|
180
|
+
// Encrypt the data
|
|
181
|
+
const encrypted = CryptoJS.AES.encrypt(dataStr, derivedKey, {
|
|
182
|
+
iv: iv,
|
|
183
|
+
mode: CryptoJS.mode.CBC,
|
|
184
|
+
padding: CryptoJS.pad.Pkcs7
|
|
185
|
+
});
|
|
186
|
+
// Combine IV + Salt + Ciphertext
|
|
187
|
+
const combined = iv.concat(salt).concat(encrypted.ciphertext);
|
|
188
|
+
// Convert to URL-safe base64
|
|
189
|
+
return CryptoJS.enc.Base64.stringify(combined)
|
|
190
|
+
.replace(/\+/g, '-')
|
|
191
|
+
.replace(/\//g, '_')
|
|
192
|
+
.replace(/=+$/, '');
|
|
193
|
+
}
|
|
194
|
+
catch (error) {
|
|
195
|
+
throw new error_control_model_1.DyFM_Error({
|
|
196
|
+
...this.getDefaultErrorSettings('encrypt', error),
|
|
197
|
+
errorCode: 'DyFM-CRY-ENC',
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Decrypts data that was encrypted using encrypt()
|
|
203
|
+
* @param encryptedData The encrypted data
|
|
204
|
+
* @param key The decryption key
|
|
205
|
+
* @param config Optional configuration
|
|
206
|
+
* @returns The decrypted data
|
|
207
|
+
* @throws {DyFM_Error} if decryption fails
|
|
208
|
+
*/
|
|
209
|
+
static decrypt(encryptedData, key, config) {
|
|
210
|
+
try {
|
|
211
|
+
this.validateInput(encryptedData, key);
|
|
212
|
+
const finalConfig = { ...this.DEFAULT_CONFIG, ...config };
|
|
213
|
+
// Convert from URL-safe base64
|
|
214
|
+
const base64 = encryptedData
|
|
215
|
+
.replace(/-/g, '+')
|
|
216
|
+
.replace(/_/g, '/');
|
|
217
|
+
// Parse the combined data
|
|
218
|
+
const combined = CryptoJS.enc.Base64.parse(base64);
|
|
219
|
+
// Validate minimum length (IV + Salt + minimum ciphertext)
|
|
220
|
+
const minLength = (finalConfig.ivLength + finalConfig.saltLength + 16) / 4; // 16 bytes minimum for ciphertext
|
|
221
|
+
if (combined.words.length < minLength) {
|
|
222
|
+
throw new Error('Invalid encrypted data length');
|
|
223
|
+
}
|
|
224
|
+
// Extract IV, salt, and ciphertext
|
|
225
|
+
const iv = CryptoJS.lib.WordArray.create(combined.words.slice(0, finalConfig.ivLength / 4));
|
|
226
|
+
const salt = CryptoJS.lib.WordArray.create(combined.words.slice(finalConfig.ivLength / 4, (finalConfig.ivLength + finalConfig.saltLength) / 4));
|
|
227
|
+
const ciphertext = CryptoJS.lib.WordArray.create(combined.words.slice((finalConfig.ivLength + finalConfig.saltLength) / 4));
|
|
228
|
+
// Derive key using PBKDF2
|
|
229
|
+
const derivedKey = this.deriveKey(key, salt, finalConfig);
|
|
230
|
+
// Decrypt the data
|
|
231
|
+
const decrypted = CryptoJS.AES.decrypt({ ciphertext: ciphertext }, derivedKey, {
|
|
232
|
+
iv: iv,
|
|
233
|
+
mode: CryptoJS.mode.CBC,
|
|
234
|
+
padding: CryptoJS.pad.Pkcs7
|
|
235
|
+
});
|
|
236
|
+
// Parse JSON
|
|
237
|
+
const decryptedStr = decrypted.toString(CryptoJS.enc.Utf8);
|
|
238
|
+
return this.safeDeserialize(decryptedStr);
|
|
239
|
+
}
|
|
240
|
+
catch (error) {
|
|
241
|
+
throw new error_control_model_1.DyFM_Error({
|
|
242
|
+
...this.getDefaultErrorSettings('decrypt', error),
|
|
243
|
+
errorCode: 'DyFM-CRY-DRY',
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Generates a secure random key
|
|
249
|
+
* @param length Length of the key in bytes (default: 32)
|
|
250
|
+
* @returns A secure random key
|
|
251
|
+
*/
|
|
252
|
+
static generateKey(length = 32) {
|
|
253
|
+
return CryptoJS.lib.WordArray.random(length).toString();
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Validates if a string is a valid encrypted data
|
|
257
|
+
* @param encryptedData The data to validate
|
|
258
|
+
* @returns true if the data appears to be valid encrypted data
|
|
259
|
+
*/
|
|
260
|
+
static isValidEncryptedData(encryptedData) {
|
|
261
|
+
if (!encryptedData || typeof encryptedData !== 'string') {
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
return /^[A-Za-z0-9\-_]+$/.test(encryptedData);
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Gets default error settings
|
|
268
|
+
*/
|
|
269
|
+
static getDefaultErrorSettings(operation, error) {
|
|
270
|
+
return {
|
|
271
|
+
status: error?.___status ?? error?.status ?? 401,
|
|
272
|
+
message: `Crypto operation "${operation}" failed`,
|
|
273
|
+
error: error,
|
|
274
|
+
errorCode: 'DyFM-CRY-ERR'
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
exports.DyFM_Crypto = DyFM_Crypto;
|
|
279
|
+
//# sourceMappingURL=crypto-old.util.js.map
|