Module utils

Source
Expand description

The utils module contains utility functions used internally by this library. They are exported for use in other libraries that depend on this one, or for advanced use cases that require custom logic.

Constants§

EXACT_PATH_TERMINATOR
A terminator used to indicate the end of an exact path in an HTTP certification tree.
EXACT_PATH_TERMINATOR_BYTES
A terminator used to indicate the end of an exact path in an HTTP certification tree, as bytes.
PATH_DIR_SEPARATOR
A trailing slash used to indicate a directory in an HTTP certification tree.
PATH_DIR_SEPARATOR_BYTES
A trailing slash used to indicate a directory in an HTTP certification tree, as bytes.
PATH_PREFIX
The prefix for all paths in an HTTP certification tree.
PATH_PREFIX_BYTES
The prefix for all paths in an HTTP certification tree, as bytes.
WILDCARD_PATH_TERMINATOR
A terminator used to indicate the end of a wildcard path in an HTTP certification tree.
WILDCARD_PATH_TERMINATOR_BYTES
A terminator used to indicate the end of a wildcard path in an HTTP certification tree, as bytes.

Functions§

add_skip_certification_header
Adds the IC-Certificate and IC-Certificate-Expression headers to a given HttpResponse. These headers are used by the HTTP Gateway to verify the authenticity of query call responses. In this case, the headers are pre-configured to instruct the HTTP Gateway to skip certification verification in a secure way. Secure in this context means that the decision to skip certification is made by the canister itself, and not by the replica, API boundary nodes or any other intermediate party.
add_v2_certificate_header
Adds the IC-Certificate header to a given HttpResponse. This header is used by the HTTP Gateway to verify the authenticity of query call responses made to the http_request method of the target canister.
is_wildcard_path_valid_for_request_path
Returns whether the given wildcard path is valid for the given request path.
more_specific_wildcards_for
Returns a list of wildcard paths that are more specific than the responding wildcard path. A wildcard path is more specific than another if it has more segments and it contains the requested path as a prefix. The responding wildcard path is expected to be a prefix of the requested path.
skip_certification_certified_data
Returns the hash of the certified data that can be used to instruct HTTP Gateways to skip certification.