atproto_space/scope

OAuth space:* and space:<ref> scope building, parsing, and formatting.

Space scopes take the form space:* or space:<ref>[?authority=...&skey=...&collection=...&action=...&manage=...].

Types

pub type AuthorityFilter {
  SelfAuthority
  AnyAuthority
  DidAuthority(did: did.Did)
}

Constructors

  • SelfAuthority

    authority=self (spaces owned by the authenticated account).

  • AnyAuthority

    authority=* (spaces under any authority).

  • DidAuthority(did: did.Did)

    authority=did:... (spaces under a specific authority DID).

pub type ScopeError {
  MissingSpacePrefix(value: String)
  EmptyTarget(value: String)
  InvalidTarget(value: String)
  InvalidQuery(value: String)
  InvalidAuthority(value: String, error: did.DidError)
  InvalidSkey(value: String)
  InvalidCollection(value: String)
  DuplicateParameter(name: String)
  UnknownAction(value: String)
  UnknownManage(value: String)
  UnknownParameter(name: String)
}

Constructors

  • MissingSpacePrefix(value: String)
  • EmptyTarget(value: String)
  • InvalidTarget(value: String)
  • InvalidQuery(value: String)
  • InvalidAuthority(value: String, error: did.DidError)
  • InvalidSkey(value: String)
  • InvalidCollection(value: String)
  • DuplicateParameter(name: String)
  • UnknownAction(value: String)
  • UnknownManage(value: String)
  • UnknownParameter(name: String)
pub type SkeyFilter {
  AnySkey
  ExactSkey(key: String)
}

Constructors

  • AnySkey

    skey=* (any space key).

  • ExactSkey(key: String)

    skey=<key> (a specific space key).

pub type SpaceAction {
  Read
  ReadSelf
  Create
  Update
  Delete
}

Constructors

  • Read
  • ReadSelf
  • Create
  • Update
  • Delete
pub type SpaceManage {
  ManageCreate
  ManageUpdate
  ManageDelete
}

Constructors

  • ManageCreate
  • ManageUpdate
  • ManageDelete

A validated OAuth space:* or space:<ref> scope.

pub opaque type SpaceScope
pub type SpaceTarget {
  AllSpaces
  SpaceRef(ref: String)
}

Constructors

  • AllSpaces

    space:* (all space types).

  • SpaceRef(ref: String)

    space:<ref> (a specific space type NSID or lexicon ref).

Values

pub fn actions(scope: SpaceScope) -> List(SpaceAction)
pub fn all_spaces() -> SpaceScope

Wildcard space:* scope.

pub fn authority(
  scope: SpaceScope,
) -> option.Option(AuthorityFilter)
pub fn collections(scope: SpaceScope) -> List(String)
pub fn has_space_scope(scope_string: String) -> Bool

Whether a space-separated OAuth scope string contains any valid space scope.

pub fn join_with_atproto(scopes: List(SpaceScope)) -> String

Build an OAuth scope string starting with atproto followed by any space scopes.

pub fn manage(scope: SpaceScope) -> List(SpaceManage)
pub fn parse(raw: String) -> Result(SpaceScope, ScopeError)

Parse a single space:* or space:<ref> OAuth scope token.

pub fn parse_space_scopes(
  scope_string: String,
) -> List(SpaceScope)

Extract all valid space scopes from a space-separated OAuth scope string.

pub fn scope_error_to_string(error: ScopeError) -> String
pub fn skey(scope: SpaceScope) -> option.Option(SkeyFilter)
pub fn space(ref: String) -> Result(SpaceScope, ScopeError)

Scoped space:<ref> for an NSID or lexicon ref (<nsid> or <nsid>#<def>).

pub fn target(scope: SpaceScope) -> SpaceTarget
pub fn to_string(scope: SpaceScope) -> String

Format a SpaceScope as an OAuth scope token.

pub fn with_actions(
  scope: SpaceScope,
  actions: List(SpaceAction),
) -> SpaceScope
pub fn with_authority(
  scope: SpaceScope,
  authority: AuthorityFilter,
) -> SpaceScope
pub fn with_collections(
  scope: SpaceScope,
  collections: List(String),
) -> Result(SpaceScope, ScopeError)

Attenuate a scope to one or more collection NSIDs.

pub fn with_manage(
  scope: SpaceScope,
  manage: List(SpaceManage),
) -> SpaceScope
pub fn with_skey(
  scope: SpaceScope,
  skey: SkeyFilter,
) -> Result(SpaceScope, ScopeError)

Attenuate a scope to a specific skey (validated as a record key) or wildcard.

✨ Search Document