@aidc-toolkit/utility 1.0.44-beta → 1.0.45
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/dist/index.cjs +17 -0
- package/dist/index.d.cts +683 -0
- package/dist/index.d.ts +683 -26
- package/dist/index.js +1 -9
- package/package.json +3 -3
- package/src/locale/fr/locale-resources.ts +1 -1
- package/src/locale/i18n.ts +5 -5
- package/src/version.ts +4 -0
- package/test/setup.ts +2 -2
- package/tsconfig-src.tsbuildinfo +1 -1
- package/dist/character-set.d.ts +0 -222
- package/dist/character-set.d.ts.map +0 -1
- package/dist/character-set.js +0 -568
- package/dist/character-set.js.map +0 -1
- package/dist/exclusion.d.ts +0 -26
- package/dist/exclusion.d.ts.map +0 -1
- package/dist/exclusion.js +0 -18
- package/dist/exclusion.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/iterable-utility.d.ts +0 -39
- package/dist/iterable-utility.d.ts.map +0 -1
- package/dist/iterable-utility.js +0 -35
- package/dist/iterable-utility.js.map +0 -1
- package/dist/locale/en/locale-resources.d.ts +0 -33
- package/dist/locale/en/locale-resources.d.ts.map +0 -1
- package/dist/locale/en/locale-resources.js +0 -32
- package/dist/locale/en/locale-resources.js.map +0 -1
- package/dist/locale/fr/locale-resources.d.ts +0 -33
- package/dist/locale/fr/locale-resources.d.ts.map +0 -1
- package/dist/locale/fr/locale-resources.js +0 -32
- package/dist/locale/fr/locale-resources.js.map +0 -1
- package/dist/locale/i18n.d.ts +0 -27
- package/dist/locale/i18n.d.ts.map +0 -1
- package/dist/locale/i18n.js +0 -34
- package/dist/locale/i18n.js.map +0 -1
- package/dist/record.d.ts +0 -37
- package/dist/record.d.ts.map +0 -1
- package/dist/record.js +0 -58
- package/dist/record.js.map +0 -1
- package/dist/reg-exp.d.ts +0 -40
- package/dist/reg-exp.d.ts.map +0 -1
- package/dist/reg-exp.js +0 -55
- package/dist/reg-exp.js.map +0 -1
- package/dist/sequence.d.ts +0 -45
- package/dist/sequence.d.ts.map +0 -1
- package/dist/sequence.js +0 -96
- package/dist/sequence.js.map +0 -1
- package/dist/string.d.ts +0 -25
- package/dist/string.d.ts.map +0 -1
- package/dist/string.js +0 -2
- package/dist/string.js.map +0 -1
- package/dist/transformer.d.ts +0 -196
- package/dist/transformer.d.ts.map +0 -1
- package/dist/transformer.js +0 -457
- package/dist/transformer.js.map +0 -1
package/dist/sequence.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sequence.js","sourceRoot":"","sources":["../src/sequence.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,QAAQ;IACjB;;OAEG;IACM,WAAW,CAAS;IAE7B;;OAEG;IACM,SAAS,CAAS;IAE3B;;OAEG;IACM,MAAM,CAAS;IAExB;;OAEG;IACM,UAAU,CAAW;IAE9B;;OAEG;IACM,aAAa,CAAS;IAE/B;;OAEG;IACM,aAAa,CAAS;IAE/B;;;;;;;;;OASG;IACH,YAAY,UAA2B,EAAE,KAAa;QAClD,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;QACtC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAClD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QAEpB,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;YACb,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;YACrB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC;YACtC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QAC7C,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,UAAU,GAAG,CAAC,EAAE,CAAC;YACtB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;YACzC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC;QAC1C,CAAC;IACL,CAAC;IAED;;OAEG;IACH,IAAI,UAAU;QACV,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,IAAI,KAAK;QACL,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,IAAI,YAAY;QACZ,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,IAAI,YAAY;QACZ,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACH,CAAE,CAAC,MAAM,CAAC,QAAQ,CAAC;QACf,KAAK,IAAI,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,KAAK,KAAK,IAAI,CAAC,SAAS,EAAE,KAAK,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpF,MAAM,KAAK,CAAC;QAChB,CAAC;IACL,CAAC;CACJ"}
|
package/dist/string.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* String validation interface. To ensure signature compatibility in implementing classes, string validation is
|
|
3
|
-
* controlled by validation interfaces specific to each validator type.
|
|
4
|
-
*/
|
|
5
|
-
export interface StringValidation {
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* String validator interface.
|
|
9
|
-
*
|
|
10
|
-
* @template TStringValidation
|
|
11
|
-
* String validation type.
|
|
12
|
-
*/
|
|
13
|
-
export interface StringValidator<TStringValidation extends StringValidation = StringValidation> {
|
|
14
|
-
/**
|
|
15
|
-
* Validate a string and throw an error if validation fails.
|
|
16
|
-
*
|
|
17
|
-
* @param s
|
|
18
|
-
* String.
|
|
19
|
-
*
|
|
20
|
-
* @param validation
|
|
21
|
-
* String validation parameters.
|
|
22
|
-
*/
|
|
23
|
-
validate: (s: string, validation?: TStringValidation) => void;
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=string.d.ts.map
|
package/dist/string.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../src/string.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,gBAAgB;CAChC;AAED;;;;;GAKG;AACH,MAAM,WAAW,eAAe,CAAC,iBAAiB,SAAS,gBAAgB,GAAG,gBAAgB;IAC1F;;;;;;;;OAQG;IACH,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,iBAAiB,KAAK,IAAI,CAAC;CACjE"}
|
package/dist/string.js
DELETED
package/dist/string.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"string.js","sourceRoot":"","sources":["../src/string.ts"],"names":[],"mappings":""}
|
package/dist/transformer.d.ts
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import { type IndexedCallback } from "./iterable-utility.js";
|
|
2
|
-
/**
|
|
3
|
-
* Transformer primitive type.
|
|
4
|
-
*/
|
|
5
|
-
export type TransformerPrimitive = string | number | bigint | boolean;
|
|
6
|
-
/**
|
|
7
|
-
* Transformer input type, one of:
|
|
8
|
-
*
|
|
9
|
-
* - TInput (primitive type)
|
|
10
|
-
* - Iterable\<TInput\>
|
|
11
|
-
*
|
|
12
|
-
* @template TInput
|
|
13
|
-
* Transformer input primitive type.
|
|
14
|
-
*/
|
|
15
|
-
export type TransformerInput<TInput extends TransformerPrimitive> = TInput | Iterable<TInput>;
|
|
16
|
-
/**
|
|
17
|
-
* Transformer output, based on transformer input:
|
|
18
|
-
*
|
|
19
|
-
* - If type TTransformerInput is primitive, result is type TOutput.
|
|
20
|
-
* - If type TTransformerInput is Iterable, result is type Iterable\<TOutput\>.
|
|
21
|
-
*
|
|
22
|
-
* @template TTransformerInput
|
|
23
|
-
* Transformer input type.
|
|
24
|
-
*
|
|
25
|
-
* @template TOutput
|
|
26
|
-
* Output base type.
|
|
27
|
-
*/
|
|
28
|
-
export type TransformerOutput<TTransformerInput extends TransformerInput<TransformerPrimitive>, TOutput> = TTransformerInput extends (TTransformerInput extends TransformerInput<infer TInput> ? TInput : never) ? TOutput : Iterable<TOutput>;
|
|
29
|
-
/**
|
|
30
|
-
* Transformer that transforms values in a numeric domain to values in a range equal to the domain or to another range
|
|
31
|
-
* defined by a callback function. In other words, the domain determines valid input values and, without a callback, the
|
|
32
|
-
* range of valid output values.
|
|
33
|
-
*
|
|
34
|
-
* The concept is similar to {@link https://en.wikipedia.org/wiki/Format-preserving_encryption | format-preserving
|
|
35
|
-
* encryption}, where input values within a specified domain (e.g., {@link
|
|
36
|
-
* https://en.wikipedia.org/wiki/Payment_card_number | payment card numbers} ranging from 8-19 digits) are transformed
|
|
37
|
-
* into values in the same domain, typically for storage in a database where the data type and length are already fixed
|
|
38
|
-
* and exfiltration of the data can have significant repercussions.
|
|
39
|
-
*
|
|
40
|
-
* Two subclasses are supported directly by this class: {@linkcode IdentityTransformer} (which operates based on a
|
|
41
|
-
* domain only) and {@linkcode EncryptionTransformer} (which operates based on a domain and a tweak). If an application
|
|
42
|
-
* is expected to make repeated use of a transformer with the same domain and (optional) tweak and can't manage the
|
|
43
|
-
* transformer object, an in-memory cache is available via the {@linkcode get | get()} method. Properties in {@linkcode
|
|
44
|
-
* IdentityTransformer} and {@linkcode EncryptionTransformer} are read-only once constructed, so there is no issue with
|
|
45
|
-
* their shared use.
|
|
46
|
-
*/
|
|
47
|
-
export declare abstract class Transformer {
|
|
48
|
-
#private;
|
|
49
|
-
/**
|
|
50
|
-
* Constructor.
|
|
51
|
-
*
|
|
52
|
-
* @param domain
|
|
53
|
-
* Domain.
|
|
54
|
-
*/
|
|
55
|
-
constructor(domain: number | bigint);
|
|
56
|
-
/**
|
|
57
|
-
* Get a transformer, constructing it if necessary. The type returned is {@linkcode IdentityTransformer} if tweak is
|
|
58
|
-
* undefined, {@linkcode EncryptionTransformer} if tweak is defined. Note that although an {@linkcode
|
|
59
|
-
* EncryptionTransformer} with a zero tweak operates as an {@linkcode IdentityTransformer}, {@linkcode
|
|
60
|
-
* EncryptionTransformer} is still the type returned if a zero tweak is explicitly specified.
|
|
61
|
-
*
|
|
62
|
-
* @param domain
|
|
63
|
-
* Domain.
|
|
64
|
-
*
|
|
65
|
-
* @param tweak
|
|
66
|
-
* Tweak.
|
|
67
|
-
*
|
|
68
|
-
* @returns
|
|
69
|
-
* {@linkcode IdentityTransformer} if tweak is undefined, {@linkcode EncryptionTransformer} if tweak is defined.
|
|
70
|
-
*/
|
|
71
|
-
static get(domain: number | bigint, tweak?: number | bigint): Transformer;
|
|
72
|
-
/**
|
|
73
|
-
* Get the domain.
|
|
74
|
-
*/
|
|
75
|
-
get domain(): bigint;
|
|
76
|
-
/**
|
|
77
|
-
* Do the work of transforming a value forward.
|
|
78
|
-
*
|
|
79
|
-
* @param value
|
|
80
|
-
* Value.
|
|
81
|
-
*
|
|
82
|
-
* @returns
|
|
83
|
-
* Transformed value.
|
|
84
|
-
*/
|
|
85
|
-
protected abstract doForward(value: bigint): bigint;
|
|
86
|
-
/**
|
|
87
|
-
* Transform value(s) forward.
|
|
88
|
-
*
|
|
89
|
-
* @template TTransformerInput
|
|
90
|
-
* Value(s) input type.
|
|
91
|
-
*
|
|
92
|
-
* @param valueOrValues
|
|
93
|
-
* Value(s). If this is an instance of {@linkcode Sequence}, the minimum and maximum values are validated prior to
|
|
94
|
-
* transformation. Otherwise, the individual value(s) is/are validated at the time of transformation.
|
|
95
|
-
*
|
|
96
|
-
* @returns
|
|
97
|
-
* Transformed value(s).
|
|
98
|
-
*/
|
|
99
|
-
forward<TTransformerInput extends TransformerInput<number | bigint>>(valueOrValues: TTransformerInput): TransformerOutput<TTransformerInput, bigint>;
|
|
100
|
-
/**
|
|
101
|
-
* Transform value(s) forward, optionally applying a transformation.
|
|
102
|
-
*
|
|
103
|
-
* @template TTransformerInput
|
|
104
|
-
* Value(s) input type.
|
|
105
|
-
*
|
|
106
|
-
* @template TOutput
|
|
107
|
-
* Transformation callback output type.
|
|
108
|
-
*
|
|
109
|
-
* @param valueOrValues
|
|
110
|
-
* Value(s). If this is an instance of {@linkcode Sequence}, the minimum and maximum values are validated prior to
|
|
111
|
-
* transformation. Otherwise, the individual value(s) is/are validated at the time of transformation.
|
|
112
|
-
*
|
|
113
|
-
* @param transformerCallback
|
|
114
|
-
* Called after each value is transformed to convert it to its final value.
|
|
115
|
-
*
|
|
116
|
-
* @returns
|
|
117
|
-
* Transformed value(s).
|
|
118
|
-
*/
|
|
119
|
-
forward<TTransformerInput extends TransformerInput<number | bigint>, TOutput>(valueOrValues: TTransformerInput, transformerCallback: IndexedCallback<bigint, TOutput>): TransformerOutput<TTransformerInput, TOutput>;
|
|
120
|
-
/**
|
|
121
|
-
* Do the work of transforming a value in reverse.
|
|
122
|
-
*
|
|
123
|
-
* @param transformedValue
|
|
124
|
-
* Transformed value.
|
|
125
|
-
*
|
|
126
|
-
* @returns
|
|
127
|
-
* Value.
|
|
128
|
-
*/
|
|
129
|
-
protected abstract doReverse(transformedValue: bigint): bigint;
|
|
130
|
-
/**
|
|
131
|
-
* Transform a value in reverse.
|
|
132
|
-
*
|
|
133
|
-
* @param transformedValue
|
|
134
|
-
* Transformed value.
|
|
135
|
-
*
|
|
136
|
-
* @returns
|
|
137
|
-
* Value.
|
|
138
|
-
*/
|
|
139
|
-
reverse(transformedValue: number | bigint): bigint;
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Identity transformer. Values are transformed to themselves.
|
|
143
|
-
*/
|
|
144
|
-
export declare class IdentityTransformer extends Transformer {
|
|
145
|
-
/**
|
|
146
|
-
* @inheritDoc
|
|
147
|
-
*/
|
|
148
|
-
protected doForward(value: bigint): bigint;
|
|
149
|
-
/**
|
|
150
|
-
* @inheritDoc
|
|
151
|
-
*/
|
|
152
|
-
protected doReverse(transformedValue: bigint): bigint;
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Encryption transformer. Values are transformed using repeated shuffle and xor operations, similar to those found in
|
|
156
|
-
* many cryptography algorithms, particularly AES. While sufficient for obfuscation of numeric sequences (e.g., serial
|
|
157
|
-
* number generation, below), if true format-preserving encryption is required, a more robust algorithm such as {@link
|
|
158
|
-
* https://doi.org/10.6028/NIST.SP.800-38Gr1.2pd | FF1} is recommended. Furthermore, no work has been done to mitigate
|
|
159
|
-
* {@link https://timing.attacks.cr.yp.to/index.html | timing attacks} for key detection.
|
|
160
|
-
*
|
|
161
|
-
* The purpose of the encryption transformer is to generate pseudo-random values in a deterministic manner to obscure
|
|
162
|
-
* the sequence of values generated over time. A typical example is for serial number generation, where knowledge of the
|
|
163
|
-
* sequence can infer production volumes (e.g., serial number 1000 implies that at least 1,000 units have been
|
|
164
|
-
* manufactured) or can be used in counterfeiting (e.g., a counterfeiter can generate serial numbers 1001, 1002, ...
|
|
165
|
-
* with reasonable confidence that they would be valid if queried).
|
|
166
|
-
*
|
|
167
|
-
* The domain and the tweak together determine the encryption key, which in turn determines the number of rounds of
|
|
168
|
-
* shuffle and xor operations. The minimum number of rounds is 4, except where the domain is less than or equal to 256,
|
|
169
|
-
* which results in single-byte operations. To ensure that the operations are effective for single-byte domains, the
|
|
170
|
-
* number of rounds is 1 and only the xor operation is applied (shuffling a single byte is an identity operation).
|
|
171
|
-
*
|
|
172
|
-
* Another exception is when there is a tweak value of 0; this results in identity operations where the output value is
|
|
173
|
-
* identical to the input value, as no shuffle or xor takes place.
|
|
174
|
-
*/
|
|
175
|
-
export declare class EncryptionTransformer extends Transformer {
|
|
176
|
-
#private;
|
|
177
|
-
/**
|
|
178
|
-
* Constructor.
|
|
179
|
-
*
|
|
180
|
-
* @param domain
|
|
181
|
-
* Domain.
|
|
182
|
-
*
|
|
183
|
-
* @param tweak
|
|
184
|
-
* Tweak.
|
|
185
|
-
*/
|
|
186
|
-
constructor(domain: number | bigint, tweak: number | bigint);
|
|
187
|
-
/**
|
|
188
|
-
* @inheritDoc
|
|
189
|
-
*/
|
|
190
|
-
protected doForward(value: bigint): bigint;
|
|
191
|
-
/**
|
|
192
|
-
* @inheritDoc
|
|
193
|
-
*/
|
|
194
|
-
protected doReverse(transformedValue: bigint): bigint;
|
|
195
|
-
}
|
|
196
|
-
//# sourceMappingURL=transformer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transformer.d.ts","sourceRoot":"","sources":["../src/transformer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAe,MAAM,uBAAuB,CAAC;AAI1E;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEtE;;;;;;;;GAQG;AACH,MAAM,MAAM,gBAAgB,CAAC,MAAM,SAAS,oBAAoB,IAAI,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;AAE9F;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,iBAAiB,CAAC,iBAAiB,SAAS,gBAAgB,CAAC,oBAAoB,CAAC,EAAE,OAAO,IAAI,iBAAiB,SAAS,CAAC,iBAAiB,SAAS,gBAAgB,CAAC,MAAM,MAAM,CAAC,GAAG,MAAM,GAAG,KAAK,CAAC,GAAG,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;AAE/O;;;;;;;;;;;;;;;;;GAiBG;AACH,8BAAsB,WAAW;;IAW7B;;;;;OAKG;gBACS,MAAM,EAAE,MAAM,GAAG,MAAM;IAUnC;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,WAAW;IAsBzE;;OAEG;IACH,IAAI,MAAM,IAAI,MAAM,CAEnB;IAuBD;;;;;;;;OAQG;IACH,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAsCnD;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,iBAAiB,SAAS,gBAAgB,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,aAAa,EAAE,iBAAiB,GAAG,iBAAiB,CAAC,iBAAiB,EAAE,MAAM,CAAC;IAEpJ;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,CAAC,iBAAiB,SAAS,gBAAgB,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,iBAAiB,CAAC,iBAAiB,EAAE,OAAO,CAAC;IAgCrN;;;;;;;;OAQG;IACH,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,gBAAgB,EAAE,MAAM,GAAG,MAAM;IAE9D;;;;;;;;OAQG;IACH,OAAO,CAAC,gBAAgB,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM;CAOrD;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,WAAW;IAChD;;OAEG;cACgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAInD;;OAEG;cACgB,SAAS,CAAC,gBAAgB,EAAE,MAAM,GAAG,MAAM;CAGjE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,qBAAsB,SAAQ,WAAW;;IAwClD;;;;;;;;OAQG;gBACS,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;IAuM3D;;OAEG;cACgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAiBnD;;OAEG;cACgB,SAAS,CAAC,gBAAgB,EAAE,MAAM,GAAG,MAAM;CAgBjE"}
|