This PR fixes #2. plc.directory has been set as the default host in case the option is missing in the configuration.
+3
config/runtime.exs
+3
config/runtime.exs
···
8
8
private_key:
9
9
"MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgyIpxhuDm0i3mPkrk6UdX4Sd9Jsv6YtAmSTza+A2nArShRANCAAQLF1GLueOBZOVnKWfrcnoDOO9NSRqH2utmfGMz+Rce18MDB7Z6CwFWjEq2UFYNBI4MI5cMI0+m+UYAmj4OZm+m",
10
10
key_id: "awooga"
11
+
12
+
config :atex, Atex.IdentityResolver,
13
+
directory_url: "https://plc.directory"
+26
lib/atex/config/identity_resolver.ex
+26
lib/atex/config/identity_resolver.ex
···
1
+
defmodule Atex.Config.IdentityResolver do
2
+
@moduledoc """
3
+
Configuration management for `Atex.IdentityResolver`.
4
+
5
+
Contains all configuration logic for fetching identity documents.
6
+
7
+
## Configuration
8
+
9
+
The following structure is expected in your application config:
10
+
11
+
config :atex, Atex.IdentityResolver,
12
+
directory_url: "https://plc.directory" # An address to a did:plc document host
13
+
"""
14
+
15
+
@doc """
16
+
Returns the configured URL for PLC queries.
17
+
"""
18
+
@spec directory_url :: String.t()
19
+
def directory_url(),
20
+
do:
21
+
Keyword.get(
22
+
Application.get_env(:atex, Atex.IdentityResolver, []),
23
+
:directory_url,
24
+
"https://plc.directory"
25
+
)
26
+
end
+2
-1
lib/atex/identity_resolver/did.ex
+2
-1
lib/atex/identity_resolver/did.ex
···
1
1
defmodule Atex.IdentityResolver.DID do
2
2
alias Atex.IdentityResolver.DIDDocument
3
+
alias Atex.Config.IdentityResolver, as: Config
3
4
4
5
@type resolution_result() ::
5
6
{:ok, DIDDocument.t()}
···
14
15
@spec resolve_plc(String.t()) :: resolution_result()
15
16
defp resolve_plc("did:plc:" <> _id = did) do
16
17
with {:ok, resp} when resp.status in 200..299 <-
17
-
Req.get("https://plc.directory/#{did}"),
18
+
Req.get("#{Config.directory_url()}/#{did}"),
18
19
{:ok, body} <- decode_body(resp.body),
19
20
{:ok, document} <- DIDDocument.from_json(body),
20
21
:ok <- DIDDocument.validate_for_atproto(document, did) do
History
2 rounds
1 comment
diddyfo.id
submitted
#1
2 commits
expand
collapse
84ad0605
feat: Add support for PLC endpoint configuration
883f6961
Fix runtime config error
expand 1 comment
closed without merging
diddyfo.id
submitted
#0
1 commit
expand
collapse
84ad0605
feat: Add support for PLC endpoint configuration
Merged in GitHub (https://github.com/cometsh/atex/pull/2)