@futdevpro/fsm-dynamo 1.10.49 → 1.10.51
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/_modules/crypto/_collections/crypto-non-stable.util.d.ts +80 -0
- package/build/_modules/crypto/_collections/crypto-non-stable.util.d.ts.map +1 -0
- package/build/_modules/crypto/_collections/crypto-non-stable.util.js +229 -0
- package/build/_modules/crypto/_collections/crypto-non-stable.util.js.map +1 -0
- package/build/_modules/crypto/_collections/crypto.util.d.ts +13 -45
- package/build/_modules/crypto/_collections/crypto.util.d.ts.map +1 -1
- package/build/_modules/crypto/_collections/crypto.util.js +71 -96
- package/build/_modules/crypto/_collections/crypto.util.js.map +1 -1
- package/build/_modules/crypto/_collections/crypto.util.spec.js +6 -4
- package/build/_modules/crypto/_collections/crypto.util.spec.js.map +1 -1
- package/build/_modules/pipe/_collections/pip-transforms.const.d.ts +5 -0
- package/build/_modules/pipe/_collections/pip-transforms.const.d.ts.map +1 -1
- package/build/_modules/pipe/_collections/pip-transforms.const.js +5 -0
- package/build/_modules/pipe/_collections/pip-transforms.const.js.map +1 -1
- package/build/_modules/pipe/_collections/utils/pip-country-pipe.util.d.ts +24 -0
- package/build/_modules/pipe/_collections/utils/pip-country-pipe.util.d.ts.map +1 -1
- package/build/_modules/pipe/_collections/utils/pip-country-pipe.util.js +24 -0
- package/build/_modules/pipe/_collections/utils/pip-country-pipe.util.js.map +1 -1
- package/build/_modules/pipe/_collections/utils/pip-custom-pipe.util.d.ts +20 -1
- package/build/_modules/pipe/_collections/utils/pip-custom-pipe.util.d.ts.map +1 -1
- package/build/_modules/pipe/_collections/utils/pip-custom-pipe.util.js +21 -2
- package/build/_modules/pipe/_collections/utils/pip-custom-pipe.util.js.map +1 -1
- package/build/_modules/pipe/_collections/utils/pip-division-pipe.util.d.ts +16 -0
- package/build/_modules/pipe/_collections/utils/pip-division-pipe.util.d.ts.map +1 -1
- package/build/_modules/pipe/_collections/utils/pip-division-pipe.util.js +16 -0
- package/build/_modules/pipe/_collections/utils/pip-division-pipe.util.js.map +1 -1
- package/build/_modules/pipe/_collections/utils/pip-list-pipe.util.d.ts +16 -0
- package/build/_modules/pipe/_collections/utils/pip-list-pipe.util.d.ts.map +1 -1
- package/build/_modules/pipe/_collections/utils/pip-list-pipe.util.js +16 -0
- package/build/_modules/pipe/_collections/utils/pip-list-pipe.util.js.map +1 -1
- package/build/_modules/pipe/_collections/utils/pip-multi-pipe-pipe.util.d.ts +53 -0
- package/build/_modules/pipe/_collections/utils/pip-multi-pipe-pipe.util.d.ts.map +1 -1
- package/build/_modules/pipe/_collections/utils/pip-multi-pipe-pipe.util.js +53 -0
- package/build/_modules/pipe/_collections/utils/pip-multi-pipe-pipe.util.js.map +1 -1
- package/build/_modules/pipe/_collections/utils/pip-obj-key-pipe.util.d.ts +13 -0
- package/build/_modules/pipe/_collections/utils/pip-obj-key-pipe.util.d.ts.map +1 -1
- package/build/_modules/pipe/_collections/utils/pip-obj-key-pipe.util.js +13 -0
- package/build/_modules/pipe/_collections/utils/pip-obj-key-pipe.util.js.map +1 -1
- package/build/_modules/pipe/_collections/utils/pip-range-pipe.util.d.ts +12 -0
- package/build/_modules/pipe/_collections/utils/pip-range-pipe.util.d.ts.map +1 -1
- package/build/_modules/pipe/_collections/utils/pip-range-pipe.util.js +12 -0
- package/build/_modules/pipe/_collections/utils/pip-range-pipe.util.js.map +1 -1
- package/build/_modules/pipe/_collections/utils/pip-region-pipe.util.d.ts +17 -0
- package/build/_modules/pipe/_collections/utils/pip-region-pipe.util.d.ts.map +1 -1
- package/build/_modules/pipe/_collections/utils/pip-region-pipe.util.js +17 -0
- package/build/_modules/pipe/_collections/utils/pip-region-pipe.util.js.map +1 -1
- package/build/_modules/pipe/_collections/utils/pip-replace-pipe.util.d.ts +12 -0
- package/build/_modules/pipe/_collections/utils/pip-replace-pipe.util.d.ts.map +1 -1
- package/build/_modules/pipe/_collections/utils/pip-replace-pipe.util.js +12 -0
- package/build/_modules/pipe/_collections/utils/pip-replace-pipe.util.js.map +1 -1
- package/build/_modules/pipe/_collections/utils/pip-slider-pipe.util.d.ts +14 -0
- package/build/_modules/pipe/_collections/utils/pip-slider-pipe.util.d.ts.map +1 -1
- package/build/_modules/pipe/_collections/utils/pip-slider-pipe.util.js +14 -0
- package/build/_modules/pipe/_collections/utils/pip-slider-pipe.util.js.map +1 -1
- package/build/_modules/pipe/_collections/utils/pip-smart-replace-pipe.util.d.ts +9 -1
- package/build/_modules/pipe/_collections/utils/pip-smart-replace-pipe.util.d.ts.map +1 -1
- package/build/_modules/pipe/_collections/utils/pip-smart-replace-pipe.util.js +9 -1
- package/build/_modules/pipe/_collections/utils/pip-smart-replace-pipe.util.js.map +1 -1
- package/futdevpro-fsm-dynamo-01.10.51.tgz +0 -0
- package/package.json +1 -1
- package/src/_modules/crypto/_collections/crypto-non-stable.util.ts +285 -0
- package/src/_modules/crypto/_collections/crypto.util.spec.ts +6 -4
- package/src/_modules/crypto/_collections/crypto.util.ts +82 -143
- package/src/_modules/pipe/_collections/pip-transforms.const.ts +5 -1
- package/src/_modules/pipe/_collections/utils/pip-country-pipe.util.ts +24 -1
- package/src/_modules/pipe/_collections/utils/pip-custom-pipe.util.ts +24 -3
- package/src/_modules/pipe/_collections/utils/pip-division-pipe.util.ts +16 -0
- package/src/_modules/pipe/_collections/utils/pip-list-pipe.util.ts +16 -1
- package/src/_modules/pipe/_collections/utils/pip-multi-pipe-pipe.util.ts +53 -0
- package/src/_modules/pipe/_collections/utils/pip-obj-key-pipe.util.ts +13 -1
- package/src/_modules/pipe/_collections/utils/pip-range-pipe.util.ts +12 -0
- package/src/_modules/pipe/_collections/utils/pip-region-pipe.util.ts +17 -0
- package/src/_modules/pipe/_collections/utils/pip-replace-pipe.util.ts +12 -0
- package/src/_modules/pipe/_collections/utils/pip-slider-pipe.util.ts +14 -0
- package/src/_modules/pipe/_collections/utils/pip-smart-replace-pipe.util.ts +9 -1
- package/futdevpro-fsm-dynamo-01.10.49.tgz +0 -0
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DyFM_objKey_pipeTransform = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* This pipe will return the keys of an object
|
|
6
|
+
* (it will return an empty array if the object is empty)
|
|
7
|
+
* (This can be used in multiPipe, all datas from objects)
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
*
|
|
11
|
+
* ```html
|
|
12
|
+
* {{ { a: 1, b: 2, c: 3 } | objKey }}
|
|
13
|
+
* ```
|
|
14
|
+
* will return `['a', 'b', 'c']`
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
4
17
|
function DyFM_objKey_pipeTransform(value) {
|
|
5
18
|
return value ? Object.keys(value) : [];
|
|
6
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pip-obj-key-pipe.util.js","sourceRoot":"","sources":["../../../../../src/_modules/pipe/_collections/utils/pip-obj-key-pipe.util.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"pip-obj-key-pipe.util.js","sourceRoot":"","sources":["../../../../../src/_modules/pipe/_collections/utils/pip-obj-key-pipe.util.ts"],"names":[],"mappings":";;;AAKA;;;;;;;;;;;;GAYG;AACH,SAAgB,yBAAyB,CAAQ,KAAY;IAC3D,OAAO,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACzC,CAAC;AAFD,8DAEC"}
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import { DyFM_RangePipe_Setting } from '../../_enums/pip-range-pipe-setting.enum';
|
|
2
2
|
import { DyFM_RangeValue } from '../../../../_models/control-models/range-value.control-model';
|
|
3
3
|
import { DyFM_MultiPipe_Setting } from '../../_models/pip-multi-pipe-settings.type';
|
|
4
|
+
/**
|
|
5
|
+
* This pipe will return the range of a value
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
*
|
|
9
|
+
* ```html
|
|
10
|
+
* {{ { from: 1, to: 10 } | range: 'from-to' }}
|
|
11
|
+
* ```
|
|
12
|
+
* will return `1 - 10`
|
|
13
|
+
*
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
4
16
|
export declare function DyFM_range_pipeTransform(value: DyFM_RangeValue, setting: DyFM_RangePipe_Setting | string, multiPipes?: DyFM_MultiPipe_Setting[]): string | number | DyFM_RangeValue;
|
|
5
17
|
//# sourceMappingURL=pip-range-pipe.util.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pip-range-pipe.util.d.ts","sourceRoot":"","sources":["../../../../../src/_modules/pipe/_collections/utils/pip-range-pipe.util.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,8DAA8D,CAAC;AAC/F,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AAGpF,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,eAAe,EACtB,OAAO,EAAE,sBAAsB,GAAG,MAAM,EACxC,UAAU,CAAC,EAAE,sBAAsB,EAAE,GACpC,MAAM,GAAG,MAAM,GAAG,eAAe,CAmCnC"}
|
|
1
|
+
{"version":3,"file":"pip-range-pipe.util.d.ts","sourceRoot":"","sources":["../../../../../src/_modules/pipe/_collections/utils/pip-range-pipe.util.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,8DAA8D,CAAC;AAC/F,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AAGpF;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,eAAe,EACtB,OAAO,EAAE,sBAAsB,GAAG,MAAM,EACxC,UAAU,CAAC,EAAE,sBAAsB,EAAE,GACpC,MAAM,GAAG,MAAM,GAAG,eAAe,CAmCnC"}
|
|
@@ -3,6 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DyFM_range_pipeTransform = void 0;
|
|
4
4
|
const pip_range_pipe_setting_enum_1 = require("../../_enums/pip-range-pipe-setting.enum");
|
|
5
5
|
const pip_multi_pipe_pipe_util_1 = require("./pip-multi-pipe-pipe.util");
|
|
6
|
+
/**
|
|
7
|
+
* This pipe will return the range of a value
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
*
|
|
11
|
+
* ```html
|
|
12
|
+
* {{ { from: 1, to: 10 } | range: 'from-to' }}
|
|
13
|
+
* ```
|
|
14
|
+
* will return `1 - 10`
|
|
15
|
+
*
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
6
18
|
function DyFM_range_pipeTransform(value, setting, multiPipes) {
|
|
7
19
|
if (!checkRangePipeRequirements(value, setting, multiPipes)) {
|
|
8
20
|
return value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pip-range-pipe.util.js","sourceRoot":"","sources":["../../../../../src/_modules/pipe/_collections/utils/pip-range-pipe.util.ts"],"names":[],"mappings":";;;AAOA,0FAAkF;AAGlF,yEAA0E;AAE1E,SAAgB,wBAAwB,CACtC,KAAsB,EACtB,OAAwC,EACxC,UAAqC;IAErC,IAAI,CAAC,0BAA0B,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,CAAC,EAAE,CAAC;QAC5D,OAAO,KAAK,CAAC;IACf,CAAC;IAED,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,oDAAsB,CAAC,GAAG,CAAC;QAChC,KAAK,oDAAsB,CAAC,OAAO;YACjC,OAAO,CAAC,KAAK,CAAC,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAErC,KAAK,oDAAsB,CAAC,GAAG,CAAC;QAChC,KAAK,oDAAsB,CAAC,IAAI;YAC9B,OAAO,KAAK,CAAC,IAAI,CAAC;QAEpB,KAAK,oDAAsB,CAAC,GAAG,CAAC;QAChC,KAAK,oDAAsB,CAAC,EAAE;YAC5B,OAAO,KAAK,CAAC,EAAE,CAAC;QAElB,KAAK,oDAAsB,CAAC,IAAI,CAAC;QACjC,KAAK,oDAAsB,CAAC,MAAM;YAChC,IAAI,CAAC,GAAG,UAAU,EAAE,MAAM,EAAE,CAAC;gBAC3B,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,EAAE,EAAE,CAAC;oBAC5B,OAAO,IAAA,uDAA4B,EAAC,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;gBAC9D,CAAC;qBAAM,CAAC;oBACN,OAAO,IAAA,uDAA4B,EAAC,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC;wBACzD,KAAK;wBACL,IAAA,uDAA4B,EAAC,KAAK,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;gBACvD,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,OAAO,GAAG,KAAK,CAAC,IAAI,MAAM,KAAK,CAAC,EAAE,EAAE,CAAC;YACvC,CAAC;QAEH;YACE,OAAO,KAAK,CAAC;IACjB,CAAC;AACH,CAAC;AAvCD,4DAuCC;AAED,SAAS,0BAA0B,CACjC,KAAsB,EACtB,OAAwC,EACxC,UAAqC;IAErC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC;QACpB,OAAO,CAAC,IAAI,CACV,kBAAkB;YAClB,gDAAgD,EAChD,kDAAkD,EAClD,WAAW,EAAE,KAAK,EAClB,MAAM,EACN,IAAI,KAAK,EAAE,CACZ,CAAC;QAEF,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,GAAG,oDAAsB,CAAC,MAAM,CAAC;IAC1C,CAAC;IAED,IACE,OAAO,KAAK,oDAAsB,CAAC,IAAI;QACvC,OAAO,KAAK,oDAAsB,CAAC,MAAM;QACzC,CAAC,GAAG,UAAU,EAAE,MAAM,EACtB,CAAC;QACD,OAAO,CAAC,IAAI,CACV,kBAAkB;YAClB,8EAA8E,EAC9E,oEAAoE,EACpE,WAAW,EAAE,KAAK,EAClB,aAAa,EAAE,OAAO,EACtB,kBAAkB,EAAE,UAAU,EAC9B,MAAM,EACN,IAAI,KAAK,EAAE,CACZ,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
1
|
+
{"version":3,"file":"pip-range-pipe.util.js","sourceRoot":"","sources":["../../../../../src/_modules/pipe/_collections/utils/pip-range-pipe.util.ts"],"names":[],"mappings":";;;AAOA,0FAAkF;AAGlF,yEAA0E;AAE1E;;;;;;;;;;;GAWG;AACH,SAAgB,wBAAwB,CACtC,KAAsB,EACtB,OAAwC,EACxC,UAAqC;IAErC,IAAI,CAAC,0BAA0B,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,CAAC,EAAE,CAAC;QAC5D,OAAO,KAAK,CAAC;IACf,CAAC;IAED,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,oDAAsB,CAAC,GAAG,CAAC;QAChC,KAAK,oDAAsB,CAAC,OAAO;YACjC,OAAO,CAAC,KAAK,CAAC,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAErC,KAAK,oDAAsB,CAAC,GAAG,CAAC;QAChC,KAAK,oDAAsB,CAAC,IAAI;YAC9B,OAAO,KAAK,CAAC,IAAI,CAAC;QAEpB,KAAK,oDAAsB,CAAC,GAAG,CAAC;QAChC,KAAK,oDAAsB,CAAC,EAAE;YAC5B,OAAO,KAAK,CAAC,EAAE,CAAC;QAElB,KAAK,oDAAsB,CAAC,IAAI,CAAC;QACjC,KAAK,oDAAsB,CAAC,MAAM;YAChC,IAAI,CAAC,GAAG,UAAU,EAAE,MAAM,EAAE,CAAC;gBAC3B,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,EAAE,EAAE,CAAC;oBAC5B,OAAO,IAAA,uDAA4B,EAAC,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;gBAC9D,CAAC;qBAAM,CAAC;oBACN,OAAO,IAAA,uDAA4B,EAAC,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC;wBACzD,KAAK;wBACL,IAAA,uDAA4B,EAAC,KAAK,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;gBACvD,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,OAAO,GAAG,KAAK,CAAC,IAAI,MAAM,KAAK,CAAC,EAAE,EAAE,CAAC;YACvC,CAAC;QAEH;YACE,OAAO,KAAK,CAAC;IACjB,CAAC;AACH,CAAC;AAvCD,4DAuCC;AAED,SAAS,0BAA0B,CACjC,KAAsB,EACtB,OAAwC,EACxC,UAAqC;IAErC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC;QACpB,OAAO,CAAC,IAAI,CACV,kBAAkB;YAClB,gDAAgD,EAChD,kDAAkD,EAClD,WAAW,EAAE,KAAK,EAClB,MAAM,EACN,IAAI,KAAK,EAAE,CACZ,CAAC;QAEF,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,GAAG,oDAAsB,CAAC,MAAM,CAAC;IAC1C,CAAC;IAED,IACE,OAAO,KAAK,oDAAsB,CAAC,IAAI;QACvC,OAAO,KAAK,oDAAsB,CAAC,MAAM;QACzC,CAAC,GAAG,UAAU,EAAE,MAAM,EACtB,CAAC;QACD,OAAO,CAAC,IAAI,CACV,kBAAkB;YAClB,8EAA8E,EAC9E,oEAAoE,EACpE,WAAW,EAAE,KAAK,EAClB,aAAa,EAAE,OAAO,EACtB,kBAAkB,EAAE,UAAU,EAC9B,MAAM,EACN,IAAI,KAAK,EAAE,CACZ,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,2 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This pipe will return the region of a country
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
*
|
|
6
|
+
* ```html
|
|
7
|
+
* {{ 'US' | region }}
|
|
8
|
+
* ```
|
|
9
|
+
* will return `North America`
|
|
10
|
+
*
|
|
11
|
+
* ```html
|
|
12
|
+
* {{ 'DE' | region }}
|
|
13
|
+
* ```
|
|
14
|
+
* will return `Europe`
|
|
15
|
+
*
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
1
18
|
export declare function DyFM_region_pipeTransform(countryISO: string): string;
|
|
2
19
|
//# sourceMappingURL=pip-region-pipe.util.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pip-region-pipe.util.d.ts","sourceRoot":"","sources":["../../../../../src/_modules/pipe/_collections/utils/pip-region-pipe.util.ts"],"names":[],"mappings":"AAWA,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAMpE"}
|
|
1
|
+
{"version":3,"file":"pip-region-pipe.util.d.ts","sourceRoot":"","sources":["../../../../../src/_modules/pipe/_collections/utils/pip-region-pipe.util.ts"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAMpE"}
|
|
@@ -2,6 +2,23 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DyFM_region_pipeTransform = void 0;
|
|
4
4
|
const loc_country_isos_const_1 = require("../../../location/_collections/loc-country-isos.const");
|
|
5
|
+
/**
|
|
6
|
+
* This pipe will return the region of a country
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
*
|
|
10
|
+
* ```html
|
|
11
|
+
* {{ 'US' | region }}
|
|
12
|
+
* ```
|
|
13
|
+
* will return `North America`
|
|
14
|
+
*
|
|
15
|
+
* ```html
|
|
16
|
+
* {{ 'DE' | region }}
|
|
17
|
+
* ```
|
|
18
|
+
* will return `Europe`
|
|
19
|
+
*
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
5
22
|
function DyFM_region_pipeTransform(countryISO) {
|
|
6
23
|
const result = loc_country_isos_const_1.DyFM_countryISOs.find((iso) => iso.iso2 === countryISO)?.region;
|
|
7
24
|
return result ?? countryISO;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pip-region-pipe.util.js","sourceRoot":"","sources":["../../../../../src/_modules/pipe/_collections/utils/pip-region-pipe.util.ts"],"names":[],"mappings":";;;AAQA,kGAAyF;AAGzF,SAAgB,yBAAyB,CAAC,UAAkB;IAC1D,MAAM,MAAM,GAAG,yCAAgB,CAAC,IAAI,CAClC,CAAC,GAAoB,EAAW,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,UAAU,CAC3D,EAAE,MAAM,CAAC;IAEV,OAAO,MAAM,IAAI,UAAU,CAAC;AAC9B,CAAC;AAND,8DAMC"}
|
|
1
|
+
{"version":3,"file":"pip-region-pipe.util.js","sourceRoot":"","sources":["../../../../../src/_modules/pipe/_collections/utils/pip-region-pipe.util.ts"],"names":[],"mappings":";;;AAQA,kGAAyF;AAGzF;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,yBAAyB,CAAC,UAAkB;IAC1D,MAAM,MAAM,GAAG,yCAAgB,CAAC,IAAI,CAClC,CAAC,GAAoB,EAAW,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,UAAU,CAC3D,EAAE,MAAM,CAAC;IAEV,OAAO,MAAM,IAAI,UAAU,CAAC;AAC9B,CAAC;AAND,8DAMC"}
|
|
@@ -1,2 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This pipe will replace all the occurrences of a string with another string
|
|
3
|
+
* (usually used for data injections for localized messages)
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
*
|
|
7
|
+
* ```html
|
|
8
|
+
* {{ 'Hello World' | replace: 'World', 'Universe' }}
|
|
9
|
+
* ```
|
|
10
|
+
* will return `Hello Universe`
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
1
13
|
export declare function DyFM_replace_pipeTransform(value: string, from: string, to: string): string;
|
|
2
14
|
//# sourceMappingURL=pip-replace-pipe.util.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pip-replace-pipe.util.d.ts","sourceRoot":"","sources":["../../../../../src/_modules/pipe/_collections/utils/pip-replace-pipe.util.ts"],"names":[],"mappings":"AAQA,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAE1F"}
|
|
1
|
+
{"version":3,"file":"pip-replace-pipe.util.d.ts","sourceRoot":"","sources":["../../../../../src/_modules/pipe/_collections/utils/pip-replace-pipe.util.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;GAWG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAE1F"}
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DyFM_replace_pipeTransform = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* This pipe will replace all the occurrences of a string with another string
|
|
6
|
+
* (usually used for data injections for localized messages)
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
*
|
|
10
|
+
* ```html
|
|
11
|
+
* {{ 'Hello World' | replace: 'World', 'Universe' }}
|
|
12
|
+
* ```
|
|
13
|
+
* will return `Hello Universe`
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
4
16
|
function DyFM_replace_pipeTransform(value, from, to) {
|
|
5
17
|
return value?.replaceAll(from, to) ?? value;
|
|
6
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pip-replace-pipe.util.js","sourceRoot":"","sources":["../../../../../src/_modules/pipe/_collections/utils/pip-replace-pipe.util.ts"],"names":[],"mappings":";;;AAQA,SAAgB,0BAA0B,CAAC,KAAa,EAAE,IAAY,EAAE,EAAU;IAChF,OAAO,KAAK,EAAE,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC;AAC9C,CAAC;AAFD,gEAEC"}
|
|
1
|
+
{"version":3,"file":"pip-replace-pipe.util.js","sourceRoot":"","sources":["../../../../../src/_modules/pipe/_collections/utils/pip-replace-pipe.util.ts"],"names":[],"mappings":";;;AAQA;;;;;;;;;;;GAWG;AACH,SAAgB,0BAA0B,CAAC,KAAa,EAAE,IAAY,EAAE,EAAU;IAChF,OAAO,KAAK,EAAE,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC;AAC9C,CAAC;AAFD,gEAEC"}
|
|
@@ -1,3 +1,17 @@
|
|
|
1
1
|
import { DyFM_RangeValue } from '../../../../_models/control-models/range-value.control-model';
|
|
2
|
+
/**
|
|
3
|
+
* This pipe will return the value as a string
|
|
4
|
+
* The main purpose of this pipe is to be able to rewrite this pipe,
|
|
5
|
+
* so the Dynamo Slider Field will use it as you want
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
*
|
|
9
|
+
* ```html
|
|
10
|
+
* {{ 100 | slider }}
|
|
11
|
+
* ```
|
|
12
|
+
* will return `100`
|
|
13
|
+
*
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
2
16
|
export declare function DyFM_slider_pipeTransform(value: number | DyFM_RangeValue<number> | string): string;
|
|
3
17
|
//# sourceMappingURL=pip-slider-pipe.util.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pip-slider-pipe.util.d.ts","sourceRoot":"","sources":["../../../../../src/_modules/pipe/_collections/utils/pip-slider-pipe.util.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,MAAM,8DAA8D,CAAC;AAG/F,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,GAAG,MAAM,GAC/C,MAAM,CAQR"}
|
|
1
|
+
{"version":3,"file":"pip-slider-pipe.util.d.ts","sourceRoot":"","sources":["../../../../../src/_modules/pipe/_collections/utils/pip-slider-pipe.util.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,MAAM,8DAA8D,CAAC;AAG/F;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,GAAG,MAAM,GAC/C,MAAM,CAQR"}
|
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DyFM_slider_pipeTransform = void 0;
|
|
4
4
|
const range_value_control_model_1 = require("../../../../_models/control-models/range-value.control-model");
|
|
5
|
+
/**
|
|
6
|
+
* This pipe will return the value as a string
|
|
7
|
+
* The main purpose of this pipe is to be able to rewrite this pipe,
|
|
8
|
+
* so the Dynamo Slider Field will use it as you want
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
*
|
|
12
|
+
* ```html
|
|
13
|
+
* {{ 100 | slider }}
|
|
14
|
+
* ```
|
|
15
|
+
* will return `100`
|
|
16
|
+
*
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
5
19
|
function DyFM_slider_pipeTransform(value) {
|
|
6
20
|
if (value instanceof range_value_control_model_1.DyFM_RangeValue /* (value as DyFM_RangeValue).isRange */) {
|
|
7
21
|
return value.toString();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pip-slider-pipe.util.js","sourceRoot":"","sources":["../../../../../src/_modules/pipe/_collections/utils/pip-slider-pipe.util.ts"],"names":[],"mappings":";;;AAKA,4GAA+F;AAG/F,SAAgB,yBAAyB,CACvC,KAAgD;IAEhD,IAAI,KAAK,YAAY,2CAAe,CAAC,wCAAwC,EAAE,CAAC;QAC9E,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC1B,CAAC;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACrC,OAAO,GAAG,KAAK,EAAE,CAAC;IACpB,CAAC;SAAM,CAAC;QACN,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAVD,8DAUC"}
|
|
1
|
+
{"version":3,"file":"pip-slider-pipe.util.js","sourceRoot":"","sources":["../../../../../src/_modules/pipe/_collections/utils/pip-slider-pipe.util.ts"],"names":[],"mappings":";;;AAKA,4GAA+F;AAG/F;;;;;;;;;;;;;GAaG;AACH,SAAgB,yBAAyB,CACvC,KAAgD;IAEhD,IAAI,KAAK,YAAY,2CAAe,CAAC,wCAAwC,EAAE,CAAC;QAC9E,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC1B,CAAC;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACrC,OAAO,GAAG,KAAK,EAAE,CAAC;IACpB,CAAC;SAAM,CAAC;QACN,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAVD,8DAUC"}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { DyFM_MultiPipe_Setting } from '../../_models/pip-multi-pipe-settings.type';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* This pipe will replace multiple values using the given keys
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
*
|
|
7
|
+
* ```html
|
|
8
|
+
* {{ 'Hello {name}, {customer} is waiting for you' | smartReplace: { name: 'John', customer: 'Bob' } }}
|
|
9
|
+
* ```
|
|
10
|
+
* will return `Hello John, Bob is waiting for you`
|
|
11
|
+
*
|
|
4
12
|
*/
|
|
5
13
|
export declare function DyFM_smartReplace_pipeTransform(value: string, replacer: object, multiPipes?: DyFM_MultiPipe_Setting[]): string;
|
|
6
14
|
//# sourceMappingURL=pip-smart-replace-pipe.util.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pip-smart-replace-pipe.util.d.ts","sourceRoot":"","sources":["../../../../../src/_modules/pipe/_collections/utils/pip-smart-replace-pipe.util.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AAIpF
|
|
1
|
+
{"version":3,"file":"pip-smart-replace-pipe.util.d.ts","sourceRoot":"","sources":["../../../../../src/_modules/pipe/_collections/utils/pip-smart-replace-pipe.util.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AAIpF;;;;;;;;;;GAUG;AACH,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,sBAAsB,EAAE,GACrE,MAAM,CAsDR"}
|
|
@@ -3,7 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DyFM_smartReplace_pipeTransform = void 0;
|
|
4
4
|
const pip_multi_pipe_pipe_util_1 = require("./pip-multi-pipe-pipe.util");
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* This pipe will replace multiple values using the given keys
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
*
|
|
10
|
+
* ```html
|
|
11
|
+
* {{ 'Hello {name}, {customer} is waiting for you' | smartReplace: { name: 'John', customer: 'Bob' } }}
|
|
12
|
+
* ```
|
|
13
|
+
* will return `Hello John, Bob is waiting for you`
|
|
14
|
+
*
|
|
7
15
|
*/
|
|
8
16
|
function DyFM_smartReplace_pipeTransform(value, replacer, multiPipes) {
|
|
9
17
|
if (!replacer) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pip-smart-replace-pipe.util.js","sourceRoot":"","sources":["../../../../../src/_modules/pipe/_collections/utils/pip-smart-replace-pipe.util.ts"],"names":[],"mappings":";;;AAQA,yEAA0E;AAG1E
|
|
1
|
+
{"version":3,"file":"pip-smart-replace-pipe.util.js","sourceRoot":"","sources":["../../../../../src/_modules/pipe/_collections/utils/pip-smart-replace-pipe.util.ts"],"names":[],"mappings":";;;AAQA,yEAA0E;AAG1E;;;;;;;;;;GAUG;AACH,SAAgB,+BAA+B,CAC7C,KAAa,EAAE,QAAgB,EAAE,UAAqC;IAGtE,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,CAAC,IAAI,CACV,kBAAkB;YAClB,iDAAiD,EACjD,MAAM,EACN,IAAI,KAAK,EAAE,CACZ,CAAC;QAEF,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC3B,IAAI,QAAQ,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC;gBAC1B,OAAO,CAAC,IAAI,CACV,kBAAkB;oBAClB,gCAAgC,GAAG,GAAG,GAAG,+BAA+B,EACxE,MAAM,EACN,IAAI,KAAK,EAAE,CACZ,CAAC;gBAEF,OAAO;YACT,CAAC;YAED,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;gBACxC,OAAO,CAAC,IAAI,CACV,kBAAkB;oBAClB,gCAAgC,GAAG,GAAG,GAAG,gCAAgC,EACzE,MAAM,EACN,IAAI,KAAK,EAAE,CACZ,CAAC;gBAEF,OAAO;YACT,CAAC;YAED,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAA,uDAA4B,EAC1C,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EACnB,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,CACpB,CAAC;QACJ,CAAC;QAED,IAAI,UAAU,EAAE,MAAM,EAAE,CAAC;YACvB,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAA,uDAA4B,EAC1C,QAAQ,CAAC,GAAG,CAAC,EACb,UAAU,CACX,CAAC;QACJ,CAAC;QAED,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,IAAI,GAAG,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IACtD,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAxDD,0EAwDC"}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@futdevpro/fsm-dynamo",
|
|
3
|
-
"version": "01.10.
|
|
3
|
+
"version": "01.10.51",
|
|
4
4
|
"description": "Full Stack Model Collection for Dynamic (NodeJS-Typescript) Framework called Dynamo, by Future Development Ltd.",
|
|
5
5
|
"DyBu_settings": {
|
|
6
6
|
"packageType": "full-stack-package",
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import * as CryptoJS from 'crypto-js';
|
|
2
|
+
import {
|
|
3
|
+
DyFM_Error,
|
|
4
|
+
DyFM_Error_Settings
|
|
5
|
+
} from '../../../_models/control-models/error.control-model';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Error codes for crypto operations
|
|
10
|
+
*/
|
|
11
|
+
/* export enum CryptoErrorCode {
|
|
12
|
+
INVALID_INPUT = 'DyFM-CRY-EA0',
|
|
13
|
+
DECRYPTION_FAILED = '',
|
|
14
|
+
ENCRYPTION_FAILED = 'DyFM-CRY-ENF',
|
|
15
|
+
INVALID_KEY = 'DyFM-CRY-IKY',
|
|
16
|
+
INVALID_DATA = 'DyFM-CRY-IDT'
|
|
17
|
+
} */
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Configuration options for encryption/decryption
|
|
21
|
+
*/
|
|
22
|
+
export interface CryptoConfig {
|
|
23
|
+
ivLength?: number;
|
|
24
|
+
saltLength?: number;
|
|
25
|
+
keyIterations?: number;
|
|
26
|
+
keySize?: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* A utility class for secure encryption and decryption of data
|
|
31
|
+
* Uses AES-256-CBC with PBKDF2 key derivation
|
|
32
|
+
*/
|
|
33
|
+
export class DyFM_Crypto {
|
|
34
|
+
private static readonly DEFAULT_CONFIG: Required<CryptoConfig> = {
|
|
35
|
+
ivLength: 16, // 128 bits
|
|
36
|
+
saltLength: 16, // 128 bits
|
|
37
|
+
keyIterations: 10000,
|
|
38
|
+
keySize: 8 // 256 bits (8 * 32)
|
|
39
|
+
};
|
|
40
|
+
private static readonly defaultErrorUserMsg =
|
|
41
|
+
`We encountered an unhandled Authentication Error, ` +
|
|
42
|
+
`\nplease contact the responsible development team.`;
|
|
43
|
+
|
|
44
|
+
// Tömör: kb. 60–80 karakteres token, nem 200+
|
|
45
|
+
// Nem szabványos: nehéz visszafejteni
|
|
46
|
+
// Használható cookie, header, URL-ben
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Validates the input data and key
|
|
50
|
+
* @throws {DyFM_Error} if validation fails
|
|
51
|
+
*/
|
|
52
|
+
private static validateInput(data: any, key: string): void {
|
|
53
|
+
if (!key || typeof key !== 'string' || key.trim().length === 0) {
|
|
54
|
+
throw new DyFM_Error({
|
|
55
|
+
...this.getDefaultErrorSettings('validateInput'),
|
|
56
|
+
errorCode: 'DyFM-CRY-IKY',
|
|
57
|
+
message: 'Invalid encryption key'
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (data === undefined || data === null) {
|
|
62
|
+
throw new DyFM_Error({
|
|
63
|
+
...this.getDefaultErrorSettings('validateInput'),
|
|
64
|
+
errorCode: 'DyFM-CRY-IDT',
|
|
65
|
+
message: 'Invalid data to encrypt/decrypt'
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Generates a deterministic IV based on the input data and key
|
|
72
|
+
*/
|
|
73
|
+
private static generateIV(data: string, key: string, config: Required<CryptoConfig>): CryptoJS.lib.WordArray {
|
|
74
|
+
const hash = CryptoJS.SHA256(data + key);
|
|
75
|
+
return CryptoJS.lib.WordArray.create(hash.words.slice(0, config.ivLength / 4));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Generates a deterministic salt based on the input data and key
|
|
80
|
+
*/
|
|
81
|
+
private static generateSalt(data: string, key: string, config: Required<CryptoConfig>): CryptoJS.lib.WordArray {
|
|
82
|
+
const hash = CryptoJS.SHA256(key + data);
|
|
83
|
+
return CryptoJS.lib.WordArray.create(hash.words.slice(0, config.saltLength / 4));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Derives a key using PBKDF2
|
|
88
|
+
*/
|
|
89
|
+
private static deriveKey(key: string, salt: CryptoJS.lib.WordArray, config: Required<CryptoConfig>): CryptoJS.lib.WordArray {
|
|
90
|
+
return CryptoJS.PBKDF2(key, salt, {
|
|
91
|
+
keySize: config.keySize,
|
|
92
|
+
iterations: config.keyIterations
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Safely serializes data to JSON
|
|
98
|
+
*/
|
|
99
|
+
private static safeSerialize<T>(data: T): string {
|
|
100
|
+
try {
|
|
101
|
+
return JSON.stringify(data);
|
|
102
|
+
} catch (error) {
|
|
103
|
+
throw new DyFM_Error({
|
|
104
|
+
...this.getDefaultErrorSettings('safeSerialize', error),
|
|
105
|
+
errorCode: 'DyFM-CRY-SER',
|
|
106
|
+
message: 'Failed to serialize data'
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Safely deserializes JSON data
|
|
113
|
+
*/
|
|
114
|
+
private static safeDeserialize<T>(data: string): T {
|
|
115
|
+
try {
|
|
116
|
+
let parsed = JSON.parse(data);
|
|
117
|
+
|
|
118
|
+
// Handle double-stringified JSON
|
|
119
|
+
if (typeof parsed === 'string') {
|
|
120
|
+
try {
|
|
121
|
+
parsed = JSON.parse(parsed);
|
|
122
|
+
} catch {
|
|
123
|
+
// If second parse fails, return the string as is
|
|
124
|
+
return parsed as T;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Handle primitive values
|
|
129
|
+
if (typeof parsed === 'string' || typeof parsed === 'number' || typeof parsed === 'boolean') {
|
|
130
|
+
return parsed as T;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return parsed as T;
|
|
134
|
+
} catch (error) {
|
|
135
|
+
throw new DyFM_Error({
|
|
136
|
+
...this.getDefaultErrorSettings('safeDeserialize', error),
|
|
137
|
+
errorCode: 'DyFM-CRY-DES',
|
|
138
|
+
message: 'Failed to deserialize data'
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Encrypts data using AES-256-CBC
|
|
145
|
+
* @param data The data to encrypt
|
|
146
|
+
* @param key The encryption key
|
|
147
|
+
* @param config Optional configuration
|
|
148
|
+
* @returns URL-safe encrypted string
|
|
149
|
+
* @throws {DyFM_Error} if encryption fails
|
|
150
|
+
*/
|
|
151
|
+
static encrypt<T>(data: T, key: string, config?: CryptoConfig): string {
|
|
152
|
+
try {
|
|
153
|
+
this.validateInput(data, key);
|
|
154
|
+
const finalConfig = { ...this.DEFAULT_CONFIG, ...config };
|
|
155
|
+
|
|
156
|
+
// Convert data to string
|
|
157
|
+
const dataStr = this.safeSerialize(data);
|
|
158
|
+
|
|
159
|
+
// Generate deterministic IV and salt based on data and key
|
|
160
|
+
const iv = this.generateIV(dataStr, key, finalConfig);
|
|
161
|
+
const salt = this.generateSalt(dataStr, key, finalConfig);
|
|
162
|
+
|
|
163
|
+
// Derive key using PBKDF2
|
|
164
|
+
const derivedKey = this.deriveKey(key, salt, finalConfig);
|
|
165
|
+
|
|
166
|
+
// Encrypt the data
|
|
167
|
+
const encrypted = CryptoJS.AES.encrypt(dataStr, derivedKey, {
|
|
168
|
+
iv: iv,
|
|
169
|
+
mode: CryptoJS.mode.CBC,
|
|
170
|
+
padding: CryptoJS.pad.Pkcs7
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
// Combine IV + Salt + Ciphertext
|
|
174
|
+
const combined = iv.concat(salt).concat(encrypted.ciphertext);
|
|
175
|
+
|
|
176
|
+
// Convert to URL-safe base64
|
|
177
|
+
return CryptoJS.enc.Base64.stringify(combined)
|
|
178
|
+
.replace(/\+/g, '-')
|
|
179
|
+
.replace(/\//g, '_')
|
|
180
|
+
.replace(/=+$/, '');
|
|
181
|
+
} catch (error) {
|
|
182
|
+
throw new DyFM_Error({
|
|
183
|
+
...this.getDefaultErrorSettings('encrypt', error),
|
|
184
|
+
errorCode: 'DyFM-CRY-ENC',
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Decrypts data that was encrypted using encrypt()
|
|
191
|
+
* @param encryptedData The encrypted data
|
|
192
|
+
* @param key The decryption key
|
|
193
|
+
* @param config Optional configuration
|
|
194
|
+
* @returns The decrypted data
|
|
195
|
+
* @throws {DyFM_Error} if decryption fails
|
|
196
|
+
*/
|
|
197
|
+
static decrypt<T>(encryptedData: string, key: string, config?: CryptoConfig): T {
|
|
198
|
+
try {
|
|
199
|
+
this.validateInput(encryptedData, key);
|
|
200
|
+
const finalConfig = { ...this.DEFAULT_CONFIG, ...config };
|
|
201
|
+
|
|
202
|
+
// Convert from URL-safe base64
|
|
203
|
+
const base64 = encryptedData
|
|
204
|
+
.replace(/-/g, '+')
|
|
205
|
+
.replace(/_/g, '/');
|
|
206
|
+
|
|
207
|
+
// Parse the combined data
|
|
208
|
+
const combined = CryptoJS.enc.Base64.parse(base64);
|
|
209
|
+
|
|
210
|
+
// Validate minimum length (IV + Salt + minimum ciphertext)
|
|
211
|
+
const minLength = (finalConfig.ivLength + finalConfig.saltLength + 16) / 4; // 16 bytes minimum for ciphertext
|
|
212
|
+
if (combined.words.length < minLength) {
|
|
213
|
+
throw new Error('Invalid encrypted data length');
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Extract IV, salt, and ciphertext
|
|
217
|
+
const iv = CryptoJS.lib.WordArray.create(combined.words.slice(0, finalConfig.ivLength / 4));
|
|
218
|
+
const salt = CryptoJS.lib.WordArray.create(
|
|
219
|
+
combined.words.slice(
|
|
220
|
+
finalConfig.ivLength / 4,
|
|
221
|
+
(finalConfig.ivLength + finalConfig.saltLength) / 4
|
|
222
|
+
)
|
|
223
|
+
);
|
|
224
|
+
const ciphertext = CryptoJS.lib.WordArray.create(
|
|
225
|
+
combined.words.slice((finalConfig.ivLength + finalConfig.saltLength) / 4)
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
// Derive key using PBKDF2
|
|
229
|
+
const derivedKey = this.deriveKey(key, salt, finalConfig);
|
|
230
|
+
|
|
231
|
+
// Decrypt the data
|
|
232
|
+
const decrypted = CryptoJS.AES.decrypt(
|
|
233
|
+
{ ciphertext: ciphertext },
|
|
234
|
+
derivedKey,
|
|
235
|
+
{
|
|
236
|
+
iv: iv,
|
|
237
|
+
mode: CryptoJS.mode.CBC,
|
|
238
|
+
padding: CryptoJS.pad.Pkcs7
|
|
239
|
+
}
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
// Parse JSON
|
|
243
|
+
const decryptedStr = decrypted.toString(CryptoJS.enc.Utf8);
|
|
244
|
+
return this.safeDeserialize<T>(decryptedStr);
|
|
245
|
+
} catch (error) {
|
|
246
|
+
throw new DyFM_Error({
|
|
247
|
+
...this.getDefaultErrorSettings('decrypt', error),
|
|
248
|
+
errorCode: 'DyFM-CRY-DRY',
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Generates a secure random key
|
|
255
|
+
* @param length Length of the key in bytes (default: 32)
|
|
256
|
+
* @returns A secure random key
|
|
257
|
+
*/
|
|
258
|
+
static generateKey(length: number = 32): string {
|
|
259
|
+
return CryptoJS.lib.WordArray.random(length).toString();
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Validates if a string is a valid encrypted data
|
|
264
|
+
* @param encryptedData The data to validate
|
|
265
|
+
* @returns true if the data appears to be valid encrypted data
|
|
266
|
+
*/
|
|
267
|
+
static isValidEncryptedData(encryptedData: string): boolean {
|
|
268
|
+
if (!encryptedData || typeof encryptedData !== 'string') {
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
271
|
+
return /^[A-Za-z0-9\-_]+$/.test(encryptedData);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Gets default error settings
|
|
276
|
+
*/
|
|
277
|
+
private static getDefaultErrorSettings(operation: string, error?: any): DyFM_Error_Settings {
|
|
278
|
+
return {
|
|
279
|
+
status: (error as DyFM_Error)?.___status ?? (error as any)?.status ?? 401,
|
|
280
|
+
message: `Crypto operation "${operation}" failed`,
|
|
281
|
+
error: error,
|
|
282
|
+
errorCode: 'DyFM-CRY-ERR'
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
}
|
|
@@ -572,7 +572,7 @@ describe('| DyFM_Crypto', () => {
|
|
|
572
572
|
const userData: UserData = {
|
|
573
573
|
id: 1,
|
|
574
574
|
name: 'test user',
|
|
575
|
-
lastLogin:
|
|
575
|
+
lastLogin: '2024-01-01T10:00:00.000Z',
|
|
576
576
|
preferences: {
|
|
577
577
|
language: 'en',
|
|
578
578
|
timezone: 'UTC'
|
|
@@ -584,10 +584,10 @@ describe('| DyFM_Crypto', () => {
|
|
|
584
584
|
const encrypted1 = DyFM_Crypto.encrypt(userData, key);
|
|
585
585
|
const decrypted1 = DyFM_Crypto.decrypt(encrypted1, key) as UserData;
|
|
586
586
|
|
|
587
|
-
// Simulate data update
|
|
587
|
+
// Simulate data update with a different timestamp
|
|
588
588
|
const updatedData: UserData = {
|
|
589
589
|
...decrypted1,
|
|
590
|
-
lastLogin:
|
|
590
|
+
lastLogin: '2024-01-02T15:30:00.000Z'
|
|
591
591
|
};
|
|
592
592
|
const encrypted2 = DyFM_Crypto.encrypt(updatedData, key);
|
|
593
593
|
const decrypted2 = DyFM_Crypto.decrypt(encrypted2, key) as UserData;
|
|
@@ -625,7 +625,9 @@ describe('| DyFM_Crypto', () => {
|
|
|
625
625
|
const unicodeData = {
|
|
626
626
|
text: 'Hello 世界! 🌍',
|
|
627
627
|
emoji: '👋',
|
|
628
|
-
special: '
|
|
628
|
+
special: '!!!@@@###$$$%%%^^^&&&***((()))___+++---===[[[]]]{{{}}}|||;;;:::,,,...<<<>>>' +
|
|
629
|
+
'ĐĐĐđđđßßߤ¤¤×××÷÷÷¨¨¨¨~~~ˇˇˇ^^^˘˘˘°°°˛˛˛```˙˙˙´´´˝˝˝˝¸¸¸§§§' +
|
|
630
|
+
'???ééééáááűűűúúúőőőóóóüüüöööíííÉÉÉÁÁÁŰŰŰÚÚÚŐŐŐÓÓÓÜÖÖÖÍÍÍ'
|
|
629
631
|
};
|
|
630
632
|
const encrypted = DyFM_Crypto.encrypt(unicodeData, testKey);
|
|
631
633
|
const decrypted = DyFM_Crypto.decrypt(encrypted, testKey);
|