Just a shell around the algorithm, consisting of a state, and the calls to the real implementation.

The variable parts of the state, as defined in the spec, are re-initialized at the canonicalize call. Ie, the same class instance can therefore be reused to canonicalize for different graphs.

Hierarchy

  • RDFC10

Constructors

  • Parameters

    • Optional data_factory: DataFactory<Quad, Quad>

      An implementation of the generic RDF DataFactory interface, see the specification. If undefined, the DataFactory of the n3 package is used.

    • Optional getConfigData: GetConfigData

      A function returning the configuration data, see ConfigData. By default, this returns the constant values set in the code; the caller may provide a more complex function to handle environment variables and/or configuration files.

    Returns RDFC10

Accessors

  • get logger_type(): string
  • Current logger type.

    Returns string

  • get available_logger_types(): string[]
  • List of available logger types.

    Returns string[]

  • get hash_algorithm(): string
  • Returns string

  • set hash_algorithm(algorithm_in): void
  • Set the Hash algorithm (default is "sha256"). If the algorithm isn't available the value is ignored (and an exception is thrown).

    The name is considered to be case insensitive. Also, both the format including a '-' dash character or not are accepted (i.e., "sha256" and "sha-256" are both fine).

    Parameters

    • algorithm_in: string

    Returns void

  • get available_hash_algorithms(): string[]
  • List of available hash algorithm names.

    Returns string[]

  • get maximum_complexity_number(): number
  • Returns number

  • set maximum_complexity_number(level): void
  • Set the maximal complexity number. This number, multiplied with the number of blank nodes in the dataset, sets a maximum number of calls the algorithm can do for the so called "hash n degree quads" function. Setting this number to a reasonably low number (say, 30), ensures that some "poison graphs" would not result in an unreasonably long canonicalization process. See the security consideration section in the specification.

    The default value set by this implementation is 50; any number greater then this number is ignored (and an exception is thrown).

    Parameters

    • level: number

    Returns void

  • get maximum_allowed_complexity_number(): number
  • The system-wide maximum value for the complexity level. The current maximum complexity level cannot exceed this value.

    Returns number

Methods

  • Create and set a logger instance. By default it is an "empty" logger, ie, no logging happens.

    Parameters

    • id: string = LoggerFactory.DEFAULT_LOGGER
    • level: LogLevels = LogLevels.debug

    Returns Logger

  • Canonicalize a Dataset into an N-Quads document.

    Implementation of the main algorithm, see the separate overview in the spec.

    (The real work is done in the separate function).

    Parameters

    • input_dataset: InputDataset
    • copy: boolean = undefined

      whether the input should be copied to a local store (e.g., if the input is a generator, or the uniqueness of quads are not guaranteed). If this parameter is not used (i.e., value is undefined) the copy is always done unless the input is an rdf.DatasetCore instance.

    Returns Promise<string>

    • N-Quads document using the canonical ID-s.

    Remarks

    Note that the N-Quads parser throws an exception in case of syntax error.

    Throws

    Async

  • Canonicalize a Dataset producing the full set of information.

    Implementation of the main algorithmic steps, see separate overview in the spec.

    (The real work is done in the separate function).

    The result is an Object containing the serialized version and the Quads version of the canonicalization result, as well as a bnode mapping from the original to the canonical equivalents.

    Parameters

    • input_dataset: InputDataset
    • copy: boolean = undefined

      whether the input should be copied to a local store (e.g., if the input is a generator, or the uniqueness of quads are not guaranteed). If this parameter is not used (i.e., value is undefined) the copy is always done unless the input is an rdf.DatasetCore instance.

    Returns Promise<C14nResult>

    • Detailed results of the canonicalization

    Remarks

    Note that the N-Quads parser throws an exception in case of syntax error.

    Throws

    Async

  • Serialize a dataset into a (possibly sorted) Array of nquads.

    Parameters

    • input_dataset: Iterable<Quad>
    • sort: boolean = true

      If true (the default) the array is lexicographically sorted

    Returns string[]

  • Hash a dataset:

    1. serialize the dataset into nquads and sort the result (unless the input is an N-Quads document);
    2. compute the hash of the concatenated nquads.

    This method is typically used on the result of the canonicalization to compute the canonical hash of a dataset.

    Parameters

    Returns Promise<string>