···11+# atex_atproto
22+33+This package contains the
44+[core `com.atproto` lexicons](https://github.com/bluesky-social/atproto/tree/main/lexicons/com/atproto)
55+translated into Elixir modules for use with
66+[atex](https://github.com/cometsh/atex).
77+88+## Installation
99+1010+Add `atex_atproto` to your list of dependencies in `mix.exs`:
1111+1212+```elixir
1313+def deps do
1414+ [
1515+ {:atex_atproto, "~> 0.1.0"}
1616+ ]
1717+end
1818+```
···11+defmodule Com.Atproto.Lexicon.Schema do
22+ @moduledoc false
33+ use Atex.Lexicon
44+55+ deflexicon(%{
66+ "defs" => %{
77+ "main" => %{
88+ "description" =>
99+ "Representation of Lexicon schemas themselves, when published as atproto records. Note that the schema language is not defined in Lexicon; this meta schema currently only includes a single version field ('lexicon'). See the atproto specifications for description of the other expected top-level fields ('id', 'defs', etc).",
1010+ "key" => "nsid",
1111+ "record" => %{
1212+ "properties" => %{
1313+ "lexicon" => %{
1414+ "description" =>
1515+ "Indicates the 'version' of the Lexicon language. Must be '1' for the current atproto/Lexicon schema system.",
1616+ "type" => "integer"
1717+ }
1818+ },
1919+ "required" => ["lexicon"],
2020+ "type" => "object"
2121+ },
2222+ "type" => "record"
2323+ }
2424+ },
2525+ "id" => "com.atproto.lexicon.schema",
2626+ "lexicon" => 1
2727+ })
2828+end
···11+defmodule Com.Atproto.Server.DeactivateAccount do
22+ @moduledoc false
33+ use Atex.Lexicon
44+55+ deflexicon(%{
66+ "defs" => %{
77+ "main" => %{
88+ "description" =>
99+ "Deactivates a currently active account. Stops serving of repo, and future writes to repo until reactivated. Used to finalize account migration with the old host after the account has been activated on the new host.",
1010+ "input" => %{
1111+ "encoding" => "application/json",
1212+ "schema" => %{
1313+ "properties" => %{
1414+ "deleteAfter" => %{
1515+ "description" =>
1616+ "A recommendation to server as to how long they should hold onto the deactivated account before deleting.",
1717+ "format" => "datetime",
1818+ "type" => "string"
1919+ }
2020+ },
2121+ "type" => "object"
2222+ }
2323+ },
2424+ "type" => "procedure"
2525+ }
2626+ },
2727+ "id" => "com.atproto.server.deactivateAccount",
2828+ "lexicon" => 1
2929+ })
3030+end
···11+defmodule Com.Atproto.Server.GetServiceAuth do
22+ @moduledoc false
33+ use Atex.Lexicon
44+55+ deflexicon(%{
66+ "defs" => %{
77+ "main" => %{
88+ "description" =>
99+ "Get a signed token on behalf of the requesting DID for the requested service.",
1010+ "errors" => [
1111+ %{
1212+ "description" =>
1313+ "Indicates that the requested expiration date is not a valid. May be in the past or may be reliant on the requested scopes.",
1414+ "name" => "BadExpiration"
1515+ }
1616+ ],
1717+ "output" => %{
1818+ "encoding" => "application/json",
1919+ "schema" => %{
2020+ "properties" => %{"token" => %{"type" => "string"}},
2121+ "required" => ["token"],
2222+ "type" => "object"
2323+ }
2424+ },
2525+ "parameters" => %{
2626+ "properties" => %{
2727+ "aud" => %{
2828+ "description" =>
2929+ "The DID of the service that the token will be used to authenticate with",
3030+ "format" => "did",
3131+ "type" => "string"
3232+ },
3333+ "exp" => %{
3434+ "description" =>
3535+ "The time in Unix Epoch seconds that the JWT expires. Defaults to 60 seconds in the future. The service may enforce certain time bounds on tokens depending on the requested scope.",
3636+ "type" => "integer"
3737+ },
3838+ "lxm" => %{
3939+ "description" => "Lexicon (XRPC) method to bind the requested token to",
4040+ "format" => "nsid",
4141+ "type" => "string"
4242+ }
4343+ },
4444+ "required" => ["aud"],
4545+ "type" => "params"
4646+ },
4747+ "type" => "query"
4848+ }
4949+ },
5050+ "id" => "com.atproto.server.getServiceAuth",
5151+ "lexicon" => 1
5252+ })
5353+end
+37
lib/atproto/com/atproto/server/getSession.ex
···11+defmodule Com.Atproto.Server.GetSession do
22+ @moduledoc false
33+ use Atex.Lexicon
44+55+ deflexicon(%{
66+ "defs" => %{
77+ "main" => %{
88+ "description" => "Get information about the current auth session. Requires auth.",
99+ "output" => %{
1010+ "encoding" => "application/json",
1111+ "schema" => %{
1212+ "properties" => %{
1313+ "active" => %{"type" => "boolean"},
1414+ "did" => %{"format" => "did", "type" => "string"},
1515+ "didDoc" => %{"type" => "unknown"},
1616+ "email" => %{"type" => "string"},
1717+ "emailAuthFactor" => %{"type" => "boolean"},
1818+ "emailConfirmed" => %{"type" => "boolean"},
1919+ "handle" => %{"format" => "handle", "type" => "string"},
2020+ "status" => %{
2121+ "description" =>
2222+ "If active=false, this optional field indicates a possible reason for why the account is not active. If active=false and no status is supplied, then the host makes no claim for why the repository is no longer being hosted.",
2323+ "knownValues" => ["takendown", "suspended", "deactivated"],
2424+ "type" => "string"
2525+ }
2626+ },
2727+ "required" => ["handle", "did"],
2828+ "type" => "object"
2929+ }
3030+ },
3131+ "type" => "query"
3232+ }
3333+ },
3434+ "id" => "com.atproto.server.getSession",
3535+ "lexicon" => 1
3636+ })
3737+end
···11+defmodule Com.Atproto.Sync.NotifyOfUpdate do
22+ @moduledoc false
33+ use Atex.Lexicon
44+55+ deflexicon(%{
66+ "defs" => %{
77+ "main" => %{
88+ "description" =>
99+ "Notify a crawling service of a recent update, and that crawling should resume. Intended use is after a gap between repo stream events caused the crawling service to disconnect. Does not require auth; implemented by Relay. DEPRECATED: just use com.atproto.sync.requestCrawl",
1010+ "input" => %{
1111+ "encoding" => "application/json",
1212+ "schema" => %{
1313+ "properties" => %{
1414+ "hostname" => %{
1515+ "description" =>
1616+ "Hostname of the current service (usually a PDS) that is notifying of update.",
1717+ "type" => "string"
1818+ }
1919+ },
2020+ "required" => ["hostname"],
2121+ "type" => "object"
2222+ }
2323+ },
2424+ "type" => "procedure"
2525+ }
2626+ },
2727+ "id" => "com.atproto.sync.notifyOfUpdate",
2828+ "lexicon" => 1
2929+ })
3030+end
+31
lib/atproto/com/atproto/sync/requestCrawl.ex
···11+defmodule Com.Atproto.Sync.RequestCrawl do
22+ @moduledoc false
33+ use Atex.Lexicon
44+55+ deflexicon(%{
66+ "defs" => %{
77+ "main" => %{
88+ "description" =>
99+ "Request a service to persistently crawl hosted repos. Expected use is new PDS instances declaring their existence to Relays. Does not require auth.",
1010+ "errors" => [%{"name" => "HostBanned"}],
1111+ "input" => %{
1212+ "encoding" => "application/json",
1313+ "schema" => %{
1414+ "properties" => %{
1515+ "hostname" => %{
1616+ "description" =>
1717+ "Hostname of the current service (eg, PDS) that is requesting to be crawled.",
1818+ "type" => "string"
1919+ }
2020+ },
2121+ "required" => ["hostname"],
2222+ "type" => "object"
2323+ }
2424+ },
2525+ "type" => "procedure"
2626+ }
2727+ },
2828+ "id" => "com.atproto.sync.requestCrawl",
2929+ "lexicon" => 1
3030+ })
3131+end
+238
lib/atproto/com/atproto/sync/subscribeRepos.ex
···11+defmodule Com.Atproto.Sync.SubscribeRepos do
22+ @moduledoc false
33+ use Atex.Lexicon
44+55+ deflexicon(%{
66+ "defs" => %{
77+ "account" => %{
88+ "description" =>
99+ "Represents a change to an account's status on a host (eg, PDS or Relay). The semantics of this event are that the status is at the host which emitted the event, not necessarily that at the currently active PDS. Eg, a Relay takedown would emit a takedown with active=false, even if the PDS is still active.",
1010+ "properties" => %{
1111+ "active" => %{
1212+ "description" =>
1313+ "Indicates that the account has a repository which can be fetched from the host that emitted this event.",
1414+ "type" => "boolean"
1515+ },
1616+ "did" => %{"format" => "did", "type" => "string"},
1717+ "seq" => %{"type" => "integer"},
1818+ "status" => %{
1919+ "description" =>
2020+ "If active=false, this optional field indicates a reason for why the account is not active.",
2121+ "knownValues" => [
2222+ "takendown",
2323+ "suspended",
2424+ "deleted",
2525+ "deactivated",
2626+ "desynchronized",
2727+ "throttled"
2828+ ],
2929+ "type" => "string"
3030+ },
3131+ "time" => %{"format" => "datetime", "type" => "string"}
3232+ },
3333+ "required" => ["seq", "did", "time", "active"],
3434+ "type" => "object"
3535+ },
3636+ "commit" => %{
3737+ "description" =>
3838+ "Represents an update of repository state. Note that empty commits are allowed, which include no repo data changes, but an update to rev and signature.",
3939+ "nullable" => ["since"],
4040+ "properties" => %{
4141+ "blobs" => %{
4242+ "items" => %{
4343+ "description" =>
4444+ "DEPRECATED -- will soon always be empty. List of new blobs (by CID) referenced by records in this commit.",
4545+ "type" => "cid-link"
4646+ },
4747+ "type" => "array"
4848+ },
4949+ "blocks" => %{
5050+ "description" =>
5151+ "CAR file containing relevant blocks, as a diff since the previous repo state. The commit must be included as a block, and the commit block CID must be the first entry in the CAR header 'roots' list.",
5252+ "maxLength" => 2_000_000,
5353+ "type" => "bytes"
5454+ },
5555+ "commit" => %{
5656+ "description" => "Repo commit object CID.",
5757+ "type" => "cid-link"
5858+ },
5959+ "ops" => %{
6060+ "items" => %{
6161+ "description" =>
6262+ "List of repo mutation operations in this commit (eg, records created, updated, or deleted).",
6363+ "ref" => "#repoOp",
6464+ "type" => "ref"
6565+ },
6666+ "maxLength" => 200,
6767+ "type" => "array"
6868+ },
6969+ "prevData" => %{
7070+ "description" =>
7171+ "The root CID of the MST tree for the previous commit from this repo (indicated by the 'since' revision field in this message). Corresponds to the 'data' field in the repo commit object. NOTE: this field is effectively required for the 'inductive' version of firehose.",
7272+ "type" => "cid-link"
7373+ },
7474+ "rebase" => %{
7575+ "description" => "DEPRECATED -- unused",
7676+ "type" => "boolean"
7777+ },
7878+ "repo" => %{
7979+ "description" =>
8080+ "The repo this event comes from. Note that all other message types name this field 'did'.",
8181+ "format" => "did",
8282+ "type" => "string"
8383+ },
8484+ "rev" => %{
8585+ "description" =>
8686+ "The rev of the emitted commit. Note that this information is also in the commit object included in blocks, unless this is a tooBig event.",
8787+ "format" => "tid",
8888+ "type" => "string"
8989+ },
9090+ "seq" => %{
9191+ "description" => "The stream sequence number of this message.",
9292+ "type" => "integer"
9393+ },
9494+ "since" => %{
9595+ "description" => "The rev of the last emitted commit from this repo (if any).",
9696+ "format" => "tid",
9797+ "type" => "string"
9898+ },
9999+ "time" => %{
100100+ "description" => "Timestamp of when this message was originally broadcast.",
101101+ "format" => "datetime",
102102+ "type" => "string"
103103+ },
104104+ "tooBig" => %{
105105+ "description" =>
106106+ "DEPRECATED -- replaced by #sync event and data limits. Indicates that this commit contained too many ops, or data size was too large. Consumers will need to make a separate request to get missing data.",
107107+ "type" => "boolean"
108108+ }
109109+ },
110110+ "required" => [
111111+ "seq",
112112+ "rebase",
113113+ "tooBig",
114114+ "repo",
115115+ "commit",
116116+ "rev",
117117+ "since",
118118+ "blocks",
119119+ "ops",
120120+ "blobs",
121121+ "time"
122122+ ],
123123+ "type" => "object"
124124+ },
125125+ "identity" => %{
126126+ "description" =>
127127+ "Represents a change to an account's identity. Could be an updated handle, signing key, or pds hosting endpoint. Serves as a prod to all downstream services to refresh their identity cache.",
128128+ "properties" => %{
129129+ "did" => %{"format" => "did", "type" => "string"},
130130+ "handle" => %{
131131+ "description" =>
132132+ "The current handle for the account, or 'handle.invalid' if validation fails. This field is optional, might have been validated or passed-through from an upstream source. Semantics and behaviors for PDS vs Relay may evolve in the future; see atproto specs for more details.",
133133+ "format" => "handle",
134134+ "type" => "string"
135135+ },
136136+ "seq" => %{"type" => "integer"},
137137+ "time" => %{"format" => "datetime", "type" => "string"}
138138+ },
139139+ "required" => ["seq", "did", "time"],
140140+ "type" => "object"
141141+ },
142142+ "info" => %{
143143+ "properties" => %{
144144+ "message" => %{"type" => "string"},
145145+ "name" => %{"knownValues" => ["OutdatedCursor"], "type" => "string"}
146146+ },
147147+ "required" => ["name"],
148148+ "type" => "object"
149149+ },
150150+ "main" => %{
151151+ "description" =>
152152+ "Repository event stream, aka Firehose endpoint. Outputs repo commits with diff data, and identity update events, for all repositories on the current server. See the atproto specifications for details around stream sequencing, repo versioning, CAR diff format, and more. Public and does not require auth; implemented by PDS and Relay.",
153153+ "errors" => [
154154+ %{"name" => "FutureCursor"},
155155+ %{
156156+ "description" =>
157157+ "If the consumer of the stream can not keep up with events, and a backlog gets too large, the server will drop the connection.",
158158+ "name" => "ConsumerTooSlow"
159159+ }
160160+ ],
161161+ "message" => %{
162162+ "schema" => %{
163163+ "refs" => ["#commit", "#sync", "#identity", "#account", "#info"],
164164+ "type" => "union"
165165+ }
166166+ },
167167+ "parameters" => %{
168168+ "properties" => %{
169169+ "cursor" => %{
170170+ "description" => "The last known event seq number to backfill from.",
171171+ "type" => "integer"
172172+ }
173173+ },
174174+ "type" => "params"
175175+ },
176176+ "type" => "subscription"
177177+ },
178178+ "repoOp" => %{
179179+ "description" => "A repo operation, ie a mutation of a single record.",
180180+ "nullable" => ["cid"],
181181+ "properties" => %{
182182+ "action" => %{
183183+ "knownValues" => ["create", "update", "delete"],
184184+ "type" => "string"
185185+ },
186186+ "cid" => %{
187187+ "description" => "For creates and updates, the new record CID. For deletions, null.",
188188+ "type" => "cid-link"
189189+ },
190190+ "path" => %{"type" => "string"},
191191+ "prev" => %{
192192+ "description" =>
193193+ "For updates and deletes, the previous record CID (required for inductive firehose). For creations, field should not be defined.",
194194+ "type" => "cid-link"
195195+ }
196196+ },
197197+ "required" => ["action", "path", "cid"],
198198+ "type" => "object"
199199+ },
200200+ "sync" => %{
201201+ "description" =>
202202+ "Updates the repo to a new state, without necessarily including that state on the firehose. Used to recover from broken commit streams, data loss incidents, or in situations where upstream host does not know recent state of the repository.",
203203+ "properties" => %{
204204+ "blocks" => %{
205205+ "description" =>
206206+ "CAR file containing the commit, as a block. The CAR header must include the commit block CID as the first 'root'.",
207207+ "maxLength" => 10000,
208208+ "type" => "bytes"
209209+ },
210210+ "did" => %{
211211+ "description" =>
212212+ "The account this repo event corresponds to. Must match that in the commit object.",
213213+ "format" => "did",
214214+ "type" => "string"
215215+ },
216216+ "rev" => %{
217217+ "description" =>
218218+ "The rev of the commit. This value must match that in the commit object.",
219219+ "type" => "string"
220220+ },
221221+ "seq" => %{
222222+ "description" => "The stream sequence number of this message.",
223223+ "type" => "integer"
224224+ },
225225+ "time" => %{
226226+ "description" => "Timestamp of when this message was originally broadcast.",
227227+ "format" => "datetime",
228228+ "type" => "string"
229229+ }
230230+ },
231231+ "required" => ["seq", "did", "blocks", "rev", "time"],
232232+ "type" => "object"
233233+ }
234234+ },
235235+ "id" => "com.atproto.sync.subscribeRepos",
236236+ "lexicon" => 1
237237+ })
238238+end