Auth0.Common.Util (Auth0Api v1.4.0) View Source

Documentation for Util.

Link to this section Summary

Functions

append query to endpoint.

Convert to form body from map. Nil value is removed.

Convert to query from map. Nil value is removed.

Decode json using atom key.

Generate SHA256 hash value.

Encode to Base 16 value with lower case.

Generate HMAC-SHA256 hash value.

Remove nil value from map recursively.

Convert struct to map recursively.

Convert map to struct and string keys are considered.

Generate UUID4 value.

Link to this section Functions

Link to this function

append_query(query, endpoint)

View Source

Specs

append_query(String.t(), String.t()) :: String.t()

append query to endpoint.

Examples

iex> Auth0.Common.Util.append_query("a=1&c=3&d=erin%20the%20black", "/hoge/fuga")
"/hoge/fuga?a=1&c=3&d=erin%20the%20black"
Link to this function

convert_to_form_body(map)

View Source

Specs

convert_to_form_body(map()) :: {:form, keyword()}

Convert to form body from map. Nil value is removed.

Examples

iex> Auth0.Common.Util.encode_form_body(%{a: 1, b: nil, c: 3, d: "erin the black"})
{:form, [a: 1, b: nil, c: 3, d: "erin the black"]}

Specs

convert_to_query(map()) :: String.t()

Convert to query from map. Nil value is removed.

Examples

iex> Auth0.Common.Util.encode_query(%{a: 1, b: nil, c: 3, d: "erin the black"})
"a=1&c=3&d=erin%20the%20black"

Specs

decode_json!(String.t()) :: map() | list()

Decode json using atom key.

Specs

hash(String.t()) :: binary()

Generate SHA256 hash value.

Examples

iex> Auth0.Common.Util.hash("erin")
<<124, 188, 203, 12, 76, 170, 223, 159, 205, 181, 30, 228, 87, 168, 40, 204,
  114, 164, 88, 121, 131, 27, 91, 151, 138, 226, 226, 206, 252, 68, 151, 5>>

Specs

hex_encode(String.t()) :: String.t()

Encode to Base 16 value with lower case.

Examples

iex> Auth0.Common.Util.hex_encode("erin")
"6572696e"

Specs

hmac(String.t(), String.t()) :: binary()

Generate HMAC-SHA256 hash value.

Examples

iex> Auth0.Common.Util.hmac("secret", "erin")
<<66, 116, 70, 47, 123, 250, 150, 31, 51, 11, 16, 118, 149, 254, 106, 254, 89,
  65, 153, 52, 185, 191, 44, 50, 250, 254, 55, 172, 101, 31, 249, 250>>

Specs

remove_nil(map()) :: map()

Remove nil value from map recursively.

Examples

iex> Auth0.Common.Util.remove_nil(%{a: 1, b: nil, c: 3})
%{a: 1, c: 3}

iex> Auth0.Common.Util.remove_nil(%{:a => 1, :b => nil, :c => 3, "d" => nil, "f" => 5})
%{:a => 1, :c => 3, "f" => 5}

Specs

to_map(struct()) :: map()

Convert struct to map recursively.

Specs

to_struct(map(), module()) :: struct()

Convert map to struct and string keys are considered.

Specs

uuid() :: String.t()

Generate UUID4 value.