Class TransformerAbstract

Transformer that transforms values in a numeric domain to values in a range equal to the domain or to another range defined by a callback function. In other words, the domain determines valid input values and, without a callback, the range of valid output values.

The concept is similar to format-preserving encryption, where input values within a specified domain (e.g., payment card numbers ranging from 8-19 digits) are transformed into values in the same domain, typically for storage in a database where the data type and length are already fixed and exfiltration of the data can have significant repercussions.

Two subclasses are supported directly by this class: IdentityTransformer (which operates based on a domain only) and EncryptionTransformer (which operates based on a domain and a tweak). If an application is expected to make repeated use of a transformer with the same domain and (optional) tweak and can't manage the transformer object, an in-memory cache is available via the get method. Properties in IdentityTransformer and EncryptionTransformer are read-only once constructed, so there is no issue with their shared use.

Hierarchy (view full)

Constructors

Accessors

Methods

Constructors

Accessors

Methods

  • Do the work of transforming a value forward.

    Parameters

    • value: bigint

      Value.

    Returns bigint

    Transformed value.

  • Transform a value forward.

    Parameters

    • value: number | bigint

      Value.

    Returns bigint

    Transformed value.

  • Transform a value forward.

    Type Parameters

    • T

      Type returned by transformation callback.

    Parameters

    • value: number | bigint

      Value.

    • transformationCallback: TransformationCallback<T>

      Called after the value is transformed to convert it to its final value.

    Returns T

    Value transformed into object.

  • Transform values forward.

    Parameters

    • values: Iterable<number | bigint, any, any>

      Values. If this is an instance of Sequencer, the minimum and maximum values are validated prior to transformation. Otherwise, the individual values are validated at the time of transformation.

    Returns IterableIterator<bigint, any, any>

    Transformed values.

  • Transform values forward.

    Type Parameters

    • T

      Type returned by transformation callback.

    Parameters

    • values: Iterable<number | bigint, any, any>

      Values. If this is an instance of Sequencer, the minimum and maximum values are validated prior to transformation. Otherwise, the individual values are validated at the time of transformation.

    • transformationCallback: TransformationCallback<T>

      Called after each value is transformed to convert it to its final value.

    Returns IterableIterator<T, any, any>

    Values transformed into objects.

  • Transform a value or values forward. This signature exists to allow similar overloaded methods in other classes to call this method correctly.

    Parameters

    • valueOrValues: number | bigint | Iterable<number | bigint, any, any>

    Returns bigint | IterableIterator<bigint, any, any>

  • Transform a value or values forward. This signature exists to allow similar overloaded methods in other classes to call this method correctly.

    Type Parameters

    • T

    Parameters

    Returns T | IterableIterator<T, any, any>

  • Do the work of transforming a value in reverse.

    Parameters

    • transformedValue: bigint

      Transformed value.

    Returns bigint

    Value.

  • Transform a value in reverse.

    Parameters

    • transformedValue: number | bigint

      Transformed value.

    Returns bigint

    Value.