Exosphere.ATProto.NSID (Exosphere v0.4.0)

Copy Markdown View Source

Namespaced Identifiers (NSIDs).

NSIDs name Lexicon schemas (and thus record collections / XRPC methods), for example app.bsky.feed.post or com.atproto.repo.getRecord.

Syntax rules (see the NSID spec):

  • At least 3 segments, max total length 317 characters.
  • The domain authority segments (all but the last) are each 1-63 characters of [a-zA-Z0-9-], not starting or ending with a hyphen. The first segment (the TLD) must not start with a digit.
  • The final segment (the name) is 1-63 characters of [a-zA-Z0-9] only (no hyphens) and must not start with a digit.

Examples

iex> Exosphere.ATProto.NSID.valid?("app.bsky.feed.post")
true

iex> Exosphere.ATProto.NSID.parse("app.bsky.feed.post")
{:ok, %{authority: "app.bsky.feed", name: "post", segments: ["app", "bsky", "feed", "post"]}}

Summary

Functions

Parse an NSID into its authority, name, and segments.

Validate an NSID string.

Types

parsed()

@type parsed() :: %{authority: String.t(), name: String.t(), segments: [String.t()]}

Functions

parse(nsid)

@spec parse(String.t()) :: {:ok, parsed()} | {:error, :invalid_nsid}

Parse an NSID into its authority, name, and segments.

Returns {:error, :invalid_nsid} if the string is not a valid NSID.

valid?(nsid)

@spec valid?(String.t()) :: boolean()

Validate an NSID string.