LiveKit.Grants.Claims (LiveKit v0.1.0)

Copy Markdown View Source

The complete set of LiveKit-specific claims carried by an access token.

This is the container LiveKit.AccessToken builds up; the registered JWT claims (iss, sub, iat, nbf, exp) are added at signing time.

iex> claims = %LiveKit.Grants.Claims{
...>   name: "Alice",
...>   video: %LiveKit.Grants.Video{room_join: true, room: "lobby"}
...> }
iex> LiveKit.Grants.to_claims(claims)
%{"name" => "Alice", "video" => %{"roomJoin" => true, "room" => "lobby"}}

identity is tracked here for completeness but is encoded as the sub registered claim rather than a nested field.

Summary

Functions

Mapping from struct field to LiveKit JWT claim key.

Types

t()

@type t() :: %LiveKit.Grants.Claims{
  agent: LiveKit.Grants.Agent.t() | nil,
  attributes: %{required(String.t()) => String.t()} | nil,
  identity: String.t() | nil,
  kind: String.t() | nil,
  metadata: String.t() | nil,
  name: String.t() | nil,
  room_preset: String.t() | nil,
  sha256: String.t() | nil,
  sip: LiveKit.Grants.SIP.t() | nil,
  video: LiveKit.Grants.Video.t() | nil
}

Functions

claim_keys()

@spec claim_keys() :: %{required(atom()) => String.t()}

Mapping from struct field to LiveKit JWT claim key.

:identity is absent because it is encoded as the sub registered claim.

Examples

iex> LiveKit.Grants.Claims.claim_keys()[:room_preset]
"roomPreset"

iex> Map.has_key?(LiveKit.Grants.Claims.claim_keys(), :identity)
false