Sake.Server.Session (Sake v0.1.0)

Copy Markdown View Source

Legacy session IDs are signed tokens that carry the negotiated revision, the client capabilities, the log level logging/setLevel last set, and a random nonce. The server stores nothing per session.

The nonce is the session's identity: a re-minted ID (after logging/setLevel, or when the ID gets old) keeps it, so the session's GET stream and its resource subscriptions follow the session across renewals.

Summary

Functions

Mints a new session ID; nonce is the identity of an existing session being renewed.

Re-mints session with the same nonce and the given log level.

Whether the ID is old enough to be re-minted on the response.

Types

session()

@type session() :: %{
  revision: String.t(),
  capabilities: map(),
  minted_at: integer(),
  log_level: String.t() | nil,
  nonce: String.t()
}

Functions

mint(secret, revision, capabilities, log_level \\ nil, nonce \\ nil)

@spec mint(binary(), String.t(), map(), String.t() | nil, String.t() | nil) ::
  String.t()

Mints a new session ID; nonce is the identity of an existing session being renewed.

renew(secret, session, log_level)

@spec renew(binary(), session(), String.t() | nil) :: String.t()

Re-mints session with the same nonce and the given log level.

renew?(map)

@spec renew?(session()) :: boolean()

Whether the ID is old enough to be re-minted on the response.

verify(secret, id)

@spec verify(binary(), term()) :: {:ok, session()} | :error