ProtoRune.Atproto.Session (proto_rune v0.2.0)

Copy Markdown

An authenticated AT Protocol session.

Returned by ProtoRune.login/2 and ProtoRune.refresh_session/1. Carries the access and refresh JWTs, the account's handle and did, and the service_url of the PDS resolved from the DID document, so requests are routed to the right server.

Treat it as an opaque value: pass it as the first argument to any function that requires authentication, and refresh it with ProtoRune.refresh_session/1 when the access token expires.

Summary

Functions

Parses session data from the server response.

Types

t()

@type t() :: %ProtoRune.Atproto.Session{
  access_jwt: String.t(),
  active: boolean() | nil,
  did: String.t(),
  did_doc: map() | nil,
  email: String.t() | nil,
  email_auth_factor: boolean() | nil,
  email_confirmed: boolean() | nil,
  handle: String.t(),
  refresh_jwt: String.t(),
  service_url: String.t() | nil
}

Functions

parse(data)

Parses session data from the server response.

Extracts the service URL from the DID document if available, allowing the session to carry its own service endpoint.

Examples

{:ok, session} = Session.parse(%{
  access_jwt: "...",
  refresh_jwt: "...",
  did: "did:plc:...",
  handle: "alice.bsky.social"
})