Current section
Files
Jump to
Current section
Files
src/atproto@identity.erl
-module(atproto@identity).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/atproto/identity.gleam").
-export([resolve_mini_doc/3, resolve_pds/3]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(
" Resolve a handle or DID to its PDS endpoint via an injected\n"
" Slingshot-compatible `resolveMiniDoc` resolver. This is not native atproto\n"
" identity resolution (DID doc / PLC / did:web / DNS); consumers depend on the\n"
" resolver service being available. URL, decoder, and `MiniDoc` come from\n"
" `atproto_core/identity`.\n"
).
-file("src/atproto/identity.gleam", 26).
-spec resolve_mini_doc(atproto@xrpc:client(), binary(), binary()) -> {ok,
atproto_core@identity:mini_doc()} |
{error, atproto_core@xrpc:xrpc_error()}.
resolve_mini_doc(Client, Resolver, Identifier) ->
gleam@result:'try'(
atproto@xrpc:get(
Client,
atproto_core@identity:mini_doc_url(Resolver, Identifier),
none
),
fun(Resp) ->
atproto@xrpc:parse(
erlang:element(4, Resp),
atproto_core@identity:mini_doc_decoder()
)
end
).
-file("src/atproto/identity.gleam", 17).
-spec resolve_pds(atproto@xrpc:client(), binary(), binary()) -> {ok, binary()} |
{error, atproto_core@xrpc:xrpc_error()}.
resolve_pds(Client, Resolver, Identifier) ->
_pipe = resolve_mini_doc(Client, Resolver, Identifier),
gleam@result:map(_pipe, fun(Doc) -> erlang:element(3, Doc) end).