Search documentation of ExStreamClient

# ExStreamClient.Token.User (ExStreamClient v0.1.10)

View Source

# Summary

## Functions

generate_and_sign(extra_claims \\ %{}, key \\ __default_signer__())

Combines `generate_claims/1` and `encode_and_sign/2`

generate_and_sign!(extra_claims \\ %{}, key \\ __default_signer__())

Same as `generate_and_sign/2` but raises if error

get(user_id, expires_at \\ nil, secret \\ nil)

Generates a user token for the given user ID.

signer()

Returns the signer used for user tokens.

signer(secret)

Returns the signer used for user tokens.

verify_and_validate(bearer_token, key \\ __default_signer__(), context \\ %{})

Combines `verify/2` and `validate/2`

verify_and_validate!(bearer_token, key \\ __default_signer__(), context \\ %{})

Same as `verify_and_validate/2` but raises if error

# Functions

# generate_and_sign(extra_claims \\ %{}, key \\ __default_signer__())

    @spec generate_and_sign(Joken.claims(), Joken.signer_arg()) ::
      {:ok, Joken.bearer_token(), Joken.claims()} | {:error, Joken.error_reason()}

Combines `generate_claims/1` and `encode_and_sign/2`

# generate_and_sign!(extra_claims \\ %{}, key \\ __default_signer__())

    @spec generate_and_sign!(Joken.claims(), Joken.signer_arg()) :: Joken.bearer_token()

Same as `generate_and_sign/2` but raises if error

# get(user_id, expires_at \\ nil, secret \\ nil)

    @spec get(String.t(), DateTime.t() | nil, String.t() | nil) ::
      {:ok, String.t()} | {:error, any()}

Generates a user token for the given user ID.

## Arguments

- `user_id`: The user ID to generate a token for.

## Options

- `expires_at`: The expiration time for the token as a `DateTime` struct. If not provided, the token will not expire.

# signer()

    @spec signer() :: Joken.Signer.t()

Returns the signer used for user tokens.

# signer(secret)

    @spec signer(String.t() | nil) :: Joken.Signer.t()

Returns the signer used for user tokens.

# verify_and_validate(bearer_token, key \\ __default_signer__(), context \\ %{})

    @spec verify_and_validate(Joken.bearer_token(), Joken.signer_arg(), term()) ::
      {:ok, Joken.claims()} | {:error, Joken.error_reason()}

Combines `verify/2` and `validate/2`

# verify_and_validate!(bearer_token, key \\ __default_signer__(), context \\ %{})

    @spec verify_and_validate!(Joken.bearer_token(), Joken.signer_arg(), term()) ::
      Joken.claims()

Same as `verify_and_validate/2` but raises if error