View Source Auth0.Common.Util (Auth0Api v2.2.0)
Documentation for Util.
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.
Decode json or String.
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.
Functions
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"
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"]}
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"
Decode json using atom key.
Decode json or String.
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>>
Encode to Base 16 value with lower case.
Examples
iex> Auth0.Common.Util.hex_encode("erin")
"6572696e"
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>>
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}
Convert struct to map recursively.
Convert map to struct and string keys are considered.
@spec uuid() :: String.t()
Generate UUID4 value.