Skip to content

Module dev_message.erl

The identity device: For non-reserved keys, it simply returns a key from the message as it is found in the message's underlying Erlang map.

Description

Private keys (priv[.*]) are not included. Reserved keys are: id, commitments, committers, keys, path, set, remove, get, and verify. Their function comments describe the behaviour of the device when these keys are set.

Function Index

calculate_id/3*
cannot_get_private_keys_test/0*
case_insensitive_get/3*Key matching should be case insensitive, following RFC-9110, so we implement a case-insensitive key lookup rather than delegating to hb_maps:get/2.
case_insensitive_get_test/0*
commit/3Commit to a message, using the commitment-device key to specify the device that should be used to commit to the message.
commitment_ids_from_committers/3*Returns a list of commitment IDs in a commitments map that are relevant for a list of given committer addresses.
commitment_ids_from_request/3*Implements a standardized form of specifying commitment IDs for a message request.
committed/3Return the list of committed keys from a message.
committers/1Return the committers of a message that are present in the given request.
committers/2
committers/3
deep_unset_test/0*
ensure_commitments_loaded/2*Ensure that the commitments submessage of a base message is fully loaded into local memory.
get/3Return the value associated with the key as it exists in the message's underlying Erlang map.
get/4
get_keys_mod_test/0*
id/1Return the ID of a message, using the committers list if it exists.
id/2
id/3
id_device/2*Locate the ID device of a message.
index/3Generate an index page for a message, in the event that the body and content-type of a message returned to the client are both empty.
info/0Return the info for the identity device.
is_private_mod_test/0*
key_from_device_test/0*
keys/1Get the public keys of a message.
keys/2
keys_from_device_test/0*
private_keys_are_filtered_test/0*
remove/2Remove a key or keys from a message.
remove/3
remove_test/0*
set/3Deep merge keys in a message.
set_conflicting_keys_test/0*
set_ignore_undefined_test/0*
set_path/3Special case of set/3 for setting the path key.
unset_with_set_test/0*
verify/3Verify a message.
verify_commitment/3*Execute a function for a single commitment in the context of its parent message.
verify_test/0*
with_relevant_commitments/3*Return a message with only the relevant commitments for a given request.

Function Details

calculate_id/3 *

calculate_id(Base, Req, NodeOpts) -> any()

cannot_get_private_keys_test/0 *

cannot_get_private_keys_test() -> any()

case_insensitive_get/3 *

case_insensitive_get(Key, Msg, Opts) -> any()

Key matching should be case insensitive, following RFC-9110, so we implement a case-insensitive key lookup rather than delegating to hb_maps:get/2. Encode the key to a binary if it is not already.

case_insensitive_get_test/0 *

case_insensitive_get_test() -> any()

commit/3

commit(Self, Req, Opts) -> any()

Commit to a message, using the commitment-device key to specify the device that should be used to commit to the message. If the key is not set, the default device (httpsig@1.0) is used.

commitment_ids_from_committers/3 *

commitment_ids_from_committers(CommitterAddrs, Commitments, Opts) -> any()

Returns a list of commitment IDs in a commitments map that are relevant for a list of given committer addresses.

commitment_ids_from_request/3 *

commitment_ids_from_request(Base, Req, Opts) -> any()

Implements a standardized form of specifying commitment IDs for a message request. The caller may specify a list of committers (by address) or a list of commitment IDs directly. They may specify both, in which case the returned list will be the union of the two lists. In each case, they may specify all or none for each group. If no specifiers are provided, the default is all for commitments -- also implying all for committers.

committed/3

committed(Self, Req, Opts) -> any()

Return the list of committed keys from a message.

committers/1

committers(Base) -> any()

Return the committers of a message that are present in the given request.

committers/2

committers(Base, Req) -> any()

committers/3

committers(X1, X2, NodeOpts) -> any()

deep_unset_test/0 *

deep_unset_test() -> any()

ensure_commitments_loaded/2 *

ensure_commitments_loaded(NonRelevant, Opts) -> any()

Ensure that the commitments submessage of a base message is fully loaded into local memory.

get/3

get(Key, Msg, Opts) -> any()

Return the value associated with the key as it exists in the message's underlying Erlang map. First check the public keys, then check case- insensitively if the key is a binary.

get/4

get(Key, Msg, Msg2, Opts) -> any()

get_keys_mod_test/0 *

get_keys_mod_test() -> any()

id/1

id(Base) -> any()

Return the ID of a message, using the committers list if it exists. If the committers key is all, return the ID including all known commitments -- none yields the ID without any commitments. If the committers key is a list/map, return the ID including only the specified commitments.

The id-device key in the message can be used to specify the device that should be used to calculate the ID. If it is not set, the default device (httpsig@1.0) is used.

Note: This function does not use AO-Core's get/3 function, as it as it would require significant computation. We may want to change this if/when non-map message structures are created.

id/2

id(Base, Req) -> any()

id/3

id(Base, Req, NodeOpts) -> any()

id_device/2 *

id_device(X1, Opts) -> any()

Locate the ID device of a message. The ID device is determined the device set in all of the commitments. If no commitments are present, the default device (httpsig@1.0) is used.

index/3

index(Msg, Req, Opts) -> any()

Generate an index page for a message, in the event that the body and content-type of a message returned to the client are both empty. We do this as follows: 1. Find the default_index key of the node message. If it is a binary, it is assumed to be the name of a device, and we execute the resolution as that ID. 2. Merge the base message with the default index message, favoring the default index message's keys over those in the base message, unless the default was a device name. 3. Execute the default_index_path (base: index) upon the message, giving the rest of the request unchanged.

info/0

info() -> any()

Return the info for the identity device.

is_private_mod_test/0 *

is_private_mod_test() -> any()

key_from_device_test/0 *

key_from_device_test() -> any()

keys/1

keys(Msg) -> any()

Get the public keys of a message.

keys/2

keys(Msg, Opts) -> any()

keys_from_device_test/0 *

keys_from_device_test() -> any()

private_keys_are_filtered_test/0 *

private_keys_are_filtered_test() -> any()

remove/2

remove(Message1, Key) -> any()

Remove a key or keys from a message.

remove/3

remove(Message1, X2, Opts) -> any()

remove_test/0 *

remove_test() -> any()

set/3

set(Message1, NewValuesMsg, Opts) -> any()

Deep merge keys in a message. Takes a map of key-value pairs and sets them in the message, overwriting any existing values.

set_conflicting_keys_test/0 *

set_conflicting_keys_test() -> any()

set_ignore_undefined_test/0 *

set_ignore_undefined_test() -> any()

set_path/3

set_path(Message1, X2, Opts) -> any()

Special case of set/3 for setting the path key. This cannot be set using the normal set function, as the path is a reserved key, necessary for AO-Core to know the key to evaluate in requests.

unset_with_set_test/0 *

unset_with_set_test() -> any()

verify/3

verify(Self, Req, Opts) -> any()

Verify a message. By default, all commitments are verified. The committers key in the request can be used to specify that only the commitments from specific committers should be verified. Similarly, specific commitments can be specified using the commitments key.

verify_commitment/3 *

verify_commitment(Base, Commitment, Opts) -> any()

Execute a function for a single commitment in the context of its parent message. Note: Assumes that the commitments key has already been removed from the message if applicable.

verify_test/0 *

verify_test() -> any()

with_relevant_commitments/3 *

with_relevant_commitments(Base, Req, Opts) -> any()

Return a message with only the relevant commitments for a given request. See commitment_ids_from_request/3 for more information on the request format.