Picnic.Session.TokenStore behaviour (Picnic v0.1.0)

Copy Markdown View Source

Behaviour for persisting the auth token across Picnic.Session restarts.

The store is purely functional: the session holds the store's state and threads it through these callbacks, so an implementation can be anything from a value held in memory to an ETS table, a file, or a database row.

The default is Picnic.Session.TokenStore.Memory.

Summary

Callbacks

Returns a previously stored token, or :error if there is none.

Builds the store's initial state from the options given to the session.

Stores a freshly obtained token, returning the updated store state.

Callbacks

fetch(state)

@callback fetch(state :: term()) :: {:ok, String.t()} | :error

Returns a previously stored token, or :error if there is none.

init(keyword)

@callback init(keyword()) :: term()

Builds the store's initial state from the options given to the session.

put(state, token)

@callback put(state :: term(), token :: String.t()) :: term()

Stores a freshly obtained token, returning the updated store state.