KittenBlue.JWS (kitten_blue v0.5.0)

This module provides JOSE.JWS wrappter functions using KittenBlue.JWK

Link to this section Summary

Link to this section Functions

Link to this function

sign(payload, key, header \\ %{})

Specs

sign(payload :: map(), key :: KittenBlue.JWK.t(), header :: map()) ::
  {:ok, String.t()} | {:error, :invalid_key}

Sign payload with KittenBlue.JWK

{:ok, token} = KittenBlue.JWS.sign(payload, kb_jwk)

# use header param
{:ok, token} = KittenBlue.JWS.sign(payload, kb_jwk, %{"typ" => "my_jwt_usage"})
Link to this function

verify(token, keys, required_header \\ nil)

Specs

verify(token :: String.t(), keys :: List.t(), required_header :: map()) ::
  {:error, :invalid_jwt_format}
  | {:error, :invalid_jwt_kid}
  | {:error, :invalid_jwt_signature}
  | {:error, :invalid_jwt_header}
  | {:ok, payload :: map()}

Signature verification using KittenBlue.JWK list.

{:ok, payload} = KittenBlue.JWS.verify(token, kb_jwk_list)

# with header param
{:ok, payload} = KittenBlue.JWS.verify(token, kb_jwk_list, %{"typ" => "my_jwt_usage"})