@aidc-toolkit/utility 1.0.24-beta → 1.0.25-beta
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 +14 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +43 -37
- package/dist/index.d.ts +43 -37
- package/dist/index.js +14 -13
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/character-set.ts +14 -13
- package/src/exclusion.ts +6 -1
- package/src/reg-exp.ts +5 -5
- package/src/string.ts +3 -3
- package/src/transformer.ts +16 -15
- package/test/record.test.ts +3 -1
package/dist/index.d.cts
CHANGED
|
@@ -202,11 +202,12 @@ type TransformerOutput<TTransformerInput extends TransformerInput<TransformerPri
|
|
|
202
202
|
* into values in the same domain, typically for storage in a database where the data type and length are already fixed
|
|
203
203
|
* and exfiltration of the data can have significant repercussions.
|
|
204
204
|
*
|
|
205
|
-
* Two subclasses are supported directly by this class: {@
|
|
206
|
-
* only) and {@
|
|
207
|
-
* to make repeated use of a transformer with the same domain and (optional) tweak and can't manage the
|
|
208
|
-
* object, an in-memory cache is available via the {@
|
|
209
|
-
* {@
|
|
205
|
+
* Two subclasses are supported directly by this class: {@linkcode IdentityTransformer} (which operates based on a
|
|
206
|
+
* domain only) and {@linkcode EncryptionTransformer} (which operates based on a domain and a tweak). If an application
|
|
207
|
+
* is expected to make repeated use of a transformer with the same domain and (optional) tweak and can't manage the
|
|
208
|
+
* transformer object, an in-memory cache is available via the {@linkcode get | get()} method. Properties in {@linkcode
|
|
209
|
+
* IdentityTransformer} and {@linkcode EncryptionTransformer} are read-only once constructed, so there is no issue with
|
|
210
|
+
* their shared use.
|
|
210
211
|
*/
|
|
211
212
|
declare abstract class Transformer {
|
|
212
213
|
/**
|
|
@@ -225,10 +226,10 @@ declare abstract class Transformer {
|
|
|
225
226
|
*/
|
|
226
227
|
constructor(domain: number | bigint);
|
|
227
228
|
/**
|
|
228
|
-
* Get a transformer, constructing it if necessary. The type returned is {@
|
|
229
|
-
* undefined, {@
|
|
230
|
-
* with a zero tweak operates as an {@
|
|
231
|
-
* returned if a zero tweak is explicitly specified.
|
|
229
|
+
* Get a transformer, constructing it if necessary. The type returned is {@linkcode IdentityTransformer} if tweak is
|
|
230
|
+
* undefined, {@linkcode EncryptionTransformer} if tweak is defined. Note that although an {@linkcode
|
|
231
|
+
* EncryptionTransformer} with a zero tweak operates as an {@linkcode IdentityTransformer}, {@linkcode
|
|
232
|
+
* EncryptionTransformer} is still the type returned if a zero tweak is explicitly specified.
|
|
232
233
|
*
|
|
233
234
|
* @param domain
|
|
234
235
|
* Domain.
|
|
@@ -237,7 +238,7 @@ declare abstract class Transformer {
|
|
|
237
238
|
* Tweak.
|
|
238
239
|
*
|
|
239
240
|
* @returns
|
|
240
|
-
* {@
|
|
241
|
+
* {@linkcode IdentityTransformer} if tweak is undefined, {@linkcode EncryptionTransformer} if tweak is defined.
|
|
241
242
|
*/
|
|
242
243
|
static get(domain: number | bigint, tweak?: number | bigint): Transformer;
|
|
243
244
|
/**
|
|
@@ -294,7 +295,7 @@ declare abstract class Transformer {
|
|
|
294
295
|
* Value(s) input type.
|
|
295
296
|
*
|
|
296
297
|
* @param valueOrValues
|
|
297
|
-
* Value(s). If this is an instance of {@
|
|
298
|
+
* Value(s). If this is an instance of {@linkcode Sequence}, the minimum and maximum values are validated prior to
|
|
298
299
|
* transformation. Otherwise, the individual value(s) is/are validated at the time of transformation.
|
|
299
300
|
*
|
|
300
301
|
* @returns
|
|
@@ -311,7 +312,7 @@ declare abstract class Transformer {
|
|
|
311
312
|
* Transformation callback output type.
|
|
312
313
|
*
|
|
313
314
|
* @param valueOrValues
|
|
314
|
-
* Value(s). If this is an instance of {@
|
|
315
|
+
* Value(s). If this is an instance of {@linkcode Sequence}, the minimum and maximum values are validated prior to
|
|
315
316
|
* transformation. Otherwise, the individual value(s) is/are validated at the time of transformation.
|
|
316
317
|
*
|
|
317
318
|
* @param transformerCallback
|
|
@@ -358,9 +359,9 @@ declare class IdentityTransformer extends Transformer {
|
|
|
358
359
|
/**
|
|
359
360
|
* Encryption transformer. Values are transformed using repeated shuffle and xor operations, similar to those found in
|
|
360
361
|
* many cryptography algorithms, particularly AES. While sufficient for obfuscation of numeric sequences (e.g., serial
|
|
361
|
-
* number generation, below), if true format-preserving encryption is required, a more robust algorithm such as
|
|
362
|
-
*
|
|
363
|
-
*
|
|
362
|
+
* number generation, below), if true format-preserving encryption is required, a more robust algorithm such as {@link
|
|
363
|
+
* https://doi.org/10.6028/NIST.SP.800-38Gr1.2pd | FF1} is recommended. Furthermore, no work has been done to mitigate
|
|
364
|
+
* {@link https://timing.attacks.cr.yp.to/index.html | timing attacks} for key detection.
|
|
364
365
|
*
|
|
365
366
|
* The purpose of the encryption transformer is to generate pseudo-random values in a deterministic manner to obscure
|
|
366
367
|
* the sequence of values generated over time. A typical example is for serial number generation, where knowledge of the
|
|
@@ -518,10 +519,10 @@ interface StringValidation {
|
|
|
518
519
|
/**
|
|
519
520
|
* String validator interface.
|
|
520
521
|
*
|
|
521
|
-
* @template
|
|
522
|
+
* @template TStringValidation
|
|
522
523
|
* String validation type.
|
|
523
524
|
*/
|
|
524
|
-
interface StringValidator<
|
|
525
|
+
interface StringValidator<TStringValidation extends StringValidation = StringValidation> {
|
|
525
526
|
/**
|
|
526
527
|
* Validate a string and throw an error if validation fails.
|
|
527
528
|
*
|
|
@@ -531,17 +532,17 @@ interface StringValidator<V extends StringValidation = StringValidation> {
|
|
|
531
532
|
* @param validation
|
|
532
533
|
* String validation parameters.
|
|
533
534
|
*/
|
|
534
|
-
validate: (s: string, validation?:
|
|
535
|
+
validate: (s: string, validation?: TStringValidation) => void;
|
|
535
536
|
}
|
|
536
537
|
|
|
537
538
|
/**
|
|
538
539
|
* Regular expression validator. The regular expression applies to the full string only if constructed as such. For
|
|
539
|
-
* example, <code>/\d*/</code> (0 or more digits) matches every string, <code>/\d+/</code>
|
|
540
|
-
*
|
|
541
|
-
*
|
|
540
|
+
* example, <code>/\d*/</code> (0 or more digits) matches every string, <code>/\d+/</code> (1
|
|
541
|
+
* or more digits) matches strings with at least one digit, <code>/^\d*$/</code> matches strings that are
|
|
542
|
+
* all digits or empty, and <code>/^\d+$/</code> matches strings that are all digits and not empty.
|
|
542
543
|
*
|
|
543
|
-
* Clients of this class are recommended to override the {@
|
|
544
|
-
* message for their use case.
|
|
544
|
+
* Clients of this class are recommended to override the {@linkcode createErrorMessage | createErrorMessage()} method
|
|
545
|
+
* to create a more suitable error message for their use case.
|
|
545
546
|
*/
|
|
546
547
|
declare class RegExpValidator implements StringValidator {
|
|
547
548
|
/**
|
|
@@ -636,10 +637,14 @@ declare const Exclusions: {
|
|
|
636
637
|
*/
|
|
637
638
|
readonly AllNumeric: 2;
|
|
638
639
|
};
|
|
640
|
+
/**
|
|
641
|
+
* Exclusion key.
|
|
642
|
+
*/
|
|
643
|
+
type ExclusionKey = keyof typeof Exclusions;
|
|
639
644
|
/**
|
|
640
645
|
* Exclusion.
|
|
641
646
|
*/
|
|
642
|
-
type Exclusion = typeof Exclusions[
|
|
647
|
+
type Exclusion = typeof Exclusions[ExclusionKey];
|
|
643
648
|
|
|
644
649
|
/**
|
|
645
650
|
* Character set validation parameters.
|
|
@@ -695,7 +700,7 @@ declare class CharacterSetValidator implements StringValidator<CharacterSetValid
|
|
|
695
700
|
* set.
|
|
696
701
|
*
|
|
697
702
|
* @param exclusionSupport
|
|
698
|
-
* Exclusions supported by the character set. All character sets implicitly support {@
|
|
703
|
+
* Exclusions supported by the character set. All character sets implicitly support {@linkcode Exclusions.None}.
|
|
699
704
|
*/
|
|
700
705
|
constructor(characterSet: readonly string[], ...exclusionSupport: readonly Exclusion[]);
|
|
701
706
|
/**
|
|
@@ -811,7 +816,7 @@ declare class CharacterSetCreator extends CharacterSetValidator {
|
|
|
811
816
|
*/
|
|
812
817
|
private readonly _characterSetSizeMinusOneN;
|
|
813
818
|
/**
|
|
814
|
-
* Domains for every length for every supported {@
|
|
819
|
+
* Domains for every length for every supported {@linkcode Exclusions}.
|
|
815
820
|
*/
|
|
816
821
|
private readonly _exclusionDomains;
|
|
817
822
|
/**
|
|
@@ -826,7 +831,7 @@ declare class CharacterSetCreator extends CharacterSetValidator {
|
|
|
826
831
|
* set.
|
|
827
832
|
*
|
|
828
833
|
* @param exclusionSupport
|
|
829
|
-
* Exclusions supported by the character set. All character sets implicitly support {@
|
|
834
|
+
* Exclusions supported by the character set. All character sets implicitly support {@linkcode Exclusions.None}.
|
|
830
835
|
*/
|
|
831
836
|
constructor(characterSet: readonly string[], ...exclusionSupport: readonly Exclusion[]);
|
|
832
837
|
/**
|
|
@@ -856,7 +861,7 @@ declare class CharacterSetCreator extends CharacterSetValidator {
|
|
|
856
861
|
*/
|
|
857
862
|
private allNumericShift;
|
|
858
863
|
/**
|
|
859
|
-
* Validate that a length is less than or equal to {@
|
|
864
|
+
* Validate that a length is less than or equal to {@linkcode MAXIMUM_STRING_LENGTH}. If not, an error is thrown.
|
|
860
865
|
*
|
|
861
866
|
* @param length
|
|
862
867
|
* Length.
|
|
@@ -876,7 +881,8 @@ declare class CharacterSetCreator extends CharacterSetValidator {
|
|
|
876
881
|
* Numeric value(s) of the string(s).
|
|
877
882
|
*
|
|
878
883
|
* @param exclusion
|
|
879
|
-
* String(s) to be excluded from the range of outputs. See {@
|
|
884
|
+
* String(s) to be excluded from the range of outputs. See {@linkcode Exclusions} for possible values and their
|
|
885
|
+
* meaning.
|
|
880
886
|
*
|
|
881
887
|
* @param tweak
|
|
882
888
|
* If provided, the numerical value of the string(s) is/are "tweaked" using an {@link EncryptionTransformer |
|
|
@@ -896,7 +902,7 @@ declare class CharacterSetCreator extends CharacterSetValidator {
|
|
|
896
902
|
* String.
|
|
897
903
|
*
|
|
898
904
|
* @param exclusion
|
|
899
|
-
* Strings excluded from the range of inputs. See {@
|
|
905
|
+
* Strings excluded from the range of inputs. See {@linkcode Exclusions} for possible values and their meaning.
|
|
900
906
|
*
|
|
901
907
|
* @param tweak
|
|
902
908
|
* If provided, the numerical value of the string was "tweaked" using an {@link EncryptionTransformer | encryption
|
|
@@ -908,20 +914,20 @@ declare class CharacterSetCreator extends CharacterSetValidator {
|
|
|
908
914
|
valueFor(s: string, exclusion?: Exclusion, tweak?: number | bigint): bigint;
|
|
909
915
|
}
|
|
910
916
|
/**
|
|
911
|
-
* Numeric creator. Character set is 0-9. Supports {@
|
|
917
|
+
* Numeric creator. Character set is 0-9. Supports {@linkcode Exclusions.FirstZero}.
|
|
912
918
|
*/
|
|
913
919
|
declare const NUMERIC_CREATOR: CharacterSetCreator;
|
|
914
920
|
/**
|
|
915
|
-
* Numeric validator. Character set is 0-9. Supports {@
|
|
921
|
+
* Numeric validator. Character set is 0-9. Supports {@linkcode Exclusions.FirstZero}.
|
|
916
922
|
*/
|
|
917
923
|
declare const NUMERIC_VALIDATOR: CharacterSetValidator;
|
|
918
924
|
/**
|
|
919
|
-
* Hexadecimal creator. Character set is 0-9, A-F. Supports {@
|
|
925
|
+
* Hexadecimal creator. Character set is 0-9, A-F. Supports {@linkcode Exclusions.FirstZero} and {@linkcode
|
|
920
926
|
* Exclusions.AllNumeric}.
|
|
921
927
|
*/
|
|
922
928
|
declare const HEXADECIMAL_CREATOR: CharacterSetCreator;
|
|
923
929
|
/**
|
|
924
|
-
* Hexadecimal validator. Character set is 0-9, A-F. Supports {@
|
|
930
|
+
* Hexadecimal validator. Character set is 0-9, A-F. Supports {@linkcode Exclusions.FirstZero} and {@linkcode
|
|
925
931
|
* Exclusions.AllNumeric}.
|
|
926
932
|
*/
|
|
927
933
|
declare const HEXADECIMAL_VALIDATOR: CharacterSetValidator;
|
|
@@ -934,14 +940,14 @@ declare const ALPHABETIC_CREATOR: CharacterSetCreator;
|
|
|
934
940
|
*/
|
|
935
941
|
declare const ALPHABETIC_VALIDATOR: CharacterSetValidator;
|
|
936
942
|
/**
|
|
937
|
-
* Alphanumeric creator. Character set is 0-9, A-Z. Supports {@
|
|
943
|
+
* Alphanumeric creator. Character set is 0-9, A-Z. Supports {@linkcode Exclusions.FirstZero} and {@linkcode
|
|
938
944
|
* Exclusions.AllNumeric}.
|
|
939
945
|
*/
|
|
940
946
|
declare const ALPHANUMERIC_CREATOR: CharacterSetCreator;
|
|
941
947
|
/**
|
|
942
|
-
* Alphanumeric validator. Character set is 0-9, A-Z. Supports {@
|
|
948
|
+
* Alphanumeric validator. Character set is 0-9, A-Z. Supports {@linkcode Exclusions.FirstZero} and {@linkcode
|
|
943
949
|
* Exclusions.AllNumeric}.
|
|
944
950
|
*/
|
|
945
951
|
declare const ALPHANUMERIC_VALIDATOR: CharacterSetValidator;
|
|
946
952
|
|
|
947
|
-
export { ALPHABETIC_CREATOR, ALPHABETIC_VALIDATOR, ALPHANUMERIC_CREATOR, ALPHANUMERIC_VALIDATOR, CharacterSetCreator, type CharacterSetValidation, CharacterSetValidator, EncryptionTransformer, type Exclusion, Exclusions, HEXADECIMAL_CREATOR, HEXADECIMAL_VALIDATOR, IdentityTransformer, type IndexedCallback, NUMERIC_CREATOR, NUMERIC_VALIDATOR, RecordValidator, RegExpValidator, Sequence, type StringValidation, type StringValidator, Transformer, type TransformerInput, type TransformerOutput, type TransformerPrimitive, type UtilityLocaleResources, i18nUtilityInit, i18nextUtility, mapIterable, utilityNS, utilityResources };
|
|
953
|
+
export { ALPHABETIC_CREATOR, ALPHABETIC_VALIDATOR, ALPHANUMERIC_CREATOR, ALPHANUMERIC_VALIDATOR, CharacterSetCreator, type CharacterSetValidation, CharacterSetValidator, EncryptionTransformer, type Exclusion, type ExclusionKey, Exclusions, HEXADECIMAL_CREATOR, HEXADECIMAL_VALIDATOR, IdentityTransformer, type IndexedCallback, NUMERIC_CREATOR, NUMERIC_VALIDATOR, RecordValidator, RegExpValidator, Sequence, type StringValidation, type StringValidator, Transformer, type TransformerInput, type TransformerOutput, type TransformerPrimitive, type UtilityLocaleResources, i18nUtilityInit, i18nextUtility, mapIterable, utilityNS, utilityResources };
|
package/dist/index.d.ts
CHANGED
|
@@ -202,11 +202,12 @@ type TransformerOutput<TTransformerInput extends TransformerInput<TransformerPri
|
|
|
202
202
|
* into values in the same domain, typically for storage in a database where the data type and length are already fixed
|
|
203
203
|
* and exfiltration of the data can have significant repercussions.
|
|
204
204
|
*
|
|
205
|
-
* Two subclasses are supported directly by this class: {@
|
|
206
|
-
* only) and {@
|
|
207
|
-
* to make repeated use of a transformer with the same domain and (optional) tweak and can't manage the
|
|
208
|
-
* object, an in-memory cache is available via the {@
|
|
209
|
-
* {@
|
|
205
|
+
* Two subclasses are supported directly by this class: {@linkcode IdentityTransformer} (which operates based on a
|
|
206
|
+
* domain only) and {@linkcode EncryptionTransformer} (which operates based on a domain and a tweak). If an application
|
|
207
|
+
* is expected to make repeated use of a transformer with the same domain and (optional) tweak and can't manage the
|
|
208
|
+
* transformer object, an in-memory cache is available via the {@linkcode get | get()} method. Properties in {@linkcode
|
|
209
|
+
* IdentityTransformer} and {@linkcode EncryptionTransformer} are read-only once constructed, so there is no issue with
|
|
210
|
+
* their shared use.
|
|
210
211
|
*/
|
|
211
212
|
declare abstract class Transformer {
|
|
212
213
|
/**
|
|
@@ -225,10 +226,10 @@ declare abstract class Transformer {
|
|
|
225
226
|
*/
|
|
226
227
|
constructor(domain: number | bigint);
|
|
227
228
|
/**
|
|
228
|
-
* Get a transformer, constructing it if necessary. The type returned is {@
|
|
229
|
-
* undefined, {@
|
|
230
|
-
* with a zero tweak operates as an {@
|
|
231
|
-
* returned if a zero tweak is explicitly specified.
|
|
229
|
+
* Get a transformer, constructing it if necessary. The type returned is {@linkcode IdentityTransformer} if tweak is
|
|
230
|
+
* undefined, {@linkcode EncryptionTransformer} if tweak is defined. Note that although an {@linkcode
|
|
231
|
+
* EncryptionTransformer} with a zero tweak operates as an {@linkcode IdentityTransformer}, {@linkcode
|
|
232
|
+
* EncryptionTransformer} is still the type returned if a zero tweak is explicitly specified.
|
|
232
233
|
*
|
|
233
234
|
* @param domain
|
|
234
235
|
* Domain.
|
|
@@ -237,7 +238,7 @@ declare abstract class Transformer {
|
|
|
237
238
|
* Tweak.
|
|
238
239
|
*
|
|
239
240
|
* @returns
|
|
240
|
-
* {@
|
|
241
|
+
* {@linkcode IdentityTransformer} if tweak is undefined, {@linkcode EncryptionTransformer} if tweak is defined.
|
|
241
242
|
*/
|
|
242
243
|
static get(domain: number | bigint, tweak?: number | bigint): Transformer;
|
|
243
244
|
/**
|
|
@@ -294,7 +295,7 @@ declare abstract class Transformer {
|
|
|
294
295
|
* Value(s) input type.
|
|
295
296
|
*
|
|
296
297
|
* @param valueOrValues
|
|
297
|
-
* Value(s). If this is an instance of {@
|
|
298
|
+
* Value(s). If this is an instance of {@linkcode Sequence}, the minimum and maximum values are validated prior to
|
|
298
299
|
* transformation. Otherwise, the individual value(s) is/are validated at the time of transformation.
|
|
299
300
|
*
|
|
300
301
|
* @returns
|
|
@@ -311,7 +312,7 @@ declare abstract class Transformer {
|
|
|
311
312
|
* Transformation callback output type.
|
|
312
313
|
*
|
|
313
314
|
* @param valueOrValues
|
|
314
|
-
* Value(s). If this is an instance of {@
|
|
315
|
+
* Value(s). If this is an instance of {@linkcode Sequence}, the minimum and maximum values are validated prior to
|
|
315
316
|
* transformation. Otherwise, the individual value(s) is/are validated at the time of transformation.
|
|
316
317
|
*
|
|
317
318
|
* @param transformerCallback
|
|
@@ -358,9 +359,9 @@ declare class IdentityTransformer extends Transformer {
|
|
|
358
359
|
/**
|
|
359
360
|
* Encryption transformer. Values are transformed using repeated shuffle and xor operations, similar to those found in
|
|
360
361
|
* many cryptography algorithms, particularly AES. While sufficient for obfuscation of numeric sequences (e.g., serial
|
|
361
|
-
* number generation, below), if true format-preserving encryption is required, a more robust algorithm such as
|
|
362
|
-
*
|
|
363
|
-
*
|
|
362
|
+
* number generation, below), if true format-preserving encryption is required, a more robust algorithm such as {@link
|
|
363
|
+
* https://doi.org/10.6028/NIST.SP.800-38Gr1.2pd | FF1} is recommended. Furthermore, no work has been done to mitigate
|
|
364
|
+
* {@link https://timing.attacks.cr.yp.to/index.html | timing attacks} for key detection.
|
|
364
365
|
*
|
|
365
366
|
* The purpose of the encryption transformer is to generate pseudo-random values in a deterministic manner to obscure
|
|
366
367
|
* the sequence of values generated over time. A typical example is for serial number generation, where knowledge of the
|
|
@@ -518,10 +519,10 @@ interface StringValidation {
|
|
|
518
519
|
/**
|
|
519
520
|
* String validator interface.
|
|
520
521
|
*
|
|
521
|
-
* @template
|
|
522
|
+
* @template TStringValidation
|
|
522
523
|
* String validation type.
|
|
523
524
|
*/
|
|
524
|
-
interface StringValidator<
|
|
525
|
+
interface StringValidator<TStringValidation extends StringValidation = StringValidation> {
|
|
525
526
|
/**
|
|
526
527
|
* Validate a string and throw an error if validation fails.
|
|
527
528
|
*
|
|
@@ -531,17 +532,17 @@ interface StringValidator<V extends StringValidation = StringValidation> {
|
|
|
531
532
|
* @param validation
|
|
532
533
|
* String validation parameters.
|
|
533
534
|
*/
|
|
534
|
-
validate: (s: string, validation?:
|
|
535
|
+
validate: (s: string, validation?: TStringValidation) => void;
|
|
535
536
|
}
|
|
536
537
|
|
|
537
538
|
/**
|
|
538
539
|
* Regular expression validator. The regular expression applies to the full string only if constructed as such. For
|
|
539
|
-
* example, <code>/\d*/</code> (0 or more digits) matches every string, <code>/\d+/</code>
|
|
540
|
-
*
|
|
541
|
-
*
|
|
540
|
+
* example, <code>/\d*/</code> (0 or more digits) matches every string, <code>/\d+/</code> (1
|
|
541
|
+
* or more digits) matches strings with at least one digit, <code>/^\d*$/</code> matches strings that are
|
|
542
|
+
* all digits or empty, and <code>/^\d+$/</code> matches strings that are all digits and not empty.
|
|
542
543
|
*
|
|
543
|
-
* Clients of this class are recommended to override the {@
|
|
544
|
-
* message for their use case.
|
|
544
|
+
* Clients of this class are recommended to override the {@linkcode createErrorMessage | createErrorMessage()} method
|
|
545
|
+
* to create a more suitable error message for their use case.
|
|
545
546
|
*/
|
|
546
547
|
declare class RegExpValidator implements StringValidator {
|
|
547
548
|
/**
|
|
@@ -636,10 +637,14 @@ declare const Exclusions: {
|
|
|
636
637
|
*/
|
|
637
638
|
readonly AllNumeric: 2;
|
|
638
639
|
};
|
|
640
|
+
/**
|
|
641
|
+
* Exclusion key.
|
|
642
|
+
*/
|
|
643
|
+
type ExclusionKey = keyof typeof Exclusions;
|
|
639
644
|
/**
|
|
640
645
|
* Exclusion.
|
|
641
646
|
*/
|
|
642
|
-
type Exclusion = typeof Exclusions[
|
|
647
|
+
type Exclusion = typeof Exclusions[ExclusionKey];
|
|
643
648
|
|
|
644
649
|
/**
|
|
645
650
|
* Character set validation parameters.
|
|
@@ -695,7 +700,7 @@ declare class CharacterSetValidator implements StringValidator<CharacterSetValid
|
|
|
695
700
|
* set.
|
|
696
701
|
*
|
|
697
702
|
* @param exclusionSupport
|
|
698
|
-
* Exclusions supported by the character set. All character sets implicitly support {@
|
|
703
|
+
* Exclusions supported by the character set. All character sets implicitly support {@linkcode Exclusions.None}.
|
|
699
704
|
*/
|
|
700
705
|
constructor(characterSet: readonly string[], ...exclusionSupport: readonly Exclusion[]);
|
|
701
706
|
/**
|
|
@@ -811,7 +816,7 @@ declare class CharacterSetCreator extends CharacterSetValidator {
|
|
|
811
816
|
*/
|
|
812
817
|
private readonly _characterSetSizeMinusOneN;
|
|
813
818
|
/**
|
|
814
|
-
* Domains for every length for every supported {@
|
|
819
|
+
* Domains for every length for every supported {@linkcode Exclusions}.
|
|
815
820
|
*/
|
|
816
821
|
private readonly _exclusionDomains;
|
|
817
822
|
/**
|
|
@@ -826,7 +831,7 @@ declare class CharacterSetCreator extends CharacterSetValidator {
|
|
|
826
831
|
* set.
|
|
827
832
|
*
|
|
828
833
|
* @param exclusionSupport
|
|
829
|
-
* Exclusions supported by the character set. All character sets implicitly support {@
|
|
834
|
+
* Exclusions supported by the character set. All character sets implicitly support {@linkcode Exclusions.None}.
|
|
830
835
|
*/
|
|
831
836
|
constructor(characterSet: readonly string[], ...exclusionSupport: readonly Exclusion[]);
|
|
832
837
|
/**
|
|
@@ -856,7 +861,7 @@ declare class CharacterSetCreator extends CharacterSetValidator {
|
|
|
856
861
|
*/
|
|
857
862
|
private allNumericShift;
|
|
858
863
|
/**
|
|
859
|
-
* Validate that a length is less than or equal to {@
|
|
864
|
+
* Validate that a length is less than or equal to {@linkcode MAXIMUM_STRING_LENGTH}. If not, an error is thrown.
|
|
860
865
|
*
|
|
861
866
|
* @param length
|
|
862
867
|
* Length.
|
|
@@ -876,7 +881,8 @@ declare class CharacterSetCreator extends CharacterSetValidator {
|
|
|
876
881
|
* Numeric value(s) of the string(s).
|
|
877
882
|
*
|
|
878
883
|
* @param exclusion
|
|
879
|
-
* String(s) to be excluded from the range of outputs. See {@
|
|
884
|
+
* String(s) to be excluded from the range of outputs. See {@linkcode Exclusions} for possible values and their
|
|
885
|
+
* meaning.
|
|
880
886
|
*
|
|
881
887
|
* @param tweak
|
|
882
888
|
* If provided, the numerical value of the string(s) is/are "tweaked" using an {@link EncryptionTransformer |
|
|
@@ -896,7 +902,7 @@ declare class CharacterSetCreator extends CharacterSetValidator {
|
|
|
896
902
|
* String.
|
|
897
903
|
*
|
|
898
904
|
* @param exclusion
|
|
899
|
-
* Strings excluded from the range of inputs. See {@
|
|
905
|
+
* Strings excluded from the range of inputs. See {@linkcode Exclusions} for possible values and their meaning.
|
|
900
906
|
*
|
|
901
907
|
* @param tweak
|
|
902
908
|
* If provided, the numerical value of the string was "tweaked" using an {@link EncryptionTransformer | encryption
|
|
@@ -908,20 +914,20 @@ declare class CharacterSetCreator extends CharacterSetValidator {
|
|
|
908
914
|
valueFor(s: string, exclusion?: Exclusion, tweak?: number | bigint): bigint;
|
|
909
915
|
}
|
|
910
916
|
/**
|
|
911
|
-
* Numeric creator. Character set is 0-9. Supports {@
|
|
917
|
+
* Numeric creator. Character set is 0-9. Supports {@linkcode Exclusions.FirstZero}.
|
|
912
918
|
*/
|
|
913
919
|
declare const NUMERIC_CREATOR: CharacterSetCreator;
|
|
914
920
|
/**
|
|
915
|
-
* Numeric validator. Character set is 0-9. Supports {@
|
|
921
|
+
* Numeric validator. Character set is 0-9. Supports {@linkcode Exclusions.FirstZero}.
|
|
916
922
|
*/
|
|
917
923
|
declare const NUMERIC_VALIDATOR: CharacterSetValidator;
|
|
918
924
|
/**
|
|
919
|
-
* Hexadecimal creator. Character set is 0-9, A-F. Supports {@
|
|
925
|
+
* Hexadecimal creator. Character set is 0-9, A-F. Supports {@linkcode Exclusions.FirstZero} and {@linkcode
|
|
920
926
|
* Exclusions.AllNumeric}.
|
|
921
927
|
*/
|
|
922
928
|
declare const HEXADECIMAL_CREATOR: CharacterSetCreator;
|
|
923
929
|
/**
|
|
924
|
-
* Hexadecimal validator. Character set is 0-9, A-F. Supports {@
|
|
930
|
+
* Hexadecimal validator. Character set is 0-9, A-F. Supports {@linkcode Exclusions.FirstZero} and {@linkcode
|
|
925
931
|
* Exclusions.AllNumeric}.
|
|
926
932
|
*/
|
|
927
933
|
declare const HEXADECIMAL_VALIDATOR: CharacterSetValidator;
|
|
@@ -934,14 +940,14 @@ declare const ALPHABETIC_CREATOR: CharacterSetCreator;
|
|
|
934
940
|
*/
|
|
935
941
|
declare const ALPHABETIC_VALIDATOR: CharacterSetValidator;
|
|
936
942
|
/**
|
|
937
|
-
* Alphanumeric creator. Character set is 0-9, A-Z. Supports {@
|
|
943
|
+
* Alphanumeric creator. Character set is 0-9, A-Z. Supports {@linkcode Exclusions.FirstZero} and {@linkcode
|
|
938
944
|
* Exclusions.AllNumeric}.
|
|
939
945
|
*/
|
|
940
946
|
declare const ALPHANUMERIC_CREATOR: CharacterSetCreator;
|
|
941
947
|
/**
|
|
942
|
-
* Alphanumeric validator. Character set is 0-9, A-Z. Supports {@
|
|
948
|
+
* Alphanumeric validator. Character set is 0-9, A-Z. Supports {@linkcode Exclusions.FirstZero} and {@linkcode
|
|
943
949
|
* Exclusions.AllNumeric}.
|
|
944
950
|
*/
|
|
945
951
|
declare const ALPHANUMERIC_VALIDATOR: CharacterSetValidator;
|
|
946
952
|
|
|
947
|
-
export { ALPHABETIC_CREATOR, ALPHABETIC_VALIDATOR, ALPHANUMERIC_CREATOR, ALPHANUMERIC_VALIDATOR, CharacterSetCreator, type CharacterSetValidation, CharacterSetValidator, EncryptionTransformer, type Exclusion, Exclusions, HEXADECIMAL_CREATOR, HEXADECIMAL_VALIDATOR, IdentityTransformer, type IndexedCallback, NUMERIC_CREATOR, NUMERIC_VALIDATOR, RecordValidator, RegExpValidator, Sequence, type StringValidation, type StringValidator, Transformer, type TransformerInput, type TransformerOutput, type TransformerPrimitive, type UtilityLocaleResources, i18nUtilityInit, i18nextUtility, mapIterable, utilityNS, utilityResources };
|
|
953
|
+
export { ALPHABETIC_CREATOR, ALPHABETIC_VALIDATOR, ALPHANUMERIC_CREATOR, ALPHANUMERIC_VALIDATOR, CharacterSetCreator, type CharacterSetValidation, CharacterSetValidator, EncryptionTransformer, type Exclusion, type ExclusionKey, Exclusions, HEXADECIMAL_CREATOR, HEXADECIMAL_VALIDATOR, IdentityTransformer, type IndexedCallback, NUMERIC_CREATOR, NUMERIC_VALIDATOR, RecordValidator, RegExpValidator, Sequence, type StringValidation, type StringValidator, Transformer, type TransformerInput, type TransformerOutput, type TransformerPrimitive, type UtilityLocaleResources, i18nUtilityInit, i18nextUtility, mapIterable, utilityNS, utilityResources };
|
package/dist/index.js
CHANGED
|
@@ -430,7 +430,7 @@ var postProcessor = {
|
|
|
430
430
|
return value;
|
|
431
431
|
}
|
|
432
432
|
};
|
|
433
|
-
var PATH_KEY = Symbol("i18next/PATH_KEY");
|
|
433
|
+
var PATH_KEY = /* @__PURE__ */ Symbol("i18next/PATH_KEY");
|
|
434
434
|
function createProxy() {
|
|
435
435
|
const state = [];
|
|
436
436
|
const handler = /* @__PURE__ */ Object.create(null);
|
|
@@ -2415,10 +2415,10 @@ var Transformer = class _Transformer {
|
|
|
2415
2415
|
}
|
|
2416
2416
|
}
|
|
2417
2417
|
/**
|
|
2418
|
-
* Get a transformer, constructing it if necessary. The type returned is {@
|
|
2419
|
-
* undefined, {@
|
|
2420
|
-
* with a zero tweak operates as an {@
|
|
2421
|
-
* returned if a zero tweak is explicitly specified.
|
|
2418
|
+
* Get a transformer, constructing it if necessary. The type returned is {@linkcode IdentityTransformer} if tweak is
|
|
2419
|
+
* undefined, {@linkcode EncryptionTransformer} if tweak is defined. Note that although an {@linkcode
|
|
2420
|
+
* EncryptionTransformer} with a zero tweak operates as an {@linkcode IdentityTransformer}, {@linkcode
|
|
2421
|
+
* EncryptionTransformer} is still the type returned if a zero tweak is explicitly specified.
|
|
2422
2422
|
*
|
|
2423
2423
|
* @param domain
|
|
2424
2424
|
* Domain.
|
|
@@ -2427,7 +2427,7 @@ var Transformer = class _Transformer {
|
|
|
2427
2427
|
* Tweak.
|
|
2428
2428
|
*
|
|
2429
2429
|
* @returns
|
|
2430
|
-
* {@
|
|
2430
|
+
* {@linkcode IdentityTransformer} if tweak is undefined, {@linkcode EncryptionTransformer} if tweak is defined.
|
|
2431
2431
|
*/
|
|
2432
2432
|
static get(domain, tweak) {
|
|
2433
2433
|
const domainN = BigInt(domain);
|
|
@@ -2943,7 +2943,7 @@ var CharacterSetValidator = class _CharacterSetValidator {
|
|
|
2943
2943
|
* set.
|
|
2944
2944
|
*
|
|
2945
2945
|
* @param exclusionSupport
|
|
2946
|
-
* Exclusions supported by the character set. All character sets implicitly support {@
|
|
2946
|
+
* Exclusions supported by the character set. All character sets implicitly support {@linkcode Exclusions.None}.
|
|
2947
2947
|
*/
|
|
2948
2948
|
constructor(characterSet, ...exclusionSupport) {
|
|
2949
2949
|
this._characterSet = characterSet;
|
|
@@ -3148,7 +3148,7 @@ var CharacterSetCreator = class _CharacterSetCreator extends CharacterSetValidat
|
|
|
3148
3148
|
*/
|
|
3149
3149
|
_characterSetSizeMinusOneN;
|
|
3150
3150
|
/**
|
|
3151
|
-
* Domains for every length for every supported {@
|
|
3151
|
+
* Domains for every length for every supported {@linkcode Exclusions}.
|
|
3152
3152
|
*/
|
|
3153
3153
|
_exclusionDomains;
|
|
3154
3154
|
/**
|
|
@@ -3163,7 +3163,7 @@ var CharacterSetCreator = class _CharacterSetCreator extends CharacterSetValidat
|
|
|
3163
3163
|
* set.
|
|
3164
3164
|
*
|
|
3165
3165
|
* @param exclusionSupport
|
|
3166
|
-
* Exclusions supported by the character set. All character sets implicitly support {@
|
|
3166
|
+
* Exclusions supported by the character set. All character sets implicitly support {@linkcode Exclusions.None}.
|
|
3167
3167
|
*/
|
|
3168
3168
|
constructor(characterSet, ...exclusionSupport) {
|
|
3169
3169
|
super(characterSet, ...exclusionSupport);
|
|
@@ -3260,7 +3260,7 @@ var CharacterSetCreator = class _CharacterSetCreator extends CharacterSetValidat
|
|
|
3260
3260
|
return shift;
|
|
3261
3261
|
}
|
|
3262
3262
|
/**
|
|
3263
|
-
* Validate that a length is less than or equal to {@
|
|
3263
|
+
* Validate that a length is less than or equal to {@linkcode MAXIMUM_STRING_LENGTH}. If not, an error is thrown.
|
|
3264
3264
|
*
|
|
3265
3265
|
* @param length
|
|
3266
3266
|
* Length.
|
|
@@ -3293,7 +3293,8 @@ var CharacterSetCreator = class _CharacterSetCreator extends CharacterSetValidat
|
|
|
3293
3293
|
* Numeric value(s) of the string(s).
|
|
3294
3294
|
*
|
|
3295
3295
|
* @param exclusion
|
|
3296
|
-
* String(s) to be excluded from the range of outputs. See {@
|
|
3296
|
+
* String(s) to be excluded from the range of outputs. See {@linkcode Exclusions} for possible values and their
|
|
3297
|
+
* meaning.
|
|
3297
3298
|
*
|
|
3298
3299
|
* @param tweak
|
|
3299
3300
|
* If provided, the numerical value of the string(s) is/are "tweaked" using an {@link EncryptionTransformer |
|
|
@@ -3315,7 +3316,7 @@ var CharacterSetCreator = class _CharacterSetCreator extends CharacterSetValidat
|
|
|
3315
3316
|
if (length !== 0) {
|
|
3316
3317
|
let convertValue = transformedValue;
|
|
3317
3318
|
if (exclusion === Exclusions.AllNumeric && convertValue >= allZerosValue) {
|
|
3318
|
-
convertValue
|
|
3319
|
+
convertValue += this.allNumericShift(true, length, convertValue - allZerosValue);
|
|
3319
3320
|
}
|
|
3320
3321
|
for (let position = length - 1; position > 0; position--) {
|
|
3321
3322
|
const nextConvertValue = convertValue / this._characterSetSizeN;
|
|
@@ -3334,7 +3335,7 @@ var CharacterSetCreator = class _CharacterSetCreator extends CharacterSetValidat
|
|
|
3334
3335
|
* String.
|
|
3335
3336
|
*
|
|
3336
3337
|
* @param exclusion
|
|
3337
|
-
* Strings excluded from the range of inputs. See {@
|
|
3338
|
+
* Strings excluded from the range of inputs. See {@linkcode Exclusions} for possible values and their meaning.
|
|
3338
3339
|
*
|
|
3339
3340
|
* @param tweak
|
|
3340
3341
|
* If provided, the numerical value of the string was "tweaked" using an {@link EncryptionTransformer | encryption
|