View Source AppIdentity.Proof (AppIdentity for Elixir v1.3.0)

A struct describing a computed or parsed App Identity proof.

Summary

Types

t()

The components of a parsed AppIdentity proof.

Types

@type t() :: %AppIdentity.Proof{
  id: AppIdentity.id(),
  nonce: AppIdentity.nonce(),
  padlock: binary(),
  version: AppIdentity.version()
}

The components of a parsed AppIdentity proof.

Functions

Link to this function

build(app, nonce, options \\ [])

View Source
@spec build(
  app :: AppIdentity.App.t(),
  nonce :: AppIdentity.nonce(),
  options :: [AppIdentity.option()]
) ::
  {:ok, proof :: t()} | {:error, reason :: String.t()}

Build an AppIdentity.Proof struct from an AppIdentity.App struct and a nonce.

This method returns the either {:ok, proof} or {:error, reason}

Examples:

iex> AppIdentity.Proof.build(
...>   AppIdentity.App.new!(%{
...>     id: "867-5309",
...>     secret: "Something unguessable",
...>     version: 1
...>   }),
...>   "a nonce"
...> )
{:ok, %AppIdentity.Proof{
  id: "867-5309",
  nonce: "a nonce",
  version: 1,
  padlock: "57384B64BF69703296DF9E4C93DC83CF4B96EAF20298006897DFBC2A63904219"
}}

iex> AppIdentity.Proof.build(
...>   AppIdentity.App.new!(%{
...>     id: "123-456-789",
...>     secret: fn -> "Something unguessable" end,
...>     version: 2
...>   }),
...>   "",
...>   version: 3
...> )
{:error, "nonce must not be an empty string"}
@spec from_string(proof :: binary()) ::
  {:ok, proof :: t()} | {:error, reason :: String.t()}
@spec to_string(proof :: t()) :: binary()
Link to this function

verify(proof, app, options)

View Source
@spec verify(
  proof :: t(),
  app :: AppIdentity.App.finder() | AppIdentity.App.t(),
  options :: [AppIdentity.option()]
) :: {:ok, app :: AppIdentity.App.t() | nil} | {:error, reason :: String.t()}